diff --git a/CHANGELOG.md b/CHANGELOG.md index f06241d..acce37c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Logs ## Unreleased Version - Fix sorting of materials +- Cleanup code ## v2.0.0 (for 1.13.x) - Update to 1.13.2 diff --git a/CHANGELOG.zh-tw.md b/CHANGELOG.zh-tw.md index 698e31d..24f7296 100644 --- a/CHANGELOG.zh-tw.md +++ b/CHANGELOG.zh-tw.md @@ -1,6 +1,7 @@ # 更新紀錄 ## 未釋出版本 - 修正材料的排序 +- 清理程式碼 ## v2.0.0 (for 1.13.x) - 升級至1.13.2 diff --git a/src/main/java/club/kid7/bannermaker/BannerMaker.java b/src/main/java/club/kid7/bannermaker/BannerMaker.java index 3b8dd82..a5dea94 100644 --- a/src/main/java/club/kid7/bannermaker/BannerMaker.java +++ b/src/main/java/club/kid7/bannermaker/BannerMaker.java @@ -3,8 +3,6 @@ import club.kid7.bannermaker.command.BannerMakerCommand; import club.kid7.bannermaker.configuration.DefaultConfig; import club.kid7.bannermaker.configuration.Language; -import club.kid7.bannermaker.version.VersionHandler; -import club.kid7.bannermaker.version.VersionHandler_1_8; import club.kid7.pluginutilities.command.CommandComponent; import club.kid7.pluginutilities.configuration.KConfigManager; import club.kid7.pluginutilities.gui.CustomGUI; @@ -21,28 +19,11 @@ public class BannerMaker extends JavaPlugin { private static BannerMaker instance = null; public Economy econ = null; public boolean enableAlphabetAndNumber = true; - private VersionHandler versionHandler = null; public PlayerDataMap playerDataMap = null; - public VersionHandler getVersionHandler() { - return versionHandler; - } - @Override public void onEnable() { instance = this; - //根據不同版本選擇Handler - String version = getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3]; - switch (version) { - case "v1_8_R1": - case "v1_8_R2": - case "v1_8_R3": - versionHandler = new VersionHandler_1_8(); - break; - default: - versionHandler = new VersionHandler(); - break; - } //Commands registerCommands(); diff --git a/src/main/java/club/kid7/bannermaker/command/HandCommand.java b/src/main/java/club/kid7/bannermaker/command/HandCommand.java index 2002677..3aeca56 100644 --- a/src/main/java/club/kid7/bannermaker/command/HandCommand.java +++ b/src/main/java/club/kid7/bannermaker/command/HandCommand.java @@ -34,7 +34,7 @@ public HandCommand(BannerMaker bm) { public boolean executeCommand(CommandSender sender, Command cmd, String label, String[] args) { BannerMaker bm = (BannerMaker) plugin; Player player = (Player) sender; - ItemStack itemStack = bm.getVersionHandler().getItemInMainHand(player); + ItemStack itemStack = player.getInventory().getItemInMainHand(); if (!BannerUtil.isBanner(itemStack)) { player.sendMessage(MessageUtil.format(true, "&c" + Language.tl("command.not-banner-hand"))); return true; diff --git a/src/main/java/club/kid7/bannermaker/version/VersionHandler.java b/src/main/java/club/kid7/bannermaker/version/VersionHandler.java deleted file mode 100644 index 5a0df7b..0000000 --- a/src/main/java/club/kid7/bannermaker/version/VersionHandler.java +++ /dev/null @@ -1,10 +0,0 @@ -package club.kid7.bannermaker.version; - -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -public class VersionHandler { - public ItemStack getItemInMainHand(Player player) { - return player.getInventory().getItemInMainHand(); - } -} diff --git a/src/main/java/club/kid7/bannermaker/version/VersionHandler_1_8.java b/src/main/java/club/kid7/bannermaker/version/VersionHandler_1_8.java deleted file mode 100644 index 99f31a5..0000000 --- a/src/main/java/club/kid7/bannermaker/version/VersionHandler_1_8.java +++ /dev/null @@ -1,12 +0,0 @@ -package club.kid7.bannermaker.version; - -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -public class VersionHandler_1_8 extends VersionHandler { - @SuppressWarnings("deprecation") - @Override - public ItemStack getItemInMainHand(Player player) { - return player.getItemInHand(); - } -}