From c87bac641ee65aa3157a9b24695f7b4dad0bd781 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 11 Oct 2023 10:56:05 +0200 Subject: [PATCH] TPS Warp Signed-off-by: Lixfel --- .../de/steamwar/fightsystem/FightSystem.java | 1 + .../fightsystem/FightSystem.properties | 3 ++ .../fightsystem/FightSystem_de.properties | 3 ++ .../fightsystem/commands/TPSWarpCommand.java | 52 +++++++++++++++++++ FightSystem_Core/src/plugin.yml | 2 + 5 files changed, 61 insertions(+) create mode 100644 FightSystem_Core/src/de/steamwar/fightsystem/commands/TPSWarpCommand.java diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java index e6ae767..78bb14c 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java @@ -156,6 +156,7 @@ public class FightSystem extends JavaPlugin { new LockschemCommand(); new StateCommand(); new SkipCommand(); + new TPSWarpCommand(); new UnrankCommand(); new WinCommand(); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties index c2590cd..3c220d6 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties @@ -51,6 +51,9 @@ INFO_RANKED=§7Ranked§8: §e{0} INFO_LEADER=§7Leader {0}§8: {1} INFO_SCHEMATIC=§7Schematic {0}§8: §e{1} §7from {2}, Rank: {3} +TPSWARP_HELP=§8/§7tpswarp §8[§eticks per second§8] +TPSWARP_SET=§7TPS set to §e{0} + # GUI STATE_TITLE=Fight state diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties index 62b7861..06b07d1 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties @@ -45,6 +45,9 @@ REMOVE_HELP=§8/§eremove §8[§eSpieler§8] NOT_FIGHTLEADER=§cDu bist nicht Kampfleiter WIN_HELP=§8/§7win §8[§eTeam §8oder §etie§8] +TPSWARP_HELP=§8/§7tpswarp §8[§eTicks pro Sekunde§8] +TPSWARP_SET=§7TPS auf §e{0} §7gesetzt + # GUI STATE_TITLE=Kampfstatus diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/commands/TPSWarpCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/TPSWarpCommand.java new file mode 100644 index 0000000..27927f7 --- /dev/null +++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/TPSWarpCommand.java @@ -0,0 +1,52 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.fightsystem.commands; + +import de.steamwar.core.TPSWarpUtils; +import de.steamwar.fightsystem.ArenaMode; +import de.steamwar.fightsystem.FightSystem; +import de.steamwar.fightsystem.states.FightState; +import de.steamwar.fightsystem.states.StateDependentCommand; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +public class TPSWarpCommand implements CommandExecutor { + + public TPSWarpCommand() { + new StateDependentCommand(ArenaMode.Prepare, FightState.PostSchemSetup, "tpswarp", this); + new StateDependentCommand(ArenaMode.Prepare, FightState.PostSchemSetup, "tpslimit", this); + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + double tps; + try { + tps = Double.parseDouble(args[0]); + } catch (NumberFormatException | ArrayIndexOutOfBoundsException e) { + FightSystem.getMessage().send("TPSWARP_HELP", sender); + return false; + } + + TPSWarpUtils.warp(tps); + FightSystem.getMessage().broadcastActionbar("TPSWARP_SET", tps); + return false; + } +} diff --git a/FightSystem_Core/src/plugin.yml b/FightSystem_Core/src/plugin.yml index f0df4c2..d876395 100644 --- a/FightSystem_Core/src/plugin.yml +++ b/FightSystem_Core/src/plugin.yml @@ -26,4 +26,6 @@ commands: win: resetwg: resettb: + tpslimit: + tpswarp: unrank: \ No newline at end of file -- 2.39.5