2 Commits
V1.0 ... main

Author SHA1 Message Date
KäseToatz
7e828a42b0 Fix duplicate enchants 2025-08-23 00:11:48 +02:00
0f2c4a81db V1.1 2025-08-11 02:03:40 +02:00
4 changed files with 58 additions and 21 deletions

View File

@@ -4,7 +4,7 @@ plugins {
} }
group = 'com.kasetoatz' group = 'com.kasetoatz'
version = '1.0' version = '1.2'
repositories { repositories {
mavenCentral() mavenCentral()
@@ -23,7 +23,7 @@ tasks {
// Configure the Minecraft version for our task. // Configure the Minecraft version for our task.
// This is the only required configuration besides applying the plugin. // This is the only required configuration besides applying the plugin.
// Your plugin's jar (or shadowJar if present) will be used automatically. // Your plugin's jar (or shadowJar if present) will be used automatically.
minecraftVersion("1.21") minecraftVersion("1.21.8")
} }
} }

View File

@@ -1,10 +1,56 @@
package com.kasetoatz.superArmor; package com.kasetoatz.superArmor;
import org.bukkit.enchantments.Enchantment;
import java.util.Map;
public class Multiplier public class Multiplier
{ {
public int item; public int item;
public int book; public int book;
public static final Map<Enchantment, Multiplier> multipliers = Map.ofEntries(
Map.entry(Enchantment.PROTECTION, new Multiplier(1, 1)),
Map.entry(Enchantment.FIRE_PROTECTION, new Multiplier(2, 1)),
Map.entry(Enchantment.FEATHER_FALLING, new Multiplier(2, 1)),
Map.entry(Enchantment.BLAST_PROTECTION, new Multiplier(4, 2)),
Map.entry(Enchantment.PROJECTILE_PROTECTION, new Multiplier(2, 1)),
Map.entry(Enchantment.THORNS, new Multiplier(8, 4)),
Map.entry(Enchantment.RESPIRATION, new Multiplier(4, 2)),
Map.entry(Enchantment.DEPTH_STRIDER, new Multiplier(4, 2)),
Map.entry(Enchantment.AQUA_AFFINITY, new Multiplier(4, 2)),
Map.entry(Enchantment.SHARPNESS, new Multiplier(1, 1)),
Map.entry(Enchantment.SMITE, new Multiplier(2, 1)),
Map.entry(Enchantment.BANE_OF_ARTHROPODS, new Multiplier(2, 1)),
Map.entry(Enchantment.KNOCKBACK, new Multiplier(2, 1)),
Map.entry(Enchantment.FIRE_ASPECT, new Multiplier(4, 2)),
Map.entry(Enchantment.LOOTING, new Multiplier(4, 2)),
Map.entry(Enchantment.EFFICIENCY, new Multiplier(1, 1)),
Map.entry(Enchantment.SILK_TOUCH, new Multiplier(8, 4)),
Map.entry(Enchantment.UNBREAKING, new Multiplier(2, 1)),
Map.entry(Enchantment.FORTUNE, new Multiplier(4, 2)),
Map.entry(Enchantment.POWER, new Multiplier(1, 1)),
Map.entry(Enchantment.PUNCH, new Multiplier(4, 2)),
Map.entry(Enchantment.FLAME, new Multiplier(4, 2)),
Map.entry(Enchantment.INFINITY, new Multiplier(8, 4)),
Map.entry(Enchantment.LUCK_OF_THE_SEA, new Multiplier(4, 2)),
Map.entry(Enchantment.LURE, new Multiplier(4, 2)),
Map.entry(Enchantment.FROST_WALKER, new Multiplier(4, 2)),
Map.entry(Enchantment.MENDING, new Multiplier(4, 2)),
Map.entry(Enchantment.IMPALING, new Multiplier(2, 1)),
Map.entry(Enchantment.RIPTIDE, new Multiplier(4, 2)),
Map.entry(Enchantment.LOYALTY, new Multiplier(1, 1)),
Map.entry(Enchantment.CHANNELING, new Multiplier(8, 4)),
Map.entry(Enchantment.MULTISHOT, new Multiplier(4, 2)),
Map.entry(Enchantment.PIERCING, new Multiplier(1, 1)),
Map.entry(Enchantment.QUICK_CHARGE, new Multiplier(2, 1)),
Map.entry(Enchantment.SWEEPING_EDGE, new Multiplier(4, 2)),
Map.entry(Enchantment.SWIFT_SNEAK, new Multiplier(8, 4)),
Map.entry(Enchantment.SOUL_SPEED, new Multiplier(8, 4)),
Map.entry(Enchantment.BINDING_CURSE, new Multiplier(8, 4)),
Map.entry(Enchantment.VANISHING_CURSE, new Multiplier(8, 4))
);
public Multiplier(int item, int book) public Multiplier(int item, int book)
{ {
this.item = item; this.item = item;

View File

@@ -15,26 +15,13 @@ import org.bukkit.inventory.view.AnvilView;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
public final class SuperArmor extends JavaPlugin implements Listener { import static com.kasetoatz.superArmor.Multiplier.multipliers;
private final Map<Enchantment, Multiplier> multipliers = Map.ofEntries(
Map.entry(Enchantment.MENDING, new Multiplier(4, 2)),
Map.entry(Enchantment.UNBREAKING, new Multiplier(2, 1)),
Map.entry(Enchantment.THORNS, new Multiplier(8, 4)),
Map.entry(Enchantment.RESPIRATION, new Multiplier(4, 2)),
Map.entry(Enchantment.AQUA_AFFINITY, new Multiplier(4, 2)),
Map.entry(Enchantment.SWIFT_SNEAK, new Multiplier(8, 4)),
Map.entry(Enchantment.FEATHER_FALLING, new Multiplier(2, 1)),
Map.entry(Enchantment.SOUL_SPEED, new Multiplier(8, 4)),
Map.entry(Enchantment.PROTECTION, new Multiplier(1, 1)),
Map.entry(Enchantment.PROJECTILE_PROTECTION, new Multiplier(2, 1)),
Map.entry(Enchantment.FIRE_PROTECTION, new Multiplier(2, 1)),
Map.entry(Enchantment.BLAST_PROTECTION, new Multiplier(4, 2)),
Map.entry(Enchantment.DEPTH_STRIDER, new Multiplier(4, 2)),
Map.entry(Enchantment.FROST_WALKER, new Multiplier(4, 2))
);
public final class SuperArmor extends JavaPlugin implements Listener {
@Override @Override
public void onEnable() public void onEnable()
{ {
@@ -141,8 +128,12 @@ public final class SuperArmor extends JavaPlugin implements Listener {
ItemStack result = left.clone(); ItemStack result = left.clone();
boolean repair = false; boolean repair = false;
getEnchants(right).forEach((enchant, level) -> { getEnchants(right).forEach((enchant, level) -> {
if (isProtection(enchant)) if (isValidEnchant(left, enchant))
{ {
if (Objects.equals(getEnchants(left).getOrDefault(enchant, -1), level))
{
level = Math.min(enchant.getMaxLevel(), level + 1);
}
if (result.getItemMeta() instanceof EnchantmentStorageMeta meta) if (result.getItemMeta() instanceof EnchantmentStorageMeta meta)
{ {
meta.addStoredEnchant(enchant, level, true); meta.addStoredEnchant(enchant, level, true);

View File

@@ -1,4 +1,4 @@
name: SuperArmor name: SuperArmor
version: '1.0' version: '1.2'
main: com.kasetoatz.superArmor.SuperArmor main: com.kasetoatz.superArmor.SuperArmor
api-version: '1.21' api-version: '1.21'