diff --git a/BauSystem_Main/src/de/steamwar/bausystem/configplayer/ConfigUpdater.java b/BauSystem_Main/src/de/steamwar/bausystem/configplayer/Config.java similarity index 95% rename from BauSystem_Main/src/de/steamwar/bausystem/configplayer/ConfigUpdater.java rename to BauSystem_Main/src/de/steamwar/bausystem/configplayer/Config.java index d5329e7f..357b4781 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/configplayer/ConfigUpdater.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/configplayer/Config.java @@ -2,6 +2,7 @@ package de.steamwar.bausystem.configplayer; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; +import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -17,7 +18,14 @@ import java.util.UUID; import java.util.logging.Level; @Linked(LinkageType.LISTENER) -public class ConfigUpdater implements Listener { +public class Config implements Listener { + + @Getter + private static Config instance; + + { + instance = this; + } private final Map playerConfigurations = new HashMap<>(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/configplayer/ConfigCreator.java b/BauSystem_Main/src/de/steamwar/bausystem/configplayer/ConfigCreator.java index 19b2831f..8d22bb0e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/configplayer/ConfigCreator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/configplayer/ConfigCreator.java @@ -12,9 +12,49 @@ public class ConfigCreator { YAPIONObject yapionObject = new YAPIONObject(); // This call should never be touched yapionObject.add("@version", currentVersion); + yapionObject.add("baugui", defaultBauGui()); // Any initialising goes into here return yapionObject; } + private YAPIONObject defaultBauGui() { + YAPIONObject yapionObject = new YAPIONObject(); + + // 0: ? | 1: ? | 2: 10 | 3: 3 | 4: 7 | 5: 17 | 6: 15 | 7: ? | 8: ? + // 9: 5 | 10: ? | 11: ? | 12: ? | 13: ? | 14: ? | 15: ? | 16: ? | 17: 16 + // 18: 4 | 19: ? | 20: 19 | 21: 21 | 22: 9 | 23: 0 | 24: 1 | 25: ? | 26: 11 + // 27: 6 | 28: ? | 29: ? | 30: ? | 31: ? | 32: ? | 33: ? | 34: ? | 35: 18 + // 36: ? | 37: 23 | 38: 20 | 39: 8 | 40: 22 | 41: 26 | 42: 12 | 43: 14 | 44: ? + + yapionObject.add("2", 10); + yapionObject.add("3", 3); + yapionObject.add("4", 7); + yapionObject.add("5", 17); + yapionObject.add("6", 15); + + yapionObject.add("9", 5); + yapionObject.add("18", 4); + yapionObject.add("27", 6); + + yapionObject.add("17", 16); + yapionObject.add("26", 11); + yapionObject.add("35", 18); + + yapionObject.add("20", 19); + yapionObject.add("21", 21); + yapionObject.add("22", 9); + yapionObject.add("23", 0); + yapionObject.add("24", 1); + + yapionObject.add("37", 23); + yapionObject.add("38", 20); + yapionObject.add("39", 8); + yapionObject.add("40", 22); + yapionObject.add("41", 26); + yapionObject.add("42", 12); + yapionObject.add("43", 14); + return yapionObject; + } + } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiMapping.java b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiMapping.java index d7bd306a..38868aa8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiMapping.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiMapping.java @@ -20,10 +20,12 @@ package de.steamwar.bausystem.features.gui.editor; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.configplayer.Config; import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitTask; +import yapion.hierarchy.types.YAPIONObject; import java.util.*; @@ -50,7 +52,9 @@ public class BauGuiMapping { BauGuiMapping mapping = fromUUID.get(p.getUniqueId()); if (mapping == null) { - mapping = TempClass.DEFAULT_GUI.apply(p.getUniqueId()); + YAPIONObject yapionObject = Config.getInstance().get(p); + // TODO: Implement loading + // mapping = TempClass.DEFAULT_GUI.apply(p.getUniqueId()); } return mapping; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/TempClass.java b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/TempClass.java deleted file mode 100644 index 5b3d11da..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/TempClass.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 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 . - */ - -package de.steamwar.bausystem.features.gui.editor; - -import de.steamwar.bausystem.features.gui.BauGUI; -import de.steamwar.bausystem.linkage.specific.BauGuiItem; - -import java.util.HashMap; -import java.util.Random; -import java.util.UUID; -import java.util.function.Function; - -// TODO: 01.05.2021 remove class -public class TempClass { - - public static final Function DEFAULT_GUI; - - static { - DEFAULT_GUI = player -> { - Random rnd = new Random(); - int size = (rnd.nextInt(5) + 1) * 9; - HashMap mapping = new HashMap<>(); - for (BauGuiItem item : BauGUI.getITEMS().values()) { - int slot; - int i = 0; - do { - if (i > 5) { - slot = -1; - break; - } - slot = rnd.nextInt(size + 1) - 1; - i++; - } while (mapping.containsValue(slot)); - mapping.put(item.getId(), slot); - } - return new BauGuiMapping(player, size, mapping); - }; - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NavWandBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NavWandBauGuiItem.java new file mode 100644 index 00000000..86a1deaf --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NavWandBauGuiItem.java @@ -0,0 +1,57 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2021 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 . + */ + +package de.steamwar.bausystem.features.util.items; + +import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.bausystem.linkage.specific.BauGuiItem; +import de.steamwar.inventory.SWItem; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import java.util.Arrays; + +@Linked(LinkageType.BAU_GUI_ITEM) +public class NavWandBauGuiItem extends BauGuiItem { + + public NavWandBauGuiItem() { + super(27); + } + + @Override + public Permission permission() { + return Permission.WORLDEDIT; + } + + @Override + public ItemStack getItem(Player player) { + return new SWItem(Material.WOODEN_AXE, "Navigation Wand", Arrays.asList("Left click: jump to location", "Right click: pass through walls"), false, clickType -> { + }).getItemStack(); + } + + @Override + public boolean click(ClickType click, Player p) { + p.performCommand("/wand -n"); + return false; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WorldEditBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WorldEditBauGuiItem.java new file mode 100644 index 00000000..90c2575c --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WorldEditBauGuiItem.java @@ -0,0 +1,57 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2021 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 . + */ + +package de.steamwar.bausystem.features.util.items; + +import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.bausystem.linkage.specific.BauGuiItem; +import de.steamwar.inventory.SWItem; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import java.util.Arrays; + +@Linked(LinkageType.BAU_GUI_ITEM) +public class WorldEditBauGuiItem extends BauGuiItem { + + public WorldEditBauGuiItem() { + super(26); + } + + @Override + public Permission permission() { + return Permission.WORLDEDIT; + } + + @Override + public ItemStack getItem(Player player) { + return new SWItem(Material.WOODEN_AXE, "WorldEdit Wand", Arrays.asList("Left click: select pos #1", "Right click: select pos #2"), false, clickType -> { + }).getItemStack(); + } + + @Override + public boolean click(ClickType click, Player p) { + p.performCommand("/wand"); + return false; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkageType.java b/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkageType.java index 90675900..c6684b35 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkageType.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkageType.java @@ -21,7 +21,7 @@ package de.steamwar.bausystem.linkage; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.configplayer.ConfigConverter; -import de.steamwar.bausystem.configplayer.ConfigUpdater; +import de.steamwar.bausystem.configplayer.Config; import de.steamwar.bausystem.features.gui.BauGUI; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; @@ -54,7 +54,7 @@ public enum LinkageType { // SPECIFIC BAU_GUI_ITEM(3, false, BauGuiItem.class::isAssignableFrom, o -> BauGUI.addItem((BauGuiItem) o)), SCRIPT_COMMAND(4, false, SpecialCommand.class::isAssignableFrom, o -> ScriptExecutor.SPECIAL_COMMANDS.add((SpecialCommand) o)), - CONFIG_CONVERTER(5, false, ConfigConverter.class::isAssignableFrom, o -> ConfigUpdater.addConfigConverter((ConfigConverter) o)), + CONFIG_CONVERTER(5, false, ConfigConverter.class::isAssignableFrom, o -> Config.addConfigConverter((ConfigConverter) o)), SCOREBOARD(6, false, ScoreboardItem.class::isAssignableFrom, o -> {}); private final int order;