mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2025-02-15 04:21:20 +01:00
Refactor
This commit is contained in:
parent
97f7fe8198
commit
0454d25008
@ -24,7 +24,7 @@ public class EcoEnchantsPlugin extends JavaPlugin {
|
||||
/**
|
||||
* NMS version
|
||||
*/
|
||||
public static final String nmsVersion = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
public static final String NMS_VERSION = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
|
||||
/**
|
||||
* ProtocolLib
|
||||
|
@ -54,7 +54,7 @@ public final class PacketOpenWindowMerchant extends AbstractPacketAdapter {
|
||||
modifiersField.setInt(fSelling, fSelling.getModifiers() & ~Modifier.FINAL);
|
||||
|
||||
// Reflectively access CraftItemStack.class for respective version
|
||||
Class<?> craftItemStack = Class.forName("org.bukkit.craftbukkit." + EcoEnchantsPlugin.nmsVersion + ".inventory.CraftItemStack");
|
||||
Class<?> craftItemStack = Class.forName("org.bukkit.craftbukkit." + EcoEnchantsPlugin.NMS_VERSION + ".inventory.CraftItemStack");
|
||||
|
||||
// Bukkit Result ItemStack from NMS Result ItemStack
|
||||
ItemStack nmsSelling = (ItemStack) craftItemStack.getMethod("asBukkitCopy", selling.getClass()).invoke(null, selling);
|
||||
|
@ -10,7 +10,7 @@ public class BlockBreak {
|
||||
|
||||
public static boolean init() {
|
||||
try {
|
||||
final Class<?> class2 = Class.forName("com.willfp.ecoenchants." + EcoEnchantsPlugin.nmsVersion + ".BlockBreak");
|
||||
final Class<?> class2 = Class.forName("com.willfp.ecoenchants." + EcoEnchantsPlugin.NMS_VERSION + ".BlockBreak");
|
||||
if (BlockBreakWrapper.class.isAssignableFrom(class2)) {
|
||||
blockBreakWrapper = (BlockBreakWrapper) class2.getConstructor().newInstance();
|
||||
}
|
||||
|
@ -1,10 +1,7 @@
|
||||
package com.willfp.ecoenchants.nms;
|
||||
|
||||
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import com.willfp.ecoenchants.nms.API.BlockBreakWrapper;
|
||||
import com.willfp.ecoenchants.nms.API.RepairCostWrapper;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class RepairCost {
|
||||
@ -12,7 +9,7 @@ public class RepairCost {
|
||||
|
||||
public static boolean init() {
|
||||
try {
|
||||
final Class<?> class2 = Class.forName("com.willfp.ecoenchants." + EcoEnchantsPlugin.nmsVersion + ".RepairCost");
|
||||
final Class<?> class2 = Class.forName("com.willfp.ecoenchants." + EcoEnchantsPlugin.NMS_VERSION + ".RepairCost");
|
||||
if (RepairCostWrapper.class.isAssignableFrom(class2)) {
|
||||
repairCostWrapper = (RepairCostWrapper) class2.getConstructor().newInstance();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user