mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
[CI skip] More refactoring
This commit is contained in:
parent
aaff35152a
commit
c3f6eb3a3d
@ -48,6 +48,7 @@
|
||||
* Fixed a translation not showing properly
|
||||
* Fixed #1577
|
||||
* Fixed #1597
|
||||
* Fixed disabled Slimefun Addons not showing under /sf versions
|
||||
|
||||
## Release Candidate 6 (16 Feb 2020)
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation {
|
||||
actions.add(new PlayerRunnable(1) {
|
||||
|
||||
@Override
|
||||
public void run(final Player p) {
|
||||
public void run(Player p) {
|
||||
Slimefun.runSync(() -> openCategory(profile, category, survival, 1), 1L);
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation {
|
||||
actions.add(new PlayerRunnable(1) {
|
||||
|
||||
@Override
|
||||
public void run(final Player p) {
|
||||
public void run(Player p) {
|
||||
Slimefun.runSync(() -> openCategory(profile, category, survival, 1), 1L);
|
||||
}
|
||||
|
||||
@ -196,8 +196,8 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation {
|
||||
actions.add(new PlayerRunnable(2) {
|
||||
|
||||
@Override
|
||||
public void run(final Player p) {
|
||||
if (!Research.isResearching(p)) {
|
||||
public void run(Player p) {
|
||||
if (!SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().contains(p.getUniqueId())) {
|
||||
if (research.canUnlock(p)) {
|
||||
if (profile.hasUnlocked(research)) {
|
||||
openCategory(profile, category, true, page);
|
||||
@ -271,7 +271,7 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation {
|
||||
pageMessage.addClickEvent(new PlayerRunnable(2) {
|
||||
|
||||
@Override
|
||||
public void run(final Player p) {
|
||||
public void run(Player p) {
|
||||
openMainMenu(profile, survival, 1);
|
||||
}
|
||||
|
||||
|
@ -222,9 +222,8 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
|
||||
if (Slimefun.hasPermission(p, sfitem, false)) {
|
||||
menu.addItem(index, new CustomItem(Material.BARRIER, "&r" + ItemUtils.getItemName(sfitem.getItem()), "&4&lLOCKED", "", "&a> Click to unlock", "", "&7Cost: &b" + research.getCost() + " Level"));
|
||||
menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
|
||||
if (!Research.isResearching(pl)) {
|
||||
if (!SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().contains(pl.getUniqueId())) {
|
||||
if (research.canUnlock(pl)) {
|
||||
|
||||
if (profile.hasUnlocked(research)) {
|
||||
openCategory(profile, category, true, page);
|
||||
}
|
||||
@ -243,7 +242,9 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
|
||||
}
|
||||
}
|
||||
}
|
||||
else SlimefunPlugin.getLocal().sendMessage(pl, "messages.not-enough-xp", true);
|
||||
else {
|
||||
SlimefunPlugin.getLocal().sendMessage(pl, "messages.not-enough-xp", true);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
@ -19,9 +19,9 @@ import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.CargoNet;
|
||||
|
||||
public class CargoManagerBlock extends SlimefunItem {
|
||||
public class CargoManager extends SlimefunItem {
|
||||
|
||||
public CargoManagerBlock(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
public CargoManager(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
|
||||
registerBlockHandler(getID(), (p, b, tool, reason) -> {
|
@ -8,10 +8,10 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.GeneratorTicker;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
import me.mrCookieSlime.Slimefun.api.energy.EnergyTicker;
|
||||
|
||||
public abstract class SolarGenerator extends SimpleSlimefunItem<EnergyTicker> {
|
||||
public abstract class SolarGenerator extends SimpleSlimefunItem<GeneratorTicker> {
|
||||
|
||||
public SolarGenerator(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
@ -25,8 +25,8 @@ public abstract class SolarGenerator extends SimpleSlimefunItem<EnergyTicker> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnergyTicker getItemHandler() {
|
||||
return new EnergyTicker() {
|
||||
public GeneratorTicker getItemHandler() {
|
||||
return new GeneratorTicker() {
|
||||
|
||||
@Override
|
||||
public double generateEnergy(Location l, SlimefunItem item, Config data) {
|
||||
|
@ -45,7 +45,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RepairedSp
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.AdvancedCargoOutputNode;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoConnector;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoInputNode;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoManagerBlock;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoManager;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoOutputNode;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.ReactorAccessPort;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.TrashCan;
|
||||
@ -3136,7 +3136,7 @@ public final class SlimefunItemSetup {
|
||||
new CustomItem(SlimefunItems.CARGO_MOTOR, 4))
|
||||
.register(plugin);
|
||||
|
||||
new CargoManagerBlock(Categories.CARGO, (SlimefunItemStack) SlimefunItems.CARGO_MANAGER, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new CargoManager(Categories.CARGO, (SlimefunItemStack) SlimefunItems.CARGO_MANAGER, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new ItemStack[] {null, SlimefunItems.HOLOGRAM_PROJECTOR, null, SlimefunItems.REINFORCED_PLATE, SlimefunItems.CARGO_MOTOR, SlimefunItems.REINFORCED_PLATE, SlimefunItems.ALUMINUM_BRONZE_INGOT, SlimefunItems.ANDROID_MEMORY_CORE, SlimefunItems.ALUMINUM_BRONZE_INGOT})
|
||||
.register(plugin);
|
||||
|
||||
|
@ -15,6 +15,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Lists.Categories;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
@ -32,10 +33,10 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
*/
|
||||
public class Category implements Keyed {
|
||||
|
||||
private final NamespacedKey key;
|
||||
private final ItemStack item;
|
||||
private final List<SlimefunItem> items;
|
||||
private final int tier;
|
||||
protected final NamespacedKey key;
|
||||
protected final ItemStack item;
|
||||
protected final List<SlimefunItem> items;
|
||||
protected final int tier;
|
||||
|
||||
/**
|
||||
* Constructs a Category with the given display item.
|
||||
@ -51,6 +52,14 @@ public class Category implements Keyed {
|
||||
this(item, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@link Category} with the given {@link NamespacedKey} as an identifier
|
||||
* and the given {@link ItemStack} as its display item.
|
||||
* The tier is set to a default value of {@code 3}.
|
||||
*
|
||||
* @param key The {@link NamespacedKey} that is used to identify this {@link Category}
|
||||
* @param item The {@link ItemStack} that is used to display this {@link Category}
|
||||
*/
|
||||
public Category(NamespacedKey key, ItemStack item) {
|
||||
this(key, item, 3);
|
||||
}
|
||||
@ -71,6 +80,14 @@ public class Category implements Keyed {
|
||||
this(new NamespacedKey(SlimefunPlugin.instance, "invalid_category"), item, tier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@link Category} with the given {@link NamespacedKey} as an identifier
|
||||
* and the given {@link ItemStack} as its display item.
|
||||
*
|
||||
* @param key The {@link NamespacedKey} that is used to identify this {@link Category}
|
||||
* @param item The {@link ItemStack} that is used to display this {@link Category}
|
||||
* @param tier The tier of this {@link Category}, higher tiers will make this {@link Category} appear further down in the {@link SlimefunGuide}
|
||||
*/
|
||||
public Category(NamespacedKey key, ItemStack item, int tier) {
|
||||
this.item = item;
|
||||
this.key = key;
|
||||
@ -110,20 +127,21 @@ public class Category implements Keyed {
|
||||
}
|
||||
|
||||
/**
|
||||
* Bounds the provided {@link SlimefunItem} to this category.
|
||||
* Adds the given {@link SlimefunItem} to this {@link Category}.
|
||||
*
|
||||
* @param item the SlimefunItem to bound to this category
|
||||
*
|
||||
* @since 4.0
|
||||
* @param item the {@link SlimefunItem} that should be added to this {@link Category}
|
||||
*/
|
||||
public void add(SlimefunItem item) {
|
||||
items.add(item);
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return item.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns a localized display item of this {@link Category}
|
||||
* for the specified {@link Player}.
|
||||
*
|
||||
* @param p The Player to create this {@link ItemStack} for
|
||||
* @return A localized display item for this {@link Category}
|
||||
*/
|
||||
public ItemStack getItem(Player p) {
|
||||
return new CustomItem(item, meta -> {
|
||||
String name = SlimefunPlugin.getLocal().getCategoryName(p, getKey());
|
||||
@ -141,11 +159,9 @@ public class Category implements Keyed {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of SlimefunItems bound to this category.
|
||||
* Returns all instances of {@link SlimefunItem} bound to this {@link Category}.
|
||||
*
|
||||
* @return the list of SlimefunItems bound to this category
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public List<SlimefunItem> getItems() {
|
||||
return this.items;
|
||||
@ -153,10 +169,9 @@ public class Category implements Keyed {
|
||||
|
||||
/**
|
||||
* Returns the tier of this category.
|
||||
* The tier determines the position of this {@link Category} in the {@link SlimefunGuide}.
|
||||
*
|
||||
* @return the tier of this category
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public int getTier() {
|
||||
return tier;
|
||||
@ -164,7 +179,7 @@ public class Category implements Keyed {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Slimefun Category {" + item.getItemMeta().getDisplayName() + ",tier=" + tier + "}";
|
||||
return "Slimefun Category {" + key + ",tier=" + tier + "}";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -83,7 +83,9 @@ public class LockedCategory extends Category {
|
||||
* @see #removeParent(Category)
|
||||
*/
|
||||
public void addParent(Category category) {
|
||||
if (category == this || category == null) throw new IllegalArgumentException("Category '" + this.getItem().getItemMeta().getDisplayName() + "' cannot be a parent of itself or have a 'null' parent.");
|
||||
if (category == this || category == null) {
|
||||
throw new IllegalArgumentException("Category '" + item.getItemMeta().getDisplayName() + "' cannot be a parent of itself or have a 'null' parent.");
|
||||
}
|
||||
|
||||
this.parents.add(category);
|
||||
}
|
||||
|
@ -150,12 +150,10 @@ public class Research implements Keyed {
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlocks the research for the specified player.
|
||||
* Unlocks this {@link Research} for the specified {@link Player}.
|
||||
*
|
||||
* @param p Player to unlock the research
|
||||
* @param p The {@link Player} for which to unlock this {@link Research}
|
||||
* @param instant Whether to unlock the research instantly
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public void unlock(final Player p, boolean instant) {
|
||||
if (!instant) {
|
||||
@ -208,9 +206,7 @@ public class Research implements Keyed {
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the research.
|
||||
*
|
||||
* @since 4.0
|
||||
* Registers this {@link Research}.
|
||||
*/
|
||||
public void register() {
|
||||
SlimefunPlugin.getResearchCfg().setDefaultValue("enable-researching", true);
|
||||
@ -242,6 +238,7 @@ public class Research implements Keyed {
|
||||
}
|
||||
}
|
||||
|
||||
// Temporary migration method from ids to Namespaced Keys.
|
||||
private void migrate(int id, String path) {
|
||||
if (SlimefunPlugin.getResearchCfg().contains(id + ".enabled")) {
|
||||
SlimefunPlugin.getResearchCfg().setValue(path + ".enabled", SlimefunPlugin.getResearchCfg().getBoolean(id + ".enabled"));
|
||||
@ -255,24 +252,10 @@ public class Research implements Keyed {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if the specified player is currently unlocking a research.
|
||||
*
|
||||
* @param p Player to check
|
||||
* @return true if the player is unlocking a research, otherwise false
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public static boolean isResearching(Player p) {
|
||||
return SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().contains(p.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to get the research with the given ID.
|
||||
* Attempts to get a {@link Research} with the given ID.
|
||||
*
|
||||
* @param id ID of the research to get
|
||||
* @return Research if found, or null
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public static Research getByID(int id) {
|
||||
for (Research research : SlimefunPlugin.getRegistry().getResearches()) {
|
||||
|
@ -33,12 +33,12 @@ import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Research;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.GeneratorTicker;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
import me.mrCookieSlime.Slimefun.api.energy.EnergyNet;
|
||||
import me.mrCookieSlime.Slimefun.api.energy.EnergyNetComponentType;
|
||||
import me.mrCookieSlime.Slimefun.api.energy.EnergyTicker;
|
||||
|
||||
public class SlimefunItem implements Placeable {
|
||||
|
||||
@ -68,7 +68,7 @@ public class SlimefunItem implements Placeable {
|
||||
private final OptionalMap<Class<? extends ItemHandler>, ItemHandler> itemhandlers = new OptionalMap<>(HashMap::new);
|
||||
private boolean ticking = false;
|
||||
private BlockTicker blockTicker;
|
||||
private EnergyTicker energyTicker;
|
||||
private GeneratorTicker energyTicker;
|
||||
|
||||
public SlimefunItem(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
this(category, item, recipeType, recipe, null);
|
||||
@ -193,7 +193,7 @@ public class SlimefunItem implements Placeable {
|
||||
return blockTicker;
|
||||
}
|
||||
|
||||
public EnergyTicker getEnergyTicker() {
|
||||
public GeneratorTicker getEnergyTicker() {
|
||||
return energyTicker;
|
||||
}
|
||||
|
||||
@ -467,8 +467,8 @@ public class SlimefunItem implements Placeable {
|
||||
SlimefunPlugin.getRegistry().getTickerBlocks().add(getID());
|
||||
blockTicker = (BlockTicker) handler;
|
||||
}
|
||||
else if (handler instanceof EnergyTicker) {
|
||||
energyTicker = (EnergyTicker) handler;
|
||||
else if (handler instanceof GeneratorTicker) {
|
||||
energyTicker = (GeneratorTicker) handler;
|
||||
EnergyNet.registerComponent(getID(), EnergyNetComponentType.GENERATOR);
|
||||
}
|
||||
}
|
||||
|
@ -31,12 +31,12 @@ import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.RecipeDisplayItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.GeneratorTicker;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock;
|
||||
import me.mrCookieSlime.Slimefun.api.energy.EnergyNetComponentType;
|
||||
import me.mrCookieSlime.Slimefun.api.energy.EnergyTicker;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
||||
@ -167,7 +167,7 @@ public abstract class AGenerator extends SlimefunItem implements RecipeDisplayIt
|
||||
|
||||
@Override
|
||||
public void preRegister() {
|
||||
addItemHandler(new EnergyTicker() {
|
||||
addItemHandler(new GeneratorTicker() {
|
||||
|
||||
@Override
|
||||
public double generateEnergy(Location l, SlimefunItem sf, Config data) {
|
||||
|
@ -33,13 +33,13 @@ import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.RecipeDisplayItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.GeneratorTicker;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock;
|
||||
import me.mrCookieSlime.Slimefun.api.energy.EnergyNetComponentType;
|
||||
import me.mrCookieSlime.Slimefun.api.energy.EnergyTicker;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
||||
@ -250,7 +250,7 @@ public abstract class AReactor extends SlimefunItem implements RecipeDisplayItem
|
||||
|
||||
@Override
|
||||
public void preRegister() {
|
||||
addItemHandler(new EnergyTicker() {
|
||||
addItemHandler(new GeneratorTicker() {
|
||||
|
||||
private final Set<Location> explode = new HashSet<>();
|
||||
|
||||
|
@ -1,19 +1,18 @@
|
||||
package me.mrCookieSlime.Slimefun.api.energy;
|
||||
package me.mrCookieSlime.Slimefun.Objects.handlers;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
|
||||
|
||||
public abstract class EnergyTicker implements ItemHandler {
|
||||
public abstract class GeneratorTicker implements ItemHandler {
|
||||
|
||||
public abstract double generateEnergy(Location l, SlimefunItem item, Config data);
|
||||
public abstract boolean explode(Location l);
|
||||
|
||||
@Override
|
||||
public Class<? extends ItemHandler> getIdentifier() {
|
||||
return EnergyTicker.class;
|
||||
return GeneratorTicker.class;
|
||||
}
|
||||
|
||||
}
|
@ -213,7 +213,7 @@ public class CargoNet extends Network {
|
||||
|
||||
if (menu.getItemInSlot(17) == null) {
|
||||
Block target = getAttachedBlock(bus.getBlock());
|
||||
ItemAndInt stack = CargoUtils.withdraw(bus.getBlock(), target, -1);
|
||||
ItemStackAndInteger stack = CargoUtils.withdraw(bus.getBlock(), target, -1);
|
||||
|
||||
if (stack != null) {
|
||||
menu.replaceExistingItem(17, stack.getItem());
|
||||
@ -354,7 +354,7 @@ public class CargoNet extends Network {
|
||||
boolean roundrobin = "true".equals(cfg.getString("round-robin"));
|
||||
|
||||
if (inputTarget != null) {
|
||||
ItemAndInt slot = CargoUtils.withdraw(input.getBlock(), inputTarget, Integer.parseInt(cfg.getString("index")));
|
||||
ItemStackAndInteger slot = CargoUtils.withdraw(input.getBlock(), inputTarget, Integer.parseInt(cfg.getString("index")));
|
||||
|
||||
if (slot != null) {
|
||||
stack = slot.getItem();
|
||||
@ -413,7 +413,7 @@ public class CargoNet extends Network {
|
||||
|
||||
//Chest Terminal Code
|
||||
if (extraChannels) {
|
||||
List<ItemAndInt> items = new ArrayList<>();
|
||||
List<ItemStackAndInteger> items = new ArrayList<>();
|
||||
|
||||
for (Location l : providers) {
|
||||
Block target = getAttachedBlock(l.getBlock());
|
||||
@ -438,7 +438,7 @@ public class CargoNet extends Network {
|
||||
if (is != null && CargoUtils.matchesFilter(l.getBlock(), is, -1)) {
|
||||
boolean add = true;
|
||||
|
||||
for (ItemAndInt item : items) {
|
||||
for (ItemStackAndInteger item : items) {
|
||||
if (SlimefunManager.isItemSimilar(is, item.getItem(), true)) {
|
||||
add = false;
|
||||
item.add(is.getAmount() + stored);
|
||||
@ -446,7 +446,7 @@ public class CargoNet extends Network {
|
||||
}
|
||||
|
||||
if (add) {
|
||||
items.add(new ItemAndInt(new CustomItem(is, 1), is.getAmount() + stored));
|
||||
items.add(new ItemStackAndInteger(new CustomItem(is, 1), is.getAmount() + stored));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -483,7 +483,7 @@ public class CargoNet extends Network {
|
||||
int slot = terminal_slots[i];
|
||||
|
||||
if (items.size() > i + (terminal_slots.length * (page - 1))) {
|
||||
ItemAndInt item = items.get(i + (terminal_slots.length * (page - 1)));
|
||||
ItemStackAndInteger item = items.get(i + (terminal_slots.length * (page - 1)));
|
||||
|
||||
ItemStack stack = item.getItem().clone();
|
||||
ItemMeta im = stack.getItemMeta();
|
||||
@ -539,17 +539,17 @@ public class CargoNet extends Network {
|
||||
return freq;
|
||||
}
|
||||
|
||||
private void handleWithdraw(DirtyChestMenu menu, List<ItemAndInt> items, Location l) {
|
||||
private void handleWithdraw(DirtyChestMenu menu, List<ItemStackAndInteger> items, Location l) {
|
||||
for (int slot : menu.getPreset().getSlotsAccessedByItemTransport(menu, ItemTransportFlow.WITHDRAW, null)) {
|
||||
filter(menu.getItemInSlot(slot), items, l);
|
||||
}
|
||||
}
|
||||
|
||||
private void filter(ItemStack is, List<ItemAndInt> items, Location l) {
|
||||
private void filter(ItemStack is, List<ItemStackAndInteger> items, Location l) {
|
||||
if (is != null && CargoUtils.matchesFilter(l.getBlock(), is, -1)) {
|
||||
boolean add = true;
|
||||
|
||||
for (ItemAndInt item : items) {
|
||||
for (ItemStackAndInteger item : items) {
|
||||
if (SlimefunManager.isItemSimilar(is, item.getItem(), true)) {
|
||||
add = false;
|
||||
item.add(is.getAmount());
|
||||
@ -557,7 +557,7 @@ public class CargoNet extends Network {
|
||||
}
|
||||
|
||||
if (add) {
|
||||
items.add(new ItemAndInt(new CustomItem(is, 1), is.getAmount()));
|
||||
items.add(new ItemStackAndInteger(new CustomItem(is, 1), is.getAmount()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ public final class CargoUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemAndInt withdraw(Block node, Block target, int index) {
|
||||
public static ItemStackAndInteger withdraw(Block node, Block target, int index) {
|
||||
DirtyChestMenu menu = getChestMenu(target);
|
||||
|
||||
if (menu != null) {
|
||||
@ -95,7 +95,7 @@ public final class CargoUtils {
|
||||
|
||||
if (matchesFilter(node, is, index)) {
|
||||
menu.replaceExistingItem(slot, null);
|
||||
return new ItemAndInt(is.clone(), slot);
|
||||
return new ItemStackAndInteger(is.clone(), slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -121,7 +121,7 @@ public final class CargoUtils {
|
||||
|
||||
if (matchesFilter(node, is, index)) {
|
||||
inv.setItem(slot, null);
|
||||
return new ItemAndInt(is.clone(), slot);
|
||||
return new ItemStackAndInteger(is.clone(), slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,12 @@ package me.mrCookieSlime.Slimefun.api.item_transport;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ItemAndInt {
|
||||
class ItemStackAndInteger {
|
||||
|
||||
private final ItemStack item;
|
||||
private int number;
|
||||
|
||||
public ItemAndInt(ItemStack item, int amount) {
|
||||
public ItemStackAndInteger(ItemStack item, int amount) {
|
||||
this.number = amount;
|
||||
this.item = item;
|
||||
}
|
Loading…
Reference in New Issue
Block a user