Compare commits
No commits in common. "main" and "6322a444beada56540d5bd9236358073e028eb7d" have entirely different histories.
main
...
6322a444be
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>
|
41
.idea/jarRepositories.xml
generated
41
.idea/jarRepositories.xml
generated
@ -1,45 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="RemoteRepositoriesConfiguration">
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="central" />
|
|
||||||
<option name="name" value="Central Repository" />
|
|
||||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
|
||||||
</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" />
|
|
||||||
<option name="url" value="https://oss.sonatype.org/content/groups/public/" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="spigot-repo" />
|
<option name="id" value="spigot-repo" />
|
||||||
<option name="name" value="spigot-repo" />
|
<option name="name" value="spigot-repo" />
|
||||||
<option name="url" value="https://hub.spigotmc.org/nexus/content/repositories/snapshots/" />
|
<option name="url" value="https://hub.spigotmc.org/nexus/content/repositories/snapshots/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="dmulloy2-repo" />
|
<option name="id" value="central" />
|
||||||
<option name="name" value="dmulloy2-repo" />
|
<option name="name" value="Central Repository" />
|
||||||
<option name="url" value="https://repo.dmulloy2.net/repository/public/" />
|
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
|
||||||
<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>
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="central" />
|
<option name="id" value="central" />
|
||||||
@ -51,5 +21,10 @@
|
|||||||
<option name="name" value="JBoss Community repository" />
|
<option name="name" value="JBoss Community repository" />
|
||||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="sonatype" />
|
||||||
|
<option name="name" value="sonatype" />
|
||||||
|
<option name="url" value="https://oss.sonatype.org/content/groups/public/" />
|
||||||
|
</remote-repository>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
6
.idea/misc.xml
generated
6
.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>
|
||||||
@ -13,8 +12,5 @@
|
|||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="16" project-jdk-type="JavaSDK" />
|
||||||
<component name="ProjectType">
|
|
||||||
<option name="id" value="jpab" />
|
|
||||||
</component>
|
|
||||||
</project>
|
</project>
|
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module version="4">
|
|
||||||
<component name="McpModuleSettings">
|
|
||||||
<option name="srgType" value="SRG" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
60
README.md
60
README.md
@ -1,53 +1,35 @@
|
|||||||

|
# SimplifyTools
|
||||||
### An 'All-in-one' plugin for MC servers.
|
### An 'All-in-one' helper plugin for Minecraft Spigot Servers.
|
||||||
#### TabList Customizing, Server Password, Clear Dropped Items, Custom Advancement, Connect messages, AutoSave, Logger
|
| Build Status |  |
|
||||||
[](https://ci.ditservices.hu/job/SimplifyTools/)   [](https://bstats.org/plugin/bukkit/SimplifyTools/15108) 
|
|:-------------:|:-----------------------------------------------------------------------------------------------------------------:|
|
||||||
<br>[Changelog](docs/ChangeLog.md)
|
| MC Version |  |
|
||||||
<hr>
|
| Lines of code |  |
|
||||||
|
| Files |  |
|
||||||
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- **Tab Manager** - Allows you to specify colored texts, with animations on the tab window.
|
- **Tab Manager** - Allows you to specify colored texts, with animations on the tab window.
|
||||||
Also you can display the average ping, Server RAM statistics.
|
Also you can display the average ping, Server RAM statistics.
|
||||||

|

|
||||||
- **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.)
|
|
||||||

|
|
||||||
- **Server Password** - Allows you to set a server password *(same password for all players)*, ability to: skip auth for OP players, hide inventory, disable moving, building, until providing correct password `/slogin {PASSWORD}`
|
|
||||||
- **Clearing Dropped Items** - Set an interval in seconds to remove dropped items. Ability to broadcast clearing before 1min, 10sec, skip items and/or worlds.
|
|
||||||
- **Custom Connect/Disconnect messages** - Allows you to customize the message that is broadcasted when someone joins or leaves the server.
|
|
||||||

|
|
||||||
- **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.
|
- **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.
|
||||||
- **Plugin Manager** - Allows you to unload/load plugins without a server restart. (Disabled by default since v1.2.1)
|
- **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.
|
||||||
|
(Note: This may be removed in 1.17.x versions for security reasons)
|
||||||
|
- **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.)
|
||||||
|

|
||||||
- **Custom Advancement Messages** - You can customize the advancement messages in three categories: advancement, goal, challenge.
|
- **Custom Advancement Messages** - You can customize the advancement messages in three categories: advancement, goal, challenge.
|
||||||
(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)
|
||||||
_________________
|
|
||||||
### Translation
|
|
||||||
Under the plugin's directory inside the lang folder you can add your own translation. <br>
|
|
||||||
Just copy-paste [en.yml](src/main/resources/en.yml) and translate the strings to your language. <br>
|
|
||||||
In the config.yml you can set the newly created language (for example: de.yml) to like this: `language: 'de'` and your translation will be used. <br>
|
|
||||||
Feel free to open a pull request and your language can be added to the plugin.
|
|
||||||
_________________
|
|
||||||
### [Building from source](docs/BUILDING.md)
|
|
||||||
_________________
|
|
||||||
### If you have an idea or bug report [Create an issue](https://github.com/LabodiDavid/SimplifyTools/issues/new/choose) or [Create a pull request](https://github.com/LabodiDavid/SimplifyTools/compare)
|
### If you have an idea or bug report [Create an issue](https://github.com/LabodiDavid/SimplifyTools/issues/new/choose) or [Create a pull request](https://github.com/LabodiDavid/SimplifyTools/compare)
|
||||||
_________________
|
|
||||||
## Main goal
|
## Main goal
|
||||||
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 so many 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)
|
|
@ -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>
|
||||||
@ -9,7 +9,18 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</facet>
|
</facet>
|
||||||
</component>
|
</component>
|
||||||
<component name="McpModuleSettings">
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||||
<option name="srgType" value="SRG" />
|
<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" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.16.5-R0.1-SNAPSHOT" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
@ -1,30 +0,0 @@
|
|||||||
## SimplifyTools - Building
|
|
||||||
Some of these dependencies only needed
|
|
||||||
#### Dependencies:
|
|
||||||
- (1.18.2) - spigot-api-1.18.2-R0.1-SNAPSHOT-shaded.jar (from Spigot Repo Downloads Automatically OR **BuildTools** compiled `Spigot\Spigot-API\target\`)
|
|
||||||
- (1.18.2) - brigadier-1.0.18.jar (from **BuildTools** compiled `spigot-x.xx.x.jar\META-INF\libraries\`)
|
|
||||||
- (1.18.2) - craftbukkit-1.18.2-R0.1-SNAPSHOT.jar (from downloaded `craftbukkit-x.xx.x.jar\META-INF\versions\`)
|
|
||||||
- (1.16.5) - spigot-1.16.5.jar (**BuildTools** compiled)
|
|
||||||
- (1.15.2) - spigot-1.15.2.jar (**BuildTools** compiled)
|
|
||||||
- (1.14.4) - spigot-1.14.4.jar (**BuildTools** compiled)
|
|
||||||
##### Installing Dependencies:
|
|
||||||
You can install the dependencies to your maven repository through CLI like this:
|
|
||||||
|
|
||||||
- mvn install:install-file -Dfile=spigot-api-1.18.2-R0.1-SNAPSHOT-shaded.jar -DgroupId=org.spigotmc -DartifactId=spigot-api -Dversion=1.18.2-R0.1-SNAPSHOT -Dpackaging=jar
|
|
||||||
|
|
||||||
|
|
||||||
- mvn install:install-file -Dfile=craftbukkit-1.18.2-R0.1-SNAPSHOT.jar -DgroupId=org.bukkit -DartifactId=craftbukkit -Dversion=1.18.2-R0.1-SNAPSHOT -Dpackaging=jar
|
|
||||||
|
|
||||||
|
|
||||||
- mvn install:install-file -Dfile=brigadier-1.0.18.jar -DgroupId=com.mojang -DartifactId=brigadier -Dversion=1.0.18 -Dpackaging=jar
|
|
||||||
|
|
||||||
|
|
||||||
- mvn install:install-file -Dfile=spigot-1.16.5.jar -DgroupId=org.spigotmc -DartifactId=spigot -Dversion=1.16.5-R0.1-SNAPSHOT -Dpackaging=jar
|
|
||||||
|
|
||||||
|
|
||||||
- mvn install:install-file -Dfile=spigot-1.15.2.jar -DgroupId=org.spigotmc -DartifactId=spigot -Dversion=1.15.2-R0.1-SNAPSHOT -Dpackaging=jar
|
|
||||||
|
|
||||||
|
|
||||||
- mvn install:install-file -Dfile=spigot-1.14.4.jar -DgroupId=org.spigotmc -DartifactId=spigot -Dversion=1.14.4-R0.1-SNAPSHOT -Dpackaging=jar
|
|
||||||
|
|
||||||
- mvn install:install-file -Dfile=spigot-1.17.1.jar -DgroupId=org.spigotmc -DartifactId=spigot -Dversion=1.17.1-R0.1-SNAPSHOT -Dpackaging=jar
|
|
@ -1,37 +1,4 @@
|
|||||||
# SimplifyTools - Changelog
|
## SimplifyTools Changelog
|
||||||
- **1.2.4**
|
|
||||||
- Added *Server password feature*
|
- 1.0.0 - First Release
|
||||||
- Added *Clearing dropped items feature*
|
- Notice: If the /st reload command not reloading the new settings, you need to restart your MC server.
|
||||||
- Implemented customizable translation
|
|
||||||
- Added total play time to stats command
|
|
||||||
- Tab completer optimalizations
|
|
||||||
- Minor refactors/optimalizations
|
|
||||||
- Prepared support for 1.21.5 (Not tested yet)
|
|
||||||
- From now running newer untested server versions is allowed
|
|
||||||
- **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**
|
|
||||||
- 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,20 +1,16 @@
|
|||||||
## SimplifyTools - Commands
|
## SimplifyTools Commands
|
||||||
You can use the following commands to use the features of SimplifyTools.
|
You can use the following commands to use the features of SimplifyTools.
|
||||||
- **/st**: The main SimplifyTools command.<br />Requires `st.st`
|
- **/st**: The main SimplifyTools command.<br />Requires `st.st`
|
||||||
- **/st help**: Displays all SimplifyTools related commands.<br />Requires `st.help`
|
- **/st help**: Displays all SimplifyTools related commands.<br />Requires `st.help`
|
||||||
- **/st ping**: Displays your ping to the current server.<br />Requires `st.ping`
|
- **/st ping**: Displays your ping to the current server.<br />Requires `st.ping`
|
||||||
- **/st tps**: Displays plugin calculated TPS.<br />Requires `st.tps`
|
|
||||||
- **/st stats**: Displays your gameplay statistics.<br />Requires `st.stats`
|
- **/st stats**: Displays your gameplay statistics.<br />Requires `st.stats`
|
||||||
- **/slogin**: Used to login if server password enabled.<br />Requires `st.slogin`
|
|
||||||
- **/st save-all**: Saves the players, worlds data on the server.<br />Requires `st.save`
|
- **/st save-all**: Saves the players, worlds data on the server.<br />Requires `st.save`
|
||||||
- **/st pmanager** <LOAD/UNLOAD>: A built-in plugin manager.<br />Requires `st.pmanager.*`
|
- **/st pmanager** <LOAD/UNLOAD>: A built-in plugin manager.<br />Requires `st.pmanager.*`
|
||||||
- **/st pmanager load** <PLUGIN-NAME>: Plugin loading.<br />Requires `st.pmanager.load (can be inherited from st.pmanager.*)`
|
- **/st pmanager load** <PLUGIN-NAME>: Plugin loading.<br />Requires `st.pmanager.load (can be inherited from st.pmanager.*)`
|
||||||
- **/st pmanager unload** <PLUGIN-NAME>: Plugin unload.<br />Requires `st.pmanager.unload (can be inherited from st.pmanager.*)`
|
- **/st pmanager unload** <PLUGIN-NAME>: Plugin unload.<br />Requires `st.pmanager.unload (can be inherited from st.pmanager.*)`
|
||||||
- **/st reload**: Plugin settings reload.<br />Requires `st.reload`
|
- **/st reload**: Plugin settings reload.<br />Requires `st.reload`
|
||||||
## SimplifyTools - Permissions
|
<br />
|
||||||
- `st.slogin.skip` - If has this permission the user dont have to provide server password upon connect if enabled.
|
## SimplifyTools Wildcard Permissions
|
||||||
## SimplifyTools - Wildcard Permissions
|
|
||||||
|
|
||||||
- **st.*** - Wildcard permission for all commands, permissions for this plugin.
|
- **st.*** - Wildcard permission for all commands, permissions for this plugin.
|
||||||
- **st.pmanager.*** - Wildcard permission for the plugin manager commands.
|
- **st.pmanager.*** - Wildcard permission for the plugin manager commands.
|
||||||
- **st.admin** - A wildcard permission for admins. This is used for notify when update available, also grants usage for `st.save` and `st.pmanager.*`
|
- **st.admin** - A wildcard permission for admins. This is used for notify when update available, also grants usage for `st.save` and `st.pmanager.*`
|
BIN
docs/img/1.gif
BIN
docs/img/1.gif
Binary file not shown.
Before Width: | Height: | Size: 2.7 MiB |
BIN
docs/img/2.gif
BIN
docs/img/2.gif
Binary file not shown.
Before Width: | Height: | Size: 948 KiB |
BIN
docs/img/3.gif
BIN
docs/img/3.gif
Binary file not shown.
Before Width: | Height: | Size: 4.6 MiB |
BIN
docs/img/4.gif
BIN
docs/img/4.gif
Binary file not shown.
Before Width: | Height: | Size: 3.7 MiB |
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 |
70
pom.xml
70
pom.xml
@ -4,9 +4,9 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>hu.ditservices</groupId>
|
<groupId>tk.ditservices</groupId>
|
||||||
<artifactId>SimplifyTools</artifactId>
|
<artifactId>SimplifyTools</artifactId>
|
||||||
<version>1.2.4</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>SimplifyTools</name>
|
<name>SimplifyTools</name>
|
||||||
@ -16,11 +16,11 @@
|
|||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<url>ditservices.hu</url>
|
<url>dit-services.tk</url>
|
||||||
|
|
||||||
<ciManagement>
|
<ciManagement>
|
||||||
<system>jenkins</system>
|
<system>jenkins</system>
|
||||||
<url>https://ci.ditservices.hu/job/SimplifyTools/</url>
|
<url>https://ci.dit-services.tk/job/SimplifyTools/</url>
|
||||||
</ciManagement>
|
</ciManagement>
|
||||||
|
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
@ -42,7 +42,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.10.1</version>
|
<version>3.7.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>${java.version}</source>
|
<source>${java.version}</source>
|
||||||
<target>${java.version}</target>
|
<target>${java.version}</target>
|
||||||
@ -51,20 +51,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>3.2.1</version>
|
<version>3.1.0</version>
|
||||||
<configuration>
|
|
||||||
<relocations>
|
|
||||||
<!-- Using the maven-shade-plugin to shade and relocate the UpdateChecker -->
|
|
||||||
<relocation>
|
|
||||||
<pattern>com.jeff_media.updatechecker</pattern>
|
|
||||||
<shadedPattern>hu.ditservices.updatechecker</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
|
||||||
<pattern>org.bstats</pattern>
|
|
||||||
<shadedPattern>hu.ditservices.bstats</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
</relocations>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
@ -87,58 +74,21 @@
|
|||||||
</build>
|
</build>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
|
||||||
<id>spigot-repo</id>
|
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>papermc</id>
|
|
||||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>jeff-media-public</id>
|
|
||||||
<url>https://hub.jeff-media.com/nexus/repository/jeff-media-public/</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>sonatype</id>
|
<id>sonatype</id>
|
||||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>dmulloy2-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>https://repo.dmulloy2.net/repository/public/</url>
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>com.tchristofferson</groupId>
|
|
||||||
<artifactId>ConfigUpdater</artifactId>
|
|
||||||
<version>2.2-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.jeff_media</groupId>
|
|
||||||
<artifactId>SpigotUpdateChecker</artifactId>
|
|
||||||
<version>2.2.0</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bstats</groupId>
|
|
||||||
<artifactId>bstats-bukkit</artifactId>
|
|
||||||
<version>3.0.0</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.21.5-R0.1-SNAPSHOT</version>
|
<version>1.16.5-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<!-- from downloaded craftbukkit-x.xx.x.jar\META-INF\versions\ -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.comphenix.protocol</groupId>
|
|
||||||
<artifactId>ProtocolLib</artifactId>
|
|
||||||
<version>5.1.0</version>
|
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -1,270 +0,0 @@
|
|||||||
package hu.ditservices;
|
|
||||||
|
|
||||||
import hu.ditservices.handlers.*;
|
|
||||||
import hu.ditservices.listeners.*;
|
|
||||||
import hu.ditservices.utils.*;
|
|
||||||
import hu.ditservices.utils.Math;
|
|
||||||
import org.bstats.bukkit.Metrics;
|
|
||||||
import com.tchristofferson.configupdater.ConfigUpdater;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.PluginCommand;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import com.jeff_media.updatechecker.UpdateCheckSource;
|
|
||||||
import com.jeff_media.updatechecker.UpdateChecker;
|
|
||||||
import com.jeff_media.updatechecker.UserAgentBuilder;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.lang.management.ManagementFactory;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
public final class STPlugin extends JavaPlugin implements CommandExecutor, Listener {
|
|
||||||
private static STPlugin instance;
|
|
||||||
private final Logger log = Bukkit.getLogger();
|
|
||||||
|
|
||||||
private FileConfiguration config;
|
|
||||||
|
|
||||||
public long ServerStartTime;
|
|
||||||
|
|
||||||
private YamlConfiguration langConfig;
|
|
||||||
private ServerPasswordData serverPasswordData;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnable() {
|
|
||||||
instance = this;
|
|
||||||
|
|
||||||
if (this.initPlugin()) {
|
|
||||||
this.log.info(ChatColor.stripColor(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 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(ChatColor.stripColor(this.getPrefix()) + "Custom Advancement Messages enabled!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.config.isSet("ServerPassword.enabled") && this.config.getBoolean("ServerPassword.enabled")) {
|
|
||||||
this.serverPasswordData = new ServerPasswordData(this);
|
|
||||||
PluginCommand sloginCommand = this.getCommand("slogin");
|
|
||||||
sloginCommand.setExecutor(new LoginCommandHandler(this));
|
|
||||||
getServer().getPluginManager().registerEvents(new ServerPasswordEvents(this), this);
|
|
||||||
this.log.info(ChatColor.stripColor(this.getPrefix()) + "Server Password enabled!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void scheduleTasks() {
|
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new TPS(), 0, 1);
|
|
||||||
|
|
||||||
if (this.config.getBoolean("ClearDropItems.enabled")) {
|
|
||||||
new ClearDropItemsTask(this).runTaskTimer(this, 20L, 20L);
|
|
||||||
this.log.info(ChatColor.stripColor(this.getPrefix()) + "Clear dropped items enabled!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.config.getBoolean("Saving.enabled") && this.config.getInt("Saving.interval") > 0) {
|
|
||||||
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")
|
|
||||||
.setChangelogLink("https://github.com/LabodiDavid/SimplifyTools/blob/main/docs/ChangeLog.md")
|
|
||||||
.setNotifyOpsOnJoin(true)
|
|
||||||
.setNotifyByPermissionOnJoin("st.admin")
|
|
||||||
.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)) {
|
|
||||||
throw new Exception("The server version is not supported! Update to to atleast 1.12 version to use this plugin!");
|
|
||||||
}
|
|
||||||
if (Version.ServerVersion.isCurrentHigher(Version.ServerVersion.v1_21_5_R1)) {
|
|
||||||
this.log.warning(ChatColor.stripColor(this.getPrefix()) + "You are running a server version which is not tested with this plugin, errors can be occur!");
|
|
||||||
}
|
|
||||||
|
|
||||||
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(ChatColor.stripColor(this.getPrefix()) + "INITIALIZATION ERROR: " + e.getMessage());
|
|
||||||
this.log.warning(ChatColor.stripColor(this.getPrefix()) + "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"));
|
|
||||||
}else{
|
|
||||||
return ChatColor.translateAlternateColorCodes('&',"&a[&fSimplify&7Tools&2] &4- &f");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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() {
|
|
||||||
long uptime = (System.currentTimeMillis() - instance.ServerStartTime) / 1000;
|
|
||||||
StringBuilder returnText = new StringBuilder();
|
|
||||||
|
|
||||||
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.append(days).append(" days ");
|
|
||||||
}
|
|
||||||
if (hours > 1) {
|
|
||||||
returnText.append(hours).append(" hours ");
|
|
||||||
}
|
|
||||||
if (minutes > 1) {
|
|
||||||
returnText.append(minutes).append(" min ");
|
|
||||||
}
|
|
||||||
if (seconds > 1) {
|
|
||||||
returnText.append(seconds).append("s ");
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnText.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerPasswordData getServerPasswordData() {
|
|
||||||
return this.serverPasswordData;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void copyDefaultLang(String filename, File langFolder) {
|
|
||||||
File outFile = new File(langFolder, filename);
|
|
||||||
|
|
||||||
if (!outFile.exists()) {
|
|
||||||
try (InputStream in = getResource(filename);
|
|
||||||
OutputStream out = new FileOutputStream(outFile)) {
|
|
||||||
|
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
int length;
|
|
||||||
while ((length = in.read(buffer)) > 0) {
|
|
||||||
out.write(buffer, 0, length);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
this.log.warning(ChatColor.stripColor(this.getPrefix()) + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initLocalization() throws IOException {
|
|
||||||
File langFolder = new File(getDataFolder(), "lang");
|
|
||||||
if (!langFolder.exists()) {
|
|
||||||
langFolder.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] languages = {"en", "hu"};
|
|
||||||
for (String l : languages) {
|
|
||||||
File langFile = new File(langFolder, l + ".yml");
|
|
||||||
if (!langFile.exists()) {
|
|
||||||
copyDefaultLang(l + ".yml", langFolder);
|
|
||||||
}
|
|
||||||
ConfigUpdater.update(this, l + ".yml", langFile, Collections.emptyList());
|
|
||||||
}
|
|
||||||
|
|
||||||
String lang = this.config.getString("language", "en");
|
|
||||||
File langFile = new File(getDataFolder(), "lang" + File.separator + lang + ".yml");
|
|
||||||
if (!langFile.exists()) {
|
|
||||||
getLogger().warning("Language file for '" + lang + "' not found. Falling back to English.");
|
|
||||||
langFile = new File(getDataFolder(), "lang" + File.separator + "en.yml");
|
|
||||||
}
|
|
||||||
this.langConfig = YamlConfiguration.loadConfiguration(langFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTranslatedText(String key) {
|
|
||||||
return langConfig.getString(key, "Translation not found: " + key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean reload(){
|
|
||||||
File configFile = new File(getDataFolder(), "config.yml");
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (!configFile.exists()){
|
|
||||||
this.saveDefaultConfig();
|
|
||||||
}
|
|
||||||
ConfigUpdater.update(this, "config.yml", configFile, Collections.emptyList());
|
|
||||||
} catch (IOException e) {
|
|
||||||
this.log.warning(ChatColor.stripColor(this.getPrefix()) + e.getMessage());
|
|
||||||
}
|
|
||||||
reloadConfig();
|
|
||||||
this.config = getConfig();
|
|
||||||
try {
|
|
||||||
this.initLocalization();
|
|
||||||
} catch (IOException e) {
|
|
||||||
this.log.warning(ChatColor.stripColor(this.getPrefix()) + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onDisable() {
|
|
||||||
this.log.info(ChatColor.stripColor(this.getPrefix()) + "Stopped running.");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
package hu.ditservices.commands;
|
|
||||||
|
|
||||||
import hu.ditservices.STPlugin;
|
|
||||||
import hu.ditservices.utils.Server;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class PingCommand {
|
|
||||||
public static boolean Run(CommandSender sender) {
|
|
||||||
STPlugin plugin = STPlugin.getInstance();
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
try {
|
|
||||||
player.sendMessage(plugin.getPrefix() + plugin.getTranslatedText("cmd.ping") + Server.getPlayerPing(player) + " ms");
|
|
||||||
return true;
|
|
||||||
} catch (IllegalArgumentException | SecurityException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (sender instanceof ConsoleCommandSender) {
|
|
||||||
ConsoleCommandSender consoleCommandSender = (ConsoleCommandSender) sender;
|
|
||||||
consoleCommandSender.sendMessage(plugin.getPrefix() + "For this command you have to be a player!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
package hu.ditservices.commands;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import hu.ditservices.STPlugin;
|
|
||||||
//import hu.ditservices.DitPluginManager;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
|
|
||||||
public class PluginManagerCommand {
|
|
||||||
public static boolean LoadPlugin(CommandSender sender, String[] args){
|
|
||||||
Plugin plugin = Bukkit.getPluginManager().getPlugin(args[2]);
|
|
||||||
if (plugin == null) {
|
|
||||||
sender.sendMessage(STPlugin.getInstance().getPrefix()+ STPlugin.getInstance().getTranslatedText("pmanager.not.exist"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (plugin.isEnabled()){
|
|
||||||
sender.sendMessage(STPlugin.getInstance().getPrefix()+"Plugin "+plugin.getName()+STPlugin.getInstance().getTranslatedText("pmanager.already.enabled"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getPluginManager().enablePlugin(plugin);
|
|
||||||
sender.sendMessage(STPlugin.getInstance().getPrefix()+"Plugin "+plugin.getName()+STPlugin.getInstance().getTranslatedText("pmanager.success.enabled"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public static boolean UnloadPlugin(CommandSender sender, String[] args){
|
|
||||||
Plugin plugin = Bukkit.getPluginManager().getPlugin(args[2]);
|
|
||||||
if (plugin == null) {
|
|
||||||
sender.sendMessage(STPlugin.getInstance().getPrefix()+STPlugin.getInstance().getTranslatedText("pmanager.not.exist"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!plugin.isEnabled()){
|
|
||||||
sender.sendMessage(STPlugin.getInstance().getPrefix()+"Plugin "+plugin.getName()+STPlugin.getInstance().getTranslatedText("pmanager.already.disabled"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Bukkit.getPluginManager().disablePlugin(plugin);
|
|
||||||
sender.sendMessage(STPlugin.getInstance().getPrefix()+"Plugin "+plugin.getName()+STPlugin.getInstance().getTranslatedText("pmanager.success.disabled"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*public static boolean handleLoad(CommandSender sender, String[] args){
|
|
||||||
switch (DitPluginManager.load(args[2])){
|
|
||||||
case 0: sender.sendMessage(DITSystem.getInstance().getPrefix()+" Plugin loaded."); return true;
|
|
||||||
case 2: sender.sendMessage(DITSystem.getInstance().getPrefix()+"Missing dependency!"); return true;
|
|
||||||
case -1: sender.sendMessage(DITSystem.getInstance().getPrefix()+"Invalid/ not exist plugin!"); return true;
|
|
||||||
case 3: sender.sendMessage(DITSystem.getInstance().getPrefix()+"Invalid description!"); return true;
|
|
||||||
case 5: sender.sendMessage(DITSystem.getInstance().getPrefix()+"This plugin is already running!"); return true;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public static boolean handleUnload(CommandSender sender, String[] args){
|
|
||||||
switch (DitPluginManager.unload(args[2])){
|
|
||||||
case 0: sender.sendMessage(DITSystem.getInstance().getPrefix()+" Plugin disabled."); return true;
|
|
||||||
case -1: sender.sendMessage(DITSystem.getInstance().getPrefix()+"This plugin is not exist."); return true;
|
|
||||||
case 1: sender.sendMessage(DITSystem.getInstance().getPrefix()+"Plugin and their dependents disabled."); return true;
|
|
||||||
case 5: sender.sendMessage(DITSystem.getInstance().getPrefix()+"This plugin is not loaded."); return true;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}*/
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
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();
|
|
||||||
|
|
||||||
String enabled = plugin.getTranslatedText("settings.enabled");
|
|
||||||
String disabled = plugin.getTranslatedText("settings.disabled");
|
|
||||||
|
|
||||||
sender.sendMessage( ChatColor.GREEN+" === Plugin Information === " + "\n"
|
|
||||||
+ ChatColor.GREEN + "Plugin " + plugin.getTranslatedText("version.pre.text") + ChatColor.translateAlternateColorCodes('&',"&a[&fSimplify&7Tools&2] &4- &f") + plugin.getDescription().getVersion() + "\n"
|
|
||||||
+ ChatColor.GREEN + plugin.getTranslatedText("settings.server") + plugin.getTranslatedText("version.pre.text") + Version.ServerVersion.getCurrent().toString() + "\n"
|
|
||||||
+ ChatColor.GREEN + " -------- " + plugin.getTranslatedText("settings.features") +" -------- " + "\n"
|
|
||||||
+ ChatColor.GREEN + plugin.getTranslatedText("settings.feature.tab") + (plugin.getConfig().getBoolean("Tab.enabled") ? ChatColor.GREEN + enabled : ChatColor.RED + disabled) + "\n"
|
|
||||||
+ ChatColor.GREEN + plugin.getTranslatedText("settings.feature.CustomAdvancementMsg") + (plugin.getConfig().getBoolean("CustomAdvancement.enabled") ? ChatColor.GREEN + enabled : ChatColor.RED + disabled) + "\n"
|
|
||||||
+ ChatColor.GREEN + plugin.getTranslatedText("settings.feature.AutoSave") + (plugin.getConfig().getBoolean("Saving.enabled") ? ChatColor.GREEN + enabled : ChatColor.RED + disabled) + "\n"
|
|
||||||
+ ChatColor.GREEN + plugin.getTranslatedText("settings.feature.pmanager") + (plugin.getConfig().getBoolean("PluginManager.enabled") ? ChatColor.GREEN + enabled : ChatColor.RED + disabled) + "\n"
|
|
||||||
+ ChatColor.GREEN + " ========================== "
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
package hu.ditservices.commands;
|
|
||||||
|
|
||||||
import hu.ditservices.STPlugin;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Statistic;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class StatCommand {
|
|
||||||
public static boolean Run(CommandSender sender){
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
// Calculate total play time from ticks (Minecraft runs at 20 ticks per second)
|
|
||||||
long totalTicks = player.getStatistic(Statistic.TOTAL_WORLD_TIME);
|
|
||||||
long totalSeconds = totalTicks / 20;
|
|
||||||
long hours = totalSeconds / 3600;
|
|
||||||
long minutes = (totalSeconds % 3600) / 60;
|
|
||||||
long seconds = totalSeconds % 60;
|
|
||||||
STPlugin plugin = STPlugin.getInstance();
|
|
||||||
plugin.getTranslatedText("");
|
|
||||||
|
|
||||||
player.sendMessage(STPlugin.getInstance().getPrefix() + ChatColor.GREEN + " === "+plugin.getTranslatedText("stats.header")+" === ");
|
|
||||||
player.sendMessage(ChatColor.AQUA+plugin.getTranslatedText("stats.connects") + (player.getStatistic(Statistic.LEAVE_GAME)+1));
|
|
||||||
player.sendMessage(ChatColor.AQUA+plugin.getTranslatedText("stats.deaths") + player.getStatistic(Statistic.DEATHS));
|
|
||||||
player.sendMessage(ChatColor.AQUA+plugin.getTranslatedText("stats.MobKills") + player.getStatistic(Statistic.MOB_KILLS));
|
|
||||||
player.sendMessage(ChatColor.AQUA+plugin.getTranslatedText("stats.PlayerKills") + player.getStatistic(Statistic.PLAYER_KILLS));
|
|
||||||
player.sendMessage(ChatColor.AQUA+plugin.getTranslatedText("stats.sleeps") + player.getStatistic(Statistic.SLEEP_IN_BED));
|
|
||||||
player.sendMessage(ChatColor.AQUA+plugin.getTranslatedText("stats.enchants") + player.getStatistic(Statistic.ITEM_ENCHANTED));
|
|
||||||
player.sendMessage(ChatColor.AQUA + plugin.getTranslatedText("stats.totaltime") + hours + plugin.getTranslatedText("stats.hour") + minutes + plugin.getTranslatedText("stats.minutes") + seconds + plugin.getTranslatedText("stats.seconds"));
|
|
||||||
player.sendMessage(ChatColor.GREEN+" =================== ");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,76 +0,0 @@
|
|||||||
package hu.ditservices.handlers;
|
|
||||||
|
|
||||||
import hu.ditservices.STPlugin;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Item;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ClearDropItemsTask extends BukkitRunnable {
|
|
||||||
private final STPlugin plugin;
|
|
||||||
private int countdown;
|
|
||||||
private final int interval; // In seconds
|
|
||||||
private final List<String> exceptItemList;
|
|
||||||
private final List<String> exceptWorldList;
|
|
||||||
private final boolean shouldBroadcast;
|
|
||||||
|
|
||||||
public ClearDropItemsTask(STPlugin plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.interval = plugin.getConfig().getInt("ClearDropItems.interval", 300);
|
|
||||||
this.countdown = this.interval;
|
|
||||||
// Get the exception list from the config (should be a list of item type names, e.g., ["DIAMOND", "GOLD_INGOT"])
|
|
||||||
this.exceptItemList = plugin.getConfig().getStringList("ClearDropItems.except");
|
|
||||||
this.exceptWorldList = plugin.getConfig().getStringList("ClearDropItems.skipWorlds");
|
|
||||||
this.shouldBroadcast = plugin.getConfig().getBoolean("ClearDropItems.broadcastMsg", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (this.shouldBroadcast) {
|
|
||||||
if (countdown == 60) {
|
|
||||||
Bukkit.broadcastMessage(plugin.getPrefix() + ChatColor.RED + plugin.getTranslatedText("cleardropitems.oneMin"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (countdown == 10) {
|
|
||||||
Bukkit.broadcastMessage(plugin.getPrefix() + ChatColor.RED + plugin.getTranslatedText("cleardropitems.tenSec"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (countdown <= 0) {
|
|
||||||
int removed = 0;
|
|
||||||
|
|
||||||
for (World world : Bukkit.getWorlds()) {
|
|
||||||
if (this.exceptWorldList.contains(world.getName())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (Entity entity : world.getEntities()) {
|
|
||||||
|
|
||||||
if (entity instanceof Item) {
|
|
||||||
Item item = (Item) entity;
|
|
||||||
String itemType = item.getItemStack().getType().toString();
|
|
||||||
// Check if the item is in the exception list
|
|
||||||
boolean isException = this.exceptItemList.stream()
|
|
||||||
.anyMatch(ex -> ex.equalsIgnoreCase(itemType));
|
|
||||||
if (!isException) {
|
|
||||||
item.remove();
|
|
||||||
removed++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.shouldBroadcast) {
|
|
||||||
Bukkit.broadcastMessage(plugin.getPrefix() + ChatColor.GREEN + plugin.getTranslatedText("cleardropitems.cleared").replace("%REMOVECOUNT%",String.valueOf(removed)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset the countdown to the interval for the next cycle
|
|
||||||
countdown = interval;
|
|
||||||
} else {
|
|
||||||
countdown--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,113 +0,0 @@
|
|||||||
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 + plugin.getTranslatedText("list.help");
|
|
||||||
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+plugin.getTranslatedText("version.pre.text") + 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 + plugin.getTranslatedText("notice.settings.not.applied"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (command.getName().equals("st") && args[0].contains("tps") && sender.hasPermission("st.tps")) {
|
|
||||||
sender.sendMessage(plugin.getPrefix() + ChatColor.GREEN+plugin.getTranslatedText("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+plugin.getTranslatedText("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.getTranslatedText("pmanager.disabled"));
|
|
||||||
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,63 +0,0 @@
|
|||||||
package hu.ditservices.handlers;
|
|
||||||
|
|
||||||
import hu.ditservices.STPlugin;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class LoginCommandHandler implements CommandExecutor {
|
|
||||||
|
|
||||||
private final STPlugin plugin;
|
|
||||||
|
|
||||||
public LoginCommandHandler(STPlugin instance) {
|
|
||||||
this.plugin = instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Method to authenticate the player
|
|
||||||
public boolean authenticate(Player player, String password) {
|
|
||||||
if (plugin.getServerPasswordData().getServerPassword().equals(password)) {
|
|
||||||
if (plugin.getConfig().getBoolean("ServerPassword.preventInventory")) {
|
|
||||||
player.getInventory().setContents(plugin.getServerPasswordData().getInventoryMap().get(player.getUniqueId()));
|
|
||||||
player.getInventory().setArmorContents(plugin.getServerPasswordData().getArmorMap().get(player.getUniqueId()));
|
|
||||||
}
|
|
||||||
plugin.getServerPasswordData().getAuthenticatedPlayers().put(player.getUniqueId(), true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
sender.sendMessage("Only players can execute this command.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player player = (Player) sender;
|
|
||||||
UUID pUuid = player.getUniqueId();
|
|
||||||
|
|
||||||
if (args.length != 1) {
|
|
||||||
player.sendMessage(plugin.getTranslatedText("cmd.usage.login"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plugin.getServerPasswordData().getAuthenticatedPlayers().getOrDefault(pUuid,false)) {
|
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getTranslatedText("serverpassword.already.auth"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.authenticate(player, args[0])) {
|
|
||||||
player.sendMessage(ChatColor.GREEN + plugin.getTranslatedText("serverpassword.success.auth"));
|
|
||||||
plugin.getServerPasswordData().getInventoryMap().remove(pUuid);
|
|
||||||
plugin.getServerPasswordData().getArmorMap().remove(pUuid);
|
|
||||||
} else {
|
|
||||||
player.sendMessage(ChatColor.RED + plugin.getTranslatedText("serverpassword.incorrect"));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
|||||||
package hu.ditservices.handlers;
|
|
||||||
|
|
||||||
import hu.ditservices.commands.SaveCommand;
|
|
||||||
|
|
||||||
public class SaveHandler implements Runnable{
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
SaveCommand.Run();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,229 +0,0 @@
|
|||||||
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.Math;
|
|
||||||
import hu.ditservices.utils.Server;
|
|
||||||
import hu.ditservices.utils.TPS;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class TabHandler {
|
|
||||||
public final List<WrappedChatComponent> headerComponents = new ArrayList<>();
|
|
||||||
public final List<WrappedChatComponent> footerComponents = new ArrayList<>();
|
|
||||||
|
|
||||||
private Integer refreshRate;
|
|
||||||
|
|
||||||
private final STPlugin plugin;
|
|
||||||
public List<String> headeranimList = new ArrayList<>();
|
|
||||||
public List<String> footeranimList = new ArrayList<>();
|
|
||||||
|
|
||||||
private final ArrayList<String> formatArray = new ArrayList<>();
|
|
||||||
public final List<Integer> DynamicHeaders = new ArrayList<>();
|
|
||||||
public final List<Integer> DynamicFooters = new ArrayList<>();
|
|
||||||
|
|
||||||
private int count1 = 0; //headers
|
|
||||||
private int count2 = 0; //footers
|
|
||||||
private Object packet;
|
|
||||||
|
|
||||||
public TabHandler() {
|
|
||||||
|
|
||||||
this.plugin = STPlugin.getInstance();
|
|
||||||
|
|
||||||
if(this.init()){
|
|
||||||
if (headerComponents.isEmpty() && footerComponents.isEmpty()){
|
|
||||||
plugin.getLogger().warning(ChatColor.stripColor(plugin.getPrefix()) + "TAB customization disabled because empty customization config or feature related errors!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
plugin.getLogger().info("- TAB customization enabled!");
|
|
||||||
this.updateTab();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
private boolean init() {
|
|
||||||
if (plugin.getConfig().getBoolean("Tab.enabled")){
|
|
||||||
|
|
||||||
int availProcessors = Server.getCpuCores();
|
|
||||||
if (availProcessors < 3) {
|
|
||||||
plugin.getLogger().warning("You're currently having " + availProcessors + " CPU processors, which is not enough to run a minecraft server with scheduled plugins including SimplifyTools.");
|
|
||||||
plugin.getLogger().warning("You will be experiencing many lags during the server is running. Consider upgrading your CPU to at least reach 3 cores.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (plugin.getConfig().isSet("Tab.refreshRate")){
|
|
||||||
this.refreshRate = plugin.getConfig().getInt("Tab.refreshRate");
|
|
||||||
}else{
|
|
||||||
this.refreshRate=1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Getting the tab lines from the config
|
|
||||||
headeranimList = plugin.getConfig().getStringList("Tab.headerAnimation");
|
|
||||||
footeranimList = plugin.getConfig().getStringList("Tab.footerAnimation");
|
|
||||||
|
|
||||||
//Investigating lines where we need to run the formatting every tab refresh for example for the RAM usage.
|
|
||||||
//Only storing those lines indexes.
|
|
||||||
formatArray.add("{TOTALRAM}");
|
|
||||||
formatArray.add("{FREERAM}");
|
|
||||||
formatArray.add("{USEDRAM}");
|
|
||||||
formatArray.add("{AVERAGEPING}");
|
|
||||||
formatArray.add("{ONLINEPLAYERS}");
|
|
||||||
formatArray.add("{MAXPLAYERS}");
|
|
||||||
formatArray.add("{MOTD}");
|
|
||||||
formatArray.add("{UPTIME}");
|
|
||||||
formatArray.add("{TPS}");
|
|
||||||
for (String f: formatArray){
|
|
||||||
for (int i = 0; i<headeranimList.size(); i++){
|
|
||||||
if (headeranimList.get(i).contains(f) && !DynamicHeaders.contains(i)){
|
|
||||||
DynamicHeaders.add(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i<footeranimList.size(); i++){
|
|
||||||
if (footeranimList.get(i).contains(f) && !DynamicFooters.contains(i)){
|
|
||||||
DynamicFooters.add(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (String hanim : headeranimList){
|
|
||||||
this.addHeaderFooter(true,hanim,false);
|
|
||||||
}
|
|
||||||
for (String fanim : footeranimList){
|
|
||||||
this.addHeaderFooter(false,fanim,false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateTab(){
|
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
|
|
||||||
try {
|
|
||||||
if (Bukkit.getOnlinePlayers().isEmpty()){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
//display current value. (We check those lines in the init())
|
|
||||||
if (!DynamicHeaders.isEmpty() && count1 < DynamicHeaders.size()) {
|
|
||||||
if (DynamicHeaders.get(count1) == count1) {
|
|
||||||
addHeaderFooter(true, headeranimList.get(count1), true, count1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!DynamicFooters.isEmpty() && count2 < DynamicFooters.size()) {
|
|
||||||
if (DynamicFooters.get(count2) == count2) {
|
|
||||||
addHeaderFooter(false, footeranimList.get(count2), true, count2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
|
||||||
PacketContainer packet = protocolManager.createPacket(com.comphenix.protocol.PacketType.Play.Server.PLAYER_LIST_HEADER_FOOTER);
|
|
||||||
|
|
||||||
packet.getChatComponents().write(0, headerComponents.get(count1));
|
|
||||||
packet.getChatComponents().write(1, footerComponents.get(count2));
|
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
|
||||||
protocolManager.sendServerPacket(player, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (headerComponents.size() > 1) {
|
|
||||||
count1++;
|
|
||||||
}
|
|
||||||
if (footerComponents.size() > 1) {
|
|
||||||
count2++;
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
plugin.getLogger().warning(ChatColor.stripColor(plugin.getPrefix()) + e.getMessage());
|
|
||||||
}
|
|
||||||
},0,Math.convert(Math.Convert.SECONDS,Math.Convert.TICKS,this.refreshRate));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 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)+"\"}";
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e){
|
|
||||||
plugin.getLogger().warning(ChatColor.stripColor(plugin.getPrefix()) + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replaces the msg values to their represents and recognizes MC color codes.
|
|
||||||
* @param msg The text.
|
|
||||||
* @return Replaced text with recognized MC color codes.
|
|
||||||
*/
|
|
||||||
private String format(String msg){
|
|
||||||
if (msg.contains("{TOTALRAM}")){
|
|
||||||
msg = msg.replace("{TOTALRAM}",String.valueOf(Server.getRAM(Server.RAM.TOTAL)));
|
|
||||||
}
|
|
||||||
if (msg.contains("{FREERAM}")){
|
|
||||||
msg = msg.replace("{FREERAM}",String.valueOf(Server.getRAM(Server.RAM.FREE)));
|
|
||||||
}
|
|
||||||
if (msg.contains("{USEDRAM}")){
|
|
||||||
msg = msg.replace("{USEDRAM}",String.valueOf(Server.getRAM(Server.RAM.USED)));
|
|
||||||
}
|
|
||||||
if (msg.contains("{AVERAGEPING}")){
|
|
||||||
msg = msg.replace("{AVERAGEPING}",String.valueOf(Server.getAveragePing()));
|
|
||||||
}
|
|
||||||
if (msg.contains("{ONLINEPLAYERS}")){
|
|
||||||
msg = msg.replace("{ONLINEPLAYERS}",String.valueOf(plugin.getServer().getOnlinePlayers().size()));
|
|
||||||
}
|
|
||||||
if (msg.contains("{MAXPLAYERS}")){
|
|
||||||
msg = msg.replace("{MAXPLAYERS}",String.valueOf(plugin.getServer().getMaxPlayers()));
|
|
||||||
}
|
|
||||||
if (msg.contains("{UPTIME}")){
|
|
||||||
msg = msg.replace("{UPTIME}", STPlugin.getUptime());
|
|
||||||
}
|
|
||||||
if (msg.contains("{MOTD}")){
|
|
||||||
msg = msg.replace("{MOTD}", plugin.getServer().getMotd()); //LegacyComponentSerializer.legacyAmpersand().serialize(plugin.getServer().motd().asComponent())
|
|
||||||
}
|
|
||||||
if (msg.contains("{TPS}")){
|
|
||||||
msg = msg.replace("{TPS}",String.valueOf(java.lang.Math.round(TPS.getTPS())));
|
|
||||||
}
|
|
||||||
return ChatColor.translateAlternateColorCodes('&',msg);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,127 +0,0 @@
|
|||||||
package hu.ditservices.listeners;
|
|
||||||
|
|
||||||
import hu.ditservices.STPlugin;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class ServerPasswordEvents implements Listener {
|
|
||||||
private STPlugin plugin;
|
|
||||||
private FileConfiguration config;
|
|
||||||
|
|
||||||
public ServerPasswordEvents(STPlugin instance){
|
|
||||||
this.plugin = instance;
|
|
||||||
this.config = plugin.getConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean skipIfOpPlayer(Player player)
|
|
||||||
{
|
|
||||||
return (player.isOp() && config.getBoolean("ServerPassword.exceptOps")) || player.hasPermission("st.slogin.skip");
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
|
||||||
if (skipIfOpPlayer(player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((!config.getBoolean("ServerPassword.rememberUntilRestart"))
|
|
||||||
|| (!plugin.getServerPasswordData().getAuthenticatedPlayers().getOrDefault(player.getUniqueId(),false))) {
|
|
||||||
plugin.getServerPasswordData().getAuthenticatedPlayers().put(player.getUniqueId(),false);
|
|
||||||
if (config.getBoolean("ServerPassword.preventInventory")) {
|
|
||||||
// Store and clear inventory
|
|
||||||
plugin.getServerPasswordData().getInventoryMap().put(player.getUniqueId(), player.getInventory().getContents());
|
|
||||||
plugin.getServerPasswordData().getArmorMap().put(player.getUniqueId(), player.getInventory().getArmorContents());
|
|
||||||
player.getInventory().clear();
|
|
||||||
player.getInventory().setArmorContents(null);
|
|
||||||
}
|
|
||||||
player.sendMessage(ChatColor.RED + plugin.getTranslatedText("serverpassword.enabled"));
|
|
||||||
player.sendMessage(plugin.getTranslatedText("serverpassword.note"));
|
|
||||||
BukkitRunnable authReminder = new BukkitRunnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
// Check if the player is authenticated, default to false if not present.
|
|
||||||
if (plugin.getServerPasswordData().getAuthenticatedPlayers().getOrDefault(player.getUniqueId(), false)) {
|
|
||||||
this.cancel();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
player.sendMessage(ChatColor.RED + plugin.getTranslatedText("serverpassword.login"));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
authReminder.runTaskTimer(plugin, 0L, 100L);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
|
||||||
if (skipIfOpPlayer(event.getPlayer())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ((!plugin.getServerPasswordData().getAuthenticatedPlayers().getOrDefault(event.getPlayer().getUniqueId(),false))
|
|
||||||
&& config.getBoolean("ServerPassword.preventMove")) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
|
||||||
if (skipIfOpPlayer(event.getPlayer())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ((!plugin.getServerPasswordData().getAuthenticatedPlayers().getOrDefault(event.getPlayer().getUniqueId(),false))
|
|
||||||
&& config.getBoolean("ServerPassword.preventBuild")) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
|
||||||
if (skipIfOpPlayer(event.getPlayer())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ((!plugin.getServerPasswordData().getAuthenticatedPlayers().getOrDefault(event.getPlayer().getUniqueId(),false))
|
|
||||||
&& config.getBoolean("ServerPassword.preventBuild")) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
UUID uuid = player.getUniqueId();
|
|
||||||
|
|
||||||
if (skipIfOpPlayer(player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plugin.getServerPasswordData().getAuthenticatedPlayers().getOrDefault(uuid, false)) {
|
|
||||||
if (!config.getBoolean("ServerPassword.rememberUntilRestart")) {
|
|
||||||
plugin.getServerPasswordData().getAuthenticatedPlayers().remove(uuid);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (plugin.getConfig().getBoolean("ServerPassword.preventInventory")) {
|
|
||||||
if (plugin.getServerPasswordData().getInventoryMap().containsKey(uuid)) {
|
|
||||||
player.getInventory().setContents(plugin.getServerPasswordData().getInventoryMap().get(uuid));
|
|
||||||
plugin.getServerPasswordData().getInventoryMap().remove(uuid);
|
|
||||||
}
|
|
||||||
if (plugin.getServerPasswordData().getArmorMap().containsKey(uuid)) {
|
|
||||||
player.getInventory().setArmorContents(plugin.getServerPasswordData().getArmorMap().get(uuid));
|
|
||||||
plugin.getServerPasswordData().getArmorMap().remove(uuid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
package hu.ditservices.utils;
|
|
||||||
|
|
||||||
import hu.ditservices.STPlugin;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class ServerPasswordData {
|
|
||||||
private STPlugin plugin;
|
|
||||||
public ServerPasswordData(STPlugin instance) {
|
|
||||||
this.plugin = instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Maps to store inventory, armor, and authentication status
|
|
||||||
private final Map<UUID, ItemStack[]> inventoryMap = new HashMap<>();
|
|
||||||
private final Map<UUID, ItemStack[]> armorMap = new HashMap<>();
|
|
||||||
private final Map<UUID, Boolean> authenticatedPlayers = new HashMap<>();
|
|
||||||
|
|
||||||
// Getter for the inventory map
|
|
||||||
public Map<UUID, ItemStack[]> getInventoryMap() {
|
|
||||||
return inventoryMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getter for the armor map
|
|
||||||
public Map<UUID, ItemStack[]> getArmorMap() {
|
|
||||||
return armorMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getter for the authenticated players map
|
|
||||||
public Map<UUID, Boolean> getAuthenticatedPlayers() {
|
|
||||||
return authenticatedPlayers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getServerPassword() {
|
|
||||||
return this.plugin.getConfig().getString("ServerPassword.password");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
|||||||
package hu.ditservices.utils;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public class TPS implements Runnable {
|
|
||||||
|
|
||||||
public static int TICK_COUNT = 0;
|
|
||||||
public static long[] TICKS = new long[600];
|
|
||||||
public static long LAST_TICK = 0L;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static double getTPS() {
|
|
||||||
return getTPS(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ChatColor getColor(double... tps){
|
|
||||||
double s = TPS.getTPS();
|
|
||||||
if (tps.length>0){
|
|
||||||
s = tps[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s == 18.0) {
|
|
||||||
return ChatColor.GREEN;
|
|
||||||
} else if (s >= 15.0) {
|
|
||||||
return ChatColor.YELLOW;
|
|
||||||
} else {
|
|
||||||
return ChatColor.RED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static double getTPS(int ticks) {
|
|
||||||
try {
|
|
||||||
if (TICK_COUNT < ticks) {
|
|
||||||
return 20.0D;
|
|
||||||
}
|
|
||||||
int target = (TICK_COUNT - 1 - ticks) % TICKS.length;
|
|
||||||
long elapsed = System.currentTimeMillis() - TICKS[target];
|
|
||||||
|
|
||||||
return ticks / (elapsed / 1000.0D);
|
|
||||||
} catch (Exception ignored){
|
|
||||||
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static long getElapsed(int tickID) {
|
|
||||||
if (TICK_COUNT - tickID >= TICKS.length) {
|
|
||||||
}
|
|
||||||
|
|
||||||
long time = TICKS[(tickID % TICKS.length)];
|
|
||||||
return System.currentTimeMillis() - time;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
TICKS[(TICK_COUNT % TICKS.length)] = System.currentTimeMillis();
|
|
||||||
|
|
||||||
TICK_COUNT += 1;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,171 +0,0 @@
|
|||||||
package hu.ditservices.utils;
|
|
||||||
|
|
||||||
import hu.ditservices.STPlugin;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public class Version {
|
|
||||||
public enum ServerVersion {
|
|
||||||
v1_8_R1,
|
|
||||||
v1_8_R2,
|
|
||||||
v1_8_R3,
|
|
||||||
v1_9_R1,
|
|
||||||
v1_9_R2,
|
|
||||||
v1_10_R1,
|
|
||||||
v1_11_R1,
|
|
||||||
v1_12_R1,
|
|
||||||
v1_13_R1,
|
|
||||||
v1_13_R2,
|
|
||||||
v1_14_R1,
|
|
||||||
v1_14_R2,
|
|
||||||
v1_15_R1,
|
|
||||||
v1_15_R2,
|
|
||||||
v1_16_R1,
|
|
||||||
v1_16_R2,
|
|
||||||
v1_16_R3,
|
|
||||||
v1_17_R1,
|
|
||||||
v1_17_R2,
|
|
||||||
v1_18_R1,
|
|
||||||
v1_18_R2,
|
|
||||||
v1_19_R1,
|
|
||||||
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,
|
|
||||||
v1_21_5_R1;
|
|
||||||
|
|
||||||
private int value;
|
|
||||||
|
|
||||||
private static String[] arrayVersion;
|
|
||||||
private static ServerVersion current;
|
|
||||||
|
|
||||||
ServerVersion() {
|
|
||||||
value = Integer.valueOf(getNumberEscapeSequence().matcher(name()).replaceAll(""));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ServerVersion getCurrent() {
|
|
||||||
if (current != null)
|
|
||||||
return current;
|
|
||||||
|
|
||||||
String[] v = getArrayVersion();
|
|
||||||
String vv = v[v.length - 1];
|
|
||||||
for (ServerVersion one : values()) {
|
|
||||||
if (one.name().equalsIgnoreCase(vv)) {
|
|
||||||
current = one;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (current == null) {
|
|
||||||
current = ServerVersion.v1_16_R3;
|
|
||||||
}
|
|
||||||
|
|
||||||
return current;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*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 version = null;
|
|
||||||
try {
|
|
||||||
// Check if the Paper method getMinecraftVersion exists
|
|
||||||
Method minecraftVersionMethod = Bukkit.getServer().getClass().getMethod("getMinecraftVersion");
|
|
||||||
if (minecraftVersionMethod != null) {
|
|
||||||
version = (String) minecraftVersionMethod.invoke(Bukkit.getServer());
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
// The method doesn't exist in this server version; fall back below.
|
|
||||||
} catch (Exception e) {
|
|
||||||
STPlugin plugin = STPlugin.getInstance();
|
|
||||||
plugin.getLogger().warning(ChatColor.stripColor(plugin.getPrefix()) + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fallback: use Bukkit version if no version was obtained or it's empty.
|
|
||||||
if (version == null || version.trim().isEmpty()) {
|
|
||||||
version = Bukkit.getServer().getBukkitVersion();
|
|
||||||
// Remove any suffix (e.g., "-R0.1-SNAPSHOT") for consistency.
|
|
||||||
int dashIndex = version.indexOf('-');
|
|
||||||
if (dashIndex != -1) {
|
|
||||||
version = version.substring(0, dashIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Construct a legacy-style version string.
|
|
||||||
String legacyVersion = "v" + version.replace('.', '_') + "_R1";
|
|
||||||
arrayVersion = new String[] { legacyVersion };
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public static boolean isCurrentEqualOrHigher(ServerVersion v) {
|
|
||||||
return getCurrent().value >= v.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isCurrentHigher(ServerVersion v) {
|
|
||||||
return getCurrent().value > v.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isCurrentLower(ServerVersion v) {
|
|
||||||
return getCurrent().value < v.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isCurrentEqualOrLower(ServerVersion v) {
|
|
||||||
return getCurrent().value <= v.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isCurrentEqual(ServerVersion v) {
|
|
||||||
return getCurrent().value == v.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Pattern COMMA_SPACE_SEPARATED_PATTERN = Pattern.compile(", ");
|
|
||||||
private static final Pattern NUMBER_ESCAPE_SEQUENCE = Pattern.compile("[^\\d]");
|
|
||||||
|
|
||||||
public static Pattern getCommaSpaceSeparatedPattern() {
|
|
||||||
return COMMA_SPACE_SEPARATED_PATTERN;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Pattern getNumberEscapeSequence() {
|
|
||||||
return NUMBER_ESCAPE_SEQUENCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package hu.ditservices.utils;
|
package tk.ditservices;
|
||||||
|
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
@ -10,7 +10,7 @@ import java.util.Calendar;
|
|||||||
|
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
public class Logger implements Listener {
|
public class DITLog implements Listener {
|
||||||
public static String Location = "plugins/SimplifyTools/logs/";
|
public static String Location = "plugins/SimplifyTools/logs/";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,9 +34,9 @@ public class Logger implements Listener {
|
|||||||
* @param text The text to log.
|
* @param text The text to log.
|
||||||
*/
|
*/
|
||||||
public static void logLine(String text){
|
public static void logLine(String text){
|
||||||
String fileName = Logger.getDate()+".txt";
|
String fileName = DITLog.getDate()+".txt";
|
||||||
|
|
||||||
File file = new File(Logger.Location+fileName);
|
File file = new File(DITLog.Location+fileName);
|
||||||
if (!file.exists()){ createFile(); }
|
if (!file.exists()){ createFile(); }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -51,12 +51,12 @@ public class Logger implements Listener {
|
|||||||
|
|
||||||
private static void createFile(){
|
private static void createFile(){
|
||||||
String fileName = getDate() + ".txt";
|
String fileName = getDate() + ".txt";
|
||||||
File directory = new File(Logger.Location);
|
File directory = new File(DITLog.Location);
|
||||||
if(!directory.exists()){
|
if(!directory.exists()){
|
||||||
directory.mkdirs();
|
directory.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
File file = new File(Logger.Location + fileName);
|
File file = new File(DITLog.Location + fileName);
|
||||||
if( !file.exists() ){
|
if( !file.exists() ){
|
||||||
try {
|
try {
|
||||||
file.createNewFile();
|
file.createNewFile();
|
127
src/main/java/tk/ditservices/DITSystem.java
Normal file
127
src/main/java/tk/ditservices/DITSystem.java
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
package tk.ditservices;
|
||||||
|
|
||||||
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
|
import tk.ditservices.commands.DitCmd;
|
||||||
|
import tk.ditservices.listeners.ChatEvents;
|
||||||
|
import tk.ditservices.listeners.LogChat;
|
||||||
|
import tk.ditservices.listeners.LogCommand;
|
||||||
|
import tk.ditservices.listeners.LogConnect;
|
||||||
|
import tk.ditservices.utils.ConfigUpdater;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameRule;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.PluginCommand;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import tk.ditservices.utils.Math;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public final class DITSystem extends JavaPlugin implements CommandExecutor, Listener {
|
||||||
|
private static DITSystem instance;
|
||||||
|
Logger log = Bukkit.getLogger();
|
||||||
|
private DitPluginManager dplug;
|
||||||
|
public TabManager tab;
|
||||||
|
|
||||||
|
public FileConfiguration config;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
saveDefaultConfig();
|
||||||
|
instance = this;
|
||||||
|
this.DIT_initialize();
|
||||||
|
this.tab = new TabManager(this,this.config);
|
||||||
|
this.dplug = new DitPluginManager(this);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println(this.getPrefix()+"Started running.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DIT_initialize() {
|
||||||
|
if (this.Reload()){
|
||||||
|
initOptions();
|
||||||
|
|
||||||
|
PluginCommand ditCmd = this.getCommand("st");
|
||||||
|
ditCmd.setExecutor(new DitCmd(this));
|
||||||
|
ditCmd.setTabCompleter(new DITTabCompleter());
|
||||||
|
|
||||||
|
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);
|
||||||
|
getServer().getPluginManager().registerEvents(new ChatEvents(this), this);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public String getPrefix(){
|
||||||
|
if (this.config.isSet("Prefix")){
|
||||||
|
return ChatColor.translateAlternateColorCodes('&', this.config.getString("Prefix"));
|
||||||
|
}else{
|
||||||
|
return ChatColor.translateAlternateColorCodes('&',"&a[&fSimplify&7Tools&2] &4- &f");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static DITSystem getInstance(){
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
public void initOptions(){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (config.getBoolean("Saving.enabled") && config.getInt("Saving.interval")>0){
|
||||||
|
BukkitScheduler scheduler = getServer().getScheduler();
|
||||||
|
scheduler.scheduleSyncRepeatingTask(instance, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
String p = config.isSet("Saving.broadcastMsgProgress") ? config.getString("Saving.broadcastMsgProgress").replace("{PREFIX}",instance.getPrefix()) : instance.getPrefix()+"Auto save in progress..";
|
||||||
|
String d = config.isSet("Saving.broadcastMsgDone") ? config.getString("Saving.broadcastMsgDone").replace("{PREFIX}",instance.getPrefix()) : instance.getPrefix()+"Auto save done.";
|
||||||
|
Bukkit.broadcast(p,"st.st");
|
||||||
|
for(World w : Bukkit.getServer().getWorlds()){
|
||||||
|
w.save();
|
||||||
|
}
|
||||||
|
Bukkit.savePlayers();
|
||||||
|
Bukkit.broadcast(d,"st.st");
|
||||||
|
}
|
||||||
|
}, 0L, Math.convert(Math.Convert.SECONDS,Math.Convert.TICKS,instance.config.getInt("Saving.interval")));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (this.config.isSet("CustomAdvancement.enabled")) {
|
||||||
|
if(config.getBoolean("CustomAdvancement.enabled")){
|
||||||
|
|
||||||
|
List<World> worlds = getServer().getWorlds();
|
||||||
|
for (World w : worlds) {
|
||||||
|
if(w.getGameRuleValue(GameRule.ANNOUNCE_ADVANCEMENTS)) {
|
||||||
|
w.setGameRule(GameRule.ANNOUNCE_ADVANCEMENTS, false);
|
||||||
|
log.info(this.getPrefix()+"Disabling vanilla advancement messages for " + w.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public boolean Reload(){
|
||||||
|
File configFile = new File(getDataFolder(), "config.yml");
|
||||||
|
try {
|
||||||
|
ConfigUpdater.update(this, "config.yml", configFile, Collections.emptyList());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
reloadConfig();
|
||||||
|
this.config = getConfig();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
System.out.println(this.getPrefix()+" stopped.");
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
package hu.ditservices.handlers;
|
package tk.ditservices;
|
||||||
|
|
||||||
import hu.ditservices.STPlugin;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.*;
|
import org.bukkit.command.*;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@ -31,9 +30,12 @@ public class DITTabCompleter implements TabCompleter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
List<String> idea = new ArrayList<>();
|
List<String> idea = new ArrayList<>();
|
||||||
List<String> result = new ArrayList<>();
|
List<String> result = new ArrayList<>();
|
||||||
String curr_cmd = "";
|
String curr_cmd = "";
|
||||||
|
//String[] vizsg_args = new String[args.length+1];
|
||||||
List<String> vizsg_list = new ArrayList<>();
|
List<String> vizsg_list = new ArrayList<>();
|
||||||
boolean vizsg_2 = false;
|
boolean vizsg_2 = false;
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
@ -45,42 +47,40 @@ public class DITTabCompleter implements TabCompleter {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (args.length >= 2) {
|
if (args.length >= 2) {
|
||||||
for (String a : arguments) {
|
for (String a : arguments) {
|
||||||
vizsg_2 = false;
|
vizsg_2 = false;
|
||||||
if (a.contains(" ")){
|
if (a.contains(" ")){
|
||||||
vizsg_list = Arrays.asList(a.split(" "));
|
vizsg_list = Arrays.asList(a.split(" "));
|
||||||
vizsg_2 = true;
|
vizsg_2 = true;
|
||||||
}
|
}
|
||||||
if (vizsg_2 && args.length ==2){ // length-1
|
if (vizsg_2 && args.length ==2){ // length-1
|
||||||
idea.add(vizsg_list.get(1));
|
idea.add(vizsg_list.get(1));
|
||||||
}
|
}
|
||||||
if (vizsg_2&& args[1].startsWith(vizsg_list.get(1))) {
|
if (vizsg_2&& args[1].startsWith(vizsg_list.get(1))) {
|
||||||
idea.add(vizsg_list.get(1));
|
idea.add(vizsg_list.get(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("pmanager") && args[1].equalsIgnoreCase("unload") || args[1].equalsIgnoreCase("load")) {
|
if (args[0].equalsIgnoreCase("pmanager")&& args[1].equalsIgnoreCase("unload") || args[1].equalsIgnoreCase("load")) {
|
||||||
if ((args.length == 3) && STPlugin.getInstance().getConfig().getBoolean("PluginManager.enabled") &
|
if (args.length == 3) {
|
||||||
(commandSender.hasPermission("st.pmanager")
|
result.clear();
|
||||||
|| commandSender.hasPermission("st.pmanager.load")
|
PluginManager pm = Bukkit.getServer().getPluginManager();
|
||||||
|| commandSender.hasPermission("st.pmanager.unload"))
|
for (Plugin pl : pm.getPlugins()) {
|
||||||
) {
|
if (pl.getName().toLowerCase().startsWith(args[2].toLowerCase()) && args[1].equalsIgnoreCase("unload")) {
|
||||||
result.clear();
|
|
||||||
PluginManager pm = Bukkit.getServer().getPluginManager();
|
|
||||||
for (Plugin pl : pm.getPlugins()) {
|
|
||||||
if (pl.getName().toLowerCase().startsWith(args[2].toLowerCase()) && args[1].equalsIgnoreCase("unload")) {
|
|
||||||
result.add(pl.getName());
|
|
||||||
}
|
|
||||||
if (!pl.isEnabled()){
|
|
||||||
if (pl.getName().toLowerCase().startsWith(args[2].toLowerCase()) && args[1].equalsIgnoreCase("load")) {
|
|
||||||
result.add(pl.getName());
|
result.add(pl.getName());
|
||||||
}
|
}
|
||||||
|
if (!pl.isEnabled()){
|
||||||
|
if (pl.getName().toLowerCase().startsWith(args[2].toLowerCase()) && args[1].equalsIgnoreCase("load")) {
|
||||||
|
result.add(pl.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
return idea;
|
||||||
return idea;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
183
src/main/java/tk/ditservices/DitPluginManager.java
Normal file
183
src/main/java/tk/ditservices/DitPluginManager.java
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
package tk.ditservices;
|
||||||
|
import tk.ditservices.DITSystem;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.PluginCommand;
|
||||||
|
import org.bukkit.command.SimpleCommandMap;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.plugin.*;
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.*;
|
||||||
|
public class DitPluginManager {
|
||||||
|
private static DITSystem plugin;
|
||||||
|
public DitPluginManager(DITSystem instance){
|
||||||
|
plugin = instance;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Loads the requested plugin.
|
||||||
|
* @param pluginName Plugin name in string.
|
||||||
|
*/
|
||||||
|
public static int load(final String pluginName) {
|
||||||
|
PluginManager pm = Bukkit.getServer().getPluginManager();
|
||||||
|
boolean there = false;
|
||||||
|
for (Plugin pl : pm.getPlugins()){
|
||||||
|
if (pl.getName().toLowerCase().startsWith(pluginName)){
|
||||||
|
there = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (there)
|
||||||
|
{ return 1;} //plugin already exists
|
||||||
|
else {
|
||||||
|
String name = "";
|
||||||
|
String path = plugin.getDataFolder().getParent();
|
||||||
|
File folder = new File(path);
|
||||||
|
ArrayList<File> files = new ArrayList<File>();
|
||||||
|
File[] listOfFiles = folder.listFiles();
|
||||||
|
for (File compare : listOfFiles) {
|
||||||
|
if (compare.isFile()) {
|
||||||
|
try {
|
||||||
|
name = plugin.getPluginLoader().getPluginDescription(compare).getName();
|
||||||
|
} catch (InvalidDescriptionException e) {
|
||||||
|
plugin.getLogger().warning("[Loading Plugin] " + compare.getName() + " didn't match");
|
||||||
|
}
|
||||||
|
if (name.toLowerCase().startsWith(pluginName.toLowerCase())) {
|
||||||
|
files.add(compare);
|
||||||
|
try {
|
||||||
|
Bukkit.getServer().getPluginManager().loadPlugin(compare);
|
||||||
|
} catch (UnknownDependencyException e) {
|
||||||
|
return 2; //missing dependent plugin
|
||||||
|
} catch (InvalidPluginException e) {
|
||||||
|
return -1; //not a plugin
|
||||||
|
} catch (InvalidDescriptionException e) {
|
||||||
|
return 3; //invalid description
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Plugin[] plugins = pm.getPlugins();
|
||||||
|
for (Plugin pl : plugins) {
|
||||||
|
for (File compare : files) {
|
||||||
|
try {
|
||||||
|
if (pl.getName().equalsIgnoreCase(plugin.getPluginLoader().getPluginDescription(compare).getName()))
|
||||||
|
if (!pl.isEnabled()){
|
||||||
|
pm.enablePlugin(pl);
|
||||||
|
}else { return 5; }
|
||||||
|
} catch (InvalidDescriptionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0; //success
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static int unload(String pluginName) {
|
||||||
|
pluginName = pluginName.toLowerCase().trim();
|
||||||
|
PluginManager manager = Bukkit.getServer().getPluginManager();
|
||||||
|
SimplePluginManager spm = (SimplePluginManager) manager;
|
||||||
|
SimpleCommandMap commandMap = null;
|
||||||
|
List<Plugin> plugins = null;
|
||||||
|
Map<String, Plugin> lookupNames = null;
|
||||||
|
Map<String, Command> knownCommands = null;
|
||||||
|
Map<Event, SortedSet<RegisteredListener>> listeners = null;
|
||||||
|
boolean reloadlisteners = true;
|
||||||
|
try {
|
||||||
|
if (spm != null) {
|
||||||
|
Field pluginsField = spm.getClass().getDeclaredField("plugins");
|
||||||
|
pluginsField.setAccessible(true);
|
||||||
|
plugins = (List<Plugin>) pluginsField.get(spm);
|
||||||
|
|
||||||
|
Field lookupNamesField = spm.getClass().getDeclaredField("lookupNames");
|
||||||
|
lookupNamesField.setAccessible(true);
|
||||||
|
lookupNames = (Map<String, Plugin>) lookupNamesField.get(spm);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Field listenersField = spm.getClass().getDeclaredField("listeners");
|
||||||
|
listenersField.setAccessible(true);
|
||||||
|
listeners = (Map<Event, SortedSet<RegisteredListener>>) listenersField.get(spm);
|
||||||
|
} catch (Exception e) {
|
||||||
|
reloadlisteners = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Field commandMapField = spm.getClass().getDeclaredField("commandMap");
|
||||||
|
commandMapField.setAccessible(true);
|
||||||
|
commandMap = (SimpleCommandMap) commandMapField.get(spm);
|
||||||
|
|
||||||
|
Field knownCommandsField = commandMap.getClass().getDeclaredField("knownCommands");
|
||||||
|
knownCommandsField.setAccessible(true);
|
||||||
|
knownCommands = (Map<String, Command>) knownCommandsField.get(commandMap);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
boolean in = false;
|
||||||
|
|
||||||
|
for (Plugin pl : Bukkit.getServer().getPluginManager().getPlugins()) {
|
||||||
|
if (in)
|
||||||
|
break;
|
||||||
|
if (pl.getName().toLowerCase().startsWith(pluginName.toLowerCase())) {
|
||||||
|
if (pl.isEnabled()) {
|
||||||
|
manager.disablePlugin(pl);
|
||||||
|
if (plugins != null && plugins.contains(pl))
|
||||||
|
plugins.remove(pl);
|
||||||
|
|
||||||
|
if (lookupNames != null && lookupNames.containsKey(pl.getName())) {
|
||||||
|
lookupNames.remove(pl.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listeners != null && reloadlisteners) {
|
||||||
|
for (SortedSet<RegisteredListener> set : listeners.values()) {
|
||||||
|
for (Iterator<RegisteredListener> it = set.iterator(); it.hasNext(); ) {
|
||||||
|
RegisteredListener value = it.next();
|
||||||
|
|
||||||
|
if (value.getPlugin() == pl) {
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (commandMap != null) {
|
||||||
|
for (Iterator<Map.Entry<String, Command>> it = knownCommands.entrySet().iterator(); it.hasNext(); ) {
|
||||||
|
Map.Entry<String, Command> entry = it.next();
|
||||||
|
if (entry.getValue() instanceof PluginCommand) {
|
||||||
|
PluginCommand c = (PluginCommand) entry.getValue();
|
||||||
|
if (c.getPlugin() == pl) {
|
||||||
|
c.unregister(commandMap);
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Plugin plu : Bukkit.getServer().getPluginManager().getPlugins()) {
|
||||||
|
if (plu.getDescription().getDepend() != null) {
|
||||||
|
for (String depend : plu.getDescription().getDepend()) {
|
||||||
|
if (depend.equalsIgnoreCase(pl.getName())) {
|
||||||
|
plugin.getLogger().info("[Unloading Plugin] " + plu.getName() + " must be disabled!");
|
||||||
|
unload(plu.getName());
|
||||||
|
return 1; //dependencies also disabled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
in = true;
|
||||||
|
} else { return 5; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!in) {
|
||||||
|
plugin.getLogger().info("Not an existing plugin");
|
||||||
|
return -1; //non-existent
|
||||||
|
}
|
||||||
|
System.gc();
|
||||||
|
return 0; //success
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
207
src/main/java/tk/ditservices/TabManager.java
Normal file
207
src/main/java/tk/ditservices/TabManager.java
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
package tk.ditservices;
|
||||||
|
|
||||||
|
import tk.ditservices.utils.Math;
|
||||||
|
import tk.ditservices.utils.Server;
|
||||||
|
import net.minecraft.server.v1_16_R3.ChatComponentText;
|
||||||
|
import net.minecraft.server.v1_16_R3.IChatBaseComponent;
|
||||||
|
import net.minecraft.server.v1_16_R3.PacketPlayOutPlayerListHeaderFooter;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import javax.annotation.CheckForNull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.lang.reflect.Array;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TabManager {
|
||||||
|
private List<ChatComponentText> headers = new ArrayList<>();
|
||||||
|
private List<ChatComponentText> footers = new ArrayList<>();
|
||||||
|
|
||||||
|
private Integer refreshRate;
|
||||||
|
|
||||||
|
private DITSystem plugin;
|
||||||
|
private FileConfiguration config;
|
||||||
|
private List<String> headeranimList = new ArrayList<String>();
|
||||||
|
private List<String> footeranimList = new ArrayList<String>();
|
||||||
|
|
||||||
|
private ArrayList<String> formatArray = new ArrayList<>();
|
||||||
|
private List<Integer> DynamicHeaders = new ArrayList<>();
|
||||||
|
private List<Integer> DynamicFooters = new ArrayList<>();
|
||||||
|
|
||||||
|
private enum AddLine {
|
||||||
|
HEADER, FOOTER
|
||||||
|
}
|
||||||
|
|
||||||
|
public TabManager(DITSystem instance,FileConfiguration c){
|
||||||
|
|
||||||
|
this.plugin = instance;
|
||||||
|
this.config = c;
|
||||||
|
|
||||||
|
if(this.init()){
|
||||||
|
this.showTab();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showTab(){
|
||||||
|
if (headers.isEmpty() && footers.isEmpty()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||||
|
PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter();
|
||||||
|
int count1 = 0; //headers
|
||||||
|
int count2 = 0; //footers
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
//Tab code
|
||||||
|
Field a = packet.getClass().getDeclaredField("header");
|
||||||
|
a.setAccessible(true);
|
||||||
|
Field b = packet.getClass().getDeclaredField("footer");
|
||||||
|
b.setAccessible(true);
|
||||||
|
if (count1>=headers.size()){
|
||||||
|
count1=0;
|
||||||
|
}
|
||||||
|
if (count2>=footers.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.get(count1) == count1){
|
||||||
|
addHeaderFooter(AddLine.HEADER,headeranimList.get(count1),true,count1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (DynamicFooters.size()>0 && count2 < DynamicFooters.size()){
|
||||||
|
if (DynamicFooters.get(count2) == count2){
|
||||||
|
addHeaderFooter(AddLine.FOOTER,footeranimList.get(count2),true,count2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
a.set(packet, headers.get(count1));
|
||||||
|
b.set(packet,footers.get(count2));
|
||||||
|
|
||||||
|
if (Bukkit.getOnlinePlayers().size() !=0){
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()){
|
||||||
|
((CraftPlayer)player).getHandle().playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (headers.size()>1){
|
||||||
|
count1++;
|
||||||
|
}
|
||||||
|
if (footers.size()>1){
|
||||||
|
count2++;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},10, Math.convert(Math.Convert.SECONDS,Math.Convert.TICKS,this.refreshRate));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean init(){
|
||||||
|
if (config.getBoolean("Tab.enabled")){
|
||||||
|
if (config.isSet("Tab.refreshRate")){
|
||||||
|
this.refreshRate = config.getInt("Tab.refreshRate");
|
||||||
|
}else{
|
||||||
|
this.refreshRate=40;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Getting the tab lines from the config
|
||||||
|
headeranimList = config.getStringList("Tab.headerAnimation");
|
||||||
|
footeranimList = config.getStringList("Tab.footerAnimation");
|
||||||
|
|
||||||
|
//Investigating lines where we need to run the formatting every tab refresh for example for the RAM usage.
|
||||||
|
//Only storing those lines indexes.
|
||||||
|
formatArray.add("{TOTALRAM}");
|
||||||
|
formatArray.add("{FREERAM}");
|
||||||
|
formatArray.add("{USEDRAM}");
|
||||||
|
formatArray.add("{AVERAGEPING}");
|
||||||
|
formatArray.add("{ONLINEPLAYERS}");
|
||||||
|
formatArray.add("{MAXPLAYERS}");
|
||||||
|
for (String f: formatArray){
|
||||||
|
for (int i = 0; i<headeranimList.size(); i++){
|
||||||
|
if (headeranimList.get(i).contains(f) && !DynamicHeaders.contains(i)){
|
||||||
|
DynamicHeaders.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i<footeranimList.size(); i++){
|
||||||
|
if (footeranimList.get(i).contains(f) && !DynamicFooters.contains(i)){
|
||||||
|
DynamicFooters.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String hanim : headeranimList){
|
||||||
|
this.addHeaderFooter(AddLine.HEADER,hanim,false);
|
||||||
|
}
|
||||||
|
for (String fanim : footeranimList){
|
||||||
|
this.addHeaderFooter(AddLine.FOOTER,fanim,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manages the adding of the tab line and the final formatting of the text.
|
||||||
|
* @param head_or_footer AddLine Enum value to choose where to add a tab line.
|
||||||
|
* @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 index Index of the 'dynamic' line. This is an overloading so there we need the index[0] element.
|
||||||
|
*/
|
||||||
|
public void addHeaderFooter(AddLine head_or_footer,String text,boolean dynamic,int... index){
|
||||||
|
IChatBaseComponent tabText = IChatBaseComponent.ChatSerializer.a("{\"text\":\"" + format(text) +"\"}");
|
||||||
|
if (head_or_footer==AddLine.HEADER){
|
||||||
|
if (dynamic){
|
||||||
|
headers.set(index[0],new ChatComponentText(tabText.getString()));
|
||||||
|
}else {
|
||||||
|
headers.add(new ChatComponentText(tabText.getString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
if (head_or_footer==AddLine.FOOTER){
|
||||||
|
if (dynamic){
|
||||||
|
footers.set(index[0],new ChatComponentText(tabText.getString()));
|
||||||
|
}else {
|
||||||
|
footers.add(new ChatComponentText(tabText.getString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the msg values to their represents and recognizes MC color codes.
|
||||||
|
* @param msg The text.
|
||||||
|
* @return Replaced text with recognized MC color codes.
|
||||||
|
*/
|
||||||
|
private String format(String msg){
|
||||||
|
if (msg.contains("{TOTALRAM}")){
|
||||||
|
msg = msg.replace("{TOTALRAM}",String.valueOf(Server.getRAM(Server.RAM.TOTAL)));
|
||||||
|
}
|
||||||
|
if (msg.contains("{FREERAM}")){
|
||||||
|
msg = msg.replace("{FREERAM}",String.valueOf(Server.getRAM(Server.RAM.FREE)));
|
||||||
|
}
|
||||||
|
if (msg.contains("{USEDRAM}")){
|
||||||
|
msg = msg.replace("{USEDRAM}",String.valueOf(Server.getRAM(Server.RAM.USED)));
|
||||||
|
}
|
||||||
|
if (msg.contains("{AVERAGEPING}")){
|
||||||
|
msg = msg.replace("{AVERAGEPING}",String.valueOf(Server.getAveragePing()));
|
||||||
|
}
|
||||||
|
if (msg.contains("{ONLINEPLAYERS}")){
|
||||||
|
msg = msg.replace("{ONLINEPLAYERS}",String.valueOf(plugin.getServer().getOnlinePlayers().size()));
|
||||||
|
}
|
||||||
|
if (msg.contains("{MAXPLAYERS}")){
|
||||||
|
msg = msg.replace("{MAXPLAYERS}",String.valueOf(plugin.getServer().getMaxPlayers()));
|
||||||
|
}
|
||||||
|
return ChatColor.translateAlternateColorCodes('&', msg);
|
||||||
|
}
|
||||||
|
}
|
149
src/main/java/tk/ditservices/commands/DitCmd.java
Normal file
149
src/main/java/tk/ditservices/commands/DitCmd.java
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
package tk.ditservices.commands;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import tk.ditservices.DITSystem;
|
||||||
|
|
||||||
|
import tk.ditservices.utils.Cooldown;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.*;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
public class DitCmd implements CommandExecutor {
|
||||||
|
String noArgMsg;
|
||||||
|
DITSystem plugin;
|
||||||
|
Cooldown cd;
|
||||||
|
FileConfiguration config;
|
||||||
|
public DitCmd(DITSystem 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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)
|
||||||
|
{
|
||||||
|
if (sender instanceof Player)
|
||||||
|
{
|
||||||
|
Player p = (Player) sender;
|
||||||
|
p.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Version: "+plugin.getDescription().getVersion());
|
||||||
|
p.sendMessage(this.noArgMsg);
|
||||||
|
cd.Add(p);
|
||||||
|
return true;
|
||||||
|
}else {
|
||||||
|
if (sender instanceof ConsoleCommandSender){
|
||||||
|
sender.sendMessage(this.noArgMsg);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (command.getName().equals("st") && args[0].contains("help"))
|
||||||
|
{
|
||||||
|
if (sender instanceof Player)
|
||||||
|
{
|
||||||
|
Player p = (Player) sender;
|
||||||
|
cd.Add(p);
|
||||||
|
p.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Version: "+plugin.getDescription().getVersion());
|
||||||
|
p.sendMessage(this.noArgMsg);
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
|
ConsoleCommandSender konzoladmin = (ConsoleCommandSender) sender;
|
||||||
|
konzoladmin.sendMessage(this.noArgMsg);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (command.getName().equals("st") && args[0].contains("reload") && sender.hasPermission("st.reload")){
|
||||||
|
|
||||||
|
if(plugin.Reload()){
|
||||||
|
if (sender instanceof Player){
|
||||||
|
Player p = (Player) sender;
|
||||||
|
cd.Add(p);
|
||||||
|
}
|
||||||
|
sender.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Successfully reload!");
|
||||||
|
}
|
||||||
|
//sender.sendMessage(plugin.getPrefix()+ChatColor.RED+" Ezt a verziót a "+ChatColor.YELLOW+"'/reload confirm'"+ChatColor.RED+" parancssal tudod csak újratölteni!");
|
||||||
|
}
|
||||||
|
|
||||||
|
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 (sender instanceof Player){
|
||||||
|
Player p = (Player) sender;
|
||||||
|
cd.Add(p);
|
||||||
|
}
|
||||||
|
if (args.length==1){
|
||||||
|
String msg = plugin.getPrefix()+ChatColor.DARK_RED+"Invalid command!";
|
||||||
|
if (sender instanceof Player){
|
||||||
|
Player p = (Player) sender;
|
||||||
|
p.sendMessage(msg);
|
||||||
|
}else{
|
||||||
|
ConsoleCommandSender c = (ConsoleCommandSender) sender;
|
||||||
|
c.sendMessage(msg);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[1].equalsIgnoreCase("load")) {
|
||||||
|
PluginCmd.handleLoad(sender,args);
|
||||||
|
}
|
||||||
|
if (args[1].equalsIgnoreCase("unload")) {
|
||||||
|
PluginCmd.handleUnload(sender,args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (command.getName().equalsIgnoreCase("st") && args[0].contains("save-all") && sender.hasPermission("st.save")){
|
||||||
|
if (sender instanceof Player){
|
||||||
|
Player p = (Player) sender;
|
||||||
|
cd.Add(p);
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (command.getName().equalsIgnoreCase("st") && args[0].contains("ping") && sender.hasPermission("st.ping")){
|
||||||
|
if (sender instanceof Player){
|
||||||
|
Player p = (Player) sender;
|
||||||
|
cd.Add(p);
|
||||||
|
} return PingCmd.Run(sender);
|
||||||
|
}
|
||||||
|
if (command.getName().equalsIgnoreCase("st") && args[0].contains("stats") && sender.hasPermission("st.stats")){
|
||||||
|
if (sender instanceof Player){
|
||||||
|
Player p = (Player) sender;
|
||||||
|
cd.Add(p);
|
||||||
|
} return StatCmd.Run(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
cd.CDText(sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
32
src/main/java/tk/ditservices/commands/PingCmd.java
Normal file
32
src/main/java/tk/ditservices/commands/PingCmd.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package tk.ditservices.commands;
|
||||||
|
|
||||||
|
import tk.ditservices.DITSystem;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
|
public class PingCmd {
|
||||||
|
public static boolean Run(CommandSender sender) {
|
||||||
|
DITSystem plugin = DITSystem.getInstance();
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
try {
|
||||||
|
Object entityPlayer = player.getClass().getMethod("getHandle").invoke(player);
|
||||||
|
int ping = (int) entityPlayer.getClass().getField("ping").get(entityPlayer);
|
||||||
|
player.sendMessage(plugin.getPrefix() + "Your response time to the server: " + ping + " ms");
|
||||||
|
return true;
|
||||||
|
} catch (IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | NoSuchFieldException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
|
ConsoleCommandSender konzoladmin = (ConsoleCommandSender) sender;
|
||||||
|
konzoladmin.sendMessage(plugin.getPrefix() + "For this command you have to be a player!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
30
src/main/java/tk/ditservices/commands/PluginCmd.java
Normal file
30
src/main/java/tk/ditservices/commands/PluginCmd.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package tk.ditservices.commands;
|
||||||
|
|
||||||
|
import tk.ditservices.DITSystem;
|
||||||
|
import tk.ditservices.DitPluginManager;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
|
||||||
|
public class PluginCmd {
|
||||||
|
public static boolean handleLoad(CommandSender sender, String[] args){
|
||||||
|
switch (DitPluginManager.load(args[2])){
|
||||||
|
case 0: sender.sendMessage(DITSystem.getInstance().getPrefix()+" Plugin loaded."); return true;
|
||||||
|
case 2: sender.sendMessage(DITSystem.getInstance().getPrefix()+"Missing dependency!"); return true;
|
||||||
|
case -1: sender.sendMessage(DITSystem.getInstance().getPrefix()+"Invalid/ not exist plugin!"); return true;
|
||||||
|
case 3: sender.sendMessage(DITSystem.getInstance().getPrefix()+"Invalid description!"); return true;
|
||||||
|
case 5: sender.sendMessage(DITSystem.getInstance().getPrefix()+"This plugin is already running!"); return true;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public static boolean handleUnload(CommandSender sender, String[] args){
|
||||||
|
switch (DitPluginManager.unload(args[2])){
|
||||||
|
case 0: sender.sendMessage(DITSystem.getInstance().getPrefix()+" Plugin disabled."); return true;
|
||||||
|
case -1: sender.sendMessage(DITSystem.getInstance().getPrefix()+"This plugin is not exist."); return true;
|
||||||
|
case 1: sender.sendMessage(DITSystem.getInstance().getPrefix()+"Plugin and their dependents disabled."); return true;
|
||||||
|
case 5: sender.sendMessage(DITSystem.getInstance().getPrefix()+"This plugin is not loaded."); return true;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
23
src/main/java/tk/ditservices/commands/StatCmd.java
Normal file
23
src/main/java/tk/ditservices/commands/StatCmd.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package tk.ditservices.commands;
|
||||||
|
|
||||||
|
import tk.ditservices.DITSystem;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Statistic;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class StatCmd {
|
||||||
|
public static boolean Run(CommandSender sender){
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
player.sendMessage(DITSystem.getInstance().getPrefix()+ ChatColor.GREEN+" === Your statistics === ");
|
||||||
|
player.sendMessage(ChatColor.AQUA+"Connects: "+(player.getStatistic(Statistic.LEAVE_GAME)+1));
|
||||||
|
player.sendMessage(ChatColor.AQUA+"Deaths: "+player.getStatistic(Statistic.DEATHS));
|
||||||
|
player.sendMessage(ChatColor.AQUA+"Mob kills: "+player.getStatistic(Statistic.MOB_KILLS));
|
||||||
|
player.sendMessage(ChatColor.AQUA+"Player kills: "+player.getStatistic(Statistic.PLAYER_KILLS));
|
||||||
|
player.sendMessage(ChatColor.AQUA+"Sleep count: "+player.getStatistic(Statistic.SLEEP_IN_BED));
|
||||||
|
player.sendMessage(ChatColor.AQUA+"Enchant count: "+player.getStatistic(Statistic.ITEM_ENCHANTED));
|
||||||
|
player.sendMessage(ChatColor.GREEN+" =================== ");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package hu.ditservices.listeners;
|
package tk.ditservices.listeners;
|
||||||
|
|
||||||
import hu.ditservices.STPlugin;
|
import tk.ditservices.DITSystem;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
@ -9,26 +9,26 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerAdvancementDoneEvent;
|
import org.bukkit.event.player.PlayerAdvancementDoneEvent;
|
||||||
import hu.ditservices.utils.AdvancementHelper;
|
import tk.ditservices.utils.AdvancementHelper;
|
||||||
|
|
||||||
public class ChatEvents implements Listener {
|
public class ChatEvents implements Listener {
|
||||||
private STPlugin plugin;
|
private DITSystem plugin;
|
||||||
private FileConfiguration config;
|
private FileConfiguration config;
|
||||||
|
public ChatEvents(DITSystem instance){
|
||||||
public ChatEvents(STPlugin instance){
|
|
||||||
this.plugin = instance;
|
this.plugin = instance;
|
||||||
this.config = plugin.getConfig();
|
this.config = plugin.config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onAdvance(PlayerAdvancementDoneEvent e){
|
public void onAdvance(PlayerAdvancementDoneEvent e){
|
||||||
if (config.isSet("CustomAdvancement.enabled") && config.getBoolean("CustomAdvancement.enabled")){
|
if (config.isSet("CustomAdvancement.enabled")){
|
||||||
AdvancementHelper helper = new AdvancementHelper(this.config);
|
if (config.getBoolean("CustomAdvancement.enabled")){
|
||||||
|
AdvancementHelper helper = new AdvancementHelper(plugin,this.config);
|
||||||
if(helper.check(e.getAdvancement().getKey().getKey())) {
|
if(helper.check(e.getAdvancement().getKey().getKey())) {
|
||||||
final Player player = e.getPlayer();
|
final Player player = e.getPlayer();
|
||||||
String title = helper.find(e.getAdvancement().getKey().getKey());
|
String title = helper.find(e.getAdvancement().getKey().getKey());
|
||||||
Bukkit.broadcastMessage(plugin.getPrefix()+ChatColor.translateAlternateColorCodes('&', helper.getText(player.getName(),title)));
|
Bukkit.broadcastMessage(plugin.getPrefix()+ChatColor.translateAlternateColorCodes('&', helper.getText(player.getName(),title)));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package hu.ditservices.listeners;
|
package tk.ditservices.listeners;
|
||||||
|
|
||||||
import hu.ditservices.utils.Logger;
|
import tk.ditservices.DITLog;
|
||||||
import hu.ditservices.STPlugin;
|
import tk.ditservices.DITSystem;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -11,19 +11,19 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
public class LogChat implements Listener {
|
public class LogChat implements Listener {
|
||||||
STPlugin plugin;
|
DITSystem plugin;
|
||||||
FileConfiguration config;
|
FileConfiguration config;
|
||||||
public LogChat(STPlugin instance){
|
public LogChat(DITSystem instance){
|
||||||
this.plugin = instance;
|
this.plugin = instance;
|
||||||
this.config = plugin.getConfig();
|
this.config = plugin.config;
|
||||||
}
|
}
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onChat(AsyncPlayerChatEvent event){
|
public void onChat(AsyncPlayerChatEvent event){
|
||||||
if (config.getBoolean("Log.Chat")) {
|
if (config.getBoolean("Log.Chat")) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String format = config.isSet("Log.FormatChat") ? config.getString("Log.FormatChat") : "[{DATE}] - {TIME} - {ACTION} - {PLAYERNAME}: {MSG}";
|
String format = config.isSet("Log.FormatChat") ? config.getString("Log.FormatChat") : "[{DATE}] - {TIME} - {ACTION} - {PLAYERNAME}: {MSG}";
|
||||||
String LogMsg = format.replace("{DATE}", Logger.getDate()).replace("{TIME}", Logger.getTime()).replace("{PLAYERNAME}",player.getDisplayName()).replace("{MSG}",event.getMessage()).replace("{ACTION}","[CHAT]");
|
String LogMsg = format.replace("{DATE}",DITLog.getDate()).replace("{TIME}",DITLog.getTime()).replace("{PLAYERNAME}",player.getDisplayName()).replace("{MSG}",event.getMessage()).replace("{ACTION}","[CHAT]");
|
||||||
Logger.logLine(ChatColor.stripColor(LogMsg));
|
DITLog.logLine(ChatColor.stripColor(LogMsg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package hu.ditservices.listeners;
|
package tk.ditservices.listeners;
|
||||||
|
|
||||||
import hu.ditservices.utils.Logger;
|
import tk.ditservices.DITLog;
|
||||||
import hu.ditservices.STPlugin;
|
import tk.ditservices.DITSystem;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -11,20 +11,20 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
public class LogCommand implements Listener {
|
public class LogCommand implements Listener {
|
||||||
STPlugin plugin;
|
DITSystem plugin;
|
||||||
FileConfiguration config;
|
FileConfiguration config;
|
||||||
public LogCommand(STPlugin instance){
|
public LogCommand(DITSystem instance){
|
||||||
|
|
||||||
this.plugin = instance;
|
this.plugin = instance;
|
||||||
this.config = plugin.getConfig();
|
this.config = plugin.config;
|
||||||
}
|
}
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onCommand(PlayerCommandPreprocessEvent event){
|
public void onCommand(PlayerCommandPreprocessEvent event){
|
||||||
if (config.getBoolean("Log.Command")) {
|
if (config.getBoolean("Log.Command")) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String format = config.isSet("Log.FormatCommand") ? config.getString("Log.FormatCommand") : "[{DATE}] - {TIME} - {ACTION} - {PLAYERNAME}: {COMMAND}";
|
String format = config.isSet("Log.FormatCommand") ? config.getString("Log.FormatCommand") : "[{DATE}] - {TIME} - {ACTION} - {PLAYERNAME}: {COMMAND}";
|
||||||
String LogMsg = format.replace("{DATE}", Logger.getDate()).replace("{TIME}", Logger.getTime()).replace("{PLAYERNAME}",player.getDisplayName()).replace("{COMMAND}",event.getMessage()).replace("{ACTION}","[COMMAND]");
|
String LogMsg = format.replace("{DATE}",DITLog.getDate()).replace("{TIME}",DITLog.getTime()).replace("{PLAYERNAME}",player.getDisplayName()).replace("{COMMAND}",event.getMessage()).replace("{ACTION}","[COMMAND]");
|
||||||
Logger.logLine(ChatColor.stripColor(LogMsg));
|
DITLog.logLine(ChatColor.stripColor(LogMsg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package hu.ditservices.listeners;
|
package tk.ditservices.listeners;
|
||||||
|
|
||||||
import hu.ditservices.utils.Logger;
|
import tk.ditservices.DITLog;
|
||||||
import hu.ditservices.STPlugin;
|
import tk.ditservices.DITSystem;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
@ -13,16 +13,16 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
public class LogConnect implements Listener {
|
public class LogConnect implements Listener {
|
||||||
STPlugin plugin;
|
DITSystem plugin;
|
||||||
private String JoinMsg;
|
private String JoinMsg;
|
||||||
private String LeaveMsg;
|
private String LeaveMsg;
|
||||||
FileConfiguration config;
|
FileConfiguration config;
|
||||||
public LogConnect(STPlugin instance){
|
public LogConnect(DITSystem instance){
|
||||||
this.plugin = instance;
|
this.plugin = instance;
|
||||||
this.config = plugin.getConfig();
|
this.config = plugin.config;
|
||||||
if (config.getBoolean("CustomMsg.enabled")) {
|
if (config.getBoolean("CustomMsg.enabled")){
|
||||||
this.JoinMsg = this.config.isSet("CustomMsg.connect") ? this.config.getString("CustomMsg.connect") : "{PREFIX}{NAME} &aconnected to the server.";
|
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} left the game.";
|
this.LeaveMsg = this.config.isSet("CustomMsg.connect") ? this.config.getString("CustomMsg.disconnect") : "{PREFIX}{NAME} leaved the game.";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -39,8 +39,8 @@ public class LogConnect implements Listener {
|
|||||||
|
|
||||||
if (config.getBoolean("Log.Connect")) {
|
if (config.getBoolean("Log.Connect")) {
|
||||||
String format = config.isSet("Log.FormatConnect") ? config.getString("Log.FormatConnect") : "[{DATE}] - {TIME} - {ACTION} - {PLAYERNAME} UUID: {UUID}";
|
String format = config.isSet("Log.FormatConnect") ? config.getString("Log.FormatConnect") : "[{DATE}] - {TIME} - {ACTION} - {PLAYERNAME} UUID: {UUID}";
|
||||||
String LogMsg = format.replace("{DATE}", Logger.getDate()).replace("{TIME}", Logger.getTime()).replace("{PLAYERNAME}",player.getDisplayName()).replace("{UUID}",player.getUniqueId().toString()).replace("{ACTION}","[CONNECT]");
|
String LogMsg = format.replace("{DATE}",DITLog.getDate()).replace("{TIME}",DITLog.getTime()).replace("{PLAYERNAME}",player.getDisplayName()).replace("{UUID}",player.getUniqueId().toString()).replace("{ACTION}","[CONNECT]");
|
||||||
Logger.logLine(ChatColor.stripColor(LogMsg));
|
DITLog.logLine(ChatColor.stripColor(LogMsg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
@ -55,8 +55,8 @@ public class LogConnect implements Listener {
|
|||||||
}
|
}
|
||||||
if (config.getBoolean("Log.Connect")) {
|
if (config.getBoolean("Log.Connect")) {
|
||||||
String format = config.isSet("Log.FormatConnect") ? config.getString("Log.FormatConnect") : "[{DATE}] - {TIME} - {ACTION} - {PLAYERNAME} UUID: {UUID}";
|
String format = config.isSet("Log.FormatConnect") ? config.getString("Log.FormatConnect") : "[{DATE}] - {TIME} - {ACTION} - {PLAYERNAME} UUID: {UUID}";
|
||||||
String LogMsg = format.replace("{DATE}", Logger.getDate()).replace("{TIME}", Logger.getTime()).replace("{PLAYERNAME}",player.getDisplayName()).replace("{UUID}",player.getUniqueId().toString()).replace("{ACTION}","[DISCONNECT]");
|
String LogMsg = format.replace("{DATE}",DITLog.getDate()).replace("{TIME}",DITLog.getTime()).replace("{PLAYERNAME}",player.getDisplayName()).replace("{UUID}",player.getUniqueId().toString()).replace("{ACTION}","[DISCONNECT]");
|
||||||
Logger.logLine(ChatColor.stripColor(LogMsg));
|
DITLog.logLine(ChatColor.stripColor(LogMsg));
|
||||||
}
|
}
|
||||||
if (config.getBoolean("Saving.enabled")){
|
if (config.getBoolean("Saving.enabled")){
|
||||||
if(config.getBoolean("Saving.onDisconnect")){
|
if(config.getBoolean("Saving.onDisconnect")){
|
@ -1,21 +1,14 @@
|
|||||||
package hu.ditservices.utils;
|
package tk.ditservices.utils;
|
||||||
|
|
||||||
import hu.ditservices.STPlugin;
|
import tk.ditservices.DITLog;
|
||||||
import org.bukkit.ChatColor;
|
import tk.ditservices.DITSystem;
|
||||||
import org.bukkit.GameRule;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class AdvancementHelper {
|
public class AdvancementHelper {
|
||||||
private final STPlugin plugin = STPlugin.getInstance();
|
private DITSystem plugin;
|
||||||
private final FileConfiguration config;
|
private FileConfiguration config;
|
||||||
|
public AdvancementHelper(DITSystem instance, FileConfiguration c){
|
||||||
private boolean initialized = false;
|
this.plugin = instance;
|
||||||
|
|
||||||
public AdvancementHelper(FileConfiguration c){
|
|
||||||
this.config = c;
|
this.config = c;
|
||||||
this.initialize();
|
this.initialize();
|
||||||
}
|
}
|
||||||
@ -106,7 +99,6 @@ public class AdvancementHelper {
|
|||||||
public String[] out_type = new String[3];
|
public String[] out_type = new String[3];
|
||||||
|
|
||||||
private void initialize(){
|
private void initialize(){
|
||||||
|
|
||||||
if (config.isSet("CustomAdvancement.formats.advancement")) {
|
if (config.isSet("CustomAdvancement.formats.advancement")) {
|
||||||
out_type[0] = config.getString("CustomAdvancement.formats.advancement");
|
out_type[0] = config.getString("CustomAdvancement.formats.advancement");
|
||||||
}
|
}
|
||||||
@ -117,33 +109,6 @@ public class AdvancementHelper {
|
|||||||
out_type[2] = config.getString("CustomAdvancement.formats.challenge");
|
out_type[2] = config.getString("CustomAdvancement.formats.challenge");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
String disableMsg = ChatColor.stripColor(plugin.getPrefix()) + "Disabling vanilla advancement messages for ";
|
|
||||||
List<World> worlds = this.plugin.getServer().getWorlds();
|
|
||||||
Method setRuleMethod, getRuleMethod;
|
|
||||||
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
}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());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
//w.setGameRule(GameRule.ANNOUNCE_ADVANCEMENTS, false);
|
|
||||||
}
|
|
||||||
} catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public String getText(String PlayerName,String title){
|
public String getText(String PlayerName,String title){
|
||||||
String rtrn = this.out_type[this.type];
|
String rtrn = this.out_type[this.type];
|
320
src/main/java/tk/ditservices/utils/ConfigUpdater.java
Normal file
320
src/main/java/tk/ditservices/utils/ConfigUpdater.java
Normal file
@ -0,0 +1,320 @@
|
|||||||
|
/**
|
||||||
|
* Github repo: https://github.com/tchristofferson/Config-Updater
|
||||||
|
*/
|
||||||
|
package tk.ditservices.utils;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class to update/add new sections/keys to your config while keeping your current values and keeping your comments
|
||||||
|
* Algorithm:
|
||||||
|
* Read the new file and scan for comments and ignored sections, if ignored section is found it is treated as a comment.
|
||||||
|
* Read and write each line of the new config, if the old config has value for the given key it writes that value in the new config.
|
||||||
|
* If a key has an attached comment above it, it is written first.
|
||||||
|
* @author tchristofferson
|
||||||
|
*/
|
||||||
|
public class ConfigUpdater {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a yaml file from a resource inside your plugin jar
|
||||||
|
* @param plugin You plugin
|
||||||
|
* @param resourceName The yaml file name to update from, typically config.yml
|
||||||
|
* @param toUpdate The yaml file to update
|
||||||
|
* @param ignoredSections List of sections to ignore and copy from the current config
|
||||||
|
* @throws IOException If an IOException occurs
|
||||||
|
*/
|
||||||
|
public static void update(Plugin plugin, String resourceName, File toUpdate, List<String> ignoredSections) throws IOException {
|
||||||
|
BufferedReader newReader = new BufferedReader(new InputStreamReader(plugin.getResource(resourceName), StandardCharsets.UTF_8));
|
||||||
|
List<String> newLines = newReader.lines().collect(Collectors.toList());
|
||||||
|
newReader.close();
|
||||||
|
|
||||||
|
FileConfiguration oldConfig = YamlConfiguration.loadConfiguration(toUpdate);
|
||||||
|
FileConfiguration newConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(plugin.getResource(resourceName), StandardCharsets.UTF_8));
|
||||||
|
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(toUpdate), StandardCharsets.UTF_8));
|
||||||
|
|
||||||
|
List<String> ignoredSectionsArrayList = new ArrayList<>(ignoredSections);
|
||||||
|
//ignoredSections can ONLY contain configurations sections
|
||||||
|
ignoredSectionsArrayList.removeIf(ignoredSection -> !newConfig.isConfigurationSection(ignoredSection));
|
||||||
|
|
||||||
|
Yaml yaml = new Yaml();
|
||||||
|
Map<String, String> comments = parseComments(newLines, ignoredSectionsArrayList, oldConfig, yaml);
|
||||||
|
write(newConfig, oldConfig, comments, ignoredSectionsArrayList, writer, yaml);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Write method doing the work.
|
||||||
|
//It checks if key has a comment associated with it and writes comment then the key and value
|
||||||
|
private static void write(FileConfiguration newConfig, FileConfiguration oldConfig, Map<String, String> comments, List<String> ignoredSections, BufferedWriter writer, Yaml yaml) throws IOException {
|
||||||
|
outer: for (String key : newConfig.getKeys(true)) {
|
||||||
|
String[] keys = key.split("\\.");
|
||||||
|
String actualKey = keys[keys.length - 1];
|
||||||
|
String comment = comments.remove(key);
|
||||||
|
|
||||||
|
StringBuilder prefixBuilder = new StringBuilder();
|
||||||
|
int indents = keys.length - 1;
|
||||||
|
appendPrefixSpaces(prefixBuilder, indents);
|
||||||
|
String prefixSpaces = prefixBuilder.toString();
|
||||||
|
|
||||||
|
if (comment != null) {
|
||||||
|
writer.write(comment);//No \n character necessary, new line is automatically at end of comment
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String ignoredSection : ignoredSections) {
|
||||||
|
if (key.startsWith(ignoredSection)) {
|
||||||
|
continue outer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Object newObj = newConfig.get(key);
|
||||||
|
Object oldObj = oldConfig.get(key);
|
||||||
|
|
||||||
|
if (newObj instanceof ConfigurationSection && oldObj instanceof ConfigurationSection) {
|
||||||
|
//write the old section
|
||||||
|
writeSection(writer, actualKey, prefixSpaces, (ConfigurationSection) oldObj);
|
||||||
|
} else if (newObj instanceof ConfigurationSection) {
|
||||||
|
//write the new section, old value is no more
|
||||||
|
writeSection(writer, actualKey, prefixSpaces, (ConfigurationSection) newObj);
|
||||||
|
} else if (oldObj != null) {
|
||||||
|
//write the old object
|
||||||
|
write(oldObj, actualKey, prefixSpaces, yaml, writer);
|
||||||
|
} else {
|
||||||
|
//write new object
|
||||||
|
write(newObj, actualKey, prefixSpaces, yaml, writer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String danglingComments = comments.get(null);
|
||||||
|
|
||||||
|
if (danglingComments != null) {
|
||||||
|
writer.write(danglingComments);
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Doesn't work with configuration sections, must be an actual object
|
||||||
|
//Auto checks if it is serializable and writes to file
|
||||||
|
private static void write(Object obj, String actualKey, String prefixSpaces, Yaml yaml, BufferedWriter writer) throws IOException {
|
||||||
|
if (obj instanceof ConfigurationSerializable) {
|
||||||
|
writer.write(prefixSpaces + actualKey + ": " + yaml.dump(((ConfigurationSerializable) obj).serialize()));
|
||||||
|
} else if (obj instanceof String || obj instanceof Character) {
|
||||||
|
if (obj instanceof String) {
|
||||||
|
String s = (String) obj;
|
||||||
|
obj = s.replace("\n", "\\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.write(prefixSpaces + actualKey + ": " + yaml.dump(obj));
|
||||||
|
} else if (obj instanceof List) {
|
||||||
|
writeList((List) obj, actualKey, prefixSpaces, yaml, writer);
|
||||||
|
} else {
|
||||||
|
writer.write(prefixSpaces + actualKey + ": " + yaml.dump(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Writes a configuration section
|
||||||
|
private static void writeSection(BufferedWriter writer, String actualKey, String prefixSpaces, ConfigurationSection section) throws IOException {
|
||||||
|
if (section.getKeys(false).isEmpty()) {
|
||||||
|
writer.write(prefixSpaces + actualKey + ": {}");
|
||||||
|
} else {
|
||||||
|
writer.write(prefixSpaces + actualKey + ":");
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.write("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Writes a list of any object
|
||||||
|
private static void writeList(List list, String actualKey, String prefixSpaces, Yaml yaml, BufferedWriter writer) throws IOException {
|
||||||
|
writer.write(getListAsString(list, actualKey, prefixSpaces, yaml));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getListAsString(List list, String actualKey, String prefixSpaces, Yaml yaml) {
|
||||||
|
StringBuilder builder = new StringBuilder(prefixSpaces).append(actualKey).append(":");
|
||||||
|
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
builder.append(" []\n");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.append("\n");
|
||||||
|
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
Object o = list.get(i);
|
||||||
|
|
||||||
|
if (o instanceof String || o instanceof Character) {
|
||||||
|
builder.append(prefixSpaces).append("- '").append(o).append("'");
|
||||||
|
} else if (o instanceof List) {
|
||||||
|
builder.append(prefixSpaces).append("- ").append(yaml.dump(o));
|
||||||
|
} else {
|
||||||
|
builder.append(prefixSpaces).append("- ").append(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i != list.size()) {
|
||||||
|
builder.append("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Key is the config key, value = comment and/or ignored sections
|
||||||
|
//Parses comments, blank lines, and ignored sections
|
||||||
|
private static Map<String, String> parseComments(List<String> lines, List<String> ignoredSections, FileConfiguration oldConfig, Yaml yaml) {
|
||||||
|
Map<String, String> comments = new HashMap<>();
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
StringBuilder keyBuilder = new StringBuilder();
|
||||||
|
int lastLineIndentCount = 0;
|
||||||
|
|
||||||
|
outer: for (String line : lines) {
|
||||||
|
if (line != null && line.trim().startsWith("-"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (line == null || line.trim().equals("") || line.trim().startsWith("#")) {
|
||||||
|
builder.append(line).append("\n");
|
||||||
|
} else {
|
||||||
|
lastLineIndentCount = setFullKey(keyBuilder, line, lastLineIndentCount);
|
||||||
|
|
||||||
|
for (String ignoredSection : ignoredSections) {
|
||||||
|
if (keyBuilder.toString().equals(ignoredSection)) {
|
||||||
|
Object value = oldConfig.get(keyBuilder.toString());
|
||||||
|
|
||||||
|
if (value instanceof ConfigurationSection)
|
||||||
|
appendSection(builder, (ConfigurationSection) value, new StringBuilder(getPrefixSpaces(lastLineIndentCount)), yaml);
|
||||||
|
|
||||||
|
continue outer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keyBuilder.length() > 0) {
|
||||||
|
comments.put(keyBuilder.toString(), builder.toString());
|
||||||
|
builder.setLength(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (builder.length() > 0) {
|
||||||
|
comments.put(null, builder.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void appendSection(StringBuilder builder, ConfigurationSection section, StringBuilder prefixSpaces, Yaml yaml) {
|
||||||
|
builder.append(prefixSpaces).append(getKeyFromFullKey(section.getCurrentPath())).append(":");
|
||||||
|
Set<String> keys = section.getKeys(false);
|
||||||
|
|
||||||
|
if (keys.isEmpty()) {
|
||||||
|
builder.append(" {}\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.append("\n");
|
||||||
|
prefixSpaces.append(" ");
|
||||||
|
|
||||||
|
for (String key : keys) {
|
||||||
|
Object value = section.get(key);
|
||||||
|
String actualKey = getKeyFromFullKey(key);
|
||||||
|
|
||||||
|
if (value instanceof ConfigurationSection) {
|
||||||
|
appendSection(builder, (ConfigurationSection) value, prefixSpaces, yaml);
|
||||||
|
prefixSpaces.setLength(prefixSpaces.length() - 2);
|
||||||
|
} else if (value instanceof List) {
|
||||||
|
builder.append(getListAsString((List) value, actualKey, prefixSpaces.toString(), yaml));
|
||||||
|
} else {
|
||||||
|
builder.append(prefixSpaces.toString()).append(actualKey).append(": ").append(yaml.dump(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Counts spaces in front of key and divides by 2 since 1 indent = 2 spaces
|
||||||
|
private static int countIndents(String s) {
|
||||||
|
int spaces = 0;
|
||||||
|
|
||||||
|
for (char c : s.toCharArray()) {
|
||||||
|
if (c == ' ') {
|
||||||
|
spaces += 1;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return spaces / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Ex. keyBuilder = key1.key2.key3 --> key1.key2
|
||||||
|
private static void removeLastKey(StringBuilder keyBuilder) {
|
||||||
|
String temp = keyBuilder.toString();
|
||||||
|
String[] keys = temp.split("\\.");
|
||||||
|
|
||||||
|
if (keys.length == 1) {
|
||||||
|
keyBuilder.setLength(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
temp = temp.substring(0, temp.length() - keys[keys.length - 1].length() - 1);
|
||||||
|
keyBuilder.setLength(temp.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getKeyFromFullKey(String fullKey) {
|
||||||
|
String[] keys = fullKey.split("\\.");
|
||||||
|
return keys[keys.length - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
//Updates the keyBuilder and returns configLines number of indents
|
||||||
|
private static int setFullKey(StringBuilder keyBuilder, String configLine, int lastLineIndentCount) {
|
||||||
|
int currentIndents = countIndents(configLine);
|
||||||
|
String key = configLine.trim().split(":")[0];
|
||||||
|
|
||||||
|
if (keyBuilder.length() == 0) {
|
||||||
|
keyBuilder.append(key);
|
||||||
|
} else if (currentIndents == lastLineIndentCount) {
|
||||||
|
//Replace the last part of the key with current key
|
||||||
|
removeLastKey(keyBuilder);
|
||||||
|
|
||||||
|
if (keyBuilder.length() > 0) {
|
||||||
|
keyBuilder.append(".");
|
||||||
|
}
|
||||||
|
|
||||||
|
keyBuilder.append(key);
|
||||||
|
} else if (currentIndents > lastLineIndentCount) {
|
||||||
|
//Append current key to the keyBuilder
|
||||||
|
keyBuilder.append(".").append(key);
|
||||||
|
} else {
|
||||||
|
int difference = lastLineIndentCount - currentIndents;
|
||||||
|
|
||||||
|
for (int i = 0; i < difference + 1; i++) {
|
||||||
|
removeLastKey(keyBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keyBuilder.length() > 0) {
|
||||||
|
keyBuilder.append(".");
|
||||||
|
}
|
||||||
|
|
||||||
|
keyBuilder.append(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return currentIndents;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getPrefixSpaces(int indents) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
for (int i = 0; i < indents; i++) {
|
||||||
|
builder.append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void appendPrefixSpaces(StringBuilder builder, int indents) {
|
||||||
|
builder.append(getPrefixSpaces(indents));
|
||||||
|
}
|
||||||
|
}
|
@ -1,25 +1,25 @@
|
|||||||
package hu.ditservices.utils;
|
package tk.ditservices.utils;
|
||||||
|
|
||||||
import hu.ditservices.STPlugin;
|
import tk.ditservices.DITSystem;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class Cooldown {
|
public class Cooldown {
|
||||||
STPlugin plugin;
|
|
||||||
FileConfiguration config;
|
|
||||||
|
|
||||||
Map<String, Long> cooldowns = new HashMap<>();
|
|
||||||
private int delay = 2; //seconds
|
private int delay = 2; //seconds
|
||||||
|
DITSystem plugin;
|
||||||
|
Map<String, Long> cooldowns = new HashMap<>();
|
||||||
public long time_left;
|
public long time_left;
|
||||||
|
FileConfiguration config;
|
||||||
public Cooldown(STPlugin instance){
|
public Cooldown(DITSystem instance){
|
||||||
this.plugin = instance;
|
this.plugin = instance;
|
||||||
this.config = plugin.getConfig();
|
this.config = plugin.config;
|
||||||
if (config.isSet("Cooldown.seconds")){
|
if (config.isSet("Cooldown.seconds")){
|
||||||
int cd = this.delay;
|
int cd = this.delay;
|
||||||
if (cd!=config.getInt("Cooldown.seconds")){
|
if (cd!=config.getInt("Cooldown.seconds")){
|
||||||
@ -38,14 +38,21 @@ public class Cooldown {
|
|||||||
if (this.cooldowns.containsKey(player.getName())) {
|
if (this.cooldowns.containsKey(player.getName())) {
|
||||||
if (this.cooldowns.get(player.getName()) > System.currentTimeMillis()) {
|
if (this.cooldowns.get(player.getName()) > System.currentTimeMillis()) {
|
||||||
this.time_left = (this.cooldowns.get(player.getName()) - System.currentTimeMillis()) / 1000;
|
this.time_left = (this.cooldowns.get(player.getName()) - System.currentTimeMillis()) / 1000;
|
||||||
return this.time_left == 0;
|
if (this.time_left == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (sender instanceof ConsoleCommandSender){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public void Add(Player player){
|
public void Add(Player player){
|
@ -1,4 +1,6 @@
|
|||||||
package hu.ditservices.utils;
|
package tk.ditservices.utils;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class Math {
|
public class Math {
|
||||||
public enum Convert {
|
public enum Convert {
|
@ -1,14 +1,13 @@
|
|||||||
package hu.ditservices.utils;
|
package tk.ditservices.utils;
|
||||||
|
|
||||||
import hu.ditservices.STPlugin;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import java.lang.Math;
|
import java.lang.Math;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
public class Server {
|
public class Server {
|
||||||
|
|
||||||
|
|
||||||
public enum RAM {
|
public enum RAM {
|
||||||
FREE,USED,TOTAL
|
FREE,USED,TOTAL
|
||||||
}
|
}
|
||||||
@ -19,6 +18,7 @@ public class Server {
|
|||||||
public static long getRAM(Server.RAM t) {
|
public static long getRAM(Server.RAM t) {
|
||||||
long mb = 1048576L;
|
long mb = 1048576L;
|
||||||
Runtime runtime = Runtime.getRuntime();
|
Runtime runtime = Runtime.getRuntime();
|
||||||
|
runtime.gc();
|
||||||
if (t == RAM.FREE){
|
if (t == RAM.FREE){
|
||||||
return runtime.freeMemory() / mb;
|
return runtime.freeMemory() / mb;
|
||||||
}
|
}
|
||||||
@ -31,31 +31,18 @@ public class Server {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Get the CPU cores of the MC server.
|
|
||||||
*/
|
|
||||||
public static int getCpuCores(){
|
|
||||||
return Runtime.getRuntime().availableProcessors();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a player's ping.
|
* Get a player's ping.
|
||||||
* @param player The player object.
|
* @param player The player object.
|
||||||
* @return Returns the player's ping in integer.
|
|
||||||
*/
|
*/
|
||||||
public static int getPlayerPing(Player player){
|
public static int getPlayerPing(Player player){
|
||||||
try {
|
try {
|
||||||
if (Version.ServerVersion.isCurrentLower(Version.ServerVersion.v1_16_R1)){
|
Object entityPlayer = player.getClass().getMethod("getHandle").invoke(player);
|
||||||
Object entityPlayer = player.getClass().getMethod("getHandle").invoke(player);
|
return (int) entityPlayer.getClass().getField("ping").get(entityPlayer);
|
||||||
return (int) entityPlayer.getClass().getField("ping").get(entityPlayer);
|
} catch (IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | NoSuchFieldException | InvocationTargetException e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
return player.getPing();
|
|
||||||
} catch (Exception e) {
|
|
||||||
STPlugin plugin = STPlugin.getInstance();
|
|
||||||
plugin.getLogger().warning(ChatColor.stripColor(plugin.getPrefix()) + e.getMessage());
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get an average of the currently online player's ping.
|
* Get an average of the currently online player's ping.
|
@ -11,9 +11,6 @@
|
|||||||
# ██████╔╝██║██║░╚═╝░██║██║░░░░░███████╗██║██║░░░░░░░░██║░░░░░░██║░░░╚█████╔╝╚█████╔╝███████╗██████╔╝
|
# ██████╔╝██║██║░╚═╝░██║██║░░░░░███████╗██║██║░░░░░░░░██║░░░░░░██║░░░╚█████╔╝╚█████╔╝███████╗██████╔╝
|
||||||
# ╚═════╝░╚═╝╚═╝░░░░░╚═╝╚═╝░░░░░╚══════╝╚═╝╚═╝░░░░░░░░╚═╝░░░░░░╚═╝░░░░╚════╝░░╚════╝░╚══════╝╚═════╝░
|
# ╚═════╝░╚═╝╚═╝░░░░░╚═╝╚═╝░░░░░╚══════╝╚═╝╚═╝░░░░░░░░╚═╝░░░░░░╚═╝░░░░╚════╝░░╚════╝░╚══════╝╚═════╝░
|
||||||
#
|
#
|
||||||
# Localization options
|
|
||||||
# Currently these languages included by default: en, hu. You can add another language in the lang folder.
|
|
||||||
language: 'en'
|
|
||||||
# Logging options
|
# Logging options
|
||||||
# If you enable one of them, a txt file will be created every day automatically with the current date.
|
# If you enable one of them, a txt file will be created every day automatically with the current date.
|
||||||
Log:
|
Log:
|
||||||
@ -44,82 +41,47 @@ CustomAdvancement:
|
|||||||
# example: header: &cThis server is using SimplifyTools by &1SimplifyDave
|
# example: header: &cThis server is using SimplifyTools by &1SimplifyDave
|
||||||
# Note: Use \n to add a new line
|
# Note: Use \n to add a new line
|
||||||
# Note: The RAM values are in MB.
|
# Note: The RAM values are in MB.
|
||||||
# {USEDRAM} {TOTALRAM} {FREERAM} {AVERAGEPING} {ONLINEPLAYERS} {MAXPLAYERS} {MOTD} represents their values.
|
# {USEDRAM} {TOTALRAM} {FREERAM} {AVERAGEPING} {ONLINEPLAYERS} {MAXPLAYERS} represents their values.
|
||||||
# {UPTIME} will be replaced with the server's uptime in the following format: "xx days xx hours xx minutes"
|
|
||||||
# NOTICE: You will need a full MC server restart when you want to apply new settings here.
|
# NOTICE: You will need a full MC server restart when you want to apply new settings here.
|
||||||
Tab:
|
Tab:
|
||||||
enabled: false # If you want to enable customization on the tab
|
enabled: false # If you want to enable customization on the tab
|
||||||
refreshRate: 1 # The refresh rate in SECONDS
|
refreshRate: 2 # The refresh rate in SECONDS
|
||||||
headerAnimation:
|
headerAnimation: #If animation set to true, you can set the animations per line.
|
||||||
- '&e&n{MOTD}\n&r&eOnline Players: &6{MAXPLAYERS}/{ONLINEPLAYERS}\n&eAverage ping: &6{AVERAGEPING} ms'
|
#If you don't want animations, just leave one line text here!
|
||||||
- '&6&l&n{MOTD}\n&r&6Online Players: &e{MAXPLAYERS}/{ONLINEPLAYERS}\n&6Average ping: &e{AVERAGEPING} ms'
|
|
||||||
#If you don't want animations, just leave one line text here!
|
|
||||||
#- '&l&cThis is an example header text without animation\nAnd this is a new line!'
|
#- '&l&cThis is an example header text without animation\nAnd this is a new line!'
|
||||||
|
- '&cThis server is using SimplifyTools by &1SimplifyDave \nAverage ping: {AVERAGEPING} ms'
|
||||||
|
- '&bThis server is using SimplifyTools by &9SimplifyDave \nAverage ping: {AVERAGEPING} ms'
|
||||||
|
- '&b&lThis server is using SimplifyTools by &9SimplifyDave \nAverage ping: {AVERAGEPING} ms'
|
||||||
|
|
||||||
footerAnimation:
|
footerAnimation:
|
||||||
- '&l&7Server Statistics:\n&e&lRAM Usage: &6{TOTALRAM}MB / {USEDRAM}MB\n&e&lUptime: &6{UPTIME}\n&e&lTPS: &6{TPS}'
|
#If you don't want animations, just leave one line text here!
|
||||||
- '&l&7Server Statistics:\n&6&lRAM Usage: &e{TOTALRAM}MB / {USEDRAM}MB\n&6&lUptime: &e{UPTIME}\n&6&lTPS: &e{TPS}'
|
#- '&l&cThis is an example footer text without animation\n with multiple lines in one element!'
|
||||||
|
- '&l&4Server RAM Usage: {TOTALRAM}MB / {USEDRAM}MB\nOnline players: {MAXPLAYERS}/{ONLINEPLAYERS}'
|
||||||
|
- '&l&aServer RAM Usage: {TOTALRAM}MB / {USEDRAM}MB\nOnline players: {MAXPLAYERS}/{ONLINEPLAYERS}'
|
||||||
|
|
||||||
# Custom Connect/Disconnect messages
|
# Custom Connect/Disconnect messages
|
||||||
CustomMsg:
|
CustomMsg:
|
||||||
enabled: false
|
enabled: false
|
||||||
connect: '{PREFIX}{NAME} &aconnected to the server.'
|
connect: '{PREFIX}{NAME} &aconnected to the server.'
|
||||||
disconnect: '{PREFIX}{NAME} left the game.'
|
disconnect: '{PREFIX}{NAME} leaved the game.'
|
||||||
|
|
||||||
# Auto Save options
|
# Auto Save options
|
||||||
# Saves Worlds/Users data to disk.
|
# Saves Worlds/Users data to disk.
|
||||||
# Note: You can do a save like this with the /st save-all command.
|
# Note: You can do a save like this with the /st save-all command.
|
||||||
# NOTICE: You will need a full MC server restart when you want to apply new settings here.
|
# NOTICE: You will need a full MC server restart when you want to apply new settings here.
|
||||||
Saving:
|
Saving:
|
||||||
enabled: false
|
enabled: true
|
||||||
onDisconnect: true # When a player disconnects
|
onDisconnect: true # When a player disconnects
|
||||||
interval: 1800 # Auto saving interval in SECONDS. If this set to zero it means disabled.
|
interval: 0 # Auto saving interval in SECONDS. If this set to zero it means disabled.
|
||||||
broadcastMsgProgress: '{PREFIX}Auto save in progress..'
|
broadcastMsgProgress: '{PREFIX}Auto save in progress..'
|
||||||
broadcastMsgDone: '{PREFIX}Auto save done.'
|
broadcastMsgDone: '{PREFIX}Auto save done.'
|
||||||
|
|
||||||
# Server Password options
|
|
||||||
# You can configure a same password for all players on the server.
|
|
||||||
# Players not logged in can't move, cant build/destroy.
|
|
||||||
ServerPassword:
|
|
||||||
enabled: false
|
|
||||||
password: 'changeme'
|
|
||||||
exceptOps: true # Server operators don't need to login.
|
|
||||||
rememberUntilRestart: true # Set this to 'false' to player need to provide password each login.
|
|
||||||
# Otherwise, each player need to provide password only once until the server is restarted.
|
|
||||||
# Below settings are preventing the related actions until the password was not given by the player if the setting is 'true'.
|
|
||||||
preventInventory: true
|
|
||||||
preventMove: true
|
|
||||||
preventBuild: true
|
|
||||||
|
|
||||||
# Dropped items clearing options
|
|
||||||
ClearDropItems:
|
|
||||||
enabled: false
|
|
||||||
interval: 300 # Interval in seconds between each clear cycle
|
|
||||||
broadcastMsg: true # Broadcasts alerts before clearing 1 minutes and 10 seconds before and when cleared. Set this to 'false' to make cleaning silently.
|
|
||||||
# Dropped items that should always be kept (never cleared)
|
|
||||||
except:
|
|
||||||
- DIAMOND
|
|
||||||
- GOLD_INGOT
|
|
||||||
# - COAL
|
|
||||||
# - IRON_INGOT
|
|
||||||
# - BREAD
|
|
||||||
# Worlds to skip (dropped items in these worlds won't be cleared)
|
|
||||||
skipWorlds:
|
|
||||||
- world_nether
|
|
||||||
- world_the_end
|
|
||||||
|
|
||||||
# Cooldown options (only applicable for this plugin!)
|
# Cooldown options (only applicable for this plugin!)
|
||||||
Cooldown:
|
Cooldown:
|
||||||
enabled: true
|
enabled: true
|
||||||
# The time must be passed between using this plugin commands.
|
# The time must be passed between using this plugin commands.
|
||||||
seconds: 1 #The command cooldown in seconds
|
seconds: 2 #The command cooldown in seconds
|
||||||
Msg: '{PREFIX} Please wait {SECONDS} seconds!' # The message when the user spamming a command
|
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
|
# Miscellaneous
|
||||||
Prefix: '&a[&fSimplify&7Tools&2] &4- &f' # The prefix which is inserted to the beginning of every plugin message.
|
Prefix: '&a[&fSimplify&7Tools&2] &4- &f'
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
version.pre.text: "Version: "
|
|
||||||
action.success.reload: "Successfully reload!"
|
|
||||||
notice.settings.not.applied: "Notice: Restart your server if the settings didn't applied."
|
|
||||||
plugin.calculated.tps: "Plugin Calculated TPS: "
|
|
||||||
invalid.arguments: "Invalid arguments!"
|
|
||||||
pmanager.disabled: "Plugin manager commands are disabled in the config!"
|
|
||||||
serverpassword.enabled: "There is server password enabled on this server!"
|
|
||||||
serverpassword.note: "Note: This means the same password for all players."
|
|
||||||
serverpassword.login: "Please login using /slogin <password>"
|
|
||||||
serverpassword.already.auth: "You are already authenticated."
|
|
||||||
serverpassword.success.auth: "You have been authenticated."
|
|
||||||
serverpassword.incorrect: "Incorrect password. Try again."
|
|
||||||
cmd.usage.login: "Usage: /slogin <PASSWORD>"
|
|
||||||
settings.server: "Server "
|
|
||||||
settings.features: "Features"
|
|
||||||
settings.enabled: "Enabled"
|
|
||||||
settings.disabled: "Disabled"
|
|
||||||
settings.feature.tab: "Tab customization: "
|
|
||||||
settings.feature.CustomAdvancementMsg: "Custom Advancement Msg: "
|
|
||||||
settings.feature.AutoSave: "Auto saving: "
|
|
||||||
settings.feature.pmanager: "Plugin manager: "
|
|
||||||
stats.header: "Your statistics"
|
|
||||||
stats.connects: "Connects: "
|
|
||||||
stats.deaths: "Deaths: "
|
|
||||||
stats.MobKills: "Mob kills: "
|
|
||||||
stats.PlayerKills: "Player kills: "
|
|
||||||
stats.sleeps: "Sleeps: "
|
|
||||||
stats.enchants: "Enchants: "
|
|
||||||
stats.totaltime: "Total Play Time: "
|
|
||||||
stats.hour: "h "
|
|
||||||
stats.minutes: "m "
|
|
||||||
stats.seconds: "s"
|
|
||||||
cmd.ping: "Your response time to the server: "
|
|
||||||
pmanager.not.exist: "Plugin not exist!"
|
|
||||||
pmanager.already.enabled: " already enabled!"
|
|
||||||
pmanager.success.enabled: " successfully enabled!"
|
|
||||||
pmanager.already.disabled: " already disabled!"
|
|
||||||
pmanager.success.disabled: " successfully disabled!"
|
|
||||||
list.help: "To list all SimplifyTools commands use the '/help SIMPLIFYTOOLS' command!"
|
|
||||||
cleardropitems.oneMin: "Attention: Dropped items will be cleared in 1 minute!"
|
|
||||||
cleardropitems.tenSec: "Attention: Dropped items will be cleared in 10 seconds!"
|
|
||||||
cleardropitems.cleared: "Dropped items have been cleared (%REMOVECOUNT% items removed)."
|
|
@ -1,42 +0,0 @@
|
|||||||
version.pre.text: "Verzió: "
|
|
||||||
action.success.reload: "Sikeres újratöltés!"
|
|
||||||
notice.settings.not.applied: "Figyelem: Indítsd újra a szervert, ha a beállítások nem alkalmazódtak."
|
|
||||||
plugin.calculated.tps: "Plugin által kalkulált TPS: "
|
|
||||||
invalid.arguments: "Érvénytelen argumentek!"
|
|
||||||
pmanager.disabled: "A plugin-kezelő le van tiltva a konfigban!"
|
|
||||||
serverpassword.enabled: "Ezen a szerveren szerver jelszó van bekapcsolva!"
|
|
||||||
serverpassword.note: "Figyelem: Ez azt jelenti, hogy mindenki számára ugyanazt a jelszót kell megadni!"
|
|
||||||
serverpassword.login: "Kérlek, lépj be ezzel: /slogin <jelszó>"
|
|
||||||
serverpassword.already.auth: "Már bejelentkeztél."
|
|
||||||
serverpassword.success.auth: "Sikeresen bejelentkeztél!"
|
|
||||||
serverpassword.incorrect: "Rossz jelszó. Próbáld újra."
|
|
||||||
cmd.usage.login: "Használat: /slogin <JELSZÓ>"
|
|
||||||
settings.server: "Szerver "
|
|
||||||
settings.features: "Tulajdonságok "
|
|
||||||
settings.enabled: "Bekapcsolva"
|
|
||||||
settings.disabled: "Kikapcsolva"
|
|
||||||
settings.feature.tab: "Tablista testreszabás: "
|
|
||||||
settings.feature.CustomAdvancementMsg: "Teljesítmény-elérés üzenet testreszabás: "
|
|
||||||
settings.feature.AutoSave: "Automatikus mentés: "
|
|
||||||
settings.feature.pmanager: "Plugin kezelő: "
|
|
||||||
stats.header: "A statisztikáid"
|
|
||||||
stats.connects: "Belépések: "
|
|
||||||
stats.deaths: "Halálok: "
|
|
||||||
stats.MobKills: "Mob ölések: "
|
|
||||||
stats.PlayerKills: "Játékos ölések: "
|
|
||||||
stats.sleeps: "Alvások: "
|
|
||||||
stats.enchants: "Enchantolások: "
|
|
||||||
stats.totaltime: "Összes játékidő: "
|
|
||||||
stats.hour: "ó "
|
|
||||||
stats.minutes: "p "
|
|
||||||
stats.seconds: "mp"
|
|
||||||
cmd.ping: "A válaszidőd a szerverhez: "
|
|
||||||
pmanager.not.exist: "Plugin nem létezik!"
|
|
||||||
pmanager.already.enabled: " már eddig is engedélyezve volt!"
|
|
||||||
pmanager.success.enabled: " sikeresen engedélyezve!"
|
|
||||||
pmanager.already.disabled: " már kivolt kapcsolva eddig is!"
|
|
||||||
pmanager.success.disabled: " sikeresen kikapcsolva!"
|
|
||||||
list.help: "Használd a '/help SIMPLIFYTOOLS' parancsot a plugin parancsainak listázásához!"
|
|
||||||
cleardropitems.oneMin: "Figyelem! Az eldobott tárgyak 1 perc múlva törlésre kerülnek!"
|
|
||||||
cleardropitems.tenSec: "Figyelem! Az eldobott tárgyak 10 másodpercen belül törlésre kerülnek!"
|
|
||||||
cleardropitems.cleared: "Az eldobott tárgyak törlésre kerültek. (%REMOVECOUNT% tárgy lett eltávolítva)."
|
|
@ -1,13 +1,12 @@
|
|||||||
name: SimplifyTools
|
name: SimplifyTools
|
||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
main: hu.ditservices.STPlugin
|
main: tk.ditservices.DITSystem
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
prefix: SimplifyTools
|
prefix: SimplifyTools
|
||||||
load: POSTWORLD
|
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://dit-services.tk
|
||||||
depend: [ ProtocolLib ]
|
|
||||||
commands:
|
commands:
|
||||||
st:
|
st:
|
||||||
description: The default command for the plugin.
|
description: The default command for the plugin.
|
||||||
@ -21,18 +20,10 @@ commands:
|
|||||||
description: Displays your ping to the current server.
|
description: Displays your ping to the current server.
|
||||||
usage: "/st ping"
|
usage: "/st ping"
|
||||||
permission: st.ping
|
permission: st.ping
|
||||||
st tps:
|
|
||||||
description: Displays plugin, and server calculated TPS.
|
|
||||||
usage: "/st tps"
|
|
||||||
permission: st.tps
|
|
||||||
st stats:
|
st stats:
|
||||||
description: Displays your gameplay statistics.
|
description: Displays your gameplay statistics.
|
||||||
usage: "/st stats"
|
usage: "/st stats"
|
||||||
permission: st.stats
|
permission: st.stats
|
||||||
st settings:
|
|
||||||
description: Displays plugin settings.
|
|
||||||
usage: "/st settings"
|
|
||||||
permission: st.admin
|
|
||||||
st save-all:
|
st save-all:
|
||||||
description: Saves the players, worlds data on the server.
|
description: Saves the players, worlds data on the server.
|
||||||
usage: "/st save-all"
|
usage: "/st save-all"
|
||||||
@ -53,18 +44,8 @@ commands:
|
|||||||
description: Plugin settings reload.
|
description: Plugin settings reload.
|
||||||
usage: "/st reload"
|
usage: "/st reload"
|
||||||
permission: st.reload
|
permission: st.reload
|
||||||
slogin:
|
|
||||||
description: Server password login.
|
|
||||||
usage: "/slogin <PASSWORD>"
|
|
||||||
permission: st.slogin
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
st.slogin:
|
|
||||||
description: The server password login command.
|
|
||||||
default: true
|
|
||||||
st.slogin.skip:
|
|
||||||
description: If has this permission the user dont have to provide server password upon connect.
|
|
||||||
default: op
|
|
||||||
st.help:
|
st.help:
|
||||||
description: Enables the help command.
|
description: Enables the help command.
|
||||||
default: true
|
default: true
|
||||||
@ -74,9 +55,6 @@ permissions:
|
|||||||
st.ping:
|
st.ping:
|
||||||
description: Enables the ping command.
|
description: Enables the ping command.
|
||||||
default: true
|
default: true
|
||||||
st.tps:
|
|
||||||
description: Enables the tps command.
|
|
||||||
default: true
|
|
||||||
st.reload:
|
st.reload:
|
||||||
description: Enables the reload command.
|
description: Enables the reload command.
|
||||||
default: op
|
default: op
|
||||||
@ -95,13 +73,13 @@ permissions:
|
|||||||
st.save:
|
st.save:
|
||||||
description: Enables the save-all command.
|
description: Enables the save-all command.
|
||||||
default: op
|
default: op
|
||||||
st.admin:
|
st.admin:
|
||||||
description: An admin permission for the maintenance commands and for update notifies.
|
description: An admin permission for the maintenance commands and for update notifies.
|
||||||
default: op
|
default: op
|
||||||
children:
|
children:
|
||||||
st.save: true
|
st.save: true
|
||||||
st.pmanager.*: true
|
st.pmanager.*: true
|
||||||
st.*:
|
st.*:
|
||||||
description: Wildcard permission for all commands.
|
description: Wildcard permission for all commands.
|
||||||
default: op
|
default: op
|
||||||
children:
|
children:
|
||||||
@ -112,7 +90,7 @@ permissions:
|
|||||||
st.save: true
|
st.save: true
|
||||||
st.stats: true
|
st.stats: true
|
||||||
st.settings: true
|
st.settings: true
|
||||||
st.pmanager.*:
|
st.pmanager.*:
|
||||||
description: The plugin manager commands.
|
description: The plugin manager commands.
|
||||||
default: op
|
default: op
|
||||||
children:
|
children:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user