SteamWar/FightSystem
Archiviert
13
1

Remove of MultipleKits with same name

Dieser Commit ist enthalten in:
Chaoscaot 2021-01-10 17:06:15 +01:00
Ursprung 42b4109698
Commit bd08c9d890

Datei anzeigen

@ -75,17 +75,15 @@ public class PersonalKitCreator extends BasicListener {
SWAnvilInv anvilInv = new SWAnvilInv(player, "§eKit namen eingeben"); SWAnvilInv anvilInv = new SWAnvilInv(player, "§eKit namen eingeben");
anvilInv.setItem(Material.LEATHER_CHESTPLATE); anvilInv.setItem(Material.LEATHER_CHESTPLATE);
anvilInv.setCallback(s -> { anvilInv.setCallback(s -> {
Kit prototype = KitManager.getKits(Fight.getFightPlayer(player).isLeader()).get(0); SteamwarUser user = SteamwarUser.get(player.getUniqueId());
PersonalKit.create(SteamwarUser.get(player.getUniqueId()).getId(), Config.SchematicType.toDB(), s, prototype.getInventory(), prototype.getArmor()); if(PersonalKit.nameInUse(user.getId(), Config.SchematicType.toDB(), s)) {
List<PersonalKit> kitList = PersonalKit.get(SteamwarUser.get(player.getUniqueId()).getId(), Config.SchematicType.toDB(), s); player.sendMessage(FightSystem.PREFIX + "§cDieser Kit name wird bereits genutzt!");
if(kitList.size() > 1) { player.closeInventory();
List<SWListInv.SWListEntry<PersonalKit>> kitsSelect = new ArrayList<>(kitList.size()); return;
kitList.forEach(kit -> kitsSelect.add(new SWListInv.SWListEntry<>(new SWItem(Material.LEATHER_CHESTPLATE, "§e" + kit.getName()), kit)));
SWListInv<PersonalKit> inv1 = new SWListInv<>(player, "§eWelches Kit bearbeiten", kitsSelect, (clickType1, kit) -> openKitCreator(player, kit));
inv1.open();
} else {
openKitCreator(player, kitList.get(0));
} }
Kit prototype = KitManager.getKits(Fight.getFightPlayer(player).isLeader()).get(0);
PersonalKit kit = PersonalKit.create(user.getId(), Config.SchematicType.toDB(), s, prototype.getInventory(), prototype.getArmor());
openKitCreator(player, kit);
}); });
anvilInv.open(); anvilInv.open();
}); });
@ -103,7 +101,6 @@ public class PersonalKitCreator extends BasicListener {
inv.setItem(0, Material.LEATHER_CHESTPLATE, "§aKit benutzen", clickType -> useKit(player, kit)); inv.setItem(0, Material.LEATHER_CHESTPLATE, "§aKit benutzen", clickType -> useKit(player, kit));
inv.setItem(1, Material.GLASS, "§bPreview", clickType -> preview(player, kit)); inv.setItem(1, Material.GLASS, "§bPreview", clickType -> preview(player, kit));
inv.setItem(4, SWItem.getMaterial("WOOD_AXE"), "§6Kit bearbeiten", clickType -> openKitCreator(player, kit)); inv.setItem(4, SWItem.getMaterial("WOOD_AXE"), "§6Kit bearbeiten", clickType -> openKitCreator(player, kit));
inv.setItem(5, Material.NAME_TAG, "§6Kit Umbenennen", clickType -> renameKit(player, kit));
inv.setItem(8, Material.BARRIER, "§cKit Löschen", clickType -> { inv.setItem(8, Material.BARRIER, "§cKit Löschen", clickType -> {
player.closeInventory(); player.closeInventory();
SWInventory conf = new SWInventory(player, 0, "§cKit " + kit.getName() + " wirklich löchen?"); SWInventory conf = new SWInventory(player, 0, "§cKit " + kit.getName() + " wirklich löchen?");
@ -120,13 +117,6 @@ public class PersonalKitCreator extends BasicListener {
inv.open(); inv.open();
} }
public static void renameKit(Player player, PersonalKit kit) {
SWAnvilInv inv = new SWAnvilInv(player, "§6Kit " + kit.getName() + " umbenennen");
inv.setItem(Material.NAME_TAG);
inv.setCallback(kit::setName);
inv.open();
}
public static void preview(Player player, PersonalKit kit){ public static void preview(Player player, PersonalKit kit){
SWInventory inv = new SWInventory(player, 54, "§e" + kit.getName()); SWInventory inv = new SWInventory(player, 54, "§e" + kit.getName());