diff --git a/commons/pom.xml b/commons/pom.xml new file mode 100644 index 00000000..92fcc0be --- /dev/null +++ b/commons/pom.xml @@ -0,0 +1,70 @@ + + + 4.0.0 + + me.totalfreedom + TotalFreedomMod + 2023.02 + + + commons + + + 17 + 17 + UTF-8 + + + + + commons-io + commons-io + 2.11.0 + provided + + + + io.papermc + paperlib + 1.0.7 + compile + + + + org.apache.commons + commons-lang3 + 3.12.0 + provided + + + + org.bstats + bstats-bukkit + 3.0.0 + compile + + + + me.totalfreedom + discord + 2023.02 + provided + + + + org.reflections + reflections + 0.10.2 + compile + + + + org.eclipse.sisu + org.eclipse.sisu.inject + 0.3.5 + compile + + + \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/Announcer.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/Announcer.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/Announcer.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/Announcer.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/AntiNuke.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/AntiNuke.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/AntiNuke.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/AntiNuke.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/AntiSpam.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/AntiSpam.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/AntiSpam.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/AntiSpam.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/AutoEject.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/AutoEject.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/AutoEject.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/AutoEject.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/AutoKick.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/AutoKick.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/AutoKick.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/AutoKick.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/BackupManager.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/BackupManager.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/BackupManager.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/BackupManager.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/CommandSpy.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/CommandSpy.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/CommandSpy.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/CommandSpy.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/EntityWiper.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/EntityWiper.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/EntityWiper.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/EntityWiper.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/FreedomService.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/FreedomService.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/FreedomService.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/FreedomService.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/FreedomServiceHandler.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/FreedomServiceHandler.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/FreedomServiceHandler.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/FreedomServiceHandler.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/FrontDoor.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/FrontDoor.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/FrontDoor.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/FrontDoor.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/Fuckoff.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/Fuckoff.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/Fuckoff.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/Fuckoff.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/GameRuleHandler.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/GameRuleHandler.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/GameRuleHandler.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/GameRuleHandler.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/Monitors.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/MovementValidator.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/MovementValidator.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/MovementValidator.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/MovementValidator.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/Muter.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/Muter.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/Muter.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/Muter.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/Orbiter.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/Orbiter.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/Orbiter.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/Orbiter.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/ServerPing.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/ServerPing.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/ServerPing.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/ServerPing.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java similarity index 98% rename from src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java index 68588f94..0526bd85 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java @@ -3,6 +3,8 @@ package me.totalfreedom.totalfreedommod; import java.io.File; import java.io.InputStream; import java.util.Properties; + +import me.totalfreedom.discord.TFM_Accessor; import me.totalfreedom.totalfreedommod.admin.ActivityLog; import me.totalfreedom.totalfreedommod.admin.AdminList; import me.totalfreedom.totalfreedommod.banning.BanManager; @@ -24,7 +26,7 @@ import me.totalfreedom.totalfreedommod.bridge.WorldGuardBridge; import me.totalfreedom.totalfreedommod.caging.Cager; import me.totalfreedom.totalfreedommod.command.CommandLoader; import me.totalfreedom.totalfreedommod.config.MainConfig; -import me.totalfreedom.totalfreedommod.discord.Discord; +import me.totalfreedom.discord.TFD4J; import me.totalfreedom.totalfreedommod.freeze.Freezer; import me.totalfreedom.totalfreedommod.fun.ItemFun; import me.totalfreedom.totalfreedommod.fun.Jumppads; @@ -90,7 +92,7 @@ public class TotalFreedomMod extends JavaPlugin public SQLite sql; public Announcer an; public ChatManager cm; - public Discord dc; + public TFD4J dc; public PunishmentList pul; public BanManager bm; public IndefiniteBanList im; @@ -301,7 +303,7 @@ public class TotalFreedomMod extends JavaPlugin vo = new Votifier(); an = new Announcer(); cm = new ChatManager(); - dc = new Discord(); + dc = new TFM_Accessor().botAccessor(); pul = new PunishmentList(); bm = new BanManager(); im = new IndefiniteBanList(); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/VanishHandler.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/VanishHandler.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/VanishHandler.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/VanishHandler.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/admin/ActivityLog.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/admin/ActivityLog.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/admin/ActivityLog.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/admin/ActivityLog.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/admin/ActivityLogEntry.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/admin/ActivityLogEntry.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/admin/ActivityLogEntry.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/admin/ActivityLogEntry.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/banning/Ban.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/Ban.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/banning/Ban.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/banning/Ban.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/banning/BanManager.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/BanManager.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/banning/BanManager.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/banning/BanManager.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBan.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBan.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBan.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBan.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBanList.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBanList.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBanList.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBanList.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/EditBlocker.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/EditBlocker.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/blocking/EditBlocker.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/EditBlocker.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/PVPBlocker.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/PVPBlocker.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/blocking/PVPBlocker.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/PVPBlocker.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/PotionBlocker.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/PotionBlocker.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/blocking/PotionBlocker.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/PotionBlocker.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlocker.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlocker.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlocker.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlocker.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerAction.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerAction.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerAction.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerAction.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerEntry.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerEntry.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerEntry.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerEntry.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerRank.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerRank.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerRank.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerRank.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/BukkitTelnetBridge.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/BukkitTelnetBridge.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/bridge/BukkitTelnetBridge.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/BukkitTelnetBridge.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/EssentialsBridge.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/EssentialsBridge.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/bridge/EssentialsBridge.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/EssentialsBridge.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/LibsDisguisesBridge.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/LibsDisguisesBridge.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/bridge/LibsDisguisesBridge.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/LibsDisguisesBridge.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldGuardBridge.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldGuardBridge.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldGuardBridge.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldGuardBridge.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/caging/CageData.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/caging/CageData.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/caging/CageData.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/caging/CageData.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/caging/Cager.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/caging/Cager.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/caging/Cager.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/caging/Cager.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/CommandFailException.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/CommandFailException.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/CommandFailException.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/CommandFailException.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/CommandLoader.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/CommandLoader.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/CommandLoader.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/CommandLoader.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/CommandParameters.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/CommandParameters.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/CommandParameters.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/CommandParameters.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/CommandPermissions.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/CommandPermissions.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/CommandPermissions.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/CommandPermissions.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminchat.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminchat.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminchat.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminchat.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_admininfo.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_admininfo.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_admininfo.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_admininfo.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminmode.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminmode.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminmode.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminmode.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminworld.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminworld.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminworld.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminworld.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adventure.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adventure.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_adventure.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adventure.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_aeclear.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_aeclear.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_aeclear.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_aeclear.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_announce.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_announce.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_announce.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_announce.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_attributelist.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_attributelist.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_attributelist.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_attributelist.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_autoclear.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_autoclear.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_autoclear.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_autoclear.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_autotp.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_autotp.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_autotp.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_autotp.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ban.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ban.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_ban.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ban.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_banip.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_banip.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_banip.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_banip.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_banlist.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_banlist.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_banlist.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_banlist.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_banname.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_banname.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_banname.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_banname.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_bird.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_bird.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_bird.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_bird.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockedit.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockedit.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockedit.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockedit.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockpvp.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockpvp.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockpvp.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockpvp.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockredstone.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockredstone.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockredstone.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockredstone.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cake.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cake.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_cake.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cake.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cartsit.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cartsit.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_cartsit.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cartsit.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cleanchat.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cleanchat.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_cleanchat.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cleanchat.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cleardiscordqueue.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cleardiscordqueue.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_cleardiscordqueue.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cleardiscordqueue.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearinventory.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearinventory.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearinventory.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearinventory.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clownfish.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clownfish.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_clownfish.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clownfish.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cmdspy.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cmdspy.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_cmdspy.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cmdspy.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_coins.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_coins.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_coins.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_coins.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_colorme.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_colorme.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_colorme.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_colorme.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_commandlist.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_commandlist.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_commandlist.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_commandlist.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_consolesay.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_consolesay.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_consolesay.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_consolesay.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cookie.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cookie.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_cookie.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cookie.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_creative.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_creative.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_creative.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_creative.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deafen.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deafen.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_deafen.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deafen.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_debugstick.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_debugstick.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_debugstick.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_debugstick.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_denick.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_denick.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_denick.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_denick.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deop.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deop.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_deop.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deop.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deopall.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deopall.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_deopall.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deopall.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_disguisetoggle.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_disguisetoggle.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_disguisetoggle.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_disguisetoggle.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_dispfill.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_dispfill.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_dispfill.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_dispfill.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_doom.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_doom.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_doom.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_doom.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_eject.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_eject.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_eject.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_eject.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_enchant.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_enchant.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_enchant.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_enchant.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_end.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_end.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_end.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_end.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_entitywipe.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_entitywipe.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_entitywipe.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_entitywipe.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_expel.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_expel.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_expel.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_expel.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_explode.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_explode.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_explode.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_explode.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_explosivearrows.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_explosivearrows.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_explosivearrows.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_explosivearrows.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_findip.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_findip.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_findip.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_findip.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fireball.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fireball.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_fireball.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fireball.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_flatlands.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_flatlands.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_flatlands.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_flatlands.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_forcekill.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_forcekill.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_forcekill.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_forcekill.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_freeze.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_freeze.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_freeze.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_freeze.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fuckoff.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fuckoff.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_fuckoff.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fuckoff.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gcmd.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gcmd.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_gcmd.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gcmd.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_glow.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_glow.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_glow.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_glow.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_grapplinghook.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_grapplinghook.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_grapplinghook.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_grapplinghook.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gravity.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gravity.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_gravity.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gravity.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_health.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_health.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_health.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_health.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_indefban.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_indefban.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_indefban.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_indefban.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_inspect.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_inspect.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_inspect.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_inspect.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_invis.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_invis.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_invis.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_invis.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_invsee.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_invsee.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_invsee.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_invsee.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_jumppads.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_jumppads.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_jumppads.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_jumppads.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_kick.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_kick.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_kick.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_kick.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_kicknoob.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_kicknoob.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_kicknoob.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_kicknoob.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_landmine.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_landmine.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_landmine.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_landmine.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_lastcmd.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_lastcmd.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_lastcmd.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_lastcmd.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_lightningrod.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_lightningrod.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_lightningrod.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_lightningrod.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_linkdiscord.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_linkdiscord.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_linkdiscord.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_linkdiscord.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_links.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_links.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_links.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_links.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_localspawn.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_localspawn.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_localspawn.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_localspawn.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_lockup.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_lockup.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_lockup.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_lockup.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_loginmessage.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_loginmessage.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_loginmessage.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_loginmessage.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manageshop.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manageshop.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_manageshop.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manageshop.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_masterbuilderinfo.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_masterbuilderinfo.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_masterbuilderinfo.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_masterbuilderinfo.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_masterbuilderworld.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_masterbuilderworld.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_masterbuilderworld.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_masterbuilderworld.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mbconfig.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mbconfig.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_mbconfig.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mbconfig.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_moblimiter.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_moblimiter.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_moblimiter.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_moblimiter.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mobpurge.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mobpurge.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_mobpurge.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mobpurge.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mp44.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mp44.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_mp44.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mp44.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mute.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mute.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_mute.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mute.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myinfo.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myinfo.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_myinfo.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myinfo.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nether.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nether.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_nether.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nether.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickclean.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickclean.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickclean.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickclean.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickfilter.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickfilter.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickfilter.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickfilter.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickgradient.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickgradient.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickgradient.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickgradient.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nicknyan.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nicknyan.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_nicknyan.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nicknyan.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickrainbow.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickrainbow.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickrainbow.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickrainbow.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_notes.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_notes.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_notes.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_notes.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_op.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_op.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_op.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_op.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opall.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opall.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_opall.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opall.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opme.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opme.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_opme.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opme.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ops.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ops.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_ops.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ops.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_orbit.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_orbit.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_orbit.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_orbit.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_permissions.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_permissions.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_permissions.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_permissions.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_playtime.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_playtime.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_playtime.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_playtime.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_plotworld.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_plotworld.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_plotworld.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_plotworld.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_plugincontrol.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_plugincontrol.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_plugincontrol.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_plugincontrol.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potionspy.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potionspy.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_potionspy.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potionspy.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_purgeall.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_purgeall.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_purgeall.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_purgeall.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rank.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rank.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_rank.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rank.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rawsay.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rawsay.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_rawsay.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rawsay.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_reactionbar.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_reactionbar.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_reactionbar.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_reactionbar.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_report.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_report.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_report.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_report.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rideablepearl.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rideablepearl.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_rideablepearl.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rideablepearl.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ro.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ro.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_ro.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ro.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rock.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rock.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_rock.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rock.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_say.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_say.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_say.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_say.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_scare.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_scare.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_scare.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_scare.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_seed.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_seed.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_seed.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_seed.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_serverstats.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_serverstats.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_serverstats.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_serverstats.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setcompass.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setcompass.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_setcompass.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setcompass.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlimit.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlimit.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlimit.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlimit.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setplayerlimit.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setplayerlimit.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_setplayerlimit.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setplayerlimit.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setspawnworld.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setspawnworld.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_setspawnworld.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setspawnworld.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_settotalvotes.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_settotalvotes.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_settotalvotes.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_settotalvotes.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_shop.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_shop.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_shop.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_shop.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spawnmob.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spawnmob.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_spawnmob.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spawnmob.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectate.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectate.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectate.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectate.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectator.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectator.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectator.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectator.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stackingpotato.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stackingpotato.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_stackingpotato.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stackingpotato.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_status.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_status.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_status.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_status.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stop.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stop.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_stop.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stop.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stopsound.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stopsound.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_stopsound.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stopsound.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_survival.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_survival.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_survival.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_survival.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagnyan.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagnyan.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagnyan.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagnyan.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagrainbow.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagrainbow.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagrainbow.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagrainbow.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tempban.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tempban.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_tempban.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tempban.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglechat.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglechat.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglechat.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglechat.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggleclownfish.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggleclownfish.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggleclownfish.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggleclownfish.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglediscord.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglediscord.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglediscord.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglediscord.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglepickup.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglepickup.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglepickup.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglepickup.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tossmob.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tossmob.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_tossmob.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tossmob.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_totalfreedommod.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_totalfreedommod.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_totalfreedommod.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_totalfreedommod.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tprandom.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tprandom.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_tprandom.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tprandom.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_trail.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_trail.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_trail.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_trail.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unban.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unban.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_unban.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unban.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unbanip.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unbanip.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_unbanip.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unbanip.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unbanname.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unbanname.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_unbanname.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unbanname.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unblockcmd.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unblockcmd.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_unblockcmd.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unblockcmd.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_uncage.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_uncage.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_uncage.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_uncage.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_undisguiseall.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_undisguiseall.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_undisguiseall.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_undisguiseall.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unlinkdiscord.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unlinkdiscord.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_unlinkdiscord.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unlinkdiscord.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unmute.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unmute.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_unmute.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unmute.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vote.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vote.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_vote.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vote.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_warn.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_warn.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_warn.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_warn.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whitelist.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whitelist.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_whitelist.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whitelist.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whohas.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whohas.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_whohas.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whohas.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wildcard.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wildcard.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/Command_wildcard.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wildcard.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/FreedomCommand.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/FreedomCommand.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/FreedomCommand.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/FreedomCommand.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/SourceType.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/SourceType.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/command/SourceType.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/command/SourceType.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/config/ConfigEntry.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/config/IConfig.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/config/IConfig.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/config/IConfig.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/config/IConfig.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/config/MainConfig.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/config/MainConfig.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/config/MainConfig.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/config/MainConfig.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/config/YamlConfig.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/config/YamlConfig.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/config/YamlConfig.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/config/YamlConfig.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/freeze/FreezeData.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/freeze/FreezeData.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/freeze/FreezeData.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/freeze/FreezeData.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/freeze/Freezer.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/freeze/Freezer.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/freeze/Freezer.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/freeze/Freezer.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/fun/Jumppads.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/Jumppads.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/fun/Jumppads.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/fun/Jumppads.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/fun/Landminer.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/Landminer.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/fun/Landminer.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/fun/Landminer.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/fun/MP44.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/MP44.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/fun/MP44.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/fun/MP44.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/fun/Trailer.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/Trailer.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/fun/Trailer.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/fun/Trailer.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTMLGenerationTools.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTMLGenerationTools.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/httpd/HTMLGenerationTools.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTMLGenerationTools.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTTPDPageBuilder.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTTPDPageBuilder.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/httpd/HTTPDPageBuilder.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTTPDPageBuilder.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTTPDaemon.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTTPDaemon.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/httpd/HTTPDaemon.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTTPDaemon.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/ModuleExecutable.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/ModuleExecutable.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/httpd/ModuleExecutable.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/ModuleExecutable.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/NanoHTTPD.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/NanoHTTPD.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/httpd/NanoHTTPD.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/NanoHTTPD.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/HTTPDModule.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/HTTPDModule.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/httpd/module/HTTPDModule.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/HTTPDModule.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_activitylog.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_activitylog.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_activitylog.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_activitylog.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_admins.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_admins.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_admins.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_admins.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_bans.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_bans.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_bans.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_bans.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_file.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_file.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_file.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_file.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_help.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_help.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_help.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_help.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_indefbans.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_indefbans.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_indefbans.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_indefbans.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_index.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_index.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_index.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_index.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_list.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_list.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_list.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_list.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_logfile.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_logfile.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_logfile.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_logfile.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_players.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_players.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_players.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_players.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_punishments.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_punishments.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_punishments.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_punishments.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_schematic.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_schematic.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_schematic.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_schematic.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionConfig.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionConfig.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionConfig.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionConfig.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionEntry.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionEntry.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionEntry.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionEntry.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionManager.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionManager.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionManager.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionManager.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerList.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerList.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/player/PlayerList.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerList.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/punishments/Punishment.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/punishments/Punishment.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/punishments/Punishment.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/punishments/Punishment.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/punishments/PunishmentList.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/punishments/PunishmentList.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/punishments/PunishmentList.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/punishments/PunishmentList.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/punishments/PunishmentType.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/punishments/PunishmentType.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/punishments/PunishmentType.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/punishments/PunishmentType.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/rank/Displayable.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/Displayable.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/rank/Displayable.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/rank/Displayable.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/rank/Rank.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/Rank.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/rank/Rank.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/rank/Rank.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/rank/Title.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/Title.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/rank/Title.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/rank/Title.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/FLog.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FLog.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/util/FLog.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/util/FLog.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/FSync.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FSync.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/util/FSync.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/util/FSync.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/Groups.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/Groups.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/util/Groups.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/util/Groups.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/MethodTimer.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/MethodTimer.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/util/MethodTimer.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/util/MethodTimer.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/TimeUnit.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/TimeUnit.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/util/TimeUnit.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/util/TimeUnit.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/AdminWorld.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/AdminWorld.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/world/AdminWorld.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/world/AdminWorld.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/CleanroomChunkGenerator.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/CleanroomChunkGenerator.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/world/CleanroomChunkGenerator.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/world/CleanroomChunkGenerator.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/CustomWorld.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/CustomWorld.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/world/CustomWorld.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/world/CustomWorld.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/Flatlands.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/Flatlands.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/world/Flatlands.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/world/Flatlands.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/MasterBuilderWorld.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/MasterBuilderWorld.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/world/MasterBuilderWorld.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/world/MasterBuilderWorld.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/WorldManager.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldManager.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/world/WorldManager.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldManager.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/WorldRestrictions.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldRestrictions.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/world/WorldRestrictions.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldRestrictions.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/WorldTime.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldTime.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/world/WorldTime.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldTime.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/WorldWeather.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldWeather.java similarity index 100% rename from src/main/java/me/totalfreedom/totalfreedommod/world/WorldWeather.java rename to commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldWeather.java diff --git a/src/main/resources/activitylog.yml b/commons/src/main/resources/activitylog.yml similarity index 100% rename from src/main/resources/activitylog.yml rename to commons/src/main/resources/activitylog.yml diff --git a/src/main/resources/backup/backup.yml b/commons/src/main/resources/backup/backup.yml similarity index 100% rename from src/main/resources/backup/backup.yml rename to commons/src/main/resources/backup/backup.yml diff --git a/src/main/resources/config.yml b/commons/src/main/resources/config.yml similarity index 100% rename from src/main/resources/config.yml rename to commons/src/main/resources/config.yml diff --git a/src/main/resources/indefinitebans.yml b/commons/src/main/resources/indefinitebans.yml similarity index 100% rename from src/main/resources/indefinitebans.yml rename to commons/src/main/resources/indefinitebans.yml diff --git a/src/main/resources/permissions.yml b/commons/src/main/resources/permissions.yml similarity index 100% rename from src/main/resources/permissions.yml rename to commons/src/main/resources/permissions.yml diff --git a/src/main/resources/plugin.yml b/commons/src/main/resources/plugin.yml similarity index 87% rename from src/main/resources/plugin.yml rename to commons/src/main/resources/plugin.yml index 24ea4a9e..26d0d4f7 100644 --- a/src/main/resources/plugin.yml +++ b/commons/src/main/resources/plugin.yml @@ -13,6 +13,7 @@ softdepend: - JDA - Votifier authors: [Madgeek1450, Prozza] +loadbefore: [TFD4J, TF-Shoppe] api-version: "1.17" libraries: - org.apache.commons:commons-lang3:3.12.0 diff --git a/src/main/resources/punishments.yml b/commons/src/main/resources/punishments.yml similarity index 100% rename from src/main/resources/punishments.yml rename to commons/src/main/resources/punishments.yml diff --git a/discord/pom.xml b/discord/pom.xml new file mode 100644 index 00000000..59910ddf --- /dev/null +++ b/discord/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + + me.totalfreedom + TotalFreedomMod + 2023.02 + + + discord + + + 17 + 17 + UTF-8 + + + + + com.discord4j + discord4j-core + 3.2.3 + provided + + + me.totalfreedom + commons + 2023.02 + provided + + + io.projectreactor + reactor-core + 3.5.1 + provided + + + + \ No newline at end of file diff --git a/discord/src/main/java/me/totalfreedom/discord/Bot.java b/discord/src/main/java/me/totalfreedom/discord/Bot.java new file mode 100644 index 00000000..2870566b --- /dev/null +++ b/discord/src/main/java/me/totalfreedom/discord/Bot.java @@ -0,0 +1,138 @@ +package me.totalfreedom.discord; + +import discord4j.common.util.Snowflake; +import discord4j.core.DiscordClientBuilder; +import discord4j.core.GatewayDiscordClient; +import discord4j.core.event.domain.interaction.ChatInputInteractionEvent; +import discord4j.core.object.entity.Guild; +import discord4j.core.object.entity.Message; +import discord4j.core.object.entity.channel.TextChannel; +import me.totalfreedom.discord.command.HelpCommand; +import me.totalfreedom.discord.command.ListCommand; +import me.totalfreedom.discord.command.TPSCommand; +import me.totalfreedom.discord.handling.CommandHandler; +import me.totalfreedom.discord.util.SnowflakeEntry; +import me.totalfreedom.discord.util.TFM_Bridge; +import me.totalfreedom.totalfreedommod.config.ConfigEntry; +import me.totalfreedom.totalfreedommod.player.PlayerData; +import me.totalfreedom.totalfreedommod.util.FLog; +import net.dv8tion.jda.internal.utils.concurrent.CountingThreadFactory; +import org.bukkit.Bukkit; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledThreadPoolExecutor; + +public class Bot +{ + private final GatewayDiscordClient client; + private final TFM_Bridge tfm; + private final HashMap LINK_CODES = new HashMap<>(); + private ScheduledThreadPoolExecutor RATELIMIT_EXECUTOR; + private Boolean enabled = false; + + + public Bot() + { + //Creates the gateway client and connects to the gateway + this.client = DiscordClientBuilder.create(ConfigEntry.DISCORD_TOKEN.getString()) + .build() + .login() + .block(); + + if (client == null) throw new IllegalStateException(); + + final CommandHandler handler = new CommandHandler(client.getRestClient()); + + /* Call our code to handle creating/deleting/editing our global slash commands. + We have to hard code our list of command files since iterating over a list of files in a resource directory + is overly complicated for such a simple demo and requires handling for both IDE and .jar packaging. + Using SpringBoot we can avoid all of this and use their resource pattern matcher to do this for us. + */ + List commands = List.of("greet.json", "ping.json"); + + try + { + handler.registerCommands(commands); + handler.registerCommand(new HelpCommand()); + handler.registerCommand(new ListCommand()); + handler.registerCommand(new TPSCommand()); + } catch (Exception e) + { + Bukkit.getLogger().severe("Error trying to register global slash commands.\n" + e.getMessage()); + } + //Register our slash command listener + client.on(ChatInputInteractionEvent.class, handler::handle) + .then(client.onDisconnect()) + .block(); // We use .block() as there is not another non-daemon thread and the jvm would close otherwise. + + this.tfm = new TFM_Bridge(this); + + RATELIMIT_EXECUTOR = new ScheduledThreadPoolExecutor(5, new CountingThreadFactory(this::poolIdentifier, "RateLimit")); + RATELIMIT_EXECUTOR.setRemoveOnCancelPolicy(true); + } + + private String poolIdentifier() + { + return "TFD4J"; + } + + public TFM_Bridge getTFM() + { + return tfm; + } + + public Mono getGuildById() + { + return client.getGuildById(SnowflakeEntry.serverID); + } + + public GatewayDiscordClient getClient() + { + return client; + } + + public Map getLinkCodes() + { + return LINK_CODES; + } + + public boolean shouldISendReport() + { + if (ConfigEntry.DISCORD_REPORT_CHANNEL_ID.getString().isEmpty()) + { + return false; + } + + if (ConfigEntry.DISCORD_SERVER_ID.getString().isEmpty()) + { + FLog.severe("No Discord server ID was specified in the config, but there is a report channel ID."); + return false; + } + + Guild server = client.getGuildById(SnowflakeEntry.serverID).block(); + if (server == null) + + { + FLog.severe("The Discord server ID specified is invalid, or the bot is not on the server."); + return false; + } + + TextChannel channel = server.getChannelById(SnowflakeEntry.reportChannelID) + .ofType(TextChannel.class) + .block(); + + if (channel == null) + { + FLog.severe("The report channel ID specified in the config is invalid."); + return false; + } + + return true; + } +} diff --git a/discord/src/main/java/me/totalfreedom/discord/TFD4J.java b/discord/src/main/java/me/totalfreedom/discord/TFD4J.java new file mode 100644 index 00000000..27005a1f --- /dev/null +++ b/discord/src/main/java/me/totalfreedom/discord/TFD4J.java @@ -0,0 +1,54 @@ +package me.totalfreedom.discord; + +import me.totalfreedom.discord.listener.AdminChatListener; +import me.totalfreedom.discord.listener.BukkitNative; +import me.totalfreedom.discord.listener.MinecraftListener; +import me.totalfreedom.discord.util.Utilities; +import org.bukkit.plugin.java.JavaPlugin; + +public class TFD4J extends JavaPlugin +{ + private Bot bot; + private Utilities utils; + private MinecraftListener mc; + private AdminChatListener ac; + + @Override + public void onEnable() + { + this.bot = new Bot(); + this.utils = new Utilities(this); + new BukkitNative(this); + this.mc = new MinecraftListener(this); + this.ac = new AdminChatListener(this); + + mc.minecraftChatBound(); + ac.adminChatBound(); + } + + @Override + public void onDisable() + { + bot.getClient().onDisconnect().subscribe(); + } + + public Bot getBot() + { + return bot; + } + + public Utilities getUtils() + { + return utils; + } + + public MinecraftListener getMinecraftListener() + { + return mc; + } + + public AdminChatListener getAdminChatListener() + { + return ac; + } +} diff --git a/discord/src/main/java/me/totalfreedom/discord/TFM_Accessor.java b/discord/src/main/java/me/totalfreedom/discord/TFM_Accessor.java new file mode 100644 index 00000000..705d1641 --- /dev/null +++ b/discord/src/main/java/me/totalfreedom/discord/TFM_Accessor.java @@ -0,0 +1,18 @@ +package me.totalfreedom.discord; + +import org.bukkit.Bukkit; + +public class TFM_Accessor +{ + private final TFD4J accessor; + + public TFM_Accessor() + { + this.accessor = (TFD4J) Bukkit.getPluginManager().getPlugin("TFD4J"); + } + + public TFD4J botAccessor() + { + return accessor; + } +} diff --git a/discord/src/main/java/me/totalfreedom/discord/command/HelpCommand.java b/discord/src/main/java/me/totalfreedom/discord/command/HelpCommand.java new file mode 100644 index 00000000..d8499e7c --- /dev/null +++ b/discord/src/main/java/me/totalfreedom/discord/command/HelpCommand.java @@ -0,0 +1,36 @@ +package me.totalfreedom.discord.command; + +import discord4j.core.event.domain.interaction.ChatInputInteractionEvent; +import discord4j.core.spec.EmbedCreateSpec; +import discord4j.rest.util.Color; +import me.totalfreedom.discord.handling.SlashCommand; +import reactor.core.publisher.Mono; + +import java.time.Instant; + +public class HelpCommand implements SlashCommand +{ + @Override + public String getName() + { + return "help"; + } + + @Override + public Mono handle(ChatInputInteractionEvent event) + { + EmbedCreateSpec spec = EmbedCreateSpec.builder() + .color(Color.GREEN) + .title("Help Command") + .addField("Commands", "This is a list of all commands", false) + .addField("\u200B", "\u200B", false) + .addField("help", "Displays the help command. (This command.)", true) + .addField("list", "Displays a list of all online players.", true) + .addField("tps", "Displays the server's TPS.", true) + .timestamp(Instant.now()) + .build(); + + return event.reply() + .withEmbeds(spec); + } +} diff --git a/discord/src/main/java/me/totalfreedom/discord/command/ListCommand.java b/discord/src/main/java/me/totalfreedom/discord/command/ListCommand.java new file mode 100644 index 00000000..c11504c5 --- /dev/null +++ b/discord/src/main/java/me/totalfreedom/discord/command/ListCommand.java @@ -0,0 +1,57 @@ +package me.totalfreedom.discord.command; + +import discord4j.core.event.domain.interaction.ChatInputInteractionEvent; +import discord4j.core.spec.EmbedCreateSpec; +import discord4j.rest.util.Color; +import me.totalfreedom.discord.handling.SlashCommand; +import me.totalfreedom.totalfreedommod.config.ConfigEntry; +import org.bukkit.Bukkit; +import org.bukkit.entity.HumanEntity; +import reactor.core.publisher.Mono; + +import java.util.Iterator; +import java.util.List; + +public class ListCommand implements SlashCommand +{ + + @Override + public String getName() + { + return "list"; + } + + @Override + public Mono handle(ChatInputInteractionEvent event) + { + List playerNames = Bukkit.getOnlinePlayers() + .stream() + .map(HumanEntity::getName) + .toList(); + + StringBuilder sb = new StringBuilder(); + Iterator iterator = playerNames.iterator(); + while (iterator.hasNext()) { + sb.append(iterator.next()); + if (iterator.hasNext()) { + sb.append(", \n"); + } + } + + String empty = "\u200B"; + + EmbedCreateSpec spec = EmbedCreateSpec.builder() + .title("Player List - " + ConfigEntry.SERVER_NAME.getString()) + .color(Color.BISMARK) + .addField("Online Players", String.join(", ", playerNames), false) + .addField(empty, "Currently Online: " + playerNames.size(), false) + .addField(empty, empty, false) + .addField("Players: ", sb.toString(), true) + .build(); + + return event.reply() + .withEmbeds(spec) + .withEphemeral(true) + .withContent(sb.toString()); + } +} diff --git a/discord/src/main/java/me/totalfreedom/discord/command/TPSCommand.java b/discord/src/main/java/me/totalfreedom/discord/command/TPSCommand.java new file mode 100644 index 00000000..b7ccb73d --- /dev/null +++ b/discord/src/main/java/me/totalfreedom/discord/command/TPSCommand.java @@ -0,0 +1,39 @@ +package me.totalfreedom.discord.command; + +import discord4j.core.event.domain.interaction.ChatInputInteractionEvent; +import discord4j.core.spec.EmbedCreateSpec; +import discord4j.rest.util.Color; +import me.totalfreedom.discord.handling.SlashCommand; +import me.totalfreedom.totalfreedommod.util.FUtil; +import org.bukkit.Bukkit; +import org.jetbrains.annotations.NotNull; +import reactor.core.publisher.Mono; + +public class TPSCommand implements SlashCommand +{ + @Override + public String getName() + { + return "tps"; + } + + @Override + public Mono handle(@NotNull ChatInputInteractionEvent event) + { + String tps = String.valueOf(FUtil.getMeanAverageDouble(Bukkit.getServer().getTPS())); + + EmbedCreateSpec spec = EmbedCreateSpec.builder() + .title("Current Server Tick Information") + .addField("TPS", tps, false) + .addField("Uptime", FUtil.getUptime(), false) + .addField("Maximum Memory", Math.ceil(FUtil.getMaxMem()) + " MB", false) + .addField("Allocated Memory", Math.ceil(FUtil.getTotalMem()) + " MB", false) + .addField("Free Memory", Math.ceil(FUtil.getFreeMem()) + " MB", false) + .color(Color.BISMARK) + .build(); + + return event.reply() + .withEmbeds(spec) + .withEphemeral(true); + } +} diff --git a/discord/src/main/java/me/totalfreedom/discord/handling/CommandHandler.java b/discord/src/main/java/me/totalfreedom/discord/handling/CommandHandler.java new file mode 100644 index 00000000..2ed4de49 --- /dev/null +++ b/discord/src/main/java/me/totalfreedom/discord/handling/CommandHandler.java @@ -0,0 +1,113 @@ +package me.totalfreedom.discord.handling; + +import discord4j.common.JacksonResources; +import discord4j.core.event.domain.interaction.ChatInputInteractionEvent; +import discord4j.discordjson.json.ApplicationCommandRequest; +import discord4j.rest.RestClient; +import discord4j.rest.service.ApplicationService; +import org.bukkit.Bukkit; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +public class CommandHandler +{ + private final List commands = new ArrayList<>(); + private final RestClient restClient; + + public CommandHandler(RestClient restClient) + { + this.restClient = restClient; + } + + public void registerCommands(List fileNames) throws IOException + { + //Create an ObjectMapper that supports Discord4J classes + final JacksonResources d4jMapper = JacksonResources.create(); + + // Convenience variables for the sake of easier to read code below + final ApplicationService applicationService = restClient.getApplicationService(); + final long applicationId = Objects.requireNonNull(restClient.getApplicationId().block()); + + //Get our commands json from resources as command data + List commands = new ArrayList<>(); + for (String json : getCommandsJson(fileNames)) + { + ApplicationCommandRequest request = d4jMapper.getObjectMapper() + .readValue(json, ApplicationCommandRequest.class); + + commands.add(request); //Add to our array list + } + + /* Bulk overwrite commands. This is now idempotent, so it is safe to use this even when only 1 command + is changed/added/removed + */ + applicationService.bulkOverwriteGlobalApplicationCommand(applicationId, commands) + .doOnNext(cmd -> Bukkit.getLogger().info("Successfully registered Global Command " + + cmd.name())) + .doOnError(e -> Bukkit.getLogger().severe("Failed to register global commands.\n" + + e.getMessage())) + .subscribe(); + } + + private @NotNull List getCommandsJson(List fileNames) throws IOException + { + // Confirm that the commands folder exists + String commandsFolderName = "commands/"; + URL url = this.getClass().getClassLoader().getResource(commandsFolderName); + Objects.requireNonNull(url, commandsFolderName + " could not be found"); + + //Get all the files inside this folder and return the contents of the files as a list of strings + List list = new ArrayList<>(); + for (String file : fileNames) + { + String resourceFileAsString = getResourceFileAsString(commandsFolderName + file); + list.add(Objects.requireNonNull(resourceFileAsString, "Command file not found: " + file)); + } + return list; + } + + private @Nullable String getResourceFileAsString(String fileName) throws IOException + { + ClassLoader classLoader = ClassLoader.getSystemClassLoader(); + try (InputStream resourceAsStream = classLoader.getResourceAsStream(fileName)) + { + if (resourceAsStream == null) return null; + try (InputStreamReader inputStreamReader = new InputStreamReader(resourceAsStream); + BufferedReader reader = new BufferedReader(inputStreamReader)) + { + return reader.lines().collect(Collectors.joining(System.lineSeparator())); + } + } + } + + public void registerCommand(SlashCommand command) + { + commands.add(command); + } + + public Mono handle(ChatInputInteractionEvent event) + { + // Convert our array list to a flux that we can iterate through + return Flux.fromIterable(commands) + //Filter out all commands that don't match the name of the command this event is for + .filter(command -> command.getName().equals(event.getCommandName())) + // Get the first (and only) item in the flux that matches our filter + .next() + //have our command class handle all the logic related to its specific command. + .flatMap(command -> command.handle(event)); + } + + +} diff --git a/discord/src/main/java/me/totalfreedom/discord/handling/SlashCommand.java b/discord/src/main/java/me/totalfreedom/discord/handling/SlashCommand.java new file mode 100644 index 00000000..f549cb79 --- /dev/null +++ b/discord/src/main/java/me/totalfreedom/discord/handling/SlashCommand.java @@ -0,0 +1,10 @@ +package me.totalfreedom.discord.handling; + +import discord4j.core.event.domain.interaction.ChatInputInteractionEvent; +import reactor.core.publisher.Mono; + +public interface SlashCommand { + String getName(); + + Mono handle(ChatInputInteractionEvent event); +} diff --git a/discord/src/main/java/me/totalfreedom/discord/listener/AdminChatListener.java b/discord/src/main/java/me/totalfreedom/discord/listener/AdminChatListener.java new file mode 100644 index 00000000..0ef2decc --- /dev/null +++ b/discord/src/main/java/me/totalfreedom/discord/listener/AdminChatListener.java @@ -0,0 +1,159 @@ +package me.totalfreedom.discord.listener; + +import com.google.common.base.Strings; +import discord4j.core.event.domain.message.MessageCreateEvent; +import discord4j.core.object.entity.Attachment; +import discord4j.core.object.entity.Guild; +import discord4j.core.object.entity.Member; +import discord4j.core.object.entity.Message; +import me.totalfreedom.discord.Bot; +import me.totalfreedom.discord.TFD4J; +import me.totalfreedom.discord.util.SnowflakeEntry; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; +import me.totalfreedom.totalfreedommod.admin.Admin; +import me.totalfreedom.totalfreedommod.rank.Displayable; +import me.totalfreedom.totalfreedommod.rank.Rank; +import me.totalfreedom.totalfreedommod.rank.Title; +import me.totalfreedom.totalfreedommod.util.FLog; +import me.totalfreedom.totalfreedommod.util.FUtil; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.TextComponent; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; + +public class AdminChatListener +{ + private final Bot bot; + private final TFD4J tfd4j; + + public AdminChatListener(TFD4J tfd4j) + { + this.tfd4j = tfd4j; + this.bot = tfd4j.getBot(); + } + + public static net.md_5.bungee.api.ChatColor getColor(Displayable display) + { + return display.getColor(); + } + + public void adminChatBound() + { + tfd4j.getBot() + .getClient() + .getEventDispatcher() + .on(MessageCreateEvent.class) + .filter(m -> m.getMessage() + .getChannel() + .blockOptional() + .orElseThrow() + .getId() + .equals(SnowflakeEntry.adminChatChannelID)) + .filter(m -> !m.getMessage() + .getAuthor() + .orElseThrow() + .getId() + .equals(tfd4j.getBot().getClient().getSelfId())) + .subscribe(this::createMessageSpec); + } + + public void createMessageSpec(MessageCreateEvent m) + { + Member member = m.getMember().orElseThrow(IllegalAccessError::new); + String tag = tfd4j.getMinecraftListener().getDisplay(member); + Message msg = m.getMessage(); + String mediamessage = ChatColor.YELLOW + "[Media]"; + + StringBuilder logmessage = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "] " + ChatColor.RESET); + String lm = ChatColor.DARK_RED + member.getDisplayName() + " " + + ChatColor.DARK_GRAY + tag + ChatColor.DARK_GRAY + + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(msg.getContent()); + logmessage.append(lm); + + if (!msg.getAttachments().isEmpty()) + { + + logmessage.append(mediamessage); // Actually for logging... + + } + FLog.info(logmessage.toString()); + + Bukkit.getOnlinePlayers().stream().filter(player -> TotalFreedomMod.getPlugin().al.isAdmin(player)).forEach(player -> + { + StringBuilder message = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "] " + ChatColor.RESET); + + ComponentBuilder builder = new ComponentBuilder(message.toString()); + + Admin admin = TotalFreedomMod.getPlugin().al.getAdmin(player); + String format = admin.getAcFormat(); + if (!Strings.isNullOrEmpty(format)) + { + Displayable display = getDisplay(member); + net.md_5.bungee.api.ChatColor color = getColor(display); + String m1 = format.replace("%name%", member.getDisplayName()) + .replace("%rank%", display.getAbbr()) + .replace("%rankcolor%", color.toString()) + .replace("%msg%", FUtil.colorize(msg.getContent())); + builder.append(FUtil.colorize(m1)); + + } else + { + String m1 = ChatColor.DARK_RED + member.getDisplayName() + " " + + ChatColor.DARK_GRAY + tag + ChatColor.DARK_GRAY + + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(msg.getContent()); + builder.append(m1); + } + + if (!msg.getAttachments().isEmpty()) + { + for (Attachment attachment : msg.getAttachments()) + { + TextComponent text = new TextComponent(mediamessage); + text.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl())); + if (!msg.getContent().isEmpty()) + { + builder.append(" "); + } + builder.append(text); + } + } + player.spigot().sendMessage(builder.create()); + }); + } + + public Displayable getDisplay(Member member) + { + Guild server = tfd4j.getBot().getGuildById().block(); + // Server Owner + assert server != null; + return member.getRoles().map(role -> + { + if (role.getId().equals(SnowflakeEntry.ownerRoleID)) + { + return Title.OWNER; + } else if (role.getId().equals(SnowflakeEntry.developerRoleID)) + { + return Title.DEVELOPER; + } else if (role.getId().equals(SnowflakeEntry.executiveRoleID)) + { + return Title.EXECUTIVE; + } else if (role.getId().equals(SnowflakeEntry.assistantRoleID)) + { + return Title.ASSTEXEC; + } else if (role.getId().equals(SnowflakeEntry.seniorRoleID)) + { + return Rank.SENIOR_ADMIN; + } else if (role.getId().equals(SnowflakeEntry.adminRoleID)) + { + return Rank.ADMIN; + } else if (role.getId().equals(SnowflakeEntry.builderRoleID)) + { + return Title.MASTER_BUILDER; + } else + { + return null; + } + }).blockFirst(); + } +} diff --git a/discord/src/main/java/me/totalfreedom/discord/listener/BukkitNative.java b/discord/src/main/java/me/totalfreedom/discord/listener/BukkitNative.java new file mode 100644 index 00000000..84dcfc46 --- /dev/null +++ b/discord/src/main/java/me/totalfreedom/discord/listener/BukkitNative.java @@ -0,0 +1,91 @@ +package me.totalfreedom.discord.listener; + +import me.totalfreedom.discord.Bot; +import me.totalfreedom.discord.TFD4J; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; +import me.totalfreedom.totalfreedommod.config.ConfigEntry; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; +import net.md_5.bungee.api.ChatColor; +import org.bukkit.GameRule; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +public class BukkitNative implements Listener +{ + private final TotalFreedomMod commons; + private final Bot bot; + private final TFD4J tfd4j; + + public BukkitNative(TFD4J tfd4j) + { + this.tfd4j = tfd4j; + this.bot = tfd4j.getBot(); + this.commons = bot.getTFM().getCommons(); + + tfd4j.getServer().getPluginManager().registerEvents(this, tfd4j); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onPlayerJoin(PlayerJoinEvent event) + { + if (!commons.al.isVanished(event.getPlayer().getUniqueId())) + { + tfd4j.getUtils().messageChatChannel("**" + + tfd4j.getUtils().deformat(event.getPlayer().getName()) + + " joined the server" + "**", true); + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onPlayerLeave(PlayerQuitEvent event) + { + if (!commons.al.isVanished(event.getPlayer().getUniqueId())) + { + tfd4j.getUtils().messageChatChannel("**" + + tfd4j.getUtils().deformat(event.getPlayer().getName()) + + " left the server" + "**", true); + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onPlayerDeath(PlayerDeathEvent event) + { + //Avoiding NPE Unboxing Warnings + Boolean b = event.getEntity().getWorld().getGameRuleValue(GameRule.SHOW_DEATH_MESSAGES); + if (b == null || !b) + { + return; + } + + Component deathMessage = event.deathMessage(); + + if (deathMessage != null) + { + tfd4j.getUtils().messageChatChannel("**" + + tfd4j.getUtils().deformat(PlainTextComponentSerializer.plainText().serialize(deathMessage)) + + "**", true); + } + } + + @EventHandler(ignoreCancelled = true) + public void onAsyncPlayerChat(AsyncPlayerChatEvent event) + { + Player player = event.getPlayer(); + String message = event.getMessage(); + + if (!ConfigEntry.ADMIN_ONLY_MODE.getBoolean() && !tfd4j.getServer().hasWhitelist() + && !commons.pl.getPlayer(player).isMuted() && bot != null) + { + tfd4j.getUtils().messageChatChannel(player.getName() + + " \u00BB " + + ChatColor.stripColor(message), true); + } + } +} diff --git a/discord/src/main/java/me/totalfreedom/discord/listener/MinecraftListener.java b/discord/src/main/java/me/totalfreedom/discord/listener/MinecraftListener.java new file mode 100644 index 00000000..0ac84de9 --- /dev/null +++ b/discord/src/main/java/me/totalfreedom/discord/listener/MinecraftListener.java @@ -0,0 +1,164 @@ +package me.totalfreedom.discord.listener; + +import discord4j.core.event.domain.message.MessageCreateEvent; +import discord4j.core.object.entity.Attachment; +import discord4j.core.object.entity.Guild; +import discord4j.core.object.entity.Member; +import discord4j.core.object.entity.Message; +import discord4j.core.object.entity.channel.TextChannel; +import me.totalfreedom.discord.Bot; +import me.totalfreedom.discord.TFD4J; +import me.totalfreedom.discord.util.SnowflakeEntry; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; +import me.totalfreedom.totalfreedommod.config.ConfigEntry; +import me.totalfreedom.totalfreedommod.rank.Rank; +import me.totalfreedom.totalfreedommod.rank.Title; +import me.totalfreedom.totalfreedommod.util.FLog; +import me.totalfreedom.totalfreedommod.util.FUtil; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.TextComponent; +import net.kyori.adventure.text.event.ClickEvent; +import net.kyori.adventure.text.event.HoverEvent; +import net.kyori.adventure.text.format.NamedTextColor; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +public class MinecraftListener +{ + private final TotalFreedomMod commons; + private final Bot bot; + private final TFD4J tfd4j; + + public MinecraftListener(TFD4J tfd4j) + { + this.tfd4j = tfd4j; + this.bot = tfd4j.getBot(); + this.commons = bot.getTFM().getCommons(); + } + + public void minecraftChatBound() + { + tfd4j.getBot().getClient() + .getEventDispatcher() + .on(MessageCreateEvent.class) + .filter(m -> m.getMember().orElse(null) != null) + .filter(m -> !m.getMessage() + .getAuthor() + .orElseThrow(IllegalAccessError::new) + .getId() + .equals(tfd4j.getBot().getClient().getSelfId())) + .filter(m -> m.getMessage() + .getChannel() + .blockOptional() + .orElseThrow(IllegalAccessError::new) + .getId() + .equals(SnowflakeEntry.chatChannelID)) + .filter(m -> + { + Boolean b = m.getMessage() + .getChannel() + .map(c -> c instanceof TextChannel) + .block(); + return b != null && b; + }).subscribe(this::doMessageBodyDetails); + } + + private void doMessageBodyDetails(MessageCreateEvent m) + { + Member member = m.getMember().orElseThrow(); + Message msg = m.getMessage(); + String tag = getDisplay(member); + TextComponent[] emsg = {Component.empty()}; // We are using a single value arrays here to silence SonarLint's "return value never used" bullshit. + + emsg[0] = emsg[0].append(Component.text("[", NamedTextColor.DARK_GRAY)); + TextComponent[] inviteLink = {Component.text("Discord")}; + inviteLink[0] = inviteLink[0].color(NamedTextColor.DARK_AQUA); + HoverEvent hoverEvent = HoverEvent.showText(Component.text("Click to join our Discord server!")); + ClickEvent clickEvent = ClickEvent.openUrl(ConfigEntry.DISCORD_INVITE_LINK.getString()); + inviteLink[0] = inviteLink[0].hoverEvent(hoverEvent); + inviteLink[0] = inviteLink[0].clickEvent(clickEvent); + emsg[0] = emsg[0].append(inviteLink[0]); + emsg[0] = emsg[0].append(Component.text("] ", NamedTextColor.DARK_GRAY)); + + // Tag (if they have one) + if (tag != null) + { + emsg[0] = emsg[0].append(Component.text(tag)); + } + + emsg[0] = emsg[0].append(Component.space()); + + // User + TextComponent[] user = {Component.text(FUtil.stripColors(member.getDisplayName()))}; + user[0] = user[0].color(NamedTextColor.RED); + emsg[0] = emsg[0].append(user[0]); + + // Message + emsg[0] = emsg[0].append(Component.text(": ", NamedTextColor.DARK_GRAY)); + emsg[0] = emsg[0].append(Component.text(FUtil.stripColors(msg.getContent()), NamedTextColor.WHITE)); + // Attachments + if (!msg.getAttachments().isEmpty()) + { + if (!msg.getContent().isEmpty()) + emsg[0] = emsg[0].append(Component.space()); + + for (Attachment attachment : msg.getAttachments()) + { + TextComponent[] media = {Component.text("[Media] ")}; + media[0] = media[0].color(NamedTextColor.YELLOW); + HoverEvent hover = HoverEvent.showText(Component.text(attachment.getUrl())); + ClickEvent click = ClickEvent.openUrl(attachment.getUrl()); + media[0] = media[0].clickEvent(click); + media[0] = media[0].hoverEvent(hover); + emsg[0] = emsg[0].append(media[0]); + } + } + + + for (Player player : Bukkit.getOnlinePlayers()) + { + if (TotalFreedomMod.getPlugin().pl.getData(player).doesDisplayDiscord()) + { + player.sendMessage(emsg[0]); + } + } + + FLog.info(emsg[0].content(), true); + } + + public String getDisplay(Member member) + { + Guild server = tfd4j.getBot().getGuildById().block(); + // Server Owner + assert server != null; + return member.getRoles().map(role -> + { + if (role.getId().equals(SnowflakeEntry.ownerRoleID)) + { + return Title.OWNER.getColoredTag(); + } else if (role.getId().equals(SnowflakeEntry.developerRoleID)) + { + return Title.DEVELOPER.getColoredTag(); + } else if (role.getId().equals(SnowflakeEntry.executiveRoleID)) + { + return Title.EXECUTIVE.getColoredTag(); + } else if (role.getId().equals(SnowflakeEntry.assistantRoleID)) + { + return Title.ASSTEXEC.getColoredTag(); + } else if (role.getId().equals(SnowflakeEntry.seniorRoleID)) + { + return Rank.SENIOR_ADMIN.getColoredTag(); + } else if (role.getId().equals(SnowflakeEntry.adminRoleID)) + { + return Rank.ADMIN.getColoredTag(); + } else if (role.getId().equals(SnowflakeEntry.builderRoleID)) + { + return Title.MASTER_BUILDER.getColoredTag(); + } else + { + return null; + } + }).blockFirst(); + } +} + diff --git a/discord/src/main/java/me/totalfreedom/discord/listener/PrivateMessageListener.java b/discord/src/main/java/me/totalfreedom/discord/listener/PrivateMessageListener.java new file mode 100644 index 00000000..31f040e9 --- /dev/null +++ b/discord/src/main/java/me/totalfreedom/discord/listener/PrivateMessageListener.java @@ -0,0 +1,57 @@ +package me.totalfreedom.discord.listener; + +import discord4j.core.event.domain.message.MessageCreateEvent; +import me.totalfreedom.discord.TFD4J; +import me.totalfreedom.discord.discord.Discord; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; +import me.totalfreedom.totalfreedommod.admin.Admin; +import me.totalfreedom.totalfreedommod.player.PlayerData; + +public class PrivateMessageListener +{ + private final TFD4J tfd4j; + + public PrivateMessageListener(TFD4J tfd4j) + { + this.tfd4j = tfd4j; + } + + public void privateMessageReceived() + { + tfd4j.getBot() + .getClient() + .getEventDispatcher() + .on(MessageCreateEvent.class) + .filter(event -> event.getMessage().getAuthor().orElse(null) != null) + .filter(event -> !event.getMessage().getAuthor().orElseThrow().getId().equals(tfd4j.getBot().getClient().getSelfId())) + .filter(event -> event.getMessage().getContent().strip().matches("[0-9][0-9][0-9][0-9][0-9]")) + .subscribe(event -> + { + String code = event.getMessage().getContent().strip(); + String name; + if (Discord.LINK_CODES.get(code) != null) + { + PlayerData player = Discord.LINK_CODES.get(code); + name = player.getName(); + player.setDiscordID(event.getMessage().getAuthor().orElseThrow().getId().asString()); + + Admin admin = TotalFreedomMod.getPlugin().al.getEntryByUuid(player.getUuid()); + if (admin != null) + { + Discord.syncRoles(admin, player.getDiscordID()); + } + + TotalFreedomMod.getPlugin().pl.save(player); + Discord.LINK_CODES.remove(code); + } else + { + return; + } + event.getMessage() + .getChannel() + .blockOptional() + .orElseThrow(UnsupportedOperationException::new) + .createMessage("Link successful. Now this Discord account is linked with your Minecraft account **" + name + "**.").block(); + }); + } +} diff --git a/discord/src/main/java/me/totalfreedom/discord/listener/ReactionListener.java b/discord/src/main/java/me/totalfreedom/discord/listener/ReactionListener.java new file mode 100644 index 00000000..f91b7cac --- /dev/null +++ b/discord/src/main/java/me/totalfreedom/discord/listener/ReactionListener.java @@ -0,0 +1,77 @@ +package me.totalfreedom.discord.listener; + +import discord4j.core.event.domain.message.ReactionAddEvent; +import discord4j.core.object.Embed; +import discord4j.core.object.entity.Member; +import discord4j.core.object.entity.Message; +import discord4j.core.object.entity.channel.Channel; +import discord4j.discordjson.json.MessageCreateRequest; +import me.totalfreedom.discord.TFD4J; +import me.totalfreedom.discord.util.SnowflakeEntry; +import me.totalfreedom.totalfreedommod.util.FLog; + +public class ReactionListener +{ + private final TFD4J tfd4j; + + public ReactionListener(TFD4J tfd4J) + { + this.tfd4j = tfd4J; + } + + public void onReactionAdd() + { + tfd4j.getBot() + .getClient() + .getEventDispatcher() + .on(ReactionAddEvent.class) + .filter(r -> r.getGuild().block() != null) + .filter(r -> r.getMember().orElse(null) != null) + .filter(r -> !r.getMember() + .orElseThrow() + .getId() + .equals(tfd4j.getBot().getClient().getSelfId())) + .filter(r -> !r.getChannel() + .blockOptional() + .orElseThrow().getId().equals(SnowflakeEntry.reportChannelID)) + .filter(r -> r.getEmoji() + .asUnicodeEmoji() + .orElseThrow(UnsupportedOperationException::new) + .getRaw() + .equals("\uD83D\uDCCB")) + .subscribe(this::reactionWork); + } + + public void reactionWork(ReactionAddEvent event) + { + final Channel archiveChannel = tfd4j.getBot().getClient().getChannelById(SnowflakeEntry.archiveChannelID).block(); + + if (archiveChannel == null) + { + FLog.warning("Report archive channel is defined in the config, yet doesn't actually exist!"); + return; + } + + final Message message = event.getMessage().blockOptional().orElseThrow(); + final Member completer = event.getMember().orElseThrow(); + + if (!message.getAuthor().orElseThrow().getId().equals(tfd4j.getBot().getClient().getSelfId())) + { + return; + } + + // We don't need other embeds... yet? + final Embed embed = message.getEmbeds().get(0); + + final MessageCreateRequest request = MessageCreateRequest.builder() + .content("Report completed by " + completer.getUsername() + + " (" + completer.getDiscriminator() + + ")") + .addEmbed(embed.getData()) + .build(); + + archiveChannel.getRestChannel().createMessage(request); + + message.delete().block(); + } +} diff --git a/discord/src/main/java/me/totalfreedom/discord/util/SnowflakeEntry.java b/discord/src/main/java/me/totalfreedom/discord/util/SnowflakeEntry.java new file mode 100644 index 00000000..030e4055 --- /dev/null +++ b/discord/src/main/java/me/totalfreedom/discord/util/SnowflakeEntry.java @@ -0,0 +1,20 @@ +package me.totalfreedom.discord.util; + +import discord4j.common.util.Snowflake; +import me.totalfreedom.totalfreedommod.config.ConfigEntry; + +public class SnowflakeEntry +{ + public static final Snowflake adminChatChannelID = Snowflake.of(ConfigEntry.DISCORD_ADMINCHAT_CHANNEL_ID.getString()); + public static final Snowflake chatChannelID = Snowflake.of(ConfigEntry.DISCORD_CHAT_CHANNEL_ID.getString()); + public static final Snowflake serverID = Snowflake.of(ConfigEntry.DISCORD_SERVER_ID.getString()); + public static final Snowflake ownerRoleID = Snowflake.of(ConfigEntry.DISCORD_SERVER_OWNER_ROLE_ID.getString()); + public static final Snowflake developerRoleID = Snowflake.of(ConfigEntry.DISCORD_DEVELOPER_ROLE_ID.getString()); + public static final Snowflake executiveRoleID = Snowflake.of(ConfigEntry.DISCORD_EXECUTIVE_ROLE_ID.getString()); + public static final Snowflake assistantRoleID = Snowflake.of(ConfigEntry.DISCORD_ASSISTANT_EXECUTIVE_ROLE_ID.getString()); + public static final Snowflake seniorRoleID = Snowflake.of(ConfigEntry.DISCORD_SENIOR_ADMIN_ROLE_ID.getString()); + public static final Snowflake adminRoleID = Snowflake.of(ConfigEntry.DISCORD_NEW_ADMIN_ROLE_ID.getString()); + public static final Snowflake builderRoleID = Snowflake.of(ConfigEntry.DISCORD_MASTER_BUILDER_ROLE_ID.getString()); + public static final Snowflake reportChannelID = Snowflake.of(ConfigEntry.DISCORD_REPORT_CHANNEL_ID.getString()); + public static final Snowflake archiveChannelID = Snowflake.of(ConfigEntry.DISCORD_REPORT_ARCHIVE_CHANNEL_ID.getString()); +} diff --git a/discord/src/main/java/me/totalfreedom/discord/util/TFM_Bridge.java b/discord/src/main/java/me/totalfreedom/discord/util/TFM_Bridge.java new file mode 100644 index 00000000..b082735f --- /dev/null +++ b/discord/src/main/java/me/totalfreedom/discord/util/TFM_Bridge.java @@ -0,0 +1,145 @@ +package me.totalfreedom.discord.util; + +import discord4j.common.util.Snowflake; +import discord4j.core.object.entity.Guild; +import discord4j.core.object.entity.Member; +import discord4j.core.object.entity.Role; +import me.totalfreedom.discord.Bot; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; +import me.totalfreedom.totalfreedommod.admin.Admin; +import me.totalfreedom.totalfreedommod.config.ConfigEntry; +import me.totalfreedom.totalfreedommod.player.PlayerData; +import me.totalfreedom.totalfreedommod.rank.Rank; +import me.totalfreedom.totalfreedommod.rank.Title; +import me.totalfreedom.totalfreedommod.util.FLog; +import org.bukkit.Bukkit; + +public class TFM_Bridge +{ + private final Bot bot; + private final TotalFreedomMod commons; + + public TFM_Bridge(Bot bot) + { + this.bot = bot; + this.commons = (TotalFreedomMod) Bukkit.getPluginManager().getPlugin("TotalFreedomMod"); + + if (commons == null) throw new IllegalStateException(); + } + + public String getDisplay(Member member) + { + Guild server = bot.getGuildById().block(); + // Server Owner + if (server == null) + { + throw new IllegalStateException(); + } + + Snowflake ownerID = Snowflake.of(ConfigEntry.DISCORD_SERVER_OWNER_ROLE_ID.getString()); + Snowflake developerID = Snowflake.of(ConfigEntry.DISCORD_DEVELOPER_ROLE_ID.getString()); + Snowflake executiveID = Snowflake.of(ConfigEntry.DISCORD_EXECUTIVE_ROLE_ID.getString()); + Snowflake assistantExecutiveID = Snowflake.of(ConfigEntry.DISCORD_ASSISTANT_EXECUTIVE_ROLE_ID.getString()); + Snowflake seniorAdminID = Snowflake.of(ConfigEntry.DISCORD_SENIOR_ADMIN_ROLE_ID.getString()); + Snowflake adminID = Snowflake.of(ConfigEntry.DISCORD_NEW_ADMIN_ROLE_ID.getString()); + Snowflake masterBuilderID = Snowflake.of(ConfigEntry.DISCORD_MASTER_BUILDER_ROLE_ID.getString()); + + Snowflake[] ids = {ownerID, developerID, executiveID, assistantExecutiveID, seniorAdminID, adminID, masterBuilderID}; + String[] titles = {Title.OWNER.getColoredTag(), Title.DEVELOPER.getColoredTag(), Title.EXECUTIVE.getColoredTag(), Title.ASSTEXEC.getColoredTag(), Rank.SENIOR_ADMIN.getColoredTag(), Rank.ADMIN.getColoredTag(), Title.MASTER_BUILDER.getColoredTag()}; + + return member.getRoles().map(role -> + { + for (int i = 0; i < ids.length; i++) + { + if (role.getId().equals(ids[i])) + { + return titles[i]; + } + } + return null; + }).blockFirst(); + } + + public String getCode(PlayerData playerData) + { + for (String code : bot.getLinkCodes().keySet()) + { + if (bot.getLinkCodes().get(code).equals(playerData)) + { + return code; + } + } + return null; + } + + public boolean syncRoles(Admin admin, String discordID) + { + if (discordID == null) + { + return false; + } + + Guild server = bot.getGuildById().block(); + + if (server == null) + { + FLog.severe("The Discord server ID specified is invalid, or the bot is not on the server."); + return false; + } + + Member member = server.getMemberById(Snowflake.of(discordID)).block(); + if (member == null) + { + return false; + } + + Role adminRole = server.getRoleById(SnowflakeEntry.adminRoleID).block(); + if (adminRole == null) + { + FLog.severe("The specified Admin role does not exist!"); + return false; + } + + Role senioradminRole = server.getRoleById(SnowflakeEntry.seniorRoleID).block(); + if (senioradminRole == null) + { + FLog.severe("The specified Senior Admin role does not exist!"); + return false; + } + + if (!admin.isActive()) + { + member.getRoles() + .filter(role -> role.equals(adminRole) || role.equals(senioradminRole)) + .subscribe(r -> member.removeRole(r.getId()).block()); + return true; + } + + if (admin.getRank().equals(Rank.ADMIN)) + { + member.getRoles() + .filter(role -> !role.equals(adminRole)) + .subscribe(r -> member.addRole(r.getId()).block()); + member.getRoles() + .filter(role -> role.equals(senioradminRole)) + .subscribe(r -> member.removeRole(r.getId()).block()); + return true; + } + else if (admin.getRank().equals(Rank.SENIOR_ADMIN)) + { + member.getRoles() + .filter(role -> !role.equals(senioradminRole)) + .subscribe(r -> member.addRole(r.getId()).block()); + + member.getRoles() + .filter(role -> role.equals(adminRole)) + .subscribe(r -> member.removeRole(r.getId()).block()); + + return true; + } + return false; + } + public TotalFreedomMod getCommons() { + return commons; + } +} diff --git a/discord/src/main/java/me/totalfreedom/discord/util/Utilities.java b/discord/src/main/java/me/totalfreedom/discord/util/Utilities.java new file mode 100644 index 00000000..f79dd97c --- /dev/null +++ b/discord/src/main/java/me/totalfreedom/discord/util/Utilities.java @@ -0,0 +1,182 @@ +package me.totalfreedom.discord.util; + +import com.google.common.collect.ImmutableList; +import discord4j.core.object.entity.Guild; +import discord4j.core.object.entity.Message; +import discord4j.core.object.entity.channel.TextChannel; +import discord4j.core.object.reaction.ReactionEmoji; +import discord4j.core.spec.EmbedCreateSpec; +import discord4j.core.spec.MessageCreateSpec; +import me.totalfreedom.discord.TFD4J; +import me.totalfreedom.totalfreedommod.config.ConfigEntry; +import me.totalfreedom.totalfreedommod.util.FLog; +import org.apache.commons.lang.WordUtils; +import org.bukkit.entity.Player; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import java.time.Instant; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class Utilities +{ + private final Flux sentMessages = Flux.fromIterable(new ArrayList<>()); + private final TFD4J tfd4J; + private final ImmutableList DISCORD_SUBDOMAINS = (ImmutableList) + List.of("discordapp.com", + "discord.com", + "discord.gg"); + + public Utilities(TFD4J tfd4J) + { + this.tfd4J = tfd4J; + } + + public String sanitizeChatMessage(String message) + { + String newMessage = message; + + if (message.contains("@")) + { + // \u200B is Zero Width Space, invisible on Discord + newMessage = message.replace("@", "@\u200B"); + } + + if (message.toLowerCase().contains("discord.gg")) // discord.gg/invite works as an invite + { + return ""; + } + + for (String subdomain : DISCORD_SUBDOMAINS) + { + if (message.toLowerCase().contains(subdomain + "/invite")) + { + return ""; + } + } + + if (message.contains("§")) + { + newMessage = message.replace("§", ""); + } + + return deformat(newMessage); + } + + public void messageChatChannel(String message, boolean system) + { + String chat_channel_id = ConfigEntry.DISCORD_CHAT_CHANNEL_ID.getString(); + + String sanitizedMessage = (system) ? message : sanitizeChatMessage(message); + + if (sanitizedMessage.isBlank()) return; + + if (!chat_channel_id.isEmpty()) + { + MessageCreateSpec spec = MessageCreateSpec.builder() + .content(sanitizedMessage) + .build(); + + Mono sentMessage = tfd4J + .getBot() + .getClient() + .getChannelById(SnowflakeEntry.chatChannelID) + .ofType(TextChannel.class) + .flatMap(c -> c.createMessage(spec)); + + insert(sentMessage); + } + } + + public void messageAdminChatChannel(String message) + { + String chat_channel_id = ConfigEntry.DISCORD_ADMINCHAT_CHANNEL_ID.getString(); + + String sanitizedMessage = sanitizeChatMessage(message); + + if (sanitizedMessage.isBlank()) return; + + if (!chat_channel_id.isEmpty()) + { + MessageCreateSpec spec = MessageCreateSpec.builder() + .content(sanitizedMessage) + .build(); + + Mono sentMessage = tfd4J + .getBot() + .getClient() + .getChannelById(SnowflakeEntry.adminChatChannelID) + .ofType(TextChannel.class) + .flatMap(c -> c.createMessage(spec)); + + insert(sentMessage); + } + } + + public boolean sendReport(Player reporter, Player reported, String reason) + { + if (!tfd4J.getBot().shouldISendReport()) + { + return false; + } + + final Guild server = tfd4J.getBot() + .getClient() + .getGuildById(SnowflakeEntry.serverID) + .block(); + + if (server == null) + { + FLog.severe("The guild ID specified in the config is invalid."); + return false; + } + + final TextChannel channel = server.getChannelById(SnowflakeEntry.reportChannelID) + .ofType(TextChannel.class) + .block(); + + if (channel == null) + { + FLog.severe("The report channel ID specified in the config is invalid."); + return false; + } + String location = "World: " + Objects.requireNonNull(reported.getLocation().getWorld()).getName() + ", X: " + reported.getLocation().getBlockX() + ", Y: " + reported.getLocation().getBlockY() + ", Z: " + reported.getLocation().getBlockZ(); + + final EmbedCreateSpec spec = EmbedCreateSpec.builder() + .title("Report for " + reported.getName()) + .description(reason) + .footer("Reported by " + reporter.getName(), "https://minotar.net/helm/" + reporter.getName() + ".png") + .timestamp(Instant.from(ZonedDateTime.now())) + .addField("Location", location, true) + .addField("Game Mode", WordUtils.capitalizeFully(reported.getGameMode().name()), true) + .build(); + + Message message = channel.createMessage(spec).block(); + + if (!ConfigEntry.DISCORD_REPORT_ARCHIVE_CHANNEL_ID.getString().isEmpty() && message != null) + { + ReactionEmoji emoji = ReactionEmoji.unicode("\uD83D\uDCCB"); + message.addReaction(emoji); + } + + return true; + } + + public String deformat(String input) + { + return input.replaceAll("([_\\\\`*>|])", "\\\\$1"); + } + + public Flux getMessagesSent() + { + return sentMessages; + } + + public void insert(Mono messageMono) + { + sentMessages.concatWith(messageMono); + } +} diff --git a/discord/src/main/resources/commands/help.json b/discord/src/main/resources/commands/help.json new file mode 100644 index 00000000..3bf70691 --- /dev/null +++ b/discord/src/main/resources/commands/help.json @@ -0,0 +1,4 @@ +{ + "name": "help", + "description": "Bot help command." +} diff --git a/discord/src/main/resources/commands/list.json b/discord/src/main/resources/commands/list.json new file mode 100644 index 00000000..c9f74b35 --- /dev/null +++ b/discord/src/main/resources/commands/list.json @@ -0,0 +1,4 @@ +{ + "name": "list", + "description": "List all currently online players" +} \ No newline at end of file diff --git a/discord/src/main/resources/commands/tps.json b/discord/src/main/resources/commands/tps.json new file mode 100644 index 00000000..b5adb145 --- /dev/null +++ b/discord/src/main/resources/commands/tps.json @@ -0,0 +1,4 @@ +{ + "name": "tps", + "description": "Gets the current TPS for the server." +} \ No newline at end of file diff --git a/discord/src/main/resources/plugin.yml b/discord/src/main/resources/plugin.yml new file mode 100644 index 00000000..1f715274 --- /dev/null +++ b/discord/src/main/resources/plugin.yml @@ -0,0 +1,8 @@ +name: TFD4J +main: me.totalfreedom.discord.TFD4J +version: 1.0 +api-version: 1.19 +depend: [TotalFreedomMod] +libraries: + - com.discord4j:discord4j-core:3.2.0 + - io.projectreactor:reactor-core:3.4.9 \ No newline at end of file diff --git a/pom.xml b/pom.xml index 68416f28..e840b251 100644 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,17 @@ me.totalfreedom TotalFreedomMod - 2022.06 - jar + 2023.02 + pom + + commons + shop + discord + UTF-8 - Phoenix + Caladrius ${project.name} ${maven.build.timestamp} MM/dd/yyyy HH:mm @@ -65,11 +70,6 @@ https://maven.elmakers.com/repository/ - - sk89q-snapshots - https://maven.sk89q.com/artifactory/repo - - dv8tion m2-dv8tion @@ -91,11 +91,6 @@ https://repo.dmulloy2.net/nexus/repository/public/ - - sk89q-repo - https://maven.sk89q.com/repo/ - - esentialsx-repo https://repo.essentialsx.net/releases/ @@ -105,27 +100,6 @@ - - commons-io - commons-io - 2.11.0 - compile - - - - org.apache.commons - commons-lang3 - 3.12.0 - compile - - - - org.bstats - bstats-bukkit - 3.0.0 - compile - - me.totalfreedom.scissors scissors-api @@ -175,13 +149,6 @@ provided - - io.papermc - paperlib - 1.0.7 - compile - - com.github.vexsoftware votifier @@ -196,32 +163,18 @@ provided - - org.reflections - reflections - 0.10.2 - compile - - - - net.essentialsx - EssentialsXDiscord - 2.19.2 - provided - - org.javassist javassist 3.29.1-GA - compile + provided org.jetbrains annotations 23.0.0 - compile + provided @@ -230,19 +183,13 @@ 3.1.2 compile - + org.junit.jupiter junit-jupiter 5.9.0 compile - - - org.eclipse.sisu - org.eclipse.sisu.inject - 0.3.5 - diff --git a/shop/pom.xml b/shop/pom.xml new file mode 100644 index 00000000..a5414282 --- /dev/null +++ b/shop/pom.xml @@ -0,0 +1,20 @@ + + + 4.0.0 + + me.totalfreedom + TotalFreedomMod + 2023.02 + + + shop + + + 17 + 17 + UTF-8 + + + \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/shop/Shop.java b/shop/src/main/java/me/totalfreedom/shop/Shop.java similarity index 99% rename from src/main/java/me/totalfreedom/totalfreedommod/shop/Shop.java rename to shop/src/main/java/me/totalfreedom/shop/Shop.java index f12fb04d..c9774fbf 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/shop/Shop.java +++ b/shop/src/main/java/me/totalfreedom/shop/Shop.java @@ -1,4 +1,4 @@ -package me.totalfreedom.totalfreedommod.shop; +package me.totalfreedom.shop; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/main/java/me/totalfreedom/totalfreedommod/shop/ShopItem.java b/shop/src/main/java/me/totalfreedom/shop/ShopItem.java similarity index 98% rename from src/main/java/me/totalfreedom/totalfreedommod/shop/ShopItem.java rename to shop/src/main/java/me/totalfreedom/shop/ShopItem.java index fe3bb097..1231289d 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/shop/ShopItem.java +++ b/shop/src/main/java/me/totalfreedom/shop/ShopItem.java @@ -1,4 +1,4 @@ -package me.totalfreedom.totalfreedommod.shop; +package me.totalfreedom.shop; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import org.bukkit.ChatColor; diff --git a/src/main/java/me/totalfreedom/totalfreedommod/shop/Votifier.java b/shop/src/main/java/me/totalfreedom/shop/Votifier.java similarity index 97% rename from src/main/java/me/totalfreedom/totalfreedommod/shop/Votifier.java rename to shop/src/main/java/me/totalfreedom/shop/Votifier.java index c559d061..a9d583a6 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/shop/Votifier.java +++ b/shop/src/main/java/me/totalfreedom/shop/Votifier.java @@ -1,4 +1,4 @@ -package me.totalfreedom.totalfreedommod.shop; +package me.totalfreedom.shop; import com.vexsoftware.votifier.model.Vote; import com.vexsoftware.votifier.model.VotifierEvent; diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/EXDiscordBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/EXDiscordBridge.java deleted file mode 100644 index ac0146e9..00000000 --- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/EXDiscordBridge.java +++ /dev/null @@ -1,44 +0,0 @@ -package me.totalfreedom.totalfreedommod.bridge; - -import me.totalfreedom.totalfreedommod.FreedomService; -import me.totalfreedom.totalfreedommod.util.FLog; -import net.essentialsx.discord.EssentialsDiscord; -import org.bukkit.plugin.Plugin; - -public class EXDiscordBridge extends FreedomService -{ - private EssentialsDiscord essentialsDiscord = null; - - @Override - public void onStart() - { - // This is completely useless, but it's here to make sure the service is loaded. - } - - @Override - public void onStop() - { - essentialsDiscord = null; - } - - public EssentialsDiscord getEssentialsDiscord() - { - if (essentialsDiscord == null) - { - try - { - final Plugin xDiscord = server.getPluginManager().getPlugin("EssentialsXDiscord"); - assert xDiscord != null; - if (xDiscord instanceof EssentialsDiscord e) - { - essentialsDiscord = e; - } - } - catch (Exception ex) - { - FLog.severe(ex); - } - } - return essentialsDiscord; - } -} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java deleted file mode 100644 index 156d4582..00000000 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java +++ /dev/null @@ -1,529 +0,0 @@ -package me.totalfreedom.totalfreedommod.discord; - -import com.google.common.base.Strings; -import java.time.Instant; -import java.time.ZonedDateTime; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Objects; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import javax.security.auth.login.LoginException; - -import com.google.common.collect.ImmutableList; -import me.totalfreedom.totalfreedommod.FreedomService; -import me.totalfreedom.totalfreedommod.admin.Admin; -import me.totalfreedom.totalfreedommod.config.ConfigEntry; -import me.totalfreedom.totalfreedommod.discord.command.DiscordCommandManager; -import me.totalfreedom.totalfreedommod.player.PlayerData; -import me.totalfreedom.totalfreedommod.rank.Rank; -import me.totalfreedom.totalfreedommod.util.FLog; -import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.JDA; -import net.dv8tion.jda.api.JDABuilder; -import net.dv8tion.jda.api.entities.Guild; -import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.entities.Message; -import net.dv8tion.jda.api.entities.MessageEmbed; -import net.dv8tion.jda.api.entities.PrivateChannel; -import net.dv8tion.jda.api.entities.Role; -import net.dv8tion.jda.api.entities.SelfUser; -import net.dv8tion.jda.api.entities.TextChannel; -import net.dv8tion.jda.api.entities.User; -import net.dv8tion.jda.api.events.ReadyEvent; -import net.dv8tion.jda.api.hooks.ListenerAdapter; -import net.dv8tion.jda.api.requests.GatewayIntent; -import net.dv8tion.jda.api.utils.ChunkingFilter; -import net.dv8tion.jda.api.utils.MemberCachePolicy; -import net.dv8tion.jda.internal.utils.concurrent.CountingThreadFactory; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; -import net.md_5.bungee.api.ChatColor; -import org.apache.commons.lang.WordUtils; -import org.apache.commons.lang3.RandomStringUtils; -import org.bukkit.GameRule; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.jetbrains.annotations.NotNull; - -public class Discord extends FreedomService -{ - - public static HashMap LINK_CODES = new HashMap<>(); - public static JDA bot = null; - public static DiscordCommandManager DISCORD_COMMAND_MANAGER; - public ScheduledThreadPoolExecutor RATELIMIT_EXECUTOR; - public List> sentMessages = new ArrayList<>(); - public Boolean enabled = false; - private static final ImmutableList DISCORD_SUBDOMAINS = ImmutableList.of("discordapp.com", "discord.com", "discord.gg"); - - public static String getCode(PlayerData playerData) - { - for (String code : LINK_CODES.keySet()) - { - if (LINK_CODES.get(code).equals(playerData)) - { - return code; - } - } - return null; - } - - public static boolean syncRoles(Admin admin, String discordID) - { - if (discordID == null) - { - return false; - } - - Guild server = bot.getGuildById(ConfigEntry.DISCORD_SERVER_ID.getString()); - if (server == null) - { - FLog.severe("The Discord server ID specified is invalid, or the bot is not on the server."); - return false; - } - - Member member = server.getMemberById(discordID); - if (member == null) - { - return false; - } - - Role adminRole = server.getRoleById(ConfigEntry.DISCORD_NEW_ADMIN_ROLE_ID.getString()); - if (adminRole == null) - { - FLog.severe("The specified Admin role does not exist!"); - return false; - } - - Role senioradminRole = server.getRoleById(ConfigEntry.DISCORD_SENIOR_ADMIN_ROLE_ID.getString()); - if (senioradminRole == null) - { - FLog.severe("The specified Senior Admin role does not exist!"); - return false; - } - - if (!admin.isActive()) - { - if (member.getRoles().contains(adminRole)) - { - server.removeRoleFromMember(member, adminRole).complete(); - } - if (member.getRoles().contains(senioradminRole)) - { - server.removeRoleFromMember(member, senioradminRole).complete(); - } - return true; - } - - if (admin.getRank().equals(Rank.ADMIN)) - { - if (!member.getRoles().contains(adminRole)) - { - server.addRoleToMember(member, adminRole).complete(); - } - if (member.getRoles().contains(senioradminRole)) - { - server.removeRoleFromMember(member, senioradminRole).complete(); - } - return true; - } - else if (admin.getRank().equals(Rank.SENIOR_ADMIN)) - { - if (!member.getRoles().contains(senioradminRole)) - { - server.addRoleToMember(member, senioradminRole).complete(); - } - if (member.getRoles().contains(adminRole)) - { - server.removeRoleFromMember(member, adminRole).complete(); - } - return true; - } - return false; - } - - public void startBot() - { - DISCORD_COMMAND_MANAGER = new DiscordCommandManager(); - DISCORD_COMMAND_MANAGER.init(this); - - enabled = !Strings.isNullOrEmpty(ConfigEntry.DISCORD_TOKEN.getString()); - if (!enabled) - { - return; - } - - if (bot != null) - { - RATELIMIT_EXECUTOR = new ScheduledThreadPoolExecutor(5, new CountingThreadFactory(this::poolIdentifier, "RateLimit")); - RATELIMIT_EXECUTOR.setRemoveOnCancelPolicy(true); - for (Object object : bot.getRegisteredListeners()) - { - bot.removeEventListener(object); - } - } - - try - { - bot = JDABuilder.createDefault(ConfigEntry.DISCORD_TOKEN.getString()) - .addEventListeners(new PrivateMessageListener(), - new DiscordToMinecraftListener(), - new DiscordToAdminChatListener(), - new MessageReactionListener(), - new ListenerAdapter() - { - @Override - public void onReady(@NotNull ReadyEvent event) - { - new StartEvent().start(); - } - }) - .setAutoReconnect(true) - .setRateLimitPool(RATELIMIT_EXECUTOR) - .setChunkingFilter(ChunkingFilter.ALL) - .setMemberCachePolicy(MemberCachePolicy.ALL) - .enableIntents(GatewayIntent.GUILD_MEMBERS) - .build(); - FLog.info("Discord integration has successfully enabled!"); - } - catch (LoginException e) - { - FLog.warning("An invalid token for Discord integration was provided, the bot will not enable."); - enabled = false; - } - catch (IllegalArgumentException e) - { - FLog.warning("Discord integration failed to start."); - enabled = false; - } - catch (NoClassDefFoundError e) - { - FLog.warning("The JDA plugin is not installed, therefore the discord bot cannot start."); - FLog.warning("To resolve this error, please download the latest JDA from: https://github.com/AtlasMediaGroup/Minecraft-JDA/releases"); - enabled = false; - } - - } - - public String poolIdentifier() - { - return "JDA"; - } - - public void clearQueue() - { - for (CompletableFuture messages : sentMessages) - { - if (!messages.isDone()) - { - messages.cancel(true); - } - } - sentMessages.clear(); - messageChatChannel("**Message queue cleared**", true); - } - - public String generateCode(int size) - { - return RandomStringUtils.randomNumeric(size); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerDeath(PlayerDeathEvent event) - { - //Avoiding NPE Unboxing Warnings - Boolean b = event.getEntity().getWorld().getGameRuleValue(GameRule.SHOW_DEATH_MESSAGES); - if (b == null || !b) - { - return; - } - - Component deathMessage = event.deathMessage(); - - if (deathMessage != null) - { - messageChatChannel("**" + deformat(PlainTextComponentSerializer.plainText().serialize(deathMessage)) + "**", true); - } - } - - @Override - public void onStart() - { - startBot(); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerJoin(PlayerJoinEvent event) - { - if (!plugin.al.isVanished(event.getPlayer().getUniqueId())) - { - messageChatChannel("**" + deformat(event.getPlayer().getName()) + " joined the server" + "**", true); - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerLeave(PlayerQuitEvent event) - { - if (!plugin.al.isVanished(event.getPlayer().getUniqueId())) - { - messageChatChannel("**" + deformat(event.getPlayer().getName()) + " left the server" + "**", true); - } - } - - public static String sanitizeChatMessage(String message) - { - String newMessage = message; - - if (message.contains("@")) - { - // \u200B is Zero Width Space, invisible on Discord - newMessage = message.replaceAll("@", "@\u200B"); - } - - if (message.toLowerCase().contains("discord.gg")) // discord.gg/invite works as an invite - { - return ""; - } - - for (String subdomain : DISCORD_SUBDOMAINS) - { - if (message.toLowerCase().contains(subdomain + "/invite")) - { - return ""; - } - } - - if (message.contains("§")) - { - newMessage = message.replaceAll("§", ""); - } - - return deformat(newMessage); - } - - public void messageChatChannel(String message) - { - messageChatChannel(message, false); - } - - public void messageChatChannel(String message, boolean system) - { - String chat_channel_id = ConfigEntry.DISCORD_CHAT_CHANNEL_ID.getString(); - - String sanitizedMessage = (system) ? message : sanitizeChatMessage(message); - - if (sanitizedMessage.isBlank()) return; - - if (enabled && !chat_channel_id.isEmpty()) - { - CompletableFuture sentMessage = Objects.requireNonNull(bot.getTextChannelById(chat_channel_id)).sendMessage(sanitizedMessage).submit(true); - sentMessages.add(sentMessage); - } - } - - public void messageAdminChatChannel(String message) - { - messageAdminChatChannel(message, false); - } - - public void messageAdminChatChannel(String message, boolean system) - { - String chat_channel_id = ConfigEntry.DISCORD_ADMINCHAT_CHANNEL_ID.getString(); - - String sanitizedMessage = sanitizeChatMessage(message); - - if (sanitizedMessage.isBlank()) return; - - if (enabled && !chat_channel_id.isEmpty()) - { - CompletableFuture sentMessage = Objects.requireNonNull(bot.getTextChannelById(chat_channel_id)).sendMessage(sanitizedMessage).submit(true); - sentMessages.add(sentMessage); - } - } - - public String formatBotTag() - { - SelfUser user = bot.getSelfUser(); - return user.getAsTag(); - } - - @Override - public void onStop() - { - if (bot != null) - { - messageChatChannel("**Server has stopped**", true); - } - - FLog.info("Discord integration has successfully shutdown."); - } - - public static String deformat(String input) - { - return input.replaceAll("([_\\\\`*>|])", "\\\\$1"); - } - - public boolean shouldISendReport() - { - if (ConfigEntry.DISCORD_REPORT_CHANNEL_ID.getString().isEmpty()) - { - return false; - } - - if (ConfigEntry.DISCORD_SERVER_ID.getString().isEmpty()) - { - FLog.severe("No Discord server ID was specified in the config, but there is a report channel ID."); - return false; - } - - Guild server = bot.getGuildById(ConfigEntry.DISCORD_SERVER_ID.getString()); - if (server == null) - - { - FLog.severe("The Discord server ID specified is invalid, or the bot is not on the server."); - return false; - } - - TextChannel channel = server.getTextChannelById(ConfigEntry.DISCORD_REPORT_CHANNEL_ID.getString()); - if (channel == null) - { - FLog.severe("The report channel ID specified in the config is invalid."); - return false; - } - - return true; - } - - public boolean sendReportOffline(Player reporter, OfflinePlayer reported, String reason) - { - if (!shouldISendReport()) - { - return false; - } - - final Guild server = bot.getGuildById(ConfigEntry.DISCORD_SERVER_ID.getString()); - - if (server == null) - { - FLog.severe("The guild ID specified in the config is invalid."); - return false; - } - - final TextChannel channel = server.getTextChannelById(ConfigEntry.DISCORD_REPORT_CHANNEL_ID.getString()); - - if (channel == null) - { - FLog.severe("The report channel ID specified in the config is invalid."); - return false; - } - - final EmbedBuilder embedBuilder = new EmbedBuilder(); - embedBuilder.setTitle("Report for " + reported.getName() + " (offline)"); - embedBuilder.setDescription(reason); - embedBuilder.setFooter("Reported by " + reporter.getName(), "https://minotar.net/helm/" + reporter.getName() + ".png"); - embedBuilder.setTimestamp(Instant.from(ZonedDateTime.now())); - if (plugin.esb.isEnabled()) - { - com.earth2me.essentials.User user = plugin.esb.getEssentialsUser(reported.getName()); - String location = "World: " + Objects.requireNonNull(user.getLastLocation().getWorld()).getName() + ", X: " + user.getLastLocation().getBlockX() + ", Y: " + user.getLastLocation().getBlockY() + ", Z: " + user.getLastLocation().getBlockZ(); - embedBuilder.addField("Location", location, true); - embedBuilder.addField("God Mode", WordUtils.capitalizeFully(String.valueOf(user.isGodModeEnabled())), true); - if (user.getNickname() != null) - { - embedBuilder.addField("Nickname", user.getNickname(), true); - } - } - MessageEmbed embed = embedBuilder.build(); - Message message = channel.sendMessageEmbeds(embed).complete(); - - if (!ConfigEntry.DISCORD_REPORT_ARCHIVE_CHANNEL_ID.getString().isEmpty()) - { - message.addReaction("\uD83D\uDCCB").complete(); - } - - return true; - } - - public boolean sendReport(Player reporter, Player reported, String reason) - { - if (!shouldISendReport()) - { - return false; - } - - final Guild server = bot.getGuildById(ConfigEntry.DISCORD_SERVER_ID.getString()); - - if (server == null) - { - FLog.severe("The guild ID specified in the config is invalid."); - return false; - } - - final TextChannel channel = server.getTextChannelById(ConfigEntry.DISCORD_REPORT_CHANNEL_ID.getString()); - - if (channel == null) - { - FLog.severe("The report channel ID specified in the config is invalid."); - return false; - } - - final EmbedBuilder embedBuilder = new EmbedBuilder(); - embedBuilder.setTitle("Report for " + reported.getName()); - embedBuilder.setDescription(reason); - embedBuilder.setFooter("Reported by " + reporter.getName(), "https://minotar.net/helm/" + reporter.getName() + ".png"); - embedBuilder.setTimestamp(Instant.from(ZonedDateTime.now())); - String location = "World: " + Objects.requireNonNull(reported.getLocation().getWorld()).getName() + ", X: " + reported.getLocation().getBlockX() + ", Y: " + reported.getLocation().getBlockY() + ", Z: " + reported.getLocation().getBlockZ(); - embedBuilder.addField("Location", location, true); - embedBuilder.addField("Game Mode", WordUtils.capitalizeFully(reported.getGameMode().name()), true); - - if (plugin.esb.isEnabled()) - { - com.earth2me.essentials.User user = plugin.esb.getEssentialsUser(reported.getName()); - embedBuilder.addField("God Mode", WordUtils.capitalizeFully(String.valueOf(user.isGodModeEnabled())), true); - if (user.getNickname() != null) - { - embedBuilder.addField("Nickname", user.getNickname(), true); - } - } - - MessageEmbed embed = embedBuilder.build(); - Message message = channel.sendMessageEmbeds(embed).complete(); - - if (!ConfigEntry.DISCORD_REPORT_ARCHIVE_CHANNEL_ID.getString().isEmpty()) - { - message.addReaction("\uD83D\uDCCB").complete(); - } - - return true; - } - - // Do no ask why this is here. I spent two hours trying to make a simple thing work - public class StartEvent - { - public void start() - { - messageChatChannel("**Server has started**", true); - } - } - - @EventHandler(ignoreCancelled = true) - public void onAsyncPlayerChat(AsyncPlayerChatEvent event) - { - Player player = event.getPlayer(); - String message = event.getMessage(); - - if (!ConfigEntry.ADMIN_ONLY_MODE.getBoolean() && !server.hasWhitelist() - && !plugin.pl.getPlayer(player).isMuted() && bot != null) - { - messageChatChannel(player.getName() + " \u00BB " + ChatColor.stripColor(message)); - } - } -} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToAdminChatListener.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToAdminChatListener.java deleted file mode 100644 index 4e0ff6fb..00000000 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToAdminChatListener.java +++ /dev/null @@ -1,148 +0,0 @@ -package me.totalfreedom.totalfreedommod.discord; - -import com.google.common.base.Strings; -import me.totalfreedom.totalfreedommod.TotalFreedomMod; -import me.totalfreedom.totalfreedommod.admin.Admin; -import me.totalfreedom.totalfreedommod.config.ConfigEntry; -import me.totalfreedom.totalfreedommod.rank.Displayable; -import me.totalfreedom.totalfreedommod.rank.Rank; -import me.totalfreedom.totalfreedommod.rank.Title; -import me.totalfreedom.totalfreedommod.util.FLog; -import me.totalfreedom.totalfreedommod.util.FUtil; -import net.dv8tion.jda.api.entities.Guild; -import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.entities.Message; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; -import net.dv8tion.jda.api.hooks.ListenerAdapter; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.TextComponent; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; - -public class DiscordToAdminChatListener extends ListenerAdapter -{ - - DiscordToMinecraftListener dtml = new DiscordToMinecraftListener(); - - public static net.md_5.bungee.api.ChatColor getColor(Displayable display) - { - return display.getColor(); - } - - public void onMessageReceived(MessageReceivedEvent event) - { - String chat_channel_id = ConfigEntry.DISCORD_ADMINCHAT_CHANNEL_ID.getString(); - if (event.getMember() != null && !chat_channel_id.isEmpty() && event.getChannel().getId().equals(chat_channel_id) && !event.getAuthor().getId().equals(event.getJDA().getSelfUser().getId())) - { - Member member = event.getMember(); - String tag = dtml.getDisplay(member); - Message msg = event.getMessage(); - String mediamessage = ChatColor.YELLOW + "[Media]"; - - StringBuilder logmessage = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "] " + ChatColor.RESET); - String lm = ChatColor.DARK_RED + member.getEffectiveName() + " " - + ChatColor.DARK_GRAY + tag + ChatColor.DARK_GRAY - + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(msg.getContentDisplay()); - logmessage.append(lm); - - if (!msg.getAttachments().isEmpty()) - { - - logmessage.append(mediamessage); // Actually for logging... - - } - FLog.info(logmessage.toString()); - - Bukkit.getOnlinePlayers().stream().filter(player -> TotalFreedomMod.getPlugin().al.isAdmin(player)).forEach(player -> - { - StringBuilder message = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "] " + ChatColor.RESET); - - ComponentBuilder builder = new ComponentBuilder(message.toString()); - - Admin admin = TotalFreedomMod.getPlugin().al.getAdmin(player); - String format = admin.getAcFormat(); - if (!Strings.isNullOrEmpty(format)) - { - Displayable display = getDisplay(member); - net.md_5.bungee.api.ChatColor color = getColor(display); - String m = format.replace("%name%", member.getEffectiveName()) - .replace("%rank%", display.getAbbr()) - .replace("%rankcolor%", color.toString()) - .replace("%msg%", FUtil.colorize(msg.getContentDisplay())); - builder.append(FUtil.colorize(m)); - - } - else - { - String m = ChatColor.DARK_RED + member.getEffectiveName() + " " - + ChatColor.DARK_GRAY + tag + ChatColor.DARK_GRAY - + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(msg.getContentDisplay()); - builder.append(m); - } - - if (!msg.getAttachments().isEmpty()) - { - for (Message.Attachment attachment : msg.getAttachments()) - { - TextComponent text = new TextComponent(mediamessage); - text.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl())); - if (!msg.getContentDisplay().isEmpty()) - { - builder.append(" "); - } - builder.append(text); - } - } - player.spigot().sendMessage(builder.create()); - - }); - } - } - - // Needed to display tags in custom AC messages - public Displayable getDisplay(Member member) - { - Guild server = Discord.bot.getGuildById(ConfigEntry.DISCORD_SERVER_ID.getString()); - // Server Owner - if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_SERVER_OWNER_ROLE_ID.getString()))) - { - return Title.OWNER; - } - // Developers - else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_DEVELOPER_ROLE_ID.getString()))) - { - return Title.DEVELOPER; - } - // Executives - else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_EXECUTIVE_ROLE_ID.getString()))) - { - return Title.EXECUTIVE; - } - // Assistant Executives - else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_ASSISTANT_EXECUTIVE_ROLE_ID.getString()))) - { - return Title.ASSTEXEC; - } - // Senior Admins - else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_SENIOR_ADMIN_ROLE_ID.getString()))) - { - return Rank.SENIOR_ADMIN; - } - // Admins - else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_NEW_ADMIN_ROLE_ID.getString()))) - { - return Rank.ADMIN; - } - // Master Builders - else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_MASTER_BUILDER_ROLE_ID.getString()))) - { - return Title.MASTER_BUILDER; - } - // OP, returning null breaks? - else - { - return Rank.OP; - } - } -} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToMinecraftListener.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToMinecraftListener.java deleted file mode 100644 index 01c1c638..00000000 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToMinecraftListener.java +++ /dev/null @@ -1,173 +0,0 @@ -package me.totalfreedom.totalfreedommod.discord; - -import me.totalfreedom.totalfreedommod.TotalFreedomMod; -import me.totalfreedom.totalfreedommod.config.ConfigEntry; -import me.totalfreedom.totalfreedommod.rank.Rank; -import me.totalfreedom.totalfreedommod.rank.Title; -import me.totalfreedom.totalfreedommod.util.FLog; -import me.totalfreedom.totalfreedommod.util.FUtil; -import net.dv8tion.jda.api.entities.*; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; -import net.dv8tion.jda.api.hooks.ListenerAdapter; -import net.md_5.bungee.api.chat.BaseComponent; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.TextComponent; -import net.md_5.bungee.api.chat.hover.content.Text; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; - -public class DiscordToMinecraftListener extends ListenerAdapter -{ - public void onMessageReceived(MessageReceivedEvent event) - { - final String chat_channel_id = ConfigEntry.DISCORD_CHAT_CHANNEL_ID.getString(); - final MessageChannel genericChannel = event.getChannel(); - - if (event.getMember() == null) - { - return; - } - - if (chat_channel_id.isEmpty()) - { - return; - } - - if (event.getAuthor().getId().equals(Discord.bot.getSelfUser().getId())) - { - return; - } - - if (!genericChannel.getId().equals(chat_channel_id)) - { - return; - } - - if (!(genericChannel instanceof TextChannel)) - { - return; - } - - final TextChannel textChannel = (TextChannel) genericChannel; - - final Member member = event.getMember(); - final String tag = getDisplay(member); - final Message msg = event.getMessage(); - final String content = msg.getContentStripped(); - - if (content.startsWith(ConfigEntry.DISCORD_PREFIX.getString())) - { - Discord.DISCORD_COMMAND_MANAGER.parse(content, member, textChannel); - return; - } - - ComponentBuilder emsg = new ComponentBuilder(); - - // Prefix - emsg.append(ChatColor.DARK_GRAY + "["); - TextComponent inviteLink = new TextComponent("Discord"); - inviteLink.setColor(ChatColor.DARK_AQUA.asBungee()); - inviteLink.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, - new Text("Click here to get the invite link!"))); - inviteLink.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, - ConfigEntry.DISCORD_INVITE_LINK.getString())); - emsg.append(inviteLink); - emsg.append(ChatColor.DARK_GRAY + "] ", ComponentBuilder.FormatRetention.NONE); - - // Tag (if they have one) - if (tag != null) - { - emsg.append(tag); - } - - emsg.append(" "); - - // User - TextComponent user = new TextComponent(FUtil.stripColors(member.getEffectiveName())); - user.setColor(ChatColor.RED.asBungee()); - emsg.append(user); - - // Message - emsg.append(ChatColor.DARK_GRAY + ": " + ChatColor.RESET - + FUtil.stripColors(msg.getContentDisplay()), ComponentBuilder.FormatRetention.NONE); - - // Attachments - if (!msg.getAttachments().isEmpty()) - { - if (!msg.getContentDisplay().isEmpty()) - emsg.append(" "); - - for (Message.Attachment attachment : msg.getAttachments()) - { - TextComponent media = new TextComponent("[Media] "); - media.setColor(ChatColor.YELLOW.asBungee()); - media.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl())); - media.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(attachment.getUrl()))); - - emsg.append(media, ComponentBuilder.FormatRetention.NONE); - } - } - - BaseComponent[] components = emsg.create(); - - for (Player player : Bukkit.getOnlinePlayers()) - { - if (TotalFreedomMod.getPlugin().pl.getData(player).doesDisplayDiscord()) - { - player.sendMessage(components); - } - } - - FLog.info(BaseComponent.toLegacyText(components), true); - } - - - public String getDisplay(Member member) - { - Guild server = Discord.bot.getGuildById(ConfigEntry.DISCORD_SERVER_ID.getString()); - // Server Owner - assert server != null; - if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_SERVER_OWNER_ROLE_ID.getString()))) - { - return Title.OWNER.getColoredTag(); - } - // Developers - else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_DEVELOPER_ROLE_ID.getString()))) - { - return Title.DEVELOPER.getColoredTag(); - } - // Executives - else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_EXECUTIVE_ROLE_ID.getString()))) - { - return Title.EXECUTIVE.getColoredTag(); - } - // Assistant Executives - else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_ASSISTANT_EXECUTIVE_ROLE_ID.getString()))) - { - return Title.ASSTEXEC.getColoredTag(); - } - // Senior Admins - else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_SENIOR_ADMIN_ROLE_ID.getString()))) - { - return Rank.SENIOR_ADMIN.getColoredTag(); - } - // Admins - else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_NEW_ADMIN_ROLE_ID.getString()))) - { - return Rank.ADMIN.getColoredTag(); - } - // Master Builders - else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_MASTER_BUILDER_ROLE_ID.getString()))) - { - return Title.MASTER_BUILDER.getColoredTag(); - } - // None - else - { - return null; - } - } -} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/MessageReactionListener.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/MessageReactionListener.java deleted file mode 100644 index 738a2e5e..00000000 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/MessageReactionListener.java +++ /dev/null @@ -1,68 +0,0 @@ -package me.totalfreedom.totalfreedommod.discord; - -import me.totalfreedom.totalfreedommod.config.ConfigEntry; -import me.totalfreedom.totalfreedommod.util.FLog; -import net.dv8tion.jda.api.MessageBuilder; -import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.entities.Message; -import net.dv8tion.jda.api.entities.MessageEmbed; -import net.dv8tion.jda.api.entities.TextChannel; -import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent; -import net.dv8tion.jda.api.hooks.ListenerAdapter; - -public class MessageReactionListener extends ListenerAdapter -{ - public void onMessageReactionAdd(MessageReactionAddEvent messageReactionAddEvent) - { - if (!messageReactionAddEvent.isFromGuild()) - { - return; - } - - if (messageReactionAddEvent.getMember() == null) - { - return; - } - - if (messageReactionAddEvent.getMember().getUser().getId().equals(Discord.bot.getSelfUser().getId())) - { - return; - } - - if (!messageReactionAddEvent.getChannel().getId().equals(ConfigEntry.DISCORD_REPORT_CHANNEL_ID.getString())) - { - return; - } - - if (!messageReactionAddEvent.getReactionEmote().getEmoji().equals("\uD83D\uDCCB")) - { - return; - } - - final TextChannel archiveChannel = Discord.bot.getTextChannelById(ConfigEntry.DISCORD_REPORT_ARCHIVE_CHANNEL_ID.getString()); - - if (archiveChannel == null) - { - FLog.warning("Report archive channel is defined in the config, yet doesn't actually exist!"); - return; - } - - final Message message = messageReactionAddEvent.retrieveMessage().complete(); - final Member completer = messageReactionAddEvent.getMember(); - - if (!message.getAuthor().getId().equals(Discord.bot.getSelfUser().getId())) - { - return; - } - - // We don't need other embeds... yet? - final MessageEmbed embed = message.getEmbeds().get(0); - final MessageBuilder archiveMessageBuilder = new MessageBuilder(); - archiveMessageBuilder.setContent("Report completed by " + completer.getUser().getAsMention() + " (" + Discord.deformat(completer.getUser().getAsTag() + ")")); - archiveMessageBuilder.setEmbed(embed); - final Message archiveMessage = archiveMessageBuilder.build(); - - archiveChannel.sendMessage(archiveMessage).complete(); - message.delete().complete(); - } -} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/PrivateMessageListener.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/PrivateMessageListener.java deleted file mode 100644 index a9a2bde4..00000000 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/PrivateMessageListener.java +++ /dev/null @@ -1,43 +0,0 @@ -package me.totalfreedom.totalfreedommod.discord; - -import me.totalfreedom.totalfreedommod.TotalFreedomMod; -import me.totalfreedom.totalfreedommod.admin.Admin; -import me.totalfreedom.totalfreedommod.player.PlayerData; -import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent; -import net.dv8tion.jda.api.hooks.ListenerAdapter; - -public class PrivateMessageListener extends ListenerAdapter -{ - public void onPrivateMessageReceived(PrivateMessageReceivedEvent event) - { - if (!event.getAuthor().getId().equals(event.getJDA().getSelfUser().getId())) - { - // Handle link code - if (event.getMessage().getContentRaw().matches("[0-9][0-9][0-9][0-9][0-9]")) - { - String code = event.getMessage().getContentRaw(); - String name; - if (Discord.LINK_CODES.get(code) != null) - { - PlayerData player = Discord.LINK_CODES.get(code); - name = player.getName(); - player.setDiscordID(event.getMessage().getAuthor().getId()); - - Admin admin = TotalFreedomMod.getPlugin().al.getEntryByUuid(player.getUuid()); - if (admin != null) - { - Discord.syncRoles(admin, player.getDiscordID()); - } - - TotalFreedomMod.getPlugin().pl.save(player); - Discord.LINK_CODES.remove(code); - } - else - { - return; - } - event.getChannel().sendMessage("Link successful. Now this Discord account is linked with your Minecraft account **" + name + "**.").complete(); - } - } - } -} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/command/DiscordCommand.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/command/DiscordCommand.java deleted file mode 100644 index 94c16ad4..00000000 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/command/DiscordCommand.java +++ /dev/null @@ -1,25 +0,0 @@ -package me.totalfreedom.totalfreedommod.discord.command; - -import net.dv8tion.jda.api.MessageBuilder; -import net.dv8tion.jda.api.entities.Guild; -import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.entities.User; - -import java.util.List; - -public interface DiscordCommand -{ - String getCommandName(); - - String getDescription(); - - String getCategory(); - - List getAliases(); - - boolean isAdmin(); - - boolean canExecute(Member member); - - MessageBuilder execute(Member member, List args); -} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/command/DiscordCommandImpl.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/command/DiscordCommandImpl.java deleted file mode 100644 index 4726f1c2..00000000 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/command/DiscordCommandImpl.java +++ /dev/null @@ -1,13 +0,0 @@ -package me.totalfreedom.totalfreedommod.discord.command; - -import net.dv8tion.jda.api.entities.Member; - -public abstract class DiscordCommandImpl implements DiscordCommand -{ - @Override - public boolean canExecute(Member member) - { - // TODO Implement administrator checks if/when any administrative Discord commands are added to the bot - return !isAdmin(); - } -} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/command/DiscordCommandManager.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/command/DiscordCommandManager.java deleted file mode 100644 index 93f1c60b..00000000 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/command/DiscordCommandManager.java +++ /dev/null @@ -1,84 +0,0 @@ -package me.totalfreedom.totalfreedommod.discord.command; - -import me.totalfreedom.totalfreedommod.config.ConfigEntry; -import me.totalfreedom.totalfreedommod.discord.Discord; -import me.totalfreedom.totalfreedommod.util.FLog; -import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.MessageBuilder; -import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.entities.Message; -import net.dv8tion.jda.api.entities.TextChannel; -import org.reflections.Reflections; - -import java.awt.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import java.util.concurrent.CompletableFuture; - -public class DiscordCommandManager -{ - public static final String PREFIX = ConfigEntry.DISCORD_PREFIX.getString(); - private Discord discord; - public final List commands = new ArrayList<>(); - - public void init(Discord discord) - { - this.discord = discord; - - final Reflections discordCommandsDir = new Reflections("me.totalfreedom.totalfreedommod.discord.commands"); - - final Set> commandClasses = discordCommandsDir.getSubTypesOf(DiscordCommand.class); - - for (Class commandClass : commandClasses) - { - try - { - commands.add(commandClass.getDeclaredConstructor().newInstance()); - } - catch (Exception e) - { - FLog.warning("Failed to load Discord command: " + commandClass.getName()); - } - } - - FLog.info("Loaded " + commands.size() + " Discord commands."); - } - - public void parse(String content, Member member, TextChannel channel) - { - List args = new ArrayList<>(Arrays.asList(content.split(" "))); - - final String alias = args.remove(0).split(PREFIX)[1]; // The joys of command parsing - - for (DiscordCommand command : commands) - { - if (command.getCommandName().equalsIgnoreCase(alias) || command.getAliases().contains(alias.toLowerCase())) - { - if (command.canExecute(member)) - { - final MessageBuilder messageBuilder = command.execute(member, args); - final Message message = messageBuilder.build(); - final CompletableFuture futureMessage = channel.sendMessage(message).submit(true); - - this.discord.sentMessages.add(futureMessage); - } - else - { - final MessageBuilder messageBuilder = new MessageBuilder(); - final EmbedBuilder embedBuilder = new EmbedBuilder(); - embedBuilder.setTitle("Command error"); - embedBuilder.setColor(Color.RED); - embedBuilder.setDescription("You don't have permission to execute this command."); - messageBuilder.setEmbed(embedBuilder.build()); - final Message message = messageBuilder.build(); - - final CompletableFuture futureMessage = channel.sendMessage(message).submit(true); - - this.discord.sentMessages.add(futureMessage); - } - } - } - } -} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/commands/HelpCommand.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/commands/HelpCommand.java deleted file mode 100644 index ffa0a437..00000000 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/commands/HelpCommand.java +++ /dev/null @@ -1,86 +0,0 @@ -package me.totalfreedom.totalfreedommod.discord.commands; - -import me.totalfreedom.totalfreedommod.discord.Discord; -import me.totalfreedom.totalfreedommod.discord.command.DiscordCommand; -import me.totalfreedom.totalfreedommod.discord.command.DiscordCommandImpl; -import me.totalfreedom.totalfreedommod.discord.command.DiscordCommandManager; -import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.MessageBuilder; -import net.dv8tion.jda.api.entities.Member; - -import java.awt.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class HelpCommand extends DiscordCommandImpl -{ - @Override - public String getCommandName() - { - return "help"; - } - - @Override - public String getDescription() - { - return "Displays the help command"; - } - - @Override - public String getCategory() - { - return "Help"; - } - - @Override - public List getAliases() - { - return List.of("cmds", "commands", "elp"); - } - - @Override - public boolean isAdmin() - { - return false; - } - - @Override - public MessageBuilder execute(Member member, List args) - { - final EmbedBuilder embedBuilder = new EmbedBuilder(); - embedBuilder.setColor(Color.GREEN); - embedBuilder.setTitle("Help Command"); - - final Map> commandCategories = new HashMap<>(); - - for (DiscordCommand command : Discord.DISCORD_COMMAND_MANAGER.commands) - { - if (!commandCategories.containsKey(command.getCategory())) - { - commandCategories.put(command.getCategory(), new ArrayList<>(List.of(command))); - } - else - { - commandCategories.get(command.getCategory()).add(command); - } - } - - for (Map.Entry> entry : commandCategories.entrySet()) - { - final String category = entry.getKey(); - final List commands = entry.getValue(); - final StringBuilder fieldValue = new StringBuilder(); - - for (DiscordCommand command : commands) - { - fieldValue.append("**").append(DiscordCommandManager.PREFIX).append(command.getCommandName()).append("** - ").append(command.getDescription()).append("\n"); - } - - embedBuilder.addField(category, fieldValue.toString().trim(), false); - } - - return new MessageBuilder().setEmbeds(embedBuilder.build()); - } -} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/commands/ListCommand.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/commands/ListCommand.java deleted file mode 100644 index ac3fda2e..00000000 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/commands/ListCommand.java +++ /dev/null @@ -1,99 +0,0 @@ -package me.totalfreedom.totalfreedommod.discord.commands; - -import me.totalfreedom.totalfreedommod.TotalFreedomMod; -import me.totalfreedom.totalfreedommod.admin.AdminList; -import me.totalfreedom.totalfreedommod.config.ConfigEntry; -import me.totalfreedom.totalfreedommod.discord.Discord; -import me.totalfreedom.totalfreedommod.discord.command.DiscordCommandImpl; -import me.totalfreedom.totalfreedommod.rank.Displayable; -import me.totalfreedom.totalfreedommod.rank.RankManager; -import me.totalfreedom.totalfreedommod.util.FUtil; -import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.MessageBuilder; -import net.dv8tion.jda.api.entities.Member; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class ListCommand extends DiscordCommandImpl -{ - private static final TotalFreedomMod PLUGIN = TotalFreedomMod.plugin(); - - @Override - public String getCommandName() - { - return "list"; - } - - @Override - public String getDescription() - { - return "Gives a list of online players."; - } - - @Override - public String getCategory() - { - return "Server Commands"; - } - - @Override - public List getAliases() - { - return List.of("online", "who", "l", "lsit"); - } - - @Override - public boolean isAdmin() - { - return false; - } - - @Override - public MessageBuilder execute(Member member, List args) - { - if (PLUGIN == null) - { - throw new IllegalStateException("TotalFreedomMod somehow null while executing a command!"); - } - - final AdminList adminList = PLUGIN.al; - final RankManager rankManager = PLUGIN.rm; - - EmbedBuilder embedBuilder = new EmbedBuilder() - .setTitle("Player List - " + ConfigEntry.SERVER_NAME.getString()) - .setDescription("There are " + FUtil.getFakePlayerCount() + " / " + Bukkit.getMaxPlayers() + " online players"); - - Map> displayables = new HashMap<>(); - - Bukkit.getOnlinePlayers().stream().filter(player -> !adminList.isVanished(player.getUniqueId())).forEach(player -> - { - final Displayable displayable = rankManager.getDisplay(player); - final String name = Discord.deformat(player.getName()); - - if (displayables.containsKey(displayable)) - { - displayables.get(displayable).add(name); - } - else - { - displayables.put(displayable, new ArrayList<>(List.of(name))); - } - }); - - for (Map.Entry> entry : displayables.entrySet()) - { - final Displayable displayable = entry.getKey(); - final List players = entry.getValue(); - - embedBuilder.addField(displayable.getPlural() + " (" + players.size() + ")", - String.join(", ", players), false); - } - - return new MessageBuilder().setEmbeds(embedBuilder.build()); - } -} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/commands/TPSCommand.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/commands/TPSCommand.java deleted file mode 100644 index 4ce0d008..00000000 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/commands/TPSCommand.java +++ /dev/null @@ -1,58 +0,0 @@ -package me.totalfreedom.totalfreedommod.discord.commands; - -import me.totalfreedom.totalfreedommod.discord.command.DiscordCommandImpl; -import me.totalfreedom.totalfreedommod.util.FUtil; -import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.MessageBuilder; -import net.dv8tion.jda.api.entities.Member; -import org.bukkit.Bukkit; - -import java.util.Collections; -import java.util.List; - -public class TPSCommand extends DiscordCommandImpl -{ - @Override - public String getCommandName() - { - return "tps"; - } - - @Override - public String getDescription() - { - return "Lag information regarding the server."; - } - - @Override - public String getCategory() - { - return "Server Commands"; - } - - @Override - public List getAliases() - { - return Collections.singletonList("lag"); - } - - @Override - public boolean isAdmin() - { - return false; - } - - @Override - public MessageBuilder execute(Member member, List args) - { - final EmbedBuilder builder = new EmbedBuilder(); - builder.setTitle("Server lag information"); - builder.addField("TPS", String.valueOf(Math.round(FUtil.getMeanAverageDouble(Bukkit.getServer().getTPS()))), false); - builder.addField("Uptime", FUtil.getUptime(), false); - builder.addField("Maximum Memory", Math.ceil(FUtil.getMaxMem()) + " MB", false); - builder.addField("Allocated Memory", Math.ceil(FUtil.getTotalMem()) + " MB", false); - builder.addField("Free Memory", Math.ceil(FUtil.getFreeMem()) + " MB", false); - - return new MessageBuilder().setEmbeds(builder.build()); - } -}