diff --git a/pom.xml b/pom.xml index 45c2e54..3c8874c 100644 --- a/pom.xml +++ b/pom.xml @@ -54,41 +54,41 @@ nl.sbdeveloper.themeparkplus.libs.bstats - com.samjakob.spigui - nl.sbdeveloper.themeparkplus.libs.spigui + fr.minuskube.inv + nl.sbdeveloper.themeparkplus.libs.smartinvs - - - org.projectlombok - lombok-maven-plugin - 1.18.12.0 - - - generate-sources - - delombok - - - - - - - maven-javadoc-plugin - 3.2.0 - - 11 - - nl/sbdeveloper/themeparkplus/api/*.java - nl/sbdeveloper/themeparkplus/api/enums/*.java - nl/sbdeveloper/themeparkplus/api/objects/*.java - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -115,37 +115,39 @@ sk89q-repo https://maven.enginehub.org/repo/ - - jcenter - bintray-jcenter - https://jcenter.bintray.com - org.spigotmc spigot-api - 1.17-R0.1-SNAPSHOT + 1.18.1-R0.1-SNAPSHOT provided me.paradoxpixel themepark - 3.0.0 + 3.1.1 system - ${pom.basedir}/src/lib/themepark-3.0.0.jar + ${pom.basedir}/src/lib/themepark-3.1.1.jar + + + me.paradoxpixel + parkplusmc + 1.4 + system + ${pom.basedir}/src/lib/parkplus-1.4.jar org.projectlombok lombok - 1.18.12 + 1.18.22 provided de.tr7zw item-nbt-api - 2.7.1 + 2.8.0 com.github.MilkBowl @@ -156,38 +158,23 @@ com.zaxxer HikariCP - 3.4.5 - - - org.jetbrains - annotations - 19.0.0 + 5.0.1 org.bstats bstats-bukkit - 1.7 + 2.2.1 compile org.codemc.worldguardwrapper worldguardwrapper - 1.1.9-SNAPSHOT + 1.2.0-SNAPSHOT - com.samjakob - SpiGUI - v1.1 - - - org.spigotmc - spigot-api - - - org.bukkit - bukkit - - + fr.minuskube.inv + smart-invs + 1.2.7 diff --git a/src/lib/parkplus-1.4.jar b/src/lib/parkplus-1.4.jar new file mode 100644 index 0000000..a2a1ea5 Binary files /dev/null and b/src/lib/parkplus-1.4.jar differ diff --git a/src/lib/themepark-3.0.0.jar b/src/lib/themepark-3.0.0.jar deleted file mode 100644 index 64f4c50..0000000 Binary files a/src/lib/themepark-3.0.0.jar and /dev/null differ diff --git a/src/lib/themepark-3.1.1.jar b/src/lib/themepark-3.1.1.jar new file mode 100644 index 0000000..108c475 Binary files /dev/null and b/src/lib/themepark-3.1.1.jar differ diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/ThemeParkPlus.java b/src/main/java/nl/sbdeveloper/themeparkplus/ThemeParkPlus.java similarity index 92% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/ThemeParkPlus.java rename to src/main/java/nl/sbdeveloper/themeparkplus/ThemeParkPlus.java index 5c26c9a..290cc81 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/ThemeParkPlus.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/ThemeParkPlus.java @@ -1,20 +1,18 @@ package nl.sbdeveloper.themeparkplus; -import com.samjakob.spigui.SpiGUI; import net.milkbowl.vault.economy.Economy; import nl.sbdeveloper.themeparkplus.commands.TPPCMD; -import nl.sbdeveloper.themeparkplus.commands.TPPTabComplete; import nl.sbdeveloper.themeparkplus.listeners.*; import nl.sbdeveloper.themeparkplus.managers.DBManager; import nl.sbdeveloper.themeparkplus.sbutils.UpdateManager; import nl.sbdeveloper.themeparkplus.sbutils.YamlFile; +import nl.sbdeveloper.themeparkplus.util.Inventory; import nl.sbdeveloper.themeparkplus.util.License; import org.bstats.bukkit.Metrics; import org.bukkit.Bukkit; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; -import org.jetbrains.annotations.NotNull; import java.io.InputStreamReader; import java.io.Reader; @@ -24,7 +22,6 @@ import java.util.HashMap; import java.util.Objects; public final class ThemeParkPlus extends JavaPlugin { - private static ThemeParkPlus instance; private static YamlFile config; private static DBManager data; @@ -33,11 +30,9 @@ public final class ThemeParkPlus extends JavaPlugin { private static Economy econ = null; private static String webhookURL; - private static SpiGUI spiGUI; - private final int configVersion = 3; - private static boolean hasTPHook = false; + private static boolean hasParkHook = false; @Override public void onEnable() { @@ -107,7 +102,6 @@ public final class ThemeParkPlus extends JavaPlugin { Bukkit.getLogger().info("[ThemeParkPlus] Loading commands..."); getCommand("themeparkplus").setExecutor(new TPPCMD()); - getCommand("themeparkplus").setTabCompleter(new TPPTabComplete()); Bukkit.getLogger().info("[ThemeParkPlus] Loading listeners..."); Bukkit.getPluginManager().registerEvents(new DirectionalGateListener(), this); @@ -117,14 +111,17 @@ public final class ThemeParkPlus extends JavaPlugin { Bukkit.getPluginManager().registerEvents(new AntiFreerunListener(), this); } - if (Bukkit.getPluginManager().getPlugin("ThemePark") == null) { - Bukkit.getLogger().severe("[ThemeParkPlus] Missing ThemePark! Some functions will not work without it!"); - } else { - Bukkit.getLogger().severe("[ThemeParkPlus] Enabling ThemePark hook..."); - hasTPHook = true; + if (Bukkit.getPluginManager().getPlugin("ThemePark") == null && Bukkit.getPluginManager().getPlugin("ParkPlusMC") == null) { + getLogger().severe("ThemePark or ParkPlusMC not found! Some functions will not work without it!"); + } else if (Bukkit.getPluginManager().getPlugin("ThemePark") != null) { + getLogger().severe("Enabling ThemePark hook..."); + hasParkHook = true; + } else if (Bukkit.getPluginManager().getPlugin("ParkPlusMC") != null) { + getLogger().severe("Enabling ParkPlusMC hook..."); + hasParkHook = true; } - if (hasTPHook) { + if (hasParkHook) { Bukkit.getPluginManager().registerEvents(new FastpassListeners(), this); Bukkit.getPluginManager().registerEvents(new MalfunctionListener(), this); @@ -142,8 +139,7 @@ public final class ThemeParkPlus extends JavaPlugin { } Bukkit.getLogger().info("[ThemeParkPlus] Loading GUI helper..."); - spiGUI = new SpiGUI(this); - spiGUI.setEnableAutomaticPagination(false); + Inventory.init(this); Bukkit.getLogger().info("[ThemeParkPlus] Loading data..."); try { @@ -232,12 +228,8 @@ public final class ThemeParkPlus extends JavaPlugin { return webhookURL; } - public static SpiGUI getSpiGUI() { - return spiGUI; - } - - public static boolean hasTPHook() { - return hasTPHook; + public static boolean hasParkHook() { + return hasParkHook; } private boolean setupEconomy() { @@ -266,7 +258,6 @@ public final class ThemeParkPlus extends JavaPlugin { } } - @NotNull private HashMap getConfigVals() { HashMap var = new HashMap <>(); Reader defConfigStream = new InputStreamReader(Objects.requireNonNull(getResource("config.yml")), StandardCharsets.UTF_8); diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/api/PlusAPI.java b/src/main/java/nl/sbdeveloper/themeparkplus/api/PlusAPI.java similarity index 92% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/api/PlusAPI.java rename to src/main/java/nl/sbdeveloper/themeparkplus/api/PlusAPI.java index 42af8a1..274e1f4 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/api/PlusAPI.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/api/PlusAPI.java @@ -12,8 +12,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.codemc.worldguardwrapper.WorldGuardWrapper; import org.codemc.worldguardwrapper.region.IWrappedRegion; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.*; @@ -56,7 +54,7 @@ public class PlusAPI { * * @param gate The gate */ - public static void removeGate(@NotNull Gate gate) { + public static void removeGate(Gate gate) { gates.remove(gate.getLoc()); } @@ -103,7 +101,7 @@ public class PlusAPI { * * @param row The row */ - public static void removeRow(@NotNull WaitingRow row) { + public static void removeRow(WaitingRow row) { rows.remove(row.getRideID()); } @@ -133,7 +131,6 @@ public class PlusAPI { * @param loc The location * @return The row */ - @Nullable public static WaitingRow getRow(Location loc) { if (loc == null) return null; Set set = WorldGuardWrapper.getInstance().getRegions(loc); @@ -151,7 +148,6 @@ public class PlusAPI { * @param signLoc The sign location * @return The row */ - @NotNull public static Optional getRowBySign(Location signLoc) { return rows.values().stream().filter(row -> row.getSignLocations().contains(signLoc)).findFirst(); } @@ -172,9 +168,8 @@ public class PlusAPI { * * @return The ticket as ItemStack */ - @Nullable public static ItemStack getFastpassTicket(nl.iobyte.themepark.api.attraction.objects.Attraction att) { - String ticketName = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.Item.DisplayName")); + String ticketName = ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.Item.DisplayName")); ItemStack ticket = XMaterial.PAPER.parseItem(); if (ticket == null) return null; diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/api/enums/WalkingDirection.java b/src/main/java/nl/sbdeveloper/themeparkplus/api/enums/WalkingDirection.java similarity index 100% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/api/enums/WalkingDirection.java rename to src/main/java/nl/sbdeveloper/themeparkplus/api/enums/WalkingDirection.java diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/api/objects/Gate.java b/src/main/java/nl/sbdeveloper/themeparkplus/api/objects/Gate.java similarity index 89% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/api/objects/Gate.java rename to src/main/java/nl/sbdeveloper/themeparkplus/api/objects/Gate.java index e978562..92a1626 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/api/objects/Gate.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/api/objects/Gate.java @@ -7,7 +7,6 @@ import lombok.Setter; import nl.sbdeveloper.themeparkplus.api.enums.WalkingDirection; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.jetbrains.annotations.NotNull; import java.util.Objects; @@ -33,7 +32,7 @@ public class Gate { * @param loc The gate location * @param direction The walking direction */ - public Gate(@NotNull Location loc, WalkingDirection direction) { + public Gate(Location loc, WalkingDirection direction) { this.world = Objects.requireNonNull(loc.getWorld(), "World is null!").getName(); this.x = loc.getBlockX(); this.y = loc.getBlockY(); @@ -48,7 +47,7 @@ public class Gate { * @param loc The gate location * @param maxCount The max player count */ - public Gate(@NotNull Location loc, int maxCount) { + public Gate(Location loc, int maxCount) { this.world = Objects.requireNonNull(loc.getWorld(), "World is null!").getName(); this.x = loc.getBlockX(); this.y = loc.getBlockY(); @@ -64,7 +63,7 @@ public class Gate { * @param maxCount The max player count * @param direction The walking direction */ - public Gate(@NotNull Location loc, int maxCount, WalkingDirection direction) { + public Gate(Location loc, int maxCount, WalkingDirection direction) { this.world = Objects.requireNonNull(loc.getWorld(), "World is null!").getName(); this.x = loc.getBlockX(); this.y = loc.getBlockY(); diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/api/objects/MalfunctionReport.java b/src/main/java/nl/sbdeveloper/themeparkplus/api/objects/MalfunctionReport.java similarity index 100% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/api/objects/MalfunctionReport.java rename to src/main/java/nl/sbdeveloper/themeparkplus/api/objects/MalfunctionReport.java diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/api/objects/WaitingRow.java b/src/main/java/nl/sbdeveloper/themeparkplus/api/objects/WaitingRow.java similarity index 100% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/api/objects/WaitingRow.java rename to src/main/java/nl/sbdeveloper/themeparkplus/api/objects/WaitingRow.java diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/commands/TPPCMD.java b/src/main/java/nl/sbdeveloper/themeparkplus/commands/TPPCMD.java similarity index 76% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/commands/TPPCMD.java rename to src/main/java/nl/sbdeveloper/themeparkplus/commands/TPPCMD.java index c123b66..cce8342 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/commands/TPPCMD.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/commands/TPPCMD.java @@ -1,5 +1,6 @@ package nl.sbdeveloper.themeparkplus.commands; +import nl.iobyte.themepark.ThemePark; import nl.sbdeveloper.themeparkplus.ThemeParkPlus; import nl.sbdeveloper.themeparkplus.api.PlusAPI; import nl.sbdeveloper.themeparkplus.api.enums.WalkingDirection; @@ -15,18 +16,18 @@ import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; +import org.bukkit.util.StringUtil; -import java.util.Collections; -import java.util.HashMap; +import java.util.*; +import java.util.stream.Collectors; -public class TPPCMD implements CommandExecutor { +public class TPPCMD implements TabExecutor { - public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) { + public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (args.length == 0) { return helpCommand(sender); } else if (args[0].equalsIgnoreCase("info") && args.length == 1) { @@ -194,7 +195,7 @@ public class TPPCMD implements CommandExecutor { } private boolean giveFPTicketCommand(CommandSender sender, String[] args) { - if (!ThemeParkPlus.hasTPHook()) { + if (!ThemeParkPlus.hasParkHook()) { sender.sendMessage(ConfigUtil.getMessage("General.RequiresThemePark")); return true; } @@ -231,7 +232,7 @@ public class TPPCMD implements CommandExecutor { return true; } - private boolean infoCommand(@NotNull CommandSender sender) { + private boolean infoCommand(CommandSender sender) { sender.sendMessage("§1=================================="); sender.sendMessage("§6ThemeParkPlus plugin made by §aSBDeveloper"); sender.sendMessage("§6Version: " + ThemeParkPlus.getInstance().getDescription().getVersion()); @@ -240,7 +241,7 @@ public class TPPCMD implements CommandExecutor { return true; } - private boolean helpCommand(@NotNull CommandSender sender) { + private boolean helpCommand(CommandSender sender) { sender.sendMessage("§8ThemeParkPlus commands:"); sender.sendMessage("§6/themeparkplus info§f: Gives you information about the plugin."); sender.sendMessage("§6/themeparkplus help§f: Gives you this help page."); @@ -259,7 +260,7 @@ public class TPPCMD implements CommandExecutor { return true; } - private boolean openGate(CommandSender sender, @NotNull String[] args, int amount, WalkingDirection dir) { + private boolean openGate(CommandSender sender, String[] args, int amount, WalkingDirection dir) { World bworld = Bukkit.getWorld(args[1]); double bx = Double.parseDouble(args[2]); double by = Double.parseDouble(args[3]); @@ -307,7 +308,7 @@ public class TPPCMD implements CommandExecutor { return true; } - private boolean closeGate(CommandSender sender, @NotNull String[] args) { + private boolean closeGate(CommandSender sender, String[] args) { World bworld = Bukkit.getWorld(args[1]); double bx = Double.parseDouble(args[2]); double by = Double.parseDouble(args[3]); @@ -336,7 +337,7 @@ public class TPPCMD implements CommandExecutor { return true; } - private boolean lampTurnOnCommand(CommandSender sender, @NotNull String[] args, int secOn) { + private boolean lampTurnOnCommand(CommandSender sender, String[] args, int secOn) { World bworld = Bukkit.getWorld(args[1]); double bx = Double.parseDouble(args[2]); double by = Double.parseDouble(args[3]); @@ -357,13 +358,13 @@ public class TPPCMD implements CommandExecutor { return true; } - Bukkit.getScheduler().runTaskLater(ThemeParkPlus.getInstance(), () -> LGUtil.zetLampUit(block), secOn * 20); + Bukkit.getScheduler().runTaskLater(ThemeParkPlus.getInstance(), () -> LGUtil.zetLampUit(block), secOn * 20L); if (ConfigUtil.sendConsole(sender)) sender.sendMessage(ConfigUtil.getMessage("Lamp.TurnedOnSec", Collections.singletonMap("%sec%", String.valueOf(secOn)))); } return true; } - private boolean lampTurnOffCommand(CommandSender sender, @NotNull String[] args) { + private boolean lampTurnOffCommand(CommandSender sender, String[] args) { World bworld = Bukkit.getWorld(args[1]); double bx = Double.parseDouble(args[2]); double by = Double.parseDouble(args[3]); @@ -379,7 +380,7 @@ public class TPPCMD implements CommandExecutor { return true; } - private boolean lampsTurnOnCommand(CommandSender sender, @NotNull String[] args, int secOn) { + private boolean lampsTurnOnCommand(CommandSender sender, String[] args, int secOn) { World bworld = Bukkit.getWorld(args[1]); double bx = Double.parseDouble(args[2]); @@ -413,7 +414,7 @@ public class TPPCMD implements CommandExecutor { return true; } - private boolean lampsTurnOffCommand(@NotNull CommandSender sender, @NotNull String[] args) { + private boolean lampsTurnOffCommand(CommandSender sender, String[] args) { World bworld = Bukkit.getWorld(args[1]); double bx = Double.parseDouble(args[2]); @@ -436,4 +437,82 @@ public class TPPCMD implements CommandExecutor { if (ConfigUtil.sendConsole(sender)) sender.sendMessage(ConfigUtil.getMessage("Lamps.TurnedOff")); return true; } + + private static final List COMMANDS = Arrays.asList("info", "help", "opengate", "closegate", "lampon", "lampoff", "lampson", "lampsoff", "redstonetimer", "givefpticket"); + + @Override + public List onTabComplete(CommandSender sender, Command command, String label, String[] args) { + //Aliases + if (label.equalsIgnoreCase("themeparkplus") || label.equalsIgnoreCase("tpp") || label.equalsIgnoreCase("themeparkp")) { + if (args.length == 1) { + return StringUtil.copyPartialMatches(args[0], COMMANDS, new ArrayList<>()); + } else if (args.length == 2) { + if (args[0].equalsIgnoreCase("opengate") + || args[0].equalsIgnoreCase("closegate") + || args[0].equalsIgnoreCase("lampon") + || args[0].equalsIgnoreCase("lampoff") + || args[0].equalsIgnoreCase("redstonetimer")) { + if (sender instanceof Player) { + Player p = (Player) sender; + Location targetLoc = getTarget(p).getLocation(); + return StringUtil.copyPartialMatches(args[1], Collections.singletonList("" + targetLoc.getWorld().getName()), new ArrayList<>()); + } + } else if (args[0].equalsIgnoreCase("givefpticket")) { + return StringUtil.copyPartialMatches(args[1], ThemePark.getInstance().getAPI().getAttractionService().getAttractions().keySet(), new ArrayList<>()); + } + } else if (args.length == 3) { + if (args[0].equalsIgnoreCase("opengate") + || args[0].equalsIgnoreCase("closegate") + || args[0].equalsIgnoreCase("lampon") + || args[0].equalsIgnoreCase("lampoff") + || args[0].equalsIgnoreCase("redstonetimer")) { + if (sender instanceof Player) { + Player p = (Player) sender; + Location targetLoc = getTarget(p).getLocation(); + return StringUtil.copyPartialMatches(args[2], Collections.singletonList("" + targetLoc.getBlockX()), new ArrayList<>()); + } + } else if (args[0].equalsIgnoreCase("givefpticket")) { + return StringUtil.copyPartialMatches(args[1], Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList()), new ArrayList<>()); + } + } else if (args.length == 4) { + if (args[0].equalsIgnoreCase("opengate") + || args[0].equalsIgnoreCase("closegate") + || args[0].equalsIgnoreCase("lampon") + || args[0].equalsIgnoreCase("lampoff") + || args[0].equalsIgnoreCase("redstonetimer")) { + if (sender instanceof Player) { + Player p = (Player) sender; + Location targetLoc = getTarget(p).getLocation(); + return StringUtil.copyPartialMatches(args[3], Collections.singletonList("" + targetLoc.getBlockY()), new ArrayList<>()); + } + } + } else if (args.length == 5) { + if (args[0].equalsIgnoreCase("opengate") + || args[0].equalsIgnoreCase("closegate") + || args[0].equalsIgnoreCase("lampon") + || args[0].equalsIgnoreCase("lampoff") + || args[0].equalsIgnoreCase("redstonetimer")) { + if (sender instanceof Player) { + Player p = (Player) sender; + Location targetLoc = getTarget(p).getLocation(); + return StringUtil.copyPartialMatches(args[4], Collections.singletonList("" + targetLoc.getBlockZ()), new ArrayList<>()); + } + } + } else if (args.length == 6) { + if (args[0].equalsIgnoreCase("opengate")) { + return StringUtil.copyPartialMatches(args[5], Arrays.stream(WalkingDirection.values()).map(Enum::toString).collect(Collectors.toList()), new ArrayList<>()); + } + } else if (args.length == 7) { + if (args[0].equalsIgnoreCase("opengate")) { + return StringUtil.copyPartialMatches(args[6], Arrays.stream(WalkingDirection.values()).map(Enum::toString).collect(Collectors.toList()), new ArrayList<>()); + } + } + } + + return null; + } + + private Block getTarget(Player p) { + return p.getTargetBlock(null, 200); + } } \ No newline at end of file diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/gui/MalfunctionGUI.java b/src/main/java/nl/sbdeveloper/themeparkplus/gui/MalfunctionGUI.java similarity index 62% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/gui/MalfunctionGUI.java rename to src/main/java/nl/sbdeveloper/themeparkplus/gui/MalfunctionGUI.java index e1751f6..fc616b8 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/gui/MalfunctionGUI.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/gui/MalfunctionGUI.java @@ -1,8 +1,9 @@ package nl.sbdeveloper.themeparkplus.gui; -import com.samjakob.spigui.SGMenu; -import com.samjakob.spigui.buttons.SGButton; -import com.samjakob.spigui.item.ItemBuilder; +import fr.minuskube.inv.ClickableItem; +import fr.minuskube.inv.content.InventoryContents; +import fr.minuskube.inv.content.SlotPos; +import nl.iobyte.menuapi.item.ItemBuilder; import nl.iobyte.themepark.ThemePark; import nl.iobyte.themepark.api.attraction.enums.Status; import nl.iobyte.themepark.api.attraction.objects.Attraction; @@ -10,10 +11,10 @@ import nl.sbdeveloper.themeparkplus.ThemeParkPlus; import nl.sbdeveloper.themeparkplus.api.PlusAPI; import nl.sbdeveloper.themeparkplus.api.objects.MalfunctionReport; import nl.sbdeveloper.themeparkplus.util.ConfigUtil; +import nl.sbdeveloper.themeparkplus.util.Inventory; import nl.sbdeveloper.themeparkplus.util.XMaterial; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.ItemStack; import java.time.format.DateTimeFormatter; @@ -22,46 +23,50 @@ import java.util.Collections; import java.util.List; import java.util.Optional; -public class MalfunctionGUI { - public static void open(Attraction att, Player p) { - SGMenu menu = ThemeParkPlus.getSpiGUI().create(ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Malfunction.GUI.Title").replace("%ridename%", att.getName())), 1); +import static nl.sbdeveloper.themeparkplus.util.ConfigUtil.__; - SGButton report = new SGButton(getItem("Report", ConfigUtil.makecolored(att.getName()))).withListener((InventoryClickEvent e) -> { +public class MalfunctionGUI extends Inventory { + private final Attraction att; + + public MalfunctionGUI(Attraction att, Player p) { + super(1, __(ThemeParkPlus.getSConfig().getFile().getString("Malfunction.GUI.Title").replace("%ridename%", att.getName()))); + this.att = att; + open(p); + } + + @Override + public void init(Player player, InventoryContents contents) { + contents.set(getSlot("Report"), ClickableItem.of(getItem("Report", __(att.getName())), e -> { if (!PlusAPI.isReported(att.getID())) { - MalfunctionReport malfunctionReport = new MalfunctionReport(att.getID(), p.getUniqueId()); + MalfunctionReport malfunctionReport = new MalfunctionReport(att.getID(), player.getUniqueId()); PlusAPI.addReport(malfunctionReport); att.setStatus(Status.MALFUNCTION); - p.sendMessage(ConfigUtil.getMessage("Malfunction.Reported", Collections.singletonMap("%ride%", att.getName()))); + player.sendMessage(ConfigUtil.getMessage("Malfunction.Reported", Collections.singletonMap("%ride%", att.getName()))); } else { - p.sendMessage(ConfigUtil.getMessage("Malfunction.AlreadyReported", Collections.singletonMap("%ride%", att.getName()))); + player.sendMessage(ConfigUtil.getMessage("Malfunction.AlreadyReported", Collections.singletonMap("%ride%", att.getName()))); } - p.closeInventory(); - }); - menu.setButton(getSlot("Report"), report); + close(player); + })); - SGButton fix = new SGButton(getItem("Fix", PlusAPI.getReport(att.getID()))).withListener((InventoryClickEvent e) -> { + contents.set(getSlot("Fix"), ClickableItem.of(getItem("Fix", PlusAPI.getReport(att.getID())), e -> { if (PlusAPI.isReported(att.getID())) { PlusAPI.removeReport(att.getID()); att.setStatus(Status.CLOSED); - p.sendMessage(ConfigUtil.getMessage("Malfunction.Fixed", Collections.singletonMap("%ride%", att.getName()))); + player.sendMessage(ConfigUtil.getMessage("Malfunction.Fixed", Collections.singletonMap("%ride%", att.getName()))); } else { - p.sendMessage(ConfigUtil.getMessage("Malfunction.AlreadyFixed", Collections.singletonMap("%ride%", att.getName()))); + player.sendMessage(ConfigUtil.getMessage("Malfunction.AlreadyFixed", Collections.singletonMap("%ride%", att.getName()))); } - p.closeInventory(); - }); - menu.setButton(getSlot("Fix"), fix); + close(player); + })); - SGButton cancel = new SGButton(getItem("Cancel")).withListener((InventoryClickEvent e) -> p.closeInventory()); - menu.setButton(getSlot("Cancel"), cancel); - - p.openInventory(menu.getInventory()); + contents.set(getSlot("Cancel"), ClickableItem.of(getItem("Cancel"), e -> close(player))); } - private static int getSlot(String type) { - return ThemeParkPlus.getSConfig().getFile().getInt("Malfunction.GUI.Buttons." + type + ".Slot"); + private static SlotPos getSlot(String type) { + return new SlotPos(0, ThemeParkPlus.getSConfig().getFile().getInt("Malfunction.GUI.Buttons." + type + ".Slot")-1); } private static ItemStack getItem(String type, Object... data) { //data is a string or a report @@ -97,6 +102,6 @@ public class MalfunctionGUI { } Optional stack = XMaterial.matchXMaterial(material); - return stack.map(xMaterial -> new ItemBuilder(xMaterial.parseItem()).name(name).lore(loresFormatted).build()).orElse(null); + return stack.map(xMaterial -> new ItemBuilder(xMaterial.parseItem()).setName(name).setLore(loresFormatted).getItem()).orElse(null); } } diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/listeners/AntiFreerunListener.java b/src/main/java/nl/sbdeveloper/themeparkplus/listeners/AntiFreerunListener.java similarity index 86% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/listeners/AntiFreerunListener.java rename to src/main/java/nl/sbdeveloper/themeparkplus/listeners/AntiFreerunListener.java index 89d37bf..4a36c78 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/listeners/AntiFreerunListener.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/listeners/AntiFreerunListener.java @@ -6,14 +6,13 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.NotNull; /** * Anti-Freerun effect */ public class AntiFreerunListener implements Listener { @EventHandler - public void onJoin(@NotNull PlayerJoinEvent e) { + public void onJoin(PlayerJoinEvent e) { Player p = e.getPlayer(); if (!p.hasPermission("tpp.bypassantifreerun")) { p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 1000000, -2, false, false)); diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/listeners/DirectionalGateListener.java b/src/main/java/nl/sbdeveloper/themeparkplus/listeners/DirectionalGateListener.java similarity index 96% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/listeners/DirectionalGateListener.java rename to src/main/java/nl/sbdeveloper/themeparkplus/listeners/DirectionalGateListener.java index 9b37f26..207bb78 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/listeners/DirectionalGateListener.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/listeners/DirectionalGateListener.java @@ -12,14 +12,13 @@ import org.bukkit.block.Block; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerMoveEvent; -import org.jetbrains.annotations.NotNull; /** * Gate move listeners (directional and count checks) */ public class DirectionalGateListener implements Listener { @EventHandler - public void onWalkThroughFenceGate(@NotNull PlayerMoveEvent e) { + public void onWalkThroughFenceGate(PlayerMoveEvent e) { if (e.getTo() != null && (e.getFrom().getBlockX() != e.getTo().getBlockX() || e.getFrom().getBlockY() != e.getTo().getBlockY() diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/listeners/FastpassListeners.java b/src/main/java/nl/sbdeveloper/themeparkplus/listeners/FastpassListeners.java similarity index 88% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/listeners/FastpassListeners.java rename to src/main/java/nl/sbdeveloper/themeparkplus/listeners/FastpassListeners.java index ad877f4..8489c2a 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/listeners/FastpassListeners.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/listeners/FastpassListeners.java @@ -21,7 +21,6 @@ import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.HashMap; @@ -31,13 +30,13 @@ import java.util.HashMap; */ public class FastpassListeners implements Listener { @EventHandler - public void onSignClick(@NotNull PlayerInteractEvent e) { + public void onSignClick(PlayerInteractEvent e) { if (e.getClickedBlock() == null || e.getAction() != Action.RIGHT_CLICK_BLOCK || !(e.getClickedBlock().getState() instanceof Sign) || e.getHand() != EquipmentSlot.HAND) return; - String mLineOne = ChatColor.stripColor(ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.MachineSign.Row1"))); - String mLineTwo = ChatColor.stripColor(ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.MachineSign.Row2"))); - String sLineOne = ChatColor.stripColor(ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row1"))); - String sLineTwo = ChatColor.stripColor(ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row2"))); + String mLineOne = ChatColor.stripColor(ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.MachineSign.Row1"))); + String mLineTwo = ChatColor.stripColor(ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.MachineSign.Row2"))); + String sLineOne = ChatColor.stripColor(ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row1"))); + String sLineTwo = ChatColor.stripColor(ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row2"))); Sign sign = (Sign) e.getClickedBlock().getState(); if (!ChatColor.stripColor(sign.getLine(0)).equalsIgnoreCase(mLineOne) && !ChatColor.stripColor(sign.getLine(0)).equalsIgnoreCase(sLineOne)) return; @@ -65,7 +64,7 @@ public class FastpassListeners implements Listener { } for (ItemStack content : e.getPlayer().getInventory().getContents()) { - if (content == null || content.getType() == null || content.getType() == Material.AIR) continue; + if (content == null || content.getType() == Material.AIR) continue; NBTItem nbtContent = new NBTItem(content); if (content.getType() == XMaterial.PAPER.parseMaterial() && content.hasItemMeta() && nbtContent.hasKey("RideID") && nbtContent.getString("RideID").equalsIgnoreCase(attID)) { e.getPlayer().sendMessage(ConfigUtil.getMessage("Fastpass.AlreadyHaveTicket")); diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/listeners/MalfunctionListener.java b/src/main/java/nl/sbdeveloper/themeparkplus/listeners/MalfunctionListener.java similarity index 79% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/listeners/MalfunctionListener.java rename to src/main/java/nl/sbdeveloper/themeparkplus/listeners/MalfunctionListener.java index 7b28f5d..64d12ba 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/listeners/MalfunctionListener.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/listeners/MalfunctionListener.java @@ -18,8 +18,8 @@ public class MalfunctionListener implements Listener { public void onClickSign(PlayerInteractEvent e) { if (e.getClickedBlock() == null || e.getAction() != Action.RIGHT_CLICK_BLOCK || !(e.getClickedBlock().getState() instanceof Sign) || e.getHand() != EquipmentSlot.HAND) return; - String mrLineOne = ChatColor.stripColor(ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Malfunction.Sign.Row1"))); - String mrLineTwo = ChatColor.stripColor(ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Malfunction.Sign.Row2"))); + String mrLineOne = ChatColor.stripColor(ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Malfunction.Sign.Row1"))); + String mrLineTwo = ChatColor.stripColor(ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Malfunction.Sign.Row2"))); Sign sign = (Sign) e.getClickedBlock().getState(); if (ChatColor.stripColor(sign.getLine(0)).equalsIgnoreCase(mrLineOne) && ChatColor.stripColor(sign.getLine(1)).equalsIgnoreCase(mrLineTwo)) { @@ -27,7 +27,7 @@ public class MalfunctionListener implements Listener { if (!ThemePark.getInstance().getAPI().getAttractionService().hasAttraction(attID)) return; Attraction att = ThemePark.getInstance().getAPI().getAttractionService().getAttraction(attID); - MalfunctionGUI.open(att, e.getPlayer()); + new MalfunctionGUI(att, e.getPlayer()); } } } diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/listeners/SignListeners.java b/src/main/java/nl/sbdeveloper/themeparkplus/listeners/SignListeners.java similarity index 71% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/listeners/SignListeners.java rename to src/main/java/nl/sbdeveloper/themeparkplus/listeners/SignListeners.java index 1d9f1c2..fc593af 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/listeners/SignListeners.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/listeners/SignListeners.java @@ -11,7 +11,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.SignChangeEvent; -import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.Optional; @@ -28,14 +27,14 @@ public class SignListeners implements Listener { */ @EventHandler - public void onCreate(@NotNull SignChangeEvent e) { + public void onCreate(SignChangeEvent e) { Player p = e.getPlayer(); String[] lines = e.getLines(); //Only check themeparkplus signs! if (!lines[0].equalsIgnoreCase("[ThemeParkPlus]")) return; - if (!ThemeParkPlus.hasTPHook()) { + if (!ThemeParkPlus.hasParkHook()) { p.sendMessage(ConfigUtil.getMessage("General.RequiresThemePark")); return; } @@ -50,14 +49,14 @@ public class SignListeners implements Listener { return; } - String mLineOne = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.MachineSign.Row1")); - String mLineTwo = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.MachineSign.Row2")); - String sLineOne = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row1")); - String sLineTwo = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row2")); - String wrLineOne = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("WaitingRow.Sign.Row1")); - String wrLineTwo = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("WaitingRow.Sign.Row2")); - String mrLineOne = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Malfunction.Sign.Row1")); - String mrLineTwo = ConfigUtil.makecolored(ThemeParkPlus.getSConfig().getFile().getString("Malfunction.Sign.Row2")); + String mLineOne = ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.MachineSign.Row1")); + String mLineTwo = ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.MachineSign.Row2")); + String sLineOne = ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row1")); + String sLineTwo = ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Fastpass.ScannerSign.Row2")); + String wrLineOne = ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("WaitingRow.Sign.Row1")); + String wrLineTwo = ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("WaitingRow.Sign.Row2")); + String mrLineOne = ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Malfunction.Sign.Row1")); + String mrLineTwo = ConfigUtil.__(ThemeParkPlus.getSConfig().getFile().getString("Malfunction.Sign.Row2")); if (lines[1].equalsIgnoreCase("Machine") && !lines[2].isEmpty() && !lines[3].isEmpty()) { e.setLine(0, mLineOne); @@ -80,7 +79,7 @@ public class SignListeners implements Listener { e.setLine(0, wrLineOne); e.setLine(1, wrLineTwo); - e.setLine(2, ConfigUtil.makecolored(nl.iobyte.themepark.ThemePark.getInstance().getAPI().getAttractionService().getAttraction(lines[2]).getName())); + e.setLine(2, ConfigUtil.__(nl.iobyte.themepark.ThemePark.getInstance().getAPI().getAttractionService().getAttraction(lines[2]).getName())); e.setLine(3, "0 min."); p.sendMessage(ConfigUtil.getMessage("WaitingRow.SignCreated")); @@ -97,7 +96,7 @@ public class SignListeners implements Listener { BlockState signblocks = e.getBlock().getState(); if ((signblocks instanceof Sign)) { Optional rowOptional = PlusAPI.getRowBySign(e.getBlock().getLocation()); - if (!rowOptional.isPresent()) return; + if (rowOptional.isEmpty()) return; WaitingRow row = rowOptional.get(); if (row.getSignLocations().size() == 1) { diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/listeners/StatusChangeListener.java b/src/main/java/nl/sbdeveloper/themeparkplus/listeners/StatusChangeListener.java similarity index 61% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/listeners/StatusChangeListener.java rename to src/main/java/nl/sbdeveloper/themeparkplus/listeners/StatusChangeListener.java index f0a55e2..4591b7e 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/listeners/StatusChangeListener.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/listeners/StatusChangeListener.java @@ -46,13 +46,13 @@ public class StatusChangeListener implements Listener { } @EventHandler - public void onStatusChange(AttractionStatusChangeEvent e) { + public void onStatusChangeTP(AttractionStatusChangeEvent e) { String title = ThemeParkPlus.getSConfig().getFile().getString("DiscordWebhook.Embed.Title"); if (title == null) return; - String rideName = ChatColor.stripColor(ConfigUtil.makecolored(e.getAttraction().getName())); - String regionName = ChatColor.stripColor(ConfigUtil.makecolored(e.getAttraction().getRegionID())); - String statusAfter = ChatColor.stripColor(ConfigUtil.makecolored(e.getCurrent().getColor() + e.getCurrent().getName())); + String rideName = ChatColor.stripColor(ConfigUtil.__(e.getAttraction().getName())); + String regionName = ChatColor.stripColor(ConfigUtil.__(e.getAttraction().getRegionID())); + String statusAfter = ChatColor.stripColor(ConfigUtil.__(e.getCurrent().getColor() + e.getCurrent().getName())); title = title.replaceAll("%RideName%", rideName); title = title.replaceAll("%Region%", regionName); @@ -77,4 +77,37 @@ public class StatusChangeListener implements Listener { ex.printStackTrace(); } } + + @EventHandler + public void onStatusChangePPMC(nl.iobyte.parkplus.generic.event.attraction.AttractionStatusChangeEvent e) { + String title = ThemeParkPlus.getSConfig().getFile().getString("DiscordWebhook.Embed.Title"); + if (title == null) return; + + String rideName = ChatColor.stripColor(ConfigUtil.__(e.getAttraction().getName())); + String regionName = ChatColor.stripColor(ConfigUtil.__(e.getAttraction().getRegionID())); + String statusAfter = ChatColor.stripColor(ConfigUtil.__(e.getCurrent().getColor() + e.getCurrent().getName())); + + title = title.replaceAll("%RideName%", rideName); + title = title.replaceAll("%Region%", regionName); + String copy = ThemeParkPlus.getSConfig().getFile().getString("DiscordWebhook.Embed.Copyright"); + String copyimg = ThemeParkPlus.getSConfig().getFile().getString("DiscordWebhook.Embed.CopyrightImage"); + Color color = new Color(ThemeParkPlus.getSConfig().getFile().getInt("DiscordWebhook.Embed.Colors." + e.getCurrent().name())); + if (copy == null || copyimg == null) return; + + DiscordWebhook webhook = new DiscordWebhook(ThemeParkPlus.getWebhookURL()); + + DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject() + .setTitle(title) + .setFooter(copy, copyimg) + .setColor(color) + .addField(rideName, statusAfter, false); + + webhook.addEmbed(embed); + try { + webhook.execute(); + } catch (IOException ex) { + Bukkit.getLogger().severe("[ThemeParkPlus] Could not send the status update to Discord! See the error below:"); + ex.printStackTrace(); + } + } } diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/listeners/WaitingTimeListener.java b/src/main/java/nl/sbdeveloper/themeparkplus/listeners/WaitingTimeListener.java similarity index 92% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/listeners/WaitingTimeListener.java rename to src/main/java/nl/sbdeveloper/themeparkplus/listeners/WaitingTimeListener.java index 4047f90..36c658c 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/listeners/WaitingTimeListener.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/listeners/WaitingTimeListener.java @@ -14,26 +14,24 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerTeleportEvent; -import org.jetbrains.annotations.NotNull; import java.util.Collections; public class WaitingTimeListener implements Listener { - private static final double PER_PLAYER = ThemeParkPlus.getSConfig().getFile().getDouble("WaitingRow.MinutesPerPlayer"); @EventHandler - public void onPlayerJoin(@NotNull PlayerJoinEvent e) { + public void onPlayerJoin(PlayerJoinEvent e) { doWaitingRowThings(null, e.getPlayer().getLocation().getBlock().getLocation()); } @EventHandler - public void onPlayerQuit(@NotNull PlayerQuitEvent e) { + public void onPlayerQuit(PlayerQuitEvent e) { doWaitingRowThings(e.getPlayer().getLocation().getBlock().getLocation(), null); } @EventHandler - public void onTeleport(@NotNull PlayerTeleportEvent e) { + public void onTeleport(PlayerTeleportEvent e) { if (e.getTo() == null) return; if ((e.getFrom().getBlockX() != e.getTo().getBlockX()) || (e.getFrom().getBlockY() != e.getTo().getBlockY()) @@ -43,7 +41,7 @@ public class WaitingTimeListener implements Listener { } @EventHandler - public void onPlayerMove(@NotNull PlayerMoveEvent e) { + public void onPlayerMove(PlayerMoveEvent e) { if (e.getTo() == null) return; if ((e.getFrom().getBlockX() != e.getTo().getBlockX()) || (e.getFrom().getBlockY() != e.getTo().getBlockY()) diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/managers/DBManager.java b/src/main/java/nl/sbdeveloper/themeparkplus/managers/DBManager.java similarity index 97% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/managers/DBManager.java rename to src/main/java/nl/sbdeveloper/themeparkplus/managers/DBManager.java index 7adb6d9..17ba9c6 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/managers/DBManager.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/managers/DBManager.java @@ -11,7 +11,6 @@ import nl.sbdeveloper.themeparkplus.sbutils.SQLiteDB; import nl.sbdeveloper.themeparkplus.util.License; import nl.sbdeveloper.themeparkplus.util.LocationGsonAdapter; import org.bukkit.Location; -import org.jetbrains.annotations.NotNull; import java.sql.Connection; import java.sql.PreparedStatement; @@ -20,6 +19,7 @@ import java.sql.SQLException; import java.util.Map; public class DBManager { + private static final Gson gson = new GsonBuilder().registerTypeAdapter(Location.class, new LocationGsonAdapter()).create(); private static SQLiteDB data; private static Connection con; @@ -46,9 +46,8 @@ public class DBManager { } } - @NotNull private Gson getGson() { - return new GsonBuilder().registerTypeAdapter(Location.class, new LocationGsonAdapter()).create(); + return gson; } public void load() throws SQLException { diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/sbutils/LocationSerializer.java b/src/main/java/nl/sbdeveloper/themeparkplus/sbutils/LocationSerializer.java similarity index 83% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/sbutils/LocationSerializer.java rename to src/main/java/nl/sbdeveloper/themeparkplus/sbutils/LocationSerializer.java index 4faed2e..00a2451 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/sbutils/LocationSerializer.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/sbutils/LocationSerializer.java @@ -2,8 +2,6 @@ package nl.sbdeveloper.themeparkplus.sbutils; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public class LocationSerializer { @@ -14,8 +12,7 @@ public class LocationSerializer { * * @return The location or null if error */ - @Nullable - public static Location deserialize(@NotNull String string) { + public static Location deserialize(String string) { String[] split = string.split("_"); if (split.length < 4) return null; @@ -36,8 +33,7 @@ public class LocationSerializer { * * @return The location or null if error */ - @NotNull - public static Location deserializePY(@NotNull String string) { + public static Location deserializePY(String string) { String[] split = string.split("_"); //world_x_y_z @@ -58,8 +54,7 @@ public class LocationSerializer { * * @return The serialized string */ - @Nullable - public static String serialize(@NotNull Location loc) { + public static String serialize(Location loc) { if (loc.getWorld() == null) return null; return loc.getWorld().getName() + "_" + loc.getX() + "_" + loc.getY() + "_" + loc.getZ(); } @@ -71,8 +66,7 @@ public class LocationSerializer { * * @return The serialized string */ - @Nullable - public static String serializePY(@NotNull Location loc) { + public static String serializePY(Location loc) { if (loc.getWorld() == null) return null; return loc.getWorld().getName() + "_" + loc.getX() + "_" + loc.getY() + "_" + loc.getZ() + "_" + loc.getYaw() + "_" + loc.getPitch(); } diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/sbutils/SQLiteDB.java b/src/main/java/nl/sbdeveloper/themeparkplus/sbutils/SQLiteDB.java similarity index 98% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/sbutils/SQLiteDB.java rename to src/main/java/nl/sbdeveloper/themeparkplus/sbutils/SQLiteDB.java index 9fc1473..6bce3d2 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/sbutils/SQLiteDB.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/sbutils/SQLiteDB.java @@ -12,8 +12,7 @@ import java.sql.SQLException; import java.util.Properties; public class SQLiteDB { - - private String dbName; + private final String dbName; private HikariDataSource source; private Connection con; diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/sbutils/UpdateManager.java b/src/main/java/nl/sbdeveloper/themeparkplus/sbutils/UpdateManager.java similarity index 97% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/sbutils/UpdateManager.java rename to src/main/java/nl/sbdeveloper/themeparkplus/sbutils/UpdateManager.java index f421429..f3fcf99 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/sbutils/UpdateManager.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/sbutils/UpdateManager.java @@ -6,8 +6,6 @@ import com.google.gson.JsonParser; import org.bukkit.Bukkit; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import javax.net.ssl.HttpsURLConnection; import java.io.*; @@ -51,7 +49,7 @@ public class UpdateManager { * @param plugin The javaplugin (Main class) * @param resourceID The resourceID on spigot/sbdplugins */ - public UpdateManager(@NotNull Plugin plugin, int resourceID) { + public UpdateManager(Plugin plugin, int resourceID) { this.plugin = plugin; this.currentVersion = new Version(plugin.getDescription().getVersion()); this.resourceID = resourceID; @@ -66,7 +64,7 @@ public class UpdateManager { * @param resourceID The resourceID on spigot/sbdplugins * @param license The license for the download */ - public UpdateManager(@NotNull Plugin plugin, int resourceID, String license) { + public UpdateManager(Plugin plugin, int resourceID, String license) { this.plugin = plugin; this.currentVersion = new Version(plugin.getDescription().getVersion()); this.resourceID = resourceID; @@ -250,7 +248,6 @@ public class UpdateManager { }); } - @Nullable private File getPluginFile() { if (!(this.plugin instanceof JavaPlugin)) { return null; } try { @@ -293,7 +290,7 @@ public class UpdateManager { this.version = version; } - private VersionResponse check(@NotNull Version that) { + private VersionResponse check(Version that) { String[] thisParts = this.get().split("\\."); String[] thatParts = that.get().split("\\."); diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/sbutils/YamlFile.java b/src/main/java/nl/sbdeveloper/themeparkplus/sbutils/YamlFile.java similarity index 98% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/sbutils/YamlFile.java rename to src/main/java/nl/sbdeveloper/themeparkplus/sbutils/YamlFile.java index 8d72f1e..cf3027c 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/sbutils/YamlFile.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/sbutils/YamlFile.java @@ -17,7 +17,7 @@ public class YamlFile { private FileConfiguration fileConfiguration; private File file; - private String name; + private final String name; public YamlFile(String name) { this.name = name; diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/util/ConfigUtil.java b/src/main/java/nl/sbdeveloper/themeparkplus/util/ConfigUtil.java similarity index 87% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/util/ConfigUtil.java rename to src/main/java/nl/sbdeveloper/themeparkplus/util/ConfigUtil.java index 7e99f77..694a542 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/util/ConfigUtil.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/util/ConfigUtil.java @@ -4,7 +4,6 @@ import nl.sbdeveloper.themeparkplus.ThemeParkPlus; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; -import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.HashMap; @@ -12,36 +11,32 @@ import java.util.List; import java.util.Map; public class ConfigUtil { - @NotNull - public static String makecolored(String str) { + public static String __(String str) { return ChatColor.translateAlternateColorCodes('&', str); } - @NotNull public static List getLore(String path, Map vars) { ArrayList response = new ArrayList<>(); for (String str : ThemeParkPlus.getSConfig().getFile().getStringList(path)) { for (Map.Entry entry : vars.entrySet()) { str = str.replaceAll(entry.getKey(), entry.getValue()); } - response.add(makecolored(str)); + response.add(__(str)); } return response; } - @NotNull public static String getMessage(String path) { return getMessage(path, new HashMap<>()); } - @NotNull public static String getMessage(String path, Map vars) { String message = ThemeParkPlus.getMessages().getFile().getString(path); if (message == null) return ""; for (Map.Entry entry : vars.entrySet()) { message = message.replaceAll(entry.getKey(), entry.getValue()); } - return makecolored(message); + return __(message); } public static boolean sendConsole(CommandSender sender) { diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/util/Cuboid.java b/src/main/java/nl/sbdeveloper/themeparkplus/util/Cuboid.java similarity index 97% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/util/Cuboid.java rename to src/main/java/nl/sbdeveloper/themeparkplus/util/Cuboid.java index 12983f7..0313aab 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/util/Cuboid.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/util/Cuboid.java @@ -6,8 +6,6 @@ import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.util.Vector; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.*; @@ -16,7 +14,7 @@ public class Cuboid implements Cloneable, ConfigurationSerializable, Iterable serializedCuboid) { try { String worldName = (String) serializedCuboid.get("worldName"); diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/util/DirectionUtil.java b/src/main/java/nl/sbdeveloper/themeparkplus/util/DirectionUtil.java similarity index 95% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/util/DirectionUtil.java rename to src/main/java/nl/sbdeveloper/themeparkplus/util/DirectionUtil.java index 5305839..7fd48c5 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/util/DirectionUtil.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/util/DirectionUtil.java @@ -2,11 +2,8 @@ package nl.sbdeveloper.themeparkplus.util; import nl.sbdeveloper.themeparkplus.api.enums.WalkingDirection; import org.bukkit.block.BlockFace; -import org.jetbrains.annotations.Nullable; public class DirectionUtil { - - @Nullable public static WalkingDirection getDirection(int xoud, int zoud, int xnieuw, int znieuw) { int changeInX = xnieuw - xoud; int changeInZ = znieuw - zoud; diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/util/DiscordWebhook.java b/src/main/java/nl/sbdeveloper/themeparkplus/util/DiscordWebhook.java similarity index 99% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/util/DiscordWebhook.java rename to src/main/java/nl/sbdeveloper/themeparkplus/util/DiscordWebhook.java index 78bcbe4..0e47f48 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/util/DiscordWebhook.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/util/DiscordWebhook.java @@ -17,7 +17,6 @@ import java.util.Set; * Class used to execute Discord Webhooks with low effort */ public class DiscordWebhook { - private final String url; private String content; private String username; diff --git a/src/main/java/nl/sbdeveloper/themeparkplus/util/Inventory.java b/src/main/java/nl/sbdeveloper/themeparkplus/util/Inventory.java new file mode 100644 index 0000000..30ae24b --- /dev/null +++ b/src/main/java/nl/sbdeveloper/themeparkplus/util/Inventory.java @@ -0,0 +1,53 @@ +package nl.sbdeveloper.themeparkplus.util; + +import fr.minuskube.inv.InventoryManager; +import fr.minuskube.inv.SmartInventory; +import fr.minuskube.inv.content.InventoryContents; +import fr.minuskube.inv.content.InventoryProvider; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import static nl.sbdeveloper.themeparkplus.util.ConfigUtil.__; + +public abstract class Inventory implements InventoryProvider { + /* + This file is part of FrogRacing. + Copyright (c) 2018-2021 FrogNetwork - All Rights Reserved + Unauthorized copying of this file, via any medium is strictly prohibited + Proprietary and confidential + Written by Stijn Bannink , March 2020 + */ + + private static InventoryManager manager; + protected SmartInventory inventory; + + public Inventory(int rows, String title) { + this(rows, title, true); //Standaard sluitbaar! + } + + public Inventory(int rows, String title, boolean closeable) { + this.inventory = SmartInventory.builder().id(title).provider(this).manager(manager).size(rows, 9).closeable(closeable).title(__("&8" + title)).build(); + } + + @Override + public void update(Player player, InventoryContents contents) { + // Niet altijd nodig, daarom staat hij hier alvast. + } + + protected void open(Player player) { + this.inventory.open(player); + } + + protected void open(Player player, int page) { + this.inventory.open(player, page); + } + + public void close(Player player) { + this.inventory.close(player); + } + + public static void init(JavaPlugin plugin) { + manager = new InventoryManager(plugin); + manager.init(); + } +} diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/util/LGUtil.java b/src/main/java/nl/sbdeveloper/themeparkplus/util/LGUtil.java similarity index 85% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/util/LGUtil.java rename to src/main/java/nl/sbdeveloper/themeparkplus/util/LGUtil.java index d5b411c..5aab4b6 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/util/LGUtil.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/util/LGUtil.java @@ -1,13 +1,10 @@ package nl.sbdeveloper.themeparkplus.util; -import nl.sbdeveloper.themeparkplus.ThemeParkPlus; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; -import org.bukkit.util.Vector; -import org.jetbrains.annotations.Nullable; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -17,11 +14,7 @@ import java.util.List; import java.util.Objects; public class LGUtil { - - private static final List offsets = new ArrayList<>(); - private static final List nearbyBlocks = new ArrayList<>(); - - private static boolean nieuweVersie = false; + private static boolean is113Plus = false; private static Method getBlockDataMethod; private static Method setBlockDataMethod; @@ -30,13 +23,6 @@ public class LGUtil { private static Object lampUitData; static { - offsets.add(new Vector(1, 0, 0)); - offsets.add(new Vector(-1, 0, 0)); - offsets.add(new Vector(0, 1, 0)); - offsets.add(new Vector(0, -1, 0)); - offsets.add(new Vector(0, 0, 1)); - offsets.add(new Vector(0, 0, -1)); - try { Class blockDataClass = Class.forName("org.bukkit.block.data.BlockData"); Method methodCreateBlockData = Bukkit.class.getMethod("createBlockData", String.class); @@ -46,12 +32,12 @@ public class LGUtil { getAsStringMethod = blockDataClass.getMethod("getAsString"); lampAanData = methodCreateBlockData.invoke(null, "minecraft:redstone_lamp[lit=true]"); lampUitData = methodCreateBlockData.invoke(null, "minecraft:redstone_lamp[lit=false]"); - nieuweVersie = true; + is113Plus = true; } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {} } public static boolean zetLampAan(Block lampBlock) { - if (nieuweVersie) { + if (is113Plus) { if ((isLamp(lampBlock)) && (!isAan(lampBlock))) { setBlockData(lampBlock, lampAanData); @@ -65,23 +51,11 @@ public class LGUtil { if (neighbor != null) { BlockState neighborState = neighbor.getState(); try { - for (org.bukkit.util.Vector offset: offsets) { - Block neighborOfNeighbor = neighbor.getLocation().add(offset).getBlock(); - if ((neighborOfNeighbor.getX() != lampBlock.getX()) || (neighborOfNeighbor.getY() != lampBlock.getY()) || (neighborOfNeighbor.getZ() != lampBlock.getZ())) { - nearbyBlocks.add(neighborOfNeighbor); - } - } neighbor.setType(Material.REDSTONE_BLOCK); } catch (Exception e) { e.printStackTrace(); } finally { neighborState.update(true, false); - Bukkit.getScheduler().runTaskLater(ThemeParkPlus.getInstance(), () -> { - for (Vector offset: offsets) { - Block neighborOfNeighbor = neighbor.getLocation().add(offset).getBlock(); - nearbyBlocks.remove(neighborOfNeighbor); - } - }, 1L); } return true; } @@ -91,7 +65,7 @@ public class LGUtil { } public static boolean zetLampUit(Block lampBlock) { - if (nieuweVersie) { + if (is113Plus) { if ((isLamp(lampBlock)) && (isAan(lampBlock))) { setBlockData(lampBlock, lampUitData); @@ -112,7 +86,7 @@ public class LGUtil { } public static boolean openGate(Block b, BlockFace openFace) { - if (nieuweVersie) { + if (is113Plus) { org.bukkit.block.data.BlockData blockData = b.getBlockData(); if (isOpenable(b)) { org.bukkit.block.data.Openable op = (org.bukkit.block.data.Openable) blockData; @@ -145,7 +119,7 @@ public class LGUtil { } public static boolean closeGate(Block b) { - if (nieuweVersie) { + if (is113Plus) { org.bukkit.block.data.BlockData blockData = b.getBlockData(); if (isOpenable(b)) { org.bukkit.block.data.Openable op = (org.bukkit.block.data.Openable) blockData; @@ -172,9 +146,8 @@ public class LGUtil { return false; } - @Nullable public static BlockFace getDirection(Block b) { - if (nieuweVersie) { + if (is113Plus) { org.bukkit.block.data.BlockData blockData = b.getBlockData(); if (isOpenable(b)) { org.bukkit.block.data.Directional dir = (org.bukkit.block.data.Directional) blockData; @@ -191,7 +164,7 @@ public class LGUtil { } public static boolean isOpen(Block b) { - if (nieuweVersie) { + if (is113Plus) { org.bukkit.block.data.BlockData blockData = b.getBlockData(); if (isOpenable(b)) { org.bukkit.block.data.Openable op = (org.bukkit.block.data.Openable) blockData; @@ -212,7 +185,7 @@ public class LGUtil { if (b == null) { return false; } - if (nieuweVersie) { + if (is113Plus) { return b.getBlockData() instanceof org.bukkit.block.data.Openable; } else { return b.getState().getData() instanceof org.bukkit.material.Openable; @@ -253,7 +226,7 @@ public class LGUtil { } private static boolean isAan(Block lamp) { - if (nieuweVersie) { + if (is113Plus) { return getAsString(getBlockData(lamp)).contains("lit=true"); } else { return lamp.getType() == Material.matchMaterial(XMaterial.REDSTONE_LAMP.getLegacy()[0]); @@ -261,7 +234,7 @@ public class LGUtil { } private static boolean isLamp(Block lamp) { - if (nieuweVersie) { + if (is113Plus) { return lamp.getType() == XMaterial.REDSTONE_LAMP.parseMaterial(); } else { return Arrays.asList(XMaterial.REDSTONE_LAMP.getLegacy()).contains(lamp.getType().name()); diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/util/License.java b/src/main/java/nl/sbdeveloper/themeparkplus/util/License.java similarity index 95% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/util/License.java rename to src/main/java/nl/sbdeveloper/themeparkplus/util/License.java index e1b2305..fc01aae 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/util/License.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/util/License.java @@ -9,8 +9,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.plugin.java.JavaPlugin; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.io.BufferedReader; import java.io.IOException; @@ -42,8 +40,8 @@ public class License implements Listener { private final JavaPlugin plugin; // The plugin instance private final String license; // The license code private final String prefix; // The correct prefix for this plugin - @Nullable private String invalidReason; // The reason the license is invalid, if null it's not invalid! - @Nullable private static Boolean valid; // If true, it's valid, if false, it's not valid, if null it's not checked! + private String invalidReason; // The reason the license is invalid, if null it's not invalid! + private static Boolean valid; // If true, it's valid, if false, it's not valid, if null it's not checked! /** * Construct a new license @@ -84,7 +82,7 @@ public class License implements Listener { //STEP 2: Send license request String url = "https://sbdplugins.nl/wp-json/lmfwc/v2/licenses/" + this.license; - @Nullable JsonObject response; + JsonObject response; try { response = sendGETRequestJSON(url); } catch (IOException e) { @@ -231,7 +229,6 @@ public class License implements Listener { * @return The JSONObject * @throws IOException URL errors */ - @Nullable private JsonObject sendGETRequestJSON(String uri) throws IOException { URL url = new URL(uri); HttpURLConnection con = (HttpURLConnection) url.openConnection(); @@ -258,7 +255,7 @@ public class License implements Listener { return parser.parse(response.toString()).getAsJsonObject(); } - private boolean checkPortValue(int input, @NotNull String dataValue) { + private boolean checkPortValue(int input, String dataValue) { //STEP 1: Check wildcard if (dataValue.equals("*")) return true; @@ -309,7 +306,6 @@ public class License implements Listener { * * @return true -> VALID, false -> INVALID, null -> UNCHECKED */ - @Nullable public static Boolean isValid() { return valid; } diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/util/LocationGsonAdapter.java b/src/main/java/nl/sbdeveloper/themeparkplus/util/LocationGsonAdapter.java similarity index 100% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/util/LocationGsonAdapter.java rename to src/main/java/nl/sbdeveloper/themeparkplus/util/LocationGsonAdapter.java diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/util/XMaterial.java b/src/main/java/nl/sbdeveloper/themeparkplus/util/XMaterial.java similarity index 83% rename from src/main/lombok/nl/sbdeveloper/themeparkplus/util/XMaterial.java rename to src/main/java/nl/sbdeveloper/themeparkplus/util/XMaterial.java index 60d41c7..7b36ed1 100644 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/util/XMaterial.java +++ b/src/main/java/nl/sbdeveloper/themeparkplus/util/XMaterial.java @@ -2,7 +2,7 @@ * The MIT License (MIT) * * Copyright (c) 2018 Hex_27 - * Copyright (c) 2021 Crypto Morin + * Copyright (c) 2022 Crypto Morin * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -25,8 +25,6 @@ package nl.sbdeveloper.themeparkplus.util; import com.google.common.base.Enums; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.Validate; import org.apache.commons.lang.WordUtils; @@ -36,6 +34,7 @@ import org.bukkit.inventory.ItemStack; import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; @@ -59,7 +58,7 @@ import java.util.regex.PatternSyntaxException; * /give @p minecraft:dirt 1 10 where 1 is the item amount, and 10 is the data value. The material {@link #DIRT} with a data value of {@code 10} doesn't exist. * * @author Crypto Morin - * @version 10.0.0 + * @version 10.1.1.1 * @see Material * @see ItemStack */ @@ -93,7 +92,7 @@ public enum XMaterial { AMETHYST_BLOCK, AMETHYST_CLUSTER, AMETHYST_SHARD, - ANCIENT_DEBRIS(16), + ANCIENT_DEBRIS, ANDESITE(5, "STONE"), ANDESITE_SLAB, ANDESITE_STAIRS, @@ -110,16 +109,16 @@ public enum XMaterial { AZALEA_LEAVES, AZURE_BLUET(3, "RED_ROSE"), BAKED_POTATO, - BAMBOO(0, 14), - BAMBOO_SAPLING(14), - BARREL(0, 14), + BAMBOO, + BAMBOO_SAPLING, + BARREL, BARRIER, - BASALT(16), + BASALT, BAT_SPAWN_EGG(65, "MONSTER_EGG"), BEACON, BEDROCK, BEEF("RAW_BEEF"), - BEEHIVE(15), + BEEHIVE, /** * Beetroot is a known material in pre-1.13 */ @@ -127,9 +126,9 @@ public enum XMaterial { BEETROOTS("BEETROOT"), BEETROOT_SEEDS, BEETROOT_SOUP, - BEE_NEST(15), - BEE_SPAWN_EGG(15), - BELL(14), + BEE_NEST, + BEE_SPAWN_EGG, + BELL, BIG_DRIPLEAF, BIG_DRIPLEAF_STEM, BIRCH_BOAT("BOAT_BIRCH"), @@ -148,39 +147,42 @@ public enum XMaterial { BIRCH_TRAPDOOR("TRAP_DOOR"), BIRCH_WALL_SIGN("WALL_SIGN"), BIRCH_WOOD(2, "LOG"), - BLACKSTONE(16), - BLACKSTONE_SLAB(16), - BLACKSTONE_STAIRS(16), - BLACKSTONE_WALL(16), + BLACKSTONE, + BLACKSTONE_SLAB, + BLACKSTONE_STAIRS, + BLACKSTONE_WALL, BLACK_BANNER("STANDING_BANNER", "BANNER"), - BLACK_BED(15, "BED_BLOCK", "BED"), + /** + * Version 1.12+ interprets "BED" as BLACK_BED due to enum alphabetic ordering. + */ + BLACK_BED(supports(12) ? 15 : 0, "BED_BLOCK", "BED"), BLACK_CANDLE, BLACK_CANDLE_CAKE, BLACK_CARPET(15, "CARPET"), BLACK_CONCRETE(15, "CONCRETE"), BLACK_CONCRETE_POWDER(15, "CONCRETE_POWDER"), - BLACK_DYE(0, 14, "INK_SACK", "INK_SAC"), - BLACK_GLAZED_TERRACOTTA(15, 12), + BLACK_DYE("INK_SACK", "INK_SAC"), + BLACK_GLAZED_TERRACOTTA, BLACK_SHULKER_BOX, BLACK_STAINED_GLASS(15, "STAINED_GLASS"), BLACK_STAINED_GLASS_PANE(15, "STAINED_GLASS_PANE"), BLACK_TERRACOTTA(15, "STAINED_CLAY"), BLACK_WALL_BANNER("WALL_BANNER"), BLACK_WOOL(15, "WOOL"), - BLAST_FURNACE(0, 14), + BLAST_FURNACE, BLAZE_POWDER, BLAZE_ROD, BLAZE_SPAWN_EGG(61, "MONSTER_EGG"), BLUE_BANNER(4, "STANDING_BANNER", "BANNER"), - BLUE_BED(11, "BED_BLOCK", "BED"), + BLUE_BED(supports(12) ? 11 : 0, "BED_BLOCK", "BED"), BLUE_CANDLE, BLUE_CANDLE_CAKE, BLUE_CARPET(11, "CARPET"), BLUE_CONCRETE(11, "CONCRETE"), BLUE_CONCRETE_POWDER(11, "CONCRETE_POWDER"), BLUE_DYE(4, "INK_SACK", "LAPIS_LAZULI"), - BLUE_GLAZED_TERRACOTTA(11, 12), - BLUE_ICE(0, 13), + BLUE_GLAZED_TERRACOTTA, + BLUE_ICE, BLUE_ORCHID(1, "RED_ROSE"), BLUE_SHULKER_BOX, BLUE_STAINED_GLASS(11, "STAINED_GLASS"), @@ -195,9 +197,9 @@ public enum XMaterial { BOOKSHELF, BOW, BOWL, - BRAIN_CORAL(13), - BRAIN_CORAL_BLOCK(13), - BRAIN_CORAL_FAN(13), + BRAIN_CORAL, + BRAIN_CORAL_BLOCK, + BRAIN_CORAL_FAN, BRAIN_CORAL_WALL_FAN, BREAD, BREWING_STAND("BREWING_STAND", "BREWING_STAND_ITEM"), @@ -207,14 +209,14 @@ public enum XMaterial { BRICK_STAIRS, BRICK_WALL, BROWN_BANNER(3, "STANDING_BANNER", "BANNER"), - BROWN_BED(12, "BED_BLOCK", "BED"), + BROWN_BED(supports(12) ? 12 : 0, "BED_BLOCK", "BED"), BROWN_CANDLE, BROWN_CANDLE_CAKE, BROWN_CARPET(12, "CARPET"), BROWN_CONCRETE(12, "CONCRETE"), BROWN_CONCRETE_POWDER(12, "CONCRETE_POWDER"), BROWN_DYE(3, "INK_SACK", "DYE", "COCOA_BEANS"), - BROWN_GLAZED_TERRACOTTA(12, 12), + BROWN_GLAZED_TERRACOTTA, BROWN_MUSHROOM, BROWN_MUSHROOM_BLOCK("BROWN_MUSHROOM", "HUGE_MUSHROOM_1"), BROWN_SHULKER_BOX, @@ -223,10 +225,10 @@ public enum XMaterial { BROWN_TERRACOTTA(12, "STAINED_CLAY"), BROWN_WALL_BANNER(3, "WALL_BANNER"), BROWN_WOOL(12, "WOOL"), - BUBBLE_COLUMN(13), - BUBBLE_CORAL(13), - BUBBLE_CORAL_BLOCK(13), - BUBBLE_CORAL_FAN(13), + BUBBLE_COLUMN, + BUBBLE_CORAL, + BUBBLE_CORAL_BLOCK, + BUBBLE_CORAL_FAN, BUBBLE_CORAL_WALL_FAN, BUCKET, BUDDING_AMETHYST, @@ -234,14 +236,14 @@ public enum XMaterial { CACTUS, CAKE("CAKE_BLOCK"), CALCITE, - CAMPFIRE(14), + CAMPFIRE, CANDLE, CANDLE_CAKE, CARROT("CARROT_ITEM"), CARROTS("CARROT"), CARROT_ON_A_STICK("CARROT_STICK"), - CARTOGRAPHY_TABLE(0, 14), - CARVED_PUMPKIN(1, 13), + CARTOGRAPHY_TABLE, + CARVED_PUMPKIN, CAT_SPAWN_EGG, CAULDRON("CAULDRON", "CAULDRON_ITEM"), /** @@ -253,7 +255,7 @@ public enum XMaterial { CAVE_SPIDER_SPAWN_EGG(59, "MONSTER_EGG"), CAVE_VINES, CAVE_VINES_PLANT, - CHAIN(16), + CHAIN, CHAINMAIL_BOOTS, CHAINMAIL_CHESTPLATE, CHAINMAIL_HELMET, @@ -267,14 +269,14 @@ public enum XMaterial { CHIPPED_ANVIL(1, "ANVIL"), CHISELED_DEEPSLATE, CHISELED_NETHER_BRICKS(1, "NETHER_BRICKS"), - CHISELED_POLISHED_BLACKSTONE(0, 16, "POLISHED_BLACKSTONE"), + CHISELED_POLISHED_BLACKSTONE("POLISHED_BLACKSTONE"), CHISELED_QUARTZ_BLOCK(1, "QUARTZ_BLOCK"), CHISELED_RED_SANDSTONE(1, "RED_SANDSTONE"), CHISELED_SANDSTONE(1, "SANDSTONE"), CHISELED_STONE_BRICKS(3, "SMOOTH_BRICK"), - CHORUS_FLOWER(0, 9), - CHORUS_FRUIT(0, 9), - CHORUS_PLANT(0, 9), + CHORUS_FLOWER, + CHORUS_FRUIT, + CHORUS_PLANT, CLAY("HARD_CLAY"), CLAY_BALL, CLOCK("WATCH"), @@ -291,11 +293,11 @@ public enum XMaterial { COBBLESTONE_STAIRS, COBBLESTONE_WALL("COBBLE_WALL"), COBWEB("WEB"), - COCOA(15), + COCOA, COCOA_BEANS(3, "INK_SACK"), COD("RAW_FISH"), - COD_BUCKET(0, 13), - COD_SPAWN_EGG(0, 13), + COD_BUCKET, + COD_SPAWN_EGG, COMMAND_BLOCK("COMMAND"), COMMAND_BLOCK_MINECART("COMMAND_MINECART"), /** @@ -307,8 +309,8 @@ public enum XMaterial { */ COMPARATOR("REDSTONE_COMPARATOR_OFF", "REDSTONE_COMPARATOR_ON", "REDSTONE_COMPARATOR"), COMPASS, - COMPOSTER(0, 14), - CONDUIT(0, 13, "BEACON"), + COMPOSTER, + CONDUIT, COOKED_BEEF, COOKED_CHICKEN, COOKED_COD("COOKED_FISH"), @@ -320,52 +322,52 @@ public enum XMaterial { COPPER_BLOCK, COPPER_INGOT, COPPER_ORE, - CORNFLOWER(4, 14), + CORNFLOWER, COW_SPAWN_EGG(92, "MONSTER_EGG"), CRACKED_DEEPSLATE_BRICKS, CRACKED_DEEPSLATE_TILES, CRACKED_NETHER_BRICKS(2, "NETHER_BRICKS"), - CRACKED_POLISHED_BLACKSTONE_BRICKS(0, 16, "POLISHED_BLACKSTONE_BRICKS"), + CRACKED_POLISHED_BLACKSTONE_BRICKS("POLISHED_BLACKSTONE_BRICKS"), CRACKED_STONE_BRICKS(2, "SMOOTH_BRICK"), CRAFTING_TABLE("WORKBENCH"), CREEPER_BANNER_PATTERN, CREEPER_HEAD(4, "SKULL", "SKULL_ITEM"), CREEPER_SPAWN_EGG(50, "MONSTER_EGG"), CREEPER_WALL_HEAD(4, "SKULL", "SKULL_ITEM"), - CRIMSON_BUTTON(16), - CRIMSON_DOOR(16), - CRIMSON_FENCE(16), - CRIMSON_FENCE_GATE(16), - CRIMSON_FUNGUS(16), - CRIMSON_HYPHAE(16), - CRIMSON_NYLIUM(16), - CRIMSON_PLANKS(16), - CRIMSON_PRESSURE_PLATE(16), - CRIMSON_ROOTS(16), - CRIMSON_SIGN(0, 16, "SIGN_POST"), - CRIMSON_SLAB(16), - CRIMSON_STAIRS(16), - CRIMSON_STEM(16), - CRIMSON_TRAPDOOR(16), - CRIMSON_WALL_SIGN(0, 16, "WALL_SIGN"), + CRIMSON_BUTTON, + CRIMSON_DOOR, + CRIMSON_FENCE, + CRIMSON_FENCE_GATE, + CRIMSON_FUNGUS, + CRIMSON_HYPHAE, + CRIMSON_NYLIUM, + CRIMSON_PLANKS, + CRIMSON_PRESSURE_PLATE, + CRIMSON_ROOTS, + CRIMSON_SIGN("SIGN_POST"), + CRIMSON_SLAB, + CRIMSON_STAIRS, + CRIMSON_STEM, + CRIMSON_TRAPDOOR, + CRIMSON_WALL_SIGN("WALL_SIGN"), CROSSBOW, - CRYING_OBSIDIAN(16), + CRYING_OBSIDIAN, CUT_COPPER, CUT_COPPER_SLAB, CUT_COPPER_STAIRS, - CUT_RED_SANDSTONE(13), + CUT_RED_SANDSTONE, CUT_RED_SANDSTONE_SLAB("STONE_SLAB2"), - CUT_SANDSTONE(13), + CUT_SANDSTONE, CUT_SANDSTONE_SLAB("STEP"), CYAN_BANNER(6, "STANDING_BANNER", "BANNER"), - CYAN_BED(9, "BED_BLOCK", "BED"), + CYAN_BED(supports(12) ? 9 : 0, "BED_BLOCK", "BED"), CYAN_CANDLE, CYAN_CANDLE_CAKE, CYAN_CARPET(9, "CARPET"), CYAN_CONCRETE(9, "CONCRETE"), CYAN_CONCRETE_POWDER(9, "CONCRETE_POWDER"), CYAN_DYE(6, "INK_SACK"), - CYAN_GLAZED_TERRACOTTA(9, 12), + CYAN_GLAZED_TERRACOTTA, CYAN_SHULKER_BOX, CYAN_STAINED_GLASS(9, "STAINED_GLASS"), CYAN_STAINED_GLASS_PANE(9, "STAINED_GLASS_PANE"), @@ -379,7 +381,7 @@ public enum XMaterial { DARK_OAK_DOOR("DARK_OAK_DOOR", "DARK_OAK_DOOR_ITEM"), DARK_OAK_FENCE, DARK_OAK_FENCE_GATE, - DARK_OAK_LEAVES(4, "LEAVES", "LEAVES_2"), + DARK_OAK_LEAVES(1, "LEAVES_2"), DARK_OAK_LOG(1, "LOG_2"), DARK_OAK_PLANKS(5, "WOOD"), DARK_OAK_PRESSURE_PLATE("WOOD_PLATE"), @@ -391,31 +393,31 @@ public enum XMaterial { DARK_OAK_WALL_SIGN("WALL_SIGN"), DARK_OAK_WOOD(1, "LOG_2"), DARK_PRISMARINE(1, "PRISMARINE"), - DARK_PRISMARINE_SLAB(13), - DARK_PRISMARINE_STAIRS(13), + DARK_PRISMARINE_SLAB, + DARK_PRISMARINE_STAIRS, DAYLIGHT_DETECTOR("DAYLIGHT_DETECTOR_INVERTED"), - DEAD_BRAIN_CORAL(13), - DEAD_BRAIN_CORAL_BLOCK(13), - DEAD_BRAIN_CORAL_FAN(13), - DEAD_BRAIN_CORAL_WALL_FAN(13), - DEAD_BUBBLE_CORAL(13), - DEAD_BUBBLE_CORAL_BLOCK(13), - DEAD_BUBBLE_CORAL_FAN(13), - DEAD_BUBBLE_CORAL_WALL_FAN(13), - DEAD_BUSH, - DEAD_FIRE_CORAL(13), - DEAD_FIRE_CORAL_BLOCK(13), - DEAD_FIRE_CORAL_FAN(13), - DEAD_FIRE_CORAL_WALL_FAN(13), - DEAD_HORN_CORAL(13), - DEAD_HORN_CORAL_BLOCK(13), - DEAD_HORN_CORAL_FAN(13), - DEAD_HORN_CORAL_WALL_FAN(13), - DEAD_TUBE_CORAL(13), - DEAD_TUBE_CORAL_BLOCK(13), - DEAD_TUBE_CORAL_FAN(13), - DEAD_TUBE_CORAL_WALL_FAN(13), - DEBUG_STICK(0, 13), + DEAD_BRAIN_CORAL, + DEAD_BRAIN_CORAL_BLOCK, + DEAD_BRAIN_CORAL_FAN, + DEAD_BRAIN_CORAL_WALL_FAN, + DEAD_BUBBLE_CORAL, + DEAD_BUBBLE_CORAL_BLOCK, + DEAD_BUBBLE_CORAL_FAN, + DEAD_BUBBLE_CORAL_WALL_FAN, + DEAD_BUSH("LONG_GRASS"), + DEAD_FIRE_CORAL, + DEAD_FIRE_CORAL_BLOCK, + DEAD_FIRE_CORAL_FAN, + DEAD_FIRE_CORAL_WALL_FAN, + DEAD_HORN_CORAL, + DEAD_HORN_CORAL_BLOCK, + DEAD_HORN_CORAL_FAN, + DEAD_HORN_CORAL_WALL_FAN, + DEAD_TUBE_CORAL, + DEAD_TUBE_CORAL_BLOCK, + DEAD_TUBE_CORAL_FAN, + DEAD_TUBE_CORAL_WALL_FAN, + DEBUG_STICK, DEEPSLATE, DEEPSLATE_BRICKS, DEEPSLATE_BRICK_SLAB, @@ -457,17 +459,17 @@ public enum XMaterial { */ DIRT_PATH("GRASS_PATH"), DISPENSER, - DOLPHIN_SPAWN_EGG(0, 13), + DOLPHIN_SPAWN_EGG, DONKEY_SPAWN_EGG(32, "MONSTER_EGG"), DRAGON_BREATH("DRAGONS_BREATH"), DRAGON_EGG, - DRAGON_HEAD(5, 9, "SKULL", "SKULL_ITEM"), + DRAGON_HEAD("SKULL", "SKULL_ITEM"), DRAGON_WALL_HEAD(5, "SKULL", "SKULL_ITEM"), - DRIED_KELP(13), - DRIED_KELP_BLOCK(13), + DRIED_KELP, + DRIED_KELP_BLOCK, DRIPSTONE_BLOCK, DROPPER, - DROWNED_SPAWN_EGG(0, 13), + DROWNED_SPAWN_EGG, EGG, ELDER_GUARDIAN_SPAWN_EGG(4, "MONSTER_EGG"), ELYTRA, @@ -483,10 +485,10 @@ public enum XMaterial { ENDER_EYE("EYE_OF_ENDER"), ENDER_PEARL, END_CRYSTAL, - END_GATEWAY(0, 9), + END_GATEWAY, END_PORTAL("ENDER_PORTAL"), END_PORTAL_FRAME("ENDER_PORTAL_FRAME"), - END_ROD(0, 9), + END_ROD, END_STONE("ENDER_STONE"), END_STONE_BRICKS("END_BRICKS"), END_STONE_BRICK_SLAB(6, "STEP"), @@ -513,28 +515,28 @@ public enum XMaterial { FIREWORK_ROCKET("FIREWORK"), FIREWORK_STAR("FIREWORK_CHARGE"), FIRE_CHARGE("FIREBALL"), - FIRE_CORAL(13), - FIRE_CORAL_BLOCK(13), - FIRE_CORAL_FAN(13), + FIRE_CORAL, + FIRE_CORAL_BLOCK, + FIRE_CORAL_FAN, FIRE_CORAL_WALL_FAN, FISHING_ROD, - FLETCHING_TABLE(0, 14), + FLETCHING_TABLE, FLINT, FLINT_AND_STEEL, FLOWERING_AZALEA, FLOWERING_AZALEA_LEAVES, FLOWER_BANNER_PATTERN, FLOWER_POT("FLOWER_POT", "FLOWER_POT_ITEM"), - FOX_SPAWN_EGG(14), + FOX_SPAWN_EGG, /** * This special material cannot be obtained as an item. */ - FROSTED_ICE(0, 9), + FROSTED_ICE, FURNACE("BURNING_FURNACE"), FURNACE_MINECART("POWERED_MINECART"), GHAST_SPAWN_EGG(56, "MONSTER_EGG"), GHAST_TEAR, - GILDED_BLACKSTONE(16), + GILDED_BLACKSTONE, GLASS, GLASS_BOTTLE, GLASS_PANE("THIN_GLASS"), @@ -572,14 +574,14 @@ public enum XMaterial { GRASS_BLOCK("GRASS"), GRAVEL, GRAY_BANNER(8, "STANDING_BANNER", "BANNER"), - GRAY_BED(7, "BED_BLOCK", "BED"), + GRAY_BED(supports(12) ? 7 : 0, "BED_BLOCK", "BED"), GRAY_CANDLE, GRAY_CANDLE_CAKE, GRAY_CARPET(7, "CARPET"), GRAY_CONCRETE(7, "CONCRETE"), GRAY_CONCRETE_POWDER(7, "CONCRETE_POWDER"), GRAY_DYE(8, "INK_SACK"), - GRAY_GLAZED_TERRACOTTA(7, 12), + GRAY_GLAZED_TERRACOTTA, GRAY_SHULKER_BOX, GRAY_STAINED_GLASS(7, "STAINED_GLASS"), GRAY_STAINED_GLASS_PANE(7, "THIN_GLASS", "STAINED_GLASS_PANE"), @@ -587,37 +589,37 @@ public enum XMaterial { GRAY_WALL_BANNER(8, "WALL_BANNER"), GRAY_WOOL(7, "WOOL"), GREEN_BANNER(2, "STANDING_BANNER", "BANNER"), - GREEN_BED(13, "BED_BLOCK", "BED"), + GREEN_BED(supports(12) ? 13 : 0, "BED_BLOCK", "BED"), GREEN_CANDLE, GREEN_CANDLE_CAKE, GREEN_CARPET(13, "CARPET"), GREEN_CONCRETE(13, "CONCRETE"), GREEN_CONCRETE_POWDER(13, "CONCRETE_POWDER"), GREEN_DYE(2, "INK_SACK", "CACTUS_GREEN"), - GREEN_GLAZED_TERRACOTTA(13, 12), + GREEN_GLAZED_TERRACOTTA, GREEN_SHULKER_BOX, GREEN_STAINED_GLASS(13, "STAINED_GLASS"), GREEN_STAINED_GLASS_PANE(13, "THIN_GLASS", "STAINED_GLASS_PANE"), GREEN_TERRACOTTA(13, "STAINED_CLAY"), GREEN_WALL_BANNER(2, "WALL_BANNER"), GREEN_WOOL(13, "WOOL"), - GRINDSTONE(0, 14), + GRINDSTONE, GUARDIAN_SPAWN_EGG(68, "MONSTER_EGG"), GUNPOWDER("SULPHUR"), HANGING_ROOTS, HAY_BLOCK, - HEART_OF_THE_SEA(13), + HEART_OF_THE_SEA, HEAVY_WEIGHTED_PRESSURE_PLATE("IRON_PLATE"), - HOGLIN_SPAWN_EGG(0, 16, "MONSTER_EGG"), - HONEYCOMB(15), - HONEYCOMB_BLOCK(15), - HONEY_BLOCK(0, 15), - HONEY_BOTTLE(0, 15), + HOGLIN_SPAWN_EGG("MONSTER_EGG"), + HONEYCOMB, + HONEYCOMB_BLOCK, + HONEY_BLOCK, + HONEY_BOTTLE, HOPPER, HOPPER_MINECART, - HORN_CORAL(13), - HORN_CORAL_BLOCK(13), - HORN_CORAL_FAN(13), + HORN_CORAL, + HORN_CORAL_BLOCK, + HORN_CORAL_FAN, HORN_CORAL_WALL_FAN, HORSE_SPAWN_EGG(100, "MONSTER_EGG"), HUSK_SPAWN_EGG(23, "MONSTER_EGG"), @@ -654,7 +656,7 @@ public enum XMaterial { IRON_TRAPDOOR, ITEM_FRAME, JACK_O_LANTERN, - JIGSAW(0, 14), + JIGSAW, JUKEBOX, JUNGLE_BOAT("BOAT_JUNGLE"), JUNGLE_BUTTON("WOOD_BUTTON"), @@ -672,11 +674,11 @@ public enum XMaterial { JUNGLE_TRAPDOOR("TRAP_DOOR"), JUNGLE_WALL_SIGN("WALL_SIGN"), JUNGLE_WOOD(3, "LOG"), - KELP(13), - KELP_PLANT(13), - KNOWLEDGE_BOOK(0, 12, "BOOK"), + KELP, + KELP_PLANT, + KNOWLEDGE_BOOK("BOOK"), LADDER, - LANTERN(0, 14), + LANTERN, LAPIS_BLOCK, LAPIS_LAZULI(4, "INK_SACK"), LAPIS_ORE, @@ -690,21 +692,21 @@ public enum XMaterial { LEATHER_BOOTS, LEATHER_CHESTPLATE, LEATHER_HELMET, - LEATHER_HORSE_ARMOR(0, 14, "IRON_HORSE_ARMOR"), + LEATHER_HORSE_ARMOR("IRON_HORSE_ARMOR"), LEATHER_LEGGINGS, - LECTERN(0, 14), + LECTERN, LEVER, LIGHT, LIGHTNING_ROD, LIGHT_BLUE_BANNER(12, "STANDING_BANNER", "BANNER"), - LIGHT_BLUE_BED(3, "BED_BLOCK", "BED"), + LIGHT_BLUE_BED(supports(12) ? 3 : 0, "BED_BLOCK", "BED"), LIGHT_BLUE_CANDLE, LIGHT_BLUE_CANDLE_CAKE, LIGHT_BLUE_CARPET(3, "CARPET"), LIGHT_BLUE_CONCRETE(3, "CONCRETE"), LIGHT_BLUE_CONCRETE_POWDER(3, "CONCRETE_POWDER"), LIGHT_BLUE_DYE(12, "INK_SACK"), - LIGHT_BLUE_GLAZED_TERRACOTTA(3, 12), + LIGHT_BLUE_GLAZED_TERRACOTTA, LIGHT_BLUE_SHULKER_BOX, LIGHT_BLUE_STAINED_GLASS(3, "STAINED_GLASS"), LIGHT_BLUE_STAINED_GLASS_PANE(3, "THIN_GLASS", "STAINED_GLASS_PANE"), @@ -712,7 +714,7 @@ public enum XMaterial { LIGHT_BLUE_WALL_BANNER(12, "WALL_BANNER", "STANDING_BANNER", "BANNER"), LIGHT_BLUE_WOOL(3, "WOOL"), LIGHT_GRAY_BANNER(7, "STANDING_BANNER", "BANNER"), - LIGHT_GRAY_BED(8, "BED_BLOCK", "BED"), + LIGHT_GRAY_BED(supports(12) ? 8 : 0, "BED_BLOCK", "BED"), LIGHT_GRAY_CANDLE, LIGHT_GRAY_CANDLE_CAKE, LIGHT_GRAY_CARPET(8, "CARPET"), @@ -723,7 +725,7 @@ public enum XMaterial { * Renamed to SILVER_GLAZED_TERRACOTTA in 1.12 * Renamed to LIGHT_GRAY_GLAZED_TERRACOTTA in 1.14 */ - LIGHT_GRAY_GLAZED_TERRACOTTA(0, 12, "STAINED_CLAY", "LIGHT_GRAY_TERRACOTTA", "SILVER_GLAZED_TERRACOTTA"), + LIGHT_GRAY_GLAZED_TERRACOTTA("STAINED_CLAY", "LIGHT_GRAY_TERRACOTTA", "SILVER_GLAZED_TERRACOTTA"), LIGHT_GRAY_SHULKER_BOX("SILVER_SHULKER_BOX"), LIGHT_GRAY_STAINED_GLASS(8, "STAINED_GLASS"), LIGHT_GRAY_STAINED_GLASS_PANE(8, "THIN_GLASS", "STAINED_GLASS_PANE"), @@ -732,17 +734,17 @@ public enum XMaterial { LIGHT_GRAY_WOOL(8, "WOOL"), LIGHT_WEIGHTED_PRESSURE_PLATE("GOLD_PLATE"), LILAC(1, "DOUBLE_PLANT"), - LILY_OF_THE_VALLEY(15, 14), + LILY_OF_THE_VALLEY, LILY_PAD("WATER_LILY"), LIME_BANNER(10, "STANDING_BANNER", "BANNER"), - LIME_BED(5, "BED_BLOCK", "BED"), + LIME_BED(supports(12) ? 5 : 0, "BED_BLOCK", "BED"), LIME_CANDLE, LIME_CANDLE_CAKE, LIME_CARPET(5, "CARPET"), LIME_CONCRETE(5, "CONCRETE"), LIME_CONCRETE_POWDER(5, "CONCRETE_POWDER"), LIME_DYE(10, "INK_SACK"), - LIME_GLAZED_TERRACOTTA(5, 12), + LIME_GLAZED_TERRACOTTA, LIME_SHULKER_BOX, LIME_STAINED_GLASS(5, "STAINED_GLASS"), LIME_STAINED_GLASS_PANE(5, "STAINED_GLASS_PANE"), @@ -751,24 +753,24 @@ public enum XMaterial { LIME_WOOL(5, "WOOL"), LINGERING_POTION, LLAMA_SPAWN_EGG(103, "MONSTER_EGG"), - LODESTONE(16), - LOOM(14), + LODESTONE, + LOOM, MAGENTA_BANNER(13, "STANDING_BANNER", "BANNER"), - MAGENTA_BED(2, "BED_BLOCK", "BED"), + MAGENTA_BED(supports(12) ? 2 : 0, "BED_BLOCK", "BED"), MAGENTA_CANDLE, MAGENTA_CANDLE_CAKE, MAGENTA_CARPET(2, "CARPET"), MAGENTA_CONCRETE(2, "CONCRETE"), MAGENTA_CONCRETE_POWDER(2, "CONCRETE_POWDER"), MAGENTA_DYE(13, "INK_SACK"), - MAGENTA_GLAZED_TERRACOTTA(2, 12), + MAGENTA_GLAZED_TERRACOTTA, MAGENTA_SHULKER_BOX, MAGENTA_STAINED_GLASS(2, "STAINED_GLASS"), MAGENTA_STAINED_GLASS_PANE(2, "THIN_GLASS", "STAINED_GLASS_PANE"), MAGENTA_TERRACOTTA(2, "STAINED_CLAY"), MAGENTA_WALL_BANNER(13, "WALL_BANNER"), MAGENTA_WOOL(2, "WOOL"), - MAGMA_BLOCK(0, 10, "MAGMA"), + MAGMA_BLOCK("MAGMA"), MAGMA_CREAM, MAGMA_CUBE_SPAWN_EGG(62, "MONSTER_EGG"), /** @@ -810,7 +812,8 @@ public enum XMaterial { MUSIC_DISC_FAR("RECORD_6"), MUSIC_DISC_MALL("RECORD_7"), MUSIC_DISC_MELLOHI("RECORD_8"), - MUSIC_DISC_PIGSTEP(16), + MUSIC_DISC_OTHERSIDE, + MUSIC_DISC_PIGSTEP, MUSIC_DISC_STAL("RECORD_9"), MUSIC_DISC_STRAD("RECORD_10"), MUSIC_DISC_WAIT("RECORD_11"), @@ -818,19 +821,19 @@ public enum XMaterial { MUTTON, MYCELIUM("MYCEL"), NAME_TAG, - NAUTILUS_SHELL(13), - NETHERITE_AXE(16), - NETHERITE_BLOCK(16), - NETHERITE_BOOTS(16), - NETHERITE_CHESTPLATE(16), - NETHERITE_HELMET(16), - NETHERITE_HOE(16), - NETHERITE_INGOT(16), - NETHERITE_LEGGINGS(16), - NETHERITE_PICKAXE(16), - NETHERITE_SCRAP(16), - NETHERITE_SHOVEL(16), - NETHERITE_SWORD(16), + NAUTILUS_SHELL, + NETHERITE_AXE, + NETHERITE_BLOCK, + NETHERITE_BOOTS, + NETHERITE_CHESTPLATE, + NETHERITE_HELMET, + NETHERITE_HOE, + NETHERITE_INGOT, + NETHERITE_LEGGINGS, + NETHERITE_PICKAXE, + NETHERITE_SCRAP, + NETHERITE_SHOVEL, + NETHERITE_SWORD, NETHERRACK, NETHER_BRICK("NETHER_BRICK_ITEM"), NETHER_BRICKS("NETHER_BRICK"), @@ -838,10 +841,10 @@ public enum XMaterial { NETHER_BRICK_SLAB(6, "STEP"), NETHER_BRICK_STAIRS, NETHER_BRICK_WALL, - NETHER_GOLD_ORE(16), + NETHER_GOLD_ORE, NETHER_PORTAL("PORTAL"), NETHER_QUARTZ_ORE("QUARTZ_ORE"), - NETHER_SPROUTS(16), + NETHER_SPROUTS, NETHER_STAR, /** * Just like mentioned in https://minecraft.gamepedia.com/Nether_Wart @@ -871,14 +874,14 @@ public enum XMaterial { OBSIDIAN, OCELOT_SPAWN_EGG(98, "MONSTER_EGG"), ORANGE_BANNER(14, "STANDING_BANNER", "BANNER"), - ORANGE_BED(1, "BED_BLOCK", "BED"), + ORANGE_BED(supports(12) ? 1 : 0, "BED_BLOCK", "BED"), ORANGE_CANDLE, ORANGE_CANDLE_CAKE, ORANGE_CARPET(1, "CARPET"), ORANGE_CONCRETE(1, "CONCRETE"), ORANGE_CONCRETE_POWDER(1, "CONCRETE_POWDER"), ORANGE_DYE(14, "INK_SACK"), - ORANGE_GLAZED_TERRACOTTA(1, 12), + ORANGE_GLAZED_TERRACOTTA, ORANGE_SHULKER_BOX, ORANGE_STAINED_GLASS(1, "STAINED_GLASS"), ORANGE_STAINED_GLASS_PANE(1, "STAINED_GLASS_PANE"), @@ -893,27 +896,27 @@ public enum XMaterial { OXIDIZED_CUT_COPPER_STAIRS, PACKED_ICE, PAINTING, - PANDA_SPAWN_EGG(14), + PANDA_SPAWN_EGG, PAPER, PARROT_SPAWN_EGG(105, "MONSTER_EGG"), PEONY(5, "DOUBLE_PLANT"), PETRIFIED_OAK_SLAB("WOOD_STEP"), - PHANTOM_MEMBRANE(13), - PHANTOM_SPAWN_EGG(0, 13), - PIGLIN_BANNER_PATTERN(16), - PIGLIN_BRUTE_SPAWN_EGG(16), + PHANTOM_MEMBRANE, + PHANTOM_SPAWN_EGG, + PIGLIN_BANNER_PATTERN, + PIGLIN_BRUTE_SPAWN_EGG, PIGLIN_SPAWN_EGG(57, "MONSTER_EGG"), PIG_SPAWN_EGG(90, "MONSTER_EGG"), - PILLAGER_SPAWN_EGG(14), + PILLAGER_SPAWN_EGG, PINK_BANNER(9, "STANDING_BANNER", "BANNER"), - PINK_BED(6, "BED_BLOCK", "BED"), + PINK_BED(supports(12) ? 6 : 0, "BED_BLOCK", "BED"), PINK_CANDLE, PINK_CANDLE_CAKE, PINK_CARPET(6, "CARPET"), PINK_CONCRETE(6, "CONCRETE"), PINK_CONCRETE_POWDER(6, "CONCRETE_POWDER"), PINK_DYE(9, "INK_SACK"), - PINK_GLAZED_TERRACOTTA(6, 12), + PINK_GLAZED_TERRACOTTA, PINK_SHULKER_BOX, PINK_STAINED_GLASS(6, "STAINED_GLASS"), PINK_STAINED_GLASS_PANE(6, "THIN_GLASS", "STAINED_GLASS_PANE"), @@ -932,17 +935,17 @@ public enum XMaterial { POLISHED_ANDESITE(6, "STONE"), POLISHED_ANDESITE_SLAB, POLISHED_ANDESITE_STAIRS, - POLISHED_BASALT(16), - POLISHED_BLACKSTONE(16), - POLISHED_BLACKSTONE_BRICKS(16), - POLISHED_BLACKSTONE_BRICK_SLAB(16), - POLISHED_BLACKSTONE_BRICK_STAIRS(16), - POLISHED_BLACKSTONE_BRICK_WALL(16), - POLISHED_BLACKSTONE_BUTTON(16), - POLISHED_BLACKSTONE_PRESSURE_PLATE(16), - POLISHED_BLACKSTONE_SLAB(16), - POLISHED_BLACKSTONE_STAIRS(16), - POLISHED_BLACKSTONE_WALL(16), + POLISHED_BASALT, + POLISHED_BLACKSTONE, + POLISHED_BLACKSTONE_BRICKS, + POLISHED_BLACKSTONE_BRICK_SLAB, + POLISHED_BLACKSTONE_BRICK_STAIRS, + POLISHED_BLACKSTONE_BRICK_WALL, + POLISHED_BLACKSTONE_BUTTON, + POLISHED_BLACKSTONE_PRESSURE_PLATE, + POLISHED_BLACKSTONE_SLAB, + POLISHED_BLACKSTONE_STAIRS, + POLISHED_BLACKSTONE_WALL, POLISHED_DEEPSLATE, POLISHED_DEEPSLATE_SLAB, POLISHED_DEEPSLATE_STAIRS, @@ -959,35 +962,35 @@ public enum XMaterial { POTATO("POTATO_ITEM"), POTATOES("POTATO"), POTION, - POTTED_ACACIA_SAPLING(4, "SAPLING", "FLOWER_POT"), + POTTED_ACACIA_SAPLING(4, "FLOWER_POT"), POTTED_ALLIUM(2, "RED_ROSE", "FLOWER_POT"), POTTED_AZALEA_BUSH, POTTED_AZURE_BLUET(3, "RED_ROSE", "FLOWER_POT"), POTTED_BAMBOO, - POTTED_BIRCH_SAPLING(2, "SAPLING", "FLOWER_POT"), + POTTED_BIRCH_SAPLING(2, "FLOWER_POT"), POTTED_BLUE_ORCHID(1, "RED_ROSE", "FLOWER_POT"), POTTED_BROWN_MUSHROOM("FLOWER_POT"), POTTED_CACTUS("FLOWER_POT"), POTTED_CORNFLOWER, - POTTED_CRIMSON_FUNGUS(16), - POTTED_CRIMSON_ROOTS(16), + POTTED_CRIMSON_FUNGUS, + POTTED_CRIMSON_ROOTS, POTTED_DANDELION("YELLOW_FLOWER", "FLOWER_POT"), - POTTED_DARK_OAK_SAPLING(5, "SAPLING", "FLOWER_POT"), + POTTED_DARK_OAK_SAPLING(5, "FLOWER_POT"), POTTED_DEAD_BUSH("FLOWER_POT"), POTTED_FERN(2, "LONG_GRASS", "FLOWER_POT"), POTTED_FLOWERING_AZALEA_BUSH, - POTTED_JUNGLE_SAPLING(3, "SAPLING", "FLOWER_POT"), + POTTED_JUNGLE_SAPLING(3, "FLOWER_POT"), POTTED_LILY_OF_THE_VALLEY, - POTTED_OAK_SAPLING("SAPLING", "FLOWER_POT"), + POTTED_OAK_SAPLING("FLOWER_POT"), POTTED_ORANGE_TULIP(5, "RED_ROSE", "FLOWER_POT"), POTTED_OXEYE_DAISY(8, "RED_ROSE", "FLOWER_POT"), POTTED_PINK_TULIP(7, "RED_ROSE", "FLOWER_POT"), POTTED_POPPY("RED_ROSE", "FLOWER_POT"), POTTED_RED_MUSHROOM("FLOWER_POT"), POTTED_RED_TULIP(4, "RED_ROSE", "FLOWER_POT"), - POTTED_SPRUCE_SAPLING(1, "SAPLING", "FLOWER_POT"), - POTTED_WARPED_FUNGUS(16), - POTTED_WARPED_ROOTS(16), + POTTED_SPRUCE_SAPLING(1, "FLOWER_POT"), + POTTED_WARPED_FUNGUS, + POTTED_WARPED_ROOTS, POTTED_WHITE_TULIP(6, "RED_ROSE", "FLOWER_POT"), POTTED_WITHER_ROSE, POWDER_SNOW, @@ -997,28 +1000,28 @@ public enum XMaterial { PRISMARINE, PRISMARINE_BRICKS(2, "PRISMARINE"), PRISMARINE_BRICK_SLAB(4, "STEP"), - PRISMARINE_BRICK_STAIRS(13), + PRISMARINE_BRICK_STAIRS, PRISMARINE_CRYSTALS, PRISMARINE_SHARD, - PRISMARINE_SLAB(13), - PRISMARINE_STAIRS(13), + PRISMARINE_SLAB, + PRISMARINE_STAIRS, PRISMARINE_WALL, PUFFERFISH(3, "RAW_FISH"), - PUFFERFISH_BUCKET(0, 13), - PUFFERFISH_SPAWN_EGG(0, 13), + PUFFERFISH_BUCKET, + PUFFERFISH_SPAWN_EGG, PUMPKIN, PUMPKIN_PIE, PUMPKIN_SEEDS, PUMPKIN_STEM, PURPLE_BANNER(5, "STANDING_BANNER", "BANNER"), - PURPLE_BED(10, "BED_BLOCK", "BED"), + PURPLE_BED(supports(12) ? 10 : 0, "BED_BLOCK", "BED"), PURPLE_CANDLE, PURPLE_CANDLE_CAKE, PURPLE_CARPET(10, "CARPET"), PURPLE_CONCRETE(10, "CONCRETE"), PURPLE_CONCRETE_POWDER(10, "CONCRETE_POWDER"), PURPLE_DYE(5, "INK_SACK"), - PURPLE_GLAZED_TERRACOTTA(10, 12), + PURPLE_GLAZED_TERRACOTTA, PURPLE_SHULKER_BOX, PURPLE_STAINED_GLASS(10, "STAINED_GLASS"), PURPLE_STAINED_GLASS_PANE(10, "THIN_GLASS", "STAINED_GLASS_PANE"), @@ -1031,7 +1034,7 @@ public enum XMaterial { PURPUR_STAIRS, QUARTZ, QUARTZ_BLOCK, - QUARTZ_BRICKS(16), + QUARTZ_BRICKS, QUARTZ_PILLAR(2, "QUARTZ_BLOCK"), QUARTZ_SLAB(7, "STEP"), QUARTZ_STAIRS, @@ -1041,7 +1044,7 @@ public enum XMaterial { RABBIT_SPAWN_EGG(101, "MONSTER_EGG"), RABBIT_STEW, RAIL("RAILS"), - RAVAGER_SPAWN_EGG(14), + RAVAGER_SPAWN_EGG, RAW_COPPER, RAW_COPPER_BLOCK, RAW_GOLD, @@ -1070,14 +1073,14 @@ public enum XMaterial { /** * Data value 14 or 0 */ - RED_BED(14, "BED_BLOCK", "BED"), + RED_BED(supports(12) ? 14 : 0, "BED_BLOCK", "BED"), RED_CANDLE, RED_CANDLE_CAKE, RED_CARPET(14, "CARPET"), RED_CONCRETE(14, "CONCRETE"), RED_CONCRETE_POWDER(14, "CONCRETE_POWDER"), RED_DYE(1, "INK_SACK", "ROSE_RED"), - RED_GLAZED_TERRACOTTA(14, 12), + RED_GLAZED_TERRACOTTA, RED_MUSHROOM, RED_MUSHROOM_BLOCK("RED_MUSHROOM", "HUGE_MUSHROOM_2"), RED_NETHER_BRICKS("RED_NETHER_BRICK"), @@ -1098,29 +1101,29 @@ public enum XMaterial { RED_WOOL(14, "WOOL"), REPEATER("DIODE_BLOCK_ON", "DIODE_BLOCK_OFF", "DIODE"), REPEATING_COMMAND_BLOCK("COMMAND", "COMMAND_REPEATING"), - RESPAWN_ANCHOR(16), + RESPAWN_ANCHOR, ROOTED_DIRT, ROSE_BUSH(4, "DOUBLE_PLANT"), ROTTEN_FLESH, SADDLE, SALMON(1, "RAW_FISH"), - SALMON_BUCKET(0, 13), - SALMON_SPAWN_EGG(0, 13), + SALMON_BUCKET, + SALMON_SPAWN_EGG, SAND, SANDSTONE, SANDSTONE_SLAB(1, "DOUBLE_STEP", "STEP", "STONE_SLAB"), SANDSTONE_STAIRS, SANDSTONE_WALL, - SCAFFOLDING(0, 14), + SCAFFOLDING, SCULK_SENSOR, - SCUTE(13), - SEAGRASS(0, 13), + SCUTE, + SEAGRASS, SEA_LANTERN, - SEA_PICKLE(13), + SEA_PICKLE, SHEARS, SHEEP_SPAWN_EGG(91, "MONSTER_EGG"), SHIELD, - SHROOMLIGHT(16), + SHROOMLIGHT, SHULKER_BOX("PURPLE_SHULKER_BOX"), SHULKER_SHELL, SHULKER_SPAWN_EGG(69, "MONSTER_EGG"), @@ -1136,9 +1139,9 @@ public enum XMaterial { SMALL_AMETHYST_BUD, SMALL_DRIPLEAF, SMITHING_TABLE, - SMOKER(0, 14), + SMOKER, SMOOTH_BASALT, - SMOOTH_QUARTZ(0, 13), + SMOOTH_QUARTZ, SMOOTH_QUARTZ_SLAB(7, "STEP"), SMOOTH_QUARTZ_STAIRS, SMOOTH_RED_SANDSTONE(2, "RED_SANDSTONE"), @@ -1152,15 +1155,15 @@ public enum XMaterial { SNOW, SNOWBALL("SNOW_BALL"), SNOW_BLOCK, - SOUL_CAMPFIRE(16), - SOUL_FIRE(16), - SOUL_LANTERN(16), + SOUL_CAMPFIRE, + SOUL_FIRE, + SOUL_LANTERN, SOUL_SAND, - SOUL_SOIL(16), - SOUL_TORCH(16), - SOUL_WALL_TORCH(16), + SOUL_SOIL, + SOUL_TORCH, + SOUL_WALL_TORCH, SPAWNER("MOB_SPAWNER"), - SPECTRAL_ARROW(0, 9), + SPECTRAL_ARROW, SPIDER_EYE, SPIDER_SPAWN_EGG(52, "MONSTER_EGG"), SPLASH_POTION, @@ -1171,7 +1174,7 @@ public enum XMaterial { SPRUCE_DOOR("SPRUCE_DOOR", "SPRUCE_DOOR_ITEM"), SPRUCE_FENCE, SPRUCE_FENCE_GATE, - SPRUCE_LEAVES(1, "LEAVES", "LEAVES_2"), + SPRUCE_LEAVES(1, "LEAVES"), SPRUCE_LOG(1, "LOG"), SPRUCE_PLANKS(1, "WOOD"), SPRUCE_PRESSURE_PLATE("WOOD_PLATE"), @@ -1187,7 +1190,7 @@ public enum XMaterial { STICK, STICKY_PISTON("PISTON_BASE", "PISTON_STICKY_BASE"), STONE, - STONECUTTER(14), + STONECUTTER, STONE_AXE, STONE_BRICKS("SMOOTH_BRICK"), STONE_BRICK_SLAB(4, "DOUBLE_STEP", "STEP", "STONE_SLAB"), @@ -1202,14 +1205,14 @@ public enum XMaterial { STONE_STAIRS, STONE_SWORD, STRAY_SPAWN_EGG(6, "MONSTER_EGG"), - STRIDER_SPAWN_EGG(16), + STRIDER_SPAWN_EGG, STRING, STRIPPED_ACACIA_LOG("LOG_2"), STRIPPED_ACACIA_WOOD("LOG_2"), STRIPPED_BIRCH_LOG(2, "LOG"), STRIPPED_BIRCH_WOOD(2, "LOG"), - STRIPPED_CRIMSON_HYPHAE(16), - STRIPPED_CRIMSON_STEM(16), + STRIPPED_CRIMSON_HYPHAE, + STRIPPED_CRIMSON_STEM, STRIPPED_DARK_OAK_LOG("LOG"), STRIPPED_DARK_OAK_WOOD("LOG"), STRIPPED_JUNGLE_LOG(3, "LOG"), @@ -1218,8 +1221,8 @@ public enum XMaterial { STRIPPED_OAK_WOOD("LOG"), STRIPPED_SPRUCE_LOG(1, "LOG"), STRIPPED_SPRUCE_WOOD(1, "LOG"), - STRIPPED_WARPED_HYPHAE(16), - STRIPPED_WARPED_STEM(16), + STRIPPED_WARPED_HYPHAE, + STRIPPED_WARPED_STEM, STRUCTURE_BLOCK, /** * Originally developers used barrier blocks for its purpose. @@ -1232,37 +1235,37 @@ public enum XMaterial { */ SUGAR_CANE("SUGAR_CANE_BLOCK"), SUNFLOWER("DOUBLE_PLANT"), - SUSPICIOUS_STEW(0, 14), - SWEET_BERRIES(14), - SWEET_BERRY_BUSH(0, 14), + SUSPICIOUS_STEW, + SWEET_BERRIES, + SWEET_BERRY_BUSH, TALL_GRASS(2, "DOUBLE_PLANT"), - TALL_SEAGRASS(2, 13), - TARGET(16), + TALL_SEAGRASS, + TARGET, TERRACOTTA("STAINED_CLAY"), TINTED_GLASS, - TIPPED_ARROW(0, 9), + TIPPED_ARROW, TNT, TNT_MINECART("EXPLOSIVE_MINECART"), TORCH, TOTEM_OF_UNDYING("TOTEM"), - TRADER_LLAMA_SPAWN_EGG(103, 14), + TRADER_LLAMA_SPAWN_EGG, TRAPPED_CHEST, - TRIDENT(13), + TRIDENT, TRIPWIRE, TRIPWIRE_HOOK, TROPICAL_FISH(2, "RAW_FISH"), - TROPICAL_FISH_BUCKET(0, 13, "BUCKET", "WATER_BUCKET"), - TROPICAL_FISH_SPAWN_EGG(0, 13, "MONSTER_EGG"), - TUBE_CORAL(13), - TUBE_CORAL_BLOCK(13), - TUBE_CORAL_FAN(13), + TROPICAL_FISH_BUCKET("BUCKET", "WATER_BUCKET"), + TROPICAL_FISH_SPAWN_EGG("MONSTER_EGG"), + TUBE_CORAL, + TUBE_CORAL_BLOCK, + TUBE_CORAL_FAN, TUBE_CORAL_WALL_FAN, TUFF, - TURTLE_EGG(0, 13), - TURTLE_HELMET(0, 13), - TURTLE_SPAWN_EGG(0, 13), - TWISTING_VINES(16), - TWISTING_VINES_PLANT(16), + TURTLE_EGG, + TURTLE_HELMET, + TURTLE_SPAWN_EGG, + TWISTING_VINES, + TWISTING_VINES_PLANT, VEX_SPAWN_EGG(35, "MONSTER_EGG"), VILLAGER_SPAWN_EGG(120, "MONSTER_EGG"), VINDICATOR_SPAWN_EGG(36, "MONSTER_EGG"), @@ -1274,25 +1277,25 @@ public enum XMaterial { */ VOID_AIR("AIR"), WALL_TORCH("TORCH"), - WANDERING_TRADER_SPAWN_EGG(0, 14), - WARPED_BUTTON(16), - WARPED_DOOR(16), - WARPED_FENCE(16), - WARPED_FENCE_GATE(16), - WARPED_FUNGUS(16), - WARPED_FUNGUS_ON_A_STICK(16), - WARPED_HYPHAE(16), - WARPED_NYLIUM(16), - WARPED_PLANKS(16), - WARPED_PRESSURE_PLATE(16), - WARPED_ROOTS(16), - WARPED_SIGN(0, 16, "SIGN_POST"), - WARPED_SLAB(16), - WARPED_STAIRS(16), - WARPED_STEM(16), - WARPED_TRAPDOOR(16), - WARPED_WALL_SIGN(0, 16, "WALL_SIGN"), - WARPED_WART_BLOCK(16), + WANDERING_TRADER_SPAWN_EGG, + WARPED_BUTTON, + WARPED_DOOR, + WARPED_FENCE, + WARPED_FENCE_GATE, + WARPED_FUNGUS, + WARPED_FUNGUS_ON_A_STICK, + WARPED_HYPHAE, + WARPED_NYLIUM, + WARPED_PLANKS, + WARPED_PRESSURE_PLATE, + WARPED_ROOTS, + WARPED_SIGN("SIGN_POST"), + WARPED_SLAB, + WARPED_STAIRS, + WARPED_STEM, + WARPED_TRAPDOOR, + WARPED_WALL_SIGN("WALL_SIGN"), + WARPED_WART_BLOCK, /** * This is used for blocks only. * In 1.13- WATER will turn into STATIONARY_WATER after it finished spreading. @@ -1322,8 +1325,8 @@ public enum XMaterial { WEATHERED_CUT_COPPER, WEATHERED_CUT_COPPER_SLAB, WEATHERED_CUT_COPPER_STAIRS, - WEEPING_VINES(16), - WEEPING_VINES_PLANT(16), + WEEPING_VINES, + WEEPING_VINES_PLANT, WET_SPONGE(1, "SPONGE"), /** * Wheat is a known material in pre-1.13 @@ -1337,8 +1340,8 @@ public enum XMaterial { WHITE_CARPET("CARPET"), WHITE_CONCRETE("CONCRETE"), WHITE_CONCRETE_POWDER("CONCRETE_POWDER"), - WHITE_DYE(15, 14, "INK_SACK", "BONE_MEAL"), - WHITE_GLAZED_TERRACOTTA(0, 12, "STAINED_CLAY"), + WHITE_DYE(15, "INK_SACK", "BONE_MEAL"), + WHITE_GLAZED_TERRACOTTA("STAINED_CLAY"), WHITE_SHULKER_BOX, WHITE_STAINED_GLASS("STAINED_GLASS"), WHITE_STAINED_GLASS_PANE("THIN_GLASS", "STAINED_GLASS_PANE"), @@ -1347,7 +1350,7 @@ public enum XMaterial { WHITE_WALL_BANNER(15, "WALL_BANNER"), WHITE_WOOL("WOOL"), WITCH_SPAWN_EGG(66, "MONSTER_EGG"), - WITHER_ROSE(0, 14), + WITHER_ROSE, WITHER_SKELETON_SKULL(1, "SKULL", "SKULL_ITEM"), WITHER_SKELETON_SPAWN_EGG(5, "MONSTER_EGG"), WITHER_SKELETON_WALL_SKULL(1, "SKULL", "SKULL_ITEM"), @@ -1360,21 +1363,21 @@ public enum XMaterial { WRITABLE_BOOK("BOOK_AND_QUILL"), WRITTEN_BOOK, YELLOW_BANNER(11, "STANDING_BANNER", "BANNER"), - YELLOW_BED(4, "BED_BLOCK", "BED"), + YELLOW_BED(supports(12) ? 4 : 0, "BED_BLOCK", "BED"), YELLOW_CANDLE, YELLOW_CANDLE_CAKE, YELLOW_CARPET(4, "CARPET"), YELLOW_CONCRETE(4, "CONCRETE"), YELLOW_CONCRETE_POWDER(4, "CONCRETE_POWDER"), YELLOW_DYE(11, "INK_SACK", "DANDELION_YELLOW"), - YELLOW_GLAZED_TERRACOTTA(4, 12, "STAINED_CLAY", "YELLOW_TERRACOTTA"), + YELLOW_GLAZED_TERRACOTTA(4, "STAINED_CLAY", "YELLOW_TERRACOTTA"), YELLOW_SHULKER_BOX, YELLOW_STAINED_GLASS(4, "STAINED_GLASS"), YELLOW_STAINED_GLASS_PANE(4, "THIN_GLASS", "STAINED_GLASS_PANE"), YELLOW_TERRACOTTA(4, "STAINED_CLAY"), YELLOW_WALL_BANNER(11, "WALL_BANNER"), YELLOW_WOOL(4, "WOOL"), - ZOGLIN_SPAWN_EGG(16), + ZOGLIN_SPAWN_EGG, ZOMBIE_HEAD(2, "SKULL", "SKULL_ITEM"), ZOMBIE_HORSE_SPAWN_EGG(29, "MONSTER_EGG"), ZOMBIE_SPAWN_EGG(54, "MONSTER_EGG"), @@ -1407,25 +1410,14 @@ public enum XMaterial { private static final Cache NAME_CACHE = CacheBuilder.newBuilder() .expireAfterAccess(1, TimeUnit.HOURS) .build(); - /** * This is used for {@link #isOneOf(Collection)} * * @since 3.4.0 */ - private static final LoadingCache CACHED_REGEX = CacheBuilder.newBuilder() + private static final Cache CACHED_REGEX = CacheBuilder.newBuilder() .expireAfterAccess(3, TimeUnit.HOURS) - .build(new CacheLoader() { - @Override - public Pattern load( String str) { - try { - return Pattern.compile(str); - } catch (PatternSyntaxException ex) { - ex.printStackTrace(); - return null; - } - } - }); + .build(); /** * The maximum data value in the pre-flattening update which belongs to {@link #VILLAGER_SPAWN_EGG}
* https://minecraftitemids.com/types/spawn-egg @@ -1486,19 +1478,12 @@ public enum XMaterial { * @see #getData() */ private final byte data; - /** - * The version that this material was added in, otherwise 0 if the version is not recorded. - * - * @see #getMaterialVersion() - * @since 7.0.0 - */ - private final byte version; /** * A list of material names that was being used for older verions. * * @see #getLegacy() */ - + private final String[] legacy; /** * The cached Bukkit parsed material. @@ -1506,12 +1491,11 @@ public enum XMaterial { * @see #parseMaterial() * @since 9.0.0 */ - + private final Material material; - XMaterial(int data, int version, String... legacy) { + XMaterial(int data, String... legacy) { this.data = (byte) data; - this.version = (byte) version; this.legacy = legacy; Material mat = null; @@ -1524,20 +1508,8 @@ public enum XMaterial { this.material = mat; } - XMaterial(int data, String... legacy) { - this(data, 0, legacy); - } - - XMaterial(int version) { - this(0, version); - } - - XMaterial() { - this(0, 0); - } - XMaterial(String... legacy) { - this(0, 0, legacy); + this(0, legacy); } /** @@ -1552,7 +1524,9 @@ public enum XMaterial { * @see #getVersion() * @see #supports(int) * @since 1.0.0 + * @deprecated Use {@code XMaterial.supports(13)} instead. This method name can be confusing. */ + @Deprecated public static boolean isNewVersion() { return Data.ISFLAT; } @@ -1570,7 +1544,9 @@ public enum XMaterial { * * * @since 2.0.0 + * @deprecated Use {@code !XMaterial.supports(9)} instead. */ + @Deprecated public static boolean isOneEight() { return !supports(9); } @@ -1580,12 +1556,11 @@ public enum XMaterial { * without throwing an exception. * * @param name the name of the material. - * * @return an optional that can be empty. * @since 5.1.0 */ - - private static Optional getIfPresent( String name) { + + private static Optional getIfPresent(String name) { return Optional.ofNullable(NAMES.get(name)); } @@ -1593,7 +1568,7 @@ public enum XMaterial { * The current version of the server. * * @return the current server version minor number. - * @see #isNewVersion() + * @see #supports(int) * @since 2.0.0 */ public static int getVersion() { @@ -1601,14 +1576,14 @@ public enum XMaterial { } /** - * When using newer versions of Minecraft ({@link #isNewVersion()}), helps - * to find the old material name with its data value using a cached search for optimization. + * When using 1.13+, this helps to find the old material name + * with its data value using a cached search for optimization. * * @see #matchDefinedXMaterial(String, byte) * @since 1.0.0 */ - - private static XMaterial requestOldXMaterial( String name, byte data) { + + private static XMaterial requestOldXMaterial(String name, byte data) { String holder = name + data; XMaterial cache = NAME_CACHE.getIfPresent(holder); if (cache != null) return cache; @@ -1632,8 +1607,8 @@ public enum XMaterial { * @see #matchDefinedXMaterial(String, byte) * @since 2.0.0 */ - - public static Optional matchXMaterial( String name) { + + public static Optional matchXMaterial(String name) { Validate.notEmpty(name, "Cannot match a material with null or empty material name"); Optional oldMatch = matchXMaterialWithData(name); return oldMatch.isPresent() ? oldMatch : matchDefinedXMaterial(format(name), UNKNOWN_DATA_VALUE); @@ -1651,13 +1626,12 @@ public enum XMaterial { * * * @param name the material string that consists of the material name, data and separator character. - * * @return the parsed XMaterial. * @see #matchXMaterial(String) * @since 3.0.0 */ - - private static Optional matchXMaterialWithData( String name) { + + private static Optional matchXMaterialWithData(String name) { int index = name.indexOf(':'); if (index != -1) { String mat = format(name.substring(0, index)); @@ -1681,8 +1655,8 @@ public enum XMaterial { * @see #matchXMaterial(ItemStack) * @since 2.0.0 */ - - public static XMaterial matchXMaterial( Material material) { + + public static XMaterial matchXMaterial(Material material) { Objects.requireNonNull(material, "Cannot match null material"); return matchDefinedXMaterial(material.name(), UNKNOWN_DATA_VALUE) .orElseThrow(() -> new IllegalArgumentException("Unsupported material with no data value: " + material.name())); @@ -1693,15 +1667,14 @@ public enum XMaterial { * if not a damageable item {@link ItemStack#getDurability()}. * * @param item the ItemStack to match. - * * @return an XMaterial if matched any. * @throws IllegalArgumentException may be thrown as an unexpected exception. * @see #matchXMaterial(Material) * @since 2.0.0 */ - + @SuppressWarnings("deprecation") - public static XMaterial matchXMaterial( ItemStack item) { + public static XMaterial matchXMaterial(ItemStack item) { Objects.requireNonNull(item, "Cannot match null ItemStack"); String material = item.getType().name(); byte data = (byte) (Data.ISFLAT || item.getType().getMaxDurability() > 0 ? 0 : item.getDurability()); @@ -1719,15 +1692,14 @@ public enum XMaterial { * * @param name the formatted name of the material. * @param data the data value of the material. Is always 0 or {@link #UNKNOWN_DATA_VALUE} when {@link Data#ISFLAT} - * * @return an XMaterial (with the same data value if specified) * @see #matchXMaterial(Material) * @see #matchXMaterial(int, byte) * @see #matchXMaterial(ItemStack) * @since 3.0.0 */ - - protected static Optional matchDefinedXMaterial( String name, byte data) { + + protected static Optional matchDefinedXMaterial(String name, byte data) { // if (!Boolean.valueOf(Boolean.getBoolean(Boolean.TRUE.toString())).equals(Boolean.FALSE.booleanValue())) return null; Boolean duplicated = null; boolean isAMap = name.equalsIgnoreCase("MAP"); @@ -1745,7 +1717,8 @@ public enum XMaterial { return (data >= 0 && isAMap) ? Optional.of(FILLED_MAP) : Optional.empty(); } - if (!Data.ISFLAT && oldXMaterial.isPlural() && (duplicated == null ? isDuplicated(name) : duplicated)) return getIfPresent(name); + if (!Data.ISFLAT && oldXMaterial.isPlural() && (duplicated == null ? isDuplicated(name) : duplicated)) + return getIfPresent(name); return Optional.of(oldXMaterial); } @@ -1757,11 +1730,10 @@ public enum XMaterial { *

{@code MELON, CARROT, POTATO, BEETROOT -> true} * * @param name the name of the material to check. - * * @return true if there's a duplicated material for this material, otherwise false. * @since 2.0.0 */ - private static boolean isDuplicated( String name) { + private static boolean isDuplicated(String name) { // Don't use matchXMaterial() since this method is being called from matchXMaterial() itself and will cause a StackOverflowError. return DUPLICATED.contains(name); } @@ -1772,7 +1744,6 @@ public enum XMaterial { * * @param id the ID (Magic value) of the material. * @param data the data value of the material. - * * @return a parsed XMaterial with the same ID and data value. * @see #matchXMaterial(ItemStack) * @since 2.0.0 @@ -1780,7 +1751,7 @@ public enum XMaterial { * which takes a really long time. Plugins should no longer support IDs. If you want, you can make a {@link Map} cache yourself. * This method obviously doesn't work for 1.13+ and will not be supported. This is only here for debugging purposes. */ - + @Deprecated public static Optional matchXMaterial(int id, byte data) { if (id < 0 || id > MAX_ID || data < 0) return Optional.empty(); @@ -1797,12 +1768,11 @@ public enum XMaterial { * the normal RegEx + String Methods approach for both formatted and unformatted material names. * * @param name the material name to modify. - * * @return an enum name. * @since 2.0.0 */ - - protected static String format( String name) { + + protected static String format(String name) { int len = name.length(); char[] chs = new char[len]; int count = 0; @@ -1835,7 +1805,6 @@ public enum XMaterial { * Checks if the specified version is the same version or higher than the current server version. * * @param version the major version to be checked. "1." is ignored. E.g. 1.12 = 12 | 1.9 = 9 - * * @return true of the version is equal or higher than the current version. * @since 2.0.0 */ @@ -1843,39 +1812,6 @@ public enum XMaterial { return Data.VERSION >= version; } - /** - * Gets the exact major version (..., 1.9, 1.10, ..., 1.14) - * In most cases, you shouldn't be using this method. - * - * @param version Supports {@link Bukkit#getVersion()}, {@link Bukkit#getBukkitVersion()} and normal formats such as "1.14" - * - * @return the exact major version. - * @see #supports(int) - * @see #getVersion() - * @see #getMaterialVersion() - * @since 2.0.0 - */ - - public static String getMajorVersion( String version) { - Validate.notEmpty(version, "Cannot get major Minecraft version from null or empty string"); - - // getVersion() - int index = version.lastIndexOf("MC:"); - if (index != -1) { - version = version.substring(index + 4, version.length() - 1); - } else if (version.endsWith("SNAPSHOT")) { - // getBukkitVersion() - index = version.indexOf('-'); - version = version.substring(0, index); - } - - // 1.13.2, 1.14.4, etc... - int lastDot = version.lastIndexOf('.'); - if (version.indexOf('.') != lastDot) version = version.substring(0, lastDot); - - return version; - } - public String[] getLegacy() { return this.legacy; } @@ -1935,11 +1871,10 @@ public enum XMaterial { * Want to learn RegEx? You can mess around in RegExr website. * * @param materials the material names to check base material on. - * * @return true if one of the given material names is similar to the base material. * @since 3.1.1 */ - public boolean isOneOf( Collection materials) { + public boolean isOneOf(Collection materials) { if (materials == null || materials.isEmpty()) return false; String name = this.name(); @@ -1952,7 +1887,15 @@ public enum XMaterial { } if (checker.startsWith("REGEX:")) { comp = comp.substring(6); - Pattern pattern = CACHED_REGEX.getUnchecked(comp); + Pattern pattern = CACHED_REGEX.getIfPresent(comp); + if (pattern == null) { + try { + pattern = Pattern.compile(comp); + CACHED_REGEX.put(comp, pattern); + } catch (PatternSyntaxException ex) { + ex.printStackTrace(); + } + } if (pattern != null && pattern.matcher(name).matches()) return true; continue; } @@ -1971,13 +1914,12 @@ public enum XMaterial { * Use {@link #parseItem()} instead when creating new ItemStacks. * * @param item the item to change its type. - * * @see #parseItem() * @since 3.0.0 */ - + @SuppressWarnings("deprecation") - public ItemStack setType( ItemStack item) { + public ItemStack setType(ItemStack item) { Objects.requireNonNull(item, "Cannot set material for null ItemStack"); Material material = this.parseMaterial(); Objects.requireNonNull(material, () -> "Unsupported material: " + this.name()); @@ -1992,11 +1934,10 @@ public enum XMaterial { * All the values passed to this method will not be null or empty and are formatted correctly. * * @param name the material name to check. - * * @return true if it's one of the legacy names, otherwise false. * @since 2.0.0 */ - private boolean anyMatchLegacy( String name) { + private boolean anyMatchLegacy(String name) { for (int i = this.legacy.length - 1; i >= 0; i--) { if (name.equals(this.legacy[i])) return true; } @@ -2018,7 +1959,7 @@ public enum XMaterial { * @since 3.0.0 */ @Override - + public String toString() { return WordUtils.capitalize(this.name().replace('_', ' ').toLowerCase(Locale.ENGLISH)); } @@ -2026,6 +1967,8 @@ public enum XMaterial { /** * Gets the ID (Magic value) of the material. * https://www.minecraftinfo.com/idlist.htm + *

+ * Spigot added material ID support back in 1.16+ * * @return the ID of the material or -1 if it's not a legacy material or the server doesn't support the material. * @see #matchXMaterial(int, byte) @@ -2033,11 +1976,15 @@ public enum XMaterial { */ @SuppressWarnings("deprecation") public int getId() { - if (this.data != 0 || this.version >= 13) return -1; + // https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/diff/src/main/java/org/bukkit/Material.java?until=1cb03826ebde4ef887519ce37b0a2a341494a183 + // Should start working again in 1.16+ Material material = this.parseMaterial(); if (material == null) return -1; - if (Data.ISFLAT && !material.isLegacy()) return -1; - return material.getId(); + try { + return material.getId(); + } catch (IllegalArgumentException ignored) { + return -1; + } } /** @@ -2062,7 +2009,7 @@ public enum XMaterial { * @see #setType(ItemStack) * @since 2.0.0 */ - + @SuppressWarnings("deprecation") public ItemStack parseItem() { Material material = this.parseMaterial(); @@ -2076,7 +2023,7 @@ public enum XMaterial { * @return the material related to this XMaterial based on the server version. * @since 1.0.0 */ - + public Material parseMaterial() { return this.material; } @@ -2085,15 +2032,14 @@ public enum XMaterial { * Checks if an item has the same material (and data value on older versions). * * @param item item to check. - * * @return true if the material is the same as the item's material (and data value if on older versions), otherwise false. * @since 1.0.0 */ @SuppressWarnings("deprecation") - public boolean isSimilar( ItemStack item) { + public boolean isSimilar(ItemStack item) { Objects.requireNonNull(item, "Cannot compare with null ItemStack"); if (item.getType() != this.parseMaterial()) return false; - return Data.ISFLAT || item.getDurability() == this.data || item.getType().getMaxDurability() <= 0; + return Data.ISFLAT || item.getDurability() == this.data || item.getType().getMaxDurability() > 0; } /** @@ -2110,17 +2056,6 @@ public enum XMaterial { return this.material != null; } - /** - * The version this material was added in. This will return the minor number in the version scheme. - * For example, if it was added in 1.16, it'll return 16 - * - * @return the version number of 0 if the version was not recorded. - * @since 7.0.0 - */ - public byte getMaterialVersion() { - return version; - } - /** * This method is needed due to Java enum initialization limitations. * It's really inefficient yes, but it's only used for initialization. @@ -2162,18 +2097,27 @@ public enum XMaterial { } /** - * Used for datas that need to be accessed during enum initilization. + * Used for data that need to be accessed during enum initialization. * * @since 9.0.0 */ private static final class Data { /** - * The current version of the server in the a form of a major version. + * The current version of the server in the form of a major version. * If the static initialization for this fails, you know something's wrong with the server software. * * @since 1.0.0 */ - private static final int VERSION = Integer.parseInt(getMajorVersion(Bukkit.getVersion()).substring(2)); + private static final int VERSION; + + static { // This needs to be right below VERSION because of initialization order. + String version = Bukkit.getVersion(); + Matcher matcher = Pattern.compile("MC: \\d\\.(\\d+)").matcher(version); + + if (matcher.find()) VERSION = Integer.parseInt(matcher.group(1)); + else throw new IllegalArgumentException("Failed to parse server version from: " + version); + } + /** * Cached result if the server version is after the v1.13 flattening update. * diff --git a/src/main/lombok/nl/sbdeveloper/themeparkplus/commands/TPPTabComplete.java b/src/main/lombok/nl/sbdeveloper/themeparkplus/commands/TPPTabComplete.java deleted file mode 100644 index af8c217..0000000 --- a/src/main/lombok/nl/sbdeveloper/themeparkplus/commands/TPPTabComplete.java +++ /dev/null @@ -1,100 +0,0 @@ -package nl.sbdeveloper.themeparkplus.commands; - -import nl.iobyte.themepark.ThemePark; -import nl.sbdeveloper.themeparkplus.api.enums.WalkingDirection; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.command.TabCompleter; -import org.bukkit.entity.Player; -import org.bukkit.util.StringUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - -public class TPPTabComplete implements TabCompleter { - private static final List COMMANDS = Arrays.asList("info", "help", "opengate", "closegate", "lampon", "lampoff", "lampson", "lampsoff", "redstonetimer", "givefpticket"); - - @Override - public @Nullable List onTabComplete(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) { - //Aliases - if (label.equalsIgnoreCase("themeparkplus") || label.equalsIgnoreCase("tpp") || label.equalsIgnoreCase("themeparkp")) { - if (args.length == 1) { - return StringUtil.copyPartialMatches(args[0], COMMANDS, new ArrayList<>()); - } else if (args.length == 2) { - if (args[0].equalsIgnoreCase("opengate") - || args[0].equalsIgnoreCase("closegate") - || args[0].equalsIgnoreCase("lampon") - || args[0].equalsIgnoreCase("lampoff") - || args[0].equalsIgnoreCase("redstonetimer")) { - if (sender instanceof Player) { - Player p = (Player) sender; - Location targetLoc = getTarget(p).getLocation(); - return StringUtil.copyPartialMatches(args[1], Collections.singletonList("" + targetLoc.getWorld().getName()), new ArrayList<>()); - } - } else if (args[0].equalsIgnoreCase("givefpticket")) { - return StringUtil.copyPartialMatches(args[1], ThemePark.getInstance().getAPI().getAttractionService().getAttractions().keySet(), new ArrayList<>()); - } - } else if (args.length == 3) { - if (args[0].equalsIgnoreCase("opengate") - || args[0].equalsIgnoreCase("closegate") - || args[0].equalsIgnoreCase("lampon") - || args[0].equalsIgnoreCase("lampoff") - || args[0].equalsIgnoreCase("redstonetimer")) { - if (sender instanceof Player) { - Player p = (Player) sender; - Location targetLoc = getTarget(p).getLocation(); - return StringUtil.copyPartialMatches(args[2], Collections.singletonList("" + targetLoc.getBlockX()), new ArrayList<>()); - } - } else if (args[0].equalsIgnoreCase("givefpticket")) { - return StringUtil.copyPartialMatches(args[1], Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList()), new ArrayList<>()); - } - } else if (args.length == 4) { - if (args[0].equalsIgnoreCase("opengate") - || args[0].equalsIgnoreCase("closegate") - || args[0].equalsIgnoreCase("lampon") - || args[0].equalsIgnoreCase("lampoff") - || args[0].equalsIgnoreCase("redstonetimer")) { - if (sender instanceof Player) { - Player p = (Player) sender; - Location targetLoc = getTarget(p).getLocation(); - return StringUtil.copyPartialMatches(args[3], Collections.singletonList("" + targetLoc.getBlockY()), new ArrayList<>()); - } - } - } else if (args.length == 5) { - if (args[0].equalsIgnoreCase("opengate") - || args[0].equalsIgnoreCase("closegate") - || args[0].equalsIgnoreCase("lampon") - || args[0].equalsIgnoreCase("lampoff") - || args[0].equalsIgnoreCase("redstonetimer")) { - if (sender instanceof Player) { - Player p = (Player) sender; - Location targetLoc = getTarget(p).getLocation(); - return StringUtil.copyPartialMatches(args[4], Collections.singletonList("" + targetLoc.getBlockZ()), new ArrayList<>()); - } - } - } else if (args.length == 6) { - if (args[0].equalsIgnoreCase("opengate")) { - return StringUtil.copyPartialMatches(args[5], Arrays.stream(WalkingDirection.values()).map(Enum::toString).collect(Collectors.toList()), new ArrayList<>()); - } - } else if (args.length == 7) { - if (args[0].equalsIgnoreCase("opengate")) { - return StringUtil.copyPartialMatches(args[6], Arrays.stream(WalkingDirection.values()).map(Enum::toString).collect(Collectors.toList()), new ArrayList<>()); - } - } - } - - return null; - } - - private Block getTarget(Player p) { - return p.getTargetBlock(null, 200); - } -}