diff --git a/.gitignore b/.gitignore index 3ef53412..cc1b960d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ steamwar.properties # VSCode bin/ .vscode +.settings # Other lib diff --git a/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/TpsWarper21.java b/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/TpsWarper21.java new file mode 100644 index 00000000..94e8d5d6 --- /dev/null +++ b/FightSystem/FightSystem_21/src/de/steamwar/fightsystem/utils/TpsWarper21.java @@ -0,0 +1,11 @@ +package de.steamwar.fightsystem.utils; + +import net.minecraft.server.MinecraftServer; + +public class TpsWarper21 implements TpsWarper { + + @Override + public void warp(float tps) { + MinecraftServer.getServer().tickRateManager().setTickRate(tps); + } +} diff --git a/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/TpsWarper8.java b/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/TpsWarper8.java new file mode 100644 index 00000000..3e73cb4b --- /dev/null +++ b/FightSystem/FightSystem_8/src/de/steamwar/fightsystem/utils/TpsWarper8.java @@ -0,0 +1,11 @@ +package de.steamwar.fightsystem.utils; + +import de.steamwar.core.TPSWarpUtils; + +public class TpsWarper8 implements TpsWarper { + + @Override + public void warp(float tps) { + TPSWarpUtils.warp(tps); + } +} diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TPSWarpCommand.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TPSWarpCommand.java index 434f373e..42bd72d6 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TPSWarpCommand.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/TPSWarpCommand.java @@ -1,20 +1,18 @@ /* - * This file is a part of the SteamWar software. + * This file is a part of the SteamWar software. * - * Copyright (C) 2025 SteamWar.de-Serverteam + * 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 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. + * 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 . + * 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; @@ -24,6 +22,7 @@ import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; +import de.steamwar.fightsystem.utils.TpsWarper; import de.steamwar.linkage.Linked; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -39,15 +38,17 @@ public class TPSWarpCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - double tps; + float tps; try { - tps = Double.parseDouble(args[0]); + tps = Float.parseFloat(args[0]); } catch (NumberFormatException | ArrayIndexOutOfBoundsException e) { FightSystem.getMessage().send("TPSWARP_HELP", sender); return false; } - TPSWarpUtils.warp(tps); + TpsWarper warper = TpsWarper.impl; + warper.warp(tps); + FightSystem.getMessage().broadcastActionbar("TPSWARP_SET", tps); return false; } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/TpsWarper.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/TpsWarper.java new file mode 100644 index 00000000..de7f5b31 --- /dev/null +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/TpsWarper.java @@ -0,0 +1,10 @@ +package de.steamwar.fightsystem.utils; + +import de.steamwar.core.VersionDependent; +import de.steamwar.fightsystem.FightSystem; + +public interface TpsWarper { + TpsWarper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin()); + + void warp(float tps); +}