diff --git a/README.md b/README.md
index bd48dd5..98d3bf3 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
-# SimplifyTools
+![SimplifyTools logo](docs/img/SimplifyTools.png)
### An 'All-in-one' plugin for MC servers.
#### TabList Customizing, Custom Advancement, Connect messages, AutoSave, Logger
- [![Build Status](https://ci.ditservices.hu/job/SimplifyTools/badge/icon)](https://ci.ditservices.hu/job/SimplifyTools/) ![ MC Version](https://ci.ditservices.hu/job/SimplifyTools/badge/icon?subject=MC&status=1.12%20-%201.20.1&color=darkblue) ![Git latest release](https://img.shields.io/github/v/release/LabodiDavid/SimplifyTools) [![bStats](https://ci.ditservices.hu/job/SimplifyTools/badge/icon?subject=bStats&status=3.0&color=brightgreen)](https://bstats.org/plugin/bukkit/SimplifyTools/15108) ![Lines of code](https://tokei.rs/b1/github/LabodiDavid/SimplifyTools?category=code)
+ [![Build Status](https://ci.ditservices.hu/job/SimplifyTools/badge/icon)](https://ci.ditservices.hu/job/SimplifyTools/) ![ MC Version](https://ci.ditservices.hu/job/SimplifyTools/badge/icon?subject=MC&status=1.12%20-%201.21.4&color=darkblue) ![Git latest release](https://img.shields.io/github/v/release/LabodiDavid/SimplifyTools) [![bStats](https://ci.ditservices.hu/job/SimplifyTools/badge/icon?subject=bStats&status=3.0&color=brightgreen)](https://bstats.org/plugin/bukkit/SimplifyTools/15108) ![Lines of code](https://tokei.rs/b1/github/LabodiDavid/SimplifyTools?category=code)
[Changelog](docs/ChangeLog.md)
@@ -23,6 +23,11 @@
(Note: The advancement names are currently only can be displayed in english. In future versions there will be a feature to translate to any languages.)
![Advancement Messages preview](docs/img/4.gif)
- **Logging** - A logger with fully customizable format for dis/connect, chat, commands actions.
+_________________
+### Dependencies
+#### From version [v1.2.3](https://github.com/LabodiDavid/SimplifyTools/releases/tag/1.2.3) the plugin requires [ProtocolLib](https://github.com/dmulloy2/ProtocolLib/)
+_________________
+
### [Check the config file for more explanation and examples](https://github.com/LabodiDavid/SimplifyTools/blob/main/src/main/resources/config.yml)
_________________
### [Commands & Permissions](docs/cmd_perms.md)
@@ -35,5 +40,6 @@ _________________
My main goal is to create a single plugin that has many features, so it's can replace plugins that i often use on my servers while lowering the plugins count.
_________________
## 3rd party libraries used by this plugin
+### [ProtocolLib by dmulloy2](https://github.com/dmulloy2/ProtocolLib/)
### [Config-Updater by tchristofferson](https://github.com/tchristofferson/Config-Updater)
### [SpigotUpdateChecker by JEFF-Media-GbR](https://github.com/JEFF-Media-GbR/Spigot-UpdateChecker)
\ No newline at end of file
diff --git a/docs/ChangeLog.md b/docs/ChangeLog.md
index dd6917f..22fe3ab 100644
--- a/docs/ChangeLog.md
+++ b/docs/ChangeLog.md
@@ -1,21 +1,29 @@
# SimplifyTools - Changelog
-- 1.2.1
+- **1.2.3**
+ - Added support for version up to 1.21.4
+ - The plugin now depends on, requires ProtocolLib (https://github.com/dmulloy2/ProtocolLib/)
+ - Tab feature adjustments, refactor for ProtocolLib
+ - Removed Reflection (~300 lines of code)
+ - Showing more feature setting statuses in `/st settings`
+- **1.2.2**
+ - Added support for version up to 1.20.2
+- **1.2.1**
- Added support for version up to 1.20.1
- Plugin manager added setting, now disabled by default in the config.
- Removed coloring of the logs in the server console
- TPS number displayed in the TAB now rounded to the nearest integer.
- Minor code refactors
- - 1.2.0
+ - **1.2.0**
- Added TPS command `/st tps`
- Added `{MOTD}`, `{TPS}` variable for TAB customization in the config
- Refactored code for multi version support (1.12 - 1.19.3)
- Fixes [#1](https://github.com/LabodiDavid/SimplifyTools/issues/1)
- - 1.1.0
+ - **1.1.0**
- Updated to 1.18.2
- Minor changes
- Temporarily reworked Plugin Manager
- Added Update Checker (https://github.com/JEFF-Media-GbR/Spigot-UpdateChecker)
- Implemented Metrics (bStats)
- - 1.0.0 - First Release
- - Notice: If the /st reload command not reloading the new settings, you need to restart your MC server.
+ - **1.0.0** - First Release
+ - Notice: If the `/st reload` command not reloading the new settings, you need to restart your MC server.
diff --git a/docs/img/ST.png b/docs/img/ST.png
new file mode 100644
index 0000000..633a95d
Binary files /dev/null and b/docs/img/ST.png differ
diff --git a/docs/img/SimplifyTools.png b/docs/img/SimplifyTools.png
new file mode 100644
index 0000000..c050727
Binary files /dev/null and b/docs/img/SimplifyTools.png differ
diff --git a/src/main/java/hu/ditservices/handlers/TabHandler.java b/src/main/java/hu/ditservices/handlers/TabHandler.java
index 168571e..9f92c7f 100644
--- a/src/main/java/hu/ditservices/handlers/TabHandler.java
+++ b/src/main/java/hu/ditservices/handlers/TabHandler.java
@@ -5,10 +5,9 @@ import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import hu.ditservices.STPlugin;
-import hu.ditservices.utils.*;
import hu.ditservices.utils.Math;
-import hu.ditservices.utils.reflection.ClazzContainer;
-import hu.ditservices.utils.reflection.Reflection;
+import hu.ditservices.utils.Server;
+import hu.ditservices.utils.TPS;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@@ -17,9 +16,6 @@ import java.util.ArrayList;
import java.util.List;
public class TabHandler {
- public final List headers = new ArrayList<>();
- public final List footers = new ArrayList<>();
-
public final List headerComponents = new ArrayList<>();
public final List footerComponents = new ArrayList<>();
@@ -37,31 +33,20 @@ public class TabHandler {
private int count2 = 0; //footers
private Object packet;
- private boolean isNewerThan1_20_2;
-
- public TabHandler() throws Exception {
+ public TabHandler() {
this.plugin = STPlugin.getInstance();
- this.isNewerThan1_20_2 = Version.ServerVersion.isCurrentHigher(Version.ServerVersion.v1_20_R2);
+
if(this.init()){
- if ((headers.isEmpty() && footers.isEmpty() && !isNewerThan1_20_2)
- || (headerComponents.isEmpty() && footerComponents.isEmpty() && isNewerThan1_20_2)){
- plugin.getLogger().warning(plugin.getPrefix()+"TAB customization disabled because empty customization config!");
+ if (headerComponents.isEmpty() && footerComponents.isEmpty()){
+ plugin.getLogger().warning(plugin.getPrefix()+"TAB customization disabled because empty customization config or feature related errors!");
return;
}
this.updateTab();
- /*packet = plugin.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_LIST_HEADER_FOOTER);
- boolean both = headers.size() > 0 && footers.size() > 0;
- boolean header = !both && headers.size() > 0;
- boolean footer = !both && footers.size() > 0;*/
-
- //scheduleSyncRepeatingTask
- //Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new TabRunnable(this),20, Math.convert(Math.Convert.SECONDS,Math.Convert.TICKS,this.refreshRate));
}
}
-
- private boolean init() throws Exception {
+ private boolean init() {
if (plugin.getConfig().getBoolean("Tab.enabled")){
int availProcessors = Server.getCpuCores();
@@ -124,20 +109,12 @@ public class TabHandler {
if (Bukkit.getOnlinePlayers().isEmpty()){
return;
}
- if (isNewerThan1_20_2) {
- if (count1 >= headerComponents.size()) {
- count1 = 0;
- }
- if (count2 >= footerComponents.size()) {
- count2 = 0;
- }
- } else {
- if (count1 >= headers.size()) {
- count1 = 0;
- }
- if (count2 >= footers.size()) {
- count2 = 0;
- }
+
+ if (count1 >= headerComponents.size()) {
+ count1 = 0;
+ }
+ if (count2 >= footerComponents.size()) {
+ count2 = 0;
}
//Re adding all lines where we replaced something like the RAM usage to every refresh
@@ -153,36 +130,21 @@ public class TabHandler {
}
}
- if (Version.ServerVersion.isCurrentEqualOrLower(Version.ServerVersion.v1_12_R1)) {
- packet = ClazzContainer.buildPacketPlayOutPlayerListHeaderFooter(headers.get(count1),footers.get(count2));
- for (Player player : Bukkit.getOnlinePlayers()){
- Reflection.sendPacket(player,packet);
- }
- } else if (Version.ServerVersion.isCurrentHigher(Version.ServerVersion.v1_20_R2)) {
- // Use ProtocolLib for versions higher than 1.20.2
- ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
- PacketContainer packet = protocolManager.createPacket(com.comphenix.protocol.PacketType.Play.Server.PLAYER_LIST_HEADER_FOOTER);
+ ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
+ PacketContainer packet = protocolManager.createPacket(com.comphenix.protocol.PacketType.Play.Server.PLAYER_LIST_HEADER_FOOTER);
- // Set header and footer
- packet.getChatComponents().write(0, headerComponents.get(count1));
- packet.getChatComponents().write(1, footerComponents.get(count2));
+ packet.getChatComponents().write(0, headerComponents.get(count1));
+ packet.getChatComponents().write(1, footerComponents.get(count2));
- // Send the packet to all players
- for (Player player : Bukkit.getOnlinePlayers()) {
- protocolManager.sendServerPacket(player, packet);
- }
- } else {
- // Use the built-in Spigot API for versions between 1.13 and 1.20.1
- for (Player player : Bukkit.getOnlinePlayers()) {
- player.setPlayerListHeaderFooter(headers.get(count1), footers.get(count2));
- }
+ for (Player player : Bukkit.getOnlinePlayers()) {
+ protocolManager.sendServerPacket(player, packet);
}
- if (headers.size() > 1 || headerComponents.size() > 1) {
+ if (headerComponents.size() > 1) {
count1++;
}
- if (footers.size() > 1 || footerComponents.size() > 1) {
+ if (footerComponents.size() > 1) {
count2++;
}
@@ -199,47 +161,28 @@ public class TabHandler {
* Manages the adding of the tab line and the final formatting of the text.
* @param header If true the text will be added to the header, otherwise to the footer.
* @param text The formatted tab line text.
- * @param dynamic If the text contains a replace which need to run every tab refresh then it's true.
+ * @param dynamic If the text contains a replacement which need to run every tab refresh then it's true.
* @param index Index of the 'dynamic' line. This is an overloading so there we need the index[0] element.
*/
private void addHeaderFooter(boolean header,String text,boolean dynamic,int... index) {
try {
String Json = "{\"text\": \""+format(text)+"\"}";
- boolean isNewerThan1202 = Version.ServerVersion.isCurrentHigher(Version.ServerVersion.v1_20_R2);
+ WrappedChatComponent tabText = WrappedChatComponent.fromJson(Json);
- if (isNewerThan1202) {
- WrappedChatComponent tabText = WrappedChatComponent.fromJson(Json);
-
- if (header){
- if (dynamic){
- headerComponents.set(index[0], tabText);
- }else {
- headerComponents.add(tabText);
- }
- }else{
- if (dynamic){
- footerComponents.set(index[0], tabText);
- }else {
- footerComponents.add(tabText);
- }
+ if (header){
+ if (dynamic){
+ headerComponents.set(index[0], tabText);
+ }else {
+ headerComponents.add(tabText);
}
- } else {
- Object tabText = Reflection.asChatSerializer(Json);
-
- if (header){
- if (dynamic){
- headers.set(index[0], Reflection.getChatSerializerString(tabText));
- }else {
- headers.add(Reflection.getChatSerializerString(tabText));
- }
- }else{
- if (dynamic){
- footers.set(index[0], Reflection.getChatSerializerString(tabText));
- }else {
- footers.add(Reflection.getChatSerializerString(tabText));
- }
+ }else{
+ if (dynamic){
+ footerComponents.set(index[0], tabText);
+ } else {
+ footerComponents.add(tabText);
}
}
+
} catch (Exception e){
e.printStackTrace();
}
diff --git a/src/main/java/hu/ditservices/utils/reflection/ClazzContainer.java b/src/main/java/hu/ditservices/utils/reflection/ClazzContainer.java
index 0177100..79527d0 100644
--- a/src/main/java/hu/ditservices/utils/reflection/ClazzContainer.java
+++ b/src/main/java/hu/ditservices/utils/reflection/ClazzContainer.java
@@ -1,3 +1,4 @@
+/*
package hu.ditservices.utils.reflection;
import hu.ditservices.utils.Version;
@@ -91,3 +92,4 @@ public final class ClazzContainer {
return packet;
}
}
+*/
diff --git a/src/main/java/hu/ditservices/utils/reflection/Reflection.java b/src/main/java/hu/ditservices/utils/reflection/Reflection.java
index f24f188..3a424fa 100644
--- a/src/main/java/hu/ditservices/utils/reflection/Reflection.java
+++ b/src/main/java/hu/ditservices/utils/reflection/Reflection.java
@@ -1,3 +1,4 @@
+/*
package hu.ditservices.utils.reflection;
import hu.ditservices.utils.Version;
@@ -100,7 +101,8 @@ public class Reflection {
//return ClazzContainer.getIChatBaseComponent().cast(chatSerializerMethodA.invoke(chatSerializer, json));
}
- /*public static Class> getNMSClassRegex(String nmsClass) {
+ */
+/*public static Class> getNMSClassRegex(String nmsClass) {
String version = null;
Pattern pat = Pattern.compile("net\\.minecraft\\.(?:server)?\\.(v(?:\\d_)+R\\d)");
@@ -118,5 +120,7 @@ public class Reflection {
return null;
}
- }*/
+ }*//*
+
}
+*/
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index c83934b..2bab73d 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -7,7 +7,7 @@ load: POSTWORLD
description: SimplifyTools - An All-in-one helper plugin.
author: SimplifyDave
website: https://ditservices.hu
-#depend: [ProtocolLib]
+depend: [ ProtocolLib ]
commands:
st:
description: The default command for the plugin.