remove: key/toolbox/map items, keep only medkit and flashlight

This commit is contained in:
loki5512344 2026-06-03 23:33:19 +02:00
parent f9847dbb73
commit 3d6204cc83
156 changed files with 583 additions and 517 deletions

View file

@ -10,8 +10,8 @@ import org.bukkit.persistence.PersistentDataType;
import java.util.List;
/**
* Central factory for all DBD custom items.
* Items are identified by a PersistentDataContainer tag "mdbd:item_type".
* Central factory for DBD custom items: Medkit and Flashlight.
* Items are identified by PersistentDataContainer tag "mdbd:item_type".
* Charges are stored as "mdbd:charges".
*/
public final class DBDItems {
@ -31,7 +31,7 @@ public final class DBDItems {
charges, ItemType.MEDKIT.getDefaultCharges(),
List.of(
"<gray>Лечит одно состояние здоровья.",
"<yellow>ПКМ <gray>— начать лечение"
"<yellow>ПКМ <gray>— начать самолечение"
),
"MEDKIT"
);
@ -55,54 +55,6 @@ public final class DBDItems {
public static ItemStack flashlight() { return flashlight(ItemType.FLASHLIGHT.getDefaultCharges()); }
/** Ящик с инструментами — ускоряет ремонт генератора. */
public static ItemStack toolbox(int charges) {
return build(
Material.CHEST,
"<#00CED1>Ящик с инструментами",
charges, ItemType.TOOLBOX.getDefaultCharges(),
List.of(
"<gray>Ускоряет ремонт генераторов.",
"<yellow>Держите в руке <gray>во время ремонта"
),
"TOOLBOX"
);
}
public static ItemStack toolbox() { return toolbox(ItemType.TOOLBOX.getDefaultCharges()); }
/** Ключ — открывает люк (hatch). */
public static ItemStack key(int charges) {
return build(
Material.TRIPWIRE_HOOK,
"<#FFA500>Ключ",
charges, ItemType.KEY.getDefaultCharges(),
List.of(
"<gray>Открывает люк немедленно.",
"<yellow>ПКМ у люка <gray>— открыть"
),
"KEY"
);
}
public static ItemStack key() { return key(ItemType.KEY.getDefaultCharges()); }
/** Карта — показывает объекты на карте. */
public static ItemStack map(int charges) {
return build(
Material.MAP,
"<#87CEEB>Карта",
charges, ItemType.MAP.getDefaultCharges(),
List.of(
"<gray>Раскрывает объекты поблизости.",
"<yellow>ПКМ <gray>— активировать"
),
"MAP"
);
}
public static ItemStack map() { return map(ItemType.MAP.getDefaultCharges()); }
// ── Helpers ───────────────────────────────────────────────────────────────
private static ItemStack build(Material mat, String name, int charges, int maxCharges,
@ -111,7 +63,6 @@ public final class DBDItems {
item.editMeta(meta -> {
meta.displayName(TextUtil.color(name));
// Build lore: description lines + charges bar
var lore = new java.util.ArrayList<Component>();
for (String line : loreLines) {
lore.add(TextUtil.color(line));
@ -148,51 +99,18 @@ public final class DBDItems {
return c != null ? c : 0;
}
/** Обновить заряды на существующем предмете и вернуть обновлённый стак. */
public static ItemStack setCharges(ItemStack item, int newCharges) {
if (item == null || !item.hasItemMeta()) return item;
String type = getType(item);
if (type == null) return item;
int max = getMaxCharges(type);
return build(item.getType(),
getDisplayNameRaw(type), newCharges, max,
getLoreRaw(type), type);
return switch (type) {
case "MEDKIT" -> medkit(newCharges);
case "FLASHLIGHT" -> flashlight(newCharges);
default -> item;
};
}
public static boolean isMedkit(ItemStack item) { return "MEDKIT".equals(getType(item)); }
public static boolean isFlashlight(ItemStack item) { return "FLASHLIGHT".equals(getType(item)); }
public static boolean isToolbox(ItemStack item) { return "TOOLBOX".equals(getType(item)); }
public static boolean isKey(ItemStack item) { return "KEY".equals(getType(item)); }
public static boolean isMap(ItemStack item) { return "MAP".equals(getType(item)); }
public static boolean isDBDItem(ItemStack item) { return getType(item) != null; }
private static int getMaxCharges(String type) {
return switch (type) {
case "MEDKIT" -> ItemType.MEDKIT.getDefaultCharges();
case "FLASHLIGHT" -> ItemType.FLASHLIGHT.getDefaultCharges();
case "TOOLBOX" -> ItemType.TOOLBOX.getDefaultCharges();
case "KEY" -> ItemType.KEY.getDefaultCharges();
default -> ItemType.MAP.getDefaultCharges();
};
}
private static String getDisplayNameRaw(String type) {
return switch (type) {
case "MEDKIT" -> "<#00FF7F>Медкит";
case "FLASHLIGHT" -> "<#FFD700>Фонарик";
case "TOOLBOX" -> "<#00CED1>Ящик с инструментами";
case "KEY" -> "<#FFA500>Ключ";
default -> "<#87CEEB>Карта";
};
}
private static List<String> getLoreRaw(String type) {
return switch (type) {
case "MEDKIT" -> List.of("<gray>Лечит одно состояние здоровья.", "<yellow>ПКМ <gray>— начать лечение");
case "FLASHLIGHT" -> List.of("<gray>Ослепляет киллера при попадании.", "<yellow>ПКМ <gray>— направить луч на киллера");
case "TOOLBOX" -> List.of("<gray>Ускоряет ремонт генераторов.", "<yellow>Держите в руке <gray>во время ремонта");
case "KEY" -> List.of("<gray>Открывает люк немедленно.", "<yellow>ПКМ у люка <gray>— открыть");
default -> List.of("<gray>Раскрывает объекты поблизости.", "<yellow>ПКМ <gray>— активировать");
};
}
}