SteamWar/BauSystem2.0
Archiviert
12
0
Dieser Commit ist enthalten in:
yoyosource 2023-10-17 15:02:48 +02:00
Ursprung 4eb3a310a7
Commit e47cf80d60
23 geänderte Dateien mit 197 neuen und 124 gelöschten Zeilen

Datei anzeigen

@ -36,7 +36,7 @@ import java.util.Map;
public class SimulatorWatcher {
private Map<Player, Pair<Simulator, Runnable>> watchers = new HashMap<>();
public void watch(Player player, Simulator simulator, Runnable watcher) {
if (simulator == null || watcher == null) {
watchers.remove(player);

Datei anzeigen

@ -46,7 +46,7 @@ public abstract class SimulatorElement<T extends SimulatorPhase> {
return this;
}
public void sort(){
public void sort() {
phases.sort(Comparator.comparingInt(SimulatorPhase::getTickOffset));
}

Datei anzeigen

@ -24,6 +24,7 @@ import lombok.Setter;
import org.bukkit.Material;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
@Getter
@ -38,6 +39,10 @@ public class SimulatorGroup {
return this;
}
public void sort() {
elements.sort(Comparator.comparingInt(SimulatorElement::getBaseTick));
}
public int getBaseTick() {
return elements.stream()
.mapToInt(SimulatorElement::getBaseTick)

Datei anzeigen

@ -25,11 +25,9 @@ import lombok.Setter;
@Getter
@Setter
public abstract class SimulatorPhase {
public static final int ORDER_LIMIT = 64;
public static final int ORDER_LIMIT = 30;
protected int tickOffset = 0;
protected int lifetime = 80;
protected int order = 1;
public SimulatorPhase(){};
}

Datei anzeigen

@ -24,6 +24,7 @@ import org.bukkit.Material;
import org.bukkit.util.Vector;
public class RedstoneElement extends SimulatorElement<RedstonePhase> {
public RedstoneElement(Vector position) {
super(Material.REDSTONE_BLOCK, position);
}

Datei anzeigen

@ -20,11 +20,17 @@
package de.steamwar.bausystem.features.simulator2.data.redstone;
import de.steamwar.bausystem.features.simulator2.data.SimulatorPhase;
import lombok.NoArgsConstructor;
import org.bukkit.Material;
@NoArgsConstructor
public class RedstonePhase extends SimulatorPhase {
public RedstonePhase(){};
public RedstonePhase(int tickOffset){
public RedstonePhase(int tickOffset) {
this.tickOffset = tickOffset;
}
{
this.lifetime = 1;
}
}

Datei anzeigen

@ -21,26 +21,27 @@ package de.steamwar.bausystem.features.simulator2.data.tnt;
import de.steamwar.bausystem.features.simulator2.data.SimulatorPhase;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
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;
public TNTPhase(int tickOffset) {
this.tickOffset = tickOffset;
}
public void setJump(boolean jump){
public boolean hasJump() {
return xJump || yJump || zJump;
}
public void setJump(boolean jump) {
xJump = jump;
yJump = jump;
zJump = jump;

Datei anzeigen

@ -58,6 +58,8 @@ public class SimulatorGroupGui extends SimulatorPageGui<SimulatorElement<?>> {
return;
}
simulatorGroup.sort();
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
back.open();
}));

Datei anzeigen

@ -78,7 +78,8 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
simulatorGroup.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
SimulatorWatcher.update(simulator);
});
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {});
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
});
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
inventory.setItem(18, baseTick);
inventory.setItem(27, SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {

Datei anzeigen

@ -47,8 +47,8 @@ public class SimulatorGui extends SimulatorPageGui<SimulatorGroup> {
@Override
public void headerAndFooter() {
for(Iterator<SimulatorGroup> i = simulator.getElements().iterator(); i.hasNext();){
if(i.next().getElements().isEmpty()){
for (Iterator<SimulatorGroup> i = simulator.getElements().iterator(); i.hasNext(); ) {
if (i.next().getElements().isEmpty()) {
i.remove();
}
}

Datei anzeigen

@ -30,6 +30,7 @@ import de.steamwar.bausystem.features.simulator2.gui.utils.SimulatorMaterialGui;
import de.steamwar.inventory.SWItem;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.ArrayList;
import java.util.Arrays;
@ -38,13 +39,13 @@ import java.util.List;
public class SimulatorRedstoneGui extends SimulatorScrollGui<RedstonePhase> {
private final SimulatorGroup simulatorGroup;
private final RedstoneElement redstoneElement;
private final RedstoneElement redstone;
private final SimulatorBaseGui back;
public SimulatorRedstoneGui(Player player, Simulator simulator, SimulatorGroup simulatorGroup, RedstoneElement redstoneElement, SimulatorBaseGui back) {
super(player, simulator, 6 * 9, redstoneElement.getPhases());
public SimulatorRedstoneGui(Player player, Simulator simulator, SimulatorGroup simulatorGroup, RedstoneElement redstone, SimulatorBaseGui back) {
super(player, simulator, 6 * 9, redstone.getPhases());
this.simulatorGroup = simulatorGroup;
this.redstoneElement = redstoneElement;
this.redstone = redstone;
this.back = back;
}
@ -55,7 +56,12 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<RedstonePhase> {
@Override
public void headerAndFooter() {
redstoneElement.sort();
if (redstone.getPhases().isEmpty()) {
back.open();
return;
}
redstone.sort();
// Back Arrow
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
@ -65,43 +71,42 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<RedstonePhase> {
// Material Chooser
List<String> lore = new ArrayList<>();
lore.add("§7Activation count§8:§e " + data.size());
lore.add("§7Tick§8:§e " + redstoneElement.getBaseTick());
lore.add("§7Tick§8:§e " + redstone.getBaseTick());
lore.add("");
lore.add("§7X§8:§e " + redstoneElement.getPosition().getX());
lore.add("§7Y§8:§e " + redstoneElement.getPosition().getY());
lore.add("§7Z§8:§e " + redstoneElement.getPosition().getZ());
if (redstoneElement.isDisabled()) {
lore.add("§7X§8:§e " + redstone.getPosition().getX());
lore.add("§7Y§8:§e " + redstone.getPosition().getY());
lore.add("§7Z§8:§e " + redstone.getPosition().getZ());
if (redstone.isDisabled()) {
lore.add("");
lore.add("§cDisabled");
}
inventory.setItem(4, new SWItem(redstoneElement.getMaterial(), "§eTNT", lore, redstoneElement.isDisabled(), clickType -> {
new SimulatorMaterialGui(player, simulator, redstoneElement::getMaterial, redstoneElement::setMaterial, this).open();
inventory.setItem(4, new SWItem(redstone.getMaterial(), "§eTNT", lore, redstone.isDisabled(), clickType -> {
new SimulatorMaterialGui(player, simulator, redstone::getMaterial, redstone::setMaterial, this).open();
}));
//Settings
inventory.setItem(48, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
new SimulatorRedstoneSettingsGui(player, simulator, redstoneElement, this).open();
new SimulatorRedstoneSettingsGui(player, simulator, redstone, this).open();
}));
// 49 Lead?
//Enable/Disable
inventory.setItem(50, new SWItem(redstoneElement.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, redstoneElement.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
redstoneElement.setDisabled(!redstoneElement.isDisabled());
inventory.setItem(50, new SWItem(redstone.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, redstone.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
redstone.setDisabled(!redstone.isDisabled());
SimulatorWatcher.update(simulator);
}));
}
@Override
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.getPhases().remove(redstoneSetting);
SWItem redstone = new SWItem(Material.REDSTONE_BLOCK, "§eRedstone§8:§7 " + redstoneSetting.getTickOffset(), Arrays.asList("§7Activation Time§8:§e " + redstoneSetting.getLifetime(), "", "§7Middle-Click§8:§e Remove"), false, clickType -> {
if (clickType == ClickType.MIDDLE) this.redstone.getPhases().remove(redstoneSetting);
SimulatorWatcher.update(simulator);
});
redstone.getItemStack().setAmount(Math.max(1, Math.min(redstoneSetting.getTickOffset(), 64)));
return new SWItem[] {
return new SWItem[]{
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
redstoneSetting.setTickOffset(redstoneSetting.getTickOffset() + (clickType.isShiftClick() ? 5 : 1));
SimulatorWatcher.update(simulator);
@ -112,23 +117,31 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<RedstonePhase> {
SimulatorWatcher.update(simulator);
}),
new SWItem(Material.ANVIL, "§eEdit Activation", clickType -> {
new SimulatorRedstonePhaseSettingsGui(player, simulator, redstoneElement, redstoneSetting, this).open();
new SimulatorRedstonePhaseSettingsGui(player, simulator, this.redstone, 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);
return new SWItem[]{
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
addNewPhase(clickType.isShiftClick());
}),
new SWItem(Material.REDSTONE_BLOCK, "§eRedstone§8:§a New Phase", clickType -> {
addNewPhase(false);
}),
new SWItem(SWItem.getDye(8), "§7", clickType -> {
}),
new SWItem(Material.REDSTONE_BLOCK, "§eRedstone§8:§a New Phase", Arrays.asList(), false, clickType -> {}),
new SWItem(SWItem.getDye(8), "", Arrays.asList(), false, clickType -> {}),
};
}
private void addNewPhase(boolean shift) {
RedstonePhase lastElement = redstone.getPhases().get(redstone.getPhases().size() - 1);
RedstonePhase newPhase = new RedstonePhase(lastElement.getTickOffset() + 1);
if (shift) newPhase.setTickOffset(newPhase.getTickOffset() + 5);
scroll++;
redstone.add(newPhase);
SimulatorWatcher.update(simulator);
}
}

Datei anzeigen

@ -80,7 +80,8 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
SimulatorWatcher.update(simulator);
});
SWItem offsetItem = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + offset, clickType -> {});
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
});
offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64)));
inventory.setItem(20, offsetItem);
@ -96,7 +97,8 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
SimulatorWatcher.update(simulator);
});
SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eLifetime§8:§7 " + lifetime, clickType -> {});
SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eActivation Time§8:§7 " + lifetime, clickType -> {
});
lifetimeItem.getItemStack().setAmount(Math.max(1, Math.min(lifetime, 64)));
inventory.setItem(21, lifetimeItem);
@ -106,13 +108,15 @@ public class SimulatorRedstonePhaseSettingsGui 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(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
SimulatorWatcher.update(simulator);
});
SWItem orderItem = new SWItem(Material.COMPASS, "§eOrder§8:§7 " + order, clickType -> {});
SWItem orderItem = new SWItem(Material.COMPASS, "§eOrder§8:§7 " + order, clickType -> {
});
orderItem.getItemStack().setAmount(Math.max(1, Math.min(order, 64)));
inventory.setItem(23, orderItem);
@ -120,5 +124,6 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
redstone.setOrder(Math.max(1, order - (clickType.isShiftClick() ? -5 : -1)));
SimulatorWatcher.update(simulator);
});
*/
}
}

Datei anzeigen

@ -77,7 +77,8 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
redstone.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
SimulatorWatcher.update(simulator);
});
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {});
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
});
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
inventory.setItem(18, baseTick);
inventory.setItem(27, SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
@ -94,7 +95,8 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
redstone.move(clickType.isShiftClick() ? 5 : 1, 0, 0);
SimulatorWatcher.update(simulator);
});
inventory.setItem(24, new SWItem(Material.PAPER, "§eX"));
inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + redstone.getPosition().getBlockX(), clickType -> {
}));
inventory.setItem(33, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
redstone.move(clickType.isShiftClick() ? -5 : -1, 0, 0);
SimulatorWatcher.update(simulator);
@ -105,7 +107,8 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
redstone.move(0, clickType.isShiftClick() ? 5 : 1, 0);
SimulatorWatcher.update(simulator);
});
inventory.setItem(25, new SWItem(Material.PAPER, "§eY"));
inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + redstone.getPosition().getBlockY(), clickType -> {
}));
inventory.setItem(34, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
redstone.move(0, clickType.isShiftClick() ? -5 : -1, 0);
SimulatorWatcher.update(simulator);
@ -116,7 +119,8 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
redstone.move(0, 0, clickType.isShiftClick() ? 5 : 1);
SimulatorWatcher.update(simulator);
});
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ"));
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7" + redstone.getPosition().getBlockZ(), clickType -> {
}));
inventory.setItem(35, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
redstone.move(0, 0, clickType.isShiftClick() ? -5 : -1);
SimulatorWatcher.update(simulator);

Datei anzeigen

@ -49,7 +49,7 @@ public class SimulatorSettingsGui extends SimulatorBaseGui {
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
back.open();
}));
// Material Chooser
inventory.setItem(4, new SWItem(simulator.getMaterial(), "§e" + simulator.getName(), clickType -> {
new SimulatorMaterialGui(player, simulator, simulator::getMaterial, simulator::setMaterial, this).open();

Datei anzeigen

@ -29,6 +29,7 @@ import de.steamwar.bausystem.features.simulator2.gui.utils.SimulatorMaterialGui;
import de.steamwar.inventory.SWItem;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.ArrayList;
import java.util.Arrays;
@ -36,12 +37,12 @@ import java.util.List;
public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
private TNTElement tntElement;
private TNTElement tnt;
private SimulatorBaseGui back;
public SimulatorTNTGui(Player player, Simulator simulator, TNTElement tntElement, SimulatorBaseGui back) {
super(player, simulator, 6 * 9, tntElement.getPhases());
this.tntElement = tntElement;
public SimulatorTNTGui(Player player, Simulator simulator, TNTElement tnt, SimulatorBaseGui back) {
super(player, simulator, 6 * 9, tnt.getPhases());
this.tnt = tnt;
this.back = back;
}
@ -52,7 +53,12 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
@Override
public void headerAndFooter() {
tntElement.sort();
if (tnt.getPhases().isEmpty()) {
back.open();
return;
}
tnt.sort();
// Back Arrow
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
@ -62,39 +68,38 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
// Material Chooser
List<String> lore = new ArrayList<>();
lore.add("§7Phase count§8:§e " + data.size());
lore.add("§7Tick§8:§e " + tntElement.getBaseTick());
lore.add("§7Tick§8:§e " + tnt.getBaseTick());
lore.add("");
lore.add("§7X§8:§e " + tntElement.getPosition().getX());
lore.add("§7Y§8:§e " + tntElement.getPosition().getY());
lore.add("§7Z§8:§e " + tntElement.getPosition().getZ());
if (tntElement.isDisabled()) {
lore.add("§7X§8:§e " + tnt.getPosition().getX());
lore.add("§7Y§8:§e " + tnt.getPosition().getY());
lore.add("§7Z§8:§e " + tnt.getPosition().getZ());
if (tnt.isDisabled()) {
lore.add("");
lore.add("§cDisabled");
}
inventory.setItem(4, new SWItem(tntElement.getMaterial(), "§eTNT", lore, tntElement.isDisabled(), clickType -> {
new SimulatorMaterialGui(player, simulator, tntElement::getMaterial, tntElement::setMaterial, this).open();
inventory.setItem(4, new SWItem(tnt.getMaterial(), "§eTNT", lore, tnt.isDisabled(), clickType -> {
new SimulatorMaterialGui(player, simulator, tnt::getMaterial, tnt::setMaterial, this).open();
}));
inventory.setItem(48, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
// new SimulatorGroupSettingsGui(player, simulator, simulatorGroup, this).open();
new SimulatorTNTSettingsGui(player, simulator, tnt, this).open();
}));
// 49 Lead?
inventory.setItem(50, new SWItem(tntElement.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, tntElement.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
tntElement.setDisabled(!tntElement.isDisabled());
inventory.setItem(50, new SWItem(tnt.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, tnt.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
tnt.setDisabled(!tnt.isDisabled());
SimulatorWatcher.update(simulator);
}));
}
@Override
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.getPhases().remove(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"), "", "§7Middle-Click§8:§e Remove"), false, clickType -> {
if (clickType == ClickType.MIDDLE) this.tnt.getPhases().remove(tntSetting);
SimulatorWatcher.update(simulator);
});
tnt.getItemStack().setAmount(Math.min(tntSetting.getCount(), 64));
return new SWItem[] {
return new SWItem[]{
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
tntSetting.setCount(tntSetting.getCount() + (clickType.isShiftClick() ? 5 : 1));
SimulatorWatcher.update(simulator);
@ -105,23 +110,31 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
SimulatorWatcher.update(simulator);
}),
new SWItem(Material.ANVIL, "§eEdit Phase", clickType -> {
new SimulatorTntPhaseSettingsGui(player, simulator, tntElement, tntSetting, this).open();
new SimulatorTNTPhaseSettingsGui(player, simulator, this.tnt, 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);
return new SWItem[]{
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
addNewPhase(clickType.isShiftClick());
}),
new SWItem(Material.TNT, "§eTNT§8:§a New Phase", clickType -> {
addNewPhase(false);
}),
new SWItem(SWItem.getDye(8), "§7", clickType -> {
}),
new SWItem(Material.TNT, "§TNT§8:§a New Phase", Arrays.asList(), false, clickType -> {}),
new SWItem(SWItem.getDye(8), "", Arrays.asList(), false, clickType -> {}),
};
}
private void addNewPhase(boolean shift) {
TNTPhase lastElement = tnt.getPhases().get(tnt.getPhases().size() - 1);
TNTPhase newPhase = new TNTPhase(lastElement.getTickOffset() + 1);
if (shift) newPhase.setCount(newPhase.getCount() + 5);
scroll++;
tnt.add(newPhase);
SimulatorWatcher.update(simulator);
}
}

Datei anzeigen

@ -32,12 +32,12 @@ import org.bukkit.entity.Player;
import java.util.Arrays;
public class SimulatorTntPhaseSettingsGui extends SimulatorBaseGui{
public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
private final TNTElement tntElement;
private final TNTPhase tnt;
private final SimulatorBaseGui back;
public SimulatorTntPhaseSettingsGui(Player player, Simulator simulator, TNTElement tntElement, TNTPhase 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;
@ -46,7 +46,7 @@ public class SimulatorTntPhaseSettingsGui extends SimulatorBaseGui{
@Override
public String title() {
return "Tnt";
return "TNT";
}
@Override
@ -75,14 +75,15 @@ public class SimulatorTntPhaseSettingsGui extends SimulatorBaseGui{
//Count
int count = tnt.getCount();
inventory.setItem(10, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
inventory.setItem(9, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
tnt.setCount(count + (clickType.isShiftClick() ? 5 : 1));
SimulatorWatcher.update(simulator);
});
SWItem countItem = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + count, clickType -> {});
SWItem countItem = new SWItem(Material.TNT, "§eCount§8:§7 " + count, clickType -> {
});
countItem.getItemStack().setAmount(Math.max(1, Math.min(count, 64)));
inventory.setItem(19, countItem);
inventory.setItem(18, countItem);
inventory.setItem(28, SWItem.getDye(count > 1 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
tnt.setCount(Math.max(1, count - (clickType.isShiftClick() ? -5 : -1)));
@ -96,7 +97,8 @@ public class SimulatorTntPhaseSettingsGui extends SimulatorBaseGui{
SimulatorWatcher.update(simulator);
});
SWItem offsetItem = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + offset, clickType -> {});
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
});
offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64)));
inventory.setItem(19, offsetItem);
@ -112,7 +114,8 @@ public class SimulatorTntPhaseSettingsGui extends SimulatorBaseGui{
SimulatorWatcher.update(simulator);
});
SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eLifetime§8:§7 " + lifetime, clickType -> {});
SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eLifetime§8:§7 " + lifetime, clickType -> {
});
lifetimeItem.getItemStack().setAmount(Math.max(1, Math.min(lifetime, 64)));
inventory.setItem(20, lifetimeItem);
@ -128,8 +131,9 @@ public class SimulatorTntPhaseSettingsGui extends SimulatorBaseGui{
SimulatorWatcher.update(simulator);
});
SWItem orderItem = new SWItem(Material.COMPASS, "§eLifetime§8:§7 " + order, clickType -> {});
orderItem.getItemStack().setAmount(Math.max(1, Math.min(order, 64)));
SWItem orderItem = new SWItem(Material.COMPASS, "§eCalculation Order§8:§7 " + order, clickType -> {
});
orderItem.getItemStack().setAmount(Math.max(1, Math.min(order, 30)));
inventory.setItem(22, orderItem);
inventory.setItem(31, SWItem.getDye(order > 1 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {

Datei anzeigen

@ -50,6 +50,11 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
@Override
public void populate() {
if (tnt.getPhases().isEmpty()) {
back.open();
return;
}
// Back Arrow
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
back.open();
@ -73,7 +78,8 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
tnt.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
SimulatorWatcher.update(simulator);
});
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {});
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
});
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
inventory.setItem(18, baseTick);
inventory.setItem(27, SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
@ -86,61 +92,64 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
});
// Subpixel Alignment
inventory.setItem(24, new SWItem(Material.SUNFLOWER, "§7Align§8: §eCenter", clickType -> {
inventory.setItem(21, new SWItem(Material.SUNFLOWER, "§7Align§8: §eCenter", clickType -> {
tnt.align(new Vector(0.5, 0, 0.5));
SimulatorWatcher.update(simulator);
}));
//z
inventory.setItem(23, new SWItem(Material.OAK_BUTTON, "§7Align§8: §eNegativ Z", clickType -> {
// Z
inventory.setItem(20, new SWItem(Material.OAK_BUTTON, "§7Align§8: §eNegativ Z", clickType -> {
tnt.align(new Vector(0, 0, 0.49));
SimulatorWatcher.update(simulator);
}));
inventory.setItem(25, new SWItem(Material.OAK_BUTTON, "§7Align§8: §ePositiv Z", clickType -> {
inventory.setItem(22, new SWItem(Material.OAK_BUTTON, "§7Align§8: §ePositiv Z", clickType -> {
tnt.align(new Vector(0, 0, 0.51));
SimulatorWatcher.update(simulator);
}));
//X
inventory.setItem(15, new SWItem(Material.OAK_BUTTON, "§7Align§8: §eNegativ X", clickType -> {
// X
inventory.setItem(12, new SWItem(Material.OAK_BUTTON, "§7Align§8: §eNegativ X", clickType -> {
tnt.align(new Vector(0.49, 0, 0));
SimulatorWatcher.update(simulator);
}));
inventory.setItem(33, new SWItem(Material.OAK_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
inventory.setItem(30, new SWItem(Material.OAK_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
tnt.align(new Vector(0.51, 0, 0));
SimulatorWatcher.update(simulator);
}));
//Pos X
// Pos X
inventory.setItem(15, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
tnt.move(clickType.isShiftClick() ? 0.0625 : 1, 0, 0);
SimulatorWatcher.update(simulator);
});
inventory.setItem(24, new SWItem(Material.PAPER, "§eX"));
inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + tnt.getPosition().getX(), clickType -> {
}));
inventory.setItem(33, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
tnt.move(clickType.isShiftClick() ? -0.0625 : -1, 0, 0);
SimulatorWatcher.update(simulator);
});
//Pos Y
// Pos Y
inventory.setItem(16, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
tnt.move(0, clickType.isShiftClick() ? 0.0625 : 1, 0);
SimulatorWatcher.update(simulator);
});
inventory.setItem(25, new SWItem(Material.PAPER, "§eY"));
inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + tnt.getPosition().getY(), clickType -> {
}));
inventory.setItem(34, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
tnt.move(0, clickType.isShiftClick() ? -0.0625 : -1, 0);
SimulatorWatcher.update(simulator);
});
//Pos Z
// Pos Z
inventory.setItem(17, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
tnt.move(0, 0, clickType.isShiftClick() ? 0.0625 : 1);
SimulatorWatcher.update(simulator);
});
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ"));
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7 " + tnt.getPosition().getZ(), clickType -> {
}));
inventory.setItem(35, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
tnt.move(0, 0, clickType.isShiftClick() ? -0.0625 : -1);
SimulatorWatcher.update(simulator);

Datei anzeigen

@ -21,6 +21,7 @@ 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.core.Core;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import org.bukkit.Bukkit;
@ -44,7 +45,9 @@ public abstract class SimulatorBaseGui {
}
public final void open() {
if (inv != null) {
if (inv != null && Core.getVersion() > 19) {
inv.clear();
setup();
if (player.getOpenInventory().getTopInventory() != inv) {
inventory.open();
SimulatorWatcher.watch(player, simulator, this::open);
@ -60,10 +63,7 @@ public abstract class SimulatorBaseGui {
inv = Bukkit.createInventory(null, size, title());
return inv;
});
for (int i = 0; i < 9; i++) {
inventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§8", clickType -> {}));
inventory.setItem(size - 9 + i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§8", clickType -> {}));
}
setup();
inventory.addCloseCallback(clickType -> {
SimulatorWatcher.watch(player, null, null);
});
@ -72,7 +72,16 @@ public abstract class SimulatorBaseGui {
SimulatorWatcher.watch(player, simulator, this::open);
populate();
}
private void setup() {
for (int i = 0; i < 9; i++) {
inventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§8", clickType -> {
}));
inventory.setItem(size - 9 + i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§8", clickType -> {
}));
}
}
public abstract String title();
public abstract void populate();

Datei anzeigen

@ -69,7 +69,7 @@ public abstract class SimulatorPageGui<T> extends SimulatorBaseGui {
int index = 9;
for (int i = minElement; i < maxElement; i++) {
T element = data.get(i);
T element = data.get(i);
inventory.setItem(index++, convert(element));
}
}
@ -78,5 +78,6 @@ public abstract class SimulatorPageGui<T> extends SimulatorBaseGui {
public void headerAndFooter() {
}
public abstract SWItem convert(T t);
}

Datei anzeigen

@ -42,7 +42,7 @@ public abstract class SimulatorScrollGui<T> extends SimulatorBaseGui {
@Override
public final String title() {
return baseTitle() + " " + scroll + "/" + maxScroll();
return baseTitle() + " " + maxScroll() + "/" + Math.max((data.size() - 9 + 1), 0);
}
@Override
@ -56,21 +56,20 @@ public abstract class SimulatorScrollGui<T> extends SimulatorBaseGui {
open();
}
});
boolean hasNext = scroll < maxScroll() - (data.size() % 9 == 0 ? 1 : 0);
boolean hasNext = (data.size() + 1) - scroll > 9;
inventory.setItem(size - 1, SWItem.getDye(hasNext ? 10 : 8), hasNext ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(hasNext ? "SWLISINV_NEXT_PAGE_ACTIVE" : "SWLISINV_NEXT_PAGE_INACTIVE", player), clickType -> {
if (hasNext) {
scroll = Math.min(scroll + 9, maxScroll());
scroll = Math.min(scroll + 9, data.size() + 1 - 9);
open();
}
});
for (int i = 0; i < 9; i++) {
if(i < data.size()){
if (scroll + i < data.size()) {
T element = data.get(scroll + i);
SWItem[] column = column(element);
populateColumn(column, i);
}
else {
} else {
SWItem[] column = lastColumn();
populateColumn(column, i);
break;
@ -83,11 +82,12 @@ public abstract class SimulatorScrollGui<T> extends SimulatorBaseGui {
public void headerAndFooter() {
}
public void populateColumn(SWItem[] column, int index){
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();

Datei anzeigen

@ -61,7 +61,8 @@ public class SimulatorMaterialGui extends SimulatorPageGui<Material> {
@Override
public void headerAndFooter() {
material = currentMaterial.get();
inventory.setItem(4, new SWItem(material, "§eMaterial", clickType -> {}));
inventory.setItem(4, new SWItem(material, "§eMaterial", clickType -> {
}));
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
back.open();
}));