Compare commits

...

6 Commits

16 changed files with 425 additions and 263 deletions

View File

@ -1,22 +1,17 @@
package hu.ditservices;
import hu.ditservices.handlers.DITTabCompleter;
import hu.ditservices.handlers.SaveHandler;
import hu.ditservices.handlers.TabHandler;
import hu.ditservices.handlers.*;
import hu.ditservices.listeners.*;
import hu.ditservices.utils.*;
import hu.ditservices.utils.Math;
import org.bstats.bukkit.Metrics;
import hu.ditservices.handlers.CommandHandler;
import hu.ditservices.listeners.ChatEvents;
import hu.ditservices.listeners.LogChat;
import hu.ditservices.listeners.LogCommand;
import hu.ditservices.listeners.LogConnect;
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;
@ -26,8 +21,7 @@ import com.jeff_media.updatechecker.UserAgentBuilder;
import java.io.*;
import java.lang.management.ManagementFactory;
import java.util.Collections;
import java.util.Objects;
import java.util.*;
import java.util.logging.Logger;
public final class STPlugin extends JavaPlugin implements CommandExecutor, Listener {
@ -38,6 +32,9 @@ public final class STPlugin extends JavaPlugin implements CommandExecutor, Liste
public long ServerStartTime;
private YamlConfiguration langConfig;
private ServerPasswordData serverPasswordData;
@Override
public void onEnable() {
instance = this;
@ -68,6 +65,14 @@ public final class STPlugin extends JavaPlugin implements CommandExecutor, Liste
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() {
@ -180,6 +185,35 @@ public final class STPlugin extends JavaPlugin implements CommandExecutor, Liste
return returnText.toString();
}
public ServerPasswordData getServerPasswordData() {
return this.serverPasswordData;
}
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");
ConfigUpdater.update(this, "lang/"+l+".yml", langFile, Collections.emptyList());
}
String lang = this.config.getString("language", "en");
File langFile = new File(getDataFolder(), "lang/" + lang + ".yml");
if (!langFile.exists()) {
getLogger().warning("Language file for '" + lang + "' not found. Falling back to English.");
langFile = new File(getDataFolder(), "lang/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");
@ -193,6 +227,12 @@ public final class STPlugin extends JavaPlugin implements CommandExecutor, Liste
}
reloadConfig();
this.config = getConfig();
try {
this.initLocalization();
} catch (IOException e) {
e.printStackTrace();
}
return true;
}

View File

@ -12,7 +12,7 @@ public class PingCommand {
if (sender instanceof Player) {
Player player = (Player) sender;
try {
player.sendMessage(plugin.getPrefix() + "Your response time to the server: " + Server.getPlayerPing(player) + " ms");
player.sendMessage(plugin.getPrefix() + plugin.getTranslatedText("cmd.ping") + Server.getPlayerPing(player) + " ms");
return true;
} catch (IllegalArgumentException | SecurityException e) {
e.printStackTrace();

View File

@ -11,30 +11,30 @@ 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()+"Plugin not exist!");
sender.sendMessage(STPlugin.getInstance().getPrefix()+ STPlugin.getInstance().getTranslatedText("pmanager.not.exist"));
return false;
}
if (plugin.isEnabled()){
sender.sendMessage(STPlugin.getInstance().getPrefix()+"Plugin "+plugin.getName()+" already enabled!");
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()+" successfully enabled!");
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()+"Plugin not exist!");
sender.sendMessage(STPlugin.getInstance().getPrefix()+STPlugin.getInstance().getTranslatedText("pmanager.not.exist"));
return false;
}
if (!plugin.isEnabled()){
sender.sendMessage(STPlugin.getInstance().getPrefix()+"Plugin "+plugin.getName()+" already disabled!");
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()+" successfully disabled!");
sender.sendMessage(STPlugin.getInstance().getPrefix()+"Plugin "+plugin.getName()+STPlugin.getInstance().getTranslatedText("pmanager.success.disabled"));
return true;
}

View File

@ -9,15 +9,18 @@ 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 Version: " + ChatColor.translateAlternateColorCodes('&',"&a[&fSimplify&7Tools&2] &4- &f") + plugin.getDescription().getVersion() + "\n"
+ ChatColor.GREEN+"Server Version: " + Version.ServerVersion.getCurrent().toString() + "\n"
+ ChatColor.GREEN+" -------- Features -------- " + "\n"
+ ChatColor.GREEN+"Tab customization: "+(plugin.getConfig().getBoolean("Tab.enabled") ? ChatColor.GREEN + "Enabled" : ChatColor.RED+"Disabled") + "\n"
+ ChatColor.GREEN+"Custom Advancement Msg: " + (plugin.getConfig().getBoolean("CustomAdvancement.enabled") ? ChatColor.GREEN+"Enabled" : ChatColor.RED+"Disabled") + "\n"
+ ChatColor.GREEN+"Auto saving: " + (plugin.getConfig().getBoolean("Saving.enabled") ? ChatColor.GREEN+"Enabled" : ChatColor.RED+"Disabled") + "\n"
+ ChatColor.GREEN+"Plugin manager: " + (plugin.getConfig().getBoolean("PluginManager.enabled") ? ChatColor.GREEN+"Enabled" : ChatColor.RED+"Disabled") + "\n"
+ ChatColor.GREEN+" ========================== "
+ 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;

View File

@ -16,15 +16,17 @@ public class StatCommand {
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 + " === 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.AQUA + "Total Play Time: " + hours + "h " + minutes + "m " + seconds + "s");
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;
}

View File

@ -18,7 +18,7 @@ public class CommandHandler implements CommandExecutor {
public CommandHandler(final STPlugin instance) {
this.plugin = instance;
this.noArgMsg = plugin.getPrefix() + ChatColor.DARK_RED + "To list all SimplifyTools commands use the '/help SIMPLIFYTOOLS' command!";
this.noArgMsg = plugin.getPrefix() + ChatColor.DARK_RED + plugin.getTranslatedText("list.help");
this.cd = new Cooldown(plugin);
this.config = plugin.getConfig();
}
@ -44,7 +44,7 @@ public class CommandHandler implements CommandExecutor {
if (command.getName().equals("st") && (args.length == 0 || args[0].contains("help")))
{
sender.sendMessage(plugin.getPrefix() + ChatColor.GREEN+"Version: " + plugin.getDescription().getVersion());
sender.sendMessage(plugin.getPrefix() + ChatColor.GREEN+plugin.getTranslatedText("version.pre.text") + plugin.getDescription().getVersion());
sender.sendMessage(this.noArgMsg);
return true;
}
@ -58,13 +58,13 @@ public class CommandHandler implements CommandExecutor {
if(plugin.reload()){
sender.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Successfully reload!" + "\n"
+ plugin.getPrefix() + ChatColor.RED + "Notice: Restart your server if the settings didn't applied.");
+ 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 Calculated TPS: "+TPS.getColor()+String.format("%.2f", TPS.getTPS()));
sender.sendMessage(plugin.getPrefix() + ChatColor.GREEN+plugin.getTranslatedText("plugin.calculated.tps")+TPS.getColor()+String.format("%.2f", TPS.getTPS()));
return true;
}
@ -72,7 +72,7 @@ public class CommandHandler implements CommandExecutor {
if (command.getName().equalsIgnoreCase("st") && args[0].contains("pmanager")) {
if (sender.hasPermission("st.pmanager.unload") || sender.hasPermission("st.pmanager.load") || sender.hasPermission("st.pmanager")) {
if (args.length==1){
sender.sendMessage(plugin.getPrefix() + ChatColor.DARK_RED+"Invalid arguments!");
sender.sendMessage(plugin.getPrefix() + ChatColor.DARK_RED+plugin.getTranslatedText("invalid.arguments"));
return true;
}
if (config.getBoolean("PluginManager.enabled")) {
@ -85,7 +85,7 @@ public class CommandHandler implements CommandExecutor {
PluginManagerCommand.UnloadPlugin(sender, args);
}
} else {
sender.sendMessage(plugin.getPrefix() + ChatColor.DARK_RED + "Plugin manager commands are disabled in the config!");
sender.sendMessage(plugin.getPrefix() + ChatColor.DARK_RED + plugin.getTranslatedText("pmanager.disabled"));
return true;
}
}

View File

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

View File

@ -0,0 +1,104 @@
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();
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
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 ((!plugin.getServerPasswordData().getAuthenticatedPlayers().getOrDefault(event.getPlayer().getUniqueId(),false))
&& config.getBoolean("ServerPassword.preventMove")) {
event.setCancelled(true);
}
}
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
if ((!plugin.getServerPasswordData().getAuthenticatedPlayers().getOrDefault(event.getPlayer().getUniqueId(),false))
&& config.getBoolean("ServerPassword.preventBuild")) {
event.setCancelled(true);
}
}
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
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 (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);
}
}
}
}
}

View File

@ -0,0 +1,40 @@
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");
}
}

View File

@ -1,5 +1,8 @@
package hu.ditservices.utils;
import org.bukkit.Bukkit;
import java.lang.reflect.Method;
import java.util.regex.Pattern;
public class Version {
@ -77,6 +80,37 @@ public class Version {
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) {
e.printStackTrace();
}
// 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("\\.");
@ -97,7 +131,7 @@ public class Version {
}
return arrayVersion;
}
}*/
public static boolean isCurrentEqualOrHigher(ServerVersion v) {
return getCurrent().value >= v.value;

View File

@ -1,95 +0,0 @@
/*
package hu.ditservices.utils.reflection;
import hu.ditservices.utils.Version;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public final class ClazzContainer {
private static Class<?> packet, ChatComponentTextClass, CraftPlayerClass, IChatBaseComponentClass, PacketPlayOutPlayerListHeaderFooterClass;
private static Object ChatComponentText, IChatBaseComponent;
static {
try {
IChatBaseComponentClass = classByName("net.minecraft.network.chat", "IChatBaseComponent");
packet = classByName("net.minecraft.network.protocol", "Packet");
} catch (Exception e){
e.printStackTrace();
}
}
public ClazzContainer(){
}
public static Class<?> classByName(String newPackageName, String name) throws ClassNotFoundException {
if (Version.ServerVersion.isCurrentLower(Version.ServerVersion.v1_17_R1) || newPackageName == null) {
newPackageName = "net.minecraft.server." + Version.ServerVersion.getArrayVersion()[3];
}
return Class.forName(newPackageName + "." + name);
}
public static Object buildChatComponentText(String text) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
Constructor<?> constructor;
if (Version.ServerVersion.isCurrentEqualOrHigher(Version.ServerVersion.v1_17_R1)){
if (ChatComponentTextClass == null){
ChatComponentTextClass = Reflection.getClass("net.minecraft.network.chat.ChatComponentText");
}
constructor = ChatComponentTextClass.getConstructor(String.class);
return constructor.newInstance(text);
}else{
if (ChatComponentTextClass == null){
ChatComponentTextClass = Reflection.getClass("net.minecraft.server.%v.ChatComponentText");
}
constructor = Reflection.getClass("net.minecraft.server.%v.ChatComponentText").getConstructor(String.class);
return constructor.newInstance(text);
}
}
public static Object buildPacketPlayOutPlayerListHeaderFooter(Object header, Object footer) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
Constructor<?> constructor;
Field headerField;
Field footerField;
Object packet;
if (Version.ServerVersion.isCurrentEqualOrHigher(Version.ServerVersion.v1_17_R1)){
if (PacketPlayOutPlayerListHeaderFooterClass == null){
PacketPlayOutPlayerListHeaderFooterClass = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutPlayerListHeaderFooter");
}
}else{
if (PacketPlayOutPlayerListHeaderFooterClass == null){
PacketPlayOutPlayerListHeaderFooterClass = Reflection.getClass("net.minecraft.server.%v.PacketPlayOutPlayerListHeaderFooter");
}
}
if (Version.ServerVersion.isCurrentEqualOrLower(Version.ServerVersion.v1_12_R1)){
constructor = PacketPlayOutPlayerListHeaderFooterClass.getConstructor();
packet = constructor.newInstance();
try {
headerField = packet.getClass().getDeclaredField("a");
headerField.setAccessible(true);
headerField.set(packet, buildChatComponentText((String) header));
footerField = packet.getClass().getDeclaredField("b");
footerField.setAccessible(true);
footerField.set(packet, buildChatComponentText((String) footer));
} catch (Exception e){
e.printStackTrace();
}
}else{
constructor = PacketPlayOutPlayerListHeaderFooterClass.getConstructor(IChatBaseComponentClass,IChatBaseComponentClass);
packet = constructor.newInstance(header,footer);
}
return packet;
}
public static Class<?> getIChatBaseComponent() {
return IChatBaseComponentClass;
}
public static Class<?> getPacket() {
return packet;
}
}
*/

View File

@ -1,126 +0,0 @@
/*
package hu.ditservices.utils.reflection;
import hu.ditservices.utils.Version;
import org.bukkit.entity.Player;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class Reflection {
private static Method playerHandleMethod, sendPacketMethod, chatSerializerMethodA,chatSerializerMethodgetString;
private static Field playerConnectionField;
private static Class<?> chatSerializer;
private Reflection(){}
public static Class<?> getClass(String name) {
try {
return Class.forName(name.replace("%v",Version.ServerVersion.getCurrent().toString()));
} catch (ClassNotFoundException e) {
e.printStackTrace();
return null;
}
}
public static Class<?> getCraftClass(String className) throws ClassNotFoundException {
return Class.forName("org.bukkit.craftbukkit." + Version.ServerVersion.getArrayVersion()[3] + "." + className);
}
public static Object getPlayerHandle(Player player) throws Exception {
if (playerHandleMethod == null) {
playerHandleMethod = player.getClass().getDeclaredMethod("getHandle");
}
return playerHandleMethod.invoke(player);
}
public static void sendPacket(Player player, Object packet) {
if (player == null) {
return;
}
try {
Object playerHandle = getPlayerHandle(player);
if (playerConnectionField == null) {
playerConnectionField = playerHandle.getClass().getDeclaredField(
(Version.ServerVersion.isCurrentEqualOrHigher(Version.ServerVersion.v1_17_R1) ? "b" : "playerConnection"));
}
Object playerConnection = playerConnectionField.get(playerHandle);
if (sendPacketMethod == null) {
sendPacketMethod = playerConnection.getClass().getDeclaredMethod(
Version.ServerVersion.isCurrentEqualOrHigher(Version.ServerVersion.v1_18_R1) ? "a" : "sendPacket",
ClazzContainer.getPacket());
}
sendPacketMethod.invoke(playerConnection, packet);
} catch (Exception e) {
e.printStackTrace();
}
}
public static String getChatSerializerString(Object serializer) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
if (chatSerializerMethodgetString==null){
if (Version.ServerVersion.isCurrentEqualOrLower(Version.ServerVersion.v1_12_R1)){
chatSerializerMethodgetString = ClazzContainer.getIChatBaseComponent().getDeclaredMethod("getText");
}else{
chatSerializerMethodgetString = ClazzContainer.getIChatBaseComponent().getDeclaredMethod("getString");
}
}
return (String) chatSerializerMethodgetString.invoke(serializer);
//return (String) ClazzContainer.getIChatBaseComponent().cast(chatSerializerMethodgetString.invoke(serializer));
}
public static Object asChatSerializer(String json) throws Exception {
try {
if (Version.ServerVersion.isCurrentEqualOrHigher(Version.ServerVersion.v1_17_R1)){
if (chatSerializer==null){
chatSerializer = Class.forName("net.minecraft.network.chat.IChatBaseComponent$ChatSerializer");
}
}else{
if (chatSerializer==null){
chatSerializer = Class.forName("net.minecraft.server." + Version.ServerVersion.getArrayVersion()[3] + ".IChatBaseComponent$ChatSerializer");
}
}
if (chatSerializerMethodA == null) {
chatSerializerMethodA = chatSerializer.getMethod("a", String.class);
}
} catch (Exception e){
e.printStackTrace();
}
return chatSerializerMethodA.invoke(chatSerializer,json);
//return ClazzContainer.getIChatBaseComponent().cast(chatSerializerMethodA.invoke(chatSerializer, json));
}
*/
/*public static Class<?> getNMSClassRegex(String nmsClass) {
String version = null;
Pattern pat = Pattern.compile("net\\.minecraft\\.(?:server)?\\.(v(?:\\d_)+R\\d)");
for (Package p : Package.getPackages()) {
String name = p.getName();
Matcher m = pat.matcher(name);
if (m.matches()) version = m.group(1);
}
if (version == null) return null;
try {
return Class.forName(String.format(nmsClass, version));
} catch (ClassNotFoundException e) {
return null;
}
}*//*
}
*/

View File

@ -11,6 +11,9 @@
# ██████╔╝██║██║░╚═╝░██║██║░░░░░███████╗██║██║░░░░░░░░██║░░░░░░██║░░░╚█████╔╝╚█████╔╝███████╗██████╔╝
# ╚═════╝░╚═╝╚═╝░░░░░╚═╝╚═╝░░░░░╚══════╝╚═╝╚═╝░░░░░░░░╚═╝░░░░░░╚═╝░░░░╚════╝░░╚════╝░╚══════╝╚═════╝░
#
# Localization options
# Currently these languages included by default: en, hu. You can add another language in the lang folder.
language: 'en'
# Logging options
# If you enable one of them, a txt file will be created every day automatically with the current date.
Log:
@ -61,14 +64,14 @@ Tab:
CustomMsg:
enabled: false
connect: '{PREFIX}{NAME} &aconnected to the server.'
disconnect: '{PREFIX}{NAME} leaved the game.'
disconnect: '{PREFIX}{NAME} left the game.'
# Auto Save options
# Saves Worlds/Users data to disk.
# 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.
Saving:
enabled: true
enabled: false
onDisconnect: true # When a player disconnects
interval: 1800 # Auto saving interval in SECONDS. If this set to zero it means disabled.
broadcastMsgProgress: '{PREFIX}Auto save in progress..'
@ -81,6 +84,12 @@ 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
# Cooldown options (only applicable for this plugin!)

View File

@ -0,0 +1,39 @@
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!"

View File

@ -0,0 +1,39 @@
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!"

View File

@ -53,8 +53,18 @@ commands:
description: Plugin settings reload.
usage: "/st reload"
permission: st.reload
slogin:
description: Server password login.
usage: "/slogin <PASSWORD>"
permission: st.slogin
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:
description: Enables the help command.
default: true