SteamWar/BauSystem2.0
Archiviert
12
0

Update recalculate
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-07-21 14:01:07 +02:00
Ursprung 935be23238
Commit 8e28422b8f
6 geänderte Dateien mit 154 neuen und 38 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,30 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.simulator;
import de.steamwar.bausystem.features.tracer.show.Record;
public class SimulatorPreview15 implements SimulatorPreview {
@Override
public Record simulate(TNTSimulator tntSimulator) {
return new Record(false);
}
}

Datei anzeigen

@ -23,6 +23,7 @@ import de.steamwar.bausystem.features.tracer.TNTPosition;
import de.steamwar.bausystem.features.tracer.show.Record; import de.steamwar.bausystem.features.tracer.show.Record;
import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; import de.steamwar.bausystem.features.tracer.show.ShowModeParameter;
import de.steamwar.bausystem.features.tracer.show.mode.TraceEntityShowMode; import de.steamwar.bausystem.features.tracer.show.mode.TraceEntityShowMode;
import de.steamwar.bausystem.shared.Pair;
import de.steamwar.bausystem.shared.ShowMode; import de.steamwar.bausystem.shared.ShowMode;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -30,42 +31,64 @@ import org.bukkit.entity.Player;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set;
@UtilityClass @UtilityClass
public class SimulatorPreviewStorage { public class SimulatorPreviewStorage {
private Map<TNTSimulator, Record> previews = new HashMap<>(); private Map<TNTSimulator, Pair<Record, Set<Player>>> previews = new HashMap<>();
private Map<Player, ShowMode<TNTPosition>> showModes = new HashMap<>(); private Map<Player, Pair<TNTSimulator, ShowMode<TNTPosition>>> showModes = new HashMap<>();
public void show(Player player, TNTSimulator tntSimulator) { public void show(Player player, TNTSimulator tntSimulator) {
hide(player); if (showModes.containsKey(player)) {
Pair<TNTSimulator, ShowMode<TNTPosition>> pair = showModes.get(player);
if (pair.getKey() != tntSimulator) {
pair.getValue().hide();
Pair<Record, Set<Player>> setPair = previews.get(pair.getKey());
setPair.getValue().remove(player);
if (setPair.getValue().isEmpty()) {
previews.remove(pair.getKey());
}
} else {
return;
}
}
Pair<Record, Set<Player>> pair = previews.computeIfAbsent(tntSimulator, k -> new Pair<>(SimulatorPreview.impl.simulate(k), new HashSet<>()));
pair.getValue().add(player);
Record record = previews.computeIfAbsent(tntSimulator, SimulatorPreview.impl::simulate);
ShowModeParameter showModeParameter = new ShowModeParameter(); ShowModeParameter showModeParameter = new ShowModeParameter();
showModeParameter.setInterpolate_XZ(true); showModeParameter.setInterpolate_XZ(true);
showModeParameter.setInterpolate_Y(true); showModeParameter.setInterpolate_Y(true);
TraceEntityShowMode showMode = new TraceEntityShowMode(player, showModeParameter); TraceEntityShowMode showMode = new TraceEntityShowMode(player, showModeParameter);
record.showAll(showMode); pair.getKey().showAll(showMode);
showModes.put(player, showMode); showModes.put(player, new Pair<>(tntSimulator, showMode));
} }
public void hide(Player player) { public void hide(Player player) {
if (showModes.containsKey(player)) { if (showModes.containsKey(player)) {
showModes.get(player).hide(); Pair<TNTSimulator, ShowMode<TNTPosition>> pair = showModes.get(player);
pair.getValue().hide();
Pair<Record, Set<Player>> setPair = previews.get(pair.getKey());
setPair.getValue().remove(player);
if (setPair.getValue().isEmpty()) {
previews.remove(pair.getKey());
}
showModes.remove(player); showModes.remove(player);
} }
} }
public void recalculate(TNTSimulator tntSimulator) { public void recalculate(TNTSimulator tntSimulator) {
previews.remove(tntSimulator); Pair<Record, Set<Player>> pair = previews.get(tntSimulator);
new HashSet<>(showModes.keySet()).forEach(player -> { if (previews == null) return;
TNTSimulator simulator = SimulatorStorage.getSimulator(player.getInventory().getItemInOffHand()); pair.setKey(SimulatorPreview.impl.simulate(tntSimulator));
if (simulator == tntSimulator) { pair.getValue().forEach(player -> {
show(player, simulator); Pair<TNTSimulator, ShowMode<TNTPosition>> setPair = showModes.get(player);
} setPair.getValue().hide();
pair.getKey().showAll(setPair.getValue());
}); });
} }
public void recalculateAll() { public void recalculateAll() {
new HashSet<>(previews.keySet()).forEach(SimulatorPreviewStorage::recalculate); previews.keySet().forEach(SimulatorPreviewStorage::recalculate);
} }
} }

Datei anzeigen

@ -41,6 +41,7 @@ import org.bukkit.util.Vector;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
@UtilityClass @UtilityClass
public class TNTElementGUI { public class TNTElementGUI {
@ -62,6 +63,7 @@ public class TNTElementGUI {
} }
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player); TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
AtomicBoolean recalculate = new AtomicBoolean(false);
Runnable editObserver = () -> { Runnable editObserver = () -> {
List<String> locationLore = new ArrayList<>(); List<String> locationLore = new ArrayList<>();
locationLore.add(""); locationLore.add("");
@ -70,6 +72,7 @@ public class TNTElementGUI {
locationLore.add(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Z", player, tntElement.getPosition().getZ())); locationLore.add(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Z", player, tntElement.getPosition().getZ()));
inv.setItem(20, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_LOCATION", player), locationLore, false, clickType -> { inv.setItem(20, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_LOCATION", player), locationLore, false, clickType -> {
editLocation(player, tntElement, () -> open(player, tntElement, back)); editLocation(player, tntElement, () -> open(player, tntElement, back));
recalculate.set(true);
})); }));
List<String> propertiesLore = new ArrayList<>(); List<String> propertiesLore = new ArrayList<>();
@ -83,6 +86,7 @@ public class TNTElementGUI {
propertiesLore.add(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_Z", player, active(player, tntElement.isZVelocity()))); propertiesLore.add(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_Z", player, active(player, tntElement.isZVelocity())));
inv.setItem(22, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_PROPERTIES", player), propertiesLore, false, clickType -> { inv.setItem(22, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_PROPERTIES", player), propertiesLore, false, clickType -> {
editProperties(player, tntElement, () -> open(player, tntElement, back)); editProperties(player, tntElement, () -> open(player, tntElement, back));
recalculate.set(true);
})); }));
List<String> otherLore = new ArrayList<>(); List<String> otherLore = new ArrayList<>();
@ -95,13 +99,16 @@ public class TNTElementGUI {
} }
inv.setItem(24, new SWItem(Material.ANVIL, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_OTHER", player), otherLore, false, clickType -> { inv.setItem(24, new SWItem(Material.ANVIL, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_OTHER", player), otherLore, false, clickType -> {
editOther(player, tntElement, () -> open(player, tntElement, back)); editOther(player, tntElement, () -> open(player, tntElement, back));
recalculate.set(true);
})); }));
}; };
editObserver.run(); editObserver.run();
tntElement.register(editObserver, player::closeInventory); tntElement.register(editObserver, player::closeInventory);
inv.addCloseRunnable(() -> { inv.addCloseRunnable(() -> {
tntElement.unregister(editObserver); tntElement.unregister(editObserver);
SimulatorPreviewStorage.recalculate(tntSimulator); if (recalculate.get()) {
SimulatorPreviewStorage.recalculate(tntSimulator);
}
}); });
inv.open(); inv.open();
@ -113,57 +120,67 @@ public class TNTElementGUI {
inv.setItem(36, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("SIMULATOR_BACK", player), clickType -> back.run())); inv.setItem(36, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("SIMULATOR_BACK", player), clickType -> back.run()));
} }
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
AtomicBoolean recalculate = new AtomicBoolean(false);
Runnable editObserver = () -> { Runnable editObserver = () -> {
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player); ChangePosition.show(inv, player, recalculate, tntSimulator, tntElement, tntElement::getOwnPosition, x -> x - tntElement.getParentPosition().getX(), y -> y - tntElement.getParentPosition().getY(), z -> z - tntElement.getParentPosition().getZ(), () -> editLocation(player, tntElement, back));
ChangePosition.show(inv, player, tntSimulator, tntElement, tntElement::getOwnPosition, x -> x - tntElement.getParentPosition().getX(), y -> y - tntElement.getParentPosition().getY(), z -> z - tntElement.getParentPosition().getZ(), () -> editLocation(player, tntElement, back));
// Alignment // Alignment
inv.setItem(23, new SWItem(Material.OAK_BUTTON, "§a" + BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_NEGATIVE_Z", player), clickType -> { // Z negative inv.setItem(23, new SWItem(Material.OAK_BUTTON, "§a" + BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_NEGATIVE_Z", player), clickType -> { // Z negative
if (tntSimulator != null) tntSimulator.hide(tntElement); recalculate.set(true);
tntSimulator.hide(tntElement);
Vector position = tntElement.getPosition(); Vector position = tntElement.getPosition();
align(position, new Vector(0, 0, 0.49)); align(position, new Vector(0, 0, 0.49));
tntElement.getOwnPosition().setZ(position.getZ() - tntElement.getParentPosition().getZ()); tntElement.getOwnPosition().setZ(position.getZ() - tntElement.getParentPosition().getZ());
if (tntSimulator != null) tntSimulator.show(tntElement); tntSimulator.show(tntElement);
tntElement.change(); tntElement.change();
})); }));
inv.setItem(25, new SWItem(Material.OAK_BUTTON, "§b" + BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_POSITIVE_Z", player), clickType -> { // Z positive inv.setItem(25, new SWItem(Material.OAK_BUTTON, "§b" + BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_POSITIVE_Z", player), clickType -> { // Z positive
if (tntSimulator != null) tntSimulator.hide(tntElement); recalculate.set(true);
tntSimulator.hide(tntElement);
Vector position = tntElement.getPosition(); Vector position = tntElement.getPosition();
align(position, new Vector(0, 0, 0.51)); align(position, new Vector(0, 0, 0.51));
tntElement.getOwnPosition().setZ(position.getZ() - tntElement.getParentPosition().getZ()); tntElement.getOwnPosition().setZ(position.getZ() - tntElement.getParentPosition().getZ());
if (tntSimulator != null) tntSimulator.show(tntElement); tntSimulator.show(tntElement);
tntElement.change(); tntElement.change();
})); }));
inv.setItem(15, new SWItem(Material.OAK_BUTTON, "§c" + BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_POSITIVE_X", player), clickType -> { // X positive inv.setItem(15, new SWItem(Material.OAK_BUTTON, "§c" + BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_POSITIVE_X", player), clickType -> { // X positive
if (tntSimulator != null) tntSimulator.hide(tntElement); recalculate.set(true);
tntSimulator.hide(tntElement);
Vector position = tntElement.getPosition(); Vector position = tntElement.getPosition();
align(position, new Vector(0.51, 0, 0)); align(position, new Vector(0.51, 0, 0));
tntElement.getOwnPosition().setX(position.getX() - tntElement.getParentPosition().getX()); tntElement.getOwnPosition().setX(position.getX() - tntElement.getParentPosition().getX());
if (tntSimulator != null) tntSimulator.show(tntElement); tntSimulator.show(tntElement);
tntElement.change(); tntElement.change();
})); }));
inv.setItem(33, new SWItem(Material.OAK_BUTTON, "§e" + BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_NEGATIVE_X", player), clickType -> { // X negative inv.setItem(33, new SWItem(Material.OAK_BUTTON, "§e" + BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_NEGATIVE_X", player), clickType -> { // X negative
if (tntSimulator != null) tntSimulator.hide(tntElement); recalculate.set(true);
tntSimulator.hide(tntElement);
Vector position = tntElement.getPosition(); Vector position = tntElement.getPosition();
align(position, new Vector(0.49, 0, 0)); align(position, new Vector(0.49, 0, 0));
tntElement.getOwnPosition().setX(position.getX() - tntElement.getParentPosition().getX()); tntElement.getOwnPosition().setX(position.getX() - tntElement.getParentPosition().getX());
if (tntSimulator != null) tntSimulator.show(tntElement); tntSimulator.show(tntElement);
tntElement.change(); tntElement.change();
})); }));
inv.setItem(24, new SWItem(Material.SUNFLOWER, "§f" + BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_CENTER", player), clickType -> { // CENTER inv.setItem(24, new SWItem(Material.SUNFLOWER, "§f" + BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_CENTER", player), clickType -> { // CENTER
if (tntSimulator != null) tntSimulator.hide(tntElement); recalculate.set(true);
tntSimulator.hide(tntElement);
Vector position = tntElement.getPosition(); Vector position = tntElement.getPosition();
align(position, new Vector(0.5, 0, 0.5)); align(position, new Vector(0.5, 0, 0.5));
tntElement.getOwnPosition().setX(position.getX() - tntElement.getParentPosition().getX()); tntElement.getOwnPosition().setX(position.getX() - tntElement.getParentPosition().getX());
tntElement.getOwnPosition().setZ(position.getZ() - tntElement.getParentPosition().getZ()); tntElement.getOwnPosition().setZ(position.getZ() - tntElement.getParentPosition().getZ());
if (tntSimulator != null) tntSimulator.show(tntElement); tntSimulator.show(tntElement);
tntElement.change(); tntElement.change();
})); }));
}; };
editObserver.run(); editObserver.run();
tntElement.register(editObserver, player::closeInventory); tntElement.register(editObserver, player::closeInventory);
inv.addCloseRunnable(() -> tntElement.unregister(editObserver)); inv.addCloseRunnable(() -> {
tntElement.unregister(editObserver);
if (recalculate.get()) {
SimulatorPreviewStorage.recalculate(tntSimulator);
}
});
inv.open(); inv.open();
} }
@ -199,13 +216,17 @@ public class TNTElementGUI {
List<String> minusOneFiveShiftLore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_MINUS_FIVE_SHIFT", player)); List<String> minusOneFiveShiftLore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_MINUS_FIVE_SHIFT", player));
List<String> lore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_LORE", player)); List<String> lore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_LORE", player));
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
AtomicBoolean recalculate = new AtomicBoolean(false);
Runnable editObserver = () -> { Runnable editObserver = () -> {
// Change Count of spawned TNT // Change Count of spawned TNT
inv.setItem(10, new SWItem(SWItem.getDye(10), "§a" + plusOneName, plusOneFiveShiftLore, false, clickType -> { inv.setItem(10, new SWItem(SWItem.getDye(10), "§a" + plusOneName, plusOneFiveShiftLore, false, clickType -> {
recalculate.set(true);
tntElement.setCount(tntElement.getCount() + ((clickType.isShiftClick()) ? 5 : 1)); tntElement.setCount(tntElement.getCount() + ((clickType.isShiftClick()) ? 5 : 1));
tntElement.change(); tntElement.change();
})); }));
SWItem countItem = new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_COUNT", player, tntElement.getCount()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_COUNT_ANVIL_GUI_NAME", player), tntElement.getCount(), c -> { SWItem countItem = new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_COUNT", player, tntElement.getCount()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_COUNT_ANVIL_GUI_NAME", player), tntElement.getCount(), c -> {
recalculate.set(true);
tntElement.setCount(c); tntElement.setCount(c);
tntElement.change(); tntElement.change();
editProperties(player, tntElement, back); editProperties(player, tntElement, back);
@ -213,16 +234,19 @@ public class TNTElementGUI {
countItem.getItemStack().setAmount(tntElement.getCount()); countItem.getItemStack().setAmount(tntElement.getCount());
inv.setItem(19, countItem); inv.setItem(19, countItem);
inv.setItem(28, new SWItem(SWItem.getDye(1), "§a" + minusOneName, minusOneFiveShiftLore, false, clickType -> { inv.setItem(28, new SWItem(SWItem.getDye(1), "§a" + minusOneName, minusOneFiveShiftLore, false, clickType -> {
recalculate.set(true);
tntElement.setCount(tntElement.getCount() - ((clickType.isShiftClick()) ? 5 : 1)); tntElement.setCount(tntElement.getCount() - ((clickType.isShiftClick()) ? 5 : 1));
tntElement.change(); tntElement.change();
})); }));
// Change TickOffset // Change TickOffset
inv.setItem(11, new SWItem(SWItem.getDye(10), "§b" + plusOneName, plusOneFiveShiftLore, false, clickType -> { inv.setItem(11, new SWItem(SWItem.getDye(10), "§b" + plusOneName, plusOneFiveShiftLore, false, clickType -> {
recalculate.set(true);
tntElement.setTickOffset(tntElement.getOwnTickOffset() + (clickType.isShiftClick() ? 5 : 1)); tntElement.setTickOffset(tntElement.getOwnTickOffset() + (clickType.isShiftClick() ? 5 : 1));
tntElement.change(); tntElement.change();
})); }));
SWItem tickItem = new SWItem(SWItem.getMaterial("DIODE"), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK", player, tntElement.getTickOffset()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK_ANVIL_GUI_NAME", player), tntElement.getTickOffset(), tick -> { SWItem tickItem = new SWItem(SWItem.getMaterial("DIODE"), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK", player, tntElement.getTickOffset()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK_ANVIL_GUI_NAME", player), tntElement.getTickOffset(), tick -> {
recalculate.set(true);
tntElement.setTickOffset(tick - tntElement.getParentTickOffset()); tntElement.setTickOffset(tick - tntElement.getParentTickOffset());
tntElement.change(); tntElement.change();
editProperties(player, tntElement, back); editProperties(player, tntElement, back);
@ -230,16 +254,19 @@ public class TNTElementGUI {
tickItem.getItemStack().setAmount(Math.max(tntElement.getTickOffset(), 1)); tickItem.getItemStack().setAmount(Math.max(tntElement.getTickOffset(), 1));
inv.setItem(20, tickItem); inv.setItem(20, tickItem);
inv.setItem(29, new SWItem(SWItem.getDye(1), "§b" + minusOneName, minusOneFiveShiftLore, false, clickType -> { inv.setItem(29, new SWItem(SWItem.getDye(1), "§b" + minusOneName, minusOneFiveShiftLore, false, clickType -> {
recalculate.set(true);
tntElement.setTickOffset(tntElement.getOwnTickOffset() - (clickType.isShiftClick() ? 5 : 1)); tntElement.setTickOffset(tntElement.getOwnTickOffset() - (clickType.isShiftClick() ? 5 : 1));
tntElement.change(); tntElement.change();
})); }));
// Change FuseTicks // Change FuseTicks
inv.setItem(12, new SWItem(SWItem.getDye(10), "§c" + plusOneName, plusOneFiveShiftLore, false, clickType -> { inv.setItem(12, new SWItem(SWItem.getDye(10), "§c" + plusOneName, plusOneFiveShiftLore, false, clickType -> {
recalculate.set(true);
tntElement.setFuseTicks(tntElement.getFuseTicks() + (clickType.isShiftClick() ? 5 : 1)); tntElement.setFuseTicks(tntElement.getFuseTicks() + (clickType.isShiftClick() ? 5 : 1));
tntElement.change(); tntElement.change();
})); }));
SWItem fuseTickItem = new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_FUSE", player, tntElement.getFuseTicks()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_FUSE_ANVIL_GUI_NAME", player), tntElement.getFuseTicks(), tick -> { SWItem fuseTickItem = new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_FUSE", player, tntElement.getFuseTicks()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_FUSE_ANVIL_GUI_NAME", player), tntElement.getFuseTicks(), tick -> {
recalculate.set(true);
tntElement.setFuseTicks(tick); tntElement.setFuseTicks(tick);
tntElement.change(); tntElement.change();
editProperties(player, tntElement, back); editProperties(player, tntElement, back);
@ -247,12 +274,14 @@ public class TNTElementGUI {
fuseTickItem.getItemStack().setAmount(Math.max(tntElement.getFuseTicks(), 1)); fuseTickItem.getItemStack().setAmount(Math.max(tntElement.getFuseTicks(), 1));
inv.setItem(21, fuseTickItem); inv.setItem(21, fuseTickItem);
inv.setItem(30, new SWItem(SWItem.getDye(1), "§c" + minusOneName, minusOneFiveShiftLore, false, clickType -> { inv.setItem(30, new SWItem(SWItem.getDye(1), "§c" + minusOneName, minusOneFiveShiftLore, false, clickType -> {
recalculate.set(true);
tntElement.setFuseTicks(tntElement.getFuseTicks() - (clickType.isShiftClick() ? 5 : 1)); tntElement.setFuseTicks(tntElement.getFuseTicks() - (clickType.isShiftClick() ? 5 : 1));
tntElement.change(); tntElement.change();
})); }));
// Velocity Settings // Velocity Settings
inv.setItem(24, Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_NAME", player), clickType -> { inv.setItem(24, Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_NAME", player), clickType -> {
recalculate.set(true);
if (tntElement.isXVelocity() || tntElement.isYVelocity() || tntElement.isZVelocity()) { if (tntElement.isXVelocity() || tntElement.isYVelocity() || tntElement.isZVelocity()) {
tntElement.setXVelocity(false); tntElement.setXVelocity(false);
tntElement.setYVelocity(false); tntElement.setYVelocity(false);
@ -265,21 +294,29 @@ public class TNTElementGUI {
tntElement.change(); tntElement.change();
}); });
inv.setItem(32, new SWItem(getWool(tntElement.isXVelocity()), getColor(tntElement.isXVelocity()), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_X", player, active(player, tntElement.isXVelocity())), clickType -> { inv.setItem(32, new SWItem(getWool(tntElement.isXVelocity()), getColor(tntElement.isXVelocity()), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_X", player, active(player, tntElement.isXVelocity())), clickType -> {
recalculate.set(true);
tntElement.setXVelocity(!tntElement.isXVelocity()); tntElement.setXVelocity(!tntElement.isXVelocity());
tntElement.change(); tntElement.change();
})); }));
inv.setItem(15, new SWItem(getWool(tntElement.isYVelocity()), getColor(tntElement.isYVelocity()), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_Y", player, active(player, tntElement.isYVelocity())), clickType -> { inv.setItem(15, new SWItem(getWool(tntElement.isYVelocity()), getColor(tntElement.isYVelocity()), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_Y", player, active(player, tntElement.isYVelocity())), clickType -> {
recalculate.set(true);
tntElement.setYVelocity(!tntElement.isYVelocity()); tntElement.setYVelocity(!tntElement.isYVelocity());
tntElement.change(); tntElement.change();
})); }));
inv.setItem(34, new SWItem(getWool(tntElement.isZVelocity()), getColor(tntElement.isZVelocity()), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_Z", player, active(player, tntElement.isZVelocity())), clickType -> { inv.setItem(34, new SWItem(getWool(tntElement.isZVelocity()), getColor(tntElement.isZVelocity()), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_Z", player, active(player, tntElement.isZVelocity())), clickType -> {
recalculate.set(true);
tntElement.setZVelocity(!tntElement.isZVelocity()); tntElement.setZVelocity(!tntElement.isZVelocity());
tntElement.change(); tntElement.change();
})); }));
}; };
editObserver.run(); editObserver.run();
tntElement.register(editObserver, player::closeInventory); tntElement.register(editObserver, player::closeInventory);
inv.addCloseRunnable(() -> tntElement.unregister(editObserver)); inv.addCloseRunnable(() -> {
tntElement.unregister(editObserver);
if (recalculate.get()) {
SimulatorPreviewStorage.recalculate(tntSimulator);
}
});
inv.open(); inv.open();
} }
@ -290,10 +327,11 @@ public class TNTElementGUI {
inv.setItem(36, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("SIMULATOR_BACK", player), clickType -> back.run())); inv.setItem(36, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("SIMULATOR_BACK", player), clickType -> back.run()));
} }
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
AtomicBoolean recalculate = new AtomicBoolean(false);
Runnable editObserver = () -> { Runnable editObserver = () -> {
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
inv.setItem(19, new SWItem(tntElement.getOrder(), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ACTIVATED_NAME", player), OrderUtils.orderList(tntElement.getOrder(), player), false, clickType -> { inv.setItem(19, new SWItem(tntElement.getOrder(), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ACTIVATED_NAME", player), OrderUtils.orderList(tntElement.getOrder(), player), false, clickType -> {
recalculate.set(true);
if (clickType.isShiftClick()) { if (clickType.isShiftClick()) {
tntElement.setOrder(OrderUtils.previous(tntElement.getOrder())); tntElement.setOrder(OrderUtils.previous(tntElement.getOrder()));
} else { } else {
@ -303,10 +341,11 @@ public class TNTElementGUI {
})); }));
ChangeMaterial.show(inv, player, 21, tntElement, Material.BARREL, () -> editOther(player, tntElement, back)); ChangeMaterial.show(inv, player, 21, tntElement, Material.BARREL, () -> editOther(player, tntElement, back));
Disabled.show(inv, player, 22, tntSimulator, tntElement); Disabled.show(inv, player, recalculate, 22, tntSimulator, tntElement);
if (!tntElement.hasParent()) { if (!tntElement.hasParent()) {
inv.setItem(24, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE", player), Arrays.asList(), false, clickType -> { inv.setItem(24, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE", player), Arrays.asList(), false, clickType -> {
recalculate.set(true);
// Create TNTGroup // Create TNTGroup
tntSimulator.getTntElementList().remove(tntElement); tntSimulator.getTntElementList().remove(tntElement);
Vector vector = tntElement.getOwnPosition().clone(); Vector vector = tntElement.getOwnPosition().clone();
@ -335,6 +374,7 @@ public class TNTElementGUI {
} }
inv.setItem(25, new SWItem(Material.DISPENSER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ADD_TNT", player), clickType -> { inv.setItem(25, new SWItem(Material.DISPENSER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ADD_TNT", player), clickType -> {
recalculate.set(true);
Vector vector = tntElement.getOwnPosition().clone(); Vector vector = tntElement.getOwnPosition().clone();
TNTElement newElement = new TNTElement(vector); TNTElement newElement = new TNTElement(vector);
if (tntElement.hasParent()) { if (tntElement.hasParent()) {
@ -351,13 +391,19 @@ public class TNTElementGUI {
// Delete tnt // Delete tnt
inv.setItem(44, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_REMOVE_TNT", player), clickType -> { inv.setItem(44, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_REMOVE_TNT", player), clickType -> {
recalculate.set(true);
tntSimulator.remove(tntElement); tntSimulator.remove(tntElement);
player.closeInventory(); player.closeInventory();
})); }));
}; };
editObserver.run(); editObserver.run();
tntElement.register(editObserver, player::closeInventory); tntElement.register(editObserver, player::closeInventory);
inv.addCloseRunnable(() -> tntElement.unregister(editObserver)); inv.addCloseRunnable(() -> {
tntElement.unregister(editObserver);
if (recalculate.get()) {
SimulatorPreviewStorage.recalculate(tntSimulator);
}
});
inv.open(); inv.open();
} }

Datei anzeigen

@ -37,6 +37,7 @@ import org.bukkit.util.Consumer;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.UnaryOperator; import java.util.function.UnaryOperator;
@UtilityClass @UtilityClass
@ -61,17 +62,20 @@ public class TNTGroupEditGUI {
List<String> lore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_LORE", player)); List<String> lore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_LORE", player));
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player); TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
AtomicBoolean recalculate = new AtomicBoolean(false);
Runnable editObserver = () -> { Runnable editObserver = () -> {
ChangePosition.show(inv, player, tntSimulator, tntGroup, tntGroup::getPosition, UnaryOperator.identity(), UnaryOperator.identity(), UnaryOperator.identity(), () -> open(player, tntGroup, back)); ChangePosition.show(inv, player, recalculate, tntSimulator, tntGroup, tntGroup::getPosition, UnaryOperator.identity(), UnaryOperator.identity(), UnaryOperator.identity(), () -> open(player, tntGroup, back));
ChangeMaterial.show(inv, player, 14, tntGroup, Material.BARREL, () -> open(player, tntGroup, back)); ChangeMaterial.show(inv, player, 14, tntGroup, Material.BARREL, () -> open(player, tntGroup, back));
Disabled.show(inv, player, 32, tntSimulator, tntGroup); Disabled.show(inv, player, recalculate, 32, tntSimulator, tntGroup);
// Change TickOffset // Change TickOffset
inv.setItem(16, new SWItem(SWItem.getDye(10), plusOneName, plusOneFiveShiftLore, false, clickType -> { inv.setItem(16, new SWItem(SWItem.getDye(10), plusOneName, plusOneFiveShiftLore, false, clickType -> {
recalculate.set(true);
tntGroup.setTickOffset(tntGroup.getTickOffset() + (clickType.isShiftClick() ? 5 : 1)); tntGroup.setTickOffset(tntGroup.getTickOffset() + (clickType.isShiftClick() ? 5 : 1));
tntGroup.change(); tntGroup.change();
})); }));
SWItem tickItem = new SWItem(SWItem.getMaterial("DIODE"), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK", player, tntGroup.getTickOffset()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK_ANVIL_GUI_NAME", player), tntGroup.getTickOffset(), tick -> { SWItem tickItem = new SWItem(SWItem.getMaterial("DIODE"), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK", player, tntGroup.getTickOffset()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK_ANVIL_GUI_NAME", player), tntGroup.getTickOffset(), tick -> {
recalculate.set(true);
tntGroup.setTickOffset(tick); tntGroup.setTickOffset(tick);
tntGroup.change(); tntGroup.change();
open(player, tntGroup, back); open(player, tntGroup, back);
@ -79,6 +83,7 @@ public class TNTGroupEditGUI {
tickItem.getItemStack().setAmount(Math.max(tntGroup.getTickOffset(), 1)); tickItem.getItemStack().setAmount(Math.max(tntGroup.getTickOffset(), 1));
inv.setItem(25, tickItem); inv.setItem(25, tickItem);
inv.setItem(34, new SWItem(SWItem.getDye(1), minusOneName, minusOneFiveShiftLore, false, clickType -> { inv.setItem(34, new SWItem(SWItem.getDye(1), minusOneName, minusOneFiveShiftLore, false, clickType -> {
recalculate.set(true);
tntGroup.setTickOffset(tntGroup.getTickOffset() - (clickType.isShiftClick() ? 5 : 1)); tntGroup.setTickOffset(tntGroup.getTickOffset() - (clickType.isShiftClick() ? 5 : 1));
tntGroup.change(); tntGroup.change();
})); }));

Datei anzeigen

@ -33,6 +33,7 @@ import org.bukkit.util.Vector;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.function.UnaryOperator; import java.util.function.UnaryOperator;
@ -48,7 +49,7 @@ public class ChangePosition {
private static final Vector FY_VECTOR = new Vector(0, 1, 0); private static final Vector FY_VECTOR = new Vector(0, 1, 0);
private static final Vector FZ_VECTOR = new Vector(0, 0, 1); private static final Vector FZ_VECTOR = new Vector(0, 0, 1);
public void show(SWInventory inv, Player player, TNTSimulator tntSimulator, SimulatorElement simulatorElement, Supplier<Vector> toChangeVector, UnaryOperator<Double> calculatePositionX, UnaryOperator<Double> calculatePositionY, UnaryOperator<Double> calculatePositionZ, Runnable back) { public void show(SWInventory inv, Player player, AtomicBoolean recalculate, TNTSimulator tntSimulator, SimulatorElement simulatorElement, Supplier<Vector> toChangeVector, UnaryOperator<Double> calculatePositionX, UnaryOperator<Double> calculatePositionY, UnaryOperator<Double> calculatePositionZ, Runnable back) {
String plusOneName = BauSystem.MESSAGE.parse("SIMULATOR_PLUS_ONE", player); String plusOneName = BauSystem.MESSAGE.parse("SIMULATOR_PLUS_ONE", player);
String minusOneName = BauSystem.MESSAGE.parse("SIMULATOR_MINUS_ONE", player); String minusOneName = BauSystem.MESSAGE.parse("SIMULATOR_MINUS_ONE", player);
List<String> plusOnePixelShiftLore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_PLUS_PIXEL_SHIFT", player)); List<String> plusOnePixelShiftLore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_PLUS_PIXEL_SHIFT", player));
@ -57,6 +58,7 @@ public class ChangePosition {
// X Position // X Position
inv.setItem(10, new SWItem(SWItem.getDye(10), "§a" + plusOneName, plusOnePixelShiftLore, false, clickType -> { inv.setItem(10, new SWItem(SWItem.getDye(10), "§a" + plusOneName, plusOnePixelShiftLore, false, clickType -> {
recalculate.set(true);
if (tntSimulator != null) tntSimulator.hide(simulatorElement); if (tntSimulator != null) tntSimulator.hide(simulatorElement);
toChangeVector.get().add(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR); toChangeVector.get().add(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
if (tntSimulator != null) tntSimulator.show(simulatorElement); if (tntSimulator != null) tntSimulator.show(simulatorElement);
@ -64,6 +66,7 @@ public class ChangePosition {
})); }));
inv.setItem(19, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_X", player, simulatorElement.getPosition().getX()), lore, false, clickType -> { inv.setItem(19, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_X", player, simulatorElement.getPosition().getX()), lore, false, clickType -> {
changePosition(player, simulatorElement.getPosition().getX(), x -> { changePosition(player, simulatorElement.getPosition().getX(), x -> {
recalculate.set(true);
if (tntSimulator != null) tntSimulator.hide(simulatorElement); if (tntSimulator != null) tntSimulator.hide(simulatorElement);
toChangeVector.get().setX(clamp(calculatePositionX.apply(x))); toChangeVector.get().setX(clamp(calculatePositionX.apply(x)));
if (tntSimulator != null) tntSimulator.show(simulatorElement); if (tntSimulator != null) tntSimulator.show(simulatorElement);
@ -72,6 +75,7 @@ public class ChangePosition {
}, back); }, back);
})); }));
inv.setItem(28, new SWItem(SWItem.getDye(1), "§a" + minusOneName, minusOnePixelShiftLore, false, clickType -> { inv.setItem(28, new SWItem(SWItem.getDye(1), "§a" + minusOneName, minusOnePixelShiftLore, false, clickType -> {
recalculate.set(true);
if (tntSimulator != null) tntSimulator.hide(simulatorElement); if (tntSimulator != null) tntSimulator.hide(simulatorElement);
toChangeVector.get().subtract(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR); toChangeVector.get().subtract(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
if (tntSimulator != null) tntSimulator.show(simulatorElement); if (tntSimulator != null) tntSimulator.show(simulatorElement);
@ -80,6 +84,7 @@ public class ChangePosition {
// Y Position // Y Position
inv.setItem(11, new SWItem(SWItem.getDye(10), "§b" + plusOneName, plusOnePixelShiftLore, false, clickType -> { inv.setItem(11, new SWItem(SWItem.getDye(10), "§b" + plusOneName, plusOnePixelShiftLore, false, clickType -> {
recalculate.set(true);
if (tntSimulator != null) tntSimulator.hide(simulatorElement); if (tntSimulator != null) tntSimulator.hide(simulatorElement);
toChangeVector.get().add(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR); toChangeVector.get().add(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
if (tntSimulator != null) tntSimulator.show(simulatorElement); if (tntSimulator != null) tntSimulator.show(simulatorElement);
@ -87,6 +92,7 @@ public class ChangePosition {
})); }));
inv.setItem(20, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Y", player, simulatorElement.getPosition().getY()), lore, false, clickType -> { inv.setItem(20, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Y", player, simulatorElement.getPosition().getY()), lore, false, clickType -> {
changePosition(player, simulatorElement.getPosition().getY(), y -> { changePosition(player, simulatorElement.getPosition().getY(), y -> {
recalculate.set(true);
if (tntSimulator != null) tntSimulator.hide(simulatorElement); if (tntSimulator != null) tntSimulator.hide(simulatorElement);
toChangeVector.get().setY(clamp(calculatePositionY.apply(y))); toChangeVector.get().setY(clamp(calculatePositionY.apply(y)));
if (tntSimulator != null) tntSimulator.show(simulatorElement); if (tntSimulator != null) tntSimulator.show(simulatorElement);
@ -95,6 +101,7 @@ public class ChangePosition {
}, back); }, back);
})); }));
inv.setItem(29, new SWItem(SWItem.getDye(1), "§b" + minusOneName, minusOnePixelShiftLore, false, clickType -> { inv.setItem(29, new SWItem(SWItem.getDye(1), "§b" + minusOneName, minusOnePixelShiftLore, false, clickType -> {
recalculate.set(true);
if (tntSimulator != null) tntSimulator.hide(simulatorElement); if (tntSimulator != null) tntSimulator.hide(simulatorElement);
toChangeVector.get().subtract(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR); toChangeVector.get().subtract(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
if (tntSimulator != null) tntSimulator.show(simulatorElement); if (tntSimulator != null) tntSimulator.show(simulatorElement);
@ -103,6 +110,7 @@ public class ChangePosition {
// Z Position // Z Position
inv.setItem(12, new SWItem(SWItem.getDye(10), "§c" + plusOneName, plusOnePixelShiftLore, false, clickType -> { inv.setItem(12, new SWItem(SWItem.getDye(10), "§c" + plusOneName, plusOnePixelShiftLore, false, clickType -> {
recalculate.set(true);
if (tntSimulator != null) tntSimulator.hide(simulatorElement); if (tntSimulator != null) tntSimulator.hide(simulatorElement);
toChangeVector.get().add(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR); toChangeVector.get().add(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
if (tntSimulator != null) tntSimulator.show(simulatorElement); if (tntSimulator != null) tntSimulator.show(simulatorElement);
@ -110,6 +118,7 @@ public class ChangePosition {
})); }));
inv.setItem(21, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Z", player, simulatorElement.getPosition().getZ()), lore, false, clickType -> { inv.setItem(21, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Z", player, simulatorElement.getPosition().getZ()), lore, false, clickType -> {
changePosition(player, simulatorElement.getPosition().getZ(), z -> { changePosition(player, simulatorElement.getPosition().getZ(), z -> {
recalculate.set(true);
if (tntSimulator != null) tntSimulator.hide(simulatorElement); if (tntSimulator != null) tntSimulator.hide(simulatorElement);
toChangeVector.get().setZ(clamp(calculatePositionZ.apply(z))); toChangeVector.get().setZ(clamp(calculatePositionZ.apply(z)));
if (tntSimulator != null) tntSimulator.show(simulatorElement); if (tntSimulator != null) tntSimulator.show(simulatorElement);
@ -118,6 +127,7 @@ public class ChangePosition {
}, back); }, back);
})); }));
inv.setItem(30, new SWItem(SWItem.getDye(1), "§c" + minusOneName, minusOnePixelShiftLore, false, clickType -> { inv.setItem(30, new SWItem(SWItem.getDye(1), "§c" + minusOneName, minusOnePixelShiftLore, false, clickType -> {
recalculate.set(true);
if (tntSimulator != null) tntSimulator.hide(simulatorElement); if (tntSimulator != null) tntSimulator.hide(simulatorElement);
toChangeVector.get().subtract(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR); toChangeVector.get().subtract(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
if (tntSimulator != null) tntSimulator.show(simulatorElement); if (tntSimulator != null) tntSimulator.show(simulatorElement);

Datei anzeigen

@ -29,12 +29,14 @@ import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
@UtilityClass @UtilityClass
public class Disabled { public class Disabled {
public void show(SWInventory inv, Player player, int position, TNTSimulator tntSimulator, SimulatorElement simulatorElement) { public void show(SWInventory inv, Player player, AtomicBoolean recalculate, int position, TNTSimulator tntSimulator, SimulatorElement simulatorElement) {
inv.setItem(position, new SWItem(simulatorElement.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, BauSystem.MESSAGE.parse(simulatorElement.isDisabled() ? "SIMULATOR_TNT_SPAWN_DISABLED" : "SIMULATOR_TNT_SPAWN_ENABLED", player), new ArrayList<>(), !simulatorElement.isDisabled(), clickType -> { inv.setItem(position, new SWItem(simulatorElement.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, BauSystem.MESSAGE.parse(simulatorElement.isDisabled() ? "SIMULATOR_TNT_SPAWN_DISABLED" : "SIMULATOR_TNT_SPAWN_ENABLED", player), new ArrayList<>(), !simulatorElement.isDisabled(), clickType -> {
recalculate.set(true);
if (!simulatorElement.isDisabled()) { if (!simulatorElement.isDisabled()) {
tntSimulator.hide(simulatorElement); tntSimulator.hide(simulatorElement);
} }