Skip to content

Commit

Permalink
Improve the last commit. They remap old <=1.20.4 plugins to the latest.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew121410 committed May 6, 2024
1 parent f8115d2 commit 8e09f56
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 29 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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")) {
Expand Down
23 changes: 0 additions & 23 deletions src/main/java/com/andrew121410/mc/world16essentials/utils/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8e09f56

Please sign in to comment.