mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 11:45:51 +00:00
Reduced technical debt
This commit is contained in:
parent
76004c3df9
commit
bb50dcaf73
@ -37,10 +37,7 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
|||||||
public class SlimefunItem {
|
public class SlimefunItem {
|
||||||
|
|
||||||
public static List<SlimefunItem> items = new ArrayList<>();
|
public static List<SlimefunItem> items = new ArrayList<>();
|
||||||
|
|
||||||
public static Map<String, SlimefunItem> mapID = new HashMap<>();
|
public static Map<String, SlimefunItem> mapID = new HashMap<>();
|
||||||
public static Set<String> tickers = new HashSet<>();
|
|
||||||
|
|
||||||
public static List<SlimefunItem> all = new ArrayList<>();
|
public static List<SlimefunItem> all = new ArrayList<>();
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
@ -404,7 +401,7 @@ public class SlimefunItem {
|
|||||||
for (ItemHandler h: handler) {
|
for (ItemHandler h: handler) {
|
||||||
if (h instanceof BlockTicker) {
|
if (h instanceof BlockTicker) {
|
||||||
this.ticking = true;
|
this.ticking = true;
|
||||||
tickers.add(getID());
|
SlimefunPlugin.getUtilities().tickers.add(getID());
|
||||||
this.blockTicker = (BlockTicker) h;
|
this.blockTicker = (BlockTicker) h;
|
||||||
}
|
}
|
||||||
else if (h instanceof EnergyTicker) {
|
else if (h instanceof EnergyTicker) {
|
||||||
@ -514,7 +511,7 @@ public class SlimefunItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isTicking(String item) {
|
public static boolean isTicking(String item) {
|
||||||
return tickers.contains(item);
|
return SlimefunPlugin.getUtilities().tickers.contains(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerBlockHandler(String id, SlimefunBlockHandler handler) {
|
public static void registerBlockHandler(String id, SlimefunBlockHandler handler) {
|
||||||
|
@ -208,6 +208,7 @@ public final class SlimefunSetup {
|
|||||||
new SlimefunItem(Categories.FOOD, SlimefunItems.DIET_COOKIE, "DIET_COOKIE", RecipeType.MAGIC_WORKBENCH,
|
new SlimefunItem(Categories.FOOD, SlimefunItems.DIET_COOKIE, "DIET_COOKIE", RecipeType.MAGIC_WORKBENCH,
|
||||||
new ItemStack[] {new ItemStack(Material.COOKIE), SlimefunItems.ELYTRA_SCALE, null, null, null, null, null, null, null})
|
new ItemStack[] {new ItemStack(Material.COOKIE), SlimefunItems.ELYTRA_SCALE, null, null, null, null, null, null, null})
|
||||||
.register(true, new ItemInteractionHandler() {
|
.register(true, new ItemInteractionHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onRightClick(ItemUseEvent e, Player p, ItemStack item) {
|
public boolean onRightClick(ItemUseEvent e, Player p, ItemStack item) {
|
||||||
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.DIET_COOKIE, true)) {
|
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.DIET_COOKIE, true)) {
|
||||||
|
@ -43,10 +43,7 @@ import me.mrCookieSlime.Slimefun.api.PlayerProfile;
|
|||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunBackup;
|
import me.mrCookieSlime.Slimefun.api.SlimefunBackup;
|
||||||
import me.mrCookieSlime.Slimefun.api.TickerTask;
|
import me.mrCookieSlime.Slimefun.api.TickerTask;
|
||||||
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.energy.EnergyNet;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.energy.ItemEnergy;
|
import me.mrCookieSlime.Slimefun.api.energy.ItemEnergy;
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu;
|
import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu;
|
||||||
import me.mrCookieSlime.Slimefun.api.item_transport.CargoNet;
|
import me.mrCookieSlime.Slimefun.api.item_transport.CargoNet;
|
||||||
import me.mrCookieSlime.Slimefun.autosave.BlockAutoSaver;
|
import me.mrCookieSlime.Slimefun.autosave.BlockAutoSaver;
|
||||||
@ -366,14 +363,8 @@ public final class SlimefunPlugin extends JavaPlugin {
|
|||||||
SlimefunItem.all = null;
|
SlimefunItem.all = null;
|
||||||
SlimefunItem.items = null;
|
SlimefunItem.items = null;
|
||||||
SlimefunItem.mapID = null;
|
SlimefunItem.mapID = null;
|
||||||
BlockMenuPreset.presets = null;
|
|
||||||
ChargableBlock.capacitors = null;
|
|
||||||
ChargableBlock.maxCharges = null;
|
|
||||||
AContainer.processing = null;
|
AContainer.processing = null;
|
||||||
AContainer.progress = null;
|
AContainer.progress = null;
|
||||||
EnergyNet.machinesInput = null;
|
|
||||||
EnergyNet.machinesOutput = null;
|
|
||||||
EnergyNet.machinesStorage = null;
|
|
||||||
CargoNet.faces = null;
|
CargoNet.faces = null;
|
||||||
OreWasher.items = null;
|
OreWasher.items = null;
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package me.mrCookieSlime.Slimefun.api.energy;
|
package me.mrCookieSlime.Slimefun.api.energy;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Skull;
|
||||||
|
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Math.DoubleHandler;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Math.DoubleHandler;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
|
||||||
@ -13,28 +14,19 @@ import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
|||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Skull;
|
|
||||||
|
|
||||||
public final class ChargableBlock {
|
public final class ChargableBlock {
|
||||||
|
|
||||||
private ChargableBlock() {}
|
private ChargableBlock() {}
|
||||||
|
|
||||||
public static Map<String, Integer> maxCharges = new HashMap<>();
|
|
||||||
public static Set<String> rechargeable = new HashSet<>();
|
|
||||||
public static Set<String> capacitors = new HashSet<>();
|
|
||||||
|
|
||||||
public static void registerChargableBlock(String id, int capacity, boolean recharge) {
|
public static void registerChargableBlock(String id, int capacity, boolean recharge) {
|
||||||
maxCharges.put(id, capacity);
|
SlimefunPlugin.getUtilities().blocksEnergyCapacity.put(id, capacity);
|
||||||
if (recharge) rechargeable.add(id);
|
if (recharge) SlimefunPlugin.getUtilities().rechargeableItems.add(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerCapacitor(String id, int capacity) {
|
public static void registerCapacitor(String id, int capacity) {
|
||||||
maxCharges.put(id, capacity);
|
SlimefunPlugin.getUtilities().blocksEnergyCapacity.put(id, capacity);
|
||||||
rechargeable.add(id);
|
SlimefunPlugin.getUtilities().rechargeableItems.add(id);
|
||||||
capacitors.add(id);
|
SlimefunPlugin.getUtilities().capacitorIDs.add(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isChargable(Block b) {
|
public static boolean isChargable(Block b) {
|
||||||
@ -43,13 +35,13 @@ public final class ChargableBlock {
|
|||||||
|
|
||||||
public static boolean isChargable(Location l) {
|
public static boolean isChargable(Location l) {
|
||||||
if (!BlockStorage.hasBlockInfo(l)) return false;
|
if (!BlockStorage.hasBlockInfo(l)) return false;
|
||||||
return maxCharges.containsKey(BlockStorage.checkID(l));
|
return SlimefunPlugin.getUtilities().blocksEnergyCapacity.containsKey(BlockStorage.checkID(l));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isRechargable(Block b) {
|
public static boolean isRechargable(Block b) {
|
||||||
if (!BlockStorage.hasBlockInfo(b)) return false;
|
if (!BlockStorage.hasBlockInfo(b)) return false;
|
||||||
String id = BlockStorage.checkID(b);
|
String id = BlockStorage.checkID(b);
|
||||||
return maxCharges.containsKey(id) && rechargeable.contains(id);
|
return SlimefunPlugin.getUtilities().blocksEnergyCapacity.containsKey(id) && SlimefunPlugin.getUtilities().rechargeableItems.contains(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isCapacitor(Block b) {
|
public static boolean isCapacitor(Block b) {
|
||||||
@ -58,7 +50,7 @@ public final class ChargableBlock {
|
|||||||
|
|
||||||
public static boolean isCapacitor(Location l) {
|
public static boolean isCapacitor(Location l) {
|
||||||
if (!BlockStorage.hasBlockInfo(l)) return false;
|
if (!BlockStorage.hasBlockInfo(l)) return false;
|
||||||
return capacitors.contains(BlockStorage.checkID(l));
|
return SlimefunPlugin.getUtilities().capacitorIDs.contains(BlockStorage.checkID(l));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getDefaultCapacity(Block b) {
|
public static int getDefaultCapacity(Block b) {
|
||||||
@ -67,7 +59,7 @@ public final class ChargableBlock {
|
|||||||
|
|
||||||
public static int getDefaultCapacity(Location l) {
|
public static int getDefaultCapacity(Location l) {
|
||||||
String id = BlockStorage.checkID(l);
|
String id = BlockStorage.checkID(l);
|
||||||
return id == null ? 0: maxCharges.get(id);
|
return id == null ? 0: SlimefunPlugin.getUtilities().blocksEnergyCapacity.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getCharge(Block b) {
|
public static int getCharge(Block b) {
|
||||||
@ -135,6 +127,7 @@ public final class ChargableBlock {
|
|||||||
int energy = getCharge(l);
|
int energy = getCharge(l);
|
||||||
int space = getMaxCharge(l) - energy;
|
int space = getMaxCharge(l) - energy;
|
||||||
int rest = charge;
|
int rest = charge;
|
||||||
|
|
||||||
if (space > 0 && charge > 0) {
|
if (space > 0 && charge > 0) {
|
||||||
if (space > charge) {
|
if (space > charge) {
|
||||||
setCharge(l, energy + charge);
|
setCharge(l, energy + charge);
|
||||||
@ -144,14 +137,15 @@ public final class ChargableBlock {
|
|||||||
rest = charge - space;
|
rest = charge - space;
|
||||||
setCharge(l, getMaxCharge(l));
|
setCharge(l, getMaxCharge(l));
|
||||||
}
|
}
|
||||||
if (capacitors.contains(BlockStorage.checkID(l))) {
|
|
||||||
|
if (SlimefunPlugin.getUtilities().capacitorIDs.contains(BlockStorage.checkID(l))) {
|
||||||
updateTexture(l);
|
updateTexture(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (charge < 0 && energy >= -charge) {
|
else if (charge < 0 && energy >= -charge) {
|
||||||
setCharge(l, energy + charge);
|
setCharge(l, energy + charge);
|
||||||
|
|
||||||
if (capacitors.contains(BlockStorage.checkID(l))) {
|
if (SlimefunPlugin.getUtilities().capacitorIDs.contains(BlockStorage.checkID(l))) {
|
||||||
updateTexture(l);
|
updateTexture(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,11 +158,15 @@ public final class ChargableBlock {
|
|||||||
|
|
||||||
public static int getMaxCharge(Location l) {
|
public static int getMaxCharge(Location l) {
|
||||||
Config cfg = BlockStorage.getLocationInfo(l);
|
Config cfg = BlockStorage.getLocationInfo(l);
|
||||||
|
|
||||||
if (!cfg.contains("id")) {
|
if (!cfg.contains("id")) {
|
||||||
BlockStorage.clearBlockInfo(l);
|
BlockStorage.clearBlockInfo(l);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (cfg.contains("energy-capacity")) return Integer.parseInt(cfg.getString("energy-capacity"));
|
|
||||||
|
if (cfg.contains("energy-capacity")) {
|
||||||
|
return Integer.parseInt(cfg.getString("energy-capacity"));
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
BlockStorage.addBlockInfo(l, "energy-capacity", String.valueOf(getDefaultCapacity(l)), false);
|
BlockStorage.addBlockInfo(l, "energy-capacity", String.valueOf(getDefaultCapacity(l)), false);
|
||||||
return getDefaultCapacity(l);
|
return getDefaultCapacity(l);
|
||||||
|
@ -20,40 +20,36 @@ public class EnergyNet extends Network {
|
|||||||
|
|
||||||
private static final int RANGE = 6;
|
private static final int RANGE = 6;
|
||||||
|
|
||||||
public static Set<String> machinesInput = new HashSet<>();
|
|
||||||
public static Set<String> machinesStorage = new HashSet<>();
|
|
||||||
public static Set<String> machinesOutput = new HashSet<>();
|
|
||||||
|
|
||||||
public static EnergyNetComponent getComponent(Block b) {
|
public static EnergyNetComponent getComponent(Block b) {
|
||||||
return getComponent(b.getLocation());
|
return getComponent(b.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EnergyNetComponent getComponent(String id) {
|
public static EnergyNetComponent getComponent(String id) {
|
||||||
if (machinesInput.contains(id)) return EnergyNetComponent.SOURCE;
|
if (SlimefunPlugin.getUtilities().energyNetInput.contains(id)) return EnergyNetComponent.SOURCE;
|
||||||
if (machinesStorage.contains(id)) return EnergyNetComponent.DISTRIBUTOR;
|
if (SlimefunPlugin.getUtilities().energyNetStorage.contains(id)) return EnergyNetComponent.DISTRIBUTOR;
|
||||||
if (machinesOutput.contains(id)) return EnergyNetComponent.CONSUMER;
|
if (SlimefunPlugin.getUtilities().energyNetOutput.contains(id)) return EnergyNetComponent.CONSUMER;
|
||||||
return EnergyNetComponent.NONE;
|
return EnergyNetComponent.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EnergyNetComponent getComponent(Location l) {
|
public static EnergyNetComponent getComponent(Location l) {
|
||||||
if (!BlockStorage.hasBlockInfo(l)) return EnergyNetComponent.NONE;
|
if (!BlockStorage.hasBlockInfo(l)) return EnergyNetComponent.NONE;
|
||||||
String id = BlockStorage.checkID(l);
|
String id = BlockStorage.checkID(l);
|
||||||
if (machinesInput.contains(id)) return EnergyNetComponent.SOURCE;
|
if (SlimefunPlugin.getUtilities().energyNetInput.contains(id)) return EnergyNetComponent.SOURCE;
|
||||||
if (machinesStorage.contains(id)) return EnergyNetComponent.DISTRIBUTOR;
|
if (SlimefunPlugin.getUtilities().energyNetStorage.contains(id)) return EnergyNetComponent.DISTRIBUTOR;
|
||||||
if (machinesOutput.contains(id)) return EnergyNetComponent.CONSUMER;
|
if (SlimefunPlugin.getUtilities().energyNetOutput.contains(id)) return EnergyNetComponent.CONSUMER;
|
||||||
return EnergyNetComponent.NONE;
|
return EnergyNetComponent.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerComponent(String id, EnergyNetComponent component) {
|
public static void registerComponent(String id, EnergyNetComponent component) {
|
||||||
switch (component) {
|
switch (component) {
|
||||||
case CONSUMER:
|
case CONSUMER:
|
||||||
machinesOutput.add(id);
|
SlimefunPlugin.getUtilities().energyNetOutput.add(id);
|
||||||
break;
|
break;
|
||||||
case DISTRIBUTOR:
|
case DISTRIBUTOR:
|
||||||
machinesStorage.add(id);
|
SlimefunPlugin.getUtilities().energyNetStorage.add(id);
|
||||||
break;
|
break;
|
||||||
case SOURCE:
|
case SOURCE:
|
||||||
machinesInput.add(id);
|
SlimefunPlugin.getUtilities().energyNetInput.add(id);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package me.mrCookieSlime.Slimefun.api.inventory;
|
package me.mrCookieSlime.Slimefun.api.inventory;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -17,8 +15,6 @@ import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
|||||||
|
|
||||||
public abstract class BlockMenuPreset extends ChestMenu {
|
public abstract class BlockMenuPreset extends ChestMenu {
|
||||||
|
|
||||||
public static Map<String, BlockMenuPreset> presets = new HashMap<>();
|
|
||||||
|
|
||||||
private String title;
|
private String title;
|
||||||
private Set<Integer> occupied = new HashSet<>();
|
private Set<Integer> occupied = new HashSet<>();
|
||||||
private String id;
|
private String id;
|
||||||
@ -33,7 +29,7 @@ public abstract class BlockMenuPreset extends ChestMenu {
|
|||||||
this.title = title;
|
this.title = title;
|
||||||
this.init();
|
this.init();
|
||||||
this.universal = false;
|
this.universal = false;
|
||||||
presets.put(id, this);
|
SlimefunPlugin.getUtilities().blockMenuPresets.put(id, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerEvent(ItemManipulationEvent event) {
|
public void registerEvent(ItemManipulationEvent event) {
|
||||||
@ -46,7 +42,7 @@ public abstract class BlockMenuPreset extends ChestMenu {
|
|||||||
this.title = title;
|
this.title = title;
|
||||||
this.init();
|
this.init();
|
||||||
this.universal = universal;
|
this.universal = universal;
|
||||||
presets.put(id, this);
|
SlimefunPlugin.getUtilities().blockMenuPresets.put(id, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void init();
|
public abstract void init();
|
||||||
@ -105,15 +101,16 @@ public abstract class BlockMenuPreset extends ChestMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static BlockMenuPreset getPreset(String id) {
|
public static BlockMenuPreset getPreset(String id) {
|
||||||
return id == null ? null: presets.get(id);
|
return id == null ? null: SlimefunPlugin.getUtilities().blockMenuPresets.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInventory(String id) {
|
public static boolean isInventory(String id) {
|
||||||
return presets.containsKey(id);
|
return SlimefunPlugin.getUtilities().blockMenuPresets.containsKey(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isUniversalInventory(String id) {
|
public static boolean isUniversalInventory(String id) {
|
||||||
return presets.containsKey(id) && presets.get(id).isUniversal();
|
BlockMenuPreset preset = SlimefunPlugin.getUtilities().blockMenuPresets.get(id);
|
||||||
|
return preset != null && preset.isUniversal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUniversal() {
|
public boolean isUniversal() {
|
||||||
|
@ -39,10 +39,8 @@ public class CargoNet extends Network {
|
|||||||
|
|
||||||
private static final int RANGE = 5;
|
private static final int RANGE = 5;
|
||||||
public static List<BlockFace> faces = Arrays.asList(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST);
|
public static List<BlockFace> faces = Arrays.asList(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST);
|
||||||
public static Map<Location, Integer> roundRobin = new HashMap<>();
|
|
||||||
public static Set<ItemRequest> requests = new HashSet<>();
|
|
||||||
|
|
||||||
private static int[] slots = new int[] {19, 20, 21, 28, 29, 30, 37, 38, 39};
|
private static final int[] slots = new int[] {19, 20, 21, 28, 29, 30, 37, 38, 39};
|
||||||
|
|
||||||
// Chest Terminal Stuff
|
// Chest Terminal Stuff
|
||||||
private static final ChestTerminalSorter sorter = new ChestTerminalSorter();
|
private static final ChestTerminalSorter sorter = new ChestTerminalSorter();
|
||||||
@ -207,7 +205,7 @@ public class CargoNet extends Network {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (menu.getItemInSlot(17) != null) {
|
if (menu.getItemInSlot(17) != null) {
|
||||||
requests.add(new ItemRequest(bus, 17, menu.getItemInSlot(17), ItemTransportFlow.INSERT));
|
SlimefunPlugin.getUtilities().itemRequests.add(new ItemRequest(bus, 17, menu.getItemInSlot(17), ItemTransportFlow.INSERT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +233,7 @@ public class CargoNet extends Network {
|
|||||||
|
|
||||||
BlockStorage.addBlockInfo(bus, "index", String.valueOf(index));
|
BlockStorage.addBlockInfo(bus, "index", String.valueOf(index));
|
||||||
|
|
||||||
requests.add(new ItemRequest(bus, 17, items.get(index), ItemTransportFlow.WITHDRAW));
|
SlimefunPlugin.getUtilities().itemRequests.add(new ItemRequest(bus, 17, items.get(index), ItemTransportFlow.WITHDRAW));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -245,11 +243,11 @@ public class CargoNet extends Network {
|
|||||||
|
|
||||||
ItemStack sendingItem = menu.getItemInSlot(TERMINAL_OUT_SLOT);
|
ItemStack sendingItem = menu.getItemInSlot(TERMINAL_OUT_SLOT);
|
||||||
if (sendingItem != null) {
|
if (sendingItem != null) {
|
||||||
requests.add(new ItemRequest(terminal, TERMINAL_OUT_SLOT, sendingItem, ItemTransportFlow.INSERT));
|
SlimefunPlugin.getUtilities().itemRequests.add(new ItemRequest(terminal, TERMINAL_OUT_SLOT, sendingItem, ItemTransportFlow.INSERT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator<ItemRequest> iterator = requests.iterator();
|
Iterator<ItemRequest> iterator = SlimefunPlugin.getUtilities().itemRequests.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
ItemRequest request = iterator.next();
|
ItemRequest request = iterator.next();
|
||||||
if (terminals.contains(request.getTerminal()) || imports.contains(request.getTerminal()) || exports.contains(request.getTerminal())) {
|
if (terminals.contains(request.getTerminal()) || imports.contains(request.getTerminal()) || exports.contains(request.getTerminal())) {
|
||||||
@ -346,11 +344,11 @@ public class CargoNet extends Network {
|
|||||||
List<Location> outputlist = new ArrayList<>(output.get(frequency));
|
List<Location> outputlist = new ArrayList<>(output.get(frequency));
|
||||||
|
|
||||||
if (roundrobin) {
|
if (roundrobin) {
|
||||||
if (!roundRobin.containsKey(input)) {
|
if (!SlimefunPlugin.getUtilities().roundRobin.containsKey(input)) {
|
||||||
roundRobin.put(input, 0);
|
SlimefunPlugin.getUtilities().roundRobin.put(input, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cIndex = roundRobin.get(input);
|
int cIndex = SlimefunPlugin.getUtilities().roundRobin.get(input);
|
||||||
|
|
||||||
if (cIndex < outputlist.size()) {
|
if (cIndex < outputlist.size()) {
|
||||||
for (int i = 0; i < cIndex; i++) {
|
for (int i = 0; i < cIndex; i++) {
|
||||||
@ -362,7 +360,7 @@ public class CargoNet extends Network {
|
|||||||
}
|
}
|
||||||
else cIndex = 1;
|
else cIndex = 1;
|
||||||
|
|
||||||
roundRobin.put(input, cIndex);
|
SlimefunPlugin.getUtilities().roundRobin.put(input, cIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Location out : outputlist) {
|
for (Location out : outputlist) {
|
||||||
@ -505,7 +503,7 @@ public class CargoNet extends Network {
|
|||||||
stack.setItemMeta(im);
|
stack.setItemMeta(im);
|
||||||
menu.replaceExistingItem(slot, stack);
|
menu.replaceExistingItem(slot, stack);
|
||||||
menu.addMenuClickHandler(slot, (p, sl, is, action) -> {
|
menu.addMenuClickHandler(slot, (p, sl, is, action) -> {
|
||||||
requests.add(new ItemRequest(l, 44, new CustomItem(item.getItem(), action.isRightClicked() ? (item.getAmount() > item.getItem().getMaxStackSize() ? item.getItem().getMaxStackSize(): item.getAmount()): 1), ItemTransportFlow.WITHDRAW));
|
SlimefunPlugin.getUtilities().itemRequests.add(new ItemRequest(l, 44, new CustomItem(item.getItem(), action.isRightClicked() ? (item.getAmount() > item.getItem().getMaxStackSize() ? item.getItem().getMaxStackSize(): item.getAmount()): 1), ItemTransportFlow.WITHDRAW));
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -24,8 +24,10 @@ import me.mrCookieSlime.Slimefun.ancient_altar.AltarRecipe;
|
|||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
import me.mrCookieSlime.Slimefun.api.GuideHandler;
|
import me.mrCookieSlime.Slimefun.api.GuideHandler;
|
||||||
import me.mrCookieSlime.Slimefun.api.PlayerProfile;
|
import me.mrCookieSlime.Slimefun.api.PlayerProfile;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu;
|
import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu;
|
||||||
import me.mrCookieSlime.Slimefun.api.item_transport.CargoTransportEvent;
|
import me.mrCookieSlime.Slimefun.api.item_transport.CargoTransportEvent;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.item_transport.ItemRequest;
|
||||||
import me.mrCookieSlime.Slimefun.hooks.github.Contributor;
|
import me.mrCookieSlime.Slimefun.hooks.github.Contributor;
|
||||||
import me.mrCookieSlime.Slimefun.hooks.github.GitHubConnector;
|
import me.mrCookieSlime.Slimefun.hooks.github.GitHubConnector;
|
||||||
|
|
||||||
@ -44,6 +46,20 @@ public final class Utilities {
|
|||||||
public Set<ItemStack> radioactiveItems = new HashSet<>();
|
public Set<ItemStack> radioactiveItems = new HashSet<>();
|
||||||
public Map<String, Set<ItemHandler>> itemHandlers = new HashMap<>();
|
public Map<String, Set<ItemHandler>> itemHandlers = new HashMap<>();
|
||||||
public Map<String, SlimefunBlockHandler> blockHandlers = new HashMap<>();
|
public Map<String, SlimefunBlockHandler> blockHandlers = new HashMap<>();
|
||||||
|
public Set<String> tickers = new HashSet<>();
|
||||||
|
|
||||||
|
public Map<String, Integer> blocksEnergyCapacity = new HashMap<>();
|
||||||
|
public Set<String> rechargeableItems = new HashSet<>();
|
||||||
|
public Set<String> capacitorIDs = new HashSet<>();
|
||||||
|
|
||||||
|
public Set<String> energyNetInput = new HashSet<>();
|
||||||
|
public Set<String> energyNetStorage = new HashSet<>();
|
||||||
|
public Set<String> energyNetOutput = new HashSet<>();
|
||||||
|
|
||||||
|
public Map<Location, Integer> roundRobin = new HashMap<>();
|
||||||
|
public Set<ItemRequest> itemRequests = new HashSet<>();
|
||||||
|
|
||||||
|
public Map<String, BlockMenuPreset> blockMenuPresets = new HashMap<>();
|
||||||
|
|
||||||
public List<Category> currentlyEnabledCategories = new ArrayList<>();
|
public List<Category> currentlyEnabledCategories = new ArrayList<>();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user