Dieser Commit ist enthalten in:
Ursprung
8fb4a4669a
Commit
11fdd08f79
@ -141,8 +141,7 @@ public class SimulatorCursor implements Listener {
|
|||||||
|
|
||||||
public synchronized void calcCursor(Player player) {
|
public synchronized void calcCursor(Player player) {
|
||||||
if (!isSimulatorItem(player.getInventory().getItemInMainHand()) && !isSimulatorItem(player.getInventory().getItemInOffHand())) {
|
if (!isSimulatorItem(player.getInventory().getItemInMainHand()) && !isSimulatorItem(player.getInventory().getItemInOffHand())) {
|
||||||
if (removeCursor(player)) {
|
if (removeCursor(player) || SimulatorWatcher.show(null, player)) {
|
||||||
SimulatorWatcher.show(null, player);
|
|
||||||
SWUtils.sendToActionbar(player, "");
|
SWUtils.sendToActionbar(player, "");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -41,6 +41,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
@ -104,15 +105,18 @@ public class SimulatorWatcher {
|
|||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void show(Simulator sim, Player player) {
|
public synchronized boolean show(Simulator sim, Player player) {
|
||||||
|
AtomicBoolean removed = new AtomicBoolean();
|
||||||
entityServers.forEach((simulator, rEntityServer) -> {
|
entityServers.forEach((simulator, rEntityServer) -> {
|
||||||
if (rEntityServer == null) return;
|
if (rEntityServer == null) return;
|
||||||
if (rEntityServer.getPlayers().contains(player) && sim != simulator) {
|
if (rEntityServer.getPlayers().contains(player) && sim != simulator) {
|
||||||
rEntityServer.removePlayer(player);
|
rEntityServer.removePlayer(player);
|
||||||
|
removed.set(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (sim == null) return;
|
if (sim == null) return removed.get();
|
||||||
entityServers.computeIfAbsent(sim, __ -> createSim(new REntityServer(), sim)).addPlayer(player);
|
entityServers.computeIfAbsent(sim, __ -> createSim(new REntityServer(), sim)).addPlayer(player);
|
||||||
|
return removed.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized List<REntity> getEntitiesOfSimulator(Simulator simulator) {
|
synchronized List<REntity> getEntitiesOfSimulator(Simulator simulator) {
|
||||||
|
@ -76,7 +76,7 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
|||||||
|
|
||||||
//Tick Offset
|
//Tick Offset
|
||||||
int offset = redstone.getTickOffset();
|
int offset = redstone.getTickOffset();
|
||||||
inventory.setItem(11, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
inventory.setItem(10, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||||
redstone.setTickOffset(offset + (clickType.isShiftClick() ? 5 : 1));
|
redstone.setTickOffset(offset + (clickType.isShiftClick() ? 5 : 1));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
});
|
||||||
@ -90,16 +90,16 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
|||||||
}, this).setItem(Material.REPEATER).open();
|
}, 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(19, offsetItem);
|
||||||
|
|
||||||
inventory.setItem(29, SWItem.getDye(offset > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
inventory.setItem(28, SWItem.getDye(offset > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||||
redstone.setTickOffset(Math.max(0, offset - (clickType.isShiftClick() ? 5 : 1)));
|
redstone.setTickOffset(Math.max(0, offset - (clickType.isShiftClick() ? 5 : 1)));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
});
|
||||||
|
|
||||||
//Lifetime
|
//Lifetime
|
||||||
int lifetime = redstone.getLifetime();
|
int lifetime = redstone.getLifetime();
|
||||||
inventory.setItem(12, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
inventory.setItem(11, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||||
redstone.setLifetime(lifetime + (clickType.isShiftClick() ? 5 : 1));
|
redstone.setLifetime(lifetime + (clickType.isShiftClick() ? 5 : 1));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
});
|
||||||
@ -113,9 +113,9 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
|||||||
}, this).setItem(Material.CLOCK).open();
|
}, 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(20, lifetimeItem);
|
||||||
|
|
||||||
inventory.setItem(30, SWItem.getDye(lifetime > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
inventory.setItem(29, SWItem.getDye(lifetime > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||||
redstone.setLifetime(Math.max(0, lifetime - (clickType.isShiftClick() ? 5 : 1)));
|
redstone.setLifetime(Math.max(0, lifetime - (clickType.isShiftClick() ? 5 : 1)));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
});
|
||||||
|
@ -116,7 +116,7 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
|
|||||||
inventory.setItem(19, offsetItem);
|
inventory.setItem(19, offsetItem);
|
||||||
|
|
||||||
inventory.setItem(28, SWItem.getDye(offset > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
inventory.setItem(28, SWItem.getDye(offset > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||||
tnt.setTickOffset(Math.max(1, offset - (clickType.isShiftClick() ? 5 : 1)));
|
tnt.setTickOffset(Math.max(0, offset - (clickType.isShiftClick() ? 5 : 1)));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ 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 -> {
|
new SimulatorAnvilGui<>(player, "Lifetime", lifetime + "", Integer::parseInt, integer -> {
|
||||||
if (integer < 0) return false;
|
if (integer < 1) return false;
|
||||||
tnt.setLifetime(integer);
|
tnt.setLifetime(integer);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
return true;
|
return true;
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren