SteamWar/BauSystem2.0
Archiviert
12
0

SimRework2.0 #216

Zusammengeführt
YoyoNow hat 49 Commits von SimRework2.0 nach master 2023-12-16 12:30:57 +01:00 zusammengeführt
6 geänderte Dateien mit 130 neuen und 14 gelöschten Zeilen
Nur Änderungen aus Commit aef8edca07 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -0,0 +1,113 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 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.simulator2.gui;
import de.steamwar.bausystem.features.simulator2.SimulatorWatcher;
import de.steamwar.bausystem.features.simulator2.data.Simulator;
import de.steamwar.bausystem.features.simulator2.data.SimulatorElement;
import de.steamwar.bausystem.features.simulator2.data.SimulatorGroup;
import de.steamwar.bausystem.features.simulator2.data.redstone.RedstoneElement;
import de.steamwar.bausystem.features.simulator2.data.tnt.TNTElement;
import de.steamwar.bausystem.features.simulator2.gui.base.SimulatorBaseGui;
import de.steamwar.bausystem.features.simulator2.gui.base.SimulatorPageGui;
import de.steamwar.bausystem.features.simulator2.gui.utils.SimulatorMaterialGui;
import de.steamwar.inventory.SWItem;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class SimulatorGroupChooserGui extends SimulatorPageGui<SimulatorGroup> {
private final SimulatorElement<?> subject;
private final SimulatorGroup parent;
private final SimulatorBaseGui back;
public SimulatorGroupChooserGui(Player player, Simulator simulator, List<SimulatorGroup> data, SimulatorElement<?> subject, SimulatorGroup parent, SimulatorBaseGui back){
super(player, simulator, 6*9, data);
this.subject = subject;
this.parent = parent;
this.back = back;
}
@Override
public void headerAndFooter() {
simulator.getElements().removeIf(element -> element.getElements().isEmpty());
inventory.setItem(4, new SWItem(simulator.getMaterial(), "§e" + simulator.getName(), clickType -> {}));
if(parent.getElements().size() != 1){
inventory.setItem(49 , new SWItem(Material.BARRIER, "§c Remove from Group", clickType -> {
SimulatorGroup newParent = new SimulatorGroup();
newParent.add(subject);
simulator.getElements().add(newParent);
back.open();
SimulatorWatcher.update(simulator);
}));
}
}
@Override
public String baseTitle() {
return "§eChoose group to add to or element, to create new group";
}
@Override
public SWItem convert(SimulatorGroup simulatorGroup) {
List<SimulatorElement<?>> elements = simulatorGroup.getElements();
if (elements.size() == 1) {
SimulatorElement<?> element = elements.get(0);
List<String> lore = new ArrayList<>();
lore.add("§7Phase count§8:§e " + element.getPhases().size());
lore.add("§7Tick§8:§e " + element.getBaseTick());
lore.add("");
lore.add("§7X§8:§e " + element.getPosition().getX());
lore.add("§7Y§8:§e " + element.getPosition().getY());
lore.add("§7Z§8:§e " + element.getPosition().getZ());
if (element.isDisabled()) {
lore.add("");
lore.add("§cDisabled");
}
return new SWItem(element.getMaterial(), "§e" + element.getName(), lore, element.isDisabled(), clickType -> {
SimulatorGroup newParent = new SimulatorGroup();
newParent.add(subject);
newParent.add(element);
simulatorGroup.getElements().remove(element);
parent.getElements().remove(subject);
simulator.getElements().add(newParent);
back.open();
SimulatorWatcher.update(simulator);
});
}
List<String> lore = new ArrayList<>();
lore.add("§7Element count§8:§e " + elements.size());
lore.add("§7Tick§8:§e " + simulatorGroup.getBaseTick());
if (simulatorGroup.isDisabled()) {
lore.add("");
lore.add("§cDisabled");
}
return new SWItem(simulatorGroup.getMaterial(), "§eGroup", lore, simulatorGroup.isDisabled(), clickType -> {
simulatorGroup.add(subject);
parent.getElements().remove(subject);
back.open();
SimulatorWatcher.update(simulator);
});
}
}

Datei anzeigen

@ -35,7 +35,7 @@ import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class SimulatorGroupGui extends SimulatorPageGui<SimulatorElement<?>> { public class SimulatorGroupGui extends SimulatorPageGui<SimulatorElement<?>> { //TODO Disolve group option ?
private final SimulatorGroup simulatorGroup; private final SimulatorGroup simulatorGroup;
private final SimulatorBaseGui back; private final SimulatorBaseGui back;
@ -99,7 +99,7 @@ public class SimulatorGroupGui extends SimulatorPageGui<SimulatorElement<?>> {
} }
return new SWItem(element.getMaterial(), "§e" + element.getName(), lore, element.isDisabled(), clickType -> { return new SWItem(element.getMaterial(), "§e" + element.getName(), lore, element.isDisabled(), clickType -> {
if (element instanceof TNTElement) { if (element instanceof TNTElement) {
new SimulatorTNTGui(player, simulator, (TNTElement) element, this).open(); new SimulatorTNTGui(player, simulator, (TNTElement) element, simulatorGroup, this).open();
} else if (element instanceof RedstoneElement) { } else if (element instanceof RedstoneElement) {
new SimulatorRedstoneGui(player, simulator, simulatorGroup, (RedstoneElement) element, this).open(); new SimulatorRedstoneGui(player, simulator, simulatorGroup, (RedstoneElement) element, this).open();
} }

Datei anzeigen

@ -34,7 +34,7 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
public class SimulatorGui extends SimulatorPageGui<SimulatorGroup> { public class SimulatorGui extends SimulatorPageGui<SimulatorGroup> {//TODO Groupcreation
public SimulatorGui(Player player, Simulator simulator) { public SimulatorGui(Player player, Simulator simulator) {
super(player, simulator, 6 * 9, simulator.getElements()); super(player, simulator, 6 * 9, simulator.getElements());
@ -47,11 +47,7 @@ public class SimulatorGui extends SimulatorPageGui<SimulatorGroup> {
@Override @Override
public void headerAndFooter() { public void headerAndFooter() {
for (Iterator<SimulatorGroup> i = simulator.getElements().iterator(); i.hasNext(); ) { simulator.getElements().removeIf(element -> element.getElements().isEmpty());
if (i.next().getElements().isEmpty()) {
i.remove();
}
}
inventory.setItem(4, new SWItem(simulator.getMaterial(), "§e" + simulator.getName(), clickType -> { inventory.setItem(4, new SWItem(simulator.getMaterial(), "§e" + simulator.getName(), clickType -> {
new SimulatorMaterialGui(player, simulator, simulator::getMaterial, simulator::setMaterial, this).open(); new SimulatorMaterialGui(player, simulator, simulator::getMaterial, simulator::setMaterial, this).open();
@ -79,7 +75,7 @@ public class SimulatorGui extends SimulatorPageGui<SimulatorGroup> {
} }
return new SWItem(element.getMaterial(), "§e" + element.getName(), lore, element.isDisabled(), clickType -> { return new SWItem(element.getMaterial(), "§e" + element.getName(), lore, element.isDisabled(), clickType -> {
if (element instanceof TNTElement) { if (element instanceof TNTElement) {
new SimulatorTNTGui(player, simulator, (TNTElement) element, this).open(); new SimulatorTNTGui(player, simulator, (TNTElement) element, simulatorGroup,this).open();
} else if (element instanceof RedstoneElement) { } else if (element instanceof RedstoneElement) {
new SimulatorRedstoneGui(player, simulator, simulatorGroup, (RedstoneElement) element, this).open(); new SimulatorRedstoneGui(player, simulator, simulatorGroup, (RedstoneElement) element, this).open();
} }

Datei anzeigen

@ -89,7 +89,9 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<RedstonePhase> {
new SimulatorRedstoneSettingsGui(player, simulator, redstone, this).open(); new SimulatorRedstoneSettingsGui(player, simulator, redstone, this).open();
})); }));
// 49 Lead? inventory.setItem(49, new SWItem(Material.LEAD, "§eMove", clickType -> {
new SimulatorGroupChooserGui(player, simulator, simulator.getElements(), redstone, simulatorGroup, this).open();
}));
//Enable/Disable //Enable/Disable
inventory.setItem(50, new SWItem(redstone.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, redstone.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> { inventory.setItem(50, new SWItem(redstone.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, redstone.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {

Datei anzeigen

@ -21,11 +21,13 @@ package de.steamwar.bausystem.features.simulator2.gui;
import de.steamwar.bausystem.features.simulator2.SimulatorWatcher; import de.steamwar.bausystem.features.simulator2.SimulatorWatcher;
import de.steamwar.bausystem.features.simulator2.data.Simulator; import de.steamwar.bausystem.features.simulator2.data.Simulator;
import de.steamwar.bausystem.features.simulator2.data.SimulatorGroup;
import de.steamwar.bausystem.features.simulator2.data.tnt.TNTElement; import de.steamwar.bausystem.features.simulator2.data.tnt.TNTElement;
import de.steamwar.bausystem.features.simulator2.data.tnt.TNTPhase; import de.steamwar.bausystem.features.simulator2.data.tnt.TNTPhase;
import de.steamwar.bausystem.features.simulator2.gui.base.SimulatorBaseGui; import de.steamwar.bausystem.features.simulator2.gui.base.SimulatorBaseGui;
import de.steamwar.bausystem.features.simulator2.gui.base.SimulatorScrollGui; import de.steamwar.bausystem.features.simulator2.gui.base.SimulatorScrollGui;
import de.steamwar.bausystem.features.simulator2.gui.utils.SimulatorMaterialGui; import de.steamwar.bausystem.features.simulator2.gui.utils.SimulatorMaterialGui;
import de.steamwar.bausystem.features.simulator2.gui.SimulatorTNTPhaseSettingsGui;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -38,9 +40,10 @@ import java.util.List;
public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> { public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
private TNTElement tnt; private TNTElement tnt;
private SimulatorGroup parent;
private SimulatorBaseGui back; private SimulatorBaseGui back;
public SimulatorTNTGui(Player player, Simulator simulator, TNTElement tnt, SimulatorBaseGui back) { public SimulatorTNTGui(Player player, Simulator simulator, TNTElement tnt, SimulatorGroup parent, SimulatorBaseGui back) {
super(player, simulator, 6 * 9, tnt.getPhases()); super(player, simulator, 6 * 9, tnt.getPhases());
this.tnt = tnt; this.tnt = tnt;
this.back = back; this.back = back;
@ -84,7 +87,9 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
inventory.setItem(48, new SWItem(Material.REPEATER, "§eSettings", clickType -> { inventory.setItem(48, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
new SimulatorTNTSettingsGui(player, simulator, tnt, this).open(); new SimulatorTNTSettingsGui(player, simulator, tnt, this).open();
})); }));
// 49 Lead? inventory.setItem(49, new SWItem(Material.LEAD, "§eMove", clickType -> {
new SimulatorGroupChooserGui(player, simulator, simulator.getElements(), tnt, parent, this).open();
}));
inventory.setItem(50, new SWItem(tnt.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, tnt.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> { inventory.setItem(50, new SWItem(tnt.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, tnt.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
tnt.setDisabled(!tnt.isDisabled()); tnt.setDisabled(!tnt.isDisabled());
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);

Datei anzeigen

@ -109,12 +109,12 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
})); }));
// X // X
inventory.setItem(12, new SWItem(Material.OAK_BUTTON, "§7Align§8: §eNegativ X", clickType -> { inventory.setItem(12, new SWItem(Material.STONE_BUTTON, "§7Align§8: §eNegativ X", clickType -> {
tnt.align(new Vector(0.49, 0, 0)); tnt.align(new Vector(0.49, 0, 0));
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
})); }));
inventory.setItem(30, new SWItem(Material.OAK_BUTTON, "§7Align§8: §ePositiv X", clickType -> { inventory.setItem(30, new SWItem(Material.STONE_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
tnt.align(new Vector(0.51, 0, 0)); tnt.align(new Vector(0.51, 0, 0));
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
})); }));