SteamWar/BauSystem2.0
Archiviert
12
0

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	BauSystem_Main/src/BauSystem.properties
#	BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiImportExport.java
Dieser Commit ist enthalten in:
yoyosource 2021-05-13 16:02:19 +02:00
Commit 56a30bbbf8
4 geänderte Dateien mit 88 neuen und 48 gelöschten Zeilen

Datei anzeigen

@ -1,3 +1,22 @@
/*
* 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.configplayer;
import lombok.experimental.UtilityClass;
@ -27,11 +46,12 @@ public class ConfigCreator {
// 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).add("3", 3).add("4", 7).add("5", 17).add("6", 15);
yapionObject.add("9", 5).add("18", 4).add("27", 6);
yapionObject.add("17", 16).add("26", 11).add("35", 18);
yapionObject.add("20", 19).add("21", 21).add("22", 9).add("23", 0).add("24", 1);
yapionObject.add("37", 23).add("38", 20).add("39", 8).add("40", 22).add("41", 26).add("42", 12).add("43", 14);
yapionObject.add("10", 2).add("3", 3).add("7", 4).add("17", 5).add("15", 6);
yapionObject.add("5", 9).add("4", 18).add("6", 27);
yapionObject.add("16", 17).add("11", 26).add("18", 35);
yapionObject.add("19", 20).add("21", 21).add("9", 22).add("0", 23).add("1", 24);
yapionObject.add("23", 37).add("20", 38).add("8", 39).add("22", 40).add("26", 41).add("12", 42).add("14", 43);
yapionObject.add("size", 45);
return yapionObject;
}

Datei anzeigen

@ -22,9 +22,9 @@ package de.steamwar.bausystem.features.gui.editor;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.config.ColorConfig;
import de.steamwar.bausystem.features.gui.BauGUI;
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
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 de.steamwar.inventory.SWListInv;
import lombok.Getter;
@ -209,6 +209,7 @@ public class BauGuiEditor implements Listener {
}
mapping.setMapping(newMapping);
mapping.save();
}
@EventHandler

Datei anzeigen

@ -50,7 +50,6 @@ public class BauGuiImportExport {
byte[] bytes = Base64.getDecoder().decode(str);
if (bytes.length % 2 != 1 || bytes.length < 2) {
BauSystem.MESSAGE.send("GUI_IMPORT_INVALID_CODE", p);
System.out.println("t1");
return false;
}
@ -58,7 +57,6 @@ public class BauGuiImportExport {
final int size = bytes[bytes.length - 1];
if (size > 9 * 5) {
BauSystem.MESSAGE.send("GUI_IMPORT_INVALID_CODE", p);
System.out.println("t2");
return false;
}
@ -74,7 +72,6 @@ public class BauGuiImportExport {
if (map.containsKey((int) key) || map.containsValue((int) value) ||
value >= size || key > itemSize) {
BauSystem.MESSAGE.send("GUI_IMPORT_INVALID_CODE", p);
System.out.println("t3");
return false;
}
@ -83,6 +80,7 @@ public class BauGuiImportExport {
BauGuiMapping mapping = BauGuiMapping.getGuiMapping(p);
mapping.setMapping(map);
mapping.setSize(size);
mapping.save();
return true;
}
}

Datei anzeigen

@ -21,7 +21,10 @@ package de.steamwar.bausystem.features.gui.editor;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.configplayer.Config;
import de.steamwar.bausystem.features.gui.BauGUI;
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
@ -48,70 +51,88 @@ public class BauGuiMapping {
}
}
@Getter
private final YAPIONObject object;
@Getter
private final Player owner;
@Getter
@Setter
private boolean saved;
protected BauGuiMapping(YAPIONObject object, Player p) {
this.object = object;
this.owner = p;
fromUUID.put(p.getUniqueId(), this);
mappings.add(this);
}
public static BauGuiMapping getGuiMapping(Player p) {
BauGuiMapping mapping = fromUUID.get(p.getUniqueId());
if (mapping == null) {
YAPIONObject yapionObject = Config.getInstance().get(p);
// TODO: Implement loading
// mapping = TempClass.DEFAULT_GUI.apply(p.getUniqueId());
mapping = new BauGuiMapping(yapionObject.getObject("baugui"), p);
}
return mapping;
}
@Getter
private final UUID owner;
@Getter
private final Map<Integer, Integer> mapping;
@Getter
private int size;
@Getter
private boolean saved;
protected BauGuiMapping(UUID owner) {
this.owner = owner;
this.mapping = new HashMap<>();
fromUUID.put(owner, this);
mappings.add(this);
}
protected BauGuiMapping(UUID owner, int size, Map<Integer, Integer> mapping) {
this.owner = owner;
this.size = size;
this.mapping = mapping;
fromUUID.put(owner, this);
mappings.add(this);
}
public boolean isShown(int id) {
if (!mapping.containsKey(id)) {
return false;
}
return mapping.get(id) >= 0;
return object.getPlainValueOrDefault(Integer.toString(id), -1) >= 0;
}
public int getSlot(int id) {
return mapping.get(id);
return object.getPlainValue(Integer.toString(id));
}
public Map<Integer, Integer> getMapping() {
return internalReadMap();
}
public void setMapping(Map<Integer, Integer> mapping) {
this.mapping.clear();
this.mapping.putAll(mapping);
this.saved = true;
internalWriteMap(mapping);
}
public boolean setSize(int size) {
public int getSize() {
return object.getPlainValueOrDefault("size", 45);
}
public void setSize(int size) {
if (size % 9 != 0) {
return false;
return;
}
this.size = size;
return true;
object.add("size", size);
}
private void tick() {
this.saved = false;
}
public void save() {
if (saved) return;
YAPIONObject config = Config.getInstance().get(owner);
config.add("baugui", object);
Config.getInstance().save(owner);
saved = true;
}
private Map<Integer, Integer> internalReadMap() {
Map<Integer, Integer> map = new HashMap<>();
for (Map.Entry<Integer, BauGuiItem> e : BauGUI.getITEMS().entrySet()) {
Integer value = object.getPlainValueOrDefault(e.getKey().toString(), -1);
if (value == -1) continue;
map.put(e.getKey(), value);
}
return map;
}
private void internalWriteMap(Map<Integer, Integer> map) {
for (Map.Entry<Integer, BauGuiItem> e : BauGUI.getITEMS().entrySet()) {
object.remove(e.getKey().toString());
Integer value = map.getOrDefault(e.getKey(), -1);
if (value == -1) continue;
object.add(e.getKey().toString(), value);
}
}
}