Refactoring
This commit is contained in:
parent
d40a47a783
commit
83412fd574
@ -6,7 +6,7 @@ import hu.ditservices.handlers.TabHandler;
|
|||||||
import hu.ditservices.utils.*;
|
import hu.ditservices.utils.*;
|
||||||
import hu.ditservices.utils.Math;
|
import hu.ditservices.utils.Math;
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
import hu.ditservices.commands.DitCmd;
|
import hu.ditservices.handlers.CommandHandler;
|
||||||
import hu.ditservices.listeners.ChatEvents;
|
import hu.ditservices.listeners.ChatEvents;
|
||||||
import hu.ditservices.listeners.LogChat;
|
import hu.ditservices.listeners.LogChat;
|
||||||
import hu.ditservices.listeners.LogCommand;
|
import hu.ditservices.listeners.LogCommand;
|
||||||
@ -41,98 +41,133 @@ public final class STPlugin extends JavaPlugin implements CommandExecutor, Liste
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
|
if (this.initPlugin()) {
|
||||||
|
this.log.info(ChatColor.stripColor(this.getPrefix())+"Started running.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void scheduleTasks() {
|
||||||
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new TPS(), 0, 1);
|
||||||
|
|
||||||
|
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 {
|
try {
|
||||||
this.Init();
|
this.ServerStartTime = ManagementFactory.getRuntimeMXBean().getStartTime();
|
||||||
|
if (Version.ServerVersion.isCurrentLower(Version.ServerVersion.v1_12_R1) ||
|
||||||
|
Version.ServerVersion.isCurrentHigher(Version.ServerVersion.v1_20_R1))
|
||||||
|
{
|
||||||
|
throw new Exception("The server version is not supported! Update to a version between 1.12 - 1.20.1 to run this plugin.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.Reload()) {
|
||||||
|
TabHandler tab = new TabHandler();
|
||||||
|
|
||||||
|
PluginCommand stCommand = this.getCommand("st");
|
||||||
|
stCommand.setExecutor(new CommandHandler(this));
|
||||||
|
stCommand.setTabCompleter(new DITTabCompleter());
|
||||||
|
|
||||||
|
registerEvents();
|
||||||
|
scheduleTasks();
|
||||||
|
initUpdateChecker();
|
||||||
|
initMetrics();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
this.log.warning("[SimplifyTools] - INITIALIZATION ERROR: "+e.getMessage());
|
this.log.warning("[SimplifyTools] - INITIALIZATION ERROR: " + e.getMessage());
|
||||||
this.log.warning("[SimplifyTools] - Plugin disabled!");
|
this.log.warning("[SimplifyTools] - Plugin disabled!");
|
||||||
this.setEnabled(false);
|
this.setEnabled(false);
|
||||||
return;
|
return false;
|
||||||
}
|
|
||||||
this.log.info(ChatColor.stripColor(this.getPrefix())+"Started running.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void Init() throws Exception {
|
|
||||||
this.ServerStartTime = ManagementFactory.getRuntimeMXBean().getStartTime();
|
|
||||||
if (Version.ServerVersion.isCurrentLower(Version.ServerVersion.v1_12_R1)){
|
|
||||||
throw new Exception("The server version is not supported! Update to a version between 1.12 - 1.20.1 to run this plugin.");
|
|
||||||
}
|
|
||||||
if (this.Reload()){
|
|
||||||
|
|
||||||
|
|
||||||
TabHandler tab = new TabHandler();
|
|
||||||
PluginCommand ditCmd = this.getCommand("st");
|
|
||||||
ditCmd.setExecutor(new DitCmd(this));
|
|
||||||
ditCmd.setTabCompleter(new DITTabCompleter());
|
|
||||||
|
|
||||||
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!");
|
|
||||||
}
|
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new TPS(), 0, 1);
|
|
||||||
|
|
||||||
if (this.config.getBoolean("Saving.enabled") && this.config.getInt("Saving.interval")>0){
|
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new SaveHandler(), 0L, Math.convert(Math.Convert.SECONDS,Math.Convert.TICKS,instance.config.getInt("Saving.interval")));
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
|
|
||||||
Metrics metrics = new Metrics(this, 15108);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the plugin's prefix.
|
||||||
|
*
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
public String getPrefix(){
|
public String getPrefix(){
|
||||||
if (this.config.isSet("Prefix") && !Objects.requireNonNull(this.config.getString("Prefix")).isEmpty()){
|
if (this.config.isSet("Prefix") && !Objects.requireNonNull(this.config.getString("Prefix")).isEmpty()) {
|
||||||
return ChatColor.translateAlternateColorCodes('&', this.config.getString("Prefix"));
|
return ChatColor.translateAlternateColorCodes('&', this.config.getString("Prefix"));
|
||||||
}else{
|
}else{
|
||||||
return ChatColor.translateAlternateColorCodes('&',"&a[&fSimplify&7Tools&2] &4- &f");
|
return ChatColor.translateAlternateColorCodes('&',"&a[&fSimplify&7Tools&2] &4- &f");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the main plugin instance.
|
||||||
|
*
|
||||||
|
* @return STPlugin
|
||||||
|
*/
|
||||||
public static STPlugin getInstance(){
|
public static STPlugin getInstance(){
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getUptime(){
|
/**
|
||||||
int uptime = (int)(System.currentTimeMillis() - instance.ServerStartTime)/1000;
|
* Gets the server's uptime in a human readable format.
|
||||||
String returnText = "";
|
*
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
public static String getUptime() {
|
||||||
|
long uptime = (System.currentTimeMillis() - instance.ServerStartTime) / 1000;
|
||||||
|
StringBuilder returnText = new StringBuilder();
|
||||||
|
|
||||||
// Get remaining seconds from total minutes.
|
int days = (int) (uptime / 86400);
|
||||||
int seconds = uptime % 60;
|
int hours = (int) ((uptime % 86400) / 3600);
|
||||||
// Convert to minutes, get remaining minutes from total hours.
|
int minutes = (int) ((uptime % 3600) / 60);
|
||||||
int minutes = (uptime / 60) % 60;
|
int seconds = (int) (uptime % 60);
|
||||||
// Convert to hours, get remaining hours from total days.
|
|
||||||
int hours = (uptime / 3600) % 24;
|
|
||||||
// Convert to days.
|
|
||||||
int days = uptime / 86400;
|
|
||||||
|
|
||||||
if (days>1){
|
if (days > 1) {
|
||||||
returnText = returnText+ days+" days ";
|
returnText.append(days).append(" days ");
|
||||||
}
|
}
|
||||||
if (hours>1){
|
if (hours > 1) {
|
||||||
returnText = returnText+ hours+ " hours ";
|
returnText.append(hours).append(" hours ");
|
||||||
}
|
}
|
||||||
if (minutes>1){
|
if (minutes > 1) {
|
||||||
returnText = returnText+ minutes+ " min ";
|
returnText.append(minutes).append(" min ");
|
||||||
}
|
}
|
||||||
if (seconds>1){
|
if (seconds > 1) {
|
||||||
returnText = returnText+ seconds+ "s ";
|
returnText.append(seconds).append("s ");
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnText;
|
return returnText.toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean Reload(){
|
public boolean Reload(){
|
||||||
@ -153,6 +188,6 @@ public final class STPlugin extends JavaPlugin implements CommandExecutor, Liste
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
this.log.info(ChatColor.stripColor(this.getPrefix()) + "Started running.");
|
this.log.info(ChatColor.stripColor(this.getPrefix()) + "Stopped running.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class PingCmd {
|
public class PingCommand {
|
||||||
public static boolean Run(CommandSender sender) {
|
public static boolean Run(CommandSender sender) {
|
||||||
STPlugin plugin = STPlugin.getInstance();
|
STPlugin plugin = STPlugin.getInstance();
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
@ -7,7 +7,7 @@ import hu.ditservices.STPlugin;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
|
||||||
public class PluginCmd {
|
public class PluginManagerCommand {
|
||||||
public static boolean LoadPlugin(CommandSender sender, String[] args){
|
public static boolean LoadPlugin(CommandSender sender, String[] args){
|
||||||
Plugin plugin = Bukkit.getPluginManager().getPlugin(args[2]);
|
Plugin plugin = Bukkit.getPluginManager().getPlugin(args[2]);
|
||||||
if (plugin == null) {
|
if (plugin == null) {
|
@ -4,7 +4,7 @@ import hu.ditservices.STPlugin;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
public class SaveCmd {
|
public class SaveCommand {
|
||||||
/**
|
/**
|
||||||
* Saves all worlds and players data.
|
* Saves all worlds and players data.
|
||||||
*
|
*
|
@ -6,7 +6,7 @@ import org.bukkit.Statistic;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class StatCmd {
|
public class StatCommand {
|
||||||
public static boolean Run(CommandSender sender){
|
public static boolean Run(CommandSender sender){
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
@ -1,5 +1,9 @@
|
|||||||
package hu.ditservices.commands;
|
package hu.ditservices.handlers;
|
||||||
|
|
||||||
|
import hu.ditservices.commands.PingCommand;
|
||||||
|
import hu.ditservices.commands.PluginManagerCommand;
|
||||||
|
import hu.ditservices.commands.SaveCommand;
|
||||||
|
import hu.ditservices.commands.StatCommand;
|
||||||
import hu.ditservices.utils.TPS;
|
import hu.ditservices.utils.TPS;
|
||||||
import hu.ditservices.STPlugin;
|
import hu.ditservices.STPlugin;
|
||||||
import hu.ditservices.utils.Cooldown;
|
import hu.ditservices.utils.Cooldown;
|
||||||
@ -9,20 +13,20 @@ import org.bukkit.command.*;
|
|||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class DitCmd implements CommandExecutor {
|
public class CommandHandler implements CommandExecutor {
|
||||||
private final String noArgMsg;
|
private final String noArgMsg;
|
||||||
private final STPlugin plugin;
|
private final STPlugin plugin;
|
||||||
private final Cooldown cd;
|
private final Cooldown cd;
|
||||||
private final FileConfiguration config;
|
private final FileConfiguration config;
|
||||||
|
|
||||||
public DitCmd(final STPlugin instance){
|
public CommandHandler(final STPlugin instance) {
|
||||||
this.plugin = 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 + "To list all SimplifyTools commands use the '/help SIMPLIFYTOOLS' command!";
|
||||||
this.cd = new Cooldown(plugin);
|
this.cd = new Cooldown(plugin);
|
||||||
this.config = plugin.config;
|
this.config = plugin.config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addToCoolDown(CommandSender sender){
|
public boolean addToCoolDown(CommandSender sender) {
|
||||||
if (sender instanceof Player){
|
if (sender instanceof Player){
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
this.cd.Add(p);
|
this.cd.Add(p);
|
||||||
@ -36,9 +40,13 @@ public class DitCmd implements CommandExecutor {
|
|||||||
if (command.getName().equals("st")){
|
if (command.getName().equals("st")){
|
||||||
|
|
||||||
if (cd.Check(sender)){
|
if (cd.Check(sender)){
|
||||||
|
|
||||||
|
if (command.getName().equals("st")) {
|
||||||
|
this.addToCoolDown(sender);
|
||||||
|
}
|
||||||
|
|
||||||
if (command.getName().equals("st") && args.length==0)
|
if (command.getName().equals("st") && args.length==0)
|
||||||
{
|
{
|
||||||
this.addToCoolDown(sender);
|
|
||||||
sender.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Version: "+plugin.getDescription().getVersion());
|
sender.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Version: "+plugin.getDescription().getVersion());
|
||||||
sender.sendMessage(this.noArgMsg);
|
sender.sendMessage(this.noArgMsg);
|
||||||
return true;
|
return true;
|
||||||
@ -51,7 +59,6 @@ public class DitCmd implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
if (command.getName().equals("st") && args[0].contains("settings"))
|
if (command.getName().equals("st") && args[0].contains("settings"))
|
||||||
{
|
{
|
||||||
this.addToCoolDown(sender);
|
|
||||||
sender.sendMessage(plugin.getPrefix()+ ChatColor.GREEN+" === Plugin Information === ");
|
sender.sendMessage(plugin.getPrefix()+ ChatColor.GREEN+" === Plugin Information === ");
|
||||||
sender.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Plugin Version: "+plugin.getDescription().getVersion());
|
sender.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Plugin Version: "+plugin.getDescription().getVersion());
|
||||||
sender.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Server Version: "+ Version.ServerVersion.getCurrent().toString());
|
sender.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Server Version: "+ Version.ServerVersion.getCurrent().toString());
|
||||||
@ -65,7 +72,6 @@ public class DitCmd implements CommandExecutor {
|
|||||||
if (command.getName().equals("st") && args[0].contains("reload") && sender.hasPermission("st.reload")){
|
if (command.getName().equals("st") && args[0].contains("reload") && sender.hasPermission("st.reload")){
|
||||||
|
|
||||||
if(plugin.Reload()){
|
if(plugin.Reload()){
|
||||||
this.addToCoolDown(sender);
|
|
||||||
sender.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Successfully reload!");
|
sender.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Successfully reload!");
|
||||||
sender.sendMessage(plugin.getPrefix()+ChatColor.RED+"Notice: Restart your server if the settings didn't applied.");
|
sender.sendMessage(plugin.getPrefix()+ChatColor.RED+"Notice: Restart your server if the settings didn't applied.");
|
||||||
return true;
|
return true;
|
||||||
@ -73,16 +79,13 @@ public class DitCmd implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (command.getName().equals("st") && args[0].contains("tps") && sender.hasPermission("st.tps")){
|
if (command.getName().equals("st") && args[0].contains("tps") && sender.hasPermission("st.tps")){
|
||||||
this.addToCoolDown(sender);
|
|
||||||
sender.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Plugin Calculated TPS: "+TPS.getColor()+String.format("%.2f", TPS.getTPS()));
|
sender.sendMessage(plugin.getPrefix()+ChatColor.GREEN+"Plugin Calculated TPS: "+TPS.getColor()+String.format("%.2f", TPS.getTPS()));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.getName().equalsIgnoreCase("st") && args[0].contains("pmanager")){
|
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.hasPermission("st.pmanager.unload") || sender.hasPermission("st.pmanager.load") || sender.hasPermission("st.pmanager")) {
|
||||||
this.addToCoolDown(sender);
|
|
||||||
if (args.length==1){
|
if (args.length==1){
|
||||||
sender.sendMessage(plugin.getPrefix()+ChatColor.DARK_RED+"Invalid arguments!");
|
sender.sendMessage(plugin.getPrefix()+ChatColor.DARK_RED+"Invalid arguments!");
|
||||||
return true;
|
return true;
|
||||||
@ -90,11 +93,11 @@ public class DitCmd implements CommandExecutor {
|
|||||||
if (config.getBoolean("PluginManager.enabled")) {
|
if (config.getBoolean("PluginManager.enabled")) {
|
||||||
if (args[1].equalsIgnoreCase("load")) {
|
if (args[1].equalsIgnoreCase("load")) {
|
||||||
//PluginCmd.handleLoad(sender,args);
|
//PluginCmd.handleLoad(sender,args);
|
||||||
PluginCmd.LoadPlugin(sender,args);
|
PluginManagerCommand.LoadPlugin(sender,args);
|
||||||
}
|
}
|
||||||
if (args[1].equalsIgnoreCase("unload")) {
|
if (args[1].equalsIgnoreCase("unload")) {
|
||||||
//PluginCmd.handleUnload(sender,args);
|
//PluginCmd.handleUnload(sender,args);
|
||||||
PluginCmd.UnloadPlugin(sender, args);
|
PluginManagerCommand.UnloadPlugin(sender, args);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(plugin.getPrefix()+ChatColor.DARK_RED+"Plugin manager commands are disabled in the config!");
|
sender.sendMessage(plugin.getPrefix()+ChatColor.DARK_RED+"Plugin manager commands are disabled in the config!");
|
||||||
@ -105,17 +108,14 @@ public class DitCmd implements CommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
if (command.getName().equalsIgnoreCase("st") && args[0].contains("save-all") && sender.hasPermission("st.save")){
|
if (command.getName().equalsIgnoreCase("st") && args[0].contains("save-all") && sender.hasPermission("st.save")){
|
||||||
this.addToCoolDown(sender);
|
return SaveCommand.Run();
|
||||||
return SaveCmd.Run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.getName().equalsIgnoreCase("st") && args[0].contains("ping") && sender.hasPermission("st.ping")){
|
if (command.getName().equalsIgnoreCase("st") && args[0].contains("ping") && sender.hasPermission("st.ping")){
|
||||||
this.addToCoolDown(sender);
|
return PingCommand.Run(sender);
|
||||||
return PingCmd.Run(sender);
|
|
||||||
}
|
}
|
||||||
if (command.getName().equalsIgnoreCase("st") && args[0].contains("stats") && sender.hasPermission("st.stats")){
|
if (command.getName().equalsIgnoreCase("st") && args[0].contains("stats") && sender.hasPermission("st.stats")){
|
||||||
this.addToCoolDown(sender);
|
return StatCommand.Run(sender);
|
||||||
return StatCmd.Run(sender);
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
cd.CDText(sender);
|
cd.CDText(sender);
|
@ -44,40 +44,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) {
|
if (args.length == 3) {
|
||||||
result.clear();
|
result.clear();
|
||||||
PluginManager pm = Bukkit.getServer().getPluginManager();
|
PluginManager pm = Bukkit.getServer().getPluginManager();
|
||||||
for (Plugin pl : pm.getPlugins()) {
|
for (Plugin pl : pm.getPlugins()) {
|
||||||
if (pl.getName().toLowerCase().startsWith(args[2].toLowerCase()) && args[1].equalsIgnoreCase("unload")) {
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,10 +1,10 @@
|
|||||||
package hu.ditservices.handlers;
|
package hu.ditservices.handlers;
|
||||||
|
|
||||||
import hu.ditservices.commands.SaveCmd;
|
import hu.ditservices.commands.SaveCommand;
|
||||||
|
|
||||||
public class SaveHandler implements Runnable{
|
public class SaveHandler implements Runnable{
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
SaveCmd.Run();
|
SaveCommand.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,9 @@ public class LogConnect implements Listener {
|
|||||||
public LogConnect(STPlugin instance){
|
public LogConnect(STPlugin instance){
|
||||||
this.plugin = instance;
|
this.plugin = instance;
|
||||||
this.config = plugin.config;
|
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} leaved the game.";
|
this.LeaveMsg = this.config.isSet("CustomMsg.connect") ? this.config.getString("CustomMsg.disconnect") : "{PREFIX}{NAME} left the game.";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user