diff --git a/CHANGELOG.md b/CHANGELOG.md index a69c8c260..d8d87341f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java index 09eca823f..9662b87f3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java @@ -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); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java index ddf6d5ec0..7f3e08395 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java @@ -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; }); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManagerBlock.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java similarity index 92% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManagerBlock.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java index 7561b5730..825dd1c20 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManagerBlock.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java @@ -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) -> { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java index 12ef680dd..c6c0e301f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java @@ -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 { +public abstract class SolarGenerator extends SimpleSlimefunItem { 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 { } @Override - public EnergyTicker getItemHandler() { - return new EnergyTicker() { + public GeneratorTicker getItemHandler() { + return new GeneratorTicker() { @Override public double generateEnergy(Location l, SlimefunItem item, Config data) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java index bf5082971..e4ba3368f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java @@ -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); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java index db3e9744b..88c3ca044 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java @@ -135,7 +135,7 @@ public class AncientAltarTask implements Runnable { AncientAltarListener listener = SlimefunPlugin.getAncientAltarListener(); pedestals.forEach(b -> listener.getAltarsInUse().remove(b.getLocation())); - + // This should re-enable altar blocks on craft completion. listener.getAltarsInUse().remove(altar.getLocation()); altars.remove(altar); diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java index bfab15722..525cb4324 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java @@ -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 items; - private final int tier; + protected final NamespacedKey key; + protected final ItemStack item; + protected final List items; + protected final int tier; /** * Constructs a Category with the given display item. @@ -50,7 +51,15 @@ public class Category implements Keyed { public Category(ItemStack item) { 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); } @@ -70,7 +79,15 @@ public class Category implements Keyed { public Category(ItemStack item, int tier) { 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 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 + "}"; } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/LockedCategory.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/LockedCategory.java index 2d0f47575..4e6e85e6e 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/LockedCategory.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/LockedCategory.java @@ -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); } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/Research.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/Research.java index 814792d4b..683cd3555 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/Research.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/Research.java @@ -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 instant Whether to unlock the research instantly - * - * @since 4.0 + * @param p The {@link Player} for which to unlock this {@link Research} + * @param instant Whether to unlock the research instantly */ 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()) { diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java index fb90045d0..386f500ba 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java @@ -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, 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); } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java index b8503c405..d6ffa9e0d 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java @@ -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) { diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AReactor.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AReactor.java index 796ba6c2c..439ce885f 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AReactor.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AReactor.java @@ -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 explode = new HashSet<>(); diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/energy/EnergyTicker.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/GeneratorTicker.java similarity index 64% rename from src/main/java/me/mrCookieSlime/Slimefun/api/energy/EnergyTicker.java rename to src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/GeneratorTicker.java index 29be3bc11..0f27fe3d5 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/energy/EnergyTicker.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/GeneratorTicker.java @@ -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 getIdentifier() { - return EnergyTicker.class; + return GeneratorTicker.class; } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/CargoNet.java b/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/CargoNet.java index 8504b89ea..8edc6e59a 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/CargoNet.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/CargoNet.java @@ -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 items = new ArrayList<>(); + List 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 items, Location l) { + private void handleWithdraw(DirtyChestMenu menu, List 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 items, Location l) { + private void filter(ItemStack is, List 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())); } } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/CargoUtils.java b/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/CargoUtils.java index 3c2424064..a70a9bfe0 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/CargoUtils.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/CargoUtils.java @@ -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); } } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/ItemAndInt.java b/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/ItemStackAndInteger.java similarity index 80% rename from src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/ItemAndInt.java rename to src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/ItemStackAndInteger.java index baf4c6f77..75cbde684 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/ItemAndInt.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/ItemStackAndInteger.java @@ -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; }