From 987f4f54777cf3da38996e7b6285defb95a0a076 Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 27 Sep 2020 15:59:25 +0200 Subject: [PATCH 01/24] Add TPSWatcher --- .../src/de/steamwar/core/Core.java | 6 ++ .../src/de/steamwar/core/TPSWatcher.java | 92 +++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java diff --git a/SpigotCore_Main/src/de/steamwar/core/Core.java b/SpigotCore_Main/src/de/steamwar/core/Core.java index 893e53a..43e0bf7 100644 --- a/SpigotCore_Main/src/de/steamwar/core/Core.java +++ b/SpigotCore_Main/src/de/steamwar/core/Core.java @@ -32,6 +32,7 @@ import org.bukkit.plugin.java.JavaPlugin; public class Core extends JavaPlugin{ private static Core instance; private static final int version; + private static TPSWatcher tpsWatcher; static{ String packageName = Bukkit.getServer().getClass().getPackage().getName(); @@ -52,6 +53,7 @@ public class Core extends JavaPlugin{ @Override public void onLoad() { setInstance(this); + tpsWatcher = new TPSWatcher(); } @Override @@ -75,10 +77,14 @@ public class Core extends JavaPlugin{ public static Core getInstance() { return instance; } + public static int getVersion(){ return version; } + public static TPSWatcher getTpsWatcher() { + return tpsWatcher; + } private static void setInstance(Core instance) { Core.instance = instance; diff --git a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java new file mode 100644 index 0000000..75f33eb --- /dev/null +++ b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java @@ -0,0 +1,92 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2020 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.core; + +import org.bukkit.Bukkit; + +import java.util.LinkedList; + +public class TPSWatcher { + + private static class TPSMeter { + + private LinkedList meter = new LinkedList<>(); + private int count; + + public TPSMeter(int count) { + this.count = count; + } + + public void add(double tps) { + meter.addLast(tps); + if (meter.size() > count) meter.removeFirst(); + } + + public double get() { + double total = 0; + for (double d : meter) total += d; + return total / meter.size(); + } + + } + + private double now = 20.0; + private TPSMeter one_minute = new TPSMeter(1200); + private TPSMeter five_minutes = new TPSMeter(6000); + private TPSMeter ten_minutes = new TPSMeter(12000); + + private long lastTime = System.currentTimeMillis(); + + private static final double tickTimeDefault = 1000 / 20.0; + private static final double tickDefault = 20.0; + + TPSWatcher() { + Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> { + long tickTime = System.currentTimeMillis() - lastTime; + lastTime = System.currentTimeMillis(); + + if (tickTime != 0) { + now = (tickTimeDefault / tickTime) * tickDefault; + } else { + now = 0; + } + one_minute.add(now); + five_minutes.add(now); + ten_minutes.add(now); + }, 1, 1); + } + + public double getTPS() { + return now; + } + + public double get1TPS() { + return one_minute.get(); + } + + public double get5TPS() { + return five_minutes.get(); + } + + public double get10TPS() { + return ten_minutes.get(); + } + +} From 3959e3c8b867a4c132ca9e3d17a4b011a895d932 Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 27 Sep 2020 17:27:00 +0200 Subject: [PATCH 02/24] Optimize TPSWatcher --- .../src/de/steamwar/core/TPSWatcher.java | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java index 75f33eb..7e75119 100644 --- a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java +++ b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java @@ -21,36 +21,38 @@ package de.steamwar.core; import org.bukkit.Bukkit; +import java.util.Iterator; import java.util.LinkedList; public class TPSWatcher { - private static class TPSMeter { + private LinkedList meter = new LinkedList<>(); + private int count = 30; - private LinkedList meter = new LinkedList<>(); - private int count; + private double sum = 0; + private int sumCount = 0; - public TPSMeter(int count) { - this.count = count; - } - - public void add(double tps) { - meter.addLast(tps); + private void add(double tps) { + sum += tps; + sumCount++; + if (sumCount > 20) { + meter.addLast(sum); if (meter.size() > count) meter.removeFirst(); + sum = 0; + sumCount = 0; } - - public double get() { - double total = 0; - for (double d : meter) total += d; - return total / meter.size(); - } - } - private double now = 20.0; - private TPSMeter one_minute = new TPSMeter(1200); - private TPSMeter five_minutes = new TPSMeter(6000); - private TPSMeter ten_minutes = new TPSMeter(12000); + private double average(int count) { + count = Math.min(count, meter.size()); + if (count == 0) return 20.0; + Iterator doubleIterator = meter.iterator(); + double total = 0; + for (int i = 0; i < count; i++) { + total += doubleIterator.next(); + } + return total / count; + } private long lastTime = System.currentTimeMillis(); @@ -62,31 +64,29 @@ public class TPSWatcher { long tickTime = System.currentTimeMillis() - lastTime; lastTime = System.currentTimeMillis(); + double now = 0; if (tickTime != 0) { now = (tickTimeDefault / tickTime) * tickDefault; - } else { - now = 0; } - one_minute.add(now); - five_minutes.add(now); - ten_minutes.add(now); + add(now); }, 1, 1); } - public double getTPS() { - return now; + public enum TpsAverage { + LAST_SECOND(1), + LAST_TEN_SECONDS(10), + LAST_THIRTY_SECONDS(30); + + private int count; + + TpsAverage(int count) { + this.count = count; + } + } - public double get1TPS() { - return one_minute.get(); - } - - public double get5TPS() { - return five_minutes.get(); - } - - public double get10TPS() { - return ten_minutes.get(); + public double getTPS(TpsAverage average) { + return average(average.count); } } From f83b1359c66936aba8b5457de1f82e3274588714 Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 27 Sep 2020 17:28:32 +0200 Subject: [PATCH 03/24] Optimize TPSWatcher --- SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java index 7e75119..849b838 100644 --- a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java +++ b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java @@ -77,7 +77,7 @@ public class TPSWatcher { LAST_TEN_SECONDS(10), LAST_THIRTY_SECONDS(30); - private int count; + private final int count; TpsAverage(int count) { this.count = count; From bb2bf2577efde569130a53547e30caa159c6c2a8 Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 4 Oct 2020 18:11:19 +0200 Subject: [PATCH 04/24] Optimize TPSWatcher Remove 30 seconds TPSWatching --- .../src/de/steamwar/core/SpigotTPS_10.java | 13 +++ .../src/de/steamwar/core/SpigotTPS_12.java | 13 +++ .../src/de/steamwar/core/SpigotTPS_14.java | 13 +++ .../src/de/steamwar/core/SpigotTPS_15.java | 13 +++ .../src/de/steamwar/core/SpigotTPS_8.java | 13 +++ .../src/de/steamwar/core/SpigotTPS_9.java | 13 +++ .../src/de/steamwar/core/Core.java | 6 - .../src/de/steamwar/core/TPSWatcher.java | 103 ++++++++++-------- 8 files changed, 137 insertions(+), 50 deletions(-) create mode 100644 SpigotCore_10/src/de/steamwar/core/SpigotTPS_10.java create mode 100644 SpigotCore_12/src/de/steamwar/core/SpigotTPS_12.java create mode 100644 SpigotCore_14/src/de/steamwar/core/SpigotTPS_14.java create mode 100644 SpigotCore_15/src/de/steamwar/core/SpigotTPS_15.java create mode 100644 SpigotCore_8/src/de/steamwar/core/SpigotTPS_8.java create mode 100644 SpigotCore_9/src/de/steamwar/core/SpigotTPS_9.java diff --git a/SpigotCore_10/src/de/steamwar/core/SpigotTPS_10.java b/SpigotCore_10/src/de/steamwar/core/SpigotTPS_10.java new file mode 100644 index 0000000..792022e --- /dev/null +++ b/SpigotCore_10/src/de/steamwar/core/SpigotTPS_10.java @@ -0,0 +1,13 @@ +package de.steamwar.core; + +import net.minecraft.server.v1_10_R1.MinecraftServer; + +public class SpigotTPS_10 { + + private SpigotTPS_10(){} + + static double[] getTps(){ + return MinecraftServer.getServer().recentTps; + } + +} diff --git a/SpigotCore_12/src/de/steamwar/core/SpigotTPS_12.java b/SpigotCore_12/src/de/steamwar/core/SpigotTPS_12.java new file mode 100644 index 0000000..60bc6d9 --- /dev/null +++ b/SpigotCore_12/src/de/steamwar/core/SpigotTPS_12.java @@ -0,0 +1,13 @@ +package de.steamwar.core; + +import net.minecraft.server.v1_12_R1.MinecraftServer; + +public class SpigotTPS_12 { + + private SpigotTPS_12(){} + + static double[] getTps(){ + return MinecraftServer.getServer().recentTps; + } + +} diff --git a/SpigotCore_14/src/de/steamwar/core/SpigotTPS_14.java b/SpigotCore_14/src/de/steamwar/core/SpigotTPS_14.java new file mode 100644 index 0000000..6bd8491 --- /dev/null +++ b/SpigotCore_14/src/de/steamwar/core/SpigotTPS_14.java @@ -0,0 +1,13 @@ +package de.steamwar.core; + +import net.minecraft.server.v1_14_R1.MinecraftServer; + +public class SpigotTPS_14 { + + private SpigotTPS_14(){} + + static double[] getTps(){ + return MinecraftServer.getServer().recentTps; + } + +} diff --git a/SpigotCore_15/src/de/steamwar/core/SpigotTPS_15.java b/SpigotCore_15/src/de/steamwar/core/SpigotTPS_15.java new file mode 100644 index 0000000..e9919f9 --- /dev/null +++ b/SpigotCore_15/src/de/steamwar/core/SpigotTPS_15.java @@ -0,0 +1,13 @@ +package de.steamwar.core; + +import net.minecraft.server.v1_15_R1.MinecraftServer; + +public class SpigotTPS_15 { + + private SpigotTPS_15(){} + + static double[] getTps(){ + return MinecraftServer.getServer().recentTps; + } + +} diff --git a/SpigotCore_8/src/de/steamwar/core/SpigotTPS_8.java b/SpigotCore_8/src/de/steamwar/core/SpigotTPS_8.java new file mode 100644 index 0000000..8669728 --- /dev/null +++ b/SpigotCore_8/src/de/steamwar/core/SpigotTPS_8.java @@ -0,0 +1,13 @@ +package de.steamwar.core; + +import net.minecraft.server.v1_8_R3.MinecraftServer; + +public class SpigotTPS_8 { + + private SpigotTPS_8(){} + + static double[] getTps(){ + return MinecraftServer.getServer().recentTps; + } + +} diff --git a/SpigotCore_9/src/de/steamwar/core/SpigotTPS_9.java b/SpigotCore_9/src/de/steamwar/core/SpigotTPS_9.java new file mode 100644 index 0000000..fa5d3e6 --- /dev/null +++ b/SpigotCore_9/src/de/steamwar/core/SpigotTPS_9.java @@ -0,0 +1,13 @@ +package de.steamwar.core; + +import net.minecraft.server.v1_9_R2.MinecraftServer; + +public class SpigotTPS_9 { + + private SpigotTPS_9(){} + + static double[] getTps(){ + return MinecraftServer.getServer().recentTps; + } + +} diff --git a/SpigotCore_Main/src/de/steamwar/core/Core.java b/SpigotCore_Main/src/de/steamwar/core/Core.java index 43e0bf7..5d5ec25 100644 --- a/SpigotCore_Main/src/de/steamwar/core/Core.java +++ b/SpigotCore_Main/src/de/steamwar/core/Core.java @@ -32,7 +32,6 @@ import org.bukkit.plugin.java.JavaPlugin; public class Core extends JavaPlugin{ private static Core instance; private static final int version; - private static TPSWatcher tpsWatcher; static{ String packageName = Bukkit.getServer().getClass().getPackage().getName(); @@ -53,7 +52,6 @@ public class Core extends JavaPlugin{ @Override public void onLoad() { setInstance(this); - tpsWatcher = new TPSWatcher(); } @Override @@ -82,10 +80,6 @@ public class Core extends JavaPlugin{ return version; } - public static TPSWatcher getTpsWatcher() { - return tpsWatcher; - } - private static void setInstance(Core instance) { Core.instance = instance; } diff --git a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java index 849b838..97ad502 100644 --- a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java +++ b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java @@ -21,45 +21,20 @@ package de.steamwar.core; import org.bukkit.Bukkit; -import java.util.Iterator; -import java.util.LinkedList; - public class TPSWatcher { - private LinkedList meter = new LinkedList<>(); - private int count = 30; + private static final double tickTimeDefault = 1000; + private static final double tickDefault = 20.0; - private double sum = 0; - private int sumCount = 0; - - private void add(double tps) { - sum += tps; - sumCount++; - if (sumCount > 20) { - meter.addLast(sum); - if (meter.size() > count) meter.removeFirst(); - sum = 0; - sumCount = 0; - } - } - - private double average(int count) { - count = Math.min(count, meter.size()); - if (count == 0) return 20.0; - Iterator doubleIterator = meter.iterator(); - double total = 0; - for (int i = 0; i < count; i++) { - total += doubleIterator.next(); - } - return total / count; - } + private static TPSWatcher tps_OneSecond = new TPSWatcher(1000); + private static TPSWatcher tps_TenSecond = new TPSWatcher(10000); private long lastTime = System.currentTimeMillis(); - private static final double tickTimeDefault = 1000 / 20.0; - private static final double tickDefault = 20.0; + private double tps = 20.0; - TPSWatcher() { + private TPSWatcher(long timeInterval) { + timeInterval = timeInterval / 50; Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> { long tickTime = System.currentTimeMillis() - lastTime; lastTime = System.currentTimeMillis(); @@ -68,25 +43,65 @@ public class TPSWatcher { if (tickTime != 0) { now = (tickTimeDefault / tickTime) * tickDefault; } - add(now); - }, 1, 1); + if (now < 0) { + now = 0; + } + tps = now; + }, timeInterval, timeInterval); } - public enum TpsAverage { - LAST_SECOND(1), - LAST_TEN_SECONDS(10), - LAST_THIRTY_SECONDS(30); + public enum TPSType { - private final int count; + // With own implementation + ONE_SECOND, + TEN_SECONDS, + // With getting the values from Spigot itself + ONE_MINUTE, + FIVE_MINUTES, + TEN_MINUTES - TpsAverage(int count) { - this.count = count; + } + + public double getTPS() { + return getTPS(TPSType.ONE_SECOND); + } + + public double getTPS(TPSType tpsType) { + switch (tpsType) { + case TEN_SECONDS: + return round(tps_TenSecond.tps); + case ONE_MINUTE: + return round(getSpigotTPS()[0]); + case FIVE_MINUTES: + return round(getSpigotTPS()[1]); + case TEN_MINUTES: + return round(getSpigotTPS()[2]); + + default: + return round(tps_OneSecond.tps); } - } - public double getTPS(TpsAverage average) { - return average(average.count); + private double[] getSpigotTPS() { + switch (Core.getVersion()) { + case 8: + return SpigotTPS_8.getTps(); + case 9: + return SpigotTPS_9.getTps(); + case 10: + return SpigotTPS_10.getTps(); + case 14: + return SpigotTPS_14.getTps(); + case 15: + return SpigotTPS_15.getTps(); + + default: + return SpigotTPS_12.getTps(); + } + } + + private double round(double d) { + return Math.round(d * 10) / 10.0; } } From 599755a52775fd072a2a3dcd155facc9ab4dc11c Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 4 Oct 2020 18:18:55 +0200 Subject: [PATCH 05/24] Fix TPSWatcher for 10 seconds --- SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java index 97ad502..5c718cc 100644 --- a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java +++ b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java @@ -23,7 +23,6 @@ import org.bukkit.Bukkit; public class TPSWatcher { - private static final double tickTimeDefault = 1000; private static final double tickDefault = 20.0; private static TPSWatcher tps_OneSecond = new TPSWatcher(1000); @@ -34,20 +33,19 @@ public class TPSWatcher { private double tps = 20.0; private TPSWatcher(long timeInterval) { - timeInterval = timeInterval / 50; Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> { long tickTime = System.currentTimeMillis() - lastTime; lastTime = System.currentTimeMillis(); double now = 0; if (tickTime != 0) { - now = (tickTimeDefault / tickTime) * tickDefault; + now = (timeInterval / (double) tickTime) * tickDefault; } if (now < 0) { now = 0; } tps = now; - }, timeInterval, timeInterval); + }, timeInterval / 50, timeInterval / 50); } public enum TPSType { From 2c76604bb5fd4ec4da822b26118b371bcd48038b Mon Sep 17 00:00:00 2001 From: jojo Date: Mon, 12 Oct 2020 12:50:35 +0200 Subject: [PATCH 06/24] Add Copyright Notice --- .../src/de/steamwar/core/SpigotTPS_10.java | 19 +++++++++++++++++++ .../src/de/steamwar/core/SpigotTPS_12.java | 19 +++++++++++++++++++ .../src/de/steamwar/core/SpigotTPS_14.java | 19 +++++++++++++++++++ .../src/de/steamwar/core/SpigotTPS_15.java | 19 +++++++++++++++++++ .../src/de/steamwar/core/SpigotTPS_8.java | 19 +++++++++++++++++++ .../src/de/steamwar/core/SpigotTPS_9.java | 19 +++++++++++++++++++ .../src/de/steamwar/core/Core.java | 1 + .../src/de/steamwar/core/TPSWatcher.java | 9 +++++++-- 8 files changed, 122 insertions(+), 2 deletions(-) diff --git a/SpigotCore_10/src/de/steamwar/core/SpigotTPS_10.java b/SpigotCore_10/src/de/steamwar/core/SpigotTPS_10.java index 792022e..2cc2d26 100644 --- a/SpigotCore_10/src/de/steamwar/core/SpigotTPS_10.java +++ b/SpigotCore_10/src/de/steamwar/core/SpigotTPS_10.java @@ -1,3 +1,22 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2020 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.core; import net.minecraft.server.v1_10_R1.MinecraftServer; diff --git a/SpigotCore_12/src/de/steamwar/core/SpigotTPS_12.java b/SpigotCore_12/src/de/steamwar/core/SpigotTPS_12.java index 60bc6d9..17541c7 100644 --- a/SpigotCore_12/src/de/steamwar/core/SpigotTPS_12.java +++ b/SpigotCore_12/src/de/steamwar/core/SpigotTPS_12.java @@ -1,3 +1,22 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2020 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.core; import net.minecraft.server.v1_12_R1.MinecraftServer; diff --git a/SpigotCore_14/src/de/steamwar/core/SpigotTPS_14.java b/SpigotCore_14/src/de/steamwar/core/SpigotTPS_14.java index 6bd8491..d00aba8 100644 --- a/SpigotCore_14/src/de/steamwar/core/SpigotTPS_14.java +++ b/SpigotCore_14/src/de/steamwar/core/SpigotTPS_14.java @@ -1,3 +1,22 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2020 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.core; import net.minecraft.server.v1_14_R1.MinecraftServer; diff --git a/SpigotCore_15/src/de/steamwar/core/SpigotTPS_15.java b/SpigotCore_15/src/de/steamwar/core/SpigotTPS_15.java index e9919f9..46c1186 100644 --- a/SpigotCore_15/src/de/steamwar/core/SpigotTPS_15.java +++ b/SpigotCore_15/src/de/steamwar/core/SpigotTPS_15.java @@ -1,3 +1,22 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2020 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.core; import net.minecraft.server.v1_15_R1.MinecraftServer; diff --git a/SpigotCore_8/src/de/steamwar/core/SpigotTPS_8.java b/SpigotCore_8/src/de/steamwar/core/SpigotTPS_8.java index 8669728..aeb94d1 100644 --- a/SpigotCore_8/src/de/steamwar/core/SpigotTPS_8.java +++ b/SpigotCore_8/src/de/steamwar/core/SpigotTPS_8.java @@ -1,3 +1,22 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2020 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.core; import net.minecraft.server.v1_8_R3.MinecraftServer; diff --git a/SpigotCore_9/src/de/steamwar/core/SpigotTPS_9.java b/SpigotCore_9/src/de/steamwar/core/SpigotTPS_9.java index fa5d3e6..6a0ba28 100644 --- a/SpigotCore_9/src/de/steamwar/core/SpigotTPS_9.java +++ b/SpigotCore_9/src/de/steamwar/core/SpigotTPS_9.java @@ -1,3 +1,22 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2020 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.core; import net.minecraft.server.v1_9_R2.MinecraftServer; diff --git a/SpigotCore_Main/src/de/steamwar/core/Core.java b/SpigotCore_Main/src/de/steamwar/core/Core.java index 5d5ec25..a7e1cab 100644 --- a/SpigotCore_Main/src/de/steamwar/core/Core.java +++ b/SpigotCore_Main/src/de/steamwar/core/Core.java @@ -64,6 +64,7 @@ public class Core extends JavaPlugin{ ErrorLogger.init(); getServer().getMessenger().registerIncomingPluginChannel(this, "sw:bridge", new BungeeReceiver()); getServer().getMessenger().registerOutgoingPluginChannel(this, "sw:bridge"); + TPSWatcher.init(); } diff --git a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java index 5c718cc..a0dd0b9 100644 --- a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java +++ b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java @@ -25,8 +25,13 @@ public class TPSWatcher { private static final double tickDefault = 20.0; - private static TPSWatcher tps_OneSecond = new TPSWatcher(1000); - private static TPSWatcher tps_TenSecond = new TPSWatcher(10000); + private static TPSWatcher tps_OneSecond; + private static TPSWatcher tps_TenSecond; + + public static void init() { + tps_OneSecond = new TPSWatcher(1000); + tps_TenSecond = new TPSWatcher(10000); + } private long lastTime = System.currentTimeMillis(); From 245eb3be74a9ecd04fb1ff60be74ff233c16ce79 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 29 Oct 2020 09:31:50 +0100 Subject: [PATCH 07/24] Implementing tablist name packet --- .../de/steamwar/comms/PacketIdManager.java | 1 + .../comms/packets/TablistNamePacket.java | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 SpigotCore_Main/src/de/steamwar/comms/packets/TablistNamePacket.java diff --git a/SpigotCore_Main/src/de/steamwar/comms/PacketIdManager.java b/SpigotCore_Main/src/de/steamwar/comms/PacketIdManager.java index 27dbd81..2407d6a 100644 --- a/SpigotCore_Main/src/de/steamwar/comms/PacketIdManager.java +++ b/SpigotCore_Main/src/de/steamwar/comms/PacketIdManager.java @@ -23,6 +23,7 @@ public class PacketIdManager { //0x0(X) Standalone Packets public final static byte PING_PACKET = 0x01; + public final static byte TABLIST_NAME = 0x02; //0x1(X) Bungee Inventory public final static byte INVENTORY_PACKET = 0x10; public final static byte INVENTORY_CALLBACK_PACKET = 0x11; diff --git a/SpigotCore_Main/src/de/steamwar/comms/packets/TablistNamePacket.java b/SpigotCore_Main/src/de/steamwar/comms/packets/TablistNamePacket.java new file mode 100644 index 0000000..7f5454e --- /dev/null +++ b/SpigotCore_Main/src/de/steamwar/comms/packets/TablistNamePacket.java @@ -0,0 +1,26 @@ +package de.steamwar.comms.packets; + +import com.google.common.io.ByteArrayDataOutput; +import de.steamwar.comms.PacketIdManager; + +public class TablistNamePacket extends SpigotPacket { + + final int swUserId; + final String tablistName; + + public TablistNamePacket(int swUserId, String tablistName){ + this.swUserId = swUserId; + this.tablistName = tablistName; + } + + @Override + public int getName() { + return PacketIdManager.TABLIST_NAME; + } + + @Override + public void writeVars(ByteArrayDataOutput byteArrayDataOutput) { + byteArrayDataOutput.writeInt(swUserId); + byteArrayDataOutput.writeUTF(tablistName); + } +} From 91f3b35ed9f94cd0605bac158a934c54b61ae6bd Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 30 Oct 2020 13:52:28 +0100 Subject: [PATCH 08/24] Implementing SpectateSystem column. --- SpigotCore_Main/src/de/steamwar/sql/Event.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SpigotCore_Main/src/de/steamwar/sql/Event.java b/SpigotCore_Main/src/de/steamwar/sql/Event.java index c55260b..3b1e2a4 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/Event.java +++ b/SpigotCore_Main/src/de/steamwar/sql/Event.java @@ -34,6 +34,7 @@ public class Event { private final Timestamp end; private final int maximumTeamMembers; private final boolean publicSchemsOnly; + private final boolean spectateSystem; private Event(ResultSet rs) throws SQLException{ this.eventID = rs.getInt("EventID"); @@ -42,6 +43,7 @@ public class Event { this.end = rs.getTimestamp("End"); this.maximumTeamMembers = rs.getInt("MaximumTeamMembers"); this.publicSchemsOnly = rs.getBoolean("PublicSchemsOnly"); + this.spectateSystem = rs.getBoolean("SpectateSystem"); } public static Event get(int eventID){ @@ -75,4 +77,7 @@ public class Event { public boolean publicSchemsOnly() { return publicSchemsOnly; } + public boolean spectateSystem(){ + return spectateSystem; + } } From 27d1371e7c6579bcc83adf071b5cba53c8f7afae Mon Sep 17 00:00:00 2001 From: jojo Date: Fri, 30 Oct 2020 23:14:56 +0100 Subject: [PATCH 09/24] Fix default getTPS() limit on 20 TPS --- .../src/de/steamwar/core/TPSWatcher.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java index a0dd0b9..b805393 100644 --- a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java +++ b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java @@ -69,6 +69,10 @@ public class TPSWatcher { return getTPS(TPSType.ONE_SECOND); } + public double getTPSUnlimited() { + return getTPS(TPSType.ONE_SECOND); + } + public double getTPS(TPSType tpsType) { switch (tpsType) { case TEN_SECONDS: @@ -85,6 +89,22 @@ public class TPSWatcher { } } + public double getTPSUnlimited(TPSType tpsType) { + switch (tpsType) { + case TEN_SECONDS: + return roundUnlimited(tps_TenSecond.tps); + case ONE_MINUTE: + return roundUnlimited(getSpigotTPS()[0]); + case FIVE_MINUTES: + return roundUnlimited(getSpigotTPS()[1]); + case TEN_MINUTES: + return roundUnlimited(getSpigotTPS()[2]); + + default: + return roundUnlimited(tps_OneSecond.tps); + } + } + private double[] getSpigotTPS() { switch (Core.getVersion()) { case 8: @@ -104,6 +124,10 @@ public class TPSWatcher { } private double round(double d) { + return Math.min(Math.round(d * 10) / 10.0, 20); + } + + private double roundUnlimited(double d) { return Math.round(d * 10) / 10.0; } From b0848d3e78899f3d046a80549b788f2df34479b3 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 7 Nov 2020 11:04:54 +0100 Subject: [PATCH 10/24] Fix bugs --- SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java index b805393..9b36d29 100644 --- a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java +++ b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java @@ -70,7 +70,7 @@ public class TPSWatcher { } public double getTPSUnlimited() { - return getTPS(TPSType.ONE_SECOND); + return getTPSUnlimited(TPSType.ONE_SECOND); } public double getTPS(TPSType tpsType) { @@ -124,7 +124,7 @@ public class TPSWatcher { } private double round(double d) { - return Math.min(Math.round(d * 10) / 10.0, 20); + return Math.max(Math.round(d * 10) / 10.0, 20.0); } private double roundUnlimited(double d) { From 6bdb25a3c1ed5ded66482c0f6c4ae814f981a182 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 7 Nov 2020 11:32:38 +0100 Subject: [PATCH 11/24] Fix and simplify YoyoNows solution --- .../src/de/steamwar/core/Core.java | 2 - .../src/de/steamwar/core/TPSWatcher.java | 88 ++++++------------- 2 files changed, 28 insertions(+), 62 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/core/Core.java b/SpigotCore_Main/src/de/steamwar/core/Core.java index a7e1cab..d9c59df 100644 --- a/SpigotCore_Main/src/de/steamwar/core/Core.java +++ b/SpigotCore_Main/src/de/steamwar/core/Core.java @@ -64,8 +64,6 @@ public class Core extends JavaPlugin{ ErrorLogger.init(); getServer().getMessenger().registerIncomingPluginChannel(this, "sw:bridge", new BungeeReceiver()); getServer().getMessenger().registerOutgoingPluginChannel(this, "sw:bridge"); - TPSWatcher.init(); - } @Override diff --git a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java index 9b36d29..0e37709 100644 --- a/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java +++ b/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java @@ -23,57 +23,38 @@ import org.bukkit.Bukkit; public class TPSWatcher { - private static final double tickDefault = 20.0; + private static final double TICK_DEFAULT = 20.0; - private static TPSWatcher tps_OneSecond; - private static TPSWatcher tps_TenSecond; - - public static void init() { - tps_OneSecond = new TPSWatcher(1000); - tps_TenSecond = new TPSWatcher(10000); - } + private static final TPSWatcher tps_OneSecond = new TPSWatcher(1000); + private static final TPSWatcher tps_TenSecond = new TPSWatcher(10000); private long lastTime = System.currentTimeMillis(); - private double tps = 20.0; private TPSWatcher(long timeInterval) { Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> { - long tickTime = System.currentTimeMillis() - lastTime; - lastTime = System.currentTimeMillis(); + long currentTime = System.currentTimeMillis(); - double now = 0; - if (tickTime != 0) { - now = (timeInterval / (double) tickTime) * tickDefault; - } - if (now < 0) { - now = 0; - } - tps = now; + if (currentTime > lastTime) + tps = (timeInterval / (double) (currentTime - lastTime)) * TICK_DEFAULT; + + lastTime = currentTime; }, timeInterval / 50, timeInterval / 50); } - public enum TPSType { - - // With own implementation - ONE_SECOND, - TEN_SECONDS, - // With getting the values from Spigot itself - ONE_MINUTE, - FIVE_MINUTES, - TEN_MINUTES - - } - - public double getTPS() { + public static double getTPS() { return getTPS(TPSType.ONE_SECOND); } - public double getTPSUnlimited() { + public static double getTPSUnlimited() { return getTPSUnlimited(TPSType.ONE_SECOND); } - public double getTPS(TPSType tpsType) { + public static double getTPS(TPSType tpsType) { + return Math.min(getTPSUnlimited(tpsType), 20.0); + } + + public static double getTPSUnlimited(TPSType tpsType) { switch (tpsType) { case TEN_SECONDS: return round(tps_TenSecond.tps); @@ -83,29 +64,13 @@ public class TPSWatcher { return round(getSpigotTPS()[1]); case TEN_MINUTES: return round(getSpigotTPS()[2]); - + case ONE_SECOND: default: return round(tps_OneSecond.tps); } } - public double getTPSUnlimited(TPSType tpsType) { - switch (tpsType) { - case TEN_SECONDS: - return roundUnlimited(tps_TenSecond.tps); - case ONE_MINUTE: - return roundUnlimited(getSpigotTPS()[0]); - case FIVE_MINUTES: - return roundUnlimited(getSpigotTPS()[1]); - case TEN_MINUTES: - return roundUnlimited(getSpigotTPS()[2]); - - default: - return roundUnlimited(tps_OneSecond.tps); - } - } - - private double[] getSpigotTPS() { + private static double[] getSpigotTPS() { switch (Core.getVersion()) { case 8: return SpigotTPS_8.getTps(); @@ -113,22 +78,25 @@ public class TPSWatcher { return SpigotTPS_9.getTps(); case 10: return SpigotTPS_10.getTps(); + case 12: + return SpigotTPS_12.getTps(); case 14: return SpigotTPS_14.getTps(); case 15: - return SpigotTPS_15.getTps(); - default: - return SpigotTPS_12.getTps(); + return SpigotTPS_15.getTps(); } } - private double round(double d) { - return Math.max(Math.round(d * 10) / 10.0, 20.0); - } - - private double roundUnlimited(double d) { + private static double round(double d) { return Math.round(d * 10) / 10.0; } + public enum TPSType { + ONE_SECOND, + TEN_SECONDS, + ONE_MINUTE, + FIVE_MINUTES, + TEN_MINUTES + } } From c6c101a40f9f76f78a8bf9f1f3e72a45d09b3edf Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 10 Nov 2020 10:36:58 +0100 Subject: [PATCH 12/24] Also log warnings --- .../src/de/steamwar/core/ErrorLogger.java | 8 ++- .../src/de/steamwar/sql/SWException.java | 67 ++++++++++++------- 2 files changed, 48 insertions(+), 27 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/core/ErrorLogger.java b/SpigotCore_Main/src/de/steamwar/core/ErrorLogger.java index d2061ad..b4ba2f1 100644 --- a/SpigotCore_Main/src/de/steamwar/core/ErrorLogger.java +++ b/SpigotCore_Main/src/de/steamwar/core/ErrorLogger.java @@ -20,14 +20,16 @@ package de.steamwar.core; import de.steamwar.sql.SWException; -import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.core.Appender; import org.apache.logging.log4j.core.Core; -import org.apache.logging.log4j.core.*; +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.LoggerContext; import org.apache.logging.log4j.core.appender.AbstractAppender; import org.apache.logging.log4j.core.config.plugins.Plugin; import org.apache.logging.log4j.core.config.plugins.PluginAttribute; import org.apache.logging.log4j.core.config.plugins.PluginFactory; +import org.apache.logging.log4j.spi.StandardLevel; @Plugin(name = "ErrorLogger", category = Core.CATEGORY_NAME, elementType = Appender.ELEMENT_TYPE) public class ErrorLogger extends AbstractAppender { @@ -53,7 +55,7 @@ public class ErrorLogger extends AbstractAppender { @Override public void append(LogEvent logEvent) { - if(logEvent.getLevel().isLessSpecificThan(Level.WARN)) + if(logEvent.getLevel().intLevel() > StandardLevel.WARN.intLevel()) return; SWException.log(logEvent); diff --git a/SpigotCore_Main/src/de/steamwar/sql/SWException.java b/SpigotCore_Main/src/de/steamwar/sql/SWException.java index 31cd1ef..40f7335 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SWException.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SWException.java @@ -23,21 +23,58 @@ import org.apache.logging.log4j.core.LogEvent; import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + public class SWException { private SWException(){} private static boolean logDisabled = false; + private static final List ignorereasons; + + static { + List reasons = new ArrayList<>(); + reasons.add("Initializing Legacy Material Support."); + reasons.add("Could not save the list after adding a user."); + reasons.add("Failed to save operators list:"); + reasons.add("Block at"); + reasons.add("POI data mismatch"); + reasons.add("This crash report has been saved to:"); + reasons.add("Could not pass event PlayerQuitEvent to WorldEditSUI"); + reasons.add("[ViaVersion] Failed to remove injection handler"); + reasons.add("Something went wrong upgrading!"); + reasons.add("Tried to load unrecognized recipe"); + ignorereasons = Collections.unmodifiableList(reasons); + } public static void log(LogEvent logEvent){ if(logDisabled) return; - String server = Bukkit.getWorlds().get(0).getName(); - StringBuilder stacktrace = new StringBuilder(logEvent.getSource().toString()); + String message = logEvent.getMessage().getFormattedMessage(); + for(String reason : ignorereasons) + if(message.startsWith(reason)) + return; + switch (message) { + case "The server has stopped responding!": + logDisabled = true; + return; + case "------------------------------": + message = "Server stopped responding"; + logDisabled = true; + break; + case "Exception stopping the server": + logDisabled = true; + break; + default: + } + + StringBuilder stacktrace = new StringBuilder(logEvent.getSource().toString()); Throwable throwable = logEvent.getThrown(); while(throwable != null){ - stacktrace.append("\nCaused by ").append(throwable.getMessage()); + stacktrace.append("\nCaused by ").append(throwable.getClass().getName()).append(": ").append(throwable.getMessage()); for(StackTraceElement ste : throwable.getStackTrace()) stacktrace.append("\n").append(ste.toString()); @@ -46,32 +83,14 @@ public class SWException { } String st = stacktrace.toString(); - - String message = logEvent.getMessage().getFormattedMessage(); - if(message.startsWith("Block at") || message.startsWith("POI data mismatch") || st.contains("POI data mismatch")) - return; - else if(message.equals("The server has stopped responding!")){ - logDisabled = true; - return; - }else if(message.equals("------------------------------")){ - message = "Server stopped responding"; - logDisabled = true; - }else if(message.equals("Exception stopping the server")){ - logDisabled = true; - }else if(message.startsWith("This crash report has been saved to:") || message.startsWith("Could not pass event PlayerQuitEvent to WorldEditSUI")){ - return; - }else if(message.startsWith("[ViaVersion] Failed to remove injection handler") || message.startsWith("Something went wrong upgrading!")) - return; - else if(message.startsWith("Tried to load unrecognized recipe")) + if(st.contains("POI data mismatch")) return; - - message += "\n\n"; - + message += "\n"; for(Player player : Bukkit.getOnlinePlayers()) message += player.getName() + " "; SQL.update("INSERT INTO Exception (server, message, stacktrace) VALUES (?, ?, ?)", - server, message, st); + Bukkit.getWorlds().get(0).getName(), message, st); } } From e039392d017271b5cb3969764e8c16881ea712a2 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 11 Nov 2020 13:45:02 +0100 Subject: [PATCH 13/24] Remove unneccessary logged warnings --- SpigotCore_Main/src/de/steamwar/sql/SWException.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SWException.java b/SpigotCore_Main/src/de/steamwar/sql/SWException.java index 40f7335..59aaa08 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SWException.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SWException.java @@ -45,6 +45,8 @@ public class SWException { reasons.add("[ViaVersion] Failed to remove injection handler"); reasons.add("Something went wrong upgrading!"); reasons.add("Tried to load unrecognized recipe"); + reasons.add("Invalid BlockState in palette:"); + reasons.add("Could not register alias toggleclipboard"); ignorereasons = Collections.unmodifiableList(reasons); } @@ -57,6 +59,9 @@ public class SWException { if(message.startsWith(reason)) return; + if(message.contains("moved too quickly!") || message.contains("was kicked for floating too long!")) + return; + switch (message) { case "The server has stopped responding!": logDisabled = true; From 436341e25da5e0ca9bdef8f5423f3f13db8209cd Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 11 Nov 2020 14:54:48 +0100 Subject: [PATCH 14/24] Remove unneccessary logged warnings --- SpigotCore_Main/src/de/steamwar/sql/SWException.java | 1 + 1 file changed, 1 insertion(+) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SWException.java b/SpigotCore_Main/src/de/steamwar/sql/SWException.java index 59aaa08..e646f61 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SWException.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SWException.java @@ -47,6 +47,7 @@ public class SWException { reasons.add("Tried to load unrecognized recipe"); reasons.add("Invalid BlockState in palette:"); reasons.add("Could not register alias toggleclipboard"); + reasons.add("Can't keep up! Is the server overloaded?"); ignorereasons = Collections.unmodifiableList(reasons); } From 8794e1c50fa696ec2b7295d4bef524c2ced70dc4 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 11 Nov 2020 15:09:35 +0100 Subject: [PATCH 15/24] Remove unneccessary logged warnings --- SpigotCore_Main/src/de/steamwar/sql/SWException.java | 1 + 1 file changed, 1 insertion(+) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SWException.java b/SpigotCore_Main/src/de/steamwar/sql/SWException.java index e646f61..2b15c6f 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SWException.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SWException.java @@ -48,6 +48,7 @@ public class SWException { reasons.add("Invalid BlockState in palette:"); reasons.add("Could not register alias toggleclipboard"); reasons.add("Can't keep up! Is the server overloaded?"); + reasons.add("\tat "); ignorereasons = Collections.unmodifiableList(reasons); } From 94a28078bd81c4ef677bcb586e4a921a6a2b3be0 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 11 Nov 2020 15:36:27 +0100 Subject: [PATCH 16/24] Remove unneccessary logged warnings --- SpigotCore_Main/src/de/steamwar/sql/SWException.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SWException.java b/SpigotCore_Main/src/de/steamwar/sql/SWException.java index 2b15c6f..0d8617d 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SWException.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SWException.java @@ -43,12 +43,14 @@ public class SWException { reasons.add("This crash report has been saved to:"); reasons.add("Could not pass event PlayerQuitEvent to WorldEditSUI"); reasons.add("[ViaVersion] Failed to remove injection handler"); + reasons.add("[ViaBackwards] Metadata for entity id"); reasons.add("Something went wrong upgrading!"); reasons.add("Tried to load unrecognized recipe"); reasons.add("Invalid BlockState in palette:"); - reasons.add("Could not register alias toggleclipboard"); + reasons.add("Could not register alias"); reasons.add("Can't keep up! Is the server overloaded?"); reasons.add("\tat "); + reasons.add("java.lang.Exception"); ignorereasons = Collections.unmodifiableList(reasons); } @@ -61,7 +63,7 @@ public class SWException { if(message.startsWith(reason)) return; - if(message.contains("moved too quickly!") || message.contains("was kicked for floating too long!")) + if(message.contains("moved too quickly!") || message.contains("moved wrongly!") || message.contains("was kicked for floating too long!")) return; switch (message) { From 7cccbbd2670b6d1004bf2bfea0958f8cb2102bf8 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 11 Nov 2020 15:39:15 +0100 Subject: [PATCH 17/24] Remove unneccessary logged warnings --- SpigotCore_Main/src/de/steamwar/sql/SWException.java | 1 + 1 file changed, 1 insertion(+) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SWException.java b/SpigotCore_Main/src/de/steamwar/sql/SWException.java index 0d8617d..f3957b6 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SWException.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SWException.java @@ -51,6 +51,7 @@ public class SWException { reasons.add("Can't keep up! Is the server overloaded?"); reasons.add("\tat "); reasons.add("java.lang.Exception"); + reasons.add("[ViaVersion] Ignoring plugin channel"); ignorereasons = Collections.unmodifiableList(reasons); } From 3f544d486ab4f428de1f7c37561ac89f15afe6b7 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 12 Nov 2020 14:19:47 +0100 Subject: [PATCH 18/24] Remove unneccessary logged warnings --- SpigotCore_Main/src/de/steamwar/sql/SWException.java | 1 + 1 file changed, 1 insertion(+) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SWException.java b/SpigotCore_Main/src/de/steamwar/sql/SWException.java index f3957b6..b255287 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SWException.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SWException.java @@ -52,6 +52,7 @@ public class SWException { reasons.add("\tat "); reasons.add("java.lang.Exception"); reasons.add("[ViaVersion] Ignoring plugin channel"); + reasons.add("[ViaBackwards] Ignoring plugin channel"); ignorereasons = Collections.unmodifiableList(reasons); } From ac633a8f4ce3fe6fbe05663ebded7a0849d172c4 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 13 Nov 2020 14:50:17 +0100 Subject: [PATCH 19/24] Adding ingorereason --- SpigotCore_Main/src/de/steamwar/sql/SWException.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SWException.java b/SpigotCore_Main/src/de/steamwar/sql/SWException.java index b255287..67eb70b 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SWException.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SWException.java @@ -51,7 +51,7 @@ public class SWException { reasons.add("Can't keep up! Is the server overloaded?"); reasons.add("\tat "); reasons.add("java.lang.Exception"); - reasons.add("[ViaVersion] Ignoring plugin channel"); + reasons.add("[ViaVersion] Ignoring"); reasons.add("[ViaBackwards] Ignoring plugin channel"); ignorereasons = Collections.unmodifiableList(reasons); } From 4aed213c17f1798e54a72b8e6e3c45fd490052d8 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 15 Nov 2020 08:04:48 +0100 Subject: [PATCH 20/24] Ignore more --- SpigotCore_Main/src/de/steamwar/sql/SWException.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SWException.java b/SpigotCore_Main/src/de/steamwar/sql/SWException.java index 67eb70b..6e25052 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SWException.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SWException.java @@ -52,7 +52,7 @@ public class SWException { reasons.add("\tat "); reasons.add("java.lang.Exception"); reasons.add("[ViaVersion] Ignoring"); - reasons.add("[ViaBackwards] Ignoring plugin channel"); + reasons.add("[ViaBackwards] Ignoring"); ignorereasons = Collections.unmodifiableList(reasons); } From ebee8ae3471576a128a8ea7bf7b913acf17b9e41 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 15 Nov 2020 08:14:40 +0100 Subject: [PATCH 21/24] Fix launch exceptions --- SpigotCore_Main/src/de/steamwar/sql/SWException.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SWException.java b/SpigotCore_Main/src/de/steamwar/sql/SWException.java index 6e25052..929d5ef 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SWException.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SWException.java @@ -101,7 +101,13 @@ public class SWException { for(Player player : Bukkit.getOnlinePlayers()) message += player.getName() + " "; + String server; + if(Bukkit.getWorlds().isEmpty()) + server = Bukkit.getName(); + else + server = Bukkit.getWorlds().get(0).getName(); + SQL.update("INSERT INTO Exception (server, message, stacktrace) VALUES (?, ?, ?)", - Bukkit.getWorlds().get(0).getName(), message, st); + server, message, st); } } From e0172f495dc0f5742f5843e4062d24c4d784157b Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 15 Nov 2020 11:01:36 +0100 Subject: [PATCH 22/24] Adding ignored messages --- SpigotCore_Main/src/de/steamwar/sql/SWException.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SWException.java b/SpigotCore_Main/src/de/steamwar/sql/SWException.java index 929d5ef..67c2724 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SWException.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SWException.java @@ -40,6 +40,12 @@ public class SWException { reasons.add("Failed to save operators list:"); reasons.add("Block at"); reasons.add("POI data mismatch"); + reasons.add("handleDisconnection() called twice"); + reasons.add("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); + reasons.add("The server will make no attempt to authenticate usernames. Beware."); + reasons.add("Whilst this makes it possible to use BungeeCord,"); + reasons.add("Please see http://www.spigotmc.org/wiki/firewall-guide/ for further information."); + reasons.add("To change this, set \"online-mode\" to \"true\" in the server.properties file."); reasons.add("This crash report has been saved to:"); reasons.add("Could not pass event PlayerQuitEvent to WorldEditSUI"); reasons.add("[ViaVersion] Failed to remove injection handler"); From 05e8a8322811a6d829c698dd8f43fd3e05f593c1 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 15 Nov 2020 11:06:13 +0100 Subject: [PATCH 23/24] Fixing player.playSound in 1.12 --- SpigotCore_Main/src/de/steamwar/comms/BungeeReceiver.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/comms/BungeeReceiver.java b/SpigotCore_Main/src/de/steamwar/comms/BungeeReceiver.java index 7c1ba11..5ebdcae 100644 --- a/SpigotCore_Main/src/de/steamwar/comms/BungeeReceiver.java +++ b/SpigotCore_Main/src/de/steamwar/comms/BungeeReceiver.java @@ -26,7 +26,6 @@ import de.steamwar.comms.handlers.InventoryHandler; import de.steamwar.sql.SteamwarUser; import org.bukkit.Bukkit; import org.bukkit.Sound; -import org.bukkit.SoundCategory; import org.bukkit.entity.Player; import org.bukkit.plugin.messaging.PluginMessageListener; @@ -47,7 +46,7 @@ public class BungeeReceiver implements PluginMessageListener { UUID uuid = SteamwarUser.get(byteArrayDataInput.readInt()).getUUID(); if(Bukkit.getPlayer(uuid).isOnline()) { Player player = Bukkit.getPlayer(uuid); - player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.MASTER, 1, 1); + player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); } }); From fb59bf431705579978fbca6f315b473b1deab914 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 15 Nov 2020 11:22:45 +0100 Subject: [PATCH 24/24] Fixing player.playSound in 1.8 --- .../de/steamwar/comms/BungeeReceiver_8.java | 30 +++++++++++++++++++ .../de/steamwar/comms/BungeeReceiver_9.java | 30 +++++++++++++++++++ .../src/de/steamwar/comms/BungeeReceiver.java | 8 +++-- 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 SpigotCore_8/src/de/steamwar/comms/BungeeReceiver_8.java create mode 100644 SpigotCore_9/src/de/steamwar/comms/BungeeReceiver_9.java diff --git a/SpigotCore_8/src/de/steamwar/comms/BungeeReceiver_8.java b/SpigotCore_8/src/de/steamwar/comms/BungeeReceiver_8.java new file mode 100644 index 0000000..2b2ce08 --- /dev/null +++ b/SpigotCore_8/src/de/steamwar/comms/BungeeReceiver_8.java @@ -0,0 +1,30 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2020 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.comms; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +public class BungeeReceiver_8 { + + public static void playPling(Player player) { + player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1, 1); + } +} diff --git a/SpigotCore_9/src/de/steamwar/comms/BungeeReceiver_9.java b/SpigotCore_9/src/de/steamwar/comms/BungeeReceiver_9.java new file mode 100644 index 0000000..685b65a --- /dev/null +++ b/SpigotCore_9/src/de/steamwar/comms/BungeeReceiver_9.java @@ -0,0 +1,30 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2020 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.comms; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +public class BungeeReceiver_9 { + + public static void playpling(Player player) { + player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); + } +} diff --git a/SpigotCore_Main/src/de/steamwar/comms/BungeeReceiver.java b/SpigotCore_Main/src/de/steamwar/comms/BungeeReceiver.java index 5ebdcae..103e72f 100644 --- a/SpigotCore_Main/src/de/steamwar/comms/BungeeReceiver.java +++ b/SpigotCore_Main/src/de/steamwar/comms/BungeeReceiver.java @@ -23,9 +23,9 @@ import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteStreams; import de.steamwar.comms.handlers.BungeeHandler; import de.steamwar.comms.handlers.InventoryHandler; +import de.steamwar.core.Core; import de.steamwar.sql.SteamwarUser; import org.bukkit.Bukkit; -import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.plugin.messaging.PluginMessageListener; @@ -46,7 +46,11 @@ public class BungeeReceiver implements PluginMessageListener { UUID uuid = SteamwarUser.get(byteArrayDataInput.readInt()).getUUID(); if(Bukkit.getPlayer(uuid).isOnline()) { Player player = Bukkit.getPlayer(uuid); - player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); + if (Core.getVersion() == 8) { + BungeeReceiver_8.playPling(player); + } else { + BungeeReceiver_9.playpling(player); + } } });