forked from SteamWar/SteamWar
Initial FightSWCommand
This commit is contained in:
@@ -39,6 +39,7 @@ public enum ArenaMode {
|
|||||||
public static final Set<ArenaMode> Test = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK));
|
public static final Set<ArenaMode> Test = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK));
|
||||||
public static final Set<ArenaMode> Prepare = Collections.unmodifiableSet(EnumSet.of(PREPARE));
|
public static final Set<ArenaMode> Prepare = Collections.unmodifiableSet(EnumSet.of(PREPARE));
|
||||||
public static final Set<ArenaMode> Replay = Collections.unmodifiableSet(EnumSet.of(REPLAY, TEST));
|
public static final Set<ArenaMode> Replay = Collections.unmodifiableSet(EnumSet.of(REPLAY, TEST));
|
||||||
|
public static final Set<ArenaMode> TestOrReferee = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK, EVENT));
|
||||||
|
|
||||||
public static final Set<ArenaMode> AntiReplay = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(REPLAY)));
|
public static final Set<ArenaMode> AntiReplay = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(REPLAY)));
|
||||||
public static final Set<ArenaMode> AntiTest = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK)));
|
public static final Set<ArenaMode> AntiTest = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK)));
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ package de.steamwar.fightsystem;
|
|||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.core.WorldEditRendererCUIEditor;
|
import de.steamwar.core.WorldEditRendererCUIEditor;
|
||||||
import de.steamwar.fightsystem.commands.TechareaCommand;
|
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.listener.ClickAnalyzer;
|
import de.steamwar.fightsystem.listener.ClickAnalyzer;
|
||||||
@@ -127,8 +126,6 @@ public class FightSystem extends JavaPlugin {
|
|||||||
if (checkSchematicNode.isPrepared()) {
|
if (checkSchematicNode.isPrepared()) {
|
||||||
Fight.getRedTeam().setSchem(checkSchematicNode, NodeData.getRevisions(checkSchematicNode) - 1);
|
Fight.getRedTeam().setSchem(checkSchematicNode, NodeData.getRevisions(checkSchematicNode) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
new TechareaCommand();
|
|
||||||
} else if (Config.mode == ArenaMode.PREPARE) {
|
} else if (Config.mode == ArenaMode.PREPARE) {
|
||||||
Fight.getUnrotated().setSchem(SchematicNode.getSchematicNode(Config.PrepareSchemID));
|
Fight.getUnrotated().setSchem(SchematicNode.getSchematicNode(Config.PrepareSchemID));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,35 +24,25 @@ import de.steamwar.fightsystem.ArenaMode;
|
|||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Kit;
|
import de.steamwar.fightsystem.fight.Kit;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.UserPerm;
|
import de.steamwar.sql.UserPerm;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class AkCommand implements CommandExecutor {
|
public class AkCommand extends FightSWCommand {
|
||||||
|
|
||||||
public AkCommand() {
|
public AkCommand() {
|
||||||
new StateDependentCommand(ArenaMode.Test, FightState.All, "ak", this);
|
super(ArenaMode.Test, FightState.All, "ak");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean hasPerm(Player player, SteamwarUser user) {
|
||||||
if (!(sender instanceof Player)) {
|
return player.isOp() && user.hasPerm(UserPerm.ADMINISTRATION) && Core.getInstance() != FightSystem.getPlugin();
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
Player player = (Player) sender;
|
|
||||||
if (!player.isOp()) return false;
|
|
||||||
|
|
||||||
if (!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.ADMINISTRATION) && Core.getInstance() != FightSystem.getPlugin()) {
|
@Register
|
||||||
return false;
|
public void run(@Validator Player player, String name) {
|
||||||
}
|
Kit.createKit(name, player);
|
||||||
|
|
||||||
Kit.createKit(args[0], player);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* 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.fightsystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.command.TypeValidator;
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerCommandSendEvent;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public abstract class FightSWCommand extends SWCommand implements Listener {
|
||||||
|
|
||||||
|
private final String command;
|
||||||
|
private final String[] aliases;
|
||||||
|
|
||||||
|
protected FightSWCommand(Set<ArenaMode> mode, Set<FightState> states, String command) {
|
||||||
|
super(command);
|
||||||
|
this.command = command;
|
||||||
|
this.aliases = new String[0];
|
||||||
|
stateDependant(mode, states);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected FightSWCommand(Set<ArenaMode> mode, Set<FightState> states, String command, String... aliases) {
|
||||||
|
super(command, aliases);
|
||||||
|
this.command = command;
|
||||||
|
this.aliases = aliases;
|
||||||
|
stateDependant(mode, states);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stateDependant(Set<ArenaMode> mode, Set<FightState> states) {
|
||||||
|
FightSWCommand.this.unregister();
|
||||||
|
new StateDependent(mode, states) {
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
System.out.println("--- Enable: " + command);
|
||||||
|
FightSWCommand.this.register();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
System.out.println("--- Disable: " + command);
|
||||||
|
FightSWCommand.this.unregister();
|
||||||
|
}
|
||||||
|
}.register();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void postFightStateChange() {
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
player.updateCommands();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean hasPerm(Player player, SteamwarUser user) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
public final void onPlayerCommandSend(PlayerCommandSendEvent event) {
|
||||||
|
if (hasPerm(event.getPlayer(), SteamwarUser.get(event.getPlayer().getUniqueId()))) return;
|
||||||
|
event.getCommands().remove(command);
|
||||||
|
for (String alias : aliases) {
|
||||||
|
event.getCommands().remove(alias);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ClassValidator(value = Player.class, local = true)
|
||||||
|
public final TypeValidator<Player> permissionCheck() {
|
||||||
|
return (sender, value, messageSender) -> hasPerm(value, SteamwarUser.get(value.getUniqueId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
-74
@@ -19,92 +19,28 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.commands;
|
package de.steamwar.fightsystem.commands;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.defaults.BukkitCommand;
|
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.StringUtil;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class GamemodeCommand extends BukkitCommand {
|
public class GamemodeCommand extends FightSWCommand {
|
||||||
|
|
||||||
private static final List<String> GAMEMODE_NAMES = ImmutableList.of("adventure", "creative", "survival",
|
|
||||||
"spectator");
|
|
||||||
|
|
||||||
public GamemodeCommand() {
|
public GamemodeCommand() {
|
||||||
super("gamemode");
|
super(ArenaMode.TestOrReferee, FightState.All, "gamemode", "gm");
|
||||||
List<String> aliases = new ArrayList<>();
|
|
||||||
aliases.add("gm");
|
|
||||||
this.setAliases(aliases);
|
|
||||||
|
|
||||||
Map<String, Command> knownCommands = ((CraftServer) Bukkit.getServer()).getCommandMap().getKnownCommands();
|
|
||||||
knownCommands.remove("gamemode");
|
|
||||||
Commands.injectCommand(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
|
protected boolean hasPerm(Player player, SteamwarUser user) {
|
||||||
if (!(sender instanceof Player)) {
|
return Config.test() || Config.isReferee(player);
|
||||||
return false;
|
|
||||||
} else if (args.length == 0) {
|
|
||||||
FightSystem.getMessage().sendPrefixless("GAMEMODE_HELP", sender);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player p = (Player) sender;
|
|
||||||
|
|
||||||
if (!(Config.test() || Config.isReferee(p))) {
|
|
||||||
FightSystem.getMessage().sendPrefixless("GAMEMODE_NOT_ALLOWED", p, ChatMessageType.ACTION_BAR);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameMode mode = createMode(args[0]);
|
|
||||||
|
|
||||||
if (mode == null) {
|
|
||||||
FightSystem.getMessage().sendPrefixless("GAMEMODE_UNKNOWN", p, ChatMessageType.ACTION_BAR, args[0]);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.setGameMode(mode);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@Register(description = "GAMEMODE_HELP")
|
||||||
private GameMode createMode(String modeArg) {
|
public void execute(@Validator Player player, GameMode gameMode) {
|
||||||
try {
|
player.setGameMode(gameMode);
|
||||||
return GameMode.getByValue(Integer.parseInt(modeArg));
|
|
||||||
} catch (NumberFormatException ignored) {
|
|
||||||
if ((modeArg.equalsIgnoreCase("creative")) || (modeArg.equalsIgnoreCase("c"))) {
|
|
||||||
return GameMode.CREATIVE;
|
|
||||||
} else if ((modeArg.equalsIgnoreCase("adventure")) || (modeArg.equalsIgnoreCase("a"))) {
|
|
||||||
return GameMode.ADVENTURE;
|
|
||||||
} else if ((modeArg.equalsIgnoreCase("spectator")) || (modeArg.equalsIgnoreCase("sp"))) {
|
|
||||||
return GameMode.SPECTATOR;
|
|
||||||
} else if ((modeArg.equalsIgnoreCase("survival")) || (modeArg.equalsIgnoreCase("s"))) {
|
|
||||||
return GameMode.SURVIVAL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> tabComplete(CommandSender sender, String alias, String[] args) {
|
|
||||||
if (args.length == 1) {
|
|
||||||
return StringUtil.copyPartialMatches(args[0], GAMEMODE_NAMES, new ArrayList<>(GAMEMODE_NAMES.size()));
|
|
||||||
}
|
|
||||||
return ImmutableList.of();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,34 +20,31 @@
|
|||||||
package de.steamwar.fightsystem.commands;
|
package de.steamwar.fightsystem.commands;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
|
import de.steamwar.fightsystem.listener.Check;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.UserPerm;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class InfoCommand implements CommandExecutor {
|
public class InfoCommand extends FightSWCommand {
|
||||||
|
|
||||||
public InfoCommand() {
|
public InfoCommand() {
|
||||||
new StateDependentCommand(ArenaMode.All, FightState.All, "fightinfo", this);
|
super(ArenaMode.All, FightState.All, "fightinfo");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean hasPerm(Player player, SteamwarUser user) {
|
||||||
if (!(sender instanceof Player)) return false;
|
return Check.checkPermission(user, Config.GameModeConfig);
|
||||||
|
}
|
||||||
Player player = (Player) sender;
|
|
||||||
if (!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.CHECK)) return false;
|
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void run(@Validator Player player) {
|
||||||
for (FightTeam team : Fight.teams()) {
|
for (FightTeam team : Fight.teams()) {
|
||||||
if (!team.isLeaderless()) {
|
if (!team.isLeaderless()) {
|
||||||
FightSystem.getMessage().send("INFO_LEADER", player, team.getColoredName(), team.getLeader().getEntity().getName());
|
FightSystem.getMessage().send("INFO_LEADER", player, team.getColoredName(), team.getLeader().getEntity().getName());
|
||||||
@@ -58,6 +55,5 @@ public class InfoCommand implements CommandExecutor {
|
|||||||
FightSystem.getMessage().send("INFO_SCHEMATIC", player, team.getColoredName(), schematic.getName(), SteamwarUser.byId(schematic.getOwner()).getUserName(), schematic.getRank());
|
FightSystem.getMessage().send("INFO_SCHEMATIC", player, team.getColoredName(), schematic.getName(), SteamwarUser.byId(schematic.getOwner()).getUserName(), schematic.getRank());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,32 +21,23 @@ package de.steamwar.fightsystem.commands;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class KitCommand implements CommandExecutor {
|
public class KitCommand extends FightSWCommand {
|
||||||
|
|
||||||
public KitCommand() {
|
public KitCommand() {
|
||||||
new StateDependentCommand(ArenaMode.AntiReplay, FightState.Setup, "kit", this);
|
super(ArenaMode.AntiReplay, FightState.Setup, "kit");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Register
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void execute(Player player) {
|
||||||
if (!(sender instanceof Player)) {
|
GUI.kitSelection(player, "");
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
if (args.length != 1) {
|
@Register
|
||||||
GUI.kitSelection(player, "");
|
public void execute(Player player, String query) { // TODO: TabCompletion of Kit Names!
|
||||||
} else {
|
GUI.kitSelection(player, query);
|
||||||
Commands.kit(player, args[0]);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-14
@@ -21,28 +21,18 @@ package de.steamwar.fightsystem.commands;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class LeaveCommand implements CommandExecutor {
|
public class LeaveCommand extends FightSWCommand {
|
||||||
|
|
||||||
public LeaveCommand() {
|
public LeaveCommand() {
|
||||||
new StateDependentCommand(ArenaMode.AntiReplay, FightState.Setup, "leave", this);
|
super(ArenaMode.AntiReplay, FightState.Setup, "leave");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Register
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void execute(Player player) {
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
Commands.leaveTeam(player);
|
Commands.leaveTeam(player);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-20
@@ -20,52 +20,42 @@
|
|||||||
package de.steamwar.fightsystem.commands;
|
package de.steamwar.fightsystem.commands;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
|
import de.steamwar.fightsystem.listener.Check;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import de.steamwar.sql.SchematicType;
|
import de.steamwar.sql.SchematicType;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.UserPerm;
|
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class LockschemCommand implements CommandExecutor {
|
public class LockschemCommand extends FightSWCommand {
|
||||||
|
|
||||||
public LockschemCommand() {
|
public LockschemCommand() {
|
||||||
new StateDependentCommand(ArenaMode.All, FightState.Schem, "lockschem", this);
|
super(ArenaMode.All, FightState.Schem, "lockschem");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean hasPerm(Player player, SteamwarUser user) {
|
||||||
if (!(sender instanceof Player)) return false;
|
return Check.checkPermission(user, Config.GameModeConfig);
|
||||||
Player player = (Player) sender;
|
}
|
||||||
|
|
||||||
if (!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.CHECK)) return false;
|
@Register(description = "LOCKSCHEM_HELP")
|
||||||
|
public void execute(@Validator Player player, String teamName) {
|
||||||
if (args.length != 1) {
|
|
||||||
FightSystem.getMessage().sendPrefixless("LOCKSCHEM_HELP", player);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String teamName = args[0];
|
|
||||||
FightTeam fightTeam = Fight.getTeamByName(teamName);
|
FightTeam fightTeam = Fight.getTeamByName(teamName);
|
||||||
|
|
||||||
if (fightTeam == null) {
|
if (fightTeam == null) {
|
||||||
FightSystem.getMessage().sendPrefixless("UNKNOWN_TEAM", player, ChatMessageType.ACTION_BAR);
|
FightSystem.getMessage().sendPrefixless("UNKNOWN_TEAM", player, ChatMessageType.ACTION_BAR);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SchematicNode.getSchematicNode(fightTeam.getSchematic()).setSchemtype(SchematicType.Normal);
|
SchematicNode.getSchematicNode(fightTeam.getSchematic()).setSchemtype(SchematicType.Normal);
|
||||||
FightSystem.getMessage().sendPrefixless("LOCKSCHEM_LOCKED", player, ChatMessageType.ACTION_BAR);
|
FightSystem.getMessage().sendPrefixless("LOCKSCHEM_LOCKED", player, ChatMessageType.ACTION_BAR);
|
||||||
fightTeam.broadcastSystem("LOCKSCHEM_LOCKED_BY", player.getName());
|
fightTeam.broadcastSystem("LOCKSCHEM_LOCKED_BY", player.getName());
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-14
@@ -21,28 +21,18 @@ package de.steamwar.fightsystem.commands;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class ReadyCommand implements CommandExecutor {
|
public class ReadyCommand extends FightSWCommand {
|
||||||
|
|
||||||
public ReadyCommand() {
|
public ReadyCommand() {
|
||||||
new StateDependentCommand(ArenaMode.AntiPrepare, FightState.PostSchemSetup, "ready", this);
|
super(ArenaMode.AntiPrepare, FightState.PostSchemSetup, "ready");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Register
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void execute(Player player) {
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
Commands.toggleReady(player);
|
Commands.toggleReady(player);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-21
@@ -20,35 +20,19 @@
|
|||||||
package de.steamwar.fightsystem.commands;
|
package de.steamwar.fightsystem.commands;
|
||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class RemoveCommand implements CommandExecutor {
|
public class RemoveCommand extends FightSWCommand {
|
||||||
|
|
||||||
public RemoveCommand() {
|
public RemoveCommand() {
|
||||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "remove", this);
|
super(ArenaMode.VariableTeams, FightState.Setup, "remove");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Register(description = "REMOVE_HELP")
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void execute(Player player, Player teamMember) {
|
||||||
if (!(sender instanceof Player)) {
|
Commands.kick(player, teamMember.getName());
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
if (args.length != 1) {
|
|
||||||
FightSystem.getMessage().sendPrefixless("REMOVE_HELP", player);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Commands.kick(player, args[0]);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-15
@@ -26,37 +26,28 @@ import de.steamwar.fightsystem.fight.FightPlayer;
|
|||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.fight.JoinRequest;
|
import de.steamwar.fightsystem.fight.JoinRequest;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class RequestsCommand implements CommandExecutor {
|
public class RequestsCommand extends FightSWCommand {
|
||||||
|
|
||||||
public RequestsCommand() {
|
public RequestsCommand() {
|
||||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.AntiSpectate, "request", this);
|
super(ArenaMode.VariableTeams, FightState.AntiSpectate, "request", "requests");
|
||||||
new StateDependentCommand(ArenaMode.VariableTeams, FightState.AntiSpectate, "requests", this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Register
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void execute(Player player) {
|
||||||
if (!(sender instanceof Player)) return false;
|
|
||||||
Player player = (Player) sender;
|
|
||||||
FightPlayer fp = Fight.getFightPlayer(player);
|
FightPlayer fp = Fight.getFightPlayer(player);
|
||||||
if (fp == null || !(fp.isLeader() || fp.isLiving())) {
|
if (fp == null || !(fp.isLeader() || fp.isLiving())) {
|
||||||
GUI.joinRequest(player);
|
GUI.joinRequest(player);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Commands.checkGetLeader(player) == null) return false;
|
if (Commands.checkGetLeader(player) == null) return;
|
||||||
|
|
||||||
GUI.chooseJoinRequests(player);
|
GUI.chooseJoinRequests(player);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onJoinRequest(Player player, JoinRequest request, BiConsumer<JoinRequest, FightTeam> handleJoinRequest) {
|
public static void onJoinRequest(Player player, JoinRequest request, BiConsumer<JoinRequest, FightTeam> handleJoinRequest) {
|
||||||
|
|||||||
@@ -24,32 +24,22 @@ import de.steamwar.fightsystem.Config;
|
|||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.record.PacketProcessor;
|
import de.steamwar.fightsystem.record.PacketProcessor;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class SkipCommand implements CommandExecutor {
|
public class SkipCommand extends FightSWCommand {
|
||||||
|
|
||||||
public SkipCommand() {
|
public SkipCommand() {
|
||||||
new StateDependentCommand(ArenaMode.AntiPrepare, ArenaMode.Replay.contains(Config.mode) ? FightState.All : FightState.TeamFix, "skip", this);
|
super(ArenaMode.AntiPrepare, ArenaMode.Replay.contains(Config.mode) ? FightState.All : FightState.TeamFix, "skip");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Register
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void execute(Player player) {
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
if (PacketProcessor.isReplaying() && player.getUniqueId().equals(Fight.getBlueTeam().getDesignatedLeader())) {
|
if (PacketProcessor.isReplaying() && player.getUniqueId().equals(Fight.getBlueTeam().getDesignatedLeader())) {
|
||||||
PacketProcessor.currentReplay().skipToSubtitle();
|
PacketProcessor.currentReplay().skipToSubtitle();
|
||||||
} else {
|
} else {
|
||||||
Commands.toggleSkip(player);
|
Commands.toggleSkip(player);
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-14
@@ -21,27 +21,18 @@ package de.steamwar.fightsystem.commands;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class StateCommand implements CommandExecutor {
|
public class StateCommand extends FightSWCommand {
|
||||||
|
|
||||||
public StateCommand() {
|
public StateCommand() {
|
||||||
new StateDependentCommand(ArenaMode.Test, FightState.All, "state", this);
|
super(ArenaMode.Test, FightState.All, "state");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Register
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void execute(Player player) {
|
||||||
if (!(sender instanceof Player)) {
|
GUI.state(player);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
GUI.state((Player) sender);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,26 +22,18 @@ package de.steamwar.fightsystem.commands;
|
|||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class TBCommand implements CommandExecutor {
|
public class TBCommand extends FightSWCommand {
|
||||||
|
|
||||||
public TBCommand() {
|
public TBCommand() {
|
||||||
new StateDependentCommand(ArenaMode.Check, FightState.All, "resettb", this);
|
super(ArenaMode.Check, FightState.All, "resettb");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Register
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void execute(Player player) {
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Fight.getRedTeam().pasteSchem();
|
Fight.getRedTeam().pasteSchem();
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-19
@@ -20,34 +20,20 @@ package de.steamwar.fightsystem.commands;
|
|||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class TPSWarpCommand implements CommandExecutor {
|
public class TPSWarpCommand extends FightSWCommand {
|
||||||
|
|
||||||
public TPSWarpCommand() {
|
public TPSWarpCommand() {
|
||||||
new StateDependentCommand(ArenaMode.Prepare, FightState.PostSchemSetup, "tpswarp", this);
|
super(ArenaMode.Prepare, FightState.PostSchemSetup, "tpswarp", "tpslimit");
|
||||||
new StateDependentCommand(ArenaMode.Prepare, FightState.PostSchemSetup, "tpslimit", this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Register(description = "TPSWARP_HELP")
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void execute(Player player, float tps) {
|
||||||
float tps;
|
|
||||||
try {
|
|
||||||
tps = Float.parseFloat(args[0]);
|
|
||||||
} catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {
|
|
||||||
FightSystem.getMessage().send("TPSWARP_HELP", sender);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
MinecraftServer.getServer().tickRateManager().setTickRate(tps);
|
MinecraftServer.getServer().tickRateManager().setTickRate(tps);
|
||||||
|
|
||||||
FightSystem.getMessage().broadcastActionbar("TPSWARP_SET", tps);
|
FightSystem.getMessage().broadcastActionbar("TPSWARP_SET", tps);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-21
@@ -19,42 +19,39 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.commands;
|
package de.steamwar.fightsystem.commands;
|
||||||
|
|
||||||
import de.steamwar.command.SWCommand;
|
|
||||||
import de.steamwar.entity.CWireframe;
|
import de.steamwar.entity.CWireframe;
|
||||||
import de.steamwar.entity.REntityServer;
|
import de.steamwar.entity.REntityServer;
|
||||||
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import org.bukkit.Bukkit;
|
import de.steamwar.fightsystem.states.OneShotStateDependent;
|
||||||
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.HashMap;
|
@Linked
|
||||||
import java.util.Map;
|
public class TechareaCommand extends FightSWCommand {
|
||||||
import java.util.UUID;
|
private REntityServer entityServer = new REntityServer();
|
||||||
|
|
||||||
public class TechareaCommand extends SWCommand {
|
|
||||||
private final Map<UUID, REntityServer> servers = new HashMap<>();
|
|
||||||
|
|
||||||
public TechareaCommand() {
|
public TechareaCommand() {
|
||||||
super("techarea");
|
super(ArenaMode.Check, FightState.All, "techarea");
|
||||||
|
new OneShotStateDependent(ArenaMode.Check, FightState.All, () -> {
|
||||||
Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), () -> servers.forEach((uuid, rEntityServer) -> rEntityServer.tick()), 2, 2);
|
if (!entityServer.getEntities().isEmpty()) return;
|
||||||
}
|
|
||||||
|
|
||||||
@Register
|
|
||||||
public void genericCommand(Player player) {
|
|
||||||
if (servers.containsKey(player.getUniqueId())) {
|
|
||||||
servers.get(player.getUniqueId()).close();
|
|
||||||
} else {
|
|
||||||
REntityServer server = new REntityServer();
|
REntityServer server = new REntityServer();
|
||||||
CWireframe wireframe = new CWireframe(server);
|
CWireframe wireframe = new CWireframe(server);
|
||||||
|
|
||||||
wireframe.setPos1(Config.BlueInsetRegion.getMinLocation(Config.world));
|
wireframe.setPos1(Config.BlueInsetRegion.getMinLocation(Config.world));
|
||||||
wireframe.setPos2(Config.BlueInsetRegion.getMaxLocation(Config.world).subtract(1, 1, 1));
|
wireframe.setPos2(Config.BlueInsetRegion.getMaxLocation(Config.world).subtract(1, 1, 1));
|
||||||
wireframe.setBlock(Material.RED_CONCRETE.createBlockData());
|
wireframe.setBlock(Material.RED_CONCRETE.createBlockData());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
server.addPlayer(player);
|
@Register
|
||||||
servers.put(player.getUniqueId(), server);
|
public void genericCommand(Player player) {
|
||||||
|
if (entityServer.getPlayers().contains(player)) {
|
||||||
|
entityServer.removePlayer(player);
|
||||||
|
} else {
|
||||||
|
entityServer.addPlayer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-10
@@ -25,27 +25,24 @@ import de.steamwar.fightsystem.Config;
|
|||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.sql.SWException;
|
import de.steamwar.sql.SWException;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class TechhiderbugCommand implements CommandExecutor {
|
public class TechhiderbugCommand extends FightSWCommand {
|
||||||
|
|
||||||
public TechhiderbugCommand() {
|
public TechhiderbugCommand() {
|
||||||
new StateDependentCommand(ArenaMode.All, FightState.All, "techhiderbug", this);
|
super(ArenaMode.All, FightState.All, "techhiderbug");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Register
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
|
public void execute(Player player, String... args) {
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -76,7 +73,6 @@ public class TechhiderbugCommand implements CommandExecutor {
|
|||||||
Bukkit.getLogger().log(Level.SEVERE, "Error while generating bug report", e);
|
Bukkit.getLogger().log(Level.SEVERE, "Error while generating bug report", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
SWException.log("Techhider-Bug reported by " + sender.getName() + ": " + Arrays.toString(args), writer.toString());
|
SWException.log("Techhider-Bug reported by " + player.getName() + ": " + Arrays.toString(args), writer.toString());
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,28 +23,20 @@ import de.steamwar.fightsystem.ArenaMode;
|
|||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightWorld;
|
import de.steamwar.fightsystem.fight.FightWorld;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class WGCommand implements CommandExecutor {
|
public class WGCommand extends FightSWCommand {
|
||||||
|
|
||||||
public WGCommand() {
|
public WGCommand() {
|
||||||
new StateDependentCommand(ArenaMode.Check, FightState.All, "resetwg", this);
|
super(ArenaMode.Check, FightState.All, "resetwg");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Register
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void execute(Player player) {
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
FightWorld.resetWorld();
|
FightWorld.resetWorld();
|
||||||
Fight.getBlueTeam().pasteSchem();
|
Fight.getBlueTeam().pasteSchem();
|
||||||
Fight.getRedTeam().pasteSchem();
|
Fight.getRedTeam().pasteSchem();
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,49 +25,34 @@ import de.steamwar.fightsystem.FightSystem;
|
|||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentCommand;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class WinCommand implements CommandExecutor {
|
public class WinCommand extends FightSWCommand {
|
||||||
|
|
||||||
public WinCommand() {
|
public WinCommand() {
|
||||||
new StateDependentCommand(ArenaMode.Event, FightState.Ingame, "win", this);
|
super(ArenaMode.Event, FightState.Ingame, "win");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
protected boolean hasPerm(Player player, SteamwarUser user) {
|
||||||
if (!(sender instanceof Player)) {
|
return Config.isReferee(player);
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
Player p = (Player) sender;
|
|
||||||
|
|
||||||
if (!Config.isReferee(p)) {
|
@Register
|
||||||
FightSystem.getMessage().sendPrefixless("NOT_FIGHTLEADER", p, ChatMessageType.ACTION_BAR);
|
public void execute(@Validator Player player, String teamName) {
|
||||||
return false;
|
if (teamName.equalsIgnoreCase("tie")) {
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 0) {
|
|
||||||
FightSystem.getMessage().sendPrefixless("WIN_HELP", p);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("tie")) {
|
|
||||||
FightSystem.setSpectateState(null, "Referee", "WIN_FIGHTLEADER");
|
FightSystem.setSpectateState(null, "Referee", "WIN_FIGHTLEADER");
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (FightTeam team : Fight.teams()) {
|
for (FightTeam team : Fight.teams()) {
|
||||||
if (args[0].equalsIgnoreCase(team.getName())) {
|
if (teamName.equalsIgnoreCase(team.getName())) {
|
||||||
FightSystem.setSpectateState(team, "Referee", "WIN_FIGHTLEADER");
|
FightSystem.setSpectateState(team, "Referee", "WIN_FIGHTLEADER");
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ public class Check implements Listener {
|
|||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
if (gameModeConfig == null) gameModeConfig = GameModeConfig.getDefaults();
|
if (gameModeConfig == null) gameModeConfig = GameModeConfig.getDefaults();
|
||||||
|
return checkPermission(user, gameModeConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean checkPermission(SteamwarUser user, GameModeConfig gameModeConfig) {
|
||||||
if (user.hasPerm(UserPerm.ADMINISTRATION)) return true;
|
if (user.hasPerm(UserPerm.ADMINISTRATION)) return true;
|
||||||
if (gameModeConfig.Checkers.isEmpty() && user.hasPerm(UserPerm.CHECK)) return true;
|
if (gameModeConfig.Checkers.isEmpty() && user.hasPerm(UserPerm.CHECK)) return true;
|
||||||
return gameModeConfig.Checkers.contains(user.getId());
|
return gameModeConfig.Checkers.contains(user.getId());
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.states;
|
package de.steamwar.fightsystem.states;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.commands.FightSWCommand;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -62,6 +63,7 @@ public enum FightState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setFightState(FightState state) {
|
public static void setFightState(FightState state) {
|
||||||
|
if (fightState.equals(state)) return;
|
||||||
fightState = state;
|
fightState = state;
|
||||||
|
|
||||||
for (Map.Entry<IStateDependent, Boolean> feature : stateDependentFeatures.entrySet()) {
|
for (Map.Entry<IStateDependent, Boolean> feature : stateDependentFeatures.entrySet()) {
|
||||||
@@ -77,6 +79,7 @@ public enum FightState {
|
|||||||
feature.setValue(false);
|
feature.setValue(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FightSWCommand.postFightStateChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean setup() {
|
public static boolean setup() {
|
||||||
|
|||||||
-58
@@ -1,58 +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.fightsystem.states;
|
|
||||||
|
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.PluginCommand;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class StateDependentCommand extends StateDependent {
|
|
||||||
|
|
||||||
private static final CommandExecutor unavailable = (sender, cmd, s, strings) -> {
|
|
||||||
FightSystem.getMessage().sendPrefixless("COMMAND_CURRENTLY_UNAVAILABLE", sender, ChatMessageType.ACTION_BAR);
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
private final PluginCommand command;
|
|
||||||
private final CommandExecutor executor;
|
|
||||||
|
|
||||||
public StateDependentCommand(Set<ArenaMode> mode, Set<FightState> states, String name, CommandExecutor executor) {
|
|
||||||
super(mode, states);
|
|
||||||
this.executor = executor;
|
|
||||||
this.command = FightSystem.getPlugin().getCommand(name);
|
|
||||||
assert command != null;
|
|
||||||
disable();
|
|
||||||
register();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enable() {
|
|
||||||
command.setExecutor(executor);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void disable() {
|
|
||||||
command.setExecutor(unavailable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -11,21 +11,3 @@ depend:
|
|||||||
api-version: "1.13"
|
api-version: "1.13"
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
ak:
|
|
||||||
request:
|
|
||||||
requests:
|
|
||||||
fightinfo:
|
|
||||||
leave:
|
|
||||||
ready:
|
|
||||||
kit:
|
|
||||||
remove:
|
|
||||||
lockschem:
|
|
||||||
state:
|
|
||||||
skip:
|
|
||||||
win:
|
|
||||||
resetwg:
|
|
||||||
resettb:
|
|
||||||
tpslimit:
|
|
||||||
tpswarp:
|
|
||||||
techhiderbug:
|
|
||||||
unrank:
|
|
||||||
@@ -53,3 +53,15 @@ tasks.register<FightServer>("WarGear21") {
|
|||||||
config = "WarGear21.yml"
|
config = "WarGear21.yml"
|
||||||
jar = "/jars/paper-1.21.6.jar"
|
jar = "/jars/paper-1.21.6.jar"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.register<FightServer>("WarShip21") {
|
||||||
|
group = "run"
|
||||||
|
description = "Run a WarShip 1.21 Fight Server"
|
||||||
|
dependsOn(":SpigotCore:shadowJar")
|
||||||
|
dependsOn(":FightSystem:shadowJar")
|
||||||
|
dependsOn(":KotlinCore:shadowJar")
|
||||||
|
template = "WarShip21"
|
||||||
|
worldName = "arenas/Artic"
|
||||||
|
config = "WarShip21.yml"
|
||||||
|
jar = "/jars/paper-1.21.6.jar"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user