diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ae63b79f..b6b7a95bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,11 +50,13 @@ #### Additions * Added GEOResourceGenerationEvent * Added SlimefunGuide-Options API +* Added 1.13 backwards compatibility #### Changes #### Fixes * Fixed error message when clicking empty slots in the Slimefun Guide +* Fixed #1779 ## Release Candidate 10 (28 Mar 2020) diff --git a/lib/EmeraldEnchants v2.0.jar b/lib/EmeraldEnchants v2.0.jar deleted file mode 100644 index 388566246..000000000 Binary files a/lib/EmeraldEnchants v2.0.jar and /dev/null differ diff --git a/pom.xml b/pom.xml index ef9ac8a62..0e775628c 100644 --- a/pom.xml +++ b/pom.xml @@ -14,6 +14,10 @@ 1.8 UTF-8 + + 1.15.2 + https://hub.spigotmc.org/javadocs/bukkit/ + TheBusyBiscuit_Slimefun4 thebusybiscuit-github @@ -135,7 +139,7 @@ - https://hub.spigotmc.org/javadocs/bukkit/ + ${bukkit.javadocs} @@ -152,6 +156,10 @@ Slimefun4 - Implementations io.github.thebusybiscuit.slimefun4.implementation* + + Slimefun4 - Common utility packages + io.github.thebusybiscuit.slimefun4.utils* + Slimefun4 - Item Implementations io.github.thebusybiscuit.slimefun4.implementation.items* @@ -194,7 +202,7 @@ org.bukkit bukkit - 1.15.2-R0.1-SNAPSHOT + ${bukkit.version}-R0.1-SNAPSHOT provided @@ -208,7 +216,7 @@ com.github.thebusybiscuit CS-CoreLib2 - bd12910bdb + 0.12 compile diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SeasonalCategory.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/categories/SeasonalCategory.java similarity index 71% rename from src/main/java/me/mrCookieSlime/Slimefun/Objects/SeasonalCategory.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/core/categories/SeasonalCategory.java index a103905e9..e1d9710b3 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SeasonalCategory.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/categories/SeasonalCategory.java @@ -1,16 +1,17 @@ -package me.mrCookieSlime.Slimefun.Objects; +package io.github.thebusybiscuit.slimefun4.core.categories; +import java.time.LocalDate; import java.time.Month; -import java.util.Calendar; import org.bukkit.NamespacedKey; import org.bukkit.inventory.ItemStack; +import me.mrCookieSlime.Slimefun.Objects.Category; +import me.mrCookieSlime.Slimefun.Objects.LockedCategory; + /** * Represents a {@link Category} that is only displayed in the Guide during - * a specified month. - *

- * See {@link Category} for the complete documentation. + * a specified {@link Month}. * * @author TheBusyBiscuit * @@ -40,9 +41,9 @@ public class SeasonalCategory extends Category { } /** - * Gets the month during which the category should be displayed. + * This method returns the {@link Month} in which this {@link SeasonalCategory} will appear. * - * @return the id of the month this {@link SeasonalCategory} is assigned to (from 1 = January ; to 12 = December) + * @return the {@link Month} in which this {@link SeasonalCategory} appears */ public Month getMonth() { return month; @@ -54,8 +55,7 @@ public class SeasonalCategory extends Category { * * @return true if it should, otherwise false */ - public boolean isUnlocked() { - Calendar calendar = Calendar.getInstance(); - return month.ordinal() == calendar.get(Calendar.MONTH); + public boolean isVisible() { + return month == LocalDate.now().getMonth(); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/categories/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/categories/package-info.java new file mode 100644 index 000000000..e27036876 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/categories/package-info.java @@ -0,0 +1,6 @@ +/** + * This package stores API classes that are centered around the extension of the + * {@link me.mrCookieSlime.Slimefun.Objects.Category} class, such as + * {@link me.mrCookieSlime.Slimefun.Objects.SeasonalCategory} for example. + */ +package io.github.thebusybiscuit.slimefun4.core.categories; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java index f52ace746..a98e5bdfd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java @@ -1,6 +1,5 @@ package io.github.thebusybiscuit.slimefun4.core.commands; -import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -16,7 +15,7 @@ import me.mrCookieSlime.Slimefun.SlimefunPlugin; class SlimefunTabCompleter implements TabCompleter { - private static final int MAX_SUGGESTIONS = 50; + private static final int MAX_SUGGESTIONS = 80; private final SlimefunCommand command; @@ -68,17 +67,17 @@ class SlimefunTabCompleter implements TabCompleter { if (string.equals("")) return list; String input = string.toLowerCase(Locale.ROOT); - List returnList = new ArrayList<>(); + List returnList = new LinkedList<>(); for (String item : list) { - if (item.contains(input)) { + if (item.toLowerCase(Locale.ROOT).contains(input)) { returnList.add(item); if (returnList.size() >= MAX_SUGGESTIONS) { break; } } - else if (item.equals(input)) { + else if (item.equalsIgnoreCase(input)) { return Collections.emptyList(); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java index 239850316..b448c82b3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; +import java.util.Locale; import java.util.Optional; import org.bukkit.command.CommandSender; @@ -41,7 +42,7 @@ class GiveCommand extends SubCommand { if (player.isPresent()) { Player p = player.get(); - SlimefunItem sfItem = SlimefunItem.getByID(args[2].toUpperCase()); + SlimefunItem sfItem = SlimefunItem.getByID(args[2].toUpperCase(Locale.ROOT)); if (sfItem != null) { int amount = parseAmount(args); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java index 3d4245674..8e4a99396 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java @@ -33,6 +33,7 @@ class StatsCommand extends SubCommand { if (args.length > 1) { if (sender.hasPermission("slimefun.stats.others") || sender instanceof ConsoleCommandSender) { Optional player = PlayerList.findByName(args[1]); + if (player.isPresent()) { PlayerProfile.get(player.get(), profile -> profile.sendStats(sender)); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java index 7d7e4d506..ee988c487 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java @@ -1,8 +1,6 @@ package io.github.thebusybiscuit.slimefun4.core.services.localization; import org.bukkit.Server; -import org.bukkit.World; -import org.bukkit.World.Environment; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; 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 63fd79351..6ccaa49fd 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 @@ -13,6 +13,7 @@ import io.github.thebusybiscuit.cscorelib2.chat.ChatColors; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout; @@ -25,7 +26,6 @@ import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.LockedCategory; import me.mrCookieSlime.Slimefun.Objects.Research; -import me.mrCookieSlime.Slimefun.Objects.SeasonalCategory; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.GuideHandler; import me.mrCookieSlime.Slimefun.api.Slimefun; @@ -110,7 +110,7 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation { actions.add(null); } else if (category instanceof SeasonalCategory) { - if (((SeasonalCategory) category).isUnlocked()) { + if (((SeasonalCategory) category).isVisible()) { texts.add(ChatColors.color(ChatUtils.crop(ChatColor.GREEN, ItemUtils.getItemName(category.getItem(p))))); tooltips.add(ChatColors.color("&eClick to open the following Category:\n" + ItemUtils.getItemName(category.getItem(p)))); actions.add(new PlayerRunnable(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 a56fac865..a551608a8 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 @@ -27,6 +27,7 @@ import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.core.MultiBlock; import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory; import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation; @@ -41,7 +42,6 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.LockedCategory; import me.mrCookieSlime.Slimefun.Objects.Research; -import me.mrCookieSlime.Slimefun.Objects.SeasonalCategory; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.multiblocks.MultiBlockMachine; import me.mrCookieSlime.Slimefun.api.GuideHandler; @@ -135,7 +135,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { private boolean displayCategory(ChestMenu menu, Player p, PlayerProfile profile, boolean survival, Category category, int index) { if (!(category instanceof LockedCategory)) { - if (!(category instanceof SeasonalCategory) || ((SeasonalCategory) category).isUnlocked()) { + if (!(category instanceof SeasonalCategory) || ((SeasonalCategory) category).isVisible()) { menu.addItem(index, category.getItem(p)); menu.addMenuClickHandler(index, (pl, slot, item, action) -> { openCategory(profile, category, survival, 1); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java index 69f1dcf5f..c8e0052b5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java @@ -1,6 +1,5 @@ package io.github.thebusybiscuit.slimefun4.implementation.items; -import org.bukkit.block.Biome; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Android.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Android.java index 913c55081..d36b73fc5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Android.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Android.java @@ -9,6 +9,7 @@ import java.util.function.Predicate; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.Sound; @@ -147,8 +148,7 @@ abstract class Android extends SlimefunItem { j++; } builder.append(ScriptAction.REPEAT); - BlockStorage.addBlockInfo(b, "script", builder.toString()); - + setScript(b.getLocation(), builder.toString()); openScript(pl, b, builder.toString()); } else if (action.isRightClicked()) { @@ -161,7 +161,7 @@ abstract class Android extends SlimefunItem { } builder.append(ScriptAction.REPEAT); - BlockStorage.addBlockInfo(b, "script", builder.toString()); + setScript(b.getLocation(), builder.toString()); openScript(pl, b, builder.toString()); } @@ -283,7 +283,7 @@ abstract class Android extends SlimefunItem { script2.setValue("downloads", script2.getInt("downloads") + 1); script2.save(); - BlockStorage.addBlockInfo(b, "script", script2.getString("code")); + setScript(b.getLocation(), script2.getString("code")); openScriptEditor(pl, b); } return false; @@ -297,7 +297,7 @@ abstract class Android extends SlimefunItem { } private void uploadScript(Player p, Block b, int page) { - String code = BlockStorage.getLocationInfo(b.getLocation(), "script"); + String code = getScript(b.getLocation()); int num = 1; for (Config script : getUploadedScripts()) { @@ -339,7 +339,7 @@ abstract class Android extends SlimefunItem { menu.addItem(1, new CustomItem(SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDliZjZkYjRhZWRhOWQ4ODIyYjlmNzM2NTM4ZThjMThiOWE0ODQ0Zjg0ZWI0NTUwNGFkZmJmZWU4N2ViIn19fQ=="), "&2> Edit Script", "", "&aEdits your current Script")); menu.addMenuClickHandler(1, (pl, slot, item, action) -> { - openScript(pl, b, BlockStorage.getLocationInfo(b.getLocation(), "script")); + openScript(pl, b, getScript(b.getLocation())); return false; }); @@ -443,7 +443,7 @@ abstract class Android extends SlimefunItem { } builder.append("REPEAT"); - BlockStorage.addBlockInfo(b, "script", builder.toString()); + setScript(b.getLocation(), builder.toString()); openScript(p, b, builder.toString()); return false; @@ -474,8 +474,16 @@ abstract class Android extends SlimefunItem { } builder.append("REPEAT"); - BlockStorage.addBlockInfo(b, "script", builder.toString()); + setScript(b.getLocation(), builder.toString()); openScript(p, b, builder.toString()); } + + protected String getScript(Location l) { + return BlockStorage.getLocationInfo(l, "script"); + } + + protected void setScript(Location l, String script) { + BlockStorage.addBlockInfo(l, "script", script); + } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInstance.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInstance.java index 8215bc366..ff68ea759 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInstance.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInstance.java @@ -13,7 +13,7 @@ public class AndroidInstance { } public ProgrammableAndroid getAndroid() { - return this.android; + return android; } public Block getBlock() { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NetherStarReactor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NetherStarReactor.java index 08d68819b..b357bdc7f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NetherStarReactor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NetherStarReactor.java @@ -43,7 +43,7 @@ public abstract class NetherStarReactor extends AReactor { } @Override - public void extraTick(final Location l) { + public void extraTick(Location l) { Slimefun.runSync(() -> { for (Entity entity : ReactorHologram.getArmorStand(l, true).getNearbyEntities(5, 5, 5)) { if (entity instanceof LivingEntity) { @@ -58,6 +58,11 @@ public abstract class NetherStarReactor extends AReactor { return SlimefunItems.NETHER_ICE_COOLANT_CELL; } + @Override + public ItemStack getFuelIcon() { + return new ItemStack(Material.NETHER_STAR); + } + @Override public ItemStack getProgressBar() { return new ItemStack(Material.NETHER_STAR); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NuclearReactor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NuclearReactor.java index 31cc63ecc..b44069389 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NuclearReactor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NuclearReactor.java @@ -50,6 +50,11 @@ public abstract class NuclearReactor extends AReactor { return SlimefunItems.REACTOR_COOLANT_CELL; } + @Override + public ItemStack getFuelIcon() { + return SlimefunItems.URANIUM; + } + @Override public void extraTick(Location l) { // This machine does not need to perform anything while ticking diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BackpackListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BackpackListener.java index b619fd7c1..1acc3d121 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BackpackListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BackpackListener.java @@ -30,8 +30,14 @@ import me.mrCookieSlime.Slimefun.api.Slimefun; /** * This {@link Listener} is responsible for all events centered around a {@link SlimefunBackpack}. + * This also includes the {@link Cooler} * * @author TheBusyBiscuit + * @author Walshy + * @author NihilistBrew + * @author AtomicScience + * @author VoidAngel + * @author John000708 * * @see SlimefunBackpack * @see PlayerBackpack diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DispenserListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DispenserListener.java index da40c1cc3..8c6a18166 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DispenserListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DispenserListener.java @@ -14,6 +14,16 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockDispenseHandler; import me.mrCookieSlime.Slimefun.api.BlockStorage; +/** + * This {@link Listener} listens to the {@link BlockDispenseEvent} and calls the + * {@link BlockDispenseHandler} as a result of that. + * + * @author TheBusyBiscuit + * @author MisterErwin + * + * @see BlockDispenseHandler + * + */ public class DispenserListener implements Listener { public DispenserListener(SlimefunPlugin plugin) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ExplosionsListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ExplosionsListener.java index fa3a53dcc..e47de3035 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ExplosionsListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ExplosionsListener.java @@ -32,6 +32,7 @@ public class ExplosionsListener implements Listener { if (id != null) { blocks.remove(); + // Hardened Glass and WitherProof blocks cannot be destroyed by explosions if (!id.equalsIgnoreCase("HARDENED_GLASS") && !SlimefunPlugin.getRegistry().getWitherProofBlocks().containsKey(id)) { boolean success = true; SlimefunItem sfItem = SlimefunItem.getByID(id); @@ -49,7 +50,5 @@ public class ExplosionsListener implements Listener { } } } - } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java index 75ca59f5d..0fdb1e059 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java @@ -14,6 +14,7 @@ import org.bukkit.entity.EnderPearl; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.event.Event; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -26,12 +27,22 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; +import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Lists.SlimefunItems; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.Slimefun; +/** + * This {@link Listener} is responsible for handling all boots provided by + * Slimefun, such as the Boots of the Stomper or any {@link SlimefunArmorPiece} that + * is a pair of boots and needs to listen to an {@link Event}. + * + * @author TheBusyBiscuit + * @author Walshy + * + */ public class SlimefunBootsListener implements Listener { private final Map> cancelledEvents = new HashMap<>(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SoulboundListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SoulboundListener.java index f20ae8d65..912266e90 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SoulboundListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SoulboundListener.java @@ -31,15 +31,20 @@ public class SoulboundListener implements Listener { for (int slot = 0; slot < p.getInventory().getSize(); slot++) { ItemStack item = p.getInventory().getItem(slot); + // Store soulbound items for later retrieval if (SlimefunUtils.isSoulbound(item)) { storeItem(p.getUniqueId(), slot, item); } } + // Remove soulbound items from our drops Iterator drops = e.getDrops().iterator(); while (drops.hasNext()) { ItemStack item = drops.next(); - if (SlimefunUtils.isSoulbound(item)) drops.remove(); + + if (SlimefunUtils.isSoulbound(item)) { + drops.remove(); + } } } @@ -51,19 +56,17 @@ public class SoulboundListener implements Listener { } private void storeItem(UUID uuid, int slot, ItemStack item) { - Map items = soulbound.computeIfAbsent(uuid, id -> new HashMap<>()); + Map items = soulbound.computeIfAbsent(uuid, uid -> new HashMap<>()); items.put(slot, item); } private void retrieveItems(Player p) { - Map items = soulbound.get(p.getUniqueId()); + Map items = soulbound.remove(p.getUniqueId()); if (items != null) { for (Map.Entry entry : items.entrySet()) { p.getInventory().setItem(entry.getKey(), entry.getValue()); } } - - soulbound.remove(p.getUniqueId()); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java index a18735217..d95fee498 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java @@ -7,11 +7,11 @@ import java.util.Random; import java.util.Set; import java.util.concurrent.ThreadLocalRandom; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.ChestedHorse; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; @@ -50,10 +50,21 @@ public class TalismanListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onDamageGet(EntityDamageEvent e) { if (e.getEntity() instanceof Player) { - if (e.getCause() == DamageCause.LAVA) Talisman.checkFor(e, SlimefunItems.TALISMAN_LAVA); - if (e.getCause() == DamageCause.DROWNING) Talisman.checkFor(e, SlimefunItems.TALISMAN_WATER); - if (e.getCause() == DamageCause.FALL) Talisman.checkFor(e, SlimefunItems.TALISMAN_ANGEL); - if (e.getCause() == DamageCause.FIRE) Talisman.checkFor(e, SlimefunItems.TALISMAN_FIRE); + if (e.getCause() == DamageCause.LAVA) { + Talisman.checkFor(e, SlimefunItems.TALISMAN_LAVA); + } + + if (e.getCause() == DamageCause.DROWNING) { + Talisman.checkFor(e, SlimefunItems.TALISMAN_WATER); + } + + if (e.getCause() == DamageCause.FALL) { + Talisman.checkFor(e, SlimefunItems.TALISMAN_ANGEL); + } + + if (e.getCause() == DamageCause.FIRE) { + Talisman.checkFor(e, SlimefunItems.TALISMAN_FIRE); + } if (e.getCause() == DamageCause.ENTITY_ATTACK) { Talisman.checkFor(e, SlimefunItems.TALISMAN_KNIGHT); @@ -64,8 +75,10 @@ public class TalismanListener implements Listener { Projectile projectile = (Projectile) ((EntityDamageByEntityEvent) e).getDamager(); if (Talisman.checkFor(e, SlimefunItems.TALISMAN_WHIRLWIND)) { - Vector direction = ((Player) e.getEntity()).getEyeLocation().getDirection().multiply(2.0); - Projectile clone = (Projectile) e.getEntity().getWorld().spawnEntity(((LivingEntity) e.getEntity()).getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), projectile.getType()); + Player p = (Player) e.getEntity(); + Vector direction = p.getEyeLocation().getDirection().multiply(2.0); + Location loc = p.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()); + Projectile clone = (Projectile) e.getEntity().getWorld().spawnEntity(loc, projectile.getType()); clone.setShooter(projectile.getShooter()); clone.setVelocity(direction); projectile.remove(); @@ -79,8 +92,10 @@ public class TalismanListener implements Listener { if (e.getEntity().getKiller() != null && !(e.getEntity() instanceof Player) && !e.getEntity().getCanPickupItems() && Talisman.checkFor(e, SlimefunItems.TALISMAN_HUNTER)) { List extraDrops = new ArrayList<>(e.getDrops()); + // Prevent doubling of items stored inside a Horse's chest if (e.getEntity() instanceof ChestedHorse) { - for (ItemStack invItem : ((ChestedHorse) e.getEntity()).getInventory().getStorageContents()) { + ChestedHorse horse = ((ChestedHorse) e.getEntity()); + for (ItemStack invItem : horse.getInventory().getStorageContents()) { extraDrops.remove(invItem); } @@ -120,6 +135,8 @@ public class TalismanListener implements Listener { item.setItemMeta(meta); int itemSlot = slot; + + // Update the item forcefully Slimefun.runSync(() -> inv.setItem(itemSlot, item), 1L); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java index 7144e5cbd..6d2845157 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java @@ -27,10 +27,11 @@ public class VanillaMachinesListener implements Listener { @EventHandler(ignoreCancelled = true) public void onGrindstone(InventoryClickEvent e) { + // The Grindstone was only ever added in MC 1.14 if (!SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) { return; } - + if (e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player && e.getInventory().getType() == InventoryType.GRINDSTONE) { ItemStack item1 = e.getInventory().getContents()[0]; ItemStack item2 = e.getInventory().getContents()[1]; diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Lists/Categories.java b/src/main/java/me/mrCookieSlime/Slimefun/Lists/Categories.java index 0996ba7f6..8710a14cc 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Lists/Categories.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Lists/Categories.java @@ -6,11 +6,11 @@ import org.bukkit.Material; import org.bukkit.NamespacedKey; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; +import io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory; import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.LockedCategory; -import me.mrCookieSlime.Slimefun.Objects.SeasonalCategory; /** * This class holds a static references to every {@link Category} diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java index b5d9904f9..0cb310985 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.categories.SeasonalCategory; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Lists.Categories; @@ -89,7 +90,7 @@ public class Category implements Keyed { */ public void register() { if (this instanceof SeasonalCategory) { - if (((SeasonalCategory) this).isUnlocked()) { + if (((SeasonalCategory) this).isVisible()) { SlimefunPlugin.getRegistry().getEnabledCategories().add(this); Collections.sort(SlimefunPlugin.getRegistry().getEnabledCategories(), Comparator.comparingInt(Category::getTier)); } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/LockedCategory.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/LockedCategory.java index c94d8a239..9f5c20737 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/LockedCategory.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/LockedCategory.java @@ -8,6 +8,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.Slimefun; 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 03e72ba41..f5e6b9d28 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 @@ -179,14 +179,14 @@ public abstract class AReactor extends AbstractEnergyGenerator { preset.addItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "), ChestMenuUtils.getEmptyClickHandler()); - preset.addItem(1, new CustomItem(SlimefunItems.URANIUM, "&7Fuel Slot", "", "&rThis Slot accepts radioactive Fuel such as:", "&2Uranium &ror &aNeptunium"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(1, new CustomItem(getFuelIcon(), "&7Fuel Slot", "", "&rThis Slot accepts radioactive Fuel such as:", "&2Uranium &ror &aNeptunium"), ChestMenuUtils.getEmptyClickHandler()); for (int i : border_2) { preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "), ChestMenuUtils.getEmptyClickHandler()); } if (needsCooling()) { - preset.addItem(7, new CustomItem(this.getCoolant(), "&bCoolant Slot", "", "&rThis Slot accepts Coolant Cells", "&4Without any Coolant Cells, your Reactor", "&4will explode")); + preset.addItem(7, new CustomItem(getCoolant(), "&bCoolant Slot", "", "&rThis Slot accepts Coolant Cells", "&4Without any Coolant Cells, your Reactor", "&4will explode")); } else { preset.addItem(7, new CustomItem(new ItemStack(Material.BARRIER), "&bCoolant Slot", "", "&rThis Slot accepts Coolant Cells")); @@ -207,7 +207,23 @@ public abstract class AReactor extends AbstractEnergyGenerator { */ public abstract ItemStack getCoolant(); - private boolean needsCooling() { + /** + * This method returns the displayed icon above the fuel input slot. + * It should reflect the {@link ItemStack} used to power the reactor. + * This method does not determine the fuel input, only the icon. + * + * @return The {@link ItemStack} used as the fuel icon for this {@link AReactor}. + */ + public abstract ItemStack getFuelIcon(); + + /** + * This method returns whether this {@link AReactor} requires as some form of + * coolant. + * It is a not-null check performed on {@link #getCoolant()} + * + * @return Whether this {@link AReactor} requires cooling + */ + protected final boolean needsCooling() { return getCoolant() != null; } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index fae9e34a7..c9f75a5fa 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -11,9 +11,10 @@ api-version: 1.13 commands: slimefun: - description: basic Slimefun command + description: Slimefun command aliases: sf usage: You either forgot to install CS-CoreLib or you installed an unsupported version. + permissions: slimefun.cheat.items: description: Allows you to cheat Items