From 861e83d5274398b6f6a97844ea315e8d8bd578f6 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 31 May 2024 10:16:38 +0200 Subject: [PATCH] Move and update things --- .../features/autostart/AutostartListener.java | 5 +- .../features/loader/LoaderRecorder.java | 1 - .../features/script/lua/libs/ServerLib.java | 1 - .../testblock/blockcounter/BlockCount.java | 1 - .../bausystem/features/tpslimit/TPSUtils.java | 41 ------ BauSystem_TPSLimit/build.gradle | 4 + .../bausystem}/tpslimit/PacketCache.java | 4 +- .../bausystem}/tpslimit/TPSCommand.java | 12 +- .../bausystem}/tpslimit/TPSFreezeUtils.java | 4 +- .../bausystem}/tpslimit/TPSLimitUtils.java | 26 ++-- .../tpslimit/TPSScoreboardElement.java | 85 ++++++++++++ .../bausystem}/tpslimit/TPSSystem.java | 122 ++---------------- .../tpslimit/TPSSystemBauGuiItem.java | 68 ++++++++++ .../stemawar/bausystem/tpslimit/TPSUtils.java | 41 ++++++ BauSystem_TPSLimit/src/plugin.yml | 4 +- BauSystem_Tracer/src/plugin.yml | 2 +- BauSystem_Warp/src/plugin.yml | 11 ++ 17 files changed, 250 insertions(+), 182 deletions(-) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSUtils.java rename {BauSystem_Main/src/de/steamwar/bausystem/features => BauSystem_TPSLimit/src/de/stemawar/bausystem}/tpslimit/PacketCache.java (98%) rename {BauSystem_Main/src/de/steamwar/bausystem/features => BauSystem_TPSLimit/src/de/stemawar/bausystem}/tpslimit/TPSCommand.java (81%) rename {BauSystem_Main/src/de/steamwar/bausystem/features => BauSystem_TPSLimit/src/de/stemawar/bausystem}/tpslimit/TPSFreezeUtils.java (96%) rename {BauSystem_Main/src/de/steamwar/bausystem/features => BauSystem_TPSLimit/src/de/stemawar/bausystem}/tpslimit/TPSLimitUtils.java (82%) create mode 100644 BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSScoreboardElement.java rename {BauSystem_Main/src/de/steamwar/bausystem/features => BauSystem_TPSLimit/src/de/stemawar/bausystem}/tpslimit/TPSSystem.java (68%) create mode 100644 BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSSystemBauGuiItem.java create mode 100644 BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSUtils.java create mode 100644 BauSystem_Warp/src/plugin.yml diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java index 28126ec5..9588e688 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java @@ -44,8 +44,9 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import java.io.File; -import java.text.SimpleDateFormat; -import java.util.*; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; @Linked public class AutostartListener implements Listener { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderRecorder.java index cc3dce23..d3e2fcfb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderRecorder.java @@ -44,7 +44,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.BiConsumer; -import java.util.function.Consumer; public class LoaderRecorder implements Listener { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/ServerLib.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/ServerLib.java index 10a41830..039b849f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/ServerLib.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/ServerLib.java @@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.script.lua.libs; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.features.loader.Loader; import de.steamwar.bausystem.features.loader.LoaderRecorder; import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.inventory.SWItem; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCount.java b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCount.java index 84853b8c..e0e79f77 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCount.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCount.java @@ -24,7 +24,6 @@ import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; import lombok.ToString; -import org.bukkit.Bukkit; import org.bukkit.block.Block; import org.bukkit.scheduler.BukkitTask; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSUtils.java deleted file mode 100644 index d920b5fa..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSUtils.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 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 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 . - */ - -package de.steamwar.bausystem.features.tpslimit; - -import de.steamwar.bausystem.BauSystem; -import lombok.experimental.UtilityClass; -import org.bukkit.Bukkit; - -import java.util.function.Supplier; - -@UtilityClass -public class TPSUtils { - - private static long ticksSinceServerStart = 0; - public static final Supplier currentTick = () -> ticksSinceServerStart; // This is intended as Supplier - - private static long realTicksSinceServerStart = 0; - public static final Supplier currentRealTick = () -> realTicksSinceServerStart; // This is intended as Supplier - - static { - Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> ticksSinceServerStart++, 1, 1); - BauSystem.runTaskTimer(BauSystem.getInstance(), () -> realTicksSinceServerStart++, 1, 1); - } -} \ No newline at end of file diff --git a/BauSystem_TPSLimit/build.gradle b/BauSystem_TPSLimit/build.gradle index dd0a66df..dba3947a 100644 --- a/BauSystem_TPSLimit/build.gradle +++ b/BauSystem_TPSLimit/build.gradle @@ -44,6 +44,10 @@ sourceSets { dependencies { implementation project(":BauSystem_PluginBase") + implementation project(":BauSystem_GUI") + annotationProcessor project(":BauSystem_GUI") + implementation project(":BauSystem_Scoreboard") + annotationProcessor project(":BauSystem_Scoreboard") compileOnly 'org.projectlombok:lombok:1.18.22' annotationProcessor 'org.projectlombok:lombok:1.18.22' diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/PacketCache.java b/BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/PacketCache.java similarity index 98% rename from BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/PacketCache.java rename to BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/PacketCache.java index e9076382..e9f1cf1e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/PacketCache.java +++ b/BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/PacketCache.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2023 SteamWar.de-Serverteam + * Copyright (C) 2024 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 @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.tpslimit; +package de.stemawar.bausystem.tpslimit; import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSCommand.java b/BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSCommand.java similarity index 81% rename from BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSCommand.java rename to BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSCommand.java index 1b5b51eb..053f0749 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSCommand.java +++ b/BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSCommand.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2023 SteamWar.de-Serverteam + * Copyright (C) 2024 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 @@ -17,9 +17,9 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.tpslimit; +package de.stemawar.bausystem.tpslimit; -import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.BauSystemPlugin; import de.steamwar.command.SWCommand; import de.steamwar.core.TPSWatcher; import de.steamwar.linkage.Linked; @@ -40,8 +40,8 @@ public class TPSCommand extends SWCommand { @Register public void genericCommand(Player p, String... args) { - BauSystem.MESSAGE.sendPrefixless("OTHER_TPS_HEAD", p); - BauSystem.MESSAGE.sendPrefixless("OTHER_TPS_MESSAGE", p, + BauSystemPlugin.MESSAGE.sendPrefixless("OTHER_TPS_HEAD", p); + BauSystemPlugin.MESSAGE.sendPrefixless("OTHER_TPS_MESSAGE", p, TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_SECOND), TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_SECONDS), TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_MINUTE), @@ -52,6 +52,6 @@ public class TPSCommand extends SWCommand { @Register public void genericCommand(Player p, TPSWatcher.TPSType type) { - BauSystem.MESSAGE.sendPrefixless("OTHER_TPS_SINGLE", p, tpsSystem.getTPS(type)); + BauSystemPlugin.MESSAGE.sendPrefixless("OTHER_TPS_SINGLE", p, tpsSystem.getTPS(type)); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSFreezeUtils.java b/BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSFreezeUtils.java similarity index 96% rename from BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSFreezeUtils.java rename to BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSFreezeUtils.java index 34981161..d6c124ca 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSFreezeUtils.java +++ b/BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSFreezeUtils.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2023 SteamWar.de-Serverteam + * Copyright (C) 2024 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 @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.tpslimit; +package de.stemawar.bausystem.tpslimit; import com.comphenix.tinyprotocol.Reflection; import lombok.Getter; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSLimitUtils.java b/BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSLimitUtils.java similarity index 82% rename from BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSLimitUtils.java rename to BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSLimitUtils.java index cc1abda2..e4904445 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSLimitUtils.java +++ b/BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSLimitUtils.java @@ -1,23 +1,23 @@ /* - * This file is a part of the SteamWar software. + * This file is a part of the SteamWar software. * - * Copyright (C) 2020 SteamWar.de-Serverteam + * Copyright (C) 2024 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.bausystem.features.tpslimit; +package de.stemawar.bausystem.tpslimit; import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; diff --git a/BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSScoreboardElement.java b/BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSScoreboardElement.java new file mode 100644 index 00000000..865491c4 --- /dev/null +++ b/BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSScoreboardElement.java @@ -0,0 +1,85 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 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 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 . + */ + +package de.stemawar.bausystem.tpslimit; + +import de.steamwar.bausystem.BauSystemPlugin; +import de.steamwar.bausystem.linkage.specific.ScoreboardElement; +import de.steamwar.bausystem.region.Region; +import de.steamwar.core.TPSWatcher; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; +import de.steamwar.linkage.PluginCheck; +import org.bukkit.entity.Player; + +@Linked +@PluginCheck("BauSystem_Scoreboard") +public class TPSScoreboardElement implements ScoreboardElement { + + @LinkedInstance + public TPSSystem tpsSystem; + + @Override + public ScoreboardGroup getGroup() { + return ScoreboardGroup.FOOTER; + } + + @Override + public int order() { + return 0; + } + + @Override + public String get(Region region, Player p) { + if (tpsSystem != null && tpsSystem.currentlyStepping) { + long time = System.currentTimeMillis() % 1000; + if (time < 250) { + return "§e" + BauSystemPlugin.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: §7•••"; + } else if (time < 500) { + return "§e" + BauSystemPlugin.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: §e•§7••"; + } else if (time < 750) { + return "§e" + BauSystemPlugin.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: §7•§e•§7•"; + } else { + return "§e" + BauSystemPlugin.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: §7••§e•"; + } + } else if (TPSFreezeUtils.frozen()) { + return "§e" + BauSystemPlugin.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: " + BauSystemPlugin.MESSAGE.parse("SCOREBOARD_TPS_FROZEN", p); + } else { + return "§e" + BauSystemPlugin.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: " + tpsColor() + tpsSystem.getTPS(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit(); + } + } + + private String tpsColor() { + double tps = tpsSystem.getTPS(TPSWatcher.TPSType.ONE_SECOND); + if (tps > tpsSystem.getCurrentTPSLimit() * 0.9) { + return "§a"; + } + if (tps > tpsSystem.getCurrentTPSLimit() * 0.5) { + return "§e"; + } + return "§c"; + } + + private String tpsLimit() { + if (tpsSystem.getCurrentTPSLimit() == 20) { + return ""; + } + return "§8/§7" + tpsSystem.getCurrentTPSLimit(); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java b/BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSSystem.java similarity index 68% rename from BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java rename to BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSSystem.java index 5cb1e1b6..771f8620 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java +++ b/BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSSystem.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2023 SteamWar.de-Serverteam + * Copyright (C) 2024 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 @@ -17,15 +17,12 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.tpslimit; +package de.stemawar.bausystem.tpslimit; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.BauSystemPlugin; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.GlobalRegion; -import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.bausystem.utils.TickEndEvent; import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar; import de.steamwar.bausystem.utils.bossbar.BossBarService; @@ -34,27 +31,19 @@ import de.steamwar.command.SWCommand; import de.steamwar.core.Core; import de.steamwar.core.TPSWarpUtils; import de.steamwar.core.TPSWatcher; -import de.steamwar.inventory.SWAnvilInv; -import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.LinkedInstance; import lombok.Getter; import org.bukkit.Bukkit; -import org.bukkit.Material; import org.bukkit.boss.BarColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; - -import java.util.Arrays; @Linked public class TPSSystem implements Listener { @Getter - private double currentTPSLimit = 20; + double currentTPSLimit = 20; public double getTPS(TPSWatcher.TPSType tpsType) { return TPSWatcher.getTPSUnlimited(tpsType); @@ -111,10 +100,10 @@ public class TPSSystem implements Listener { }); } - private boolean currentlyStepping = false; - private double currentLimit; - private int stepsTotal; - private int stepsLeft; + boolean currentlyStepping = false; + double currentLimit; + int stepsTotal; + int stepsLeft; private void setSkip(int steps, double tpsLimitToUse) { currentLimit = tpsLimitToUse == 20 ? 0 : currentTPSLimit; @@ -145,7 +134,7 @@ public class TPSSystem implements Listener { private TPSBaseCommand() { super("tpslimit"); - setMessage(BauSystem.MESSAGE); + setMessage(BauSystemPlugin.MESSAGE); addDefaultHelpMessage("TPSLIMIT_HELP"); } } @@ -198,7 +187,7 @@ public class TPSSystem implements Listener { @Register(description = "TPSLIMIT_HELP") public void currentLimit(Player player) { - BauSystem.MESSAGE.send("TPSLIMIT_CURRENT", player, currentTPSLimit); + BauSystemPlugin.MESSAGE.send("TPSLIMIT_CURRENT", player, currentTPSLimit); } @Register(value = "default", description = "TPSLIMIT_DEFAULT_HELP") @@ -211,7 +200,7 @@ public class TPSSystem implements Listener { public TickBaseCommand() { super("tick"); - setMessage(BauSystem.MESSAGE); + setMessage(BauSystemPlugin.MESSAGE); } } @@ -295,7 +284,7 @@ public class TPSSystem implements Listener { @Register(value = "rate", description = "TICK_HELP") public void currentLimit(Player player) { - BauSystem.MESSAGE.send("TPSLIMIT_CURRENT", player, currentTPSLimit); + BauSystemPlugin.MESSAGE.send("TPSLIMIT_CURRENT", player, currentTPSLimit); } @Register(value = {"rate", "default"}, description = "TICK_DEFAULT_HELP") @@ -303,91 +292,4 @@ public class TPSSystem implements Listener { setTPS(20); } } - - @Linked - public static class TPSScoreboardElement implements ScoreboardElement { - - @LinkedInstance - public TPSSystem tpsSystem; - - @Override - public ScoreboardGroup getGroup() { - return ScoreboardGroup.FOOTER; - } - - @Override - public int order() { - return 0; - } - - @Override - public String get(Region region, Player p) { - if (tpsSystem != null && tpsSystem.currentlyStepping) { - long time = System.currentTimeMillis() % 1000; - if (time < 250) { - return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: §7•••"; - } else if (time < 500) { - return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: §e•§7••"; - } else if (time < 750) { - return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: §7•§e•§7•"; - } else { - return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: §7••§e•"; - } - } else if (TPSFreezeUtils.frozen()) { - return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: " + BauSystem.MESSAGE.parse("SCOREBOARD_TPS_FROZEN", p); - } else { - return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: " + tpsColor() + tpsSystem.getTPS(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit(); - } - } - - private String tpsColor() { - double tps = tpsSystem.getTPS(TPSWatcher.TPSType.ONE_SECOND); - if (tps > tpsSystem.getCurrentTPSLimit() * 0.9) { - return "§a"; - } - if (tps > tpsSystem.getCurrentTPSLimit() * 0.5) { - return "§e"; - } - return "§c"; - } - - private String tpsLimit() { - if (tpsSystem.getCurrentTPSLimit() == 20) { - return ""; - } - return "§8/§7" + tpsSystem.getCurrentTPSLimit(); - } - } - - @Linked - public static class TPSSystemBauGuiItem extends BauGuiItem { - - @LinkedInstance - public TPSSystem tpsSystem; - - public TPSSystemBauGuiItem() { - super(19); - } - - @Override - 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.currentTPSLimit)), false, clickType -> { - }).getItemStack(); - } - - @Override - public boolean click(ClickType click, Player p) { - p.closeInventory(); - SWAnvilInv inv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("TPSLIMIT_ANVIL_GUI", p)); - inv.setItem(Material.CLOCK); - inv.setCallback(s -> p.performCommand("tpslimit " + s)); - inv.open(); - return false; - } - - @Override - public Permission permission() { - return Permission.BUILD; - } - } } diff --git a/BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSSystemBauGuiItem.java b/BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSSystemBauGuiItem.java new file mode 100644 index 00000000..d4012a7e --- /dev/null +++ b/BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSSystemBauGuiItem.java @@ -0,0 +1,68 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 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 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 . + */ + +package de.stemawar.bausystem.tpslimit; + +import de.steamwar.bausystem.BauSystemPlugin; +import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.linkage.specific.BauGuiItem; +import de.steamwar.inventory.SWAnvilInv; +import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; +import de.steamwar.linkage.PluginCheck; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import java.util.Arrays; + +@Linked +@PluginCheck("BauSystem_GUI") +public class TPSSystemBauGuiItem extends BauGuiItem { + + @LinkedInstance + public TPSSystem tpsSystem; + + public TPSSystemBauGuiItem() { + super(19); + } + + @Override + public ItemStack getItem(Player player) { + return new SWItem(Material.CLOCK, BauSystemPlugin.MESSAGE.parse("TPSLIMIT_GUI_ITEM_NAME", player), Arrays.asList(BauSystemPlugin.MESSAGE.parse("TPSLIMIT_GUI_ITEM_LORE", player, tpsSystem.currentTPSLimit)), false, clickType -> { + }).getItemStack(); + } + + @Override + public boolean click(ClickType click, Player p) { + p.closeInventory(); + SWAnvilInv inv = new SWAnvilInv(p, BauSystemPlugin.MESSAGE.parse("TPSLIMIT_ANVIL_GUI", p)); + inv.setItem(Material.CLOCK); + inv.setCallback(s -> p.performCommand("tpslimit " + s)); + inv.open(); + return false; + } + + @Override + public Permission permission() { + return Permission.BUILD; + } +} diff --git a/BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSUtils.java b/BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSUtils.java new file mode 100644 index 00000000..5b5bf1c0 --- /dev/null +++ b/BauSystem_TPSLimit/src/de/stemawar/bausystem/tpslimit/TPSUtils.java @@ -0,0 +1,41 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 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 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 . + */ + +package de.stemawar.bausystem.tpslimit; + +import de.steamwar.bausystem.BauSystem; +import lombok.experimental.UtilityClass; +import org.bukkit.Bukkit; + +import java.util.function.Supplier; + +@UtilityClass +public class TPSUtils { + + private static long ticksSinceServerStart = 0; + public static final Supplier currentTick = () -> ticksSinceServerStart; // This is intended as Supplier + + private static long realTicksSinceServerStart = 0; + public static final Supplier currentRealTick = () -> realTicksSinceServerStart; // This is intended as Supplier + + static { + Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> ticksSinceServerStart++, 1, 1); + BauSystem.runTaskTimer(BauSystem.getInstance(), () -> realTicksSinceServerStart++, 1, 1); + } +} \ No newline at end of file diff --git a/BauSystem_TPSLimit/src/plugin.yml b/BauSystem_TPSLimit/src/plugin.yml index cf7115ba..ea4df5f2 100644 --- a/BauSystem_TPSLimit/src/plugin.yml +++ b/BauSystem_TPSLimit/src/plugin.yml @@ -1,7 +1,7 @@ -name: BauSystem +name: BauSystem_TPSLimit authors: [ Lixfel, YoyoNow, Chaoscaot, Zeanon, D4rkr34lm ] version: "2.0" -depend: [ WorldEdit, SpigotCore ] +depend: [ WorldEdit, SpigotCore, BauSystem_GUI, BauSystem_Scoreboard ] load: POSTWORLD main: de.steamwar.bausystem.BauSystemPlugin api-version: "1.13" diff --git a/BauSystem_Tracer/src/plugin.yml b/BauSystem_Tracer/src/plugin.yml index cf7115ba..9a751ebb 100644 --- a/BauSystem_Tracer/src/plugin.yml +++ b/BauSystem_Tracer/src/plugin.yml @@ -1,4 +1,4 @@ -name: BauSystem +name: BauSystem_Tracer authors: [ Lixfel, YoyoNow, Chaoscaot, Zeanon, D4rkr34lm ] version: "2.0" depend: [ WorldEdit, SpigotCore ] diff --git a/BauSystem_Warp/src/plugin.yml b/BauSystem_Warp/src/plugin.yml new file mode 100644 index 00000000..3d2e390f --- /dev/null +++ b/BauSystem_Warp/src/plugin.yml @@ -0,0 +1,11 @@ +name: BauSystem_Warp +authors: [ Lixfel, YoyoNow, Chaoscaot, Zeanon, D4rkr34lm ] +version: "2.0" +depend: [ WorldEdit, SpigotCore ] +load: POSTWORLD +main: de.steamwar.bausystem.BauSystemPlugin +api-version: "1.13" +website: "https://steamwar.de" +description: "So unseriös wie wir sind: BauSystem nur besser." + +commands: