From 271b38c775dc5336bafb97fb0be36dbb800956b5 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Fri, 3 Feb 2023 17:37:52 +0100 Subject: [PATCH] Add: Show Invalid SchematicTypes in changeType GUI --- .../src/SchematicSystem.properties | 21 +++++++++++++++++++ .../src/SchematicSystem_de.properties | 20 ++++++++++++++++++ .../schematicsystem/commands/GUI.java | 14 +++++++++++-- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/SchematicSystem_Core/src/SchematicSystem.properties b/SchematicSystem_Core/src/SchematicSystem.properties index 1a372a3..9932bdd 100644 --- a/SchematicSystem_Core/src/SchematicSystem.properties +++ b/SchematicSystem_Core/src/SchematicSystem.properties @@ -1,3 +1,22 @@ +# +# This file is a part of the SteamWar software. +# +# Copyright (C) 2023 SteamWar.de-Serverteam +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + PREFIX=§eSchematic§8» §7 ON=§aon OFF=§coff @@ -193,6 +212,8 @@ GUI_INFO_DELETE=§cDelete GUI_INFO_MEMBER_FROM=§7Owner §e{0} GUI_INFO_MEMBER_REMOVE=§cRemove access GUI_CHANGE_TYPE=Change type +GUI_CHANGE_TYPE_NOT_POSSIBLE=§cThe Schematic is too big +GUI_CHANGE_TYPE_NOT_POSSIBLE_COLOR=§7{0} GUI_DELETE_OWN_DELETED=Schematic §e{0} §7deleted GUI_DELETE_OWN_TITLE=Delete {0} GUI_DELETE_MEMBER_TITLE=Remove {0} diff --git a/SchematicSystem_Core/src/SchematicSystem_de.properties b/SchematicSystem_Core/src/SchematicSystem_de.properties index 66a1cae..465b0f7 100644 --- a/SchematicSystem_Core/src/SchematicSystem_de.properties +++ b/SchematicSystem_Core/src/SchematicSystem_de.properties @@ -1,3 +1,22 @@ +# +# This file is a part of the SteamWar software. +# +# Copyright (C) 2023 SteamWar.de-Serverteam +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + ON=§aAn OFF=§cAus CHANGE=§7Zum Ändern @@ -174,6 +193,7 @@ GUI_INFO_DELETE=§cLöschen GUI_INFO_MEMBER_FROM=§7von §e{0} GUI_INFO_MEMBER_REMOVE=§cZugriff entfernen GUI_CHANGE_TYPE=Typ ändern +GUI_CHANGE_TYPE_NOT_POSSIBLE=§cDie Schematic ist zu groß GUI_DELETE_OWN_DELETED=Schematic §e{0} §7gelöscht GUI_DELETE_OWN_TITLE={0} löschen GUI_DELETE_MEMBER_TITLE={0} entfernen diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/GUI.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/GUI.java index 19a9fde..f92f76d 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/GUI.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/GUI.java @@ -221,13 +221,23 @@ public class GUI { } catch (IOException ignored) { } Clipboard finalClipboard = clipboard; - List> types = SchematicType.values().parallelStream() + List types = SchematicType.values().parallelStream() .filter(SchematicType::isAssignable) .filter(type -> finalClipboard == null || CheckSchemType.get(type) == null || AutoChecker.sizeCheck(finalClipboard, CheckSchemType.get(type)).fastOk()) + .collect(Collectors.toList()); + + List> items = types.stream() .map(type -> new SWListInv.SWListEntry<>(new SWItem(SWItem.getMaterial(type.getMaterial()), type.name(), Collections.emptyList(), type.fightType(), null), type)) .collect(Collectors.toList()); - SWListInv inv = new SWListInv<>(p, SchematicSystem.MESSAGE.parse("GUI_CHANGE_TYPE", p), types, (clickType, schematicType) -> { + items.addAll(SchematicType.values().stream() + .filter(SchematicType::isAssignable) + .filter(type -> !types.contains(type)) + .map(type -> new SWListInv.SWListEntry<>(new SWItem(SWItem.getMaterial(type.getMaterial()), SchematicSystem.MESSAGE.parse("GUI_CHANGE_TYPE_NOT_POSSIBLE_COLOR", p, type.name()), Collections.singletonList(SchematicSystem.MESSAGE.parse("GUI_CHANGE_TYPE_NOT_POSSIBLE", p)), false, null), (SchematicType) null)) + .collect(Collectors.toList())); + + SWListInv inv = new SWListInv<>(p, SchematicSystem.MESSAGE.parse("GUI_CHANGE_TYPE", p), items, (clickType, schematicType) -> { + if(schematicType == null) return; p.closeInventory(); SchematicCommandUtils.changeType(p, schem, schematicType, null); }); -- 2.39.2