SteamWar/BauSystem2.0
Archiviert
12
0
Dieser Commit ist enthalten in:
yoyosource 2021-05-12 21:46:11 +02:00
Ursprung d171312e0f
Commit fb2e40c8eb
4 geänderte Dateien mit 16 neuen und 60 gelöschten Zeilen

Datei anzeigen

@ -2,6 +2,7 @@ package de.steamwar.bausystem.configplayer;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -17,7 +18,14 @@ import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
@Linked(LinkageType.LISTENER) @Linked(LinkageType.LISTENER)
public class ConfigUpdater implements Listener { public class Config implements Listener {
@Getter
private static Config instance;
{
instance = this;
}
private final Map<UUID, YAPIONObject> playerConfigurations = new HashMap<>(); private final Map<UUID, YAPIONObject> playerConfigurations = new HashMap<>();

Datei anzeigen

@ -20,10 +20,12 @@
package de.steamwar.bausystem.features.gui.editor; package de.steamwar.bausystem.features.gui.editor;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.configplayer.Config;
import lombok.Getter; import lombok.Getter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import yapion.hierarchy.types.YAPIONObject;
import java.util.*; import java.util.*;
@ -50,7 +52,9 @@ public class BauGuiMapping {
BauGuiMapping mapping = fromUUID.get(p.getUniqueId()); BauGuiMapping mapping = fromUUID.get(p.getUniqueId());
if (mapping == null) { 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; return mapping;

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<UUID, BauGuiMapping> DEFAULT_GUI;
static {
DEFAULT_GUI = player -> {
Random rnd = new Random();
int size = (rnd.nextInt(5) + 1) * 9;
HashMap<Integer, Integer> 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);
};
}
}

Datei anzeigen

@ -21,7 +21,7 @@ package de.steamwar.bausystem.linkage;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.configplayer.ConfigConverter; 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.gui.BauGUI;
import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.SpecialCommand;
@ -54,7 +54,7 @@ public enum LinkageType {
// SPECIFIC // SPECIFIC
BAU_GUI_ITEM(3, false, BauGuiItem.class::isAssignableFrom, o -> BauGUI.addItem((BauGuiItem) o)), 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)), 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 -> {}); SCOREBOARD(6, false, ScoreboardItem.class::isAssignableFrom, o -> {});
private final int order; private final int order;