Removed unneeded NMS hook

This commit is contained in:
Auxilor 2021-10-16 10:31:09 +01:00
parent f5aababf00
commit 0677a80c1b
4 changed files with 4 additions and 72 deletions

View File

@ -1,22 +0,0 @@
package com.willfp.ecoenchants.proxy.v1_16_R3;
import com.willfp.ecoenchants.proxy.proxies.RepairCostProxy;
import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
public final class RepairCost implements RepairCostProxy {
@Override
public ItemStack setRepairCost(@NotNull final ItemStack itemStack,
final int cost) {
net.minecraft.server.v1_16_R3.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
nmsStack.setRepairCost(cost);
return CraftItemStack.asBukkitCopy(nmsStack);
}
@Override
public int getRepairCost(@NotNull final ItemStack itemStack) {
net.minecraft.server.v1_16_R3.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
return nmsStack.getRepairCost();
}
}

View File

@ -1,22 +0,0 @@
package com.willfp.ecoenchants.proxy.v1_17_R1;
import com.willfp.ecoenchants.proxy.proxies.RepairCostProxy;
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
public final class RepairCost implements RepairCostProxy {
@Override
public ItemStack setRepairCost(@NotNull final ItemStack itemStack,
final int cost) {
net.minecraft.world.item.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
nmsStack.setRepairCost(cost);
return CraftItemStack.asBukkitCopy(nmsStack);
}
@Override
public int getRepairCost(@NotNull final ItemStack itemStack) {
net.minecraft.world.item.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
return nmsStack.getRepairCost();
}
}

View File

@ -6,7 +6,6 @@ import com.willfp.eco.core.fast.FastItemStack;
import com.willfp.eco.core.proxy.ProxyConstants;
import com.willfp.eco.util.NumberUtils;
import com.willfp.ecoenchants.proxy.proxies.OpenInventoryProxy;
import com.willfp.ecoenchants.proxy.proxies.RepairCostProxy;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
@ -125,14 +124,16 @@ public class AnvilListeners extends PluginDependent<EcoPlugin> implements Listen
}
if (this.getPlugin().getConfigYml().getBool("anvil.rework-cost")) {
int repairCost = this.getPlugin().getProxy(RepairCostProxy.class).getRepairCost(item);
int repairCost = FastItemStack.wrap(item).getRepairCost();
int reworkCount = NumberUtils.log2(repairCost + 1);
if (repairCost == 0) {
reworkCount = 0;
}
reworkCount++;
repairCost = (int) Math.pow(2, reworkCount) - 1;
item = this.getPlugin().getProxy(RepairCostProxy.class).setRepairCost(item, repairCost);
FastItemStack fis = FastItemStack.wrap(item);
fis.setRepairCost(repairCost);
item = fis.unwrap();
}
int cost;

View File

@ -1,25 +0,0 @@
package com.willfp.ecoenchants.proxy.proxies;
import com.willfp.eco.core.proxy.AbstractProxy;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
public interface RepairCostProxy extends AbstractProxy {
/**
* Set the rework penalty of an item.
*
* @param itemStack The item to query.
* @param cost The rework penalty to set.
* @return The item, with the rework penalty applied.
*/
ItemStack setRepairCost(@NotNull ItemStack itemStack,
int cost);
/**
* Get the rework penalty of an item.
*
* @param itemStack The item to query.
* @return The rework penalty found on the item.
*/
int getRepairCost(@NotNull ItemStack itemStack);
}