From b137aaec241885bb6ea1c279bb832e676b9611df Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 22 Jul 2024 10:30:54 +0200 Subject: [PATCH] Fix MWTeam.givePlayerItem Update Missile.lore --- src/de/steamwar/misslewars/MWTeam.java | 2 +- src/de/steamwar/misslewars/items/Missile.java | 28 ++----------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/src/de/steamwar/misslewars/MWTeam.java b/src/de/steamwar/misslewars/MWTeam.java index 0de8321..8244b6d 100644 --- a/src/de/steamwar/misslewars/MWTeam.java +++ b/src/de/steamwar/misslewars/MWTeam.java @@ -104,7 +104,7 @@ public class MWTeam { Inventory inventory = p.getInventory(); for (int i = 0; i <= 35; i++) { // 35 is the last normal inventory slot ItemStack itemStack = inventory.getItem(i); - if (itemStack != null && itemStack.isSimilar(item) && getUsesOfItem(itemStack) + getUsesOfItem(item) <= itemStack.getType().getMaxDurability()) { + if (itemStack != null && itemStack.getType() == item.getType() && getUsesOfItem(itemStack) + getUsesOfItem(item) <= itemStack.getType().getMaxDurability()) { int uses = getUsesOfItem(itemStack) + getUsesOfItem(item); ItemMeta itemMeta = itemStack.getItemMeta(); Damageable damageable = (Damageable) itemMeta; diff --git a/src/de/steamwar/misslewars/items/Missile.java b/src/de/steamwar/misslewars/items/Missile.java index efb1a1a..139beec 100644 --- a/src/de/steamwar/misslewars/items/Missile.java +++ b/src/de/steamwar/misslewars/items/Missile.java @@ -82,32 +82,10 @@ public class Missile extends SpecialItem { private void lore(List lore, String[] args, int index, String tag) { if (args.length > index) { - try { - lore.add(graph(Integer.parseInt(args[index]), GRAPH_SIZE) + tag); - return; - } catch (NumberFormatException e) { - // Ignored - } + lore.add(tag + " §8: §e" + Integer.parseInt(args[index]) + "§8/§77"); + } else { + lore.add(tag + " §8: §e0§8/§77"); } - lore.add(graph(0, GRAPH_SIZE) + tag); - } - - private String graph(int index, int size) { - if (index > size) index = size; - StringBuilder st = new StringBuilder(); - st.append("§8[§e"); - if (index > 0) st.append(repeat(index)); - st.append("§7"); - st.append(repeat(size - index)); - st.append("§8]"); - return st.toString(); - } - - private String repeat(int count) { - if (count == 0) return ""; - StringBuilder st = new StringBuilder(); - for (int i = 0; i < count; i++) st.append("="); - return st.toString(); } @Override