SteamWar/BauSystem2.0
Archiviert
12
0

Finalize first gui version

Dieser Commit ist enthalten in:
D4rkr34lm 2023-10-10 00:08:33 +02:00 committet von yoyosource
Ursprung 148761fa63
Commit 420cf4a5b8
4 geänderte Dateien mit 268 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -28,4 +28,16 @@ public abstract class SimulatorSetting {
protected int tickOffset; protected int tickOffset;
protected int lifetime = 80; protected int lifetime = 80;
protected int order = 1; protected int order = 1;
public void changeOffset(int tick){
tickOffset += tick;
}
public void changeLifetime(int tick){
lifetime += tick;
}
public void changeOrder(int tick){
order += tick;
}
} }

Datei anzeigen

@ -30,4 +30,15 @@ public class TNTSetting extends SimulatorSetting {
private boolean xJump = false; private boolean xJump = false;
private boolean yJump = false; private boolean yJump = false;
private boolean zJump = false; private boolean zJump = false;
public boolean hasJump(){
if(xJump || yJump || zJump) return true;
else return false;
}
public void setJump(boolean jump){
xJump = jump;
yJump = jump;
zJump = jump;
}
} }

Datei anzeigen

@ -29,6 +29,8 @@ import de.steamwar.inventory.SWItem;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Arrays;
public class SimulatorRedstonePhaseGui extends SimulatorBaseGui { public class SimulatorRedstonePhaseGui extends SimulatorBaseGui {
private final RedstoneElement redstoneElement; private final RedstoneElement redstoneElement;
@ -48,7 +50,7 @@ public class SimulatorRedstonePhaseGui extends SimulatorBaseGui {
} }
@Override @Override
public void populate() { // TODO: Finalize public void populate() {
if (!redstoneElement.getSettings().contains(redstone)) { if (!redstoneElement.getSettings().contains(redstone)) {
back.open(); back.open();
return; return;
@ -69,5 +71,65 @@ public class SimulatorRedstonePhaseGui extends SimulatorBaseGui {
back.open(); back.open();
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
})); }));
//Tick Offset
int offset = redstone.getTickOffset();
inventory.setItem(11, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
redstone.changeOffset(clickType.isShiftClick() ? 5 : 1);
SimulatorWatcher.update(simulator);
});
SWItem offsetItem = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + offset, clickType -> {});
offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64)));
inventory.setItem(20, offsetItem);
inventory.setItem(29, SWItem.getDye(offset > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
if (offset - (clickType.isShiftClick() ? 5 : 1) < 0) {
redstone.changeOffset(-offset);
} else {
redstone.changeOffset(clickType.isShiftClick() ? -5 : -1);
}
SimulatorWatcher.update(simulator);
});
//Lifetime
int lifetime = redstone.getLifetime();
inventory.setItem(12, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
redstone.changeLifetime(clickType.isShiftClick() ? 5 : 1);
SimulatorWatcher.update(simulator);
});
SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eLifetime§8:§7 " + lifetime, clickType -> {});
lifetimeItem.getItemStack().setAmount(Math.max(1, Math.min(lifetime, 64)));
inventory.setItem(21, lifetimeItem);
inventory.setItem(30, SWItem.getDye(lifetime > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
if (lifetime - (clickType.isShiftClick() ? 5 : 1) < 0) {
redstone.changeLifetime(-lifetime);
} else {
redstone.changeLifetime(clickType.isShiftClick() ? -5 : -1);
}
SimulatorWatcher.update(simulator);
});
//Order
int order = redstone.getOrder();
inventory.setItem(14, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
redstone.changeOrder(clickType.isShiftClick() ? 5 : 1);
SimulatorWatcher.update(simulator);
});
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);
inventory.setItem(32, SWItem.getDye(order > 1 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
if (order - (clickType.isShiftClick() ? 5 : 1) < 1) {
redstone.changeOrder(-order);
} else {
redstone.changeOrder(clickType.isShiftClick() ? -5 : -1);
}
SimulatorWatcher.update(simulator);
});
} }
} }

Datei anzeigen

@ -0,0 +1,182 @@
/*
* 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.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.tnt.TNTSetting;
import de.steamwar.bausystem.features.simulator2.gui.base.SimulatorBaseGui;
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.Arrays;
public class SimulatorTntPhaseGui extends SimulatorBaseGui{
private final TNTElement tntElement;
private final TNTSetting tnt;
private final SimulatorBaseGui back;
public SimulatorTntPhaseGui(Player player, Simulator simulator, TNTElement tntElement, TNTSetting tnt, SimulatorBaseGui back) {
super(player, simulator, 5 * 9);
this.tntElement = tntElement;
this.tnt = tnt;
this.back = back;
}
@Override
public String title() {
return "Tnt";
}
@Override
public void populate() {
if (!tntElement.getSettings().contains(tnt)) {
back.open();
return;
}
// Back Arrow
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
back.open();
}));
// Material Chooser
inventory.setItem(4, new SWItem(tntElement.getMaterial(), "§TNT", clickType -> {
new SimulatorMaterialGui(player, simulator, tntElement::getMaterial, tntElement::setMaterial, this).open();
}));
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
tntElement.getSettings().remove(tnt);
back.open();
SimulatorWatcher.update(simulator);
}));
//Count
int count = tnt.getCount();
inventory.setItem(10, 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 -> {});
countItem.getItemStack().setAmount(Math.max(1, Math.min(count, 64)));
inventory.setItem(19, countItem);
inventory.setItem(28, SWItem.getDye(count > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
if (count - (clickType.isShiftClick() ? 5 : 1) < 1) {
tnt.setCount(1);
} else {
tnt.setCount(count + (clickType.isShiftClick() ? -5 : -1));
}
SimulatorWatcher.update(simulator);
});
//Tick Offset
int offset = tnt.getTickOffset();
inventory.setItem(10, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
tnt.changeOffset(clickType.isShiftClick() ? 5 : 1);
SimulatorWatcher.update(simulator);
});
SWItem offsetItem = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + offset, clickType -> {});
offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64)));
inventory.setItem(19, offsetItem);
inventory.setItem(28, SWItem.getDye(offset > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
if (offset - (clickType.isShiftClick() ? 5 : 1) < 0) {
tnt.changeOffset(-offset);
} else {
tnt.changeOffset(clickType.isShiftClick() ? -5 : -1);
}
SimulatorWatcher.update(simulator);
});
//Lifetime
int lifetime = tnt.getLifetime();
inventory.setItem(11, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
tnt.changeLifetime(clickType.isShiftClick() ? 5 : 1);
SimulatorWatcher.update(simulator);
});
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);
inventory.setItem(29, SWItem.getDye(lifetime > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
if (lifetime - (clickType.isShiftClick() ? 5 : 1) < 0) {
tnt.changeLifetime(-lifetime);
} else {
tnt.changeLifetime(clickType.isShiftClick() ? -5 : -1);
}
SimulatorWatcher.update(simulator);
});
//Order
int order = tnt.getOrder();
inventory.setItem(13, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
tnt.changeOrder(clickType.isShiftClick() ? 5 : 1);
SimulatorWatcher.update(simulator);
});
SWItem orderItem = new SWItem(Material.COMPASS, "§eLifetime§8:§7 " + order, clickType -> {});
orderItem.getItemStack().setAmount(Math.max(1, Math.min(order, 64)));
inventory.setItem(22, orderItem);
inventory.setItem(31, SWItem.getDye(order > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
if (order - (clickType.isShiftClick() ? 5 : 1) < 1) {
tnt.changeOrder(-order);
} else {
tnt.changeOrder(clickType.isShiftClick() ? -5 : -1);
}
SimulatorWatcher.update(simulator);
});
//Jump
SWItem jumpX = new SWItem(tnt.isXJump() ? Material.GREEN_WOOL : Material.RED_WOOL, "§7TNT §eJump X§8: " + (tnt.isZJump() ? "§aon" : "§coff"), clickType -> {
tnt.setXJump(!tnt.isXJump());
SimulatorWatcher.update(simulator);
});
inventory.setItem(33, jumpX);
SWItem jumpY = new SWItem(tnt.isYJump() ? Material.GREEN_WOOL : Material.RED_WOOL, "§7TNT §eJump Y§8: " + (tnt.isYJump() ? "§aon" : "§coff"), clickType -> {
tnt.setYJump(!tnt.isYJump());
SimulatorWatcher.update(simulator);
});
inventory.setItem(16, jumpY);
SWItem jumpZ = new SWItem(tnt.isZJump() ? Material.GREEN_WOOL : Material.RED_WOOL, "§7TNT §eJump Z§8: " + (tnt.isZJump() ? "§aon" : "§coff"), clickType -> {
tnt.setZJump(!tnt.isZJump());
SimulatorWatcher.update(simulator);
});
inventory.setItem(35, jumpZ);
SWItem jumpAll = new SWItem(Material.TNT, "§7TNT §eJump §8: " + (tnt.hasJump() ? "§aon" : "§coff"), clickType -> {
tnt.setJump(!tnt.hasJump());
SimulatorWatcher.update(simulator);
});
//inventory.setItem();
}
}