From fb2e40c8ebbb392fb72ff1ddc87a08cc1878d3c5 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 12 May 2021 21:46:11 +0200 Subject: [PATCH] Rename Config --- .../{ConfigUpdater.java => Config.java} | 10 +++- .../features/gui/editor/BauGuiMapping.java | 6 +- .../features/gui/editor/TempClass.java | 56 ------------------- .../bausystem/linkage/LinkageType.java | 4 +- 4 files changed, 16 insertions(+), 60 deletions(-) rename BauSystem_Main/src/de/steamwar/bausystem/configplayer/{ConfigUpdater.java => Config.java} (95%) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/TempClass.java 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/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/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;