Dieser Commit ist enthalten in:
Ursprung
7ece12de47
Commit
e01ac8ac58
@ -22,12 +22,16 @@ package de.steamwar.bausystem.features.script.lua.libs;
|
|||||||
import de.steamwar.bausystem.features.tpslimit.TPSSystem;
|
import de.steamwar.bausystem.features.tpslimit.TPSSystem;
|
||||||
import de.steamwar.core.TPSWatcher;
|
import de.steamwar.core.TPSWatcher;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
|
import de.steamwar.linkage.LinkedInstance;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.luaj.vm2.LuaTable;
|
import org.luaj.vm2.LuaTable;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class TpsLib implements LuaLib {
|
public class TpsLib implements LuaLib {
|
||||||
|
|
||||||
|
@LinkedInstance
|
||||||
|
public TPSSystem tpsSystem;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends LuaLib> parent() {
|
public Class<? extends LuaLib> parent() {
|
||||||
return ServerLib.class;
|
return ServerLib.class;
|
||||||
@ -47,7 +51,7 @@ public class TpsLib implements LuaLib {
|
|||||||
tpsLib.set("fiveMinute", getter(() -> TPSWatcher.getTPS(TPSWatcher.TPSType.FIVE_MINUTES)));
|
tpsLib.set("fiveMinute", getter(() -> TPSWatcher.getTPS(TPSWatcher.TPSType.FIVE_MINUTES)));
|
||||||
tpsLib.set("tenMinute", getter(() -> TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES)));
|
tpsLib.set("tenMinute", getter(() -> TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES)));
|
||||||
tpsLib.set("current", getter(TPSWatcher::getTPS));
|
tpsLib.set("current", getter(TPSWatcher::getTPS));
|
||||||
tpsLib.set("limit", getter(TPSSystem.getInstance()::getCurrentTPSLimit));
|
tpsLib.set("limit", getter(tpsSystem::getCurrentTPSLimit));
|
||||||
return tpsLib;
|
return tpsLib;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,15 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.core.TPSWatcher;
|
import de.steamwar.core.TPSWatcher;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
|
import de.steamwar.linkage.LinkedInstance;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class TPSCommand extends SWCommand {
|
public class TPSCommand extends SWCommand {
|
||||||
|
|
||||||
|
@LinkedInstance
|
||||||
|
public TPSSystem tpsSystem;
|
||||||
|
|
||||||
public TPSCommand() {
|
public TPSCommand() {
|
||||||
super("tps");
|
super("tps");
|
||||||
unregister();
|
unregister();
|
||||||
@ -48,6 +52,6 @@ public class TPSCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void genericCommand(Player p, TPSWatcher.TPSType type) {
|
public void genericCommand(Player p, TPSWatcher.TPSType type) {
|
||||||
BauSystem.MESSAGE.sendPrefixless("OTHER_TPS_SINGLE", p, TPSSystem.getInstance().getTPS(type));
|
BauSystem.MESSAGE.sendPrefixless("OTHER_TPS_SINGLE", p, tpsSystem.getTPS(type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,13 +31,13 @@ import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
|||||||
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
||||||
import de.steamwar.command.AbstractSWCommand;
|
import de.steamwar.command.AbstractSWCommand;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.core.TPSWarpUtils;
|
import de.steamwar.core.TPSWarpUtils;
|
||||||
import de.steamwar.core.TPSWatcher;
|
import de.steamwar.core.TPSWatcher;
|
||||||
import de.steamwar.inventory.SWAnvilInv;
|
import de.steamwar.inventory.SWAnvilInv;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
|
import de.steamwar.linkage.LinkedInstance;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -56,16 +56,11 @@ public class TPSSystem implements Listener {
|
|||||||
@Getter
|
@Getter
|
||||||
private double currentTPSLimit = 20;
|
private double currentTPSLimit = 20;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private static TPSSystem instance;
|
|
||||||
|
|
||||||
public double getTPS(TPSWatcher.TPSType tpsType) {
|
public double getTPS(TPSWatcher.TPSType tpsType) {
|
||||||
return TPSWatcher.getTPSUnlimited(tpsType);
|
return TPSWatcher.getTPSUnlimited(tpsType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TPSSystem() {
|
public TPSSystem() {
|
||||||
instance = this;
|
|
||||||
|
|
||||||
if (TPSFreezeUtils.isCanFreeze()) {
|
if (TPSFreezeUtils.isCanFreeze()) {
|
||||||
new TPSFreezeCommand();
|
new TPSFreezeCommand();
|
||||||
new TickFreezeCommand();
|
new TickFreezeCommand();
|
||||||
@ -312,6 +307,9 @@ public class TPSSystem implements Listener {
|
|||||||
@Linked
|
@Linked
|
||||||
public static class TPSScoreboardElement implements ScoreboardElement {
|
public static class TPSScoreboardElement implements ScoreboardElement {
|
||||||
|
|
||||||
|
@LinkedInstance
|
||||||
|
public TPSSystem tpsSystem;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ScoreboardGroup getGroup() {
|
public ScoreboardGroup getGroup() {
|
||||||
return ScoreboardGroup.FOOTER;
|
return ScoreboardGroup.FOOTER;
|
||||||
@ -324,7 +322,7 @@ public class TPSSystem implements Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
if (TPSSystem.getInstance() != null && TPSSystem.getInstance().currentlyStepping) {
|
if (tpsSystem != null && tpsSystem.currentlyStepping) {
|
||||||
long time = System.currentTimeMillis() % 1000;
|
long time = System.currentTimeMillis() % 1000;
|
||||||
if (time < 250) {
|
if (time < 250) {
|
||||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: §7•••";
|
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: §7•••";
|
||||||
@ -338,39 +336,42 @@ public class TPSSystem implements Listener {
|
|||||||
} else if (TPSFreezeUtils.frozen()) {
|
} else if (TPSFreezeUtils.frozen()) {
|
||||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: " + BauSystem.MESSAGE.parse("SCOREBOARD_TPS_FROZEN", p);
|
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: " + BauSystem.MESSAGE.parse("SCOREBOARD_TPS_FROZEN", p);
|
||||||
} else {
|
} else {
|
||||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: " + tpsColor() + TPSSystem.getInstance().getTPS(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit();
|
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: " + tpsColor() + tpsSystem.getTPS(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String tpsColor() {
|
private String tpsColor() {
|
||||||
double tps = TPSSystem.getInstance().getTPS(TPSWatcher.TPSType.ONE_SECOND);
|
double tps = tpsSystem.getTPS(TPSWatcher.TPSType.ONE_SECOND);
|
||||||
if (tps > TPSSystem.getInstance().getCurrentTPSLimit() * 0.9) {
|
if (tps > tpsSystem.getCurrentTPSLimit() * 0.9) {
|
||||||
return "§a";
|
return "§a";
|
||||||
}
|
}
|
||||||
if (tps > TPSSystem.getInstance().getCurrentTPSLimit() * 0.5) {
|
if (tps > tpsSystem.getCurrentTPSLimit() * 0.5) {
|
||||||
return "§e";
|
return "§e";
|
||||||
}
|
}
|
||||||
return "§c";
|
return "§c";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String tpsLimit() {
|
private String tpsLimit() {
|
||||||
if (TPSSystem.getInstance().getCurrentTPSLimit() == 20) {
|
if (tpsSystem.getCurrentTPSLimit() == 20) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return "§8/§7" + TPSSystem.getInstance().getCurrentTPSLimit();
|
return "§8/§7" + tpsSystem.getCurrentTPSLimit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public static class TPSSystemBauGuiItem extends BauGuiItem {
|
public static class TPSSystemBauGuiItem extends BauGuiItem {
|
||||||
|
|
||||||
|
@LinkedInstance
|
||||||
|
public TPSSystem tpsSystem;
|
||||||
|
|
||||||
public TPSSystemBauGuiItem() {
|
public TPSSystemBauGuiItem() {
|
||||||
super(19);
|
super(19);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(Player player) {
|
public ItemStack getItem(Player player) {
|
||||||
return new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("TPSLIMIT_GUI_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("TPSLIMIT_GUI_ITEM_LORE", player, TPSSystem.getInstance().currentTPSLimit)), false, clickType -> {
|
return new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("TPSLIMIT_GUI_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("TPSLIMIT_GUI_ITEM_LORE", player, tpsSystem.currentTPSLimit)), false, clickType -> {
|
||||||
}).getItemStack();
|
}).getItemStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ import de.steamwar.bausystem.region.GlobalRegion;
|
|||||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||||
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
||||||
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
||||||
import de.steamwar.command.SWCommand;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.network.packets.PacketHandler;
|
import de.steamwar.network.packets.PacketHandler;
|
||||||
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
||||||
@ -132,17 +131,4 @@ public class BauMemberUpdate extends PacketHandler implements Listener {
|
|||||||
}
|
}
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Linked
|
|
||||||
public static class TestCommand extends SWCommand { // TODO: Remove before merge
|
|
||||||
|
|
||||||
public TestCommand() {
|
|
||||||
super("test");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register
|
|
||||||
public void test(Player player) {
|
|
||||||
PacketHandler.handlePacket(new BaumemberUpdatePacket());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren