SteamWar/BauSystem2.0
Archiviert
12
0

Update messages
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-12-13 21:03:05 +01:00
Ursprung a04cc76bbe
Commit 5e774ad874
5 geänderte Dateien mit 28 neuen und 24 gelöschten Zeilen

Datei anzeigen

@ -40,6 +40,7 @@ SCOREBOARD_REGION = Region
SCOREBOARD_TRACE = Trace
SCOREBOARD_LOADER = Loader
SCOREBOARD_TPS = TPS
SCOREBOARD_TPS_FROZEN = §e Eingefroren
SCOREBOARD_TRACE_TICKS = Ticks

Datei anzeigen

@ -19,8 +19,10 @@
package de.steamwar.bausystem.features.tpslimit;
import lombok.Getter;
import lombok.experimental.UtilityClass;
import net.minecraft.server.v1_15_R1.WorldServer;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import yapion.utils.ReflectionsUtils;
@ -33,37 +35,35 @@ public class FreezeUtils {
private static final Field field;
public static final boolean freezeEnabled;
@Getter
private static boolean frozen = false;
private static final World world;
static {
field = ReflectionsUtils.getField(WorldServer.class, "freezed");
if (field != null) field.setAccessible(true);
freezeEnabled = field != null;
world = Bukkit.getWorlds().get(0);
}
public static void freeze(World world) {
public static void freeze() {
setFreeze(world, true);
}
public static void unfreeze(World world) {
public static void unfreeze() {
setFreeze(world, false);
}
public static boolean frozen(World world) {
if (freezeEnabled) {
try {
return (boolean) field.get(((CraftWorld) world).getHandle());
} catch (IllegalAccessException e) {
// Ignored;
}
}
return false;
public static boolean frozen() {
return freezeEnabled && frozen;
}
private void setFreeze(World world, boolean state) {
if (freezeEnabled) {
try {
System.out.println(state + " " + frozen(world));
field.set(((CraftWorld) world).getHandle(), state);
System.out.println(state + " " + frozen(world));
frozen = state;
} catch (IllegalAccessException e) {
// Ignored;
}

Datei anzeigen

@ -75,7 +75,7 @@ public class TPSLimitCommand extends SWCommand implements Enable {
public void valueCommand(Player p, /*@DoubleRange(min = 0.5, max = 60)*/ double tpsLimitDouble) {
if (!permissionCheck(p)) return;
if (FreezeUtils.freezeEnabled && tpsLimitDouble == 0) {
FreezeUtils.freeze(p.getWorld());
FreezeUtils.freeze();
TPSLimitUtils.currentTPSLimit = 20;
TPSLimitUtils.tpsLimiter();
sendNewTPSLimitMessage(true);
@ -85,7 +85,7 @@ public class TPSLimitCommand extends SWCommand implements Enable {
sendInvalidArgumentMessage(p);
return;
}
FreezeUtils.unfreeze(p.getWorld());
FreezeUtils.unfreeze();
TPSLimitUtils.currentTPSLimit = tpsLimitDouble;
TPSLimitUtils.tpsLimiter();
sendNewTPSLimitMessage(false);

Datei anzeigen

@ -72,11 +72,9 @@ public class TickCommand extends SWCommand {
Bukkit.getOnlinePlayers().forEach(player -> {
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("TICK_STEP", player, ticks));
});
FreezeUtils.unfreeze(p.getWorld());
FreezeUtils.unfreeze();
ticksLeft = new AtomicInteger(ticks);
disableTask = () -> {
FreezeUtils.freeze(p.getWorld());
};
disableTask = FreezeUtils::freeze;
}
@Register(value = {"warp"}, description = "TICK_WARP_HELP")
@ -87,16 +85,16 @@ public class TickCommand extends SWCommand {
Bukkit.getOnlinePlayers().forEach(player -> {
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("TICK_WARP", player, ticks));
});
boolean frozen = FreezeUtils.frozen(p.getWorld());
boolean frozen = FreezeUtils.frozen();
double currentTPSLimit = TPSLimitUtils.currentTPSLimit;
TPSLimitUtils.currentTPSLimit = 120;
TPSLimitUtils.currentTPSLimit = 240;
TPSLimitUtils.tpsLimiter();
FreezeUtils.unfreeze(p.getWorld());
FreezeUtils.unfreeze();
ticksLeft = new AtomicInteger(ticks);
disableTask = () -> {
if (frozen) {
FreezeUtils.freeze(p.getWorld());
FreezeUtils.freeze();
}
TPSLimitUtils.currentTPSLimit = currentTPSLimit;
TPSLimitUtils.tpsLimiter();

Datei anzeigen

@ -2,6 +2,7 @@ package de.steamwar.bausystem.features.world;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.loader.Loader;
import de.steamwar.bausystem.features.tpslimit.FreezeUtils;
import de.steamwar.bausystem.features.tpslimit.TPSLimitUtils;
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
import de.steamwar.bausystem.features.tpslimit.TPSWarpUtils;
@ -85,7 +86,11 @@ public class BauScoreboard implements Listener {
strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_LOADER", p) + "§8: " + BauSystem.MESSAGE.parse(loader != null ? loader.getStage().getChatValue() : "LOADER_OFF", p));
strings.add("§5");
if (FreezeUtils.frozen()) {
strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + BauSystem.MESSAGE.parse("SCOREBOARD_TPS_FROZEN", p));
} else {
strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8 " + tpsColor() + TPSWarpUtils.getTps(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit());
}
int i = strings.size();
HashMap<String, Integer> result = new HashMap<>();