8 Commits

10 changed files with 160 additions and 15 deletions

View File

@ -1,6 +1,6 @@
![SimplifyTools logo](docs/img/SimplifyTools.png) ![SimplifyTools logo](docs/img/SimplifyTools.png)
### An 'All-in-one' plugin for MC servers. ### An 'All-in-one' plugin for MC servers.
#### TabList Customizing, Custom Advancement, Connect messages, AutoSave, Logger #### TabList Customizing, Server Password, Clear Dropped Items, Custom Advancement, Connect messages, AutoSave, Logger
[![Build Status](https://ci.ditservices.hu/job/SimplifyTools/badge/icon)](https://ci.ditservices.hu/job/SimplifyTools/) ![ MC Version](https://ci.ditservices.hu/job/SimplifyTools/badge/icon?subject=MC&status=1.12%20-%201.21.4&color=darkblue) ![Git latest release](https://img.shields.io/github/v/release/LabodiDavid/SimplifyTools) [![bStats](https://ci.ditservices.hu/job/SimplifyTools/badge/icon?subject=bStats&status=3.0&color=brightgreen)](https://bstats.org/plugin/bukkit/SimplifyTools/15108) ![Lines of code](https://tokei.rs/b1/github/LabodiDavid/SimplifyTools?category=code) [![Build Status](https://ci.ditservices.hu/job/SimplifyTools/badge/icon)](https://ci.ditservices.hu/job/SimplifyTools/) ![ MC Version](https://ci.ditservices.hu/job/SimplifyTools/badge/icon?subject=MC&status=1.12%20-%201.21.4&color=darkblue) ![Git latest release](https://img.shields.io/github/v/release/LabodiDavid/SimplifyTools) [![bStats](https://ci.ditservices.hu/job/SimplifyTools/badge/icon?subject=bStats&status=3.0&color=brightgreen)](https://bstats.org/plugin/bukkit/SimplifyTools/15108) ![Lines of code](https://tokei.rs/b1/github/LabodiDavid/SimplifyTools?category=code)
<br>[Changelog](docs/ChangeLog.md) <br>[Changelog](docs/ChangeLog.md)
<hr> <hr>
@ -12,13 +12,15 @@
- **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.
![Tab manager preview](docs/img/1.gif) ![Tab manager preview](docs/img/1.gif)
- **Automatic/command saving** - Allows you to schedule auto saving of the world/player data on your server, or you can initiate a save by a command.
- **Custom Connect/Disconnect messages** - Allows you to customize the message that is broadcasted when someone joins or leaves the server.
![Connect messages preview](docs/img/2.gif)
- **Plugin Manager** - Allows you to unload/load plugins without a server restart. (Disabled by default since v1.2.1)
- **Gameplay statistics** - You can check your gameplay statistics such as player/mob kills, etc. - **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.) (Note: The plugin just shows the stats not recording itself, so stats before installing this plugin are counted too.)
![Stats preview](docs/img/3.gif) ![Stats preview](docs/img/3.gif)
- **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.
![Connect messages preview](docs/img/2.gif)
- **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 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.)
![Advancement Messages preview](docs/img/4.gif) ![Advancement Messages preview](docs/img/4.gif)
@ -32,6 +34,12 @@ _________________
_________________ _________________
### [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) ### [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)

View File

@ -1,5 +1,13 @@
# SimplifyTools - Changelog # SimplifyTools - Changelog
- **1.2.4**
- Added *Server password feature*
- Added *Clearing dropped items feature*
- 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** - **1.2.3**
- Added support for version up to 1.21.4 - Added support for version up to 1.21.4
- The plugin now depends on, <b>requires ProtocolLib</b> (https://github.com/dmulloy2/ProtocolLib/) - The plugin now depends on, <b>requires ProtocolLib</b> (https://github.com/dmulloy2/ProtocolLib/)

View File

@ -5,12 +5,14 @@ You can use the following commands to use the features of SimplifyTools.
- **/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 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
- `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.

View File

@ -6,7 +6,7 @@
<groupId>hu.ditservices</groupId> <groupId>hu.ditservices</groupId>
<artifactId>SimplifyTools</artifactId> <artifactId>SimplifyTools</artifactId>
<version>1.2.4-SNAPSHOT</version> <version>1.2.5-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>SimplifyTools</name> <name>SimplifyTools</name>

View File

@ -78,6 +78,11 @@ public final class STPlugin extends JavaPlugin implements CommandExecutor, Liste
private void scheduleTasks() { private void scheduleTasks() {
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new TPS(), 0, 1); 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) { 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")); long intervalTicks = Math.convert(Math.Convert.SECONDS, Math.Convert.TICKS, instance.config.getInt("Saving.interval"));
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new SaveHandler(), 0L, intervalTicks); Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new SaveHandler(), 0L, intervalTicks);
@ -103,10 +108,11 @@ public final class STPlugin extends JavaPlugin implements CommandExecutor, Liste
private boolean initPlugin() { private boolean initPlugin() {
try { try {
this.ServerStartTime = ManagementFactory.getRuntimeMXBean().getStartTime(); this.ServerStartTime = ManagementFactory.getRuntimeMXBean().getStartTime();
if (Version.ServerVersion.isCurrentLower(Version.ServerVersion.v1_12_R1) || if (Version.ServerVersion.isCurrentLower(Version.ServerVersion.v1_12_R1)) {
Version.ServerVersion.isCurrentHigher(Version.ServerVersion.v1_21_5_R1)) throw new Exception("The server version is not supported! Update to to atleast 1.12 version to use this plugin!");
{ }
throw new Exception("The server version is not supported! Update to a version between 1.12 - 1.21.5 to run 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()) { if (this.reload()) {

View File

@ -0,0 +1,76 @@
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--;
}
}
}

View File

@ -25,9 +25,19 @@ public class ServerPasswordEvents implements Listener {
this.config = plugin.getConfig(); this.config = plugin.getConfig();
} }
private boolean skipIfOpPlayer(Player player)
{
return (player.isOp() && config.getBoolean("ServerPassword.exceptOps")) || player.hasPermission("st.slogin.skip");
}
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (skipIfOpPlayer(player)) {
return;
}
if ((!config.getBoolean("ServerPassword.rememberUntilRestart")) if ((!config.getBoolean("ServerPassword.rememberUntilRestart"))
|| (!plugin.getServerPasswordData().getAuthenticatedPlayers().getOrDefault(player.getUniqueId(),false))) { || (!plugin.getServerPasswordData().getAuthenticatedPlayers().getOrDefault(player.getUniqueId(),false))) {
plugin.getServerPasswordData().getAuthenticatedPlayers().put(player.getUniqueId(),false); plugin.getServerPasswordData().getAuthenticatedPlayers().put(player.getUniqueId(),false);
@ -57,6 +67,9 @@ public class ServerPasswordEvents implements Listener {
@EventHandler @EventHandler
public void onPlayerMove(PlayerMoveEvent event) { public void onPlayerMove(PlayerMoveEvent event) {
if (skipIfOpPlayer(event.getPlayer())) {
return;
}
if ((!plugin.getServerPasswordData().getAuthenticatedPlayers().getOrDefault(event.getPlayer().getUniqueId(),false)) if ((!plugin.getServerPasswordData().getAuthenticatedPlayers().getOrDefault(event.getPlayer().getUniqueId(),false))
&& config.getBoolean("ServerPassword.preventMove")) { && config.getBoolean("ServerPassword.preventMove")) {
event.setCancelled(true); event.setCancelled(true);
@ -65,6 +78,9 @@ public class ServerPasswordEvents implements Listener {
@EventHandler @EventHandler
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
if (skipIfOpPlayer(event.getPlayer())) {
return;
}
if ((!plugin.getServerPasswordData().getAuthenticatedPlayers().getOrDefault(event.getPlayer().getUniqueId(),false)) if ((!plugin.getServerPasswordData().getAuthenticatedPlayers().getOrDefault(event.getPlayer().getUniqueId(),false))
&& config.getBoolean("ServerPassword.preventBuild")) { && config.getBoolean("ServerPassword.preventBuild")) {
event.setCancelled(true); event.setCancelled(true);
@ -73,6 +89,9 @@ public class ServerPasswordEvents implements Listener {
@EventHandler @EventHandler
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockPlace(BlockPlaceEvent event) {
if (skipIfOpPlayer(event.getPlayer())) {
return;
}
if ((!plugin.getServerPasswordData().getAuthenticatedPlayers().getOrDefault(event.getPlayer().getUniqueId(),false)) if ((!plugin.getServerPasswordData().getAuthenticatedPlayers().getOrDefault(event.getPlayer().getUniqueId(),false))
&& config.getBoolean("ServerPassword.preventBuild")) { && config.getBoolean("ServerPassword.preventBuild")) {
event.setCancelled(true); event.setCancelled(true);
@ -84,6 +103,10 @@ public class ServerPasswordEvents implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
if (skipIfOpPlayer(player)) {
return;
}
if (plugin.getServerPasswordData().getAuthenticatedPlayers().getOrDefault(uuid, false)) { if (plugin.getServerPasswordData().getAuthenticatedPlayers().getOrDefault(uuid, false)) {
if (!config.getBoolean("ServerPassword.rememberUntilRestart")) { if (!config.getBoolean("ServerPassword.rememberUntilRestart")) {
plugin.getServerPasswordData().getAuthenticatedPlayers().remove(uuid); plugin.getServerPasswordData().getAuthenticatedPlayers().remove(uuid);

View File

@ -91,12 +91,28 @@ ServerPassword:
preventMove: true preventMove: true
preventBuild: 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: 2 #The command cooldown in seconds seconds: 1 #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 # Plugin Manager - Enable/Disable plugins without server restart

View File

@ -37,3 +37,6 @@ pmanager.success.enabled: " successfully enabled!"
pmanager.already.disabled: " already disabled!" pmanager.already.disabled: " already disabled!"
pmanager.success.disabled: " successfully disabled!" pmanager.success.disabled: " successfully disabled!"
list.help: "To list all SimplifyTools commands use the '/help SIMPLIFYTOOLS' command!" 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)."

View File

@ -37,3 +37,6 @@ pmanager.success.enabled: " sikeresen engedélyezve!"
pmanager.already.disabled: " már kivolt kapcsolva eddig is!" pmanager.already.disabled: " már kivolt kapcsolva eddig is!"
pmanager.success.disabled: " sikeresen kikapcsolva!" pmanager.success.disabled: " sikeresen kikapcsolva!"
list.help: "Használd a '/help SIMPLIFYTOOLS' parancsot a plugin parancsainak listázásához!" 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)."