SteamWar/BauSystem2.0
Archiviert
12
0

Add SimulatorAnvilGui and add anvil gui's to everything
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
yoyosource 2023-10-27 17:41:10 +02:00
Ursprung b379f8457d
Commit a0859923f0
9 geänderte Dateien mit 196 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -20,7 +20,12 @@
package de.steamwar.bausystem.features.simulator.execute; package de.steamwar.bausystem.features.simulator.execute;
import de.steamwar.bausystem.features.simulator.data.Simulator; import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.features.tpslimit.TPSUtils;
import de.steamwar.bausystem.features.tracer.record.Recorder;
import de.steamwar.bausystem.features.tracer.record.SingleTraceRecorder;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.utils.TickEndEvent; import de.steamwar.bausystem.utils.TickEndEvent;
import de.steamwar.bausystem.utils.TickStartEvent; import de.steamwar.bausystem.utils.TickStartEvent;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
@ -66,6 +71,22 @@ public class SimulatorExecutor implements Listener {
currentlyRunning.remove(simulator); currentlyRunning.remove(simulator);
} }
}); });
if (simulator.isAutoTrace()) {
simulator.getGroups()
.stream()
.map(SimulatorGroup::getElements)
.flatMap(List::stream)
.map(SimulatorElement::getPosition)
.map(pos -> pos.toLocation(WORLD))
.map(Region::getRegion)
.distinct()
.forEach(region -> {
if (Recorder.INSTANCE.isDisabled(region)) {
Recorder.INSTANCE.set(region, new SingleTraceRecorder(region));
}
});
}
return true; return true;
} }

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.simulator.gui;
import de.steamwar.bausystem.features.simulator.SimulatorWatcher; import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
import de.steamwar.bausystem.features.simulator.data.Simulator; import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup; import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import org.bukkit.Material; import org.bukkit.Material;
@ -70,6 +71,12 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
SimulatorWatcher.update(simulator); 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 -> {
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
if (integer < 0) return false;
simulatorGroup.changeBaseTicks(integer - baseTicks);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(Material.REPEATER).open();
}); });
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64))); baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
inventory.setItem(18, baseTick); inventory.setItem(18, baseTick);

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.SimulatorPhase; import de.steamwar.bausystem.features.simulator.data.SimulatorPhase;
import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement; import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement;
import de.steamwar.bausystem.features.simulator.data.redstone.RedstonePhase; import de.steamwar.bausystem.features.simulator.data.redstone.RedstonePhase;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.core.Core; import de.steamwar.core.Core;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
@ -81,6 +82,12 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
}); });
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> { SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
new SimulatorAnvilGui<>(player, "Start at", offset + "", Integer::parseInt, integer -> {
if (integer < 0) return false;
redstone.setTickOffset(integer);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(Material.REPEATER).open();
}); });
offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64))); offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64)));
inventory.setItem(20, offsetItem); inventory.setItem(20, offsetItem);
@ -98,6 +105,12 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
}); });
SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eActivation Time§8:§7 " + lifetime, clickType -> { SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eActivation Time§8:§7 " + lifetime, clickType -> {
new SimulatorAnvilGui<>(player, "Activation Time", lifetime + "", Integer::parseInt, integer -> {
if (integer < 0) return false;
redstone.setLifetime(integer);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(Material.CLOCK).open();
}); });
lifetimeItem.getItemStack().setAmount(Math.max(1, Math.min(lifetime, 64))); lifetimeItem.getItemStack().setAmount(Math.max(1, Math.min(lifetime, 64)));
inventory.setItem(21, lifetimeItem); inventory.setItem(21, lifetimeItem);
@ -116,6 +129,13 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR"); Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR");
SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eActivation Order§8:§7 " + order, clickType -> { SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eActivation Order§8:§7 " + order, clickType -> {
new SimulatorAnvilGui<>(player, "Activation Order", order + "", Integer::parseInt, integer -> {
if (integer < -SimulatorPhase.ORDER_LIMIT) return false;
if (integer > SimulatorPhase.ORDER_LIMIT) return false;
redstone.setOrder(integer);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(order >= 0 ? Material.COMPASS : negativeNumbers).open();
}); });
orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30))); orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30)));
inventory.setItem(22, orderItem); inventory.setItem(22, orderItem);

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.simulator.gui;
import de.steamwar.bausystem.features.simulator.SimulatorWatcher; import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
import de.steamwar.bausystem.features.simulator.data.Simulator; import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement; import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import org.bukkit.Material; import org.bukkit.Material;
@ -68,6 +69,12 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
SimulatorWatcher.update(simulator); 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 -> {
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
if (integer < 0) return false;
redstone.changeBaseTicks(integer - baseTicks);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(Material.REPEATER).open();
}); });
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64))); baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
inventory.setItem(18, baseTick); inventory.setItem(18, baseTick);
@ -86,6 +93,11 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
}); });
inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + redstone.getPosition().getBlockX(), clickType -> { inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + redstone.getPosition().getBlockX(), clickType -> {
new SimulatorAnvilGui<>(player, "X", redstone.getPosition().getBlockX() + "", Integer::parseInt, i -> {
redstone.getPosition().setX(i);
SimulatorWatcher.update(simulator);
return true;
}, this).open();
})); }));
inventory.setItem(33, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, 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); redstone.move(clickType.isShiftClick() ? -5 : -1, 0, 0);
@ -98,6 +110,11 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
}); });
inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + redstone.getPosition().getBlockY(), clickType -> { inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + redstone.getPosition().getBlockY(), clickType -> {
new SimulatorAnvilGui<>(player, "Y", redstone.getPosition().getBlockY() + "", Integer::parseInt, i -> {
redstone.getPosition().setY(i);
SimulatorWatcher.update(simulator);
return true;
}, this).open();
})); }));
inventory.setItem(34, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, 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); redstone.move(0, clickType.isShiftClick() ? -5 : -1, 0);
@ -110,6 +127,11 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
}); });
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7 " + redstone.getPosition().getBlockZ(), clickType -> { inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7 " + redstone.getPosition().getBlockZ(), clickType -> {
new SimulatorAnvilGui<>(player, "Z", redstone.getPosition().getBlockZ() + "", Integer::parseInt, i -> {
redstone.getPosition().setZ(i);
SimulatorWatcher.update(simulator);
return true;
}, this).open();
})); }));
inventory.setItem(35, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, 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); redstone.move(0, 0, clickType.isShiftClick() ? -5 : -1);

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.SimulatorPhase; import de.steamwar.bausystem.features.simulator.data.SimulatorPhase;
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement; import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase; import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.core.Core; import de.steamwar.core.Core;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
@ -81,6 +82,12 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
}); });
SWItem countItem = new SWItem(Material.TNT, "§eCount§8:§7 " + count, clickType -> { SWItem countItem = new SWItem(Material.TNT, "§eCount§8:§7 " + count, clickType -> {
new SimulatorAnvilGui<>(player, "Count", count + "", Integer::parseInt, integer -> {
if (integer < 0) return false;
tnt.setCount(integer);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(Material.TNT).open();
}); });
countItem.getItemStack().setAmount(Math.max(1, Math.min(count, 64))); countItem.getItemStack().setAmount(Math.max(1, Math.min(count, 64)));
inventory.setItem(18, countItem); inventory.setItem(18, countItem);
@ -98,6 +105,12 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
}); });
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> { SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
new SimulatorAnvilGui<>(player, "Start at", offset + "", Integer::parseInt, integer -> {
if (integer < 0) return false;
tnt.setTickOffset(integer);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(Material.REPEATER).open();
}); });
offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64))); offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64)));
inventory.setItem(19, offsetItem); inventory.setItem(19, offsetItem);
@ -115,6 +128,12 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
}); });
SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eLifetime§8:§7 " + lifetime, clickType -> { SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eLifetime§8:§7 " + lifetime, clickType -> {
new SimulatorAnvilGui<>(player, "Lifetime", lifetime + "", Integer::parseInt, integer -> {
if (integer < 0) return false;
tnt.setLifetime(integer);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(Material.CLOCK).open();
}); });
lifetimeItem.getItemStack().setAmount(Math.max(1, Math.min(lifetime, 64))); lifetimeItem.getItemStack().setAmount(Math.max(1, Math.min(lifetime, 64)));
inventory.setItem(20, lifetimeItem); inventory.setItem(20, lifetimeItem);
@ -133,6 +152,13 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR"); Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR");
SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eCalculation Order§8:§7 " + order, clickType -> { SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eCalculation Order§8:§7 " + order, clickType -> {
new SimulatorAnvilGui<>(player, "Calculation Order", order + "", Integer::parseInt, integer -> {
if (integer < -SimulatorPhase.ORDER_LIMIT) return false;
if (integer > SimulatorPhase.ORDER_LIMIT) return false;
tnt.setOrder(integer);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(order >= 0 ? Material.COMPASS : negativeNumbers).open();
}); });
orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30))); orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30)));
inventory.setItem(22, orderItem); inventory.setItem(22, orderItem);

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.simulator.gui;
import de.steamwar.bausystem.features.simulator.SimulatorWatcher; import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
import de.steamwar.bausystem.features.simulator.data.Simulator; import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement; import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import org.bukkit.Material; import org.bukkit.Material;
@ -78,6 +79,12 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui { // TODO: Anvil G
SimulatorWatcher.update(simulator); 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 -> {
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
if (integer < 0) return false;
tnt.changeBaseTicks(integer - baseTicks);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(Material.REPEATER).open();
}); });
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64))); baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
inventory.setItem(18, baseTick); inventory.setItem(18, baseTick);
@ -124,6 +131,11 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui { // TODO: Anvil G
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
}); });
inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + tnt.getPosition().getX(), clickType -> { inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + tnt.getPosition().getX(), clickType -> {
new SimulatorAnvilGui<>(player, "X", tnt.getPosition().getX() + "", Double::parseDouble, d -> {
tnt.getPosition().setX(d);
SimulatorWatcher.update(simulator);
return true;
}, this).open();
})); }));
inventory.setItem(33, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, 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); tnt.move(clickType.isShiftClick() ? -0.0625 : -1, 0, 0);
@ -136,6 +148,11 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui { // TODO: Anvil G
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
}); });
inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + tnt.getPosition().getY(), clickType -> { inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + tnt.getPosition().getY(), clickType -> {
new SimulatorAnvilGui<>(player, "Y", tnt.getPosition().getY() + "", Double::parseDouble, d -> {
tnt.getPosition().setY(d);
SimulatorWatcher.update(simulator);
return true;
}, this).open();
})); }));
inventory.setItem(34, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, 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); tnt.move(0, clickType.isShiftClick() ? -0.0625 : -1, 0);
@ -148,6 +165,11 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui { // TODO: Anvil G
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
}); });
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7 " + tnt.getPosition().getZ(), clickType -> { inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7 " + tnt.getPosition().getZ(), clickType -> {
new SimulatorAnvilGui<>(player, "Z", tnt.getPosition().getZ() + "", Double::parseDouble, d -> {
tnt.getPosition().setZ(d);
SimulatorWatcher.update(simulator);
return true;
}, this).open();
})); }));
inventory.setItem(35, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, 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); tnt.move(0, 0, clickType.isShiftClick() ? -0.0625 : -1);

Datei anzeigen

@ -0,0 +1,73 @@
/*
* 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.simulator.gui.base;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.inventory.SWAnvilInv;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Function;
public class SimulatorAnvilGui<T extends Number> {
private SWAnvilInv anvilInv;
public SimulatorAnvilGui(Player player, String title, String defaultText, Function<String, T> mapper, Function<T, Boolean> value, SimulatorBaseGui back) {
if (defaultText == null) {
anvilInv = new SWAnvilInv(player, title);
} else {
anvilInv = new SWAnvilInv(player, title, defaultText);
}
anvilInv.addCloseCallback(() -> {
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
back.open();
}, 0);
});
anvilInv.setCallback(s -> {
T t;
try {
t = mapper.apply(s);
} catch (NumberFormatException e) {
new SimulatorAnvilGui<>(player, title, s, mapper, value, back).open();
return;
}
try {
if (!value.apply(t)) {
new SimulatorAnvilGui<>(player, title, s, mapper, value, back).open();
}
} finally {
back.open();
}
});
}
public SimulatorAnvilGui<T> setItem(Material material) {
anvilInv.setItem(material);
return this;
}
public void open() {
anvilInv.open();
}
}

Datei anzeigen

@ -86,6 +86,10 @@ public class Recorder implements Listener {
return get(tntTraceRecorderMap.computeIfAbsent(tntPrimed, e -> Region.getRegion(e.getLocation()))); return get(tntTraceRecorderMap.computeIfAbsent(tntPrimed, e -> Region.getRegion(e.getLocation())));
} }
public boolean isDisabled(Region region) {
return !regionTraceRecorderMap.containsKey(region);
}
public TraceRecorder get(Region region) { public TraceRecorder get(Region region) {
return regionTraceRecorderMap.getOrDefault(region, DISABLED); return regionTraceRecorderMap.getOrDefault(region, DISABLED);
} }

Datei anzeigen

@ -36,7 +36,7 @@ public class SingleTraceRecorder extends AutoTraceRecorder {
@Override @Override
protected boolean shouldStartRecording(StartType startType) { protected boolean shouldStartRecording(StartType startType) {
return startType == StartType.EXPLODE; return startType == StartType.IGNITE;
} }
@Override @Override