From 8e09f56d461ff792817728cfe51c57cebf202c1a Mon Sep 17 00:00:00 2001 From: Andrew121410 Date: Sun, 5 May 2024 22:46:23 -0400 Subject: [PATCH] Improve the last commit. They remap old <=1.20.4 plugins to the latest. --- build.gradle.kts | 2 +- .../commands/CommandBlockCMD.java | 4 ++-- .../world16essentials/commands/SignCMD.java | 4 ++-- .../mc/world16essentials/utils/API.java | 23 ------------------- src/main/resources/plugin.yml | 2 +- 5 files changed, 6 insertions(+), 29 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a1467f55..ef258b49 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -74,7 +74,7 @@ repositories { dependencies { api("org.bstats:bstats-bukkit:3.0.2") - compileOnly("io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT") + compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT") compileOnly("com.github.World1-6.World1-6Utils:World1-6Utils-Plugin:b50561b638") compileOnly("com.github.World1-6.World1-6Utils:World1-6Utils_CMI_API:b50561b638") compileOnly("net.essentialsx:EssentialsX:2.21.0-SNAPSHOT") diff --git a/src/main/java/com/andrew121410/mc/world16essentials/commands/CommandBlockCMD.java b/src/main/java/com/andrew121410/mc/world16essentials/commands/CommandBlockCMD.java index 4c6890c0..40680bba 100644 --- a/src/main/java/com/andrew121410/mc/world16essentials/commands/CommandBlockCMD.java +++ b/src/main/java/com/andrew121410/mc/world16essentials/commands/CommandBlockCMD.java @@ -7,6 +7,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -36,8 +37,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String } ItemStack item = InventoryUtils.createItem(Material.COMMAND_BLOCK, 1, "&cCommand Block&r", "New Fresh Command Block"); -// item.addUnsafeEnchantment(Enchantment.SHARPNESS, 1); - api.TEMP_AddunsafeEnchantment_SHARPNESS(item); + item.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 1); p.getInventory().addItem(item); return true; } diff --git a/src/main/java/com/andrew121410/mc/world16essentials/commands/SignCMD.java b/src/main/java/com/andrew121410/mc/world16essentials/commands/SignCMD.java index 1c931b34..e81f0c86 100644 --- a/src/main/java/com/andrew121410/mc/world16essentials/commands/SignCMD.java +++ b/src/main/java/com/andrew121410/mc/world16essentials/commands/SignCMD.java @@ -26,6 +26,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.inventory.ItemStack; @@ -68,8 +69,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String if (args.length == 1 && args[0].equalsIgnoreCase("give")) { ItemStack itemStack = new ItemStack(Material.OAK_SIGN, 1); -// itemStack.addUnsafeEnchantment(Enchantment.SHARPNESS, 1); - api.TEMP_AddunsafeEnchantment_SHARPNESS(itemStack); + itemStack.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 1); player.getInventory().addItem(itemStack); return true; } else if (args.length >= 1 && args[0].equalsIgnoreCase("edit")) { diff --git a/src/main/java/com/andrew121410/mc/world16essentials/utils/API.java b/src/main/java/com/andrew121410/mc/world16essentials/utils/API.java index 12b1cb4c..bb6c3789 100644 --- a/src/main/java/com/andrew121410/mc/world16essentials/utils/API.java +++ b/src/main/java/com/andrew121410/mc/world16essentials/utils/API.java @@ -13,11 +13,8 @@ import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import java.lang.reflect.Field; import java.util.List; import java.util.Map; import java.util.UUID; @@ -153,26 +150,6 @@ public Component parseMessage(Player player, String message) { return this.getMessagesUtils().parseMessage(player, message); } - // this is temp, and I'm sure there is a better way to do this, but I'm dumb, - // @TODO (remove method in a couple of months.) - public void TEMP_AddunsafeEnchantment_SHARPNESS(ItemStack item) { - Enchantment sharpness = null; - try { - Field sharpnessField = Enchantment.class.getDeclaredField("SHARPNESS"); - sharpness = (Enchantment) sharpnessField.get(null); - } catch (NoSuchFieldException | IllegalAccessException e) { - try { - Field sharpnessField = Enchantment.class.getDeclaredField("DAMAGE_ALL"); - sharpness = (Enchantment) sharpnessField.get(null); - } catch (NoSuchFieldException | IllegalAccessException e1) { - e1.printStackTrace(); - } - } - if (sharpness == null) return; - - item.addUnsafeEnchantment(sharpness, 1); - } - public ConfigUtils getConfigUtils() { return configUtils; } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 6bf12597..fc542965 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,7 +2,7 @@ name: World1-6Essentials version: 1.0 author: Andrew121410 main: com.andrew121410.mc.world16essentials.World16Essentials -api-version: "1.20" +api-version: "1.20.4" depend: - World1-6Utils