Compare commits
No commits in common. "36f4896dce39dcd2cf8dc70ab60e0e8ffeb02746" and "524510ae14eb5dd507fa8ef088ea018931789f55" have entirely different histories.
36f4896dce
...
524510ae14
3
.idea/compiler.xml
generated
3
.idea/compiler.xml
generated
@ -9,5 +9,8 @@
|
|||||||
<module name="SimplifyTools" />
|
<module name="SimplifyTools" />
|
||||||
</profile>
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
|
<bytecodeTargetLevel>
|
||||||
|
<module name="SimplifyTools" target="1.8" />
|
||||||
|
</bytecodeTargetLevel>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
21
.idea/jarRepositories.xml
generated
21
.idea/jarRepositories.xml
generated
@ -6,16 +6,16 @@
|
|||||||
<option name="name" value="Central Repository" />
|
<option name="name" value="Central Repository" />
|
||||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="papermc" />
|
|
||||||
<option name="name" value="papermc" />
|
|
||||||
<option name="url" value="https://papermc.io/repo/repository/maven-public/" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="jeff-media-public" />
|
<option name="id" value="jeff-media-public" />
|
||||||
<option name="name" value="jeff-media-public" />
|
<option name="name" value="jeff-media-public" />
|
||||||
<option name="url" value="https://hub.jeff-media.com/nexus/repository/jeff-media-public/" />
|
<option name="url" value="https://hub.jeff-media.com/nexus/repository/jeff-media-public/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="papermc" />
|
||||||
|
<option name="name" value="papermc" />
|
||||||
|
<option name="url" value="https://papermc.io/repo/repository/maven-public/" />
|
||||||
|
</remote-repository>
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="sonatype" />
|
<option name="id" value="sonatype" />
|
||||||
<option name="name" value="sonatype" />
|
<option name="name" value="sonatype" />
|
||||||
@ -32,20 +32,15 @@
|
|||||||
<option name="url" value="https://repo.dmulloy2.net/repository/public/" />
|
<option name="url" value="https://repo.dmulloy2.net/repository/public/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="spigot-repo" />
|
<option name="id" value="central" />
|
||||||
<option name="name" value="spigot-repo" />
|
<option name="name" value="Maven Central repository" />
|
||||||
<option name="url" value="https://hub.spigotmc.org/nexus/content/groups/public/" />
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="spigot" />
|
<option name="id" value="spigot" />
|
||||||
<option name="name" value="spigot" />
|
<option name="name" value="spigot" />
|
||||||
<option name="url" value="https://hub.spigotmc.org/nexus/content/groups/public/" />
|
<option name="url" value="https://hub.spigotmc.org/nexus/content/groups/public/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="central" />
|
|
||||||
<option name="name" value="Maven Central repository" />
|
|
||||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="jboss.community" />
|
<option name="id" value="jboss.community" />
|
||||||
<option name="name" value="JBoss Community repository" />
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@ -5,7 +5,6 @@
|
|||||||
<item index="0" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
|
<item index="0" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
|
||||||
</list>
|
</list>
|
||||||
</component>
|
</component>
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
|
||||||
<component name="MavenProjectsManager">
|
<component name="MavenProjectsManager">
|
||||||
<option name="originalFiles">
|
<option name="originalFiles">
|
||||||
<list>
|
<list>
|
||||||
|
10
.idea/runConfigurations.xml
generated
Normal file
10
.idea/runConfigurations.xml
generated
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RunConfigurationProducerService">
|
||||||
|
<option name="ignoredProducers">
|
||||||
|
<set>
|
||||||
|
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
10
README.md
10
README.md
@ -1,7 +1,7 @@
|
|||||||

|
# SimplifyTools
|
||||||
### An 'All-in-one' plugin for MC servers.
|
### An 'All-in-one' plugin for MC servers.
|
||||||
#### TabList Customizing, Custom Advancement, Connect messages, AutoSave, Logger
|
#### TabList Customizing, Custom Advancement, Connect messages, AutoSave, Logger
|
||||||
[](https://ci.ditservices.hu/job/SimplifyTools/)   [](https://bstats.org/plugin/bukkit/SimplifyTools/15108) 
|
[](https://ci.ditservices.hu/job/SimplifyTools/)   [](https://bstats.org/plugin/bukkit/SimplifyTools/15108) 
|
||||||
<br>[Changelog](docs/ChangeLog.md)
|
<br>[Changelog](docs/ChangeLog.md)
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
@ -23,11 +23,6 @@
|
|||||||
(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.)
|
(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.)
|
||||||

|

|
||||||
- **Logging** - A logger with fully customizable format for dis/connect, chat, commands actions.
|
- **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)
|
### [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)
|
### [Commands & Permissions](docs/cmd_perms.md)
|
||||||
@ -40,6 +35,5 @@ _________________
|
|||||||
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.
|
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
|
## 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)
|
### [Config-Updater by tchristofferson](https://github.com/tchristofferson/Config-Updater)
|
||||||
### [SpigotUpdateChecker by JEFF-Media-GbR](https://github.com/JEFF-Media-GbR/Spigot-UpdateChecker)
|
### [SpigotUpdateChecker by JEFF-Media-GbR](https://github.com/JEFF-Media-GbR/Spigot-UpdateChecker)
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module version="4">
|
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||||
<component name="FacetManager">
|
<component name="FacetManager">
|
||||||
<facet type="minecraft" name="Minecraft">
|
<facet type="minecraft" name="Minecraft">
|
||||||
<configuration>
|
<configuration>
|
||||||
@ -12,4 +12,33 @@
|
|||||||
<component name="McpModuleSettings">
|
<component name="McpModuleSettings">
|
||||||
<option name="srgType" value="SRG" />
|
<option name="srgType" value="SRG" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||||
|
<output url="file://$MODULE_DIR$/target/classes" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="Maven: com.jeff_media:SpigotUpdateChecker:2.2.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.bstats:bstats-bukkit:3.0.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.bstats:bstats-base:3.0.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:31.1-jre" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:failureaccess:1.0.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.checkerframework:checker-qual:3.12.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.errorprone:error_prone_annotations:2.11.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.j2objc:j2objc-annotations:1.3" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.10" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.joml:joml:1.10.5" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.16-R0.4" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:2.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.20.1-R0.1-SNAPSHOT" level="project" />
|
||||||
|
</component>
|
||||||
</module>
|
</module>
|
@ -1,29 +1,21 @@
|
|||||||
# SimplifyTools - Changelog
|
# SimplifyTools - Changelog
|
||||||
|
|
||||||
- **1.2.3**
|
- 1.2.1
|
||||||
- Added support for version up to 1.21.4
|
|
||||||
- The plugin now depends on, <b>requires ProtocolLib</b> (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
|
- Added support for version up to 1.20.1
|
||||||
- Plugin manager added setting, now disabled by default in the config.
|
- Plugin manager added setting, now disabled by default in the config.
|
||||||
- Removed coloring of the logs in the server console
|
- Removed coloring of the logs in the server console
|
||||||
- TPS number displayed in the TAB now rounded to the nearest integer.
|
- TPS number displayed in the TAB now rounded to the nearest integer.
|
||||||
- Minor code refactors
|
- Minor code refactors
|
||||||
- **1.2.0**
|
- 1.2.0
|
||||||
- Added TPS command `/st tps`
|
- Added TPS command `/st tps`
|
||||||
- Added `{MOTD}`, `{TPS}` variable for TAB customization in the config
|
- Added `{MOTD}`, `{TPS}` variable for TAB customization in the config
|
||||||
- Refactored code for multi version support (1.12 - 1.19.3)
|
- Refactored code for multi version support (1.12 - 1.19.3)
|
||||||
- Fixes [#1](https://github.com/LabodiDavid/SimplifyTools/issues/1)
|
- Fixes [#1](https://github.com/LabodiDavid/SimplifyTools/issues/1)
|
||||||
- **1.1.0**
|
- 1.1.0
|
||||||
- Updated to 1.18.2
|
- Updated to 1.18.2
|
||||||
- Minor changes
|
- Minor changes
|
||||||
- Temporarily reworked Plugin Manager
|
- Temporarily reworked Plugin Manager
|
||||||
- Added Update Checker (https://github.com/JEFF-Media-GbR/Spigot-UpdateChecker)
|
- Added Update Checker (https://github.com/JEFF-Media-GbR/Spigot-UpdateChecker)
|
||||||
- Implemented Metrics (bStats)
|
- Implemented Metrics (bStats)
|
||||||
- **1.0.0** - First Release
|
- 1.0.0 - First Release
|
||||||
- Notice: If the `/st reload` command not reloading the new settings, you need to restart your MC server.
|
- Notice: If the /st reload command not reloading the new settings, you need to restart your MC server.
|
||||||
|
BIN
docs/img/ST.png
BIN
docs/img/ST.png
Binary file not shown.
Before Width: | Height: | Size: 3.7 KiB |
Binary file not shown.
Before Width: | Height: | Size: 19 KiB |
18
pom.xml
18
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>hu.ditservices</groupId>
|
<groupId>hu.ditservices</groupId>
|
||||||
<artifactId>SimplifyTools</artifactId>
|
<artifactId>SimplifyTools</artifactId>
|
||||||
<version>1.2.3</version>
|
<version>1.2.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>SimplifyTools</name>
|
<name>SimplifyTools</name>
|
||||||
@ -91,6 +91,10 @@
|
|||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>spigot</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||||
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>papermc</id>
|
<id>papermc</id>
|
||||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||||
@ -126,15 +130,19 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.21.4-R0.1-SNAPSHOT</version>
|
<version>1.20.1-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- from downloaded craftbukkit-x.xx.x.jar\META-INF\versions\ -->
|
<!-- from downloaded craftbukkit-x.xx.x.jar\META-INF\versions\ -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.comphenix.protocol</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>ProtocolLib</artifactId>
|
<artifactId>craftbukkit</artifactId>
|
||||||
<version>5.1.0</version>
|
<version>1.20.1-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -99,9 +99,9 @@ public final class STPlugin extends JavaPlugin implements CommandExecutor, Liste
|
|||||||
try {
|
try {
|
||||||
this.ServerStartTime = ManagementFactory.getRuntimeMXBean().getStartTime();
|
this.ServerStartTime = ManagementFactory.getRuntimeMXBean().getStartTime();
|
||||||
if (Version.ServerVersion.isCurrentLower(Version.ServerVersion.v1_12_R1) ||
|
if (Version.ServerVersion.isCurrentLower(Version.ServerVersion.v1_12_R1) ||
|
||||||
Version.ServerVersion.isCurrentHigher(Version.ServerVersion.v1_21_4_R1))
|
Version.ServerVersion.isCurrentHigher(Version.ServerVersion.v1_20_R1))
|
||||||
{
|
{
|
||||||
throw new Exception("The server version is not supported! Update to a version between 1.12 - 1.21.4 to run this plugin.");
|
throw new Exception("The server version is not supported! Update to a version between 1.12 - 1.20.1 to run this plugin.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.reload()) {
|
if (this.reload()) {
|
||||||
|
@ -6,33 +6,20 @@ import org.bukkit.World;
|
|||||||
|
|
||||||
public class SaveCommand {
|
public class SaveCommand {
|
||||||
/**
|
/**
|
||||||
* Saves all worlds and players data on the main thread.
|
* Saves all worlds and players data.
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static boolean Run() {
|
public static boolean Run(){
|
||||||
STPlugin plugin = STPlugin.getInstance();
|
STPlugin plugin = STPlugin.getInstance();
|
||||||
String prefix = plugin.getPrefix();
|
String p = plugin.getConfig().getString("Saving.broadcastMsgProgress").replace("{PREFIX}",plugin.getPrefix());
|
||||||
String progressMsg = plugin.getConfig().getString("Saving.broadcastMsgProgress").replace("{PREFIX}", prefix);
|
String d = plugin.getConfig().getString("Saving.broadcastMsgDone").replace("{PREFIX}",plugin.getPrefix());
|
||||||
String doneMsg = plugin.getConfig().getString("Saving.broadcastMsgDone").replace("{PREFIX}", prefix);
|
Bukkit.broadcast(p,"st.st");
|
||||||
|
for(World w : Bukkit.getServer().getWorlds()){
|
||||||
// Notify players of save progress
|
w.save();
|
||||||
Bukkit.broadcast(progressMsg, "st.st");
|
|
||||||
|
|
||||||
// Schedule task to run on the main thread
|
|
||||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
|
||||||
// Save all worlds
|
|
||||||
for (World world : Bukkit.getServer().getWorlds()) {
|
|
||||||
world.save(); // Runs on main thread
|
|
||||||
}
|
}
|
||||||
|
Bukkit.savePlayers();
|
||||||
// Save player data
|
Bukkit.broadcast(d,"st.st");
|
||||||
Bukkit.savePlayers(); // Also runs on main thread
|
|
||||||
|
|
||||||
// Notify players of save completion
|
|
||||||
Bukkit.broadcast(doneMsg, "st.st");
|
|
||||||
});
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,6 @@ public class SettingsCommand {
|
|||||||
+ ChatColor.GREEN+" -------- Features -------- " + "\n"
|
+ ChatColor.GREEN+" -------- Features -------- " + "\n"
|
||||||
+ ChatColor.GREEN+"Tab customization: "+(plugin.getConfig().getBoolean("Tab.enabled") ? ChatColor.GREEN + "Enabled" : ChatColor.RED+"Disabled") + "\n"
|
+ ChatColor.GREEN+"Tab customization: "+(plugin.getConfig().getBoolean("Tab.enabled") ? ChatColor.GREEN + "Enabled" : ChatColor.RED+"Disabled") + "\n"
|
||||||
+ ChatColor.GREEN+"Custom Advancement Msg: " + (plugin.getConfig().getBoolean("CustomAdvancement.enabled") ? ChatColor.GREEN+"Enabled" : ChatColor.RED+"Disabled") + "\n"
|
+ ChatColor.GREEN+"Custom Advancement Msg: " + (plugin.getConfig().getBoolean("CustomAdvancement.enabled") ? ChatColor.GREEN+"Enabled" : ChatColor.RED+"Disabled") + "\n"
|
||||||
+ ChatColor.GREEN+"Auto saving: " + (plugin.getConfig().getBoolean("Saving.enabled") ? ChatColor.GREEN+"Enabled" : ChatColor.RED+"Disabled") + "\n"
|
|
||||||
+ ChatColor.GREEN+"Plugin manager: " + (plugin.getConfig().getBoolean("PluginManager.enabled") ? ChatColor.GREEN+"Enabled" : ChatColor.RED+"Disabled") + "\n"
|
|
||||||
+ ChatColor.GREEN+" ========================== "
|
+ ChatColor.GREEN+" ========================== "
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
package hu.ditservices.handlers;
|
package hu.ditservices.handlers;
|
||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
|
||||||
import hu.ditservices.STPlugin;
|
import hu.ditservices.STPlugin;
|
||||||
|
import hu.ditservices.utils.*;
|
||||||
import hu.ditservices.utils.Math;
|
import hu.ditservices.utils.Math;
|
||||||
import hu.ditservices.utils.Server;
|
import hu.ditservices.utils.reflection.ClazzContainer;
|
||||||
import hu.ditservices.utils.TPS;
|
import hu.ditservices.utils.reflection.Reflection;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -16,8 +13,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TabHandler {
|
public class TabHandler {
|
||||||
public final List<WrappedChatComponent> headerComponents = new ArrayList<>();
|
public final List<String> headers = new ArrayList<>();
|
||||||
public final List<WrappedChatComponent> footerComponents = new ArrayList<>();
|
public final List<String> footers = new ArrayList<>();
|
||||||
|
|
||||||
private Integer refreshRate;
|
private Integer refreshRate;
|
||||||
|
|
||||||
@ -33,20 +30,27 @@ public class TabHandler {
|
|||||||
private int count2 = 0; //footers
|
private int count2 = 0; //footers
|
||||||
private Object packet;
|
private Object packet;
|
||||||
|
|
||||||
public TabHandler() {
|
public TabHandler() throws Exception {
|
||||||
|
|
||||||
this.plugin = STPlugin.getInstance();
|
this.plugin = STPlugin.getInstance();
|
||||||
|
|
||||||
if(this.init()){
|
if(this.init()){
|
||||||
if (headerComponents.isEmpty() && footerComponents.isEmpty()){
|
if (headers.isEmpty() && footers.isEmpty()){
|
||||||
plugin.getLogger().warning(plugin.getPrefix()+"TAB customization disabled because empty customization config or feature related errors!");
|
plugin.getLogger().warning(plugin.getPrefix()+"TAB customization disabled because empty customization config!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.updateTab();
|
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() {
|
|
||||||
|
private boolean init() throws Exception {
|
||||||
if (plugin.getConfig().getBoolean("Tab.enabled")){
|
if (plugin.getConfig().getBoolean("Tab.enabled")){
|
||||||
|
|
||||||
int availProcessors = Server.getCpuCores();
|
int availProcessors = Server.getCpuCores();
|
||||||
@ -106,45 +110,71 @@ public class TabHandler {
|
|||||||
private void updateTab(){
|
private void updateTab(){
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
|
||||||
try {
|
try {
|
||||||
if (Bukkit.getOnlinePlayers().isEmpty()){
|
if (Bukkit.getOnlinePlayers().size()==0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count1 >= headerComponents.size()) {
|
if (count1 >= headers.size()) {
|
||||||
count1 = 0;
|
count1 = 0;
|
||||||
}
|
}
|
||||||
if (count2 >= footerComponents.size()) {
|
if (count2 >= footers.size()) {
|
||||||
count2 = 0;
|
count2 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Re adding all lines where we replaced something like the RAM usage to every refresh
|
//Re adding all lines where we replaced something like the RAM usage to every refresh
|
||||||
//display current value. (We check those lines in the init())
|
//display current value. (We check those lines in the init())
|
||||||
if (!DynamicHeaders.isEmpty() && count1 < DynamicHeaders.size()) {
|
if (DynamicHeaders.size() > 0 && count1 < DynamicHeaders.size()) {
|
||||||
if (DynamicHeaders.get(count1) == count1) {
|
if (DynamicHeaders.get(count1) == count1) {
|
||||||
addHeaderFooter(true, headeranimList.get(count1), true, count1);
|
addHeaderFooter(true, headeranimList.get(count1), true, count1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!DynamicFooters.isEmpty() && count2 < DynamicFooters.size()) {
|
if (DynamicFooters.size() > 0 && count2 < DynamicFooters.size()) {
|
||||||
if (DynamicFooters.get(count2) == count2) {
|
if (DynamicFooters.get(count2) == count2) {
|
||||||
addHeaderFooter(false, footeranimList.get(count2), true, count2);
|
addHeaderFooter(false, footeranimList.get(count2), true, count2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
if (both){
|
||||||
|
plugin.getLogger().info("DEBUG: Sending both (header) JSON: "+WrappedChatComponent.fromHandle(headers.get(count1)).getJson());
|
||||||
|
plugin.getLogger().info("DEBUG: Sending both (footer) JSON: "+WrappedChatComponent.fromHandle(footers.get(count2)).getJson());
|
||||||
|
|
||||||
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
packet.getChatComponents().write(0, WrappedChatComponent.fromHandle(headers.get(count1))).write(1,WrappedChatComponent.fromHandle(footers.get(count2)));
|
||||||
PacketContainer packet = protocolManager.createPacket(com.comphenix.protocol.PacketType.Play.Server.PLAYER_LIST_HEADER_FOOTER);
|
}else{
|
||||||
|
if (header){
|
||||||
|
plugin.getLogger().info("DEBUG: Sending header JSON: "+WrappedChatComponent.fromHandle(headers.get(count1)).getJson());
|
||||||
|
|
||||||
packet.getChatComponents().write(0, headerComponents.get(count1));
|
packet.getChatComponents().write(0, WrappedChatComponent.fromHandle(headers.get(count1))).write(1,WrappedChatComponent.fromText("{\"text\":\"\"}"));
|
||||||
packet.getChatComponents().write(1, footerComponents.get(count2));
|
}else{
|
||||||
|
if (footer){
|
||||||
|
plugin.getLogger().info("DEBUG: Sending footer JSON: "+WrappedChatComponent.fromHandle(footers.get(count2)).getJson());
|
||||||
|
|
||||||
|
packet.getChatComponents().write(0,WrappedChatComponent.fromText("{\"text\":\"\"}")).write(1,WrappedChatComponent.fromHandle(footers.get(count2)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
protocolManager.sendServerPacket(player, packet);
|
plugin.getProtocolManager().sendServerPacket(player, packet);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
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{
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
player.setPlayerListHeaderFooter(headers.get(count1),footers.get(count2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (headerComponents.size() > 1) {
|
if (headers.size() > 1) {
|
||||||
count1++;
|
count1++;
|
||||||
}
|
}
|
||||||
if (footerComponents.size() > 1) {
|
if (footers.size() > 1) {
|
||||||
count2++;
|
count2++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,28 +191,38 @@ public class TabHandler {
|
|||||||
* Manages the adding of the tab line and the final formatting of the text.
|
* 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 header If true the text will be added to the header, otherwise to the footer.
|
||||||
* @param text The formatted tab line text.
|
* @param text The formatted tab line text.
|
||||||
* @param dynamic If the text contains a replacement which need to run every tab refresh then it's true.
|
* @param dynamic If the text contains a replace 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.
|
* @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) {
|
private void addHeaderFooter(boolean header,String text,boolean dynamic,int... index) throws Exception {
|
||||||
try {
|
try {
|
||||||
|
//JsonObject json = new JsonObject();
|
||||||
|
//json.addProperty("text",format(text));
|
||||||
String Json = "{\"text\": \""+format(text)+"\"}";
|
String Json = "{\"text\": \""+format(text)+"\"}";
|
||||||
WrappedChatComponent tabText = WrappedChatComponent.fromJson(Json);
|
//String Json = format(text);
|
||||||
|
//Json = Json.trim();
|
||||||
|
//plugin.getLogger().info("JSON!: "+Json);
|
||||||
|
Object tabText = Reflection.asChatSerializer(Json);
|
||||||
|
|
||||||
|
//plugin.getLogger().info("DEBUG: Adding JSON: "+Json);
|
||||||
if (header){
|
if (header){
|
||||||
if (dynamic){
|
if (dynamic){
|
||||||
headerComponents.set(index[0], tabText);
|
|
||||||
|
headers.set(index[0], Reflection.getChatSerializerString(tabText));
|
||||||
|
//headers.set(index[0],Json);
|
||||||
}else {
|
}else {
|
||||||
headerComponents.add(tabText);
|
//headers.add(Json);
|
||||||
|
headers.add(Reflection.getChatSerializerString(tabText));
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if (dynamic){
|
if (dynamic){
|
||||||
footerComponents.set(index[0], tabText);
|
//footers.set(index[0],Json);
|
||||||
} else {
|
footers.set(index[0], Reflection.getChatSerializerString(tabText));
|
||||||
footerComponents.add(tabText);
|
}else {
|
||||||
|
//footers.add(Json);
|
||||||
|
footers.add(Reflection.getChatSerializerString(tabText));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -27,17 +27,7 @@ public class Version {
|
|||||||
v1_18_R2,
|
v1_18_R2,
|
||||||
v1_19_R1,
|
v1_19_R1,
|
||||||
v1_19_R2,
|
v1_19_R2,
|
||||||
v1_20_R1,
|
v1_20_R1;
|
||||||
v1_20_R2,
|
|
||||||
v1_20_3_R1,
|
|
||||||
v1_20_4_R1,
|
|
||||||
v1_20_5_R1,
|
|
||||||
v1_20_6_R1,
|
|
||||||
v1_21_R1,
|
|
||||||
v1_21_1_R1,
|
|
||||||
v1_21_2_R1,
|
|
||||||
v1_21_3_R1,
|
|
||||||
v1_21_4_R1;
|
|
||||||
|
|
||||||
private int value;
|
private int value;
|
||||||
|
|
||||||
@ -68,31 +58,9 @@ public class Version {
|
|||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public static String[] getArrayVersion() {
|
|
||||||
if (arrayVersion == null) {
|
|
||||||
arrayVersion = org.bukkit.Bukkit.getServer().getClass().getPackage().getName().split("\\.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return arrayVersion;
|
|
||||||
}*/
|
|
||||||
public static String[] getArrayVersion() {
|
public static String[] getArrayVersion() {
|
||||||
if (arrayVersion == null) {
|
if (arrayVersion == null) {
|
||||||
String packageName = org.bukkit.Bukkit.getServer().getClass().getPackage().getName();
|
arrayVersion = org.bukkit.Bukkit.getServer().getClass().getPackage().getName().split("\\.");
|
||||||
String[] splitPackageName = packageName.split("\\.");
|
|
||||||
|
|
||||||
// Check if the splitPackageName length is more than 3
|
|
||||||
if (splitPackageName.length > 3) {
|
|
||||||
arrayVersion = new String[] {splitPackageName[3]};
|
|
||||||
} else {
|
|
||||||
// Handle the case for newer versions
|
|
||||||
String version = "UNKNOWN";
|
|
||||||
try {
|
|
||||||
version = org.bukkit.Bukkit.getServer().getVersion().split("\\(MC: ")[1].split("\\)")[0];
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
arrayVersion = new String[] {"v" + version.replace('.', '_') + "_R1"};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return arrayVersion;
|
return arrayVersion;
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
/*
|
|
||||||
package hu.ditservices.utils.reflection;
|
package hu.ditservices.utils.reflection;
|
||||||
|
|
||||||
import hu.ditservices.utils.Version;
|
import hu.ditservices.utils.Version;
|
||||||
@ -92,4 +91,3 @@ public final class ClazzContainer {
|
|||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
/*
|
|
||||||
package hu.ditservices.utils.reflection;
|
package hu.ditservices.utils.reflection;
|
||||||
|
|
||||||
import hu.ditservices.utils.Version;
|
import hu.ditservices.utils.Version;
|
||||||
@ -101,8 +100,7 @@ public class Reflection {
|
|||||||
//return ClazzContainer.getIChatBaseComponent().cast(chatSerializerMethodA.invoke(chatSerializer, json));
|
//return ClazzContainer.getIChatBaseComponent().cast(chatSerializerMethodA.invoke(chatSerializer, json));
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
/*public static Class<?> getNMSClassRegex(String nmsClass) {
|
||||||
/*public static Class<?> getNMSClassRegex(String nmsClass) {
|
|
||||||
|
|
||||||
String version = null;
|
String version = null;
|
||||||
Pattern pat = Pattern.compile("net\\.minecraft\\.(?:server)?\\.(v(?:\\d_)+R\\d)");
|
Pattern pat = Pattern.compile("net\\.minecraft\\.(?:server)?\\.(v(?:\\d_)+R\\d)");
|
||||||
@ -120,7 +118,5 @@ public class Reflection {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}*//*
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
@ -7,7 +7,7 @@ load: POSTWORLD
|
|||||||
description: SimplifyTools - An All-in-one helper plugin.
|
description: SimplifyTools - An All-in-one helper plugin.
|
||||||
author: SimplifyDave
|
author: SimplifyDave
|
||||||
website: https://ditservices.hu
|
website: https://ditservices.hu
|
||||||
depend: [ ProtocolLib ]
|
#depend: [ProtocolLib]
|
||||||
commands:
|
commands:
|
||||||
st:
|
st:
|
||||||
description: The default command for the plugin.
|
description: The default command for the plugin.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user