Merge branch 'Auxilor:master' into master

This commit is contained in:
0ft3n 2021-10-18 11:04:29 +03:00 committed by GitHub
commit 9ae48463df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 25 additions and 77 deletions

View File

@ -1,6 +1,6 @@
<h1 align="center">
<br>
<img src="https://i.imgur.com/9C5wXTU.png" alt="EcoEnchants logo" width="256">
<img src="https://i.imgur.com/PtRRFPR.png" alt="EcoEnchants logo" width="256">
<br>
</h1>

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

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.command;
import com.willfp.eco.core.command.CommandHandler;
import com.willfp.eco.core.command.impl.Subcommand;
import com.willfp.eco.core.config.interfaces.Config;
import com.willfp.eco.core.config.yaml.YamlTransientConfig;
import com.willfp.eco.core.web.Paste;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
@ -31,7 +33,13 @@ public class CommandLocaleDownload extends Subcommand {
}
Paste paste = Paste.getFromHastebin(args.get(0));
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(new StringReader(paste.getContents()));
if (paste == null) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-locale"));
return;
}
String contents = paste.getContents();
Config configuration = new YamlTransientConfig(contents);
for (String key : configuration.getKeys(true)) {
this.getPlugin().getLangYml().set(key, configuration.get(key));

View File

@ -190,8 +190,10 @@ public class EnchantDisplay extends DisplayModule {
@Override
public void revert(@NotNull final ItemStack itemStack) {
if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) {
return;
if (options.isRequireTarget()) {
if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) {
return;
}
}
FastItemStack fast = FastItemStack.wrap(itemStack);
@ -217,6 +219,12 @@ public class EnchantDisplay extends DisplayModule {
@Override
public Object[] generateVarArgs(@NotNull final ItemStack itemStack) {
if (options.isRequireTarget()) {
if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) {
return new Object[]{false};
}
}
ItemMeta meta = itemStack.getItemMeta();
if (meta == null) {
return new Object[]{false};

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);
}

View File

@ -1,2 +1,2 @@
version = 8.13.5
version = 8.13.9
plugin-name = EcoEnchants