forked from SteamWar/SteamWar
Merge pull request 'Add version dependant impl of tps warp to fight system' (#187) from FightSystem/Add-version-dependent-impl-of-tps-warp into main
Reviewed-on: SteamWar/SteamWar#187 Reviewed-by: Chaoscaot <max@chaoscaot.de>
This commit is contained in:
@@ -13,6 +13,7 @@ steamwar.properties
|
||||
# VSCode
|
||||
bin/
|
||||
.vscode
|
||||
.settings
|
||||
|
||||
# Other
|
||||
lib
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
+16
-15
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
* 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;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user