diff --git a/.idea/RhinoSourceMEMES.iml b/.idea/RhinoSourceMEMES.iml
new file mode 100644
index 0000000..4fd5057
--- /dev/null
+++ b/.idea/RhinoSourceMEMES.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..998d0bf
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..15a15b2
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__cglib_cglib_nodep_2_2_2.xml b/.idea/libraries/Maven__cglib_cglib_nodep_2_2_2.xml
new file mode 100644
index 0000000..5145a35
--- /dev/null
+++ b/.idea/libraries/Maven__cglib_cglib_nodep_2_2_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_google_code_gson_gson_2_8_2.xml b/.idea/libraries/Maven__com_google_code_gson_gson_2_8_2.xml
new file mode 100644
index 0000000..49c91be
--- /dev/null
+++ b/.idea/libraries/Maven__com_google_code_gson_gson_2_8_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_thoughtworks_proxytoys_proxytoys_1_0.xml b/.idea/libraries/Maven__com_thoughtworks_proxytoys_proxytoys_1_0.xml
new file mode 100644
index 0000000..37cc5d8
--- /dev/null
+++ b/.idea/libraries/Maven__com_thoughtworks_proxytoys_proxytoys_1_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_commons_commons_collections4_4_0.xml b/.idea/libraries/Maven__org_apache_commons_commons_collections4_4_0.xml
new file mode 100644
index 0000000..28cee2a
--- /dev/null
+++ b/.idea/libraries/Maven__org_apache_commons_commons_collections4_4_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_commons_commons_lang3_3_8_1.xml b/.idea/libraries/Maven__org_apache_commons_commons_lang3_3_8_1.xml
new file mode 100644
index 0000000..33b78e9
--- /dev/null
+++ b/.idea/libraries/Maven__org_apache_commons_commons_lang3_3_8_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_commons_commons_pool2_2_4_2.xml b/.idea/libraries/Maven__org_apache_commons_commons_pool2_2_4_2.xml
new file mode 100644
index 0000000..2970b5e
--- /dev/null
+++ b/.idea/libraries/Maven__org_apache_commons_commons_pool2_2_4_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_mongodb_mongo_java_driver_3_4_0.xml b/.idea/libraries/Maven__org_mongodb_mongo_java_driver_3_4_0.xml
new file mode 100644
index 0000000..e670f92
--- /dev/null
+++ b/.idea/libraries/Maven__org_mongodb_mongo_java_driver_3_4_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_mongodb_morphia_morphia_1_3_2.xml b/.idea/libraries/Maven__org_mongodb_morphia_morphia_1_3_2.xml
new file mode 100644
index 0000000..72d9cee
--- /dev/null
+++ b/.idea/libraries/Maven__org_mongodb_morphia_morphia_1_3_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_projectlombok_lombok_1_16_18.xml b/.idea/libraries/Maven__org_projectlombok_lombok_1_16_18.xml
new file mode 100644
index 0000000..8503cb4
--- /dev/null
+++ b/.idea/libraries/Maven__org_projectlombok_lombok_1_16_18.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__redis_clients_jedis_2_9_0.xml b/.idea/libraries/Maven__redis_clients_jedis_2_9_0.xml
new file mode 100644
index 0000000..77144ff
--- /dev/null
+++ b/.idea/libraries/Maven__redis_clients_jedis_2_9_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..d1eecca
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..c58f8d5
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..0dd4dc0
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,761 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Checker
+ LicenseChecker
+ StaffTab
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1546277398574
+
+
+ 1546277398574
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No facets are configured
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+ HCF
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+ Maven: cglib:cglib-nodep:2.2.2
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Base/Base.iml b/Base/Base.iml
new file mode 100644
index 0000000..f752fae
--- /dev/null
+++ b/Base/Base.iml
@@ -0,0 +1,86 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Base/lib/LiteBans.jar b/Base/lib/LiteBans.jar
new file mode 100644
index 0000000..1726e0d
Binary files /dev/null and b/Base/lib/LiteBans.jar differ
diff --git a/Base/lib/ProtocolLib.jar b/Base/lib/ProtocolLib.jar
new file mode 100644
index 0000000..3a79b59
Binary files /dev/null and b/Base/lib/ProtocolLib.jar differ
diff --git a/Base/lib/SAPI.jar b/Base/lib/SAPI.jar
new file mode 100644
index 0000000..c9a79e2
Binary files /dev/null and b/Base/lib/SAPI.jar differ
diff --git a/Base/lib/Spigot.jar b/Base/lib/Spigot.jar
new file mode 100644
index 0000000..ce67c5c
Binary files /dev/null and b/Base/lib/Spigot.jar differ
diff --git a/Base/lib/Vault.jar b/Base/lib/Vault.jar
new file mode 100644
index 0000000..63fc042
Binary files /dev/null and b/Base/lib/Vault.jar differ
diff --git a/Base/lib/WorldEdit-6.2.jar b/Base/lib/WorldEdit-6.2.jar
new file mode 100644
index 0000000..05d3087
Binary files /dev/null and b/Base/lib/WorldEdit-6.2.jar differ
diff --git a/Base/lib/nucleusapi.jar b/Base/lib/nucleusapi.jar
new file mode 100644
index 0000000..514de59
Binary files /dev/null and b/Base/lib/nucleusapi.jar differ
diff --git a/Base/pom.xml b/Base/pom.xml
new file mode 100644
index 0000000..1a2a9a8
--- /dev/null
+++ b/Base/pom.xml
@@ -0,0 +1,131 @@
+
+
+
+ RhinoHCF
+ com.sergivb01.rhinohcf
+ 1.0-SNAPSHOT
+
+
+ 4.0.0
+
+ Base
+
+ clean install
+
+
+ src/main/resources
+ true
+
+
+
+
+ 3.6.1
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ 1.8
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.0.0
+
+
+ false
+ false
+
+
+
+ package
+
+ shade
+
+
+
+
+
+
+
+
+
+ org.paperspigot
+ API
+ 1.7.10-R0.1-SNAPSHOT
+ system
+ ${project.basedir}/lib/SAPI.jar
+
+
+ org.projectlombok
+ lombok
+ 1.16.18
+
+
+ redis.clients
+ jedis
+ 2.9.0
+
+
+ com.google.code.gson
+ gson
+ 2.8.2
+
+
+ org.apache.commons
+ commons-collections4
+ 4.0
+ compile
+
+
+ org.mongodb.morphia
+ morphia
+ 1.3.2
+
+
+ com.sevenxsix
+ PL
+ 1.7.10-R0.1-SNAPSHOT
+ system
+ ${project.basedir}/lib/ProtocolLib.jar
+
+
+ com.sevenxsix
+ LB
+ 1.7.10-R0.1-SNAPSHOT
+ system
+ ${project.basedir}/lib/LiteBans.jar
+
+
+ com.sevenxsix
+ Worldedit
+ 1.7.10-R0.1-SNAPSHOT
+ system
+ ${project.basedir}/lib/WorldEdit-6.2.jar
+
+
+ com.sevenxsix
+ Vault
+ 1.7.10-R0.1-SNAPSHOT
+ system
+ ${project.basedir}/lib/Vault.jar
+
+
+ me.joeleoli.nucleus
+ Nucleus
+ 1.0-SNAPSHOT
+ system
+ ${project.basedir}/lib/nucleusapi.jar
+
+
+ org.paperspigot
+ Spigot
+ 1.7.10-R0.1-SNAPSHOT
+ system
+ ${project.basedir}/lib/Spigot.jar
+
+
+
+
\ No newline at end of file
diff --git a/Base/src/main/java/com/sergivb01/base/BaseConstants.java b/Base/src/main/java/com/sergivb01/base/BaseConstants.java
new file mode 100644
index 0000000..4998068
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/BaseConstants.java
@@ -0,0 +1,8 @@
+package com.sergivb01.base;
+
+import org.bukkit.ChatColor;
+
+public final class BaseConstants{
+ public static final String PLAYER_WITH_NAME_OR_UUID_NOT_FOUND = ChatColor.RED + "Player '" + ChatColor.WHITE + "%1$s" + ChatColor.RED + "' not found.";
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/BasePlugin.java b/Base/src/main/java/com/sergivb01/base/BasePlugin.java
new file mode 100644
index 0000000..0258dc7
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/BasePlugin.java
@@ -0,0 +1,227 @@
+package com.sergivb01.base;
+
+import com.sergivb01.base.command.CommandManager;
+import com.sergivb01.base.command.SimpleCommandManager;
+import com.sergivb01.base.command.module.ChatModule;
+import com.sergivb01.base.command.module.EssentialModule;
+import com.sergivb01.base.command.module.InventoryModule;
+import com.sergivb01.base.command.module.TeleportModule;
+import com.sergivb01.base.command.module.essential.PunishCommand;
+import com.sergivb01.base.command.module.essential.ReportCommand;
+import com.sergivb01.base.command.module.teleport.WorldCommand;
+import com.sergivb01.base.kit.*;
+import com.sergivb01.base.listener.*;
+import com.sergivb01.base.task.AnnouncementHandler;
+import com.sergivb01.base.task.AutoRestartHandler;
+import com.sergivb01.base.task.ClearEntityHandler;
+import com.sergivb01.base.user.*;
+import com.sergivb01.base.warp.FlatFileWarpManager;
+import com.sergivb01.base.warp.Warp;
+import com.sergivb01.base.warp.WarpManager;
+import com.sergivb01.util.PersistableLocation;
+import com.sergivb01.util.RandomUtils;
+import com.sergivb01.util.SignHandler;
+import com.sergivb01.util.bossbar.BossBarManager;
+import com.sergivb01.util.chat.Lang;
+import com.sergivb01.util.cuboid.Cuboid;
+import com.sergivb01.util.cuboid.NamedCuboid;
+import com.sergivb01.util.itemdb.ItemDb;
+import com.sergivb01.util.itemdb.SimpleItemDb;
+import lombok.Getter;
+import net.milkbowl.vault.chat.Chat;
+import net.milkbowl.vault.economy.Economy;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.configuration.serialization.ConfigurationSerialization;
+import org.bukkit.permissions.Permission;
+import org.bukkit.plugin.PluginManager;
+import org.bukkit.plugin.RegisteredServiceProvider;
+import org.bukkit.plugin.java.JavaPlugin;
+import org.bukkit.scheduler.BukkitRunnable;
+
+import java.io.IOException;
+import java.util.Random;
+
+@Getter
+public class BasePlugin extends JavaPlugin{
+ private static BasePlugin plugin;
+ private static Permission perms = null;
+ private static Chat chat = null;
+ private static Economy economy = null;
+ public BukkitRunnable announcementTask;
+ private ItemDb itemDb;
+ private Random random = new Random();
+ private WarpManager warpManager;
+ private RandomUtils randomUtils;
+ private AutoRestartHandler autoRestartHandler;
+ private BukkitRunnable clearEntityHandler;
+ private CommandManager commandManager;
+ private KitManager kitManager;
+ private PlayTimeManager playTimeManager;
+ private ServerHandler serverHandler;
+ // private ConfigFile langFile;
+ private SignHandler signHandler;
+ private UserManager userManager;
+ private KitExecutor kitExecutor;
+
+ public static Chat getChat(){
+ return chat;
+ }
+
+ public static BasePlugin getPlugin(){
+ return plugin;
+ }
+
+ public void onEnable(){
+ if(getConfig().getBoolean("nucleus")) {
+ getLogger().severe("Using nucleus as dependency");
+ } else {
+ if(!setupChat()){
+ getLogger().severe("Could not find Vault dependency!");
+ getServer().getPluginManager().disablePlugin(this);
+ return;
+ }
+ }
+
+ plugin = this;
+
+ Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
+
+ ConfigurationSerialization.registerClass(Warp.class);
+ ConfigurationSerialization.registerClass(ServerParticipator.class);
+ ConfigurationSerialization.registerClass(BaseUser.class);
+ ConfigurationSerialization.registerClass(ConsoleUser.class);
+ ConfigurationSerialization.registerClass(NameHistory.class);
+ ConfigurationSerialization.registerClass(PersistableLocation.class);
+ ConfigurationSerialization.registerClass(Cuboid.class);
+ ConfigurationSerialization.registerClass(NamedCuboid.class);
+ ConfigurationSerialization.registerClass(Kit.class);
+
+ registerManagers();
+ registerCommands();
+ registerListeners();
+ reloadSchedulers();
+
+ Bukkit.getConsoleSender().sendMessage("");
+ Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[" + getDescription().getName() + "] Plugin loaded!"));
+ Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[" + getDescription().getName() + "] &eVersion: " + getDescription().getVersion()));
+ Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[" + getDescription().getName() + "] &eVault: &aHOOKED"));
+ Bukkit.getConsoleSender().sendMessage("");
+
+ Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), "clearlag 100000");
+
+ }
+
+ private boolean setupChat(){
+ if(getServer().getPluginManager().getPlugin("Vault") == null){
+ getLogger().severe("DB: Vault plugin = null");
+ return false;
+ }
+ RegisteredServiceProvider rsp = getServer().getServicesManager().getRegistration(Chat.class);
+ if(rsp == null){
+ getLogger().severe("rsp = null");
+ return false;
+ }
+ chat = rsp.getProvider();
+ return chat != null;
+ }
+
+ private boolean setupPermissions(){
+ if(this.getConfig().getBoolean("nucleus")) {
+ return true;
+ }
+ RegisteredServiceProvider rsp = getServer().getServicesManager().getRegistration(Permission.class);
+ perms = rsp.getProvider();
+ return perms != null;
+ }
+
+ public void onDisable(){
+ super.onDisable();
+
+ getLogger().info(String.format("[%s] Disabled Version %s", getDescription().getName(), getDescription().getVersion()));
+
+
+ kitManager.saveKitData();
+ playTimeManager.savePlaytimeData();
+ serverHandler.saveServerData();
+ signHandler.cancelTasks(null);
+ userManager.saveParticipatorData();
+ warpManager.saveWarpData();
+
+ plugin = null;
+ }
+
+ private void registerManagers(){
+ BossBarManager.hook();
+
+ randomUtils = new RandomUtils();
+ autoRestartHandler = new AutoRestartHandler(this);
+ kitManager = new FlatFileKitManager(this);
+ serverHandler = new ServerHandler(this);
+ signHandler = new SignHandler(this);
+ userManager = new UserManager(this);
+ itemDb = new SimpleItemDb(this);
+ warpManager = new FlatFileWarpManager(this);
+
+ try{
+ Lang.initialize("en_US");
+ }catch(IOException ex){
+ ex.printStackTrace();
+ }
+
+ }
+
+ private void registerCommands(){
+ commandManager = new SimpleCommandManager(this);
+ commandManager.registerAll(new ChatModule(this));
+ commandManager.registerAll(new EssentialModule(this));
+ commandManager.registerAll(new InventoryModule(this));
+ commandManager.registerAll(new TeleportModule(this));
+ kitExecutor = new KitExecutor(this);
+ getCommand("kit").setExecutor(kitExecutor);
+ }
+
+ private void registerListeners(){
+ PluginManager manager = getServer().getPluginManager();
+ manager.registerEvents(new WorldCommand(), this);
+ manager.registerEvents(new ChatListener(this), this);
+ manager.registerEvents(new PunishCommand(), this);
+ manager.registerEvents(new ColouredSignListener(), this);
+ manager.registerEvents(new DecreasedLagListener(this), this);
+ manager.registerEvents(new JoinListener(this), this);
+ manager.registerEvents(new ReportCommand(), this);
+ manager.registerEvents(new KitListener(this), this);
+ manager.registerEvents(new MoveByBlockEvent(), this);
+ manager.registerEvents(new MobstackListener(), this);
+ manager.registerEvents(new StaffListener(), this);
+ manager.registerEvents(new NameVerifyListener(this), this);
+ playTimeManager = new PlayTimeManager(this);
+ manager.registerEvents(playTimeManager, this);
+ manager.registerEvents(new PlayerLimitListener(), this);
+ manager.registerEvents(new VanishListener(this), this);
+ //manager.registerEvents(new ChatCommands(), this);
+ //manager.registerEvents(new AutoMuteListener(this), this);
+ manager.registerEvents(new StaffUtilsRemoveListener(), this);
+ }
+
+ private void reloadSchedulers(){
+ ClearEntityHandler clearEntityHandler;
+ AnnouncementHandler announcementTask;
+
+ if(this.clearEntityHandler != null) this.clearEntityHandler.cancel();
+ if(this.announcementTask != null) this.announcementTask.cancel();
+
+ long announcementDelay = (long) this.serverHandler.getAnnouncementDelay() * 20;
+ long claggdelay = (long) this.serverHandler.getClearlagdelay() * 20;
+
+ this.announcementTask = announcementTask = new AnnouncementHandler(this);
+ MobstackListener mobstackListener = new MobstackListener();
+ this.clearEntityHandler = clearEntityHandler = new ClearEntityHandler();
+
+ mobstackListener.runTaskTimerAsynchronously(this, 20, 20);
+ clearEntityHandler.runTaskTimer(this, claggdelay, claggdelay);
+ announcementTask.runTaskTimer(this, announcementDelay, announcementDelay);
+ }
+
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/PlayTimeManager.java b/Base/src/main/java/com/sergivb01/base/PlayTimeManager.java
new file mode 100644
index 0000000..fe7c99f
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/PlayTimeManager.java
@@ -0,0 +1,80 @@
+package com.sergivb01.base;
+
+import com.sergivb01.util.Config;
+import net.minecraft.util.gnu.trove.map.hash.TObjectLongHashMap;
+import org.bukkit.Bukkit;
+import org.bukkit.configuration.MemorySection;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+import org.bukkit.plugin.java.JavaPlugin;
+
+import java.util.UUID;
+
+public class PlayTimeManager
+ implements Listener{
+ private final TObjectLongHashMap totalPlaytimeMap = new TObjectLongHashMap();
+ private final TObjectLongHashMap sessionTimestamps = new TObjectLongHashMap();
+ private final Config config;
+
+ public PlayTimeManager(JavaPlugin plugin){
+ this.config = new Config(plugin, "play-times");
+ this.reloadPlaytimeData();
+ }
+
+ @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
+ public void onPlayerJoin(PlayerJoinEvent event){
+ this.sessionTimestamps.put(event.getPlayer().getUniqueId(), System.currentTimeMillis());
+ }
+
+ @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
+ public void onPlayerQuit(PlayerQuitEvent event){
+ UUID uuid = event.getPlayer().getUniqueId();
+ this.totalPlaytimeMap.put(uuid, this.getTotalPlayTime(uuid));
+ this.sessionTimestamps.remove(uuid);
+ }
+
+ private void reloadPlaytimeData(){
+ Object object = this.config.get("playing-times");
+ if(object instanceof MemorySection){
+ MemorySection section = (MemorySection) object;
+ for(Object id : section.getKeys(false)){
+ this.totalPlaytimeMap.put(UUID.fromString((String) id), this.config.getLong("playing-times." + id, 0));
+ }
+ }
+ long millis = System.currentTimeMillis();
+ for(Player target : Bukkit.getServer().getOnlinePlayers()){
+ this.sessionTimestamps.put(target.getUniqueId(), millis);
+ }
+ }
+
+ public void savePlaytimeData(){
+ for(Player player : Bukkit.getServer().getOnlinePlayers()){
+ this.totalPlaytimeMap.put(player.getUniqueId(), this.getTotalPlayTime(player.getUniqueId()));
+ }
+ this.totalPlaytimeMap.forEachEntry((uuid, l) -> {
+ this.config.set("playing-times." + uuid.toString(), l);
+ return true;
+ }
+ );
+ this.config.save();
+ }
+
+ private long getSessionPlayTime(UUID uuid){
+ long session = this.sessionTimestamps.get(uuid);
+ return session != this.sessionTimestamps.getNoEntryValue() ? System.currentTimeMillis() - session : 0;
+ }
+
+ private long getPreviousPlayTime(UUID uuid){
+ long stamp = this.totalPlaytimeMap.get(uuid);
+ return stamp == this.totalPlaytimeMap.getNoEntryValue() ? 0 : stamp;
+ }
+
+ public long getTotalPlayTime(UUID uuid){
+ return this.getSessionPlayTime(uuid) + this.getPreviousPlayTime(uuid);
+ }
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/ProtocolHook.java b/Base/src/main/java/com/sergivb01/base/ProtocolHook.java
new file mode 100644
index 0000000..97c2400
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/ProtocolHook.java
@@ -0,0 +1,93 @@
+package com.sergivb01.base;
+
+import com.comphenix.protocol.PacketType;
+import com.comphenix.protocol.ProtocolLibrary;
+import com.comphenix.protocol.ProtocolManager;
+import com.comphenix.protocol.events.PacketAdapter;
+import com.comphenix.protocol.events.PacketContainer;
+import com.comphenix.protocol.events.PacketEvent;
+import com.comphenix.protocol.reflect.StructureModifier;
+import com.comphenix.protocol.wrappers.WrappedDataWatcher;
+import com.sergivb01.base.user.BaseUser;
+import com.sergivb01.base.user.UserManager;
+import org.bukkit.Material;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Item;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+
+public class ProtocolHook{
+
+ public static void hook(final BasePlugin basePlugin){
+ final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
+ final UserManager userManager = basePlugin.getUserManager();
+ protocolManager.addPacketListener(new PacketAdapter(basePlugin, PacketType.Play.Server.ENTITY_EQUIPMENT){
+ public void onPacketSending(final PacketEvent event){
+ if(!basePlugin.getServerHandler().useProtocolLib){
+ return;
+ }
+ final Player player = event.getPlayer();
+ final BaseUser baseUser = userManager.getUser(player.getUniqueId());
+ if(!baseUser.isGlintEnabled()){
+ final PacketContainer packet = event.getPacket();
+ final StructureModifier modifier = packet.getItemModifier();
+ if(modifier.size() > 0){
+ final ItemStack stack = modifier.read(0);
+ if(stack != null && stack.getType() != Material.AIR){
+ convert(stack);
+ }
+ }
+ }
+ }
+ });
+
+ protocolManager.addPacketListener(new PacketAdapter(basePlugin, PacketType.Play.Server.ENTITY_METADATA){
+ public void onPacketSending(final PacketEvent event){
+ if(!basePlugin.getServerHandler().useProtocolLib){
+ return;
+ }
+ final Player player = event.getPlayer();
+ final BaseUser baseUser = userManager.getUser(player.getUniqueId());
+ if(!baseUser.isGlintEnabled()){
+ final PacketContainer packet = event.getPacket();
+ final StructureModifier modifier = packet.getEntityModifier(event);
+ if(modifier.size() > 0 && modifier.read(0) instanceof Item){
+ final WrappedDataWatcher watcher = new WrappedDataWatcher(packet.getWatchableCollectionModifier().read(0));
+ if(watcher.size() >= 10){
+ final ItemStack stack = watcher.getItemStack(10).clone();
+ if(stack != null && stack.getType() != Material.AIR){
+ convert(stack);
+ }
+ }
+ }
+ }
+ }
+ });
+
+ }
+
+ private static void convert(final ItemStack origin){
+ if(origin == null || origin.getType() == Material.AIR){
+ return;
+ }
+ switch(origin.getType()){
+ case POTION:
+ case GOLDEN_APPLE:{
+ if(origin.getDurability() > 0){
+ origin.setDurability((short) 0);
+ break;
+ }
+ break;
+ }
+ case ENCHANTED_BOOK:{
+ origin.setType(Material.BOOK);
+ break;
+ }
+ default:{
+ origin.getEnchantments().keySet().forEach(origin::removeEnchantment);
+ break;
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/Base/src/main/java/com/sergivb01/base/ServerHandler.java b/Base/src/main/java/com/sergivb01/base/ServerHandler.java
new file mode 100644
index 0000000..06ecb52
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/ServerHandler.java
@@ -0,0 +1,166 @@
+package com.sergivb01.base;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.configuration.file.FileConfiguration;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ServerHandler{
+ @Getter
+ private final List announcements = new ArrayList();
+ private final List serverRules = new ArrayList();
+ private final BasePlugin plugin;
+ @Getter
+ @Setter
+ public boolean useProtocolLib;
+ @Getter
+ @Setter
+ private boolean kitmap;
+ @Getter
+ @Setter
+ private int clearlagdelay;
+ @Getter
+ @Setter
+ private int announcementDelay;
+ @Getter
+ @Setter
+ private long chatSlowedMillis;
+ @Setter
+ private long chatDisabledMillis;
+ @Setter
+ private int chatSlowedDelay;
+ @Getter
+ private String broadcastFormat;
+ @Getter
+ private FileConfiguration config;
+ @Getter
+ @Setter
+ private boolean decreasedLagMode;
+ @Getter
+ @Setter
+ private boolean end;
+ @Getter
+ private Location endExit;
+ @Getter
+ @Setter
+ private boolean donorOnly;
+ @Getter
+ private int worldBorder;
+ @Getter
+ private int netherBorder;
+ @Getter
+ private int endBorder;
+ @Getter
+ private boolean Lockdown;
+ @Getter
+ public String teamspeak;
+
+ public ServerHandler(BasePlugin plugin){
+ this.plugin = plugin;
+ this.config = plugin.getConfig();
+ this.reloadServerData();
+ }
+
+ public void setServerBorder(World.Environment environment, Integer integer){
+ if(environment.equals(World.Environment.NORMAL)){
+ this.worldBorder = integer;
+ }else if(environment.equals(World.Environment.NETHER)){
+ this.netherBorder = integer;
+ }else if(environment.equals(World.Environment.THE_END)){
+ this.endBorder = integer;
+ }
+ }
+
+ private void reloadServerData(){
+ this.plugin.reloadConfig();
+ this.config = this.plugin.getConfig();
+ String exitWorld = this.config.getString("end.exitLocation.world", "world");
+ double x = this.config.getDouble("end.exitLocation.x", 0.0);
+ double y = this.config.getDouble("end.exitLocation.y", 66.0);
+ double z = this.config.getDouble("end.exitLocation.z", -200.0);
+ this.endExit = new Location(Bukkit.getWorld(exitWorld), x, y, z);
+ this.donorOnly = this.config.getBoolean("donor-only-enter");
+ this.Lockdown = this.config.getBoolean("lockdown-enabled", false);
+ this.end = this.config.getBoolean("end-open");
+ this.worldBorder = this.config.getInt("border.worldBorder", 3000);
+ this.netherBorder = this.config.getInt("border.netherBorder", 1000);
+ this.endBorder = this.config.getInt("border.endBorder", 1500);
+ this.serverRules.clear();
+ this.clearlagdelay = this.config.getInt("clearlag.delay", 100000);
+ this.announcementDelay = this.config.getInt("announcements.delay", 15);
+ this.announcements.clear();
+ for(String each : this.config.getStringList("announcements.list")){
+ this.announcements.add(ChatColor.translateAlternateColorCodes('&', each));
+ }
+ this.chatDisabledMillis = this.config.getLong("chat.disabled.millis", 0);
+ this.chatSlowedMillis = this.config.getLong("chat.slowed.millis", 0);
+ this.chatSlowedDelay = this.config.getInt("chat.slowed.delay", 15);
+ this.useProtocolLib = this.config.getBoolean("use-protocol-lib", true);
+ this.decreasedLagMode = this.config.getBoolean("decreased-lag-mode");
+ this.broadcastFormat = ChatColor.translateAlternateColorCodes('&', this.config.getString("broadcast.format", ChatColor.AQUA + " &7%1$s"));
+ this.teamspeak = config.getString("teamspeak");
+ this.kitmap = this.config.getBoolean("kit-map");
+ }
+
+ public void saveServerData(){
+ this.config.set("clearlag.delay", this.clearlagdelay);
+ this.config.set("server-rules", this.serverRules);
+ this.config.set("use-protocol-lib", this.useProtocolLib);
+ this.config.set("chat.disabled.millis", this.chatDisabledMillis);
+ this.config.set("chat.slowed.millis", this.chatSlowedMillis);
+ this.config.set("chat.slowed-delay", this.chatSlowedDelay);
+ this.config.set("announcements.delay", this.announcementDelay);
+ this.config.set("announcements.list", this.announcements);
+ this.config.set("kit-map", this.kitmap);
+ this.config.set("decreased-lag-mode", this.decreasedLagMode);
+ this.config.set("end.exitLocation.world", this.endExit.getWorld().getName());
+ this.config.set("end.exitLocation.x", this.endExit.getX());
+ this.config.set("end.exitLocation.y", this.endExit.getY());
+ this.config.set("end.exitLocation.z", this.endExit.getX());
+ this.config.set("donor-only-enter", this.donorOnly);
+ this.config.set("lockdown-enabled", this.Lockdown);
+ this.config.set("end-open", this.end);
+ this.config.set("border.worldBorder", this.worldBorder);
+ this.config.set("border.netherBorder", this.netherBorder);
+ this.config.set("border.endBorder", this.endBorder);
+ this.plugin.saveConfig();
+ }
+
+
+ public void setChatSlowedMillis(long ticks){
+ this.chatSlowedMillis = System.currentTimeMillis() + ticks;
+ }
+
+ public long getRemainingChatSlowedMillis(){
+ return this.chatSlowedMillis - System.currentTimeMillis();
+ }
+
+ public boolean isChatDisabled(){
+ return this.getRemainingChatDisabledMillis() > 0;
+ }
+
+ public long getChatDisabledMillis(){
+ return this.chatDisabledMillis;
+ }
+
+ public void setChatDisabledMillis(long ticks){
+ long millis = System.currentTimeMillis();
+ this.chatDisabledMillis = millis + ticks;
+ }
+
+ public long getRemainingChatDisabledMillis(){
+ return this.chatDisabledMillis - System.currentTimeMillis();
+ }
+
+ public int getChatSlowedDelay(){
+ return this.chatSlowedDelay;
+ }
+
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/StaffPriority.java b/Base/src/main/java/com/sergivb01/base/StaffPriority.java
new file mode 100644
index 0000000..ba54eef
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/StaffPriority.java
@@ -0,0 +1,51 @@
+package com.sergivb01.base;
+
+import com.google.common.collect.ImmutableMap;
+import org.bukkit.entity.Player;
+
+public enum StaffPriority{
+ OWNER(6),
+ HEADADMIN(5),
+ STAFFMANAGER(4),
+ ADMIN(3),
+ MODERATOR(2),
+ TRIAL(1),
+ NONE(0);
+
+ private static final ImmutableMap BY_ID;
+
+ static{
+ ImmutableMap.Builder builder = new ImmutableMap.Builder();
+ for(StaffPriority staffPriority : StaffPriority.values()){
+ builder.put(staffPriority.priorityLevel, staffPriority);
+ }
+ BY_ID = builder.build();
+ }
+
+ private final int priorityLevel;
+
+ StaffPriority(int priorityLevel){
+ this.priorityLevel = priorityLevel;
+ }
+
+ public static StaffPriority of(int level){
+ return BY_ID.get(level);
+ }
+
+ public static StaffPriority of(Player player){
+ for(StaffPriority staffPriority : StaffPriority.values()){
+ if(!player.hasPermission("staffpriority." + staffPriority.priorityLevel)) continue;
+ return staffPriority;
+ }
+ return NONE;
+ }
+
+ public int getPriorityLevel(){
+ return this.priorityLevel;
+ }
+
+ public boolean isMoreThan(StaffPriority other){
+ return this.priorityLevel > other.priorityLevel;
+ }
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/BaseCommand.java b/Base/src/main/java/com/sergivb01/base/command/BaseCommand.java
new file mode 100644
index 0000000..20193a3
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/BaseCommand.java
@@ -0,0 +1,83 @@
+package com.sergivb01.base.command;
+
+import com.sergivb01.base.BaseConstants;
+import com.sergivb01.util.BukkitUtils;
+import com.sergivb01.util.command.ArgumentExecutor;
+import org.apache.commons.lang.ArrayUtils;
+import org.bukkit.ChatColor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+import java.util.Arrays;
+import java.util.regex.Pattern;
+
+public abstract class BaseCommand
+ extends ArgumentExecutor{
+ private static final Pattern USAGE_REPLACER_PATTERN = Pattern.compile("(command)", 16);
+ private final String name;
+ private final String description;
+ private String[] aliases;
+ private String usage;
+
+ public BaseCommand(String name, String description){
+ super(name);
+ this.name = name;
+ this.description = description;
+ }
+
+ public static boolean checkNull(CommandSender sender, String player){
+ Player target = BukkitUtils.playerWithNameOrUUID(player);
+ if(target == null || !BaseCommand.canSee(sender, target)){
+ sender.sendMessage(String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, player));
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean canSee(CommandSender sender, Player target){
+ return target != null && (!(sender instanceof Player) || ((Player) sender).canSee(target));
+ }
+
+ public final String getPermission(){
+ return "base.command." + this.name;
+ }
+
+ public boolean isPlayerOnlyCommand(){
+ return false;
+ }
+
+ public String getName(){
+ return this.name;
+ }
+
+ public String getDescription(){
+ return this.description;
+ }
+
+ public String getUsage(){
+ if(this.usage == null){
+ this.usage = "";
+ }
+ return ChatColor.RED + "Usage: " + USAGE_REPLACER_PATTERN.matcher(this.usage).replaceAll(this.name);
+ }
+
+ public void setUsage(String usage){
+ this.usage = usage;
+ }
+
+ public String getUsage(String label){
+ return ChatColor.RED + "" + USAGE_REPLACER_PATTERN.matcher(this.usage).replaceAll(label);
+ }
+
+ public String[] getAliases(){
+ if(this.aliases == null){
+ this.aliases = ArrayUtils.EMPTY_STRING_ARRAY;
+ }
+ return Arrays.copyOf(this.aliases, this.aliases.length);
+ }
+
+ protected void setAliases(String[] aliases){
+ this.aliases = aliases;
+ }
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/BaseCommandModule.java b/Base/src/main/java/com/sergivb01/base/command/BaseCommandModule.java
new file mode 100644
index 0000000..aaf82e3
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/BaseCommandModule.java
@@ -0,0 +1,31 @@
+package com.sergivb01.base.command;
+
+import com.google.common.collect.Sets;
+
+import java.util.Set;
+
+public abstract class BaseCommandModule{
+ protected final Set commands = Sets.newHashSet();
+ protected boolean enabled = true;
+
+ Set getCommands(){
+ return this.commands;
+ }
+
+ void unregisterCommand(BaseCommand command){
+ this.commands.remove(command);
+ }
+
+ void unregisterCommands(){
+ this.commands.clear();
+ }
+
+ boolean isEnabled(){
+ return this.enabled;
+ }
+
+ void setEnabled(boolean enabled){
+ this.enabled = enabled;
+ }
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/CommandManager.java b/Base/src/main/java/com/sergivb01/base/command/CommandManager.java
new file mode 100644
index 0000000..e190dde
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/CommandManager.java
@@ -0,0 +1,16 @@
+package com.sergivb01.base.command;
+
+public interface CommandManager{
+ boolean containsCommand(BaseCommand var1);
+
+ void registerAll(BaseCommandModule var1);
+
+ void registerCommand(BaseCommand var1);
+
+ void registerCommands(BaseCommand[] var1);
+
+ void unregisterCommand(BaseCommand var1);
+
+ BaseCommand getCommand(String var1);
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/ReflectionCommandManager.java b/Base/src/main/java/com/sergivb01/base/command/ReflectionCommandManager.java
new file mode 100644
index 0000000..fa2e552
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/ReflectionCommandManager.java
@@ -0,0 +1,125 @@
+package com.sergivb01.base.command;
+
+import com.sergivb01.base.BasePlugin;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Server;
+import org.bukkit.command.CommandMap;
+import org.bukkit.command.ConsoleCommandSender;
+import org.bukkit.command.PluginCommand;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.plugin.PluginManager;
+import org.bukkit.plugin.SimplePluginManager;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.util.*;
+
+public class ReflectionCommandManager
+ implements CommandManager{
+ private static final String PERMISSION_MESSAGE = ChatColor.RED + "You do not have permission for this command.";
+ private final Map commandMap = new HashMap();
+
+ public ReflectionCommandManager(final BasePlugin plugin){
+ final ConsoleCommandSender console = Bukkit.getConsoleSender();
+ final Server server = Bukkit.getServer();
+ server.getScheduler().runTaskLater(plugin, new Runnable(){
+
+ @Override
+ public void run(){
+ Optional optionalCommandMap = ReflectionCommandManager.this.getCommandMap(server);
+ if(!optionalCommandMap.isPresent()){
+ Bukkit.broadcastMessage("" + '[' + plugin.getDescription().getFullName() + "] Command map not found");
+ console.sendMessage("" + '[' + plugin.getDescription().getFullName() + "] Command map not found");
+ return;
+ }
+ CommandMap bukkitCommandMap = (CommandMap) optionalCommandMap.get();
+ for(BaseCommand command : ReflectionCommandManager.this.commandMap.values()){
+ String commandName = command.getName();
+ Optional optional = ReflectionCommandManager.this.getPluginCommand(commandName, plugin);
+ if(optional.isPresent()){
+ PluginCommand pluginCommand = (PluginCommand) optional.get();
+ pluginCommand.setAliases(Arrays.asList(command.getAliases()));
+ pluginCommand.setDescription(command.getDescription());
+ pluginCommand.setExecutor(command);
+ pluginCommand.setTabCompleter(command);
+ pluginCommand.setUsage(command.getUsage());
+ pluginCommand.setPermission(command.getPermission());
+ pluginCommand.setPermissionMessage(PERMISSION_MESSAGE);
+ bukkitCommandMap.register(plugin.getDescription().getName(), pluginCommand);
+ continue;
+ }
+ Bukkit.broadcastMessage("" + '[' + plugin.getName() + "] " + ChatColor.YELLOW + "Failed to register command '" + commandName + "'.");
+ console.sendMessage("" + '[' + plugin.getName() + "] " + ChatColor.YELLOW + "Failed to register command '" + commandName + "'.");
+ }
+ }
+ }, 1);
+ }
+
+ @Override
+ public boolean containsCommand(BaseCommand command){
+ return this.commandMap.containsValue(command);
+ }
+
+ @Override
+ public void registerAll(BaseCommandModule module){
+ if(module.isEnabled()){
+ Set commands = module.getCommands();
+ for(BaseCommand command : commands){
+ this.commandMap.put(command.getName(), command);
+ }
+ }
+ }
+
+ @Override
+ public void registerCommand(BaseCommand command){
+ this.commandMap.put(command.getName(), command);
+ }
+
+ @Override
+ public void registerCommands(BaseCommand[] commands){
+ for(BaseCommand command : commands){
+ this.commandMap.put(command.getName(), command);
+ }
+ }
+
+ @Override
+ public void unregisterCommand(BaseCommand command){
+ this.commandMap.values().remove(command);
+ }
+
+ @Override
+ public BaseCommand getCommand(final String id){
+ return this.commandMap.get(id);
+ }
+
+ private Optional getPluginCommand(final String name, final Plugin plugin){
+ try{
+ final Constructor constructor = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class);
+ constructor.setAccessible(true);
+ return Optional.of(constructor.newInstance(name, plugin));
+ }catch(IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | SecurityException ex){
+ ex.printStackTrace();
+ return Optional.empty();
+ }
+ }
+
+
+ private Optional getCommandMap(Server server){
+ PluginManager pluginManager = server.getPluginManager();
+ if(pluginManager instanceof SimplePluginManager){
+ try{
+ Field field = SimplePluginManager.class.getDeclaredField("commandMap");
+ field.setAccessible(true);
+ return Optional.of((CommandMap) field.get(pluginManager));
+ }catch(IllegalAccessException | IllegalArgumentException | NoSuchFieldException | SecurityException ex){
+ ex.printStackTrace();
+ return Optional.empty();
+ }
+ }
+ return Optional.empty();
+ }
+
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/SimpleCommandManager.java b/Base/src/main/java/com/sergivb01/base/command/SimpleCommandManager.java
new file mode 100644
index 0000000..545e947
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/SimpleCommandManager.java
@@ -0,0 +1,84 @@
+package com.sergivb01.base.command;
+
+import com.sergivb01.base.BasePlugin;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.ConsoleCommandSender;
+import org.bukkit.command.PluginCommand;
+import org.bukkit.scheduler.BukkitRunnable;
+
+import java.util.*;
+
+public class SimpleCommandManager implements CommandManager{
+ private static final String PERMISSION_MESSAGE;
+
+ static{
+ PERMISSION_MESSAGE = ChatColor.RED + "You do not have permission to execute this command.";
+ }
+
+ private final Map commandMap;
+
+ public SimpleCommandManager(final BasePlugin plugin){
+ this.commandMap = new HashMap();
+ final ConsoleCommandSender console = plugin.getServer().getConsoleSender();
+ new BukkitRunnable(){
+ public void run(){
+ final Collection commands = SimpleCommandManager.this.commandMap.values();
+ for(final BaseCommand command : commands){
+ final String commandName = command.getName();
+ final PluginCommand pluginCommand = plugin.getCommand(commandName);
+ if(pluginCommand == null){
+ Bukkit.broadcastMessage(commandName);
+ console.sendMessage('[' + plugin.getName() + "] " + ChatColor.YELLOW + "Failed to register command '" + commandName + "'.");
+ console.sendMessage('[' + plugin.getName() + "] " + ChatColor.YELLOW + "Reason: Undefined in plugin.yml.");
+ }else{
+ pluginCommand.setAliases(Arrays.asList(command.getAliases()));
+ pluginCommand.setDescription(command.getDescription());
+ pluginCommand.setExecutor(command);
+ pluginCommand.setTabCompleter(command);
+ pluginCommand.setUsage(command.getUsage());
+ pluginCommand.setPermission("base.command." + command.getName());
+ pluginCommand.setPermissionMessage(SimpleCommandManager.PERMISSION_MESSAGE);
+ }
+ }
+ }
+ }.runTask(plugin);
+ }
+
+ @Override
+ public boolean containsCommand(final BaseCommand command){
+ return this.commandMap.containsValue(command);
+ }
+
+ @Override
+ public void registerAll(final BaseCommandModule module){
+ if(module.isEnabled()){
+ final Set commands = module.getCommands();
+ for(final BaseCommand command : commands){
+ this.commandMap.put(command.getName(), command);
+ }
+ }
+ }
+
+ @Override
+ public void registerCommand(final BaseCommand command){
+ this.commandMap.put(command.getName(), command);
+ }
+
+ @Override
+ public void registerCommands(final BaseCommand[] commands){
+ for(final BaseCommand command : commands){
+ this.commandMap.put(command.getName(), command);
+ }
+ }
+
+ @Override
+ public void unregisterCommand(final BaseCommand command){
+ this.commandMap.values().remove(command);
+ }
+
+ @Override
+ public BaseCommand getCommand(final String id){
+ return this.commandMap.get(id);
+ }
+}
\ No newline at end of file
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/ChatModule.java b/Base/src/main/java/com/sergivb01/base/command/module/ChatModule.java
new file mode 100644
index 0000000..80f2fe9
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/ChatModule.java
@@ -0,0 +1,27 @@
+package com.sergivb01.base.command.module;
+
+import com.sergivb01.base.BasePlugin;
+import com.sergivb01.base.command.BaseCommandModule;
+import com.sergivb01.base.command.module.chat.*;
+
+public class ChatModule
+ extends BaseCommandModule{
+ public ChatModule(BasePlugin plugin){
+ this.commands.add(new ToggleSoundsCommand(plugin));
+ this.commands.add(new ToggleStaffChatCommand(plugin));
+ this.commands.add(new AnnouncementCommand(plugin));
+ this.commands.add(new BroadcastCommand(plugin));
+ this.commands.add(new ClearChatCommand());
+ this.commands.add(new DisableChatCommand(plugin));
+ this.commands.add(new SlowChatCommand(plugin));
+ //this.commands.add(new StaffChatCommand(plugin));
+ this.commands.add(new FamousCommand(plugin));
+ this.commands.add(new YoutubeCommand(plugin));
+ this.commands.add(new IgnoreCommand(plugin));
+ this.commands.add(new MessageCommand(plugin));
+ this.commands.add(new MessageSpyCommand(plugin));
+ this.commands.add(new ReplyCommand(plugin));
+ this.commands.add(new ToggleMessagesCommand(plugin));
+ }
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/EssentialModule.java b/Base/src/main/java/com/sergivb01/base/command/module/EssentialModule.java
new file mode 100644
index 0000000..d3b584d
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/EssentialModule.java
@@ -0,0 +1,50 @@
+package com.sergivb01.base.command.module;
+
+import com.sergivb01.base.BasePlugin;
+import com.sergivb01.base.command.BaseCommandModule;
+import com.sergivb01.base.command.module.essential.*;
+
+public class EssentialModule
+ extends BaseCommandModule{
+ public EssentialModule(BasePlugin plugin){
+ this.commands.add(new SettingsCommand(plugin));
+ this.commands.add(new SetViewDistanceCommand());
+ this.commands.add(new LolCommand(plugin));
+ this.commands.add(new ToggleDonorOnly(plugin));
+ this.commands.add(new ClearLagg());
+ this.commands.add(new SNoteCommand());
+ this.commands.add(new StaffServerCommand());
+ this.commands.add(new AmivisCommand(plugin));
+ this.commands.add(new DonateCommand());
+ this.commands.add(new AutoRestartCommand(plugin));
+ this.commands.add(new ListCommand());
+ this.commands.add(new EnchantCommand());
+ this.commands.add(new NoteCommand());
+ this.commands.add(new PunishCommand());
+ this.commands.add(new FeedCommand());
+ this.commands.add(new FlyCommand());
+ this.commands.add(new KillMobsCommand(plugin));
+ this.commands.add(new NearCommand());
+ this.commands.add(new FreezeCommand(plugin));
+ this.commands.add(new GamemodeCommand());
+ this.commands.add(new HatCommand());
+ this.commands.add(new StaffUtilitiesCommand(plugin));
+ this.commands.add(new HealCommand());
+ this.commands.add(new KillCommand());
+ this.commands.add(new PingCommand());
+ this.commands.add(new PlayTimeCommand(plugin));
+ this.commands.add(new RemoveEntityCommand());
+ this.commands.add(new RenameCommand());
+ this.commands.add(new RepairCommand());
+ this.commands.add(new LagCommand());
+ this.commands.add(new RulesCommand(plugin));
+ this.commands.add(new SetMotdCommand(plugin));
+ this.commands.add(new InsiderCommand(plugin));
+ this.commands.add(new SpeedCommand());
+ this.commands.add(new StopLagCommand(plugin));
+ this.commands.add(new SudoCommand());
+ this.commands.add(new VanishCommand(plugin));
+ this.commands.add(new WhoisCommand(plugin));
+ }
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/InventoryModule.java b/Base/src/main/java/com/sergivb01/base/command/module/InventoryModule.java
new file mode 100644
index 0000000..6c05638
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/InventoryModule.java
@@ -0,0 +1,21 @@
+package com.sergivb01.base.command.module;
+
+import com.sergivb01.base.BasePlugin;
+import com.sergivb01.base.command.BaseCommandModule;
+import com.sergivb01.base.command.module.inventory.*;
+
+public class InventoryModule
+ extends BaseCommandModule{
+ public InventoryModule(BasePlugin plugin){
+ this.commands.add(new ClearInvCommand());
+ this.commands.add(new GiveCommand());
+ this.commands.add(new IdCommand());
+ this.commands.add(new InvSeeCommand(plugin));
+ this.commands.add(new ItemCommand());
+ this.commands.add(new KitsCommand());
+ this.commands.add(new MoreCommand());
+ this.commands.add(new SkullCommand());
+ this.commands.add(new CopyInvCommand());
+ }
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/TeleportModule.java b/Base/src/main/java/com/sergivb01/base/command/module/TeleportModule.java
new file mode 100644
index 0000000..0b5452a
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/TeleportModule.java
@@ -0,0 +1,21 @@
+package com.sergivb01.base.command.module;
+
+import com.sergivb01.base.BasePlugin;
+import com.sergivb01.base.command.BaseCommandModule;
+import com.sergivb01.base.command.module.teleport.*;
+import com.sergivb01.base.command.module.warp.WarpExecutor;
+
+public class TeleportModule
+ extends BaseCommandModule{
+ public TeleportModule(BasePlugin plugin){
+ this.commands.add(new LobbyCommand(plugin));
+ this.commands.add(new BackCommand(plugin));
+ this.commands.add(new TeleportCommand());
+ this.commands.add(new TeleportAllCommand());
+ this.commands.add(new TeleportHereCommand());
+ this.commands.add(new TopCommand());
+ this.commands.add(new WorldCommand());
+ this.commands.add(new WarpExecutor(plugin));
+ }
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/chat/AnnouncementCommand.java b/Base/src/main/java/com/sergivb01/base/command/module/chat/AnnouncementCommand.java
new file mode 100644
index 0000000..7372560
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/chat/AnnouncementCommand.java
@@ -0,0 +1,100 @@
+package com.sergivb01.base.command.module.chat;
+
+import com.google.common.collect.ImmutableList;
+import com.sergivb01.base.BasePlugin;
+import com.sergivb01.base.command.BaseCommand;
+import com.sergivb01.base.task.AnnouncementHandler;
+import com.sergivb01.util.BukkitUtils;
+import org.apache.commons.lang.StringUtils;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+
+import java.util.Collections;
+import java.util.List;
+
+public class AnnouncementCommand
+ extends BaseCommand{
+ private final BasePlugin plugin;
+ private List COMPLETIONS;
+ private int MAX_ANNOUNCEMENT_PER_PAGE = 10;
+
+ public AnnouncementCommand(BasePlugin plugin){
+ super("announcement", "Broadcasts a message to the server.");
+ this.setAliases(new String[]{"announce", "ann"});
+ this.COMPLETIONS = ImmutableList.of("add", "remove", "list", "delay");
+ this.setUsage("/(command) ");
+ this.plugin = plugin;
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ if(args.length == 0){
+ sender.sendMessage(this.getUsage(label));
+ return true;
+ }
+ if(args.length >= 1){
+ if(args[0].equalsIgnoreCase("list")){
+ Integer number = 0;
+ sender.sendMessage(ChatColor.AQUA + "Announcement Lists: ");
+ if(number <= this.MAX_ANNOUNCEMENT_PER_PAGE){
+ for(String announce : this.plugin.getServerHandler().getAnnouncements()){
+ sender.sendMessage(ChatColor.GRAY.toString() + " [" + ChatColor.YELLOW + number + ChatColor.GRAY + ']' + ChatColor.YELLOW + announce);
+ Integer n = number;
+ Integer n2 = number = Integer.valueOf(number + 1);
+ }
+ }else{
+ sender.sendMessage(ChatColor.YELLOW + "Too many to display!");
+ return true;
+ }
+ return true;
+ }
+ if(args[0].equalsIgnoreCase("add")){
+ String messagge = StringUtils.join(args, ' ', 1, args.length);
+ this.plugin.getServerHandler().getAnnouncements().add(ChatColor.translateAlternateColorCodes('&', messagge));
+ Command.broadcastCommandMessage(sender, ChatColor.YELLOW + "Added " + messagge + " to the announcements.", true);
+ return true;
+ }
+ if(args[0].equalsIgnoreCase("remove")){
+ int integer;
+ try{
+ integer = Integer.parseInt(args[1]);
+ }catch(NumberFormatException ex){
+ sender.sendMessage(ChatColor.RED + "Use /" + label + " list to get the number.");
+ return true;
+ }
+ Command.broadcastCommandMessage(sender, ChatColor.YELLOW + "Announcement number " + integer + " has been removed." + '\n' + ChatColor.GRAY + "(" + this.plugin.getServerHandler().getAnnouncements().get(integer) + ")");
+ this.plugin.getServerHandler().getAnnouncements().remove(integer);
+ return true;
+ }
+ if(args[0].equalsIgnoreCase("delay")){
+ int integer;
+ try{
+ integer = Integer.parseInt(args[1]);
+ }catch(NumberFormatException ex){
+ sender.sendMessage(ChatColor.RED + "Must be a number to set the delay.");
+ return true;
+ }
+ if(this.plugin.getServerHandler().getAnnouncementDelay() == integer){
+ return true;
+ }
+
+ this.plugin.getServerHandler().setAnnouncementDelay(integer * 20);
+ BasePlugin.getPlugin().announcementTask.cancel();
+ final AnnouncementHandler announcementTask = new AnnouncementHandler(this.plugin);
+ (BasePlugin.getPlugin().announcementTask = announcementTask).runTaskTimerAsynchronously(BasePlugin.getPlugin(), (long) this.plugin.getServerHandler().getAnnouncementDelay(), (long) this.plugin.getServerHandler().getAnnouncementDelay());
+ Command.broadcastCommandMessage(sender, ChatColor.YELLOW + "Announcement Delay has been modified to " + integer);
+ sender.sendMessage(args[0]);
+ sender.sendMessage(args[1]);
+ return true;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public List onTabComplete(CommandSender sender, Command command, String label, String[] args){
+ return args.length == 1 ? BukkitUtils.getCompletions(args, this.COMPLETIONS) : Collections.emptyList();
+ }
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/chat/BroadcastCommand.java b/Base/src/main/java/com/sergivb01/base/command/module/chat/BroadcastCommand.java
new file mode 100644
index 0000000..df0eaf0
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/chat/BroadcastCommand.java
@@ -0,0 +1,64 @@
+package com.sergivb01.base.command.module.chat;
+
+import com.google.common.collect.ImmutableList;
+import com.sergivb01.base.BasePlugin;
+import com.sergivb01.base.command.BaseCommand;
+import com.sergivb01.util.BukkitUtils;
+import org.apache.commons.lang.StringUtils;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+
+public class BroadcastCommand
+ extends BaseCommand{
+ private final BasePlugin plugin;
+ private final List COMPLETIONS_FIRST = ImmutableList.of("-raw");
+
+ public BroadcastCommand(BasePlugin plugin){
+ super("broadcast", "Broadcasts a message to the server.");
+ this.setAliases(new String[]{"bc"});
+ this.setUsage("/(command) [-raw *sendRaw*] ");
+ this.plugin = plugin;
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ int position;
+ boolean raw;
+ if(args.length < 1){
+ sender.sendMessage(this.getUsage(label));
+ return true;
+ }
+ if(args.length > 1 && args[0].startsWith("-raw")){
+ position = 1;
+ raw = true;
+ }else{
+ position = 0;
+ raw = false;
+ }
+ String message = StringUtils.join(args, ' ', position, args.length);
+ if(raw){
+ if(message.length() < 3){
+ sender.sendMessage(ChatColor.RED + "Character limit not met, must have atleast 3 characters.");
+ return true;
+ }
+ }else if(message.length() < 4){
+ sender.sendMessage(ChatColor.RED + "Character limit not met, must have atleast 4 characters.");
+ return true;
+ }
+ message = !raw ? ChatColor.translateAlternateColorCodes('&', String.format(Locale.ENGLISH, this.plugin.getServerHandler().getBroadcastFormat(), message)) : ChatColor.translateAlternateColorCodes('&', message);
+ Bukkit.broadcastMessage(message);
+ return true;
+ }
+
+ @Override
+ public List onTabComplete(CommandSender sender, Command command, String label, String[] args){
+ return args.length == 1 ? BukkitUtils.getCompletions(args, this.COMPLETIONS_FIRST) : Collections.emptyList();
+ }
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/chat/ChatCommands.java b/Base/src/main/java/com/sergivb01/base/command/module/chat/ChatCommands.java
new file mode 100644
index 0000000..8f17ba7
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/chat/ChatCommands.java
@@ -0,0 +1,143 @@
+package com.sergivb01.base.command.module.chat;
+
+import com.sergivb01.util.BukkitUtils;
+import com.sergivb01.util.chat.ClickAction;
+import com.sergivb01.util.chat.Text;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.AsyncPlayerChatEvent;
+
+public class ChatCommands implements Listener{
+
+ @EventHandler (priority = EventPriority.HIGHEST)
+ public void onChat(AsyncPlayerChatEvent event){
+ String command = event.getMessage();
+ Player player = event.getPlayer();
+ String spacebar = ChatColor.GRAY + BukkitUtils.STRAIGHT_LINE_DEFAULT;
+ switch(command){
+ case "?help":
+ event.setCancelled(true);
+ player.sendMessage(spacebar);
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&9&lChatCommands list &7(Click)"));
+ new Text(ChatColor.translateAlternateColorCodes('&', " &7* &b?claim")).setHoverText(ChatColor.BLUE + "Click to ?claim").setClick(ClickAction.RUN_COMMAND, "?claim").send(player);
+ new Text(ChatColor.translateAlternateColorCodes('&', " &7* &b?elevator")).setHoverText(ChatColor.BLUE + "Click to ?elevator").setClick(ClickAction.RUN_COMMAND, "?elevator").send(player);
+ new Text(ChatColor.translateAlternateColorCodes('&', " &7* &b?potions")).setHoverText(ChatColor.BLUE + "Click to ?potions").setClick(ClickAction.RUN_COMMAND, "?potions").send(player);
+ new Text(ChatColor.translateAlternateColorCodes('&', " &7* &b?links")).setHoverText(ChatColor.BLUE + "Click to ?links").setClick(ClickAction.RUN_COMMAND, "?links").send(player);
+ new Text(ChatColor.translateAlternateColorCodes('&', " &7* &b?teamspeak")).setHoverText(ChatColor.BLUE + "Click to ?teamspeak").setClick(ClickAction.RUN_COMMAND, "?teamspeak").send(player);
+ player.sendMessage(spacebar);
+ break;
+ case "?claim":
+ event.setCancelled(true);
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&',
+ spacebar +
+ "&9&lClaiming tutorial\n" +
+ "&rTo start claiming you must type &b/f claim &rand you will get a claiming wand. &7&o(Hover over the item for more information)&r.\n" +
+ " \n" +
+ " &7* &3&lUsing the wand:\n" +
+ " &r&lLeft &rclick on the first corner of the land you want to claim.\n" +
+ " &r&lRight &rclick on the second corner of the land you want to claim.\n" +
+ " &r&lRight &rclick &r&lair &rto &ccancel &ryour current claim selection.\n" +
+ " &r&lShift &r+ &r&lLeft &rclick to &apurchase &ryour current claim selection.\n" +
+ " \n" +
+ " &7* &3&lUnclaiming land:\n" +
+ " &rYou must type &b/f unclaim &rand you will have to confirm it by adding &a&lyes &ror &c&lno &rto the command.\n" +
+ spacebar
+ ));
+ break;
+ case "?elevator":
+ case "?elevators":
+ event.setCancelled(true);
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&',
+ spacebar +
+ "&9&lElevators tutorial (2 Signs)\n" +
+ " \n" +
+ " &7* &rPlace the first sign on a block and type &3&l[Elevator] &7&o(First line) &rand &bDown &7&o(Second line)&r.\n" +
+ " \n" +
+ " &7* &rThen &cin the same pillar of blocks&r, go down as many blocks as you want, place the second sign and type &3&l[Elevator] &7&o(First line) &rand &bUp &7&o(Second line)&r.\n" +
+ spacebar
+ ));
+ break;
+ case "?potions":
+ case "?brewing":
+ String square = "\u2588";
+ String circle = "\u2B24";
+ String triangle = "&l\u29CA";
+ String arrow = " &r\u279D ";
+ event.setCancelled(true);
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&',
+ spacebar +
+ "&9&lBrewing tutorial\n" +
+ spacebar +
+ "&3&lIcons:\n" +
+ " &7* &rGlowstone &e" + triangle + " &7(Increases Potency)\n" +
+ " &7* &rRedstone &4" + triangle + " &7(Increases Duration)\n" +
+ " &7* &rGunpowder &8" + triangle + " &7(Make potions splashable)\n" +
+ " &7* &rSugar &r" + triangle + "\n" +
+ " &7* &rNether Wart &c" + square + "\n" +
+ " &7* &rGlistering Melon &6" + square + "\n" +
+ " &7* &rGolden Carrot &e" + square + "\n" +
+ " &7* &rMagma Cream &a" + circle + "\n" +
+ " &7* &rSpider Eye &c" + circle + "\n" +
+ " &7* &rFermented Spider Eye &4" + circle + "\n" +
+ spacebar +
+ "&3&lCraftings:\n" +
+ " &7- &a" + circle + " &r= Slimeball + Blaze Powder\n" +
+ " &7- &6" + square + " &r= Melon + 8xGold Nuggets\n" +
+ " &7- &e" + square + " &r= Carrot + 8xGold Nuggets\n" +
+ " &7- &4" + circle + " &r= " + "&c" + circle + " &r+ " + triangle + " &r+ Brown Mushroom\n" +
+ spacebar +
+ "&3&lPotions:\n" +
+ " &7» &c&ki&rHealing II Splash&c&ki&r: &c" + square + arrow + "&6" + square + arrow + "&e" + triangle + arrow + "&8" + triangle + "\n" +
+ " &7» &b&ki&rSpeed II&b&ki&r: &c" + square + arrow + "&r" + triangle + arrow + "&e" + triangle + "\n" +
+ " &7» &6&ki&rFire Resistance +&6&ki&r: &c" + square + arrow + "&a" + circle + arrow + "&4" + triangle + "\n" +
+ " &7» &7&ki&rInvisibility +&7&ki&r: &c" + square + arrow + "&a" + circle + arrow + "&4" + circle + arrow + "&4" + triangle + "\n" +
+ " &7» &2&ki&rPoison II Splash&2&ki&r: &c" + square + arrow + "&c" + circle + arrow + "&e" + triangle + arrow + "&8" + triangle + "\n" +
+ " &7» &5&ki&rSlowness II Splash&5&ki&r: &c" + square + arrow + "&r" + triangle + arrow + "&4" + circle + arrow + "&4" + triangle + arrow + "&8" + triangle + "\n" +
+ spacebar
+ ));
+ break;
+ case "?links":
+ case "?forums":
+ case "?forum":
+ case "?discord":
+ case "?website":
+ case "?store":
+ case "?twitter":
+ case "?staff":
+ case "?mods":
+ case "?rules":
+ case "?clients":
+ event.setCancelled(true);
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&',
+ spacebar +
+ "&9&lServer links\n" +
+ " &7* &3Website: &rveilhcf.us\n" +
+ " &7* &3Forums: &rveilhcf.us/community\n" +
+ " &7* &3Store: &rstore.veilhcf.us\n" +
+ " &7* &3Twitter: &rtwitter.com/veilhcf\n" +
+ " &7* &3Discord: &rdiscord.gg/RdbbBx7\n" +
+ " &7* &3Allowed Mods: &rhttps://veilhcf.us/community/d/12-allowed-modifications\n" +
+ " &7* &3Server Rules: &rhttps://veilhcf.us/community/d/118-our-rules\n" +
+ spacebar
+ ));
+ break;
+ case "?teamspeak":
+ case "?ts":
+ case "?ts3":
+ event.setCancelled(true);
+ player.sendMessage(ChatColor.translateAlternateColorCodes('&',
+ spacebar +
+ "&9&lTeamSpeak: &7ts.veilhcf.us\n" +
+ spacebar
+ ));
+ break;
+ }
+ if(command.startsWith("?") && command.trim().split(" ").length == 1 && !event.isCancelled() && command.toCharArray().length > 1){
+ event.setCancelled(true);
+ player.chat("?help");
+ }
+ }
+}
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/chat/ClearChatCommand.java b/Base/src/main/java/com/sergivb01/base/command/module/chat/ClearChatCommand.java
new file mode 100644
index 0000000..d51422c
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/chat/ClearChatCommand.java
@@ -0,0 +1,38 @@
+package com.sergivb01.base.command.module.chat;
+
+import com.sergivb01.base.command.BaseCommand;
+import net.minecraft.util.org.apache.commons.lang3.StringUtils;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+public class ClearChatCommand
+ extends BaseCommand{
+ private static final String BYPASS_PERMISSION = "command.clearchat.bypass";
+ private static final String[] CLEAR_MESSAGE = new String[101];
+
+ public ClearChatCommand(){
+ super("clearchat", "Clears the server chat for players.");
+ this.setAliases(new String[]{"cc"});
+ this.setUsage("/(command) ");
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ if(args.length == 0){
+ sender.sendMessage(this.getUsage());
+ return true;
+ }
+ String reason = StringUtils.join(args, ' ');
+ for(Player player : Bukkit.getOnlinePlayers()){
+ if(player.hasPermission(BYPASS_PERMISSION)) continue;
+ player.sendMessage(CLEAR_MESSAGE);
+ }
+ Command.broadcastCommandMessage(sender, ChatColor.YELLOW + "You have cleared chat for: " + reason, true);
+
+ return true;
+ }
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/chat/DisableChatCommand.java b/Base/src/main/java/com/sergivb01/base/command/module/chat/DisableChatCommand.java
new file mode 100644
index 0000000..30a9f11
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/chat/DisableChatCommand.java
@@ -0,0 +1,53 @@
+package com.sergivb01.base.command.module.chat;
+
+import com.sergivb01.base.BasePlugin;
+import com.sergivb01.base.command.BaseCommand;
+import com.sergivb01.util.JavaUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DurationFormatUtils;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+
+import java.util.concurrent.TimeUnit;
+
+public class DisableChatCommand
+ extends BaseCommand{
+ private static final long DEFAULT_DELAY;
+
+ static{
+ DEFAULT_DELAY = TimeUnit.MINUTES.toMillis(3L);
+ }
+
+ private final BasePlugin plugin;
+
+ public DisableChatCommand(BasePlugin plugin){
+ super("disablechat", "Disables the chat for non-staff.");
+ this.setAliases(new String[]{"mutechat", "restrictchat", "mc", "rc"});
+ this.setUsage("/(command)");
+ this.plugin = plugin;
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ long oldTicks = this.plugin.getServerHandler().getRemainingChatDisabledMillis();
+ long newTicks;
+ if(oldTicks > 0L){
+ newTicks = 0L;
+ }else if(args.length < 1){
+ newTicks = DisableChatCommand.DEFAULT_DELAY;
+ }else{
+ newTicks = JavaUtils.parse(StringUtils.join(args, ' ', 0, args.length));
+ if(newTicks == -1L){
+ sender.sendMessage(ChatColor.RED + "Invalid duration, use the correct format: 10m1s");
+ return true;
+ }
+ }
+ this.plugin.getServerHandler().setChatDisabledMillis(newTicks);
+ Command.broadcastCommandMessage(sender, ChatColor.translateAlternateColorCodes('&', "&eYou have " + ((newTicks > 0L) ? ("disabled") : ("enabled")) + " chat."));
+ Bukkit.broadcastMessage(ChatColor.YELLOW + "Global chat is now " + ((newTicks > 0L) ? (ChatColor.RED + "disabled" + ChatColor.YELLOW + " for " + ChatColor.GOLD + DurationFormatUtils.formatDurationWords(newTicks, true, true)) : (ChatColor.GREEN + "enabled")));
+ return true;
+ }
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/chat/FamousCommand.java b/Base/src/main/java/com/sergivb01/base/command/module/chat/FamousCommand.java
new file mode 100644
index 0000000..e47e8c5
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/chat/FamousCommand.java
@@ -0,0 +1,27 @@
+package com.sergivb01.base.command.module.chat;
+
+import com.sergivb01.base.BasePlugin;
+import com.sergivb01.base.command.BaseCommand;
+import com.sergivb01.util.BukkitUtils;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+
+public class FamousCommand
+ extends BaseCommand{
+
+ public FamousCommand(BasePlugin plugin){
+ super("famous", "Check requirements");
+ this.setUsage("/(command)");
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ sender.sendMessage(ChatColor.GRAY + BukkitUtils.STRAIGHT_LINE_DEFAULT);
+ sender.sendMessage(ChatColor.GOLD.toString() + ChatColor.BOLD + "Famous Requirments");
+ sender.sendMessage(ChatColor.DARK_GRAY + " * " + ChatColor.WHITE + "3,000 Subscribers");
+ sender.sendMessage(ChatColor.DARK_GRAY + " * " + ChatColor.WHITE + "1 Video");
+ sender.sendMessage(ChatColor.GRAY + BukkitUtils.STRAIGHT_LINE_DEFAULT);
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/chat/IgnoreCommand.java b/Base/src/main/java/com/sergivb01/base/command/module/chat/IgnoreCommand.java
new file mode 100644
index 0000000..b1a7a60
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/chat/IgnoreCommand.java
@@ -0,0 +1,213 @@
+package com.sergivb01.base.command.module.chat;
+
+import com.sergivb01.base.BaseConstants;
+import com.sergivb01.base.BasePlugin;
+import com.sergivb01.base.StaffPriority;
+import com.sergivb01.base.command.BaseCommand;
+import com.sergivb01.base.user.BaseUser;
+import com.sergivb01.util.BukkitUtils;
+import com.sergivb01.util.command.CommandArgument;
+import com.sergivb01.util.command.CommandWrapper;
+import org.apache.commons.lang.StringUtils;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+import java.util.*;
+
+public class IgnoreCommand
+ extends BaseCommand{
+ private final CommandWrapper handler;
+
+ public IgnoreCommand(BasePlugin plugin){
+ super("ignore", "Ignores a player from messages.");
+ this.setUsage("/(command) [playerName]");
+ ArrayList arguments = new ArrayList(4);
+ arguments.add(new IgnoreClearArgument(plugin));
+ arguments.add(new IgnoreListArgument(plugin));
+ arguments.add(new IgnoreAddArgument(plugin));
+ arguments.add(new IgnoreDeleteArgument(plugin));
+ Collections.sort(arguments, new CommandWrapper.ArgumentComparator());
+ this.handler = new CommandWrapper(arguments);
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ return this.handler.onCommand(sender, command, label, args);
+ }
+
+ @Override
+ public List onTabComplete(CommandSender sender, Command command, String label, String[] args){
+ return this.handler.onTabComplete(sender, command, label, args);
+ }
+
+ private static class IgnoreDeleteArgument
+ extends CommandArgument{
+ private final BasePlugin plugin;
+
+ public IgnoreDeleteArgument(BasePlugin plugin){
+ super("delete", "Un-ignores a player.");
+ this.plugin = plugin;
+ this.aliases = new String[]{"del", "remove", "unset"};
+ }
+
+ @Override
+ public String getUsage(String label){
+ return "" + '/' + label + ' ' + this.getName() + " ";
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ if(!(sender instanceof Player)){
+ sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
+ return true;
+ }
+ if(args.length < 2){
+ sender.sendMessage(ChatColor.RED + "Usage: " + this.getUsage(label));
+ return true;
+ }
+ sender.sendMessage(ChatColor.YELLOW + "You are " + (this.plugin.getUserManager().getUser(((Player) sender).getUniqueId()).getIgnoring().remove(args[1]) ? new StringBuilder().append(ChatColor.RED).append("not").toString() : new StringBuilder().append(ChatColor.GREEN).append("no longer").toString()) + ChatColor.YELLOW + " ignoring " + args[1] + '.');
+ return true;
+ }
+
+ @Override
+ public List onTabComplete(CommandSender sender, Command command, String label, String[] args){
+ return null;
+ }
+ }
+
+ private static class IgnoreListArgument
+ extends CommandArgument{
+ private final BasePlugin plugin;
+
+ public IgnoreListArgument(BasePlugin plugin){
+ super("list", "Lists all ignored players.");
+ this.plugin = plugin;
+ }
+
+ @Override
+ public String getUsage(String label){
+ return "" + '/' + label + ' ' + this.getName();
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ if(!(sender instanceof Player)){
+ sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
+ return true;
+ }
+ Set ignoring = this.plugin.getUserManager().getUser(((Player) sender).getUniqueId()).getIgnoring();
+ if(ignoring.isEmpty()){
+ sender.sendMessage(ChatColor.YELLOW + "You are not ignoring anyone.");
+ return true;
+ }
+ sender.sendMessage(ChatColor.YELLOW + "You are ignoring (" + ignoring.size() + ") members: " + '[' + ChatColor.WHITE + StringUtils.join(ignoring, ", ") + ChatColor.YELLOW + ']');
+ return true;
+ }
+
+ @Override
+ public List onTabComplete(CommandSender sender, Command command, String label, String[] args){
+ return Collections.emptyList();
+ }
+ }
+
+ private static class IgnoreClearArgument
+ extends CommandArgument{
+ private final BasePlugin plugin;
+
+ public IgnoreClearArgument(BasePlugin plugin){
+ super("clear", "Clears all ignored players.");
+ this.plugin = plugin;
+ }
+
+ @Override
+ public String getUsage(String label){
+ return "" + '/' + label + ' ' + this.getName();
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ if(!(sender instanceof Player)){
+ sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
+ return true;
+ }
+ Set ignoring = this.plugin.getUserManager().getUser(((Player) sender).getUniqueId()).getIgnoring();
+ if(ignoring.isEmpty()){
+ sender.sendMessage(ChatColor.RED + "Your ignore list is already empty.");
+ return true;
+ }
+ ignoring.clear();
+ sender.sendMessage(ChatColor.YELLOW + "Your ignore list has been cleared.");
+ return true;
+ }
+
+ @Override
+ public List onTabComplete(CommandSender sender, Command command, String label, String[] args){
+ return Collections.emptyList();
+ }
+ }
+
+ private static class IgnoreAddArgument
+ extends CommandArgument{
+ private final BasePlugin plugin;
+
+ public IgnoreAddArgument(BasePlugin plugin){
+ super("add", "Starts ignoring a player.");
+ this.plugin = plugin;
+ }
+
+ @Override
+ public String getUsage(String label){
+ return "" + '/' + label + ' ' + this.getName() + " ";
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ if(!(sender instanceof Player)){
+ sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
+ return true;
+ }
+ if(args.length < 2){
+ sender.sendMessage(this.getUsage(label));
+ return true;
+ }
+ Player player = (Player) sender;
+ UUID uuid = player.getUniqueId();
+ BaseUser baseUser = this.plugin.getUserManager().getUser(uuid);
+ Set ignoring = baseUser.getIgnoring();
+ Player target = BukkitUtils.playerWithNameOrUUID(args[1]);
+ if(target == null || !BaseCommand.canSee(sender, target)){
+ sender.sendMessage(String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, args[1]));
+ return true;
+ }
+ if(sender.equals(target)){
+ sender.sendMessage(ChatColor.RED + "You may not ignore yourself.");
+ return true;
+ }
+ StaffPriority selfPriority = StaffPriority.of(player);
+ if(StaffPriority.of(target).isMoreThan(selfPriority)){
+ sender.sendMessage(ChatColor.RED + "You cannot ignore this player.");
+ return true;
+ }
+ if(target.hasPermission("command.ignore.exempt")){
+ sender.sendMessage(ChatColor.RED + "You do not have permission to ignore this player.");
+ return true;
+ }
+ String targetName = target.getName();
+ if(ignoring.add(target.getName())){
+ sender.sendMessage(ChatColor.GOLD + "You are now ignoring " + targetName + '.');
+ }else{
+ sender.sendMessage(ChatColor.RED + "You are already ignoring someone named " + targetName + '.');
+ }
+ return true;
+ }
+
+ @Override
+ public List onTabComplete(CommandSender sender, Command command, String label, String[] args){
+ return args.length == 2 ? null : Collections.emptyList();
+ }
+ }
+
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/chat/MessageCommand.java b/Base/src/main/java/com/sergivb01/base/command/module/chat/MessageCommand.java
new file mode 100644
index 0000000..198f9b8
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/chat/MessageCommand.java
@@ -0,0 +1,58 @@
+package com.sergivb01.base.command.module.chat;
+
+import com.sergivb01.base.BaseConstants;
+import com.sergivb01.base.BasePlugin;
+import com.sergivb01.base.command.BaseCommand;
+import com.sergivb01.base.event.PlayerMessageEvent;
+import com.sergivb01.util.BukkitUtils;
+import org.apache.commons.lang.StringUtils;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+public class MessageCommand
+ extends BaseCommand{
+ public MessageCommand(BasePlugin plugin){
+ super("message", "Sends a message to a recipient(s).");
+ this.setAliases(new String[]{"msg", "m", "whisper", "w", "tell"});
+ this.setUsage("/(command) ");
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ if(!(sender instanceof Player)){
+ sender.sendMessage(ChatColor.RED + "This command is only executable for players.");
+ return true;
+ }
+ if(args.length < 2){
+ sender.sendMessage(ChatColor.RED + "Usage: " + this.getUsage(label));
+ return true;
+ }
+ Player player = (Player) sender;
+ Player target = BukkitUtils.playerWithNameOrUUID(args[0]);
+ if(target == null || !BaseCommand.canSee(sender, target)){
+ sender.sendMessage(String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, args[0]));
+ return true;
+ }
+ String message = StringUtils.join(args, ' ', 1, args.length);
+ Set recipients = Collections.singleton(target);
+ PlayerMessageEvent playerMessageEvent = new PlayerMessageEvent(player, recipients, message, false);
+ Bukkit.getPluginManager().callEvent(playerMessageEvent);
+ if(!playerMessageEvent.isCancelled()){
+ playerMessageEvent.send();
+ }
+ return true;
+ }
+
+ @Override
+ public List onTabComplete(CommandSender sender, Command command, String label, String[] args){
+ return null;
+ }
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/chat/MessageSpyCommand.java b/Base/src/main/java/com/sergivb01/base/command/module/chat/MessageSpyCommand.java
new file mode 100644
index 0000000..a7b65b1
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/chat/MessageSpyCommand.java
@@ -0,0 +1,218 @@
+package com.sergivb01.base.command.module.chat;
+
+import com.google.common.collect.Iterables;
+import com.sergivb01.base.BasePlugin;
+import com.sergivb01.base.command.BaseCommand;
+import com.sergivb01.base.user.ServerParticipator;
+import com.sergivb01.util.BukkitUtils;
+import com.sergivb01.util.JavaUtils;
+import com.sergivb01.util.command.CommandArgument;
+import com.sergivb01.util.command.CommandWrapper;
+import org.apache.commons.lang.StringUtils;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.OfflinePlayer;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+
+import java.util.*;
+
+public class MessageSpyCommand
+ extends BaseCommand{
+ private final CommandWrapper handler;
+
+ public MessageSpyCommand(BasePlugin plugin){
+ super("socialspy", "Spies on the PM's of a player.");
+ this.setUsage("/(command) [playerName]");
+ ArrayList arguments = new ArrayList(4);
+ arguments.add(new MessageSpyListArgument(plugin));
+ arguments.add(new IgnoreClearArgument(plugin));
+ arguments.add(new MessageSpyAddArgument(plugin));
+ arguments.add(new MessageSpyDeleteArgument(plugin));
+ Collections.sort(arguments, new CommandWrapper.ArgumentComparator());
+ this.handler = new CommandWrapper(arguments);
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ return this.handler.onCommand(sender, command, label, args);
+ }
+
+ @Override
+ public List onTabComplete(CommandSender sender, Command command, String label, String[] args){
+ return this.handler.onTabComplete(sender, command, label, args);
+ }
+
+ private static class MessageSpyListArgument
+ extends CommandArgument{
+ private final BasePlugin plugin;
+
+ public MessageSpyListArgument(BasePlugin plugin){
+ super("list", "Lists all players you're spying on.");
+ this.plugin = plugin;
+ }
+
+ @Override
+ public String getUsage(String label){
+ return "" + '/' + label + ' ' + this.getName();
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ ServerParticipator participator = this.plugin.getUserManager().getParticipator(sender);
+ if(participator == null){
+ sender.sendMessage(ChatColor.RED + "You are not able to message spy.");
+ return true;
+ }
+ LinkedHashSet spyingNames = new LinkedHashSet();
+ Set messageSpying = participator.getMessageSpying();
+ if(messageSpying.size() == 1 && Iterables.getOnlyElement(messageSpying).equals("all")){
+ sender.sendMessage(ChatColor.GRAY + "You are currently spying on the messages of all players.");
+ return true;
+ }
+ for(String spyingId : messageSpying){
+ String name = Bukkit.getOfflinePlayer(UUID.fromString(spyingId)).getName();
+ if(name == null) continue;
+ spyingNames.add(name);
+ }
+ if(spyingNames.isEmpty()){
+ sender.sendMessage(ChatColor.RED + "You are not spying on the messages of any players.");
+ return true;
+ }
+ sender.sendMessage(ChatColor.GRAY + "You are currently spying on the messages of (" + spyingNames.size() + " players): " + ChatColor.RED + StringUtils.join(spyingNames, new StringBuilder().append(ChatColor.GRAY.toString()).append(", ").append(ChatColor.RED).toString()) + ChatColor.GRAY + '.');
+ return true;
+ }
+ }
+
+ private static class IgnoreClearArgument
+ extends CommandArgument{
+ private final BasePlugin plugin;
+
+ public IgnoreClearArgument(BasePlugin plugin){
+ super("clear", "Clears your current spy list.");
+ this.plugin = plugin;
+ }
+
+ @Override
+ public String getUsage(String label){
+ return "" + '/' + label + ' ' + this.getName();
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ ServerParticipator participator = this.plugin.getUserManager().getParticipator(sender);
+ if(participator == null){
+ sender.sendMessage(ChatColor.RED + "You are not able to message spy.");
+ return true;
+ }
+ participator.getMessageSpying().clear();
+ sender.sendMessage(ChatColor.YELLOW + "You are no longer spying the messages of anyone.");
+ return true;
+ }
+ }
+
+ private static class MessageSpyAddArgument
+ extends CommandArgument{
+ private final BasePlugin plugin;
+
+ public MessageSpyAddArgument(BasePlugin plugin){
+ super("add", "Adds a player to your message spy list.");
+ this.plugin = plugin;
+ }
+
+ @Override
+ public String getUsage(String label){
+ return "" + '/' + label + ' ' + this.getName() + " ";
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ ServerParticipator participator = this.plugin.getUserManager().getParticipator(sender);
+ if(participator == null){
+ sender.sendMessage(ChatColor.RED + "You are not able to message spy.");
+ return true;
+ }
+ if(args.length < 2){
+ sender.sendMessage(ChatColor.RED + "Usage: " + this.getUsage(label));
+ return true;
+ }
+ Set messageSpying = participator.getMessageSpying();
+ boolean all = messageSpying.contains("all");
+ if(all || JavaUtils.containsIgnoreCase(messageSpying, args[1])){
+ sender.sendMessage(ChatColor.RED + "You are already spying on the messages of " + (all ? "all players" : args[1]) + '.');
+ return true;
+ }
+ if(args[1].equalsIgnoreCase("all")){
+ messageSpying.clear();
+ messageSpying.add("all");
+ sender.sendMessage(ChatColor.GREEN + "You are now spying on the messages of all players.");
+ return true;
+ }
+ OfflinePlayer offlineTarget = Bukkit.getOfflinePlayer(args[1]);
+ if(!offlineTarget.hasPlayedBefore() && offlineTarget.getPlayer() == null){
+ sender.sendMessage(ChatColor.GOLD + "Player '" + ChatColor.WHITE + args[1] + ChatColor.GOLD + "' not found.");
+ return true;
+ }
+ if(offlineTarget.equals(sender)){
+ sender.sendMessage(ChatColor.RED + "You cannot spy on the messages of yourself.");
+ return true;
+ }
+ sender.sendMessage(ChatColor.YELLOW + "You are " + (messageSpying.add(offlineTarget.getUniqueId().toString()) ? new StringBuilder().append(ChatColor.GREEN).append("now").toString() : new StringBuilder().append(ChatColor.RED).append("already").toString()) + ChatColor.YELLOW + " spying on the messages of " + offlineTarget.getName() + '.');
+ return true;
+ }
+
+ @Override
+ public List onTabComplete(CommandSender sender, Command command, String label, String[] args){
+ return args.length == 2 ? null : Collections.emptyList();
+ }
+ }
+
+ private static class MessageSpyDeleteArgument
+ extends CommandArgument{
+ private final BasePlugin plugin;
+
+ public MessageSpyDeleteArgument(BasePlugin plugin){
+ super("delete", "Deletes a player from your message spy list.");
+ this.plugin = plugin;
+ this.aliases = new String[]{"del", "remove"};
+ }
+
+ @Override
+ public String getUsage(String label){
+ return "" + '/' + label + ' ' + this.getName() + " ";
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ ServerParticipator participator = this.plugin.getUserManager().getParticipator(sender);
+ if(participator == null){
+ sender.sendMessage(ChatColor.RED + "You are not able to message spy.");
+ return true;
+ }
+ if(args.length < 2){
+ sender.sendMessage(ChatColor.RED + "Usage: " + this.getUsage(label));
+ return true;
+ }
+ Set messageSpying = participator.getMessageSpying();
+ if(args[1].equalsIgnoreCase("all")){
+ messageSpying.remove("all");
+ sender.sendMessage(ChatColor.RED + "You are no longer spying on the messages of all players.");
+ return true;
+ }
+ OfflinePlayer offlineTarget = BukkitUtils.offlinePlayerWithNameOrUUID(args[1]);
+ if(!offlineTarget.hasPlayedBefore() && !offlineTarget.isOnline()){
+ sender.sendMessage(ChatColor.GOLD + "Player named or with UUID '" + ChatColor.WHITE + args[1] + ChatColor.GOLD + "' not found.");
+ return true;
+ }
+ sender.sendMessage("You are " + (messageSpying.remove(offlineTarget.getUniqueId().toString()) ? new StringBuilder().append(ChatColor.GREEN).append("no longer").toString() : new StringBuilder().append(ChatColor.RED).append("still not").toString()) + ChatColor.YELLOW + " spying on the messages of " + offlineTarget.getName() + '.');
+ return true;
+ }
+
+ @Override
+ public List onTabComplete(CommandSender sender, Command command, String label, String[] args){
+ return args.length == 2 ? null : Collections.emptyList();
+ }
+ }
+
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/chat/ReplyCommand.java b/Base/src/main/java/com/sergivb01/base/command/module/chat/ReplyCommand.java
new file mode 100644
index 0000000..e65ae3a
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/chat/ReplyCommand.java
@@ -0,0 +1,71 @@
+package com.sergivb01.base.command.module.chat;
+
+import com.google.common.collect.Sets;
+import com.sergivb01.base.BasePlugin;
+import com.sergivb01.base.command.BaseCommand;
+import com.sergivb01.base.event.PlayerMessageEvent;
+import com.sergivb01.base.user.BaseUser;
+import org.apache.commons.lang.StringUtils;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+
+public class ReplyCommand
+ extends BaseCommand{
+ private static final long VANISH_REPLY_TIMEOUT = TimeUnit.SECONDS.toMillis(45);
+ private final BasePlugin plugin;
+
+ public ReplyCommand(BasePlugin plugin){
+ super("reply", "Replies to the last conversing player.");
+ this.setAliases(new String[]{"r"});
+ this.setUsage("/(command) ");
+ this.plugin = plugin;
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ Player target;
+ if(!(sender instanceof Player)){
+ sender.sendMessage(ChatColor.RED + "This command is only executable for players.");
+ return true;
+ }
+ Player player = (Player) sender;
+ UUID uuid = player.getUniqueId();
+ BaseUser baseUser = this.plugin.getUserManager().getUser(uuid);
+ UUID lastReplied = baseUser.getLastRepliedTo();
+ Player player2 = target = lastReplied == null ? null : Bukkit.getPlayer(lastReplied);
+ if(args.length < 1){
+ sender.sendMessage(ChatColor.RED + "Usage: " + this.getUsage(label));
+ if(lastReplied != null && BaseCommand.canSee(sender, target)){
+ sender.sendMessage(ChatColor.RED + "You are in a conversation with " + target.getName() + '.');
+ }
+ return true;
+ }
+ long millis = System.currentTimeMillis();
+ if(target == null || !BaseCommand.canSee(sender, target) && millis - baseUser.getLastReceivedMessageMillis() > VANISH_REPLY_TIMEOUT){
+ sender.sendMessage(ChatColor.RED + "There is no player to reply to.");
+ return true;
+ }
+ String message = StringUtils.join(args, ' ');
+ HashSet recipients = Sets.newHashSet((Object[]) new Player[]{target});
+ PlayerMessageEvent playerMessageEvent = new PlayerMessageEvent(player, recipients, message, false);
+ Bukkit.getPluginManager().callEvent(playerMessageEvent);
+ if(!playerMessageEvent.isCancelled()){
+ playerMessageEvent.send();
+ }
+ return true;
+ }
+
+ @Override
+ public List onTabComplete(CommandSender sender, Command command, String label, String[] args){
+ return null;
+ }
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/chat/SlowChatCommand.java b/Base/src/main/java/com/sergivb01/base/command/module/chat/SlowChatCommand.java
new file mode 100644
index 0000000..bf599db
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/chat/SlowChatCommand.java
@@ -0,0 +1,47 @@
+package com.sergivb01.base.command.module.chat;
+
+import com.sergivb01.base.BasePlugin;
+import com.sergivb01.base.command.BaseCommand;
+import com.sergivb01.util.JavaUtils;
+import org.apache.commons.lang.time.DurationFormatUtils;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+
+import java.util.concurrent.TimeUnit;
+
+public class SlowChatCommand
+ extends BaseCommand{
+ private static final long DEFAULT_DELAY = TimeUnit.MINUTES.toMillis(5);
+ private final BasePlugin plugin;
+
+ public SlowChatCommand(BasePlugin plugin){
+ super("slowchat", "Slows the chat down for non-staff.");
+ this.setAliases(new String[]{"slow"});
+ this.setUsage("/(command)");
+ this.plugin = plugin;
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ Long newTicks;
+ long oldTicks = this.plugin.getServerHandler().getRemainingChatSlowedMillis();
+ if(oldTicks > 0){
+ newTicks = (long) 0;
+ }else if(args.length < 1){
+ newTicks = DEFAULT_DELAY;
+ }else{
+ newTicks = JavaUtils.parse(args[0]);
+ if(newTicks == -1){
+ sender.sendMessage(ChatColor.RED + "Invalid duration, use the correct format: 10m1s");
+ return true;
+ }
+ }
+ this.plugin.getServerHandler().setChatSlowedMillis(newTicks);
+ Command.broadcastCommandMessage(sender, ChatColor.translateAlternateColorCodes('&', "&eYou have " + (newTicks > 0 ? " slowed down chat." : String.valueOf(ChatColor.YELLOW) + " de-restricted chat.")));
+ Bukkit.broadcastMessage(ChatColor.YELLOW + "Global chat is" + (newTicks > 0 ? " now slowed down for " + DurationFormatUtils.formatDurationWords(newTicks, true, true) : String.valueOf(ChatColor.YELLOW) + " no longer slowed") + ChatColor.YELLOW + '.');
+ return true;
+ }
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/chat/StaffChatCommand.java b/Base/src/main/java/com/sergivb01/base/command/module/chat/StaffChatCommand.java
new file mode 100644
index 0000000..d96be94
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/chat/StaffChatCommand.java
@@ -0,0 +1,71 @@
+package com.sergivb01.base.command.module.chat;
+
+import com.sergivb01.base.BasePlugin;
+import com.sergivb01.base.command.BaseCommand;
+import com.sergivb01.base.user.BaseUser;
+import com.sergivb01.base.user.ServerParticipator;
+import net.minecraft.util.org.apache.commons.lang3.StringUtils;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+import java.util.List;
+import java.util.Locale;
+
+public class StaffChatCommand {
+
+ // extends BaseCommand{
+ /*
+ private final BasePlugin plugin;
+
+ public StaffChatCommand(BasePlugin plugin){
+ super("staffchat", "Enters staff chat mode.");
+ this.setAliases(new String[]{"sc", "ac"});
+ this.setUsage("/(command) [playerName]");
+ this.plugin = plugin;
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ ServerParticipator target;
+ ServerParticipator participator = this.plugin.getUserManager().getParticipator(sender);
+ if(participator == null){
+ sender.sendMessage(ChatColor.RED + "You are not allowed to do this.");
+ return true;
+ }
+ if(args.length <= 0){
+ if(!(sender instanceof Player)){
+ sender.sendMessage(ChatColor.RED + "Usage: /" + label + " ");
+ return true;
+ }
+ target = participator;
+ }else{
+ Player targetPlayer = Bukkit.getPlayerExact(args[0]);
+ if(targetPlayer == null || !BaseCommand.canSee(sender, targetPlayer) || !sender.hasPermission(command.getPermission() + ".others")){
+ String message = StringUtils.join(args, ' ');
+ String format = ChatColor.AQUA + String.format(Locale.ENGLISH, new StringBuilder().append(ChatColor.BLUE).append("(Staff) ").append(ChatColor.AQUA).append("%1$s").append(ChatColor.GRAY).append(": ").append(ChatColor.AQUA).append("%2$s").toString(), sender.getName(), message);
+ Bukkit.getConsoleSender().sendMessage(format);
+ for(Player other : Bukkit.getServer().getOnlinePlayers()){
+ BaseUser otherUser = this.plugin.getUserManager().getUser(other.getUniqueId());
+ if(!otherUser.isStaffChatVisible() || !other.hasPermission("base.command.staffchat")) continue;
+ other.sendMessage(format);
+ }
+ return true;
+ }
+ target = this.plugin.getUserManager().getUser(targetPlayer.getUniqueId());
+ }
+ boolean newStaffChat = !target.isInStaffChat() || args.length >= 2 && Boolean.parseBoolean(args[1]);
+ target.setInStaffChat(newStaffChat);
+ sender.sendMessage(ChatColor.YELLOW + "Staff chat mode of " + target.getName() + " set to " + newStaffChat + '.');
+ return true;
+ }
+
+ @Override
+ public List onTabComplete(CommandSender sender, Command command, String label, String[] args){
+ return null;
+ }
+ */
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/chat/ToggleMessagesCommand.java b/Base/src/main/java/com/sergivb01/base/command/module/chat/ToggleMessagesCommand.java
new file mode 100644
index 0000000..2bdd689
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/chat/ToggleMessagesCommand.java
@@ -0,0 +1,41 @@
+package com.sergivb01.base.command.module.chat;
+
+import com.sergivb01.base.BasePlugin;
+import com.sergivb01.base.command.BaseCommand;
+import com.sergivb01.base.user.BaseUser;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+public class ToggleMessagesCommand
+ extends BaseCommand{
+ private final BasePlugin plugin;
+
+ public ToggleMessagesCommand(BasePlugin plugin){
+ super("togglemessages", "Toggles private messages.");
+ this.setAliases(new String[]{"togglepm", "toggleprivatemessages"});
+ this.setUsage("/(command)");
+ this.plugin = plugin;
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ if(!(sender instanceof Player)){
+ sender.sendMessage(ChatColor.RED + "This command is only executable for players.");
+ return true;
+ }
+ Player player = (Player) sender;
+ BaseUser baseUser = this.plugin.getUserManager().getUser(player.getUniqueId());
+ boolean newToggled = !baseUser.isMessagesVisible();
+ baseUser.setMessagesVisible(newToggled);
+ if(newToggled){
+ sender.sendMessage(ChatColor.GREEN + "You have enabled private messages.");
+ return true;
+ }else{
+ sender.sendMessage(ChatColor.RED + "You have disabled private messages.");
+ }
+ return true;
+ }
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/chat/ToggleSoundsCommand.java b/Base/src/main/java/com/sergivb01/base/command/module/chat/ToggleSoundsCommand.java
new file mode 100644
index 0000000..cdc53eb
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/chat/ToggleSoundsCommand.java
@@ -0,0 +1,35 @@
+package com.sergivb01.base.command.module.chat;
+
+import com.sergivb01.base.BasePlugin;
+import com.sergivb01.base.command.BaseCommand;
+import com.sergivb01.base.user.BaseUser;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+public class ToggleSoundsCommand extends BaseCommand{
+ private final BasePlugin plugin;
+
+ public ToggleSoundsCommand(BasePlugin plugin){
+ super("togglesounds", "Toggles sounds.");
+ this.setAliases(new String[]{"sounds"});
+ this.setUsage("/(command)");
+ this.plugin = plugin;
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ if(!(sender instanceof Player)){
+ sender.sendMessage(ChatColor.RED + "This command is only executable for players.");
+ return true;
+ }
+ Player player = (Player) sender;
+ BaseUser baseUser = this.plugin.getUserManager().getUser(player.getUniqueId());
+ boolean newToggled = !baseUser.isMessagingSounds();
+ baseUser.setMessagingSounds(newToggled);
+ sender.sendMessage(ChatColor.YELLOW + "You have " + (newToggled ? "enabled" : "disabled") + ChatColor.YELLOW + " sounds.");
+ return true;
+ }
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/chat/ToggleStaffChatCommand.java b/Base/src/main/java/com/sergivb01/base/command/module/chat/ToggleStaffChatCommand.java
new file mode 100644
index 0000000..31dd3ae
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/chat/ToggleStaffChatCommand.java
@@ -0,0 +1,36 @@
+package com.sergivb01.base.command.module.chat;
+
+import com.sergivb01.base.BasePlugin;
+import com.sergivb01.base.command.BaseCommand;
+import com.sergivb01.base.user.BaseUser;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+public class ToggleStaffChatCommand
+ extends BaseCommand{
+ private final BasePlugin plugin;
+
+ public ToggleStaffChatCommand(BasePlugin plugin){
+ super("togglesc", "Toggles private messages.");
+ this.setAliases(new String[]{"toggleac", "togglestaffchat"});
+ this.setUsage("/(command)");
+ this.plugin = plugin;
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ if(!(sender instanceof Player)){
+ sender.sendMessage(ChatColor.RED + "This command is only executable for players.");
+ return true;
+ }
+ Player player = (Player) sender;
+ BaseUser baseUser = this.plugin.getUserManager().getUser(player.getUniqueId());
+ boolean newToggled = !baseUser.isStaffChatVisible();
+ baseUser.setStaffChatVisible(newToggled);
+ sender.sendMessage(ChatColor.YELLOW + "You have turned staffchat visibility " + (newToggled ? String.valueOf(ChatColor.GREEN) + "on" : String.valueOf(ChatColor.RED) + "off") + ChatColor.YELLOW + '.');
+ return true;
+ }
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/chat/YoutubeCommand.java b/Base/src/main/java/com/sergivb01/base/command/module/chat/YoutubeCommand.java
new file mode 100644
index 0000000..6c07f1d
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/chat/YoutubeCommand.java
@@ -0,0 +1,27 @@
+package com.sergivb01.base.command.module.chat;
+
+import com.sergivb01.base.BasePlugin;
+import com.sergivb01.base.command.BaseCommand;
+import com.sergivb01.util.BukkitUtils;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+
+public class YoutubeCommand
+ extends BaseCommand{
+
+ public YoutubeCommand(BasePlugin plugin){
+ super("youtube", "Check requirements");
+ this.setUsage("/(command)");
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ sender.sendMessage(ChatColor.GRAY + BukkitUtils.STRAIGHT_LINE_DEFAULT);
+ sender.sendMessage(ChatColor.GOLD.toString() + ChatColor.BOLD + "YouTuber Requirments");
+ sender.sendMessage(ChatColor.DARK_GRAY + " * " + ChatColor.WHITE + "1000 Subscribers");
+ sender.sendMessage(ChatColor.DARK_GRAY + " * " + ChatColor.WHITE + "1 Video");
+ sender.sendMessage(ChatColor.GRAY + BukkitUtils.STRAIGHT_LINE_DEFAULT);
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/essential/AmivisCommand.java b/Base/src/main/java/com/sergivb01/base/command/module/essential/AmivisCommand.java
new file mode 100644
index 0000000..544ed43
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/essential/AmivisCommand.java
@@ -0,0 +1,51 @@
+package com.sergivb01.base.command.module.essential;
+
+import com.sergivb01.base.BaseConstants;
+import com.sergivb01.base.BasePlugin;
+import com.sergivb01.base.command.BaseCommand;
+import com.sergivb01.util.BukkitUtils;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+import java.util.Collections;
+import java.util.List;
+
+public class AmivisCommand
+ extends BaseCommand{
+ private final BasePlugin plugin;
+
+ public AmivisCommand(BasePlugin plugin){
+ super("amivis", "Check if a player is visible.");
+ this.setUsage("/(command) [targetName]");
+ this.plugin = plugin;
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ boolean vanished;
+ Player target;
+ if(args.length > 0){
+ target = BukkitUtils.playerWithNameOrUUID(args[0]);
+ }else{
+ if(!(sender instanceof Player)){
+ sender.sendMessage(this.getUsage(label));
+ return true;
+ }
+ target = (Player) sender;
+ }
+ if(target == null || !BaseCommand.canSee(sender, target)){
+ sender.sendMessage(String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, args[0]));
+ return true;
+ }
+ sender.sendMessage(ChatColor.YELLOW + target.getName() + " is " + (this.plugin.getUserManager().getUser(target.getUniqueId()).isVanished() ? "in vanish" : "not in vanish") + '.');
+ return true;
+ }
+
+ @Override
+ public List onTabComplete(CommandSender sender, Command command, String label, String[] args){
+ return args.length == 1 ? null : Collections.emptyList();
+ }
+}
+
diff --git a/Base/src/main/java/com/sergivb01/base/command/module/essential/AutoRestartCommand.java b/Base/src/main/java/com/sergivb01/base/command/module/essential/AutoRestartCommand.java
new file mode 100644
index 0000000..8a8e2fa
--- /dev/null
+++ b/Base/src/main/java/com/sergivb01/base/command/module/essential/AutoRestartCommand.java
@@ -0,0 +1,130 @@
+package com.sergivb01.base.command.module.essential;
+
+import com.google.common.base.Strings;
+import com.sergivb01.base.BasePlugin;
+import com.sergivb01.base.command.BaseCommand;
+import com.sergivb01.util.JavaUtils;
+import com.sergivb01.util.command.CommandArgument;
+import com.sergivb01.util.command.CommandWrapper;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DurationFormatUtils;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class AutoRestartCommand
+ extends BaseCommand{
+ private final CommandWrapper handler;
+
+ public AutoRestartCommand(BasePlugin plugin){
+ super("autorestart", "Allows management of server restarts.");
+ this.setUsage("/(command) ");
+ ArrayList arguments = new ArrayList(3);
+ arguments.add(new AutoRestartCancelArgument(plugin));
+ arguments.add(new AutoRestartScheduleArgument(plugin));
+ arguments.add(new AutoRestartTimeArgument(plugin));
+ arguments.sort(new CommandWrapper.ArgumentComparator());
+ this.handler = new CommandWrapper(arguments);
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ return this.handler.onCommand(sender, command, label, args);
+ }
+
+ @Override
+ public List onTabComplete(CommandSender sender, Command command, String label, String[] args){
+ return this.handler.onTabComplete(sender, command, label, args);
+ }
+
+ private static class AutoRestartTimeArgument
+ extends CommandArgument{
+ private final BasePlugin plugin;
+
+ public AutoRestartTimeArgument(BasePlugin plugin){
+ super("time", "Gets the remaining time until next restart.");
+ this.plugin = plugin;
+ this.aliases = new String[]{"remaining", "time"};
+ }
+
+ @Override
+ public String getUsage(String label){
+ return "" + '/' + label + ' ' + this.getName();
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
+ String reason;
+ if(!this.plugin.getAutoRestartHandler().isPendingRestart()){
+ sender.sendMessage(ChatColor.RED + "There is not a restart task pending.");
+ return true;
+ }
+ sender.sendMessage(ChatColor.AQUA + "Automatic restart task occurring in " + DurationFormatUtils.formatDurationWords(this.plugin.getAutoRestartHandler().getRemainingMilliseconds(), true, true) + (Strings.nullToEmpty(reason = this.plugin.getAutoRestartHandler().getReason()).isEmpty() ? "" : new StringBuilder().append(" for ").append(reason).toString()) + '.');
+ return true;
+ }
+ }
+
+ private static class AutoRestartScheduleArgument
+ extends CommandArgument{
+ private final BasePlugin plugin;
+
+ public AutoRestartScheduleArgument(BasePlugin plugin){
+ super("schedule", "Schedule an automatic restart.");
+ this.plugin = plugin;
+ this.aliases = new String[]{"reschedule"};
+ }
+
+ @Override
+ public String getUsage(String label){
+ return "" + '/' + label + ' ' + this.getName() + "