Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e176b3bca8 | |||
| f81f05c3d0 | |||
| 0afb6ce06a | |||
| a938abde3f | |||
| ec9b0387c5 | |||
| 03c3d49659 | |||
| 8d9a77ab67 | |||
| fc2997e011 | |||
| 8eb5f5ddf2 | |||
| fd8f942014 | |||
| eab8826583 | |||
| bc0177df43 | |||
| 1dc78b8eb8 |
@@ -834,6 +834,10 @@ SKIN_NO_REGION = §7You are not in a region with a changealbe skin
|
|||||||
SKIN_ALREADY_EXISTS = §cThis skin already exists like this
|
SKIN_ALREADY_EXISTS = §cThis skin already exists like this
|
||||||
SKIN_MESSAGE = §7Skin created
|
SKIN_MESSAGE = §7Skin created
|
||||||
SKIN_MESSAGE_HOVER = §eClick to copy for YoyoNow and send
|
SKIN_MESSAGE_HOVER = §eClick to copy for YoyoNow and send
|
||||||
|
# Blast Resistance
|
||||||
|
BLASTRESISTANCE_HELP = §8/§eblastresistance §8-§7 Calculate min/max and average blast resistance of current clipboard
|
||||||
|
BLASTRESISTANCE_NO_CLIPBOARD = §cYou currently do not have a clipboard to be used.
|
||||||
|
BLASTRESISTANCE_RESULT = §7BlastResistance §8>>§7 Min§8: §e{0}§7 Max§8: §e{1}§7 Avg§8: §e{2}
|
||||||
# Panzern
|
# Panzern
|
||||||
PANZERN_HELP = §8/§epanzern §8[§7Block§8] §8[§7Slab§8] §8- §7Armor your WorldEdit selection
|
PANZERN_HELP = §8/§epanzern §8[§7Block§8] §8[§7Slab§8] §8- §7Armor your WorldEdit selection
|
||||||
PANZERN_PREPARE1 = §71. Check, if barrels reach until border of armor.
|
PANZERN_PREPARE1 = §71. Check, if barrels reach until border of armor.
|
||||||
|
|||||||
@@ -772,6 +772,10 @@ SKIN_NO_REGION = §7Du steht in keiner Region, welche mit einem Skin versehen we
|
|||||||
SKIN_ALREADY_EXISTS = §cDieser Skin existiert in der Form bereits
|
SKIN_ALREADY_EXISTS = §cDieser Skin existiert in der Form bereits
|
||||||
SKIN_MESSAGE = §7Skin erstellt
|
SKIN_MESSAGE = §7Skin erstellt
|
||||||
SKIN_MESSAGE_HOVER = §eKlicken zum kopieren für YoyoNow und an diesen senden
|
SKIN_MESSAGE_HOVER = §eKlicken zum kopieren für YoyoNow und an diesen senden
|
||||||
|
# Blast Resistance
|
||||||
|
BLASTRESISTANCE_HELP = §8/§eblastresistance §8-§7 Minimal-, Maximal- und durchschnittliche Sprengfestigkeit des aktuellen Inhalts der Zwischenablage berechnen
|
||||||
|
BLASTRESISTANCE_NO_CLIPBOARD = §cDerzeit steht Ihnen keine Zwischenablage zur Verfügung.
|
||||||
|
BLASTRESISTANCE_RESULT = §7BlastResistance §8>>§7 Min§8: §e{0}§7 Max§8: §e{1}§7 Avg§8: §e{2}
|
||||||
# Panzern
|
# Panzern
|
||||||
PANZERN_HELP = §8/§epanzern §8[§7Block§8] §8[§7Slab§8] §8- §7Panzer deine WorldEdit Auswahl
|
PANZERN_HELP = §8/§epanzern §8[§7Block§8] §8[§7Slab§8] §8- §7Panzer deine WorldEdit Auswahl
|
||||||
PANZERN_PREPARE1 = §71. Gucke nochmal nach, ob Läufe auch bis zur Panzergrenze führen.
|
PANZERN_PREPARE1 = §71. Gucke nochmal nach, ob Läufe auch bis zur Panzergrenze führen.
|
||||||
|
|||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2026 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.experimental;
|
||||||
|
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.linkage.Linked;
|
||||||
|
|
||||||
|
@Linked
|
||||||
|
public class ExperimentalCommand extends SWCommand {
|
||||||
|
|
||||||
|
public ExperimentalCommand() {
|
||||||
|
super("experimental", "experiment");
|
||||||
|
}
|
||||||
|
}
|
||||||
+135
@@ -0,0 +1,135 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2026 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.experimental.redstone_engine;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.experimental.ExperimentalCommand;
|
||||||
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
|
import de.steamwar.command.AbstractSWCommand;
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.linkage.Linked;
|
||||||
|
import io.papermc.paper.configuration.WorldConfiguration;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import net.kyori.adventure.title.TitlePart;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@AbstractSWCommand.PartOf(ExperimentalCommand.class)
|
||||||
|
@Linked
|
||||||
|
public class RedstoneEngine extends SWCommand implements Listener, ScoreboardElement {
|
||||||
|
|
||||||
|
public RedstoneEngine() {
|
||||||
|
super("");
|
||||||
|
}
|
||||||
|
|
||||||
|
private WorldConfiguration.Misc getConfig() {
|
||||||
|
return ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle().paperConfig().misc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register("redstone")
|
||||||
|
@Register("redstoneengine")
|
||||||
|
public void setRedstoneEngine(Player player, @StaticValue("alternate_current") String __, WorldConfiguration.Misc.AlternateCurrentUpdateOrder updateOrder) {
|
||||||
|
WorldConfiguration.Misc misc = getConfig();
|
||||||
|
misc.redstoneImplementation = WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT;
|
||||||
|
misc.alternateCurrentUpdateOrder = updateOrder;
|
||||||
|
broadcastTitle(Bukkit.getOnlinePlayers());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register("redstone")
|
||||||
|
@Register("redstoneengine")
|
||||||
|
public void setRedstoneEngine(Player player, WorldConfiguration.Misc.RedstoneImplementation implementation) {
|
||||||
|
getConfig().redstoneImplementation = implementation;
|
||||||
|
broadcastTitle(Bukkit.getOnlinePlayers());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
WorldConfiguration.Misc misc = getConfig();
|
||||||
|
if (misc.redstoneImplementation != WorldConfiguration.Misc.RedstoneImplementation.EIGENCRAFT) {
|
||||||
|
broadcastTitle(List.of(event.getPlayer()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void broadcastTitle(Collection<? extends Player> players) {
|
||||||
|
WorldConfiguration.Misc misc = getConfig();
|
||||||
|
Component title = switch (misc.redstoneImplementation) {
|
||||||
|
case VANILLA -> Component.text("⚠").color(NamedTextColor.RED).append(Component.text(" Redstone: Vanilla ").color(NamedTextColor.WHITE)).append(Component.text("⚠").color(NamedTextColor.RED));
|
||||||
|
case EIGENCRAFT -> Component.text("Redstone: Eigencraft");
|
||||||
|
case ALTERNATE_CURRENT -> Component.text("⚠").color(NamedTextColor.RED).append(Component.text(" Redstone: AC ").color(NamedTextColor.WHITE)).append(Component.text("⚠").color(NamedTextColor.RED));
|
||||||
|
};
|
||||||
|
Component subtitle;
|
||||||
|
if (misc.redstoneImplementation != WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) {
|
||||||
|
subtitle = Component.text().build();
|
||||||
|
} else {
|
||||||
|
subtitle = switch (misc.alternateCurrentUpdateOrder) {
|
||||||
|
case VERTICAL_FIRST_INWARD -> Component.text("Y first inwards"); // Y before XZ
|
||||||
|
case VERTICAL_FIRST_OUTWARD -> Component.text("Y first outwards"); // XZ before Y
|
||||||
|
case HORIZONTAL_FIRST_INWARD -> Component.text("XZ first inwards"); // Y before XZ
|
||||||
|
case HORIZONTAL_FIRST_OUTWARD -> Component.text("XZ first outwards"); // XZ before Y
|
||||||
|
};
|
||||||
|
}
|
||||||
|
players.forEach(player -> {
|
||||||
|
player.sendTitlePart(TitlePart.TITLE, title);
|
||||||
|
player.sendTitlePart(TitlePart.SUBTITLE, subtitle);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ScoreboardGroup getGroup() {
|
||||||
|
return ScoreboardGroup.FOOTER;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int order() {
|
||||||
|
return Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String get(Region region, Player p) {
|
||||||
|
WorldConfiguration.Misc misc = getConfig();
|
||||||
|
switch (misc.redstoneImplementation) {
|
||||||
|
case ALTERNATE_CURRENT:
|
||||||
|
switch (misc.alternateCurrentUpdateOrder) {
|
||||||
|
case VERTICAL_FIRST_INWARD:
|
||||||
|
return "§eRedstone§8: §cAC §8(§7Y in§8)";
|
||||||
|
case VERTICAL_FIRST_OUTWARD:
|
||||||
|
return "§eRedstone§8: §cAC §8(§7Y out§8)";
|
||||||
|
case HORIZONTAL_FIRST_INWARD:
|
||||||
|
return "§eRedstone§8: §cAC §8(§7XZ in§8)";
|
||||||
|
case HORIZONTAL_FIRST_OUTWARD:
|
||||||
|
return "§eRedstone§8: §cAC §8(§7XZ out§8)";
|
||||||
|
}
|
||||||
|
return "§eRedstone§8: §cAC";
|
||||||
|
case EIGENCRAFT:
|
||||||
|
return null;
|
||||||
|
case VANILLA:
|
||||||
|
default:
|
||||||
|
return "§eRedstone§8: §cVanilla";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-3
@@ -38,7 +38,7 @@ import java.util.Collection;
|
|||||||
public class SimulatorCommand extends SWCommand {
|
public class SimulatorCommand extends SWCommand {
|
||||||
|
|
||||||
@LinkedInstance
|
@LinkedInstance
|
||||||
public SimulatorCursorManager simulatorCursorManager;
|
public SimulatorCursor simulatorCursor;
|
||||||
|
|
||||||
public SimulatorCommand() {
|
public SimulatorCommand() {
|
||||||
super("sim", "simulator");
|
super("sim", "simulator");
|
||||||
@@ -47,12 +47,12 @@ public class SimulatorCommand extends SWCommand {
|
|||||||
@Register(description = "SIMULATOR_HELP")
|
@Register(description = "SIMULATOR_HELP")
|
||||||
public void genericCommand(@Validator Player p) {
|
public void genericCommand(@Validator Player p) {
|
||||||
SWUtils.giveItemToPlayer(p, SimulatorStorage.getWand(p));
|
SWUtils.giveItemToPlayer(p, SimulatorStorage.getWand(p));
|
||||||
simulatorCursorManager.calcCursor(p);
|
simulatorCursor.calcCursor(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "change", description = "SIMULATOR_CHANGE_HELP")
|
@Register(value = "change", description = "SIMULATOR_CHANGE_HELP")
|
||||||
public void change(@Validator Player p) {
|
public void change(@Validator Player p) {
|
||||||
if (!SimulatorCursorManager.isSimulatorItem(p.getInventory().getItemInMainHand()) && !SimulatorCursorManager.isSimulatorItem(p.getInventory().getItemInOffHand())) {
|
if (!SimulatorCursor.isSimulatorItem(p.getInventory().getItemInMainHand()) && !SimulatorCursor.isSimulatorItem(p.getInventory().getItemInOffHand())) {
|
||||||
BauSystem.MESSAGE.send("SIMULATOR_NO_SIM_IN_HAND", p);
|
BauSystem.MESSAGE.send("SIMULATOR_NO_SIM_IN_HAND", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+362
@@ -0,0 +1,362 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2025 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.BauSystem;
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
|
import de.steamwar.bausystem.SWUtils;
|
||||||
|
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.simulator.data.observer.ObserverElement;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.observer.ObserverPhase;
|
||||||
|
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.tnt.TNTElement;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
|
||||||
|
import de.steamwar.bausystem.features.simulator.execute.SimulatorExecutor;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.SimulatorGroupGui;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.SimulatorGui;
|
||||||
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||||
|
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||||
|
import de.steamwar.bausystem.utils.ItemUtils;
|
||||||
|
import de.steamwar.core.SWPlayer;
|
||||||
|
import de.steamwar.cursor.Cursor;
|
||||||
|
import de.steamwar.entity.REntity;
|
||||||
|
import de.steamwar.entity.REntityServer;
|
||||||
|
import de.steamwar.inventory.SWAnvilInv;
|
||||||
|
import de.steamwar.linkage.Linked;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||||
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
|
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Linked
|
||||||
|
public class SimulatorCursor implements Listener {
|
||||||
|
|
||||||
|
private static final Map<Player, CursorType> cursorType = Collections.synchronizedMap(new HashMap<>());
|
||||||
|
private static final Map<Player, REntityServer> emptyTargetServers = Collections.synchronizedMap(new HashMap<>());
|
||||||
|
|
||||||
|
public static boolean isSimulatorItem(ItemStack itemStack) {
|
||||||
|
return ItemUtils.isItem(itemStack, "simulator");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean hasSimulatorItem(Player player) {
|
||||||
|
return isSimulatorItem(player.getInventory().getItemInMainHand()) || isSimulatorItem(player.getInventory().getItemInOffHand());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void scheduleCursorUpdate(Player player) {
|
||||||
|
BauSystem.runTaskLater(BauSystem.getInstance(), () -> calcCursor(player), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
|
scheduleCursorUpdate(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||||
|
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
|
scheduleCursorUpdate(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerItemHeld(PlayerItemHeldEvent event) {
|
||||||
|
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||||
|
scheduleCursorUpdate(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
|
if (!(event.getWhoClicked() instanceof Player player)) return;
|
||||||
|
if (!Permission.BUILD.hasPermission(player)) return;
|
||||||
|
scheduleCursorUpdate(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onInventoryDrag(InventoryDragEvent event) {
|
||||||
|
if (!(event.getWhoClicked() instanceof Player player)) return;
|
||||||
|
if (!Permission.BUILD.hasPermission(player)) return;
|
||||||
|
scheduleCursorUpdate(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
|
||||||
|
event.getChanged().forEach(SimulatorCursor::calcCursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
cursorType.remove(event.getPlayer());
|
||||||
|
removeCursor(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Map<Player, Long> LAST_SNEAKS = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
|
||||||
|
long millis = System.currentTimeMillis();
|
||||||
|
LAST_SNEAKS.entrySet().removeIf(entry -> millis - entry.getValue() > 200);
|
||||||
|
}, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
|
||||||
|
if (!event.isSneaking()) return;
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (!hasSimulatorItem(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (LAST_SNEAKS.containsKey(player)) {
|
||||||
|
CursorType currentType = cursorType.getOrDefault(player, CursorType.TNT);
|
||||||
|
if (currentType == CursorType.TNT) {
|
||||||
|
cursorType.put(player, CursorType.REDSTONE_BLOCK);
|
||||||
|
} else {
|
||||||
|
cursorType.put(player, CursorType.TNT);
|
||||||
|
}
|
||||||
|
calcCursor(player);
|
||||||
|
} else {
|
||||||
|
LAST_SNEAKS.put(player, System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CursorType getCursorType(Player player) {
|
||||||
|
return cursorType.getOrDefault(player, CursorType.TNT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setCursorType(Player player, CursorType cursorType) {
|
||||||
|
SimulatorCursor.cursorType.put(player, cursorType);
|
||||||
|
calcCursor(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void calcCursor(Player player) {
|
||||||
|
if (!Permission.BUILD.hasPermission(player) || !hasSimulatorItem(player)) {
|
||||||
|
if (removeCursor(player) | SimulatorWatcher.show(null, player)) {
|
||||||
|
SWUtils.sendToActionbar(player, "");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Simulator simulator = SimulatorStorage.getSimulator(player);
|
||||||
|
if (simulator != null && simulator.getStabGenerator() != null) {
|
||||||
|
removeCursor(player);
|
||||||
|
SimulatorWatcher.show(null, player);
|
||||||
|
SWUtils.sendToActionbar(player, "§cGenerating Stab");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SimulatorWatcher.show(simulator, player);
|
||||||
|
Cursor cursor = getOrCreateCursor(player, simulator, cursorType.getOrDefault(player, CursorType.TNT));
|
||||||
|
cursor.renderDeduplicated();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Cursor getOrCreateCursor(Player player, Simulator simulator, CursorType type) {
|
||||||
|
REntityServer targetServer = simulator == null ? emptyTargetServers.computeIfAbsent(player, __ -> new REntityServer()) : SimulatorWatcher.getEntityServerOfSimulator(simulator);
|
||||||
|
SWPlayer swPlayer = SWPlayer.of(player);
|
||||||
|
Optional<Cursor> activeCursor = swPlayer.getComponent(Cursor.class);
|
||||||
|
|
||||||
|
Cursor cursor = activeCursor.orElse(null);
|
||||||
|
if (cursor == null || cursor.getTargetServer() != targetServer) {
|
||||||
|
swPlayer.removeComponent(Cursor.class);
|
||||||
|
cursor = new Cursor(
|
||||||
|
targetServer,
|
||||||
|
player,
|
||||||
|
Material.GLASS,
|
||||||
|
type.material,
|
||||||
|
type.cursorModes,
|
||||||
|
(location, hitEntity, action) -> handlePlayerClick(player, location, hitEntity, action),
|
||||||
|
(location, hitEntity) -> sendCursorActionbar(player, SimulatorStorage.getSimulator(player), location != null, hitEntity.isPresent())
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
cursor.setCursorMaterial(type.material);
|
||||||
|
cursor.setAllowedCursorModes(type.cursorModes);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static synchronized boolean removeCursor(Player player) {
|
||||||
|
Optional<Cursor> cursor = SWPlayer.of(player).getComponent(Cursor.class);
|
||||||
|
cursor.ifPresent(__ -> SWPlayer.of(player).removeComponent(Cursor.class));
|
||||||
|
REntityServer emptyTargetServer = emptyTargetServers.remove(player);
|
||||||
|
if (emptyTargetServer != null) {
|
||||||
|
emptyTargetServer.close();
|
||||||
|
}
|
||||||
|
return cursor.isPresent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void sendCursorActionbar(Player player, Simulator simulator, boolean hasCursorLocation, boolean hasHitEntity) {
|
||||||
|
if (!hasCursorLocation) {
|
||||||
|
SWUtils.sendToActionbar(player, simulator == null ? "§eSelect Simulator" : "§eOpen Simulator");
|
||||||
|
} else if (simulator == null) {
|
||||||
|
SWUtils.sendToActionbar(player, "§eCreate new Simulator");
|
||||||
|
} else if (hasHitEntity) {
|
||||||
|
SWUtils.sendToActionbar(player, "§eEdit Position");
|
||||||
|
} else {
|
||||||
|
SWUtils.sendToActionbar(player, "§eAdd new " + cursorType.getOrDefault(player, CursorType.TNT).name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum CursorType {
|
||||||
|
TNT(Material.TNT, Material.GUNPOWDER, List.of(Cursor.CursorMode.FREE, Cursor.CursorMode.SURFACE_ALIGNED), "TNT", vector -> new TNTElement(vector).add(new TNTPhase())),
|
||||||
|
REDSTONE_BLOCK(Material.REDSTONE_BLOCK, Material.REDSTONE, List.of(Cursor.CursorMode.BLOCK_ALIGNED), "Redstone Block", vector -> new RedstoneElement(vector).add(new RedstonePhase())),
|
||||||
|
OBSERVER(Material.OBSERVER, Material.QUARTZ, List.of(Cursor.CursorMode.BLOCK_ALIGNED), "Observer", vector -> new ObserverElement(vector).add(new ObserverPhase())),
|
||||||
|
;
|
||||||
|
|
||||||
|
public final Material material;
|
||||||
|
public final Material nonSelectedMaterial;
|
||||||
|
public final List<Cursor.CursorMode> cursorModes;
|
||||||
|
public final String name;
|
||||||
|
public final Function<Vector, SimulatorElement<?>> elementFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void handlePlayerClick(Player player, Location cursorLocation, Optional<REntity> hitEntity, Action action) {
|
||||||
|
if (!Permission.BUILD.hasPermission(player)) return;
|
||||||
|
if (!hasSimulatorItem(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Simulator simulator = SimulatorStorage.getSimulator(player);
|
||||||
|
|
||||||
|
if (action == Action.LEFT_CLICK_BLOCK || action == Action.LEFT_CLICK_AIR) {
|
||||||
|
if (simulator == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SimulatorExecutor.run(player, simulator, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (action != Action.RIGHT_CLICK_BLOCK && action != Action.RIGHT_CLICK_AIR) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (simulator == null) {
|
||||||
|
if (cursorLocation == null) {
|
||||||
|
SimulatorStorage.openSimulatorSelector(player);
|
||||||
|
} else {
|
||||||
|
SWAnvilInv anvilInv = new SWAnvilInv(player, "Name");
|
||||||
|
anvilInv.setCallback(s -> {
|
||||||
|
Simulator sim = SimulatorStorage.getSimulator(s);
|
||||||
|
if (sim != null) {
|
||||||
|
BauSystem.MESSAGE.send("SIMULATOR_NAME_ALREADY_EXISTS", player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!s.matches("[a-zA-Z_0-9-]+")) {
|
||||||
|
BauSystem.MESSAGE.send("SIMULATOR_NAME_INVALID", player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sim = new Simulator(s);
|
||||||
|
SimulatorStorage.addSimulator(s, sim);
|
||||||
|
createElement(player, cursorLocation, sim);
|
||||||
|
SimulatorStorage.setSimulator(player, sim);
|
||||||
|
});
|
||||||
|
anvilInv.open();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cursorLocation == null) {
|
||||||
|
new SimulatorGui(player, simulator).open();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hitEntity.isPresent()) {
|
||||||
|
openElement(player, simulator, hitEntity.get());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
createElement(player, cursorLocation, simulator);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void openElement(Player player, Simulator simulator, REntity hitEntity) {
|
||||||
|
Vector vector = new Vector(hitEntity.getX(), hitEntity.getY(), hitEntity.getZ());
|
||||||
|
List<SimulatorElement<?>> elements = simulator.getGroups().stream().map(SimulatorGroup::getElements).flatMap(List::stream).filter(element -> {
|
||||||
|
return element.getWorldPos().distanceSquared(vector) < (1 / 16.0) * (1 / 16.0);
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
switch (elements.size()) {
|
||||||
|
case 0:
|
||||||
|
return;
|
||||||
|
case 1:
|
||||||
|
SimulatorElement<?> element = elements.get(0);
|
||||||
|
SimulatorGroup group1 = element.getGroup(simulator);
|
||||||
|
SimulatorBaseGui back = new SimulatorGui(player, simulator);
|
||||||
|
if (group1.getElements().size() > 1) {
|
||||||
|
back = new SimulatorGroupGui(player, simulator, group1, back);
|
||||||
|
}
|
||||||
|
element.open(player, simulator, group1, back);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
List<SimulatorGroup> parents = elements.stream().map(e -> e.getGroup(simulator)).distinct().collect(Collectors.toList());
|
||||||
|
if (parents.size() == 1) {
|
||||||
|
SimulatorGui simulatorGui = new SimulatorGui(player, simulator);
|
||||||
|
new SimulatorGroupGui(player, simulator, parents.get(0), simulatorGui).open();
|
||||||
|
} else {
|
||||||
|
SimulatorGroup group2 = new SimulatorGroup();
|
||||||
|
group2.setMaterial(null);
|
||||||
|
group2.getElements().addAll(elements);
|
||||||
|
SimulatorGui simulatorGui = new SimulatorGui(player, simulator);
|
||||||
|
new SimulatorGroupGui(player, simulator, group2, simulatorGui).open();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void createElement(Player player, Location cursorLocation, Simulator simulator) {
|
||||||
|
CursorType type = cursorType.getOrDefault(player, CursorType.TNT);
|
||||||
|
Vector vector = cursorLocation.toVector();
|
||||||
|
if (type == CursorType.REDSTONE_BLOCK) {
|
||||||
|
vector.subtract(new Vector(0.5, 0, 0.5));
|
||||||
|
}
|
||||||
|
SimulatorElement<?> element = type.elementFunction.apply(vector);
|
||||||
|
SimulatorGroup group = new SimulatorGroup().add(element);
|
||||||
|
simulator.getGroups().add(group);
|
||||||
|
SimulatorGui simulatorGui = new SimulatorGui(player, simulator);
|
||||||
|
element.open(player, simulator, group, simulatorGui);
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
calcCursor(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
-440
@@ -1,440 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2025 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.BauSystem;
|
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.SWUtils;
|
|
||||||
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.simulator.data.observer.ObserverElement;
|
|
||||||
import de.steamwar.bausystem.features.simulator.data.observer.ObserverPhase;
|
|
||||||
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.tnt.TNTElement;
|
|
||||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
|
|
||||||
import de.steamwar.bausystem.features.simulator.execute.SimulatorExecutor;
|
|
||||||
import de.steamwar.bausystem.features.simulator.gui.SimulatorGroupGui;
|
|
||||||
import de.steamwar.bausystem.features.simulator.gui.SimulatorGui;
|
|
||||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
|
||||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
|
||||||
import de.steamwar.bausystem.utils.ItemUtils;
|
|
||||||
import de.steamwar.core.SWPlayer;
|
|
||||||
import de.steamwar.cursor.Cursor;
|
|
||||||
import de.steamwar.entity.REntity;
|
|
||||||
import de.steamwar.entity.REntityServer;
|
|
||||||
import de.steamwar.inventory.SWAnvilInv;
|
|
||||||
import de.steamwar.linkage.Linked;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.block.Action;
|
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
|
||||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Linked
|
|
||||||
public class SimulatorCursorManager implements Listener {
|
|
||||||
|
|
||||||
private static class SimulatorCursorComponent implements SWPlayer.Component {
|
|
||||||
private Player player;
|
|
||||||
private Cursor cursor;
|
|
||||||
private CursorType cursorType = CursorType.TNT;
|
|
||||||
private REntityServer emptyTargetServer;
|
|
||||||
private REntityServer currentTargetServer;
|
|
||||||
private long lastSneakMillis;
|
|
||||||
|
|
||||||
private SimulatorCursorComponent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
private SimulatorCursorComponent(CursorType cursorType) {
|
|
||||||
this.cursorType = cursorType;
|
|
||||||
}
|
|
||||||
|
|
||||||
private REntityServer getOrCreateEmptyTargetServer() {
|
|
||||||
if (emptyTargetServer == null) {
|
|
||||||
emptyTargetServer = new REntityServer();
|
|
||||||
}
|
|
||||||
return emptyTargetServer;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean handleSneak(long now) {
|
|
||||||
boolean doubleSneak = now - lastSneakMillis <= 200;
|
|
||||||
lastSneakMillis = doubleSneak ? 0 : now;
|
|
||||||
return doubleSneak;
|
|
||||||
}
|
|
||||||
|
|
||||||
private CursorType getCursorType() {
|
|
||||||
return cursorType;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setCursorType(CursorType cursorType) {
|
|
||||||
this.cursorType = cursorType;
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void switchCursorMode() {
|
|
||||||
cursorType = cursorType == CursorType.TNT ? CursorType.REDSTONE_BLOCK : CursorType.TNT;
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refresh() {
|
|
||||||
if (!Permission.BUILD.hasPermission(player) || !hasSimulatorItem(player)) {
|
|
||||||
deactivateCursor(player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Simulator simulator = SimulatorStorage.getSimulator(player);
|
|
||||||
if (simulator != null && simulator.getStabGenerator() != null) {
|
|
||||||
removeGenericCursor();
|
|
||||||
boolean watcherRemoved = SimulatorWatcher.show(null, player);
|
|
||||||
if (watcherRemoved) {
|
|
||||||
SWUtils.sendToActionbar(player, "");
|
|
||||||
}
|
|
||||||
SWUtils.sendToActionbar(player, "§cGenerating Stab");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SimulatorWatcher.show(simulator, player);
|
|
||||||
REntityServer targetServer = simulator == null ? getOrCreateEmptyTargetServer() : SimulatorWatcher.getEntityServerOfSimulator(simulator);
|
|
||||||
if (cursor == null || currentTargetServer != targetServer) {
|
|
||||||
removeGenericCursor();
|
|
||||||
currentTargetServer = targetServer;
|
|
||||||
cursor = new Cursor(
|
|
||||||
targetServer,
|
|
||||||
player,
|
|
||||||
Material.GLASS,
|
|
||||||
cursorType.material,
|
|
||||||
cursorType.cursorModes,
|
|
||||||
this::handlePlayerClick,
|
|
||||||
(location, hitEntity) -> sendCursorActionbar(simulator, location != null, hitEntity.isPresent())
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
cursor.setCursorMaterial(cursorType.material);
|
|
||||||
cursor.setAllowedCursorModes(cursorType.cursorModes);
|
|
||||||
}
|
|
||||||
cursor.renderDeduplicated();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removeGenericCursor() {
|
|
||||||
if (cursor == null && !SWPlayer.of(player).hasComponent(Cursor.class)) {
|
|
||||||
currentTargetServer = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SWPlayer.of(player).removeComponent(Cursor.class);
|
|
||||||
cursor = null;
|
|
||||||
currentTargetServer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void closeEmptyTargetServer() {
|
|
||||||
if (emptyTargetServer == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
emptyTargetServer.close();
|
|
||||||
emptyTargetServer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendCursorActionbar(Simulator simulator, boolean hasCursorLocation, boolean hasHitEntity) {
|
|
||||||
if (!hasCursorLocation) {
|
|
||||||
SWUtils.sendToActionbar(player, simulator == null ? "§eSelect Simulator" : "§eOpen Simulator");
|
|
||||||
} else if (simulator == null) {
|
|
||||||
SWUtils.sendToActionbar(player, "§eCreate new Simulator");
|
|
||||||
} else if (hasHitEntity) {
|
|
||||||
SWUtils.sendToActionbar(player, "§eEdit Position");
|
|
||||||
} else {
|
|
||||||
SWUtils.sendToActionbar(player, "§eAdd new " + cursorType.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handlePlayerClick(Location cursorLocation, Optional<REntity> hitEntity, Action action) {
|
|
||||||
if (!Permission.BUILD.hasPermission(player)) return;
|
|
||||||
if (!hasSimulatorItem(player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Simulator simulator = SimulatorStorage.getSimulator(player);
|
|
||||||
|
|
||||||
if (action == Action.LEFT_CLICK_BLOCK || action == Action.LEFT_CLICK_AIR) {
|
|
||||||
if (simulator == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SimulatorExecutor.run(player, simulator, null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (action != Action.RIGHT_CLICK_BLOCK && action != Action.RIGHT_CLICK_AIR) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (simulator == null) {
|
|
||||||
if (cursorLocation == null) {
|
|
||||||
SimulatorStorage.openSimulatorSelector(player);
|
|
||||||
} else {
|
|
||||||
SWAnvilInv anvilInv = new SWAnvilInv(player, "Name");
|
|
||||||
anvilInv.setCallback(s -> {
|
|
||||||
Simulator sim = SimulatorStorage.getSimulator(s);
|
|
||||||
if (sim != null) {
|
|
||||||
BauSystem.MESSAGE.send("SIMULATOR_NAME_ALREADY_EXISTS", player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!s.matches("[a-zA-Z_0-9-]+")) {
|
|
||||||
BauSystem.MESSAGE.send("SIMULATOR_NAME_INVALID", player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sim = new Simulator(s);
|
|
||||||
SimulatorStorage.addSimulator(s, sim);
|
|
||||||
createElement(player, cursorLocation, sim);
|
|
||||||
SimulatorStorage.setSimulator(player, sim);
|
|
||||||
});
|
|
||||||
anvilInv.open();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cursorLocation == null) {
|
|
||||||
new SimulatorGui(player, simulator).open();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hitEntity.isPresent()) {
|
|
||||||
openElement(player, simulator, hitEntity.get());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
createElement(player, cursorLocation, simulator);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onMount(SWPlayer player) {
|
|
||||||
this.player = player.getPlayer();
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUnmount(SWPlayer player) {
|
|
||||||
boolean hadCursor = cursor != null || player.hasComponent(Cursor.class);
|
|
||||||
removeGenericCursor();
|
|
||||||
closeEmptyTargetServer();
|
|
||||||
boolean watcherRemoved = SimulatorWatcher.show(null, this.player);
|
|
||||||
if (hadCursor || watcherRemoved) {
|
|
||||||
SWUtils.sendToActionbar(this.player, "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isSimulatorItem(ItemStack itemStack) {
|
|
||||||
return ItemUtils.isItem(itemStack, "simulator");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean hasSimulatorItem(Player player) {
|
|
||||||
return isSimulatorItem(player.getInventory().getItemInMainHand()) || isSimulatorItem(player.getInventory().getItemInOffHand());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
|
||||||
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
|
||||||
calcCursor(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerItemHeld(PlayerItemHeldEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (!Permission.BUILD.hasPermission(player)) return;
|
|
||||||
|
|
||||||
boolean hasSimulatorInNewMainHand = isSimulatorItem(player.getInventory().getItem(event.getNewSlot()));
|
|
||||||
boolean hasSimulatorInOffHand = isSimulatorItem(player.getInventory().getItemInOffHand());
|
|
||||||
if (!hasSimulatorInNewMainHand && !hasSimulatorInOffHand) {
|
|
||||||
boolean cursorRemoved = deactivateCursor(player);
|
|
||||||
boolean watcherRemoved = SimulatorWatcher.show(null, player);
|
|
||||||
if (cursorRemoved || watcherRemoved) {
|
|
||||||
SWUtils.sendToActionbar(player, "");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> calcCursor(player), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
|
|
||||||
event.getChanged().forEach(SimulatorCursorManager::calcCursor);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
|
||||||
deactivateCursor(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
|
|
||||||
if (!event.isSneaking()) return;
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (!hasSimulatorItem(player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SimulatorCursorComponent component = activateOrRefresh(player);
|
|
||||||
if (component == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
boolean shouldSwitch = component.handleSneak(System.currentTimeMillis());
|
|
||||||
if (shouldSwitch) {
|
|
||||||
component.switchCursorMode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CursorType getCursorType(Player player) {
|
|
||||||
return SWPlayer.of(player).getComponent(SimulatorCursorComponent.class)
|
|
||||||
.map(SimulatorCursorComponent::getCursorType)
|
|
||||||
.orElse(CursorType.TNT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setCursorType(Player player, CursorType cursorType) {
|
|
||||||
Optional<SimulatorCursorComponent> component = SWPlayer.of(player).getComponent(SimulatorCursorComponent.class);
|
|
||||||
if (component.isPresent()) {
|
|
||||||
component.get().setCursorType(cursorType);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Permission.BUILD.hasPermission(player) || !hasSimulatorItem(player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SWPlayer.of(player).setComponent(new SimulatorCursorComponent(cursorType));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void calcCursor(Player player) {
|
|
||||||
activateOrRefresh(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static SimulatorCursorComponent activateOrRefresh(Player player) {
|
|
||||||
if (!Permission.BUILD.hasPermission(player) || !hasSimulatorItem(player)) {
|
|
||||||
boolean cursorRemoved = deactivateCursor(player);
|
|
||||||
boolean watcherRemoved = SimulatorWatcher.show(null, player);
|
|
||||||
if (cursorRemoved || watcherRemoved) {
|
|
||||||
SWUtils.sendToActionbar(player, "");
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
SWPlayer swPlayer = SWPlayer.of(player);
|
|
||||||
Optional<SimulatorCursorComponent> existingComponent = swPlayer.getComponent(SimulatorCursorComponent.class);
|
|
||||||
if (existingComponent.isPresent()) {
|
|
||||||
SimulatorCursorComponent component = existingComponent.get();
|
|
||||||
component.refresh();
|
|
||||||
return component;
|
|
||||||
}
|
|
||||||
|
|
||||||
SimulatorCursorComponent component = new SimulatorCursorComponent();
|
|
||||||
swPlayer.setComponent(component);
|
|
||||||
return component;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static synchronized boolean deactivateCursor(Player player) {
|
|
||||||
SWPlayer swPlayer = SWPlayer.of(player);
|
|
||||||
boolean hadSimulatorCursor = swPlayer.hasComponent(SimulatorCursorComponent.class);
|
|
||||||
boolean hadCursor = swPlayer.hasComponent(Cursor.class);
|
|
||||||
swPlayer.removeComponent(SimulatorCursorComponent.class);
|
|
||||||
if (!hadSimulatorCursor) {
|
|
||||||
swPlayer.removeComponent(Cursor.class);
|
|
||||||
}
|
|
||||||
return hadSimulatorCursor || hadCursor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public enum CursorType {
|
|
||||||
TNT(Material.TNT, Material.GUNPOWDER, List.of(Cursor.CursorMode.SURFACE_ALIGNED, Cursor.CursorMode.FREE), "TNT", vector -> new TNTElement(vector).add(new TNTPhase())),
|
|
||||||
REDSTONE_BLOCK(Material.REDSTONE_BLOCK, Material.REDSTONE, List.of(Cursor.CursorMode.BLOCK_ALIGNED), "Redstone Block", vector -> new RedstoneElement(vector).add(new RedstonePhase())),
|
|
||||||
OBSERVER(Material.OBSERVER, Material.QUARTZ, List.of(Cursor.CursorMode.BLOCK_ALIGNED), "Observer", vector -> new ObserverElement(vector).add(new ObserverPhase())),
|
|
||||||
;
|
|
||||||
|
|
||||||
public final Material material;
|
|
||||||
public final Material nonSelectedMaterial;
|
|
||||||
public final List<Cursor.CursorMode> cursorModes;
|
|
||||||
public final String name;
|
|
||||||
public final Function<Vector, SimulatorElement<?>> elementFunction;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void openElement(Player player, Simulator simulator, REntity hitEntity) {
|
|
||||||
Vector vector = new Vector(hitEntity.getX(), hitEntity.getY(), hitEntity.getZ());
|
|
||||||
List<SimulatorElement<?>> elements = simulator.getGroups().stream().map(SimulatorGroup::getElements).flatMap(List::stream).filter(element -> {
|
|
||||||
return element.getWorldPos().distanceSquared(vector) < (1 / 16.0) * (1 / 16.0);
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
|
|
||||||
switch (elements.size()) {
|
|
||||||
case 0:
|
|
||||||
return;
|
|
||||||
case 1:
|
|
||||||
SimulatorElement<?> element = elements.get(0);
|
|
||||||
SimulatorGroup group1 = element.getGroup(simulator);
|
|
||||||
SimulatorBaseGui back = new SimulatorGui(player, simulator);
|
|
||||||
if (group1.getElements().size() > 1) {
|
|
||||||
back = new SimulatorGroupGui(player, simulator, group1, back);
|
|
||||||
}
|
|
||||||
element.open(player, simulator, group1, back);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
List<SimulatorGroup> parents = elements.stream().map(e -> e.getGroup(simulator)).distinct().collect(Collectors.toList());
|
|
||||||
if (parents.size() == 1) {
|
|
||||||
SimulatorGui simulatorGui = new SimulatorGui(player, simulator);
|
|
||||||
new SimulatorGroupGui(player, simulator, parents.get(0), simulatorGui).open();
|
|
||||||
} else {
|
|
||||||
SimulatorGroup group2 = new SimulatorGroup();
|
|
||||||
group2.setMaterial(null);
|
|
||||||
group2.getElements().addAll(elements);
|
|
||||||
SimulatorGui simulatorGui = new SimulatorGui(player, simulator);
|
|
||||||
new SimulatorGroupGui(player, simulator, group2, simulatorGui).open();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void createElement(Player player, Location cursorLocation, Simulator simulator) {
|
|
||||||
CursorType type = getCursorType(player);
|
|
||||||
Vector vector = cursorLocation.toVector();
|
|
||||||
if (type == CursorType.REDSTONE_BLOCK) {
|
|
||||||
vector.subtract(new Vector(0.5, 0, 0.5));
|
|
||||||
}
|
|
||||||
SimulatorElement<?> element = type.elementFunction.apply(vector);
|
|
||||||
SimulatorGroup group = new SimulatorGroup().add(element);
|
|
||||||
simulator.getGroups().add(group);
|
|
||||||
SimulatorGui simulatorGui = new SimulatorGui(player, simulator);
|
|
||||||
element.open(player, simulator, group, simulatorGui);
|
|
||||||
SimulatorWatcher.update(simulator);
|
|
||||||
calcCursor(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+3
-3
@@ -59,7 +59,7 @@ public class SimulatorStorage implements Enable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Simulator getSimulator(ItemStack itemStack) {
|
public static Simulator getSimulator(ItemStack itemStack) {
|
||||||
if (!SimulatorCursorManager.isSimulatorItem(itemStack)) {
|
if (!SimulatorCursor.isSimulatorItem(itemStack)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String selection = ItemUtils.getTag(itemStack, simulatorSelection);
|
String selection = ItemUtils.getTag(itemStack, simulatorSelection);
|
||||||
@@ -181,9 +181,9 @@ public class SimulatorStorage implements Enable {
|
|||||||
ItemStack mainHand = player.getInventory().getItemInMainHand();
|
ItemStack mainHand = player.getInventory().getItemInMainHand();
|
||||||
ItemStack offHand = player.getInventory().getItemInOffHand();
|
ItemStack offHand = player.getInventory().getItemInOffHand();
|
||||||
ItemStack itemStack;
|
ItemStack itemStack;
|
||||||
if (SimulatorCursorManager.isSimulatorItem(mainHand)) {
|
if (SimulatorCursor.isSimulatorItem(mainHand)) {
|
||||||
itemStack = mainHand;
|
itemStack = mainHand;
|
||||||
} else if (SimulatorCursorManager.isSimulatorItem(offHand)) {
|
} else if (SimulatorCursor.isSimulatorItem(offHand)) {
|
||||||
itemStack = offHand;
|
itemStack = offHand;
|
||||||
} else {
|
} else {
|
||||||
itemStack = null;
|
itemStack = null;
|
||||||
|
|||||||
+4
-4
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.simulator.gui;
|
package de.steamwar.bausystem.features.simulator.gui;
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.simulator.SimulatorCursorManager;
|
import de.steamwar.bausystem.features.simulator.SimulatorCursor;
|
||||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||||
import de.steamwar.data.CMDs;
|
import de.steamwar.data.CMDs;
|
||||||
@@ -50,14 +50,14 @@ public class SimulatorCursorSwitcherGui extends SimulatorBaseGui {
|
|||||||
}).setCustomModelData(CMDs.BACK));
|
}).setCustomModelData(CMDs.BACK));
|
||||||
|
|
||||||
int slot = 2;
|
int slot = 2;
|
||||||
SimulatorCursorManager.CursorType currentType = SimulatorCursorManager.getCursorType(player);
|
SimulatorCursor.CursorType currentType = SimulatorCursor.getCursorType(player);
|
||||||
for (SimulatorCursorManager.CursorType type : SimulatorCursorManager.CursorType.values()) {
|
for (SimulatorCursor.CursorType type : SimulatorCursor.CursorType.values()) {
|
||||||
boolean selected = type == currentType;
|
boolean selected = type == currentType;
|
||||||
SWItem swItem = new SWItem(selected ? type.material : type.nonSelectedMaterial, "§e" + type.name)
|
SWItem swItem = new SWItem(selected ? type.material : type.nonSelectedMaterial, "§e" + type.name)
|
||||||
.setCustomModelData(selected ? 0 : CMDs.Simulator.NEW_PHASE)
|
.setCustomModelData(selected ? 0 : CMDs.Simulator.NEW_PHASE)
|
||||||
.setLore(Collections.singletonList("§eClick to select"))
|
.setLore(Collections.singletonList("§eClick to select"))
|
||||||
.setCallback(click -> {
|
.setCallback(click -> {
|
||||||
SimulatorCursorManager.setCursorType(player, type);
|
SimulatorCursor.setCursorType(player, type);
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
});
|
});
|
||||||
inventory.setItem(slot, swItem);
|
inventory.setItem(slot, swItem);
|
||||||
|
|||||||
+2
-2
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.simulator.gui;
|
package de.steamwar.bausystem.features.simulator.gui;
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.simulator.SimulatorCursorManager;
|
import de.steamwar.bausystem.features.simulator.SimulatorCursor;
|
||||||
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.SimulatorElement;
|
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||||
@@ -50,7 +50,7 @@ public class SimulatorGui extends SimulatorPageGui<SimulatorGroup> {
|
|||||||
inventory.setItem(4, simulator.toItem(player, clickType -> {
|
inventory.setItem(4, simulator.toItem(player, clickType -> {
|
||||||
new SimulatorMaterialGui(player, simulator, simulator::getMaterial, simulator::setMaterial, this).open();
|
new SimulatorMaterialGui(player, simulator, simulator::getMaterial, simulator::setMaterial, this).open();
|
||||||
}));
|
}));
|
||||||
SimulatorCursorManager.CursorType cursorType = SimulatorCursorManager.getCursorType(player);
|
SimulatorCursor.CursorType cursorType = SimulatorCursor.getCursorType(player);
|
||||||
inventory.setItem(48, new SWItem(cursorType.material, "§7Placing §8-§e " + cursorType.name, clickType -> {
|
inventory.setItem(48, new SWItem(cursorType.material, "§7Placing §8-§e " + cursorType.name, clickType -> {
|
||||||
new SimulatorCursorSwitcherGui(player, simulator, this).open();
|
new SimulatorCursorSwitcherGui(player, simulator, this).open();
|
||||||
}));
|
}));
|
||||||
|
|||||||
+73
@@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2026 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.slaves.blastresistance;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.AtomicDouble;
|
||||||
|
import com.sk89q.worldedit.LocalSession;
|
||||||
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.linkage.Linked;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
@Linked
|
||||||
|
public class BlastResistanceCommand extends SWCommand {
|
||||||
|
|
||||||
|
public BlastResistanceCommand() {
|
||||||
|
super("blastresistance");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register(description = "BLASTRESISTANCE_HELP")
|
||||||
|
public void command(@Validator Player player) {
|
||||||
|
LocalSession localSession = WorldEdit.getInstance().getSessionManager().get(BukkitAdapter.adapt(player));
|
||||||
|
Clipboard clipboard;
|
||||||
|
try {
|
||||||
|
clipboard = localSession.getClipboard().getClipboards().getFirst();
|
||||||
|
} catch (WorldEditException e) {
|
||||||
|
BauSystem.MESSAGE.send("BLASTRESISTANCE_NO_CLIPBOARD", player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AtomicDouble min = new AtomicDouble(0);
|
||||||
|
AtomicDouble max = new AtomicDouble(0);
|
||||||
|
AtomicDouble sum = new AtomicDouble(0);
|
||||||
|
AtomicInteger count = new AtomicInteger(0);
|
||||||
|
clipboard.forEach(blockVector3 -> {
|
||||||
|
BlockState blockState = clipboard.getBlock(blockVector3);
|
||||||
|
Material material = BukkitAdapter.adapt(blockState).getMaterial();
|
||||||
|
if (material == Material.WATER || material == Material.LAVA) return;
|
||||||
|
double blastResistance = BukkitAdapter.adapt(blockState).getMaterial().getBlastResistance();
|
||||||
|
min.set(Math.min(min.get(), blastResistance));
|
||||||
|
max.set(Math.max(max.get(), blastResistance));
|
||||||
|
sum.addAndGet(blastResistance);
|
||||||
|
count.getAndIncrement();
|
||||||
|
});
|
||||||
|
|
||||||
|
BauSystem.MESSAGE.send("BLASTRESISTANCE_RESULT", player, min.get(), max.get(), sum.get() / count.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,13 +42,6 @@ public class ReplayCommand extends SWCommand {
|
|||||||
super("replay");
|
super("replay");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
|
||||||
public void genericCommand(PlayerChatter sender) {
|
|
||||||
sender.system("REPLAY_UNAVAILABLE");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
@Register
|
@Register
|
||||||
public void genericCommand(PlayerChatter sender, int replayId, @StaticValue(value = {"", "-a"}, allowISE = true) @OptionalValue("") boolean isAdmin, @OptionalValue("") String optionalMap) {
|
public void genericCommand(PlayerChatter sender, int replayId, @StaticValue(value = {"", "-a"}, allowISE = true) @OptionalValue("") boolean isAdmin, @OptionalValue("") String optionalMap) {
|
||||||
Fight fight = Fight.getById(replayId);
|
Fight fight = Fight.getById(replayId);
|
||||||
@@ -64,6 +57,9 @@ public class ReplayCommand extends SWCommand {
|
|||||||
@Register
|
@Register
|
||||||
public void genericCommand(PlayerChatter sender, @OptionalValue("") String optionalMap) {
|
public void genericCommand(PlayerChatter sender, @OptionalValue("") String optionalMap) {
|
||||||
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer)) return;
|
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer)) return;
|
||||||
|
if (!sender.user().hasPerm(UserPerm.TEAM)) return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
new SWStreamInv<>(sender, new Message("REPLAY_TITLE"), (click, fight) -> {
|
new SWStreamInv<>(sender, new Message("REPLAY_TITLE"), (click, fight) -> {
|
||||||
startReplay(sender, click.isShiftClick(), optionalMap, fight);
|
startReplay(sender, click.isShiftClick(), optionalMap, fight);
|
||||||
@@ -72,6 +68,7 @@ public class ReplayCommand extends SWCommand {
|
|||||||
|
|
||||||
private void startReplay(PlayerChatter sender, boolean isAdmin, String optionalMap, Fight fight) {
|
private void startReplay(PlayerChatter sender, boolean isAdmin, String optionalMap, Fight fight) {
|
||||||
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer)) return;
|
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer)) return;
|
||||||
|
if (!sender.user().hasPerm(UserPerm.TEAM)) return;
|
||||||
|
|
||||||
GameModeConfig<String, String> mode = ArenaMode.getBySchemType(fight.getSchemType());
|
GameModeConfig<String, String> mode = ArenaMode.getBySchemType(fight.getSchemType());
|
||||||
ServerStarter starter = new ServerStarter().replay(fight.getFightID()).blueLeader(sender.getPlayer());
|
ServerStarter starter = new ServerStarter().replay(fight.getFightID()).blueLeader(sender.getPlayer());
|
||||||
@@ -116,5 +113,5 @@ public class ReplayCommand extends SWCommand {
|
|||||||
private Message parseLeader(SteamwarUser leader, int players, boolean winner) {
|
private Message parseLeader(SteamwarUser leader, int players, boolean winner) {
|
||||||
return new Message("REPLAY_" + (players > 1 ? "" : "SOLO_") + (winner ? "WINNER" : "LOSER"), leader.getUserName(), players - 1);
|
return new Message("REPLAY_" + (players > 1 ? "" : "SOLO_") + (winner ? "WINNER" : "LOSER"), leader.getUserName(), players - 1);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class DevServer extends DefaultTask {
|
|||||||
|
|
||||||
@Input
|
@Input
|
||||||
@Optional
|
@Optional
|
||||||
String worldName = null
|
boolean debug = false
|
||||||
|
|
||||||
@Input
|
@Input
|
||||||
String template = null
|
String template = null
|
||||||
@@ -84,10 +84,13 @@ class DevServer extends DefaultTask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (worldName == null) worldName = properties.get("worldName")
|
worldName = properties.get("worldName")
|
||||||
host = properties.get("host")
|
host = properties.get("host")
|
||||||
debugPort = new Random().nextInt(5001, 10000)
|
debugPort = new Random().nextInt(5001, 10000)
|
||||||
|
|
||||||
|
if (worldName == null) {
|
||||||
|
throw new GradleException("Please supply the 'worldName' in a 'steamwar.properties' files either in this project dir or any parent project!")
|
||||||
|
}
|
||||||
if (host == null) {
|
if (host == null) {
|
||||||
throw new GradleException("Please supply the 'host' in a 'steamwar.properties' files either in this project dir or any parent project!")
|
throw new GradleException("Please supply the 'host' in a 'steamwar.properties' files either in this project dir or any parent project!")
|
||||||
}
|
}
|
||||||
@@ -95,7 +98,7 @@ class DevServer extends DefaultTask {
|
|||||||
doLast {
|
doLast {
|
||||||
setupTemplate(template)
|
setupTemplate(template)
|
||||||
uploadDependencies()
|
uploadDependencies()
|
||||||
startDebugPort()
|
if (debug) startDebugPort()
|
||||||
startDevServer()
|
startDevServer()
|
||||||
}
|
}
|
||||||
finalizedBy(new Finalizer())
|
finalizedBy(new Finalizer())
|
||||||
@@ -113,6 +116,9 @@ class DevServer extends DefaultTask {
|
|||||||
@Internal
|
@Internal
|
||||||
Boolean running = true
|
Boolean running = true
|
||||||
|
|
||||||
|
@Internal
|
||||||
|
String worldName = null
|
||||||
|
|
||||||
class Finalizer extends DefaultTask {
|
class Finalizer extends DefaultTask {
|
||||||
|
|
||||||
Finalizer() {
|
Finalizer() {
|
||||||
@@ -241,7 +247,7 @@ class DevServer extends DefaultTask {
|
|||||||
devPy.append(" -D${dParam.key}=${dParam.value}")
|
devPy.append(" -D${dParam.key}=${dParam.value}")
|
||||||
}
|
}
|
||||||
devPy.append(" $template")
|
devPy.append(" $template")
|
||||||
devPy.append(" -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:$debugPort")
|
if (debug) devPy.append(" -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:$debugPort")
|
||||||
if (jvmArgs != null) devPy.append(" $jvmArgs")
|
if (jvmArgs != null) devPy.append(" $jvmArgs")
|
||||||
println("Starting $template with command ${devPy.toString()}")
|
println("Starting $template with command ${devPy.toString()}")
|
||||||
|
|
||||||
@@ -286,7 +292,7 @@ class VelocityServer extends DevServer {
|
|||||||
VelocityServer() {
|
VelocityServer() {
|
||||||
super()
|
super()
|
||||||
doFirst {
|
doFirst {
|
||||||
if(packetDecodeLogging) dParams.put("velocity.packet-decode-logging", "true")
|
if (packetDecodeLogging) dParams.put("velocity.packet-decode-logging", "true")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user