SimRework2.0 #216
@ -22,9 +22,9 @@ package de.steamwar.bausystem.features.simulator2;
|
||||
import de.steamwar.bausystem.features.simulator2.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator2.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.simulator2.data.redstone.RedstoneElement;
|
||||
import de.steamwar.bausystem.features.simulator2.data.redstone.RedstoneSetting;
|
||||
import de.steamwar.bausystem.features.simulator2.data.redstone.RedstonePhase;
|
||||
import de.steamwar.bausystem.features.simulator2.data.tnt.TNTElement;
|
||||
import de.steamwar.bausystem.features.simulator2.data.tnt.TNTSetting;
|
||||
import de.steamwar.bausystem.features.simulator2.data.tnt.TNTPhase;
|
||||
import de.steamwar.bausystem.features.simulator2.gui.SimulatorGui;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
@ -39,13 +39,13 @@ public class SimulatorTestCommand extends SWCommand {
|
||||
public SimulatorTestCommand() {
|
||||
super("simtest");
|
||||
|
||||
SimulatorGroup group1 = new SimulatorGroup().add(new TNTElement(new Vector(0, 0, 0)).add(new TNTSetting())).add(new TNTElement(new Vector(0, 0, 0)).add(new TNTSetting()));
|
||||
SimulatorGroup group1 = new SimulatorGroup().add(new TNTElement(new Vector(0, 0, 0)).add(new TNTPhase())).add(new TNTElement(new Vector(0, 0, 0)).add(new TNTPhase()));
|
||||
SIMULATOR.getElements().add(group1);
|
||||
|
||||
SimulatorGroup group2 = new SimulatorGroup().add(new TNTElement(new Vector(0, 0, 0)).add(new TNTSetting()));
|
||||
SimulatorGroup group2 = new SimulatorGroup().add(new TNTElement(new Vector(0, 0, 0)).add(new TNTPhase()));
|
||||
SIMULATOR.getElements().add(group2);
|
||||
|
||||
SimulatorGroup group3 = new SimulatorGroup().add(new RedstoneElement(new Vector(0, 0, 0)).add(new RedstoneSetting()));
|
||||
SimulatorGroup group3 = new SimulatorGroup().add(new RedstoneElement(new Vector(0, 0, 0)).add(new RedstonePhase()));
|
||||
SIMULATOR.getElements().add(group3);
|
||||
}
|
||||
|
||||
|
@ -29,11 +29,11 @@ import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public abstract class SimulatorElement<T extends SimulatorSetting> {
|
||||
public abstract class SimulatorElement<T extends SimulatorPhase> {
|
||||
protected Material material;
|
||||
protected final Vector position;
|
||||
protected boolean disabled = false;
|
||||
protected final List<T> settings = new ArrayList<>();
|
||||
protected final List<T> phases = new ArrayList<>();
|
||||
|
||||
protected SimulatorElement(Material material, Vector position) {
|
||||
this.material = material;
|
||||
@ -41,21 +41,21 @@ public abstract class SimulatorElement<T extends SimulatorSetting> {
|
||||
}
|
||||
|
||||
public SimulatorElement<T> add(T setting) {
|
||||
settings.add(setting);
|
||||
phases.add(setting);
|
||||
return this;
|
||||
}
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public int getBaseTick() {
|
||||
return settings.stream()
|
||||
return phases.stream()
|
||||
.mapToInt(value -> value.tickOffset)
|
||||
.min()
|
||||
.orElse(0);
|
||||
}
|
||||
|
||||
public void changeBaseTicks(int tick) {
|
||||
settings.forEach(t -> {
|
||||
phases.forEach(t -> {
|
||||
t.tickOffset += tick;
|
||||
});
|
||||
}
|
||||
|
@ -24,9 +24,12 @@ import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public abstract class SimulatorSetting {
|
||||
public abstract class SimulatorPhase {
|
||||
public static final int ORDER_LIMIT = 64;
|
||||
protected int tickOffset;
|
||||
|
||||
protected int tickOffset = 0;
|
||||
protected int lifetime = 80;
|
||||
protected int order = 1;
|
||||
|
||||
public SimulatorPhase(){};
|
||||
}
|
@ -23,8 +23,7 @@ import de.steamwar.bausystem.features.simulator2.data.SimulatorElement;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class RedstoneElement extends SimulatorElement<RedstoneSetting> {
|
||||
|
||||
public class RedstoneElement extends SimulatorElement<RedstonePhase> {
|
||||
public RedstoneElement(Vector position) {
|
||||
super(Material.REDSTONE_BLOCK, position);
|
||||
}
|
||||
|
@ -19,7 +19,12 @@
|
||||
|
||||
package de.steamwar.bausystem.features.simulator2.data.redstone;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator2.data.SimulatorSetting;
|
||||
import de.steamwar.bausystem.features.simulator2.data.SimulatorPhase;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class RedstoneSetting extends SimulatorSetting {
|
||||
public class RedstonePhase extends SimulatorPhase {
|
||||
public RedstonePhase(){};
|
||||
public RedstonePhase(int tickOffset){
|
||||
this.tickOffset = tickOffset;
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@ import de.steamwar.bausystem.features.simulator2.data.SimulatorElement;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class TNTElement extends SimulatorElement<TNTSetting> {
|
||||
public class TNTElement extends SimulatorElement<TNTPhase> {
|
||||
|
||||
public TNTElement(Vector position) {
|
||||
super(Material.TNT, position);
|
||||
|
@ -19,18 +19,22 @@
|
||||
|
||||
package de.steamwar.bausystem.features.simulator2.data.tnt;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator2.data.SimulatorSetting;
|
||||
import de.steamwar.bausystem.features.simulator2.data.SimulatorPhase;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class TNTSetting extends SimulatorSetting {
|
||||
public class TNTPhase extends SimulatorPhase {
|
||||
private int count = 1;
|
||||
private boolean xJump = false;
|
||||
private boolean yJump = false;
|
||||
private boolean zJump = false;
|
||||
|
||||
public TNTPhase(){}
|
||||
|
||||
public TNTPhase(int tickOffset){this.tickOffset = tickOffset;}
|
||||
|
||||
public boolean hasJump(){
|
||||
if(xJump || yJump || zJump) return true;
|
||||
else return false;
|
@ -85,7 +85,7 @@ public class SimulatorGroupGui extends SimulatorPageGui<SimulatorElement<?>> {
|
||||
@Override
|
||||
public SWItem convert(SimulatorElement<?> element) {
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("§7Phase count§8:§e " + element.getSettings().size());
|
||||
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());
|
||||
|
@ -67,7 +67,7 @@ public class SimulatorGui extends SimulatorPageGui<SimulatorGroup> {
|
||||
if (elements.size() == 1) {
|
||||
SimulatorElement<?> element = elements.get(0);
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("§7Phase count§8:§e " + element.getSettings().size());
|
||||
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());
|
||||
|
@ -23,8 +23,7 @@ import de.steamwar.bausystem.features.simulator2.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator2.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator2.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.simulator2.data.redstone.RedstoneElement;
|
||||
import de.steamwar.bausystem.features.simulator2.data.redstone.RedstoneSetting;
|
||||
import de.steamwar.bausystem.features.simulator2.data.tnt.TNTElement;
|
||||
import de.steamwar.bausystem.features.simulator2.data.redstone.RedstonePhase;
|
||||
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.utils.SimulatorMaterialGui;
|
||||
@ -36,14 +35,14 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class SimulatorRedstoneGui extends SimulatorScrollGui<RedstoneSetting> {
|
||||
public class SimulatorRedstoneGui extends SimulatorScrollGui<RedstonePhase> {
|
||||
|
||||
private final SimulatorGroup simulatorGroup;
|
||||
private final RedstoneElement redstoneElement;
|
||||
private final SimulatorBaseGui back;
|
||||
|
||||
public SimulatorRedstoneGui(Player player, Simulator simulator, SimulatorGroup simulatorGroup, RedstoneElement redstoneElement, SimulatorBaseGui back) {
|
||||
super(player, simulator, 6 * 9, redstoneElement.getSettings());
|
||||
super(player, simulator, 6 * 9, redstoneElement.getPhases());
|
||||
this.simulatorGroup = simulatorGroup;
|
||||
this.redstoneElement = redstoneElement;
|
||||
this.back = back;
|
||||
@ -56,12 +55,6 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<RedstoneSetting> {
|
||||
|
||||
@Override
|
||||
public void headerAndFooter() {
|
||||
if (redstoneElement.getSettings().isEmpty()) {
|
||||
simulatorGroup.getElements().remove(redstoneElement);
|
||||
back.open();
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO Sort Data List
|
||||
|
||||
// Back Arrow
|
||||
@ -100,10 +93,10 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<RedstoneSetting> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWItem[] column(RedstoneSetting redstoneSetting) {
|
||||
public SWItem[] column(RedstonePhase redstoneSetting) {
|
||||
SWItem redstone = new SWItem(Material.REDSTONE_BLOCK, "§eRedstone§8:§7 " + redstoneSetting.getTickOffset(), Arrays.asList("§7Fuse§8:§e " + redstoneSetting.getLifetime(), "", "§7Order§8:§e " + redstoneSetting.getOrder()), false, clickType -> {
|
||||
//Quick remove per rightclick
|
||||
if (clickType.isRightClick()) redstoneElement.getSettings().remove(redstoneSetting);
|
||||
if (clickType.isRightClick()) redstoneElement.getPhases().remove(redstoneSetting);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
redstone.getItemStack().setAmount(Math.max(1, Math.min(redstoneSetting.getTickOffset(), 64)));
|
||||
@ -119,8 +112,23 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<RedstoneSetting> {
|
||||
SimulatorWatcher.update(simulator);
|
||||
}),
|
||||
new SWItem(Material.ANVIL, "§eEdit Activation", clickType -> {
|
||||
new SimulatorRedstonePhaseGui(player, simulator, redstoneElement, redstoneSetting, this).open();
|
||||
new SimulatorRedstonePhaseSettingsGui(player, simulator, redstoneElement, redstoneSetting, this).open();
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWItem[] lastColumn() {
|
||||
return new SWItem[] {
|
||||
new SWItem(SWItem.getDye(10), "§aNew Phase", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
RedstonePhase lastElement = redstoneElement.getPhases().get(redstoneElement.getPhases().size() - 1);
|
||||
RedstonePhase newPhase = new RedstonePhase(lastElement.getTickOffset() + 1);
|
||||
if(clickType.isShiftClick()) newPhase.setTickOffset(newPhase.getTickOffset() + 4);
|
||||
redstoneElement.add(newPhase);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}),
|
||||
new SWItem(Material.REDSTONE_BLOCK, "§eRedstone§8:§a New Phase", Arrays.asList(), false, clickType -> {}),
|
||||
new SWItem(SWItem.getDye(8), "", Arrays.asList(), false, clickType -> {}),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -21,9 +21,9 @@ 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.SimulatorSetting;
|
||||
import de.steamwar.bausystem.features.simulator2.data.SimulatorPhase;
|
||||
import de.steamwar.bausystem.features.simulator2.data.redstone.RedstoneElement;
|
||||
import de.steamwar.bausystem.features.simulator2.data.redstone.RedstoneSetting;
|
||||
import de.steamwar.bausystem.features.simulator2.data.redstone.RedstonePhase;
|
||||
import de.steamwar.bausystem.features.simulator2.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.bausystem.features.simulator2.gui.utils.SimulatorMaterialGui;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
@ -32,12 +32,12 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class SimulatorRedstonePhaseGui extends SimulatorBaseGui {
|
||||
public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
||||
private final RedstoneElement redstoneElement;
|
||||
private final RedstoneSetting redstone;
|
||||
private final RedstonePhase redstone;
|
||||
private final SimulatorBaseGui back;
|
||||
|
||||
public SimulatorRedstonePhaseGui(Player player, Simulator simulator, RedstoneElement redstoneElement, RedstoneSetting redstone, SimulatorBaseGui back) {
|
||||
public SimulatorRedstonePhaseSettingsGui(Player player, Simulator simulator, RedstoneElement redstoneElement, RedstonePhase redstone, SimulatorBaseGui back) {
|
||||
super(player, simulator, 5 * 9);
|
||||
this.redstoneElement = redstoneElement;
|
||||
this.redstone = redstone;
|
||||
@ -51,7 +51,7 @@ public class SimulatorRedstonePhaseGui extends SimulatorBaseGui {
|
||||
|
||||
@Override
|
||||
public void populate() {
|
||||
if (!redstoneElement.getSettings().contains(redstone)) {
|
||||
if (!redstoneElement.getPhases().contains(redstone)) {
|
||||
back.open();
|
||||
return;
|
||||
}
|
||||
@ -68,7 +68,7 @@ public class SimulatorRedstonePhaseGui extends SimulatorBaseGui {
|
||||
|
||||
// Delete
|
||||
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
||||
redstoneElement.getSettings().remove(redstone);
|
||||
redstoneElement.getPhases().remove(redstone);
|
||||
back.open();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
@ -108,7 +108,7 @@ public class SimulatorRedstonePhaseGui extends SimulatorBaseGui {
|
||||
//Order
|
||||
int order = redstone.getOrder();
|
||||
inventory.setItem(14, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.setOrder(Math.min(SimulatorSetting.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
|
||||
redstone.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
|
@ -49,7 +49,7 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
@Override
|
||||
public void populate() {
|
||||
if (redstone.getSettings().isEmpty()) {
|
||||
if (redstone.getPhases().isEmpty()) {
|
||||
back.open();
|
||||
return;
|
||||
}
|
||||
@ -61,7 +61,7 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
// Material Chooser
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("§7Activation count§8:§e " + redstone.getSettings().size());
|
||||
lore.add("§7Activation count§8:§e " + redstone.getPhases().size());
|
||||
lore.add("§7Tick§8:§e " + redstone.getBaseTick());
|
||||
if (redstone.isDisabled()) {
|
||||
lore.add("");
|
||||
|
@ -21,8 +21,9 @@ 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.redstone.RedstonePhase;
|
||||
import de.steamwar.bausystem.features.simulator2.data.tnt.TNTElement;
|
||||
import de.steamwar.bausystem.features.simulator2.data.tnt.TNTSetting;
|
||||
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.SimulatorScrollGui;
|
||||
import de.steamwar.bausystem.features.simulator2.gui.utils.SimulatorMaterialGui;
|
||||
@ -34,13 +35,13 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class SimulatorTNTGui extends SimulatorScrollGui<TNTSetting> {
|
||||
public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
|
||||
|
||||
private TNTElement tntElement;
|
||||
private SimulatorBaseGui back;
|
||||
|
||||
public SimulatorTNTGui(Player player, Simulator simulator, TNTElement tntElement, SimulatorBaseGui back) {
|
||||
super(player, simulator, 6 * 9, tntElement.getSettings());
|
||||
super(player, simulator, 6 * 9, tntElement.getPhases());
|
||||
this.tntElement = tntElement;
|
||||
this.back = back;
|
||||
}
|
||||
@ -88,10 +89,10 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTSetting> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWItem[] column(TNTSetting tntSetting) {
|
||||
public SWItem[] column(TNTPhase tntSetting) {
|
||||
SWItem tnt = new SWItem(Material.TNT, "§eTNT§8:§7 " + tntSetting.getCount(), Arrays.asList("§7Tick§8: §e" + tntSetting.getTickOffset(), "§7Fuse§8:§e " + tntSetting.getLifetime(), "", "§7Order§8:§e " + tntSetting.getOrder(), "", "§7X-Jump§8: " + (tntSetting.isXJump() ? "§aOn" : "§cOff"), "§7Y-Jump§8: " + (tntSetting.isYJump() ? "§aOn" : "§cOff"), "§7Z-Jump§8: " + (tntSetting.isZJump() ? "§aOn" : "§cOff")), false, clickType -> {
|
||||
//Quick remove per rightclick
|
||||
if (clickType.isRightClick()) tntElement.getSettings().remove(tntSetting);
|
||||
if (clickType.isRightClick()) tntElement.getPhases().remove(tntSetting);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
tnt.getItemStack().setAmount(Math.min(tntSetting.getCount(), 64));
|
||||
@ -107,8 +108,23 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTSetting> {
|
||||
SimulatorWatcher.update(simulator);
|
||||
}),
|
||||
new SWItem(Material.ANVIL, "§eEdit Phase", clickType -> {
|
||||
new SimulatorTntPhaseGui(player, simulator, tntElement, tntSetting, this).open();
|
||||
new SimulatorTntPhaseSettingsGui(player, simulator, tntElement, tntSetting, this).open();
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWItem[] lastColumn() {
|
||||
return new SWItem[] {
|
||||
new SWItem(SWItem.getDye(10), "§aNew Phase", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
TNTPhase lastElement = tntElement.getPhases().get(tntElement.getPhases().size() - 1);
|
||||
TNTPhase newPhase = new TNTPhase(lastElement.getTickOffset() + 1);
|
||||
if(clickType.isShiftClick()) newPhase.setCount(newPhase.getCount() + 4);
|
||||
tntElement.add(newPhase);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}),
|
||||
new SWItem(Material.TNT, "§TNT§8:§a New Phase", Arrays.asList(), false, clickType -> {}),
|
||||
new SWItem(SWItem.getDye(8), "", Arrays.asList(), false, clickType -> {}),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
// Material Chooser
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("§7Phase count§8:§e " + tnt.getSettings().size());
|
||||
lore.add("§7Phase count§8:§e " + tnt.getPhases().size());
|
||||
lore.add("§7Tick§8:§e " + tnt.getBaseTick());
|
||||
if (tnt.isDisabled()) {
|
||||
lore.add("");
|
||||
|
@ -21,11 +21,9 @@ 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.SimulatorSetting;
|
||||
import de.steamwar.bausystem.features.simulator2.data.redstone.RedstoneElement;
|
||||
import de.steamwar.bausystem.features.simulator2.data.redstone.RedstoneSetting;
|
||||
import de.steamwar.bausystem.features.simulator2.data.SimulatorPhase;
|
||||
import de.steamwar.bausystem.features.simulator2.data.tnt.TNTElement;
|
||||
import de.steamwar.bausystem.features.simulator2.data.tnt.TNTSetting;
|
||||
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.utils.SimulatorMaterialGui;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
@ -34,12 +32,12 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class SimulatorTntPhaseGui extends SimulatorBaseGui{
|
||||
public class SimulatorTntPhaseSettingsGui extends SimulatorBaseGui{
|
||||
private final TNTElement tntElement;
|
||||
private final TNTSetting tnt;
|
||||
private final TNTPhase tnt;
|
||||
private final SimulatorBaseGui back;
|
||||
|
||||
public SimulatorTntPhaseGui(Player player, Simulator simulator, TNTElement tntElement, TNTSetting tnt, SimulatorBaseGui back) {
|
||||
public SimulatorTntPhaseSettingsGui(Player player, Simulator simulator, TNTElement tntElement, TNTPhase tnt, SimulatorBaseGui back) {
|
||||
super(player, simulator, 5 * 9);
|
||||
this.tntElement = tntElement;
|
||||
this.tnt = tnt;
|
||||
@ -53,7 +51,7 @@ public class SimulatorTntPhaseGui extends SimulatorBaseGui{
|
||||
|
||||
@Override
|
||||
public void populate() {
|
||||
if (!tntElement.getSettings().contains(tnt)) {
|
||||
if (!tntElement.getPhases().contains(tnt)) {
|
||||
back.open();
|
||||
return;
|
||||
}
|
||||
@ -70,7 +68,7 @@ public class SimulatorTntPhaseGui extends SimulatorBaseGui{
|
||||
|
||||
//Delete
|
||||
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
||||
tntElement.getSettings().remove(tnt);
|
||||
tntElement.getPhases().remove(tnt);
|
||||
back.open();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
@ -125,8 +123,8 @@ public class SimulatorTntPhaseGui extends SimulatorBaseGui{
|
||||
|
||||
//Order
|
||||
int order = tnt.getOrder();
|
||||
inventory.setItem(13, SWItem.getDye(order < SimulatorSetting.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
tnt.setOrder(Math.min(SimulatorSetting.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
|
||||
inventory.setItem(13, SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
tnt.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
|
@ -19,11 +19,15 @@
|
||||
|
||||
package de.steamwar.bausystem.features.simulator2.gui.base;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator2.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator2.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator2.data.redstone.RedstonePhase;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class SimulatorScrollGui<T> extends SimulatorBaseGui { // TODO: Last Column?
|
||||
@ -36,7 +40,7 @@ public abstract class SimulatorScrollGui<T> extends SimulatorBaseGui { // TODO:
|
||||
}
|
||||
|
||||
private int maxScroll() {
|
||||
return Math.max(0, Math.min(scroll, data.size() - 9));
|
||||
return Math.max(0, Math.min(scroll, data.size() - 9 + 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -63,11 +67,16 @@ public abstract class SimulatorScrollGui<T> extends SimulatorBaseGui { // TODO:
|
||||
}
|
||||
});
|
||||
|
||||
for (int i = 0; i < Math.min(9, data.size()); i++) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if(i < data.size()){
|
||||
T element = data.get(scroll + i);
|
||||
SWItem[] column = column(element);
|
||||
for (int j = 0; j < column.length; j++) {
|
||||
inventory.setItem(i + j * 9 + 9, column[j]);
|
||||
populateColumn(column, i);
|
||||
}
|
||||
else {
|
||||
SWItem[] column = lastColumn();
|
||||
populateColumn(column, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -76,5 +85,13 @@ public abstract class SimulatorScrollGui<T> extends SimulatorBaseGui { // TODO:
|
||||
|
||||
public void headerAndFooter() {
|
||||
}
|
||||
|
||||
public void populateColumn(SWItem[] column, int index){
|
||||
for (int j = 0; j < column.length; j++) {
|
||||
inventory.setItem(index + j * 9 + 9, column[j]);
|
||||
}
|
||||
}
|
||||
public abstract SWItem[] column(T t);
|
||||
|
||||
public abstract SWItem[] lastColumn();
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren