SteamWar/BauSystem2.0
Archiviert
12
0

Update and fix stuff
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-06-13 11:40:42 +02:00
Ursprung 482008c461
Commit 063495c624
8 geänderte Dateien mit 51 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -567,6 +567,7 @@ SIMULATOR_GUI_TNT_GROUP_LORE_5 = §7y§8: §e{0}
SIMULATOR_GUI_TNT_GROUP_LORE_6 = §7z§8: §e{0} SIMULATOR_GUI_TNT_GROUP_LORE_6 = §7z§8: §e{0}
SIMULATOR_GUI_TNT_DISABLED = §cDisabled SIMULATOR_GUI_TNT_DISABLED = §cDisabled
SIMULATOR_GUI_NAME = Simulator SIMULATOR_GUI_NAME = Simulator
SIMULATOR_GUI_DELETE = §cDelete TNT
SIMULATOR_GUI_START = §eStart SIMULATOR_GUI_START = §eStart
SIMULATOR_GUI_AUTO_TRACE = §eAutoTrace§8: §7{0} SIMULATOR_GUI_AUTO_TRACE = §eAutoTrace§8: §7{0}
SIMULATOR_GUI_MOVE_ALL = §eMove all SIMULATOR_GUI_MOVE_ALL = §eMove all

Datei anzeigen

@ -558,6 +558,7 @@ SIMULATOR_GUI_TNT_GROUP_NAME = §eTNT Gruppe
SIMULATOR_GUI_TNT_GROUP_LORE_1 = §7Elementanzahl§8: §e{0} SIMULATOR_GUI_TNT_GROUP_LORE_1 = §7Elementanzahl§8: §e{0}
SIMULATOR_GUI_TNT_DISABLED = §cDisabled SIMULATOR_GUI_TNT_DISABLED = §cDisabled
SIMULATOR_GUI_NAME = Kanonensimulator SIMULATOR_GUI_NAME = Kanonensimulator
SIMULATOR_GUI_DELETE = §cTNT löschen
SIMULATOR_GUI_START = §eStarten SIMULATOR_GUI_START = §eStarten
SIMULATOR_GUI_AUTO_TRACE = §eAutoTrace§8: §7{0} SIMULATOR_GUI_AUTO_TRACE = §eAutoTrace§8: §7{0}
SIMULATOR_GUI_MOVE_ALL = §eAlle Verschieben SIMULATOR_GUI_MOVE_ALL = §eAlle Verschieben

Datei anzeigen

@ -156,12 +156,14 @@ public class TNTSimulator {
return tntSpawns; return tntSpawns;
} }
public void remove(TNTElement tntElement) { public void remove(SimulatorElement element) {
hide(tntElement); hide(element);
tntElementList.remove(tntElement); tntElementList.remove(element);
Set<SimulatorElement> toRemove = new HashSet<>(); Set<SimulatorElement> toRemove = new HashSet<>();
for (SimulatorElement spawn : tntElementList) { for (SimulatorElement spawn : tntElementList) {
spawn.remove(tntElement); if (element instanceof TNTElement) {
spawn.remove((TNTElement) element);
}
if (spawn instanceof TNTGroup) { if (spawn instanceof TNTGroup) {
if (((TNTGroup) spawn).getElements().isEmpty()) { if (((TNTGroup) spawn).getElements().isEmpty()) {
toRemove.add(spawn); toRemove.add(spawn);
@ -170,7 +172,7 @@ public class TNTSimulator {
} }
} }
tntElementList.removeAll(toRemove); tntElementList.removeAll(toRemove);
tntElement.close(); element.close();
} }
public void change() { public void change() {

Datei anzeigen

@ -321,6 +321,9 @@ public class TNTElementGUI {
tntGroup.add(newElement); tntGroup.add(newElement);
tntElement.change(); tntElement.change();
open(player, newElement, () -> TNTSimulatorGui.open(player, null, tntGroup, () -> new ArrayList<>(tntGroup.getElements()), () -> {
TNTSimulatorGui.open(player, tntSimulator, null, () -> new ArrayList<>(tntSimulator.getTntElementList()), null);
}));
})); }));
} else { } else {
inv.setItem(24, new SWItem()); inv.setItem(24, new SWItem());
@ -332,8 +335,12 @@ public class TNTElementGUI {
if (tntElement.hasParent()) { if (tntElement.hasParent()) {
newElement.setTickOffset(tntElement.getOwnTickOffset() + 1); newElement.setTickOffset(tntElement.getOwnTickOffset() + 1);
tntElement.getParent().add(newElement); tntElement.getParent().add(newElement);
open(player, newElement, () -> TNTSimulatorGui.open(player, null, tntElement.getParent(), () -> new ArrayList<>(tntElement.getParent().getElements()), () -> {
TNTSimulatorGui.open(player, tntSimulator, null, () -> new ArrayList<>(tntSimulator.getTntElementList()), null);
}));
} else { } else {
tntSimulator.getTntElementList().add(newElement); tntSimulator.getTntElementList().add(newElement);
open(player, newElement, () -> TNTSimulatorGui.open(player, tntSimulator, null, tntSimulator::getTntElementList, null));
} }
})); }));

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.simulator.gui;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.configplayer.Config; import de.steamwar.bausystem.configplayer.Config;
import de.steamwar.bausystem.features.simulator.SimulatorStorage;
import de.steamwar.bausystem.features.simulator.TNTSimulator; import de.steamwar.bausystem.features.simulator.TNTSimulator;
import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement; import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement;
import de.steamwar.bausystem.features.simulator.tnt.TNTElement; import de.steamwar.bausystem.features.simulator.tnt.TNTElement;
@ -70,17 +71,22 @@ public class TNTSimulatorGui {
inv.setItem(47, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("SIMULATOR_BACK", player), clickType -> back.run())); inv.setItem(47, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("SIMULATOR_BACK", player), clickType -> back.run()));
} }
if (currentTntSimulator != null) { if (currentTntSimulator != null) {
inv.setItem(50, new SWItem(Material.MAGENTA_GLAZED_TERRACOTTA, BauSystem.MESSAGE.parse("SIMULATOR_GUI_MOVE_ALL", player), clickType -> { if (totalTNTCount > 0) {
inv.setItem(48, new SWItem(Material.MAGENTA_GLAZED_TERRACOTTA, BauSystem.MESSAGE.parse("SIMULATOR_GUI_MOVE_ALL", player), clickType -> {
moveAll(player, currentTntSimulator, () -> open(player, currentTntSimulator, currentTntGroup, simulatorElements, back)); moveAll(player, currentTntSimulator, () -> open(player, currentTntSimulator, currentTntGroup, simulatorElements, back));
})); }));
}
boolean simulatorAutoTrace = Config.getInstance().get(player).getPlainValueOrDefault("simulatorAutoTrace", false); boolean simulatorAutoTrace = Config.getInstance().get(player).getPlainValueOrDefault("simulatorAutoTrace", false);
inv.setItem(48, new SWItem(simulatorAutoTrace ? Material.CHAIN_COMMAND_BLOCK : Material.COMMAND_BLOCK, BauSystem.MESSAGE.parse("SIMULATOR_GUI_AUTO_TRACE", player, simulatorAutoTrace), clickType -> { inv.setItem(47, new SWItem(simulatorAutoTrace ? Material.CHAIN_COMMAND_BLOCK : Material.COMMAND_BLOCK, BauSystem.MESSAGE.parse("SIMULATOR_GUI_AUTO_TRACE", player, simulatorAutoTrace), clickType -> {
Config.getInstance().get(player).put("simulatorAutoTrace", !simulatorAutoTrace); Config.getInstance().get(player).put("simulatorAutoTrace", !simulatorAutoTrace);
open(player, currentTntSimulator, currentTntGroup, simulatorElements, back); open(player, currentTntSimulator, currentTntGroup, simulatorElements, back);
})); }));
} }
inv.setItem(49, new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("SIMULATOR_GUI_TOTAL_TNT", player, totalTNTCount), clickType -> {})); SWItem swItem = new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("SIMULATOR_GUI_TOTAL_TNT", player, totalTNTCount), clickType -> {
});
swItem.getItemStack().setAmount(totalTNTCount);
inv.setItem(currentTntSimulator != null || currentTntGroup != null ? 50 : 49, swItem);
if (currentTntGroup != null) { if (currentTntGroup != null) {
Runnable editObserver = () -> { Runnable editObserver = () -> {
List<String> otherLore = new ArrayList<>(); List<String> otherLore = new ArrayList<>();
@ -96,7 +102,7 @@ public class TNTSimulatorGui {
otherLore.add(""); otherLore.add("");
otherLore.add(BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_DISABLED", player)); otherLore.add(BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_DISABLED", player));
} }
inv.setItem(51, new SWItem(Material.ANVIL, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_GROUP", player), otherLore, false, clickType -> { inv.setItem(48, new SWItem(Material.ANVIL, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_GROUP", player), otherLore, false, clickType -> {
TNTGroupEditGUI.open(player, currentTntGroup, () -> open(player, currentTntSimulator, currentTntGroup, simulatorElements, back)); TNTGroupEditGUI.open(player, currentTntGroup, () -> open(player, currentTntSimulator, currentTntGroup, simulatorElements, back));
})); }));
}; };
@ -105,6 +111,20 @@ public class TNTSimulatorGui {
inv.addCloseRunnable(() -> currentTntGroup.unregister(editObserver)); inv.addCloseRunnable(() -> currentTntGroup.unregister(editObserver));
} }
if (currentTntSimulator != null || currentTntGroup != null) {
inv.setItem(51, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("SIMULATOR_GUI_DELETE", player), clickType -> {
if (currentTntSimulator != null) {
currentTntSimulator.hide();
currentTntSimulator.getTntElementList().forEach(SimulatorElement::close);
currentTntSimulator.getTntElementList().clear();
player.closeInventory();
} else {
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player.getInventory().getItemInMainHand());
tntSimulator.remove(currentTntGroup);
}
}));
}
inv.open(); inv.open();
} }

Datei anzeigen

@ -78,6 +78,9 @@ public interface SimulatorElement {
if (closeRunnable == null) return; if (closeRunnable == null) return;
closeRunnable.run(); closeRunnable.run();
}); });
if (this instanceof TNTGroup) {
((TNTGroup) this).getElements().forEach(SimulatorElement::close);
}
} }
// API // API

Datei anzeigen

@ -165,7 +165,9 @@ public class TNTElement implements SimulatorElement {
lore.add(""); lore.add("");
lore.add(BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_DISABLED", p)); lore.add(BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_DISABLED", p));
} }
return new SWItem(material, BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_SPAWN_NAME", p), lore, disabled, null); SWItem swItem = new SWItem(material, BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_SPAWN_NAME", p), lore, disabled, null);
if (!disabled) swItem.getItemStack().setAmount(tntCount());
return swItem;
} }
@Override @Override

Datei anzeigen

@ -135,7 +135,9 @@ public class TNTGroup implements SimulatorElement {
lore.add(""); lore.add("");
lore.add(BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_DISABLED", p)); lore.add(BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_DISABLED", p));
} }
return new SWItem(material, BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_GROUP_NAME", p), lore, disabled, null); SWItem swItem = new SWItem(material, BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_GROUP_NAME", p), lore, disabled, null);
if (!disabled) swItem.getItemStack().setAmount(tntCount());
return swItem;
} }
@Override @Override