Compare commits
11 Commits
1.2.0
...
36f4896dce
Author | SHA1 | Date | |
---|---|---|---|
36f4896dce | |||
ffe27ee24c | |||
7eff18257d | |||
6f9e97acce | |||
27c9de4776 | |||
619548297d | |||
62ae820837 | |||
0227814e72 | |||
524510ae14 | |||
83412fd574 | |||
d40a47a783 |
3
.idea/compiler.xml
generated
3
.idea/compiler.xml
generated
@ -9,8 +9,5 @@
|
||||
<module name="SimplifyTools" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
<bytecodeTargetLevel>
|
||||
<module name="SimplifyTools" target="1.8" />
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
</project>
|
21
.idea/jarRepositories.xml
generated
21
.idea/jarRepositories.xml
generated
@ -6,16 +6,16 @@
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" 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/" />
|
||||
</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>
|
||||
<option name="id" 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/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="sonatype" />
|
||||
<option name="name" value="sonatype" />
|
||||
@ -32,15 +32,20 @@
|
||||
<option name="url" value="https://repo.dmulloy2.net/repository/public/" />
|
||||
</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" />
|
||||
<option name="id" value="spigot-repo" />
|
||||
<option name="name" value="spigot-repo" />
|
||||
<option name="url" value="https://hub.spigotmc.org/nexus/content/groups/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="spigot" />
|
||||
<option name="name" value="spigot" />
|
||||
<option name="url" value="https://hub.spigotmc.org/nexus/content/groups/public/" />
|
||||
</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>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
|
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@ -5,6 +5,7 @@
|
||||
<item index="0" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
|
||||
</list>
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
|
10
.idea/runConfigurations.xml
generated
10
.idea/runConfigurations.xml
generated
@ -1,10 +0,0 @@
|
||||
<?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>
|
17
README.md
17
README.md
@ -1,7 +1,12 @@
|
||||
# SimplifyTools
|
||||

|
||||
### An 'All-in-one' plugin for MC servers.
|
||||
#### 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)
|
||||
<hr>
|
||||
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
- **Tab Manager** - Allows you to specify colored texts, with animations on the tab window.
|
||||
@ -10,7 +15,7 @@
|
||||
- **Automatic/command saving** - Allows you to schedule auto saving of the world/player data on your server, or you can initiate a save by a command.
|
||||
- **Custom Connect/Disconnect messages** - Allows you to customize the message that is broadcasted when someone joins or leaves the server.
|
||||

|
||||
- **Plugin Manager** - Allows you to unload/load plugins without a server restart.
|
||||
- **Plugin Manager** - Allows you to unload/load plugins without a server restart. (Disabled by default since v1.2.1)
|
||||
- **Gameplay statistics** - You can check your gameplay statistics such as player/mob kills, etc.
|
||||
(Note: The plugin just shows the stats not recording itself, so stats before installing this plugin are counted too.)
|
||||

|
||||
@ -18,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.)
|
||||

|
||||
- **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)
|
||||
@ -30,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)
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<module version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="minecraft" name="Minecraft">
|
||||
<configuration>
|
||||
@ -12,32 +12,4 @@
|
||||
<component name="McpModuleSettings">
|
||||
<option name="srgType" value="SRG" />
|
||||
</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.19.3-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: net.md-5:bungeecord-chat:1.16-R0.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.33" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.19.3-R0.1-SNAPSHOT" level="project" />
|
||||
</component>
|
||||
</module>
|
@ -1,14 +1,29 @@
|
||||
# SimplifyTools - Changelog
|
||||
- 1.2.0
|
||||
|
||||
- **1.2.3**
|
||||
- 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
|
||||
- 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**
|
||||
- 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.
|
||||
|
BIN
docs/img/ST.png
Normal file
BIN
docs/img/ST.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
BIN
docs/img/SimplifyTools.png
Normal file
BIN
docs/img/SimplifyTools.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
18
pom.xml
18
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>hu.ditservices</groupId>
|
||||
<artifactId>SimplifyTools</artifactId>
|
||||
<version>1.2.0</version>
|
||||
<version>1.2.3</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>SimplifyTools</name>
|
||||
@ -91,10 +91,6 @@
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
@ -130,19 +126,15 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.19.3-R0.1-SNAPSHOT</version>
|
||||
<version>1.21.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- from downloaded craftbukkit-x.xx.x.jar\META-INF\versions\ -->
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.19.3-R0.1-SNAPSHOT</version>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
<version>5.1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -6,7 +6,7 @@ import hu.ditservices.handlers.TabHandler;
|
||||
import hu.ditservices.utils.*;
|
||||
import hu.ditservices.utils.Math;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import hu.ditservices.commands.DitCmd;
|
||||
import hu.ditservices.handlers.CommandHandler;
|
||||
import hu.ditservices.listeners.ChatEvents;
|
||||
import hu.ditservices.listeners.LogChat;
|
||||
import hu.ditservices.listeners.LogCommand;
|
||||
@ -34,53 +34,52 @@ public final class STPlugin extends JavaPlugin implements CommandExecutor, Liste
|
||||
private static STPlugin instance;
|
||||
private final Logger log = Bukkit.getLogger();
|
||||
|
||||
public FileConfiguration config = getConfig();
|
||||
private FileConfiguration config;
|
||||
|
||||
public long ServerStartTime;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
try {
|
||||
this.Init();
|
||||
} catch (Exception e) {
|
||||
this.log.warning("[SimplifyTools] - INITIALIZATION ERROR: "+e.getMessage());
|
||||
this.log.warning("[SimplifyTools] - Plugin disabled!");
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
|
||||
if (this.initPlugin()) {
|
||||
this.log.info(ChatColor.stripColor(this.getPrefix())+"Started running.");
|
||||
}
|
||||
//this.dplug = new DitPluginManager(this);
|
||||
this.log.info(this.getPrefix()+"Started running.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileConfiguration getConfig() {
|
||||
//TODO Implement defaults everywhere when config is not loaded for some reasons
|
||||
if (this.config != null) {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
return super.getConfig();
|
||||
}
|
||||
|
||||
|
||||
private void Init() throws Exception {
|
||||
this.ServerStartTime = ManagementFactory.getRuntimeMXBean().getStartTime();
|
||||
if (Version.ServerVersion.isCurrentLower(Version.ServerVersion.v1_12_R1)){
|
||||
throw new Exception("The server version is not supported! Update to a version between 1.12 - 1.19.3 to run this plugin.");
|
||||
}
|
||||
if (this.Reload()){
|
||||
|
||||
|
||||
TabHandler tab = new TabHandler();
|
||||
PluginCommand ditCmd = this.getCommand("st");
|
||||
ditCmd.setExecutor(new DitCmd(this));
|
||||
ditCmd.setTabCompleter(new DITTabCompleter());
|
||||
|
||||
private void registerEvents() {
|
||||
getServer().getPluginManager().registerEvents(this, this);
|
||||
getServer().getPluginManager().registerEvents(new LogChat(this), this);
|
||||
getServer().getPluginManager().registerEvents(new LogCommand(this), this);
|
||||
getServer().getPluginManager().registerEvents(new LogConnect(this), this);
|
||||
|
||||
if (this.config.isSet("CustomAdvancement.enabled") && this.config.getBoolean("CustomAdvancement.enabled")) {
|
||||
getServer().getPluginManager().registerEvents(new ChatEvents(this), this);
|
||||
this.log.info(this.getPrefix()+"Custom Advancement Messages enabled!");
|
||||
this.log.info(ChatColor.stripColor(this.getPrefix()) + "Custom Advancement Messages enabled!");
|
||||
}
|
||||
}
|
||||
|
||||
private void scheduleTasks() {
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new TPS(), 0, 1);
|
||||
|
||||
if (this.config.getBoolean("Saving.enabled") && this.config.getInt("Saving.interval") > 0) {
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new SaveHandler(), 0L, Math.convert(Math.Convert.SECONDS,Math.Convert.TICKS,instance.config.getInt("Saving.interval")));
|
||||
long intervalTicks = Math.convert(Math.Convert.SECONDS, Math.Convert.TICKS, instance.config.getInt("Saving.interval"));
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new SaveHandler(), 0L, intervalTicks);
|
||||
}
|
||||
}
|
||||
|
||||
private void initUpdateChecker() {
|
||||
new UpdateChecker(this, UpdateCheckSource.GITHUB_RELEASE_TAG, "LabodiDavid/SimplifyTools")
|
||||
.setDownloadLink("https://github.com/LabodiDavid/SimplifyTools/releases")
|
||||
.setDonationLink("https://paypal.me/labodidavid")
|
||||
@ -90,10 +89,50 @@ public final class STPlugin extends JavaPlugin implements CommandExecutor, Liste
|
||||
.setUserAgent(new UserAgentBuilder().addPluginNameAndVersion())
|
||||
.checkEveryXHours(24)
|
||||
.checkNow();
|
||||
}
|
||||
|
||||
private void initMetrics() {
|
||||
Metrics metrics = new Metrics(this, 15108);
|
||||
}
|
||||
|
||||
private boolean initPlugin() {
|
||||
try {
|
||||
this.ServerStartTime = ManagementFactory.getRuntimeMXBean().getStartTime();
|
||||
if (Version.ServerVersion.isCurrentLower(Version.ServerVersion.v1_12_R1) ||
|
||||
Version.ServerVersion.isCurrentHigher(Version.ServerVersion.v1_21_4_R1))
|
||||
{
|
||||
throw new Exception("The server version is not supported! Update to a version between 1.12 - 1.21.4 to run this plugin.");
|
||||
}
|
||||
|
||||
if (this.reload()) {
|
||||
TabHandler tab = new TabHandler();
|
||||
|
||||
PluginCommand stCommand = this.getCommand("st");
|
||||
stCommand.setExecutor(new CommandHandler(this));
|
||||
stCommand.setTabCompleter(new DITTabCompleter());
|
||||
|
||||
registerEvents();
|
||||
scheduleTasks();
|
||||
initUpdateChecker();
|
||||
initMetrics();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.log.warning("[SimplifyTools] - INITIALIZATION ERROR: " + e.getMessage());
|
||||
this.log.warning("[SimplifyTools] - Plugin disabled!");
|
||||
this.setEnabled(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the plugin's prefix.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getPrefix(){
|
||||
if (this.config.isSet("Prefix") && !Objects.requireNonNull(this.config.getString("Prefix")).isEmpty()) {
|
||||
return ChatColor.translateAlternateColorCodes('&', this.config.getString("Prefix"));
|
||||
@ -102,41 +141,46 @@ public final class STPlugin extends JavaPlugin implements CommandExecutor, Liste
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the main plugin instance.
|
||||
*
|
||||
* @return STPlugin
|
||||
*/
|
||||
public static STPlugin getInstance(){
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the server's uptime in a human readable format.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public static String getUptime() {
|
||||
int uptime = (int)(System.currentTimeMillis() - instance.ServerStartTime)/1000;
|
||||
String returnText = "";
|
||||
long uptime = (System.currentTimeMillis() - instance.ServerStartTime) / 1000;
|
||||
StringBuilder returnText = new StringBuilder();
|
||||
|
||||
// Get remaining seconds from total minutes.
|
||||
int seconds = uptime % 60;
|
||||
// Convert to minutes, get remaining minutes from total hours.
|
||||
int minutes = (uptime / 60) % 60;
|
||||
// Convert to hours, get remaining hours from total days.
|
||||
int hours = (uptime / 3600) % 24;
|
||||
// Convert to days.
|
||||
int days = uptime / 86400;
|
||||
int days = (int) (uptime / 86400);
|
||||
int hours = (int) ((uptime % 86400) / 3600);
|
||||
int minutes = (int) ((uptime % 3600) / 60);
|
||||
int seconds = (int) (uptime % 60);
|
||||
|
||||
if (days > 1) {
|
||||
returnText = returnText+ days+" days ";
|
||||
returnText.append(days).append(" days ");
|
||||
}
|
||||
if (hours > 1) {
|
||||
returnText = returnText+ hours+ " hours ";
|
||||
returnText.append(hours).append(" hours ");
|
||||
}
|
||||
if (minutes > 1) {
|
||||
returnText = returnText+ minutes+ " min ";
|
||||
returnText.append(minutes).append(" min ");
|
||||
}
|
||||
if (seconds > 1) {
|
||||
returnText = returnText+ seconds+ "s ";
|
||||
returnText.append(seconds).append("s ");
|
||||
}
|
||||
|
||||
return returnText;
|
||||
|
||||
return returnText.toString();
|
||||
}
|
||||
|
||||
public boolean Reload(){
|
||||
public boolean reload(){
|
||||
File configFile = new File(getDataFolder(), "config.yml");
|
||||
|
||||
try {
|
||||
@ -154,6 +198,6 @@ public final class STPlugin extends JavaPlugin implements CommandExecutor, Liste
|
||||
}
|
||||
@Override
|
||||
public void onDisable() {
|
||||
System.out.println(this.getPrefix()+" stopped.");
|
||||
this.log.info(ChatColor.stripColor(this.getPrefix()) + "Stopped running.");
|
||||
}
|
||||
}
|
||||
|
@ -1,123 +0,0 @@
|
||||
package hu.ditservices.commands;
|
||||
|
||||
import hu.ditservices.utils.TPS;
|
||||
import hu.ditservices.STPlugin;
|
||||
import hu.ditservices.utils.Cooldown;
|
||||
import hu.ditservices.utils.Version;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class DitCmd implements CommandExecutor {
|
||||
private final String noArgMsg;
|
||||
private final STPlugin plugin;
|
||||
private final Cooldown cd;
|
||||
private final FileConfiguration config;
|
||||
|
||||
public DitCmd(final STPlugin instance){
|
||||
this.plugin = instance;
|
||||
this.noArgMsg = plugin.getPrefix()+ ChatColor.DARK_RED + "To list all SimplifyTools commands use the '/help SIMPLIFYTOOLS' command!";
|
||||
this.cd = new Cooldown(plugin);
|
||||
this.config = plugin.config;
|
||||
}
|
||||
|
||||
public boolean addToCoolDown(CommandSender sender){
|
||||
if (sender instanceof Player){
|
||||
Player p = (Player) sender;
|
||||
this.cd.Add(p);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (command.getName().equals("st")){
|
||||
|
||||
if (cd.Check(sender)){
|
||||
if (command.getName().equals("st") && args.length==0)
|
||||
{
|
||||
this.addToCoolDown(sender);
|
||||
sender.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Version: "+plugin.getDescription().getVersion());
|
||||
sender.sendMessage(this.noArgMsg);
|
||||
return true;
|
||||
}
|
||||
if (command.getName().equals("st") && args[0].contains("help"))
|
||||
{
|
||||
sender.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Version: "+plugin.getDescription().getVersion());
|
||||
sender.sendMessage(this.noArgMsg);
|
||||
return true;
|
||||
}
|
||||
if (command.getName().equals("st") && args[0].contains("settings"))
|
||||
{
|
||||
this.addToCoolDown(sender);
|
||||
sender.sendMessage(plugin.getPrefix()+ ChatColor.GREEN+" === Plugin Information === ");
|
||||
sender.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Plugin Version: "+plugin.getDescription().getVersion());
|
||||
sender.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Server Version: "+ Version.ServerVersion.getCurrent().toString());
|
||||
sender.sendMessage(ChatColor.GREEN+" -------- Features -------- ");
|
||||
sender.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Tab customization: "+(config.getBoolean("Tab.enabled") ? ChatColor.GREEN+"Enabled" : ChatColor.RED+"Disabled"));
|
||||
sender.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Custom Advancement Msg: "+(config.getBoolean("CustomAdvancement.enabled") ? ChatColor.GREEN+"Enabled" : ChatColor.RED+"Disabled"));
|
||||
sender.sendMessage(ChatColor.GREEN+" ========================== ");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (command.getName().equals("st") && args[0].contains("reload") && sender.hasPermission("st.reload")){
|
||||
|
||||
if(plugin.Reload()){
|
||||
this.addToCoolDown(sender);
|
||||
sender.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Successfully reload!");
|
||||
sender.sendMessage(plugin.getPrefix()+ChatColor.RED+"Notice: Restart your server if the settings didn't applied.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (command.getName().equals("st") && args[0].contains("tps") && sender.hasPermission("st.tps")){
|
||||
this.addToCoolDown(sender);
|
||||
sender.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Plugin Calculated TPS: "+TPS.getColor()+String.format("%.2f", TPS.getTPS()));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (command.getName().equalsIgnoreCase("st") && args[0].contains("pmanager")){
|
||||
|
||||
if (sender.hasPermission("st.pmanager.unload") || sender.hasPermission("st.pmanager.load") || sender.hasPermission("st.pmanager")) {
|
||||
this.addToCoolDown(sender);
|
||||
if (args.length==1){
|
||||
sender.sendMessage(plugin.getPrefix()+ChatColor.DARK_RED+"Invalid arguments!");
|
||||
return true;
|
||||
}
|
||||
if (args[1].equalsIgnoreCase("load")) {
|
||||
//PluginCmd.handleLoad(sender,args);
|
||||
PluginCmd.LoadPlugin(sender,args);
|
||||
}
|
||||
if (args[1].equalsIgnoreCase("unload")) {
|
||||
//PluginCmd.handleUnload(sender,args);
|
||||
PluginCmd.UnloadPlugin(sender, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (command.getName().equalsIgnoreCase("st") && args[0].contains("save-all") && sender.hasPermission("st.save")){
|
||||
this.addToCoolDown(sender);
|
||||
return SaveCmd.Run(sender);
|
||||
}
|
||||
|
||||
if (command.getName().equalsIgnoreCase("st") && args[0].contains("ping") && sender.hasPermission("st.ping")){
|
||||
this.addToCoolDown(sender);
|
||||
return PingCmd.Run(sender);
|
||||
}
|
||||
if (command.getName().equalsIgnoreCase("st") && args[0].contains("stats") && sender.hasPermission("st.stats")){
|
||||
this.addToCoolDown(sender);
|
||||
return StatCmd.Run(sender);
|
||||
}
|
||||
}else{
|
||||
cd.CDText(sender);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -6,7 +6,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PingCmd {
|
||||
public class PingCommand {
|
||||
public static boolean Run(CommandSender sender) {
|
||||
STPlugin plugin = STPlugin.getInstance();
|
||||
if (sender instanceof Player) {
|
@ -7,7 +7,7 @@ import hu.ditservices.STPlugin;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class PluginCmd {
|
||||
public class PluginManagerCommand {
|
||||
public static boolean LoadPlugin(CommandSender sender, String[] args){
|
||||
Plugin plugin = Bukkit.getPluginManager().getPlugin(args[2]);
|
||||
if (plugin == null) {
|
@ -1,21 +0,0 @@
|
||||
package hu.ditservices.commands;
|
||||
|
||||
import hu.ditservices.STPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class SaveCmd {
|
||||
public static boolean Run(CommandSender sender){
|
||||
STPlugin plugin = STPlugin.getInstance();
|
||||
String p = plugin.config.getString("Saving.broadcastMsgProgress").replace("{PREFIX}",plugin.getPrefix());
|
||||
String d = plugin.config.getString("Saving.broadcastMsgDone").replace("{PREFIX}",plugin.getPrefix());
|
||||
Bukkit.broadcast(p,"st.st");
|
||||
for(World w : Bukkit.getServer().getWorlds()){
|
||||
w.save();
|
||||
}
|
||||
Bukkit.savePlayers();
|
||||
Bukkit.broadcast(d,"st.st");
|
||||
return true;
|
||||
}
|
||||
}
|
38
src/main/java/hu/ditservices/commands/SaveCommand.java
Normal file
38
src/main/java/hu/ditservices/commands/SaveCommand.java
Normal file
@ -0,0 +1,38 @@
|
||||
package hu.ditservices.commands;
|
||||
|
||||
import hu.ditservices.STPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class SaveCommand {
|
||||
/**
|
||||
* Saves all worlds and players data on the main thread.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean Run() {
|
||||
STPlugin plugin = STPlugin.getInstance();
|
||||
String prefix = plugin.getPrefix();
|
||||
String progressMsg = plugin.getConfig().getString("Saving.broadcastMsgProgress").replace("{PREFIX}", prefix);
|
||||
String doneMsg = plugin.getConfig().getString("Saving.broadcastMsgDone").replace("{PREFIX}", prefix);
|
||||
|
||||
// Notify players of save progress
|
||||
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
|
||||
}
|
||||
|
||||
// Save player data
|
||||
Bukkit.savePlayers(); // Also runs on main thread
|
||||
|
||||
// Notify players of save completion
|
||||
Bukkit.broadcast(doneMsg, "st.st");
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
25
src/main/java/hu/ditservices/commands/SettingsCommand.java
Normal file
25
src/main/java/hu/ditservices/commands/SettingsCommand.java
Normal file
@ -0,0 +1,25 @@
|
||||
package hu.ditservices.commands;
|
||||
|
||||
import hu.ditservices.STPlugin;
|
||||
import hu.ditservices.utils.Version;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class SettingsCommand {
|
||||
public static boolean Run(CommandSender sender) {
|
||||
STPlugin plugin = STPlugin.getInstance();
|
||||
|
||||
sender.sendMessage( ChatColor.GREEN+" === Plugin Information === " + "\n"
|
||||
+ ChatColor.GREEN+"Plugin Version: " + ChatColor.translateAlternateColorCodes('&',"&a[&fSimplify&7Tools&2] &4- &f") + plugin.getDescription().getVersion() + "\n"
|
||||
+ ChatColor.GREEN+"Server Version: " + Version.ServerVersion.getCurrent().toString() + "\n"
|
||||
+ ChatColor.GREEN+" -------- Features -------- " + "\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+"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+" ========================== "
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ import org.bukkit.Statistic;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class StatCmd {
|
||||
public class StatCommand {
|
||||
public static boolean Run(CommandSender sender){
|
||||
Player player = (Player) sender;
|
||||
|
113
src/main/java/hu/ditservices/handlers/CommandHandler.java
Normal file
113
src/main/java/hu/ditservices/handlers/CommandHandler.java
Normal file
@ -0,0 +1,113 @@
|
||||
package hu.ditservices.handlers;
|
||||
|
||||
import hu.ditservices.commands.*;
|
||||
import hu.ditservices.utils.TPS;
|
||||
import hu.ditservices.STPlugin;
|
||||
import hu.ditservices.utils.Cooldown;
|
||||
import hu.ditservices.utils.Version;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandHandler implements CommandExecutor {
|
||||
private final String noArgMsg;
|
||||
private final STPlugin plugin;
|
||||
private final Cooldown cd;
|
||||
private final FileConfiguration config;
|
||||
|
||||
public CommandHandler(final STPlugin instance) {
|
||||
this.plugin = instance;
|
||||
this.noArgMsg = plugin.getPrefix() + ChatColor.DARK_RED + "To list all SimplifyTools commands use the '/help SIMPLIFYTOOLS' command!";
|
||||
this.cd = new Cooldown(plugin);
|
||||
this.config = plugin.getConfig();
|
||||
}
|
||||
|
||||
public boolean addToCoolDown(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
this.cd.Add(p);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (command.getName().equals("st")){
|
||||
|
||||
if (cd.Check(sender)){
|
||||
|
||||
if (command.getName().equals("st")) {
|
||||
this.addToCoolDown(sender);
|
||||
}
|
||||
|
||||
if (command.getName().equals("st") && (args.length == 0 || args[0].contains("help")))
|
||||
{
|
||||
sender.sendMessage(plugin.getPrefix() + ChatColor.GREEN+"Version: " + plugin.getDescription().getVersion());
|
||||
sender.sendMessage(this.noArgMsg);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (command.getName().equals("st") && args[0].contains("settings"))
|
||||
{
|
||||
return SettingsCommand.Run(sender);
|
||||
}
|
||||
|
||||
if (command.getName().equals("st") && args[0].contains("reload") && sender.hasPermission("st.reload")){
|
||||
|
||||
if(plugin.reload()){
|
||||
sender.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Successfully reload!" + "\n"
|
||||
+ plugin.getPrefix() + ChatColor.RED + "Notice: Restart your server if the settings didn't applied.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (command.getName().equals("st") && args[0].contains("tps") && sender.hasPermission("st.tps")) {
|
||||
sender.sendMessage(plugin.getPrefix() + ChatColor.GREEN+"Plugin Calculated TPS: "+TPS.getColor()+String.format("%.2f", TPS.getTPS()));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (command.getName().equalsIgnoreCase("st") && args[0].contains("pmanager")) {
|
||||
if (sender.hasPermission("st.pmanager.unload") || sender.hasPermission("st.pmanager.load") || sender.hasPermission("st.pmanager")) {
|
||||
if (args.length==1){
|
||||
sender.sendMessage(plugin.getPrefix() + ChatColor.DARK_RED+"Invalid arguments!");
|
||||
return true;
|
||||
}
|
||||
if (config.getBoolean("PluginManager.enabled")) {
|
||||
if (args[1].equalsIgnoreCase("load")) {
|
||||
//PluginCmd.handleLoad(sender,args);
|
||||
PluginManagerCommand.LoadPlugin(sender,args);
|
||||
}
|
||||
if (args[1].equalsIgnoreCase("unload")) {
|
||||
//PluginCmd.handleUnload(sender,args);
|
||||
PluginManagerCommand.UnloadPlugin(sender, args);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(plugin.getPrefix() + ChatColor.DARK_RED + "Plugin manager commands are disabled in the config!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (command.getName().equalsIgnoreCase("st") && args[0].contains("save-all") && sender.hasPermission("st.save")) {
|
||||
return SaveCommand.Run();
|
||||
}
|
||||
|
||||
if (command.getName().equalsIgnoreCase("st") && args[0].contains("ping") && sender.hasPermission("st.ping")) {
|
||||
return PingCommand.Run(sender);
|
||||
}
|
||||
if (command.getName().equalsIgnoreCase("st") && args[0].contains("stats") && sender.hasPermission("st.stats")) {
|
||||
return StatCommand.Run(sender);
|
||||
}
|
||||
}else{
|
||||
cd.CDText(sender);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,33 +1,10 @@
|
||||
package hu.ditservices.handlers;
|
||||
|
||||
import hu.ditservices.STPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import hu.ditservices.commands.SaveCommand;
|
||||
|
||||
public class SaveHandler implements Runnable{
|
||||
STPlugin plugin = STPlugin.getInstance();
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
String p = plugin.config.isSet("Saving.broadcastMsgProgress") ? plugin.config.getString("Saving.broadcastMsgProgress").replace("{PREFIX}",plugin.getPrefix()) : plugin.getPrefix()+"Auto save in progress..";
|
||||
String d = plugin.config.isSet("Saving.broadcastMsgDone") ? plugin.config.getString("Saving.broadcastMsgDone").replace("{PREFIX}",plugin.getPrefix()) : plugin.getPrefix()+"Auto save done.";
|
||||
if (Bukkit.getOnlinePlayers().size()>0){
|
||||
for (Player player : Bukkit.getOnlinePlayers()){
|
||||
player.sendMessage(p);
|
||||
}
|
||||
}
|
||||
plugin.getLogger().info(p);
|
||||
for(World w : Bukkit.getServer().getWorlds()){
|
||||
w.save();
|
||||
}
|
||||
Bukkit.savePlayers();
|
||||
if (Bukkit.getOnlinePlayers().size()>0){
|
||||
for (Player player : Bukkit.getOnlinePlayers()){
|
||||
player.sendMessage(d);
|
||||
}
|
||||
}
|
||||
plugin.getLogger().info(d);
|
||||
|
||||
SaveCommand.Run();
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,13 @@
|
||||
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.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;
|
||||
@ -13,8 +16,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TabHandler {
|
||||
public final List<String> headers = new ArrayList<>();
|
||||
public final List<String> footers = new ArrayList<>();
|
||||
public final List<WrappedChatComponent> headerComponents = new ArrayList<>();
|
||||
public final List<WrappedChatComponent> footerComponents = new ArrayList<>();
|
||||
|
||||
private Integer refreshRate;
|
||||
|
||||
@ -30,27 +33,20 @@ public class TabHandler {
|
||||
private int count2 = 0; //footers
|
||||
private Object packet;
|
||||
|
||||
public TabHandler() throws Exception {
|
||||
public TabHandler() {
|
||||
|
||||
this.plugin = STPlugin.getInstance();
|
||||
|
||||
if(this.init()){
|
||||
if (headers.isEmpty() && footers.isEmpty()){
|
||||
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();
|
||||
@ -110,71 +106,45 @@ public class TabHandler {
|
||||
private void updateTab(){
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
|
||||
try {
|
||||
if (Bukkit.getOnlinePlayers().size()==0){
|
||||
if (Bukkit.getOnlinePlayers().isEmpty()){
|
||||
return;
|
||||
}
|
||||
|
||||
if (count1 >= headers.size()) {
|
||||
if (count1 >= headerComponents.size()) {
|
||||
count1 = 0;
|
||||
}
|
||||
if (count2 >= footers.size()) {
|
||||
if (count2 >= footerComponents.size()) {
|
||||
count2 = 0;
|
||||
}
|
||||
|
||||
//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())
|
||||
if (DynamicHeaders.size() > 0 && count1 < DynamicHeaders.size()) {
|
||||
if (!DynamicHeaders.isEmpty() && count1 < DynamicHeaders.size()) {
|
||||
if (DynamicHeaders.get(count1) == count1) {
|
||||
addHeaderFooter(true, headeranimList.get(count1), true, count1);
|
||||
}
|
||||
}
|
||||
if (DynamicFooters.size() > 0 && count2 < DynamicFooters.size()) {
|
||||
if (!DynamicFooters.isEmpty() && count2 < DynamicFooters.size()) {
|
||||
if (DynamicFooters.get(count2) == 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());
|
||||
|
||||
packet.getChatComponents().write(0, WrappedChatComponent.fromHandle(headers.get(count1))).write(1,WrappedChatComponent.fromHandle(footers.get(count2)));
|
||||
}else{
|
||||
if (header){
|
||||
plugin.getLogger().info("DEBUG: Sending header JSON: "+WrappedChatComponent.fromHandle(headers.get(count1)).getJson());
|
||||
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
||||
PacketContainer packet = protocolManager.createPacket(com.comphenix.protocol.PacketType.Play.Server.PLAYER_LIST_HEADER_FOOTER);
|
||||
|
||||
packet.getChatComponents().write(0, WrappedChatComponent.fromHandle(headers.get(count1))).write(1,WrappedChatComponent.fromText("{\"text\":\"\"}"));
|
||||
}else{
|
||||
if (footer){
|
||||
plugin.getLogger().info("DEBUG: Sending footer JSON: "+WrappedChatComponent.fromHandle(footers.get(count2)).getJson());
|
||||
packet.getChatComponents().write(0, headerComponents.get(count1));
|
||||
packet.getChatComponents().write(1, footerComponents.get(count2));
|
||||
|
||||
packet.getChatComponents().write(0,WrappedChatComponent.fromText("{\"text\":\"\"}")).write(1,WrappedChatComponent.fromHandle(footers.get(count2)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
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));
|
||||
}
|
||||
protocolManager.sendServerPacket(player, packet);
|
||||
}
|
||||
|
||||
|
||||
if (headers.size() > 1) {
|
||||
if (headerComponents.size() > 1) {
|
||||
count1++;
|
||||
}
|
||||
if (footers.size() > 1) {
|
||||
if (footerComponents.size() > 1) {
|
||||
count2++;
|
||||
}
|
||||
|
||||
@ -191,38 +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) throws Exception {
|
||||
private void addHeaderFooter(boolean header,String text,boolean dynamic,int... index) {
|
||||
try {
|
||||
//JsonObject json = new JsonObject();
|
||||
//json.addProperty("text",format(text));
|
||||
String Json = "{\"text\": \""+format(text)+"\"}";
|
||||
//String Json = format(text);
|
||||
//Json = Json.trim();
|
||||
//plugin.getLogger().info("JSON!: "+Json);
|
||||
Object tabText = Reflection.asChatSerializer(Json);
|
||||
WrappedChatComponent tabText = WrappedChatComponent.fromJson(Json);
|
||||
|
||||
//plugin.getLogger().info("DEBUG: Adding JSON: "+Json);
|
||||
if (header){
|
||||
if (dynamic){
|
||||
|
||||
headers.set(index[0], Reflection.getChatSerializerString(tabText));
|
||||
//headers.set(index[0],Json);
|
||||
headerComponents.set(index[0], tabText);
|
||||
}else {
|
||||
//headers.add(Json);
|
||||
headers.add(Reflection.getChatSerializerString(tabText));
|
||||
headerComponents.add(tabText);
|
||||
}
|
||||
}else{
|
||||
if (dynamic){
|
||||
//footers.set(index[0],Json);
|
||||
footers.set(index[0], Reflection.getChatSerializerString(tabText));
|
||||
footerComponents.set(index[0], tabText);
|
||||
} else {
|
||||
//footers.add(Json);
|
||||
footers.add(Reflection.getChatSerializerString(tabText));
|
||||
footerComponents.add(tabText);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -261,7 +221,7 @@ public class TabHandler {
|
||||
msg = msg.replace("{MOTD}", plugin.getServer().getMotd()); //LegacyComponentSerializer.legacyAmpersand().serialize(plugin.getServer().motd().asComponent())
|
||||
}
|
||||
if (msg.contains("{TPS}")){
|
||||
msg = msg.replace("{TPS}",String.format("%.2f", TPS.getTPS()));
|
||||
msg = msg.replace("{TPS}",String.valueOf(java.lang.Math.round(TPS.getTPS())));
|
||||
}
|
||||
return ChatColor.translateAlternateColorCodes('&',msg);
|
||||
}
|
||||
|
@ -14,10 +14,12 @@ import hu.ditservices.utils.AdvancementHelper;
|
||||
public class ChatEvents implements Listener {
|
||||
private STPlugin plugin;
|
||||
private FileConfiguration config;
|
||||
|
||||
public ChatEvents(STPlugin instance){
|
||||
this.plugin = instance;
|
||||
this.config = plugin.config;
|
||||
this.config = plugin.getConfig();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onAdvance(PlayerAdvancementDoneEvent e){
|
||||
if (config.isSet("CustomAdvancement.enabled") && config.getBoolean("CustomAdvancement.enabled")){
|
||||
|
@ -15,7 +15,7 @@ public class LogChat implements Listener {
|
||||
FileConfiguration config;
|
||||
public LogChat(STPlugin instance){
|
||||
this.plugin = instance;
|
||||
this.config = plugin.config;
|
||||
this.config = plugin.getConfig();
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onChat(AsyncPlayerChatEvent event){
|
||||
|
@ -16,7 +16,7 @@ public class LogCommand implements Listener {
|
||||
public LogCommand(STPlugin instance){
|
||||
|
||||
this.plugin = instance;
|
||||
this.config = plugin.config;
|
||||
this.config = plugin.getConfig();
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onCommand(PlayerCommandPreprocessEvent event){
|
||||
|
@ -19,10 +19,10 @@ public class LogConnect implements Listener {
|
||||
FileConfiguration config;
|
||||
public LogConnect(STPlugin instance){
|
||||
this.plugin = instance;
|
||||
this.config = plugin.config;
|
||||
this.config = plugin.getConfig();
|
||||
if (config.getBoolean("CustomMsg.enabled")) {
|
||||
this.JoinMsg = this.config.isSet("CustomMsg.connect") ? this.config.getString("CustomMsg.connect") : "{PREFIX}{NAME} &aconnected to the server.";
|
||||
this.LeaveMsg = this.config.isSet("CustomMsg.connect") ? this.config.getString("CustomMsg.disconnect") : "{PREFIX}{NAME} leaved the game.";
|
||||
this.LeaveMsg = this.config.isSet("CustomMsg.connect") ? this.config.getString("CustomMsg.disconnect") : "{PREFIX}{NAME} left the game.";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package hu.ditservices.utils;
|
||||
|
||||
import hu.ditservices.STPlugin;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -115,24 +116,26 @@ public class AdvancementHelper {
|
||||
if (config.isSet("CustomAdvancement.formats.challenge")) {
|
||||
out_type[2] = config.getString("CustomAdvancement.formats.challenge");
|
||||
}
|
||||
String disablemsg = plugin.getPrefix()+"Disabling vanilla advancement messages for ";
|
||||
|
||||
try {
|
||||
String disableMsg = ChatColor.stripColor(plugin.getPrefix()) + "Disabling vanilla advancement messages for ";
|
||||
List<World> worlds = this.plugin.getServer().getWorlds();
|
||||
Method setRuleMethod, getRuleMethod;
|
||||
try {
|
||||
|
||||
for (World w : worlds) {
|
||||
if (Version.ServerVersion.isCurrentEqualOrLower(Version.ServerVersion.v1_12_R1)){
|
||||
getRuleMethod = w.getClass().getDeclaredMethod("getGameRuleValue", String.class);
|
||||
if (getRuleMethod.invoke(w,"announceAdvancements")=="true"){
|
||||
setRuleMethod = w.getClass().getDeclaredMethod("setGameRuleValue", String.class, String.class);
|
||||
setRuleMethod.invoke(w,"announceAdvancements", "false");
|
||||
this.plugin.getLogger().info(disablemsg + w.getName());
|
||||
this.plugin.getLogger().info(disableMsg + w.getName());
|
||||
}
|
||||
}else{
|
||||
getRuleMethod = w.getClass().getDeclaredMethod("getGameRuleValue", GameRule.class);
|
||||
if ((boolean)getRuleMethod.invoke(w,GameRule.ANNOUNCE_ADVANCEMENTS)){
|
||||
setRuleMethod = w.getClass().getDeclaredMethod("setGameRule", GameRule.class, Object.class);
|
||||
setRuleMethod.invoke(w,GameRule.ANNOUNCE_ADVANCEMENTS,false);
|
||||
this.plugin.getLogger().info(disablemsg + w.getName());
|
||||
this.plugin.getLogger().info(disableMsg + w.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class Cooldown {
|
||||
|
||||
public Cooldown(STPlugin instance){
|
||||
this.plugin = instance;
|
||||
this.config = plugin.config;
|
||||
this.config = plugin.getConfig();
|
||||
if (config.isSet("Cooldown.seconds")){
|
||||
int cd = this.delay;
|
||||
if (cd!=config.getInt("Cooldown.seconds")){
|
||||
|
@ -26,7 +26,18 @@ public class Version {
|
||||
v1_18_R1,
|
||||
v1_18_R2,
|
||||
v1_19_R1,
|
||||
v1_19_R2;
|
||||
v1_19_R2,
|
||||
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;
|
||||
|
||||
@ -57,11 +68,33 @@ public class Version {
|
||||
return current;
|
||||
}
|
||||
|
||||
public static String[] getArrayVersion() {
|
||||
/*public static String[] getArrayVersion() {
|
||||
if (arrayVersion == null) {
|
||||
arrayVersion = org.bukkit.Bukkit.getServer().getClass().getPackage().getName().split("\\.");
|
||||
}
|
||||
|
||||
return arrayVersion;
|
||||
}*/
|
||||
public static String[] getArrayVersion() {
|
||||
if (arrayVersion == null) {
|
||||
String packageName = org.bukkit.Bukkit.getServer().getClass().getPackage().getName();
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
/*
|
||||
package hu.ditservices.utils.reflection;
|
||||
|
||||
import hu.ditservices.utils.Version;
|
||||
@ -91,3 +92,4 @@ public final class ClazzContainer {
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -1,3 +1,4 @@
|
||||
/*
|
||||
package hu.ditservices.utils.reflection;
|
||||
|
||||
import hu.ditservices.utils.Version;
|
||||
@ -100,6 +101,7 @@ public class Reflection {
|
||||
//return ClazzContainer.getIChatBaseComponent().cast(chatSerializerMethodA.invoke(chatSerializer, json));
|
||||
}
|
||||
|
||||
*/
|
||||
/*public static Class<?> getNMSClassRegex(String nmsClass) {
|
||||
|
||||
String version = null;
|
||||
@ -118,5 +120,7 @@ public class Reflection {
|
||||
return null;
|
||||
}
|
||||
|
||||
}*/
|
||||
}*//*
|
||||
|
||||
}
|
||||
*/
|
||||
|
@ -80,6 +80,12 @@ Cooldown:
|
||||
# The time must be passed between using this plugin commands.
|
||||
seconds: 2 #The command cooldown in seconds
|
||||
Msg: '{PREFIX} Please wait {SECONDS} seconds!' # The message when the user spamming a command
|
||||
|
||||
#
|
||||
# Plugin Manager - Enable/Disable plugins without server restart
|
||||
# Attention! It may cause errors in other plugins if you use this feature, not recommended!
|
||||
# If this is set to 'true' you can use the /st pmanager commands. Set it to 'false' to prevent its use.
|
||||
#
|
||||
PluginManager:
|
||||
enabled: false
|
||||
# Miscellaneous
|
||||
Prefix: '&a[&fSimplify&7Tools&2] &4- &f'
|
||||
Prefix: '&a[&fSimplify&7Tools&2] &4- &f' # The prefix which is inserted to the beginning of every plugin message.
|
||||
|
@ -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.
|
||||
|
Reference in New Issue
Block a user