Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
a04cc76bbe
Commit
5e774ad874
@ -40,6 +40,7 @@ SCOREBOARD_REGION = Region
|
|||||||
SCOREBOARD_TRACE = Trace
|
SCOREBOARD_TRACE = Trace
|
||||||
SCOREBOARD_LOADER = Loader
|
SCOREBOARD_LOADER = Loader
|
||||||
SCOREBOARD_TPS = TPS
|
SCOREBOARD_TPS = TPS
|
||||||
|
SCOREBOARD_TPS_FROZEN = §e Eingefroren
|
||||||
|
|
||||||
SCOREBOARD_TRACE_TICKS = Ticks
|
SCOREBOARD_TRACE_TICKS = Ticks
|
||||||
|
|
||||||
|
@ -19,8 +19,10 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.tpslimit;
|
package de.steamwar.bausystem.features.tpslimit;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.minecraft.server.v1_15_R1.WorldServer;
|
import net.minecraft.server.v1_15_R1.WorldServer;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||||
import yapion.utils.ReflectionsUtils;
|
import yapion.utils.ReflectionsUtils;
|
||||||
@ -33,37 +35,35 @@ public class FreezeUtils {
|
|||||||
private static final Field field;
|
private static final Field field;
|
||||||
public static final boolean freezeEnabled;
|
public static final boolean freezeEnabled;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private static boolean frozen = false;
|
||||||
|
|
||||||
|
private static final World world;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
field = ReflectionsUtils.getField(WorldServer.class, "freezed");
|
field = ReflectionsUtils.getField(WorldServer.class, "freezed");
|
||||||
if (field != null) field.setAccessible(true);
|
if (field != null) field.setAccessible(true);
|
||||||
freezeEnabled = field != null;
|
freezeEnabled = field != null;
|
||||||
|
world = Bukkit.getWorlds().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void freeze(World world) {
|
public static void freeze() {
|
||||||
setFreeze(world, true);
|
setFreeze(world, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void unfreeze(World world) {
|
public static void unfreeze() {
|
||||||
setFreeze(world, false);
|
setFreeze(world, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean frozen(World world) {
|
public static boolean frozen() {
|
||||||
if (freezeEnabled) {
|
return freezeEnabled && frozen;
|
||||||
try {
|
|
||||||
return (boolean) field.get(((CraftWorld) world).getHandle());
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
// Ignored;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFreeze(World world, boolean state) {
|
private void setFreeze(World world, boolean state) {
|
||||||
if (freezeEnabled) {
|
if (freezeEnabled) {
|
||||||
try {
|
try {
|
||||||
System.out.println(state + " " + frozen(world));
|
|
||||||
field.set(((CraftWorld) world).getHandle(), state);
|
field.set(((CraftWorld) world).getHandle(), state);
|
||||||
System.out.println(state + " " + frozen(world));
|
frozen = state;
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
// Ignored;
|
// Ignored;
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ public class TPSLimitCommand extends SWCommand implements Enable {
|
|||||||
public void valueCommand(Player p, /*@DoubleRange(min = 0.5, max = 60)*/ double tpsLimitDouble) {
|
public void valueCommand(Player p, /*@DoubleRange(min = 0.5, max = 60)*/ double tpsLimitDouble) {
|
||||||
if (!permissionCheck(p)) return;
|
if (!permissionCheck(p)) return;
|
||||||
if (FreezeUtils.freezeEnabled && tpsLimitDouble == 0) {
|
if (FreezeUtils.freezeEnabled && tpsLimitDouble == 0) {
|
||||||
FreezeUtils.freeze(p.getWorld());
|
FreezeUtils.freeze();
|
||||||
TPSLimitUtils.currentTPSLimit = 20;
|
TPSLimitUtils.currentTPSLimit = 20;
|
||||||
TPSLimitUtils.tpsLimiter();
|
TPSLimitUtils.tpsLimiter();
|
||||||
sendNewTPSLimitMessage(true);
|
sendNewTPSLimitMessage(true);
|
||||||
@ -85,7 +85,7 @@ public class TPSLimitCommand extends SWCommand implements Enable {
|
|||||||
sendInvalidArgumentMessage(p);
|
sendInvalidArgumentMessage(p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FreezeUtils.unfreeze(p.getWorld());
|
FreezeUtils.unfreeze();
|
||||||
TPSLimitUtils.currentTPSLimit = tpsLimitDouble;
|
TPSLimitUtils.currentTPSLimit = tpsLimitDouble;
|
||||||
TPSLimitUtils.tpsLimiter();
|
TPSLimitUtils.tpsLimiter();
|
||||||
sendNewTPSLimitMessage(false);
|
sendNewTPSLimitMessage(false);
|
||||||
|
@ -72,11 +72,9 @@ public class TickCommand extends SWCommand {
|
|||||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("TICK_STEP", player, ticks));
|
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("TICK_STEP", player, ticks));
|
||||||
});
|
});
|
||||||
FreezeUtils.unfreeze(p.getWorld());
|
FreezeUtils.unfreeze();
|
||||||
ticksLeft = new AtomicInteger(ticks);
|
ticksLeft = new AtomicInteger(ticks);
|
||||||
disableTask = () -> {
|
disableTask = FreezeUtils::freeze;
|
||||||
FreezeUtils.freeze(p.getWorld());
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = {"warp"}, description = "TICK_WARP_HELP")
|
@Register(value = {"warp"}, description = "TICK_WARP_HELP")
|
||||||
@ -87,16 +85,16 @@ public class TickCommand extends SWCommand {
|
|||||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("TICK_WARP", player, ticks));
|
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("TICK_WARP", player, ticks));
|
||||||
});
|
});
|
||||||
boolean frozen = FreezeUtils.frozen(p.getWorld());
|
boolean frozen = FreezeUtils.frozen();
|
||||||
double currentTPSLimit = TPSLimitUtils.currentTPSLimit;
|
double currentTPSLimit = TPSLimitUtils.currentTPSLimit;
|
||||||
TPSLimitUtils.currentTPSLimit = 120;
|
TPSLimitUtils.currentTPSLimit = 240;
|
||||||
TPSLimitUtils.tpsLimiter();
|
TPSLimitUtils.tpsLimiter();
|
||||||
|
|
||||||
FreezeUtils.unfreeze(p.getWorld());
|
FreezeUtils.unfreeze();
|
||||||
ticksLeft = new AtomicInteger(ticks);
|
ticksLeft = new AtomicInteger(ticks);
|
||||||
disableTask = () -> {
|
disableTask = () -> {
|
||||||
if (frozen) {
|
if (frozen) {
|
||||||
FreezeUtils.freeze(p.getWorld());
|
FreezeUtils.freeze();
|
||||||
}
|
}
|
||||||
TPSLimitUtils.currentTPSLimit = currentTPSLimit;
|
TPSLimitUtils.currentTPSLimit = currentTPSLimit;
|
||||||
TPSLimitUtils.tpsLimiter();
|
TPSLimitUtils.tpsLimiter();
|
||||||
|
@ -2,6 +2,7 @@ package de.steamwar.bausystem.features.world;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.features.loader.Loader;
|
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.TPSLimitUtils;
|
||||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||||
import de.steamwar.bausystem.features.tpslimit.TPSWarpUtils;
|
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(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_LOADER", p) + "§8: " + BauSystem.MESSAGE.parse(loader != null ? loader.getStage().getChatValue() : "LOADER_OFF", p));
|
||||||
|
|
||||||
strings.add("§5");
|
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());
|
strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8 " + tpsColor() + TPSWarpUtils.getTps(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit());
|
||||||
|
}
|
||||||
|
|
||||||
int i = strings.size();
|
int i = strings.size();
|
||||||
HashMap<String, Integer> result = new HashMap<>();
|
HashMap<String, Integer> result = new HashMap<>();
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren