diff --git a/commons/pom.xml b/commons/pom.xml index 92fcc0be..b54d64a1 100644 --- a/commons/pom.xml +++ b/commons/pom.xml @@ -53,6 +53,13 @@ provided + + me.totalfreedom + shop + 2023.02 + provided + + org.reflections reflections diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java index 116a4beb..68550f01 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java @@ -149,7 +149,10 @@ public class ChatManager extends FreedomService { Displayable display = plugin.rm.getDisplay(sender); FLog.info("[ADMIN] " + sender.getName() + " " + display.getTag() + ": " + message, true); - plugin.dc.messageAdminChatChannel(sender.getName() + " \u00BB " + message); + + if (plugin.dc != null) { + plugin.dc.getUtils().messageAdminChatChannel(sender.getName() + " \u00BB " + message); + } server.getOnlinePlayers().stream().filter(player -> plugin.al.isAdmin(player)).forEach(player -> { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java index 0526bd85..c248d588 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java @@ -39,8 +39,8 @@ import me.totalfreedom.totalfreedommod.permissions.PermissionManager; import me.totalfreedom.totalfreedommod.player.PlayerList; import me.totalfreedom.totalfreedommod.punishments.PunishmentList; import me.totalfreedom.totalfreedommod.rank.RankManager; -import me.totalfreedom.totalfreedommod.shop.Shop; -import me.totalfreedom.totalfreedommod.shop.Votifier; +import me.totalfreedom.shop.Shop; +import me.totalfreedom.shop.Votifier; import me.totalfreedom.totalfreedommod.sql.SQLite; import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FUtil; @@ -299,11 +299,19 @@ public class TotalFreedomMod extends JavaPlugin as = new AntiSpam(); wr = new WorldRestrictions(); pl = new PlayerList(); - sh = new Shop(); - vo = new Votifier(); + + if (Bukkit.getPluginManager().isPluginEnabled("TF-Shoppe")) { + sh = new Shop(); + vo = new Votifier(); + } + an = new Announcer(); cm = new ChatManager(); - dc = new TFM_Accessor().botAccessor(); + + if (Bukkit.getPluginManager().isPluginEnabled("TFD4J")) { + dc = new TFM_Accessor().botAccessor(); + } + pul = new PunishmentList(); bm = new BanManager(); im = new IndefiniteBanList(); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java index c3353d32..70843ffb 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java @@ -148,44 +148,48 @@ public class Admin if (!active) { - if (getRank().isAtLeast(Rank.ADMIN)) - { - if (plugin.btb != null) - { - plugin.btb.killTelnetSessions(getName()); - } - - // Ensure admins don't have admin functionality when removed (FS-222) - AdminList.vanished.remove(getName()); - - if (plugin.esb != null) - { - plugin.esb.setVanished(getName(), false); - } - - setCommandSpy(false); - setPotionSpy(false); - - Server server = Bukkit.getServer(); - Player player = server.getPlayer(getUuid()); - - if (player != null) - { - // Update chats - FPlayer freedomPlayer = plugin.pl.getPlayer(player); - freedomPlayer.removeAdminFunctionality(); - - // Disable vanish - for (Player player1 : server.getOnlinePlayers()) - { - player1.showPlayer(plugin, player); - } - } - - } + setActiveSplitWorkToReduceComplexity(plugin); } } + private void setActiveSplitWorkToReduceComplexity(TotalFreedomMod plugin) { + if (getRank().isAtLeast(Rank.ADMIN)) + { + if (plugin.btb != null) + { + plugin.btb.killTelnetSessions(getName()); + } + + // Ensure admins don't have admin functionality when removed (FS-222) + AdminList.vanished.remove(getName()); + + if (plugin.esb != null) + { + plugin.esb.setVanished(getName(), false); + } + + setCommandSpy(false); + setPotionSpy(false); + + Server server = Bukkit.getServer(); + Player player = server.getPlayer(getUuid()); + + if (player != null) + { + // Update chats + FPlayer freedomPlayer = plugin.pl.getPlayer(player); + freedomPlayer.removeAdminFunctionality(); + + // Disable vanish + for (Player player1 : server.getOnlinePlayers()) + { + player1.showPlayer(plugin, player); + } + } + + } +} + public Rank getRank() { return rank; diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java index 84ec6d15..d71c993f 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java @@ -35,6 +35,7 @@ public class AdminList extends FreedomService @Override public void onStop() { + // This does nothing. This comment is here to prevent SonarLint from complaining. } public void load() diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/BanManager.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/BanManager.java index 23e60e58..c308d34c 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/BanManager.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/BanManager.java @@ -71,6 +71,7 @@ public class BanManager extends FreedomService @Override public void onStop() { + // This does nothing. This comment is here to prevent SonarLint from complaining. } public Set getAllBans() diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBan.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBan.java index 317105f3..f0bb1959 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBan.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBan.java @@ -19,10 +19,6 @@ public class IndefiniteBan implements IConfig private String reason = null; private Date expiry = null; - public IndefiniteBan() - { - } - @Override public void loadFrom(ConfigurationSection cs) { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBanList.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBanList.java index 953c4c51..00515dea 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBanList.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBanList.java @@ -79,6 +79,7 @@ public class IndefiniteBanList extends FreedomService @Override public void onStop() { + // This does nothing. This comment is here to prevent SonarLint from complaining. } @EventHandler(priority = EventPriority.LOWEST) @@ -113,6 +114,10 @@ public class IndefiniteBanList extends FreedomService } } + onPlayerLoginSplitWorkToReduceComplexity(event, ban, bannedBy); + } + + private void onPlayerLoginSplitWorkToReduceComplexity(PlayerLoginEvent event, IndefiniteBan ban, String bannedBy) { if (ban != null) { if (ban.isExpired()) @@ -123,8 +128,8 @@ public class IndefiniteBanList extends FreedomService } String kickMessage = ChatColor.RED + "Your " + bannedBy + " is " - + (ban.hasExpiry() ? "" : "indefinitely ") - + "banned from this server."; + + (ban.hasExpiry() ? "" : "indefinitely ") + + "banned from this server."; String reason = ban.getReason(); if (!Strings.isNullOrEmpty(reason)) { @@ -145,7 +150,6 @@ public class IndefiniteBanList extends FreedomService event.disallow(PlayerLoginEvent.Result.KICK_OTHER, kickMessage); } } - private void updateCount() { nameBanCount = 0; diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java index 03fe28d9..93ad8892 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java @@ -26,6 +26,7 @@ public class BlockBlocker extends FreedomService } @SuppressWarnings("deprecation") + // TODO: Remove deprecated method. Complexity is also O(35) which is very bad. @EventHandler(priority = EventPriority.HIGH) public void onBlockPlace(BlockPlaceEvent event) { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java index 6a70f7d4..9ebe649f 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java @@ -66,6 +66,7 @@ public class InteractBlocker extends FreedomService } } + // TODO: Current cognitive complexity is O(24). This is too high. private void handleRightClick(PlayerInteractEvent event) { final Player player = event.getPlayer(); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java index 2dae585b..99f39f14 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java @@ -54,6 +54,7 @@ public class MobBlocker extends FreedomService } } + // TODO: Complexity for this method is too high [O(23)]. This needs to be fixed. @EventHandler(priority = EventPriority.NORMAL) public void onCreatureSpawn(CreatureSpawnEvent event) { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/PVPBlocker.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/PVPBlocker.java index 52d855c2..d05f7d32 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/PVPBlocker.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/PVPBlocker.java @@ -24,6 +24,7 @@ public class PVPBlocker extends FreedomService { } + // TODO: Complexity is O(26). This needs to be reduced. @EventHandler(priority = EventPriority.LOW) public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { @@ -70,7 +71,7 @@ public class PVPBlocker extends FreedomService } } - if (player != null & !plugin.al.isAdmin(player)) + if (player != null && !plugin.al.isAdmin(player)) { if (player.getGameMode() == GameMode.CREATIVE) { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlocker.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlocker.java index 514de44e..925ee64f 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlocker.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlocker.java @@ -60,7 +60,7 @@ public class CommandBlocker extends FreedomService entryList.clear(); } - public void load() + public void load() // TODO: Complexity is 21. Need to fix this. { entryList.clear(); unknownCommands.clear(); @@ -147,6 +147,7 @@ public class CommandBlocker extends FreedomService return isCommandBlocked(command, sender, false); } + // TODO: Complexity is 22. Need to fix this. Complexity can be no more than O(15). public boolean isCommandBlocked(String command, CommandSender sender, boolean doAction) { if (command == null || command.isEmpty()) diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java index f5ba0c7a..8f317599 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java @@ -166,6 +166,7 @@ public class CoreProtectBridge extends FreedomService return historyMap.get(player.getUniqueId()); } + // TODO: Complexity is O(19). This should be reduced. public void showPageToPlayer(Player player, FUtil.PaginationList results, int pageNum) { if (player == null || !player.isOnline()) diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/LibsDisguisesBridge.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/LibsDisguisesBridge.java index 88db08ab..b4bbf416 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/LibsDisguisesBridge.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/LibsDisguisesBridge.java @@ -5,12 +5,13 @@ import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.LibsDisguises; import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.util.FLog; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; public class LibsDisguisesBridge extends FreedomService { - private LibsDisguises libsDisguisesPlugin = null; + private static LibsDisguises libsDisguisesPlugin = null; @Override public void onStart() @@ -22,22 +23,18 @@ public class LibsDisguisesBridge extends FreedomService { } - public LibsDisguises getLibsDisguisesPlugin() + public static LibsDisguises getLibsDisguisesPlugin() { if (libsDisguisesPlugin == null) { try { - final Plugin libsDisguises = server.getPluginManager().getPlugin("LibsDisguises"); - if (libsDisguises != null) + final Plugin libsDisguises = Bukkit.getServer().getPluginManager().getPlugin("LibsDisguises"); + if (libsDisguises instanceof LibsDisguises) { - if (libsDisguises instanceof LibsDisguises) - { - libsDisguisesPlugin = (LibsDisguises)libsDisguises; - } + libsDisguisesPlugin = (LibsDisguises) libsDisguises; } - } - catch (Exception ex) + } catch (Exception ex) { FLog.severe(ex); } @@ -68,8 +65,7 @@ public class LibsDisguisesBridge extends FreedomService DisguiseAPI.undisguiseToAll(player); } } - } - catch (Exception ex) + } catch (Exception ex) { FLog.severe(ex); } @@ -80,7 +76,7 @@ public class LibsDisguisesBridge extends FreedomService return !BlockedDisguises.disabled; } - public void setDisguisesEnabled(boolean state) + public static void setDisguisesEnabled(boolean state) { final LibsDisguises libsDisguises = getLibsDisguisesPlugin(); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/caging/CageData.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/caging/CageData.java index aab5299c..b584695d 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/caging/CageData.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/caging/CageData.java @@ -124,7 +124,7 @@ public class CageData this.location = location; this.outerMaterial = outer; this.innerMaterial = inner; - input = null; + input = null; // TODO: Remove static variable declaration in a non-static block. buildHistory(location); regenerate(); @@ -141,7 +141,7 @@ public class CageData this.location = location; this.outerMaterial = outer; this.innerMaterial = inner; - CageData.input = input; + CageData.input = input; // TODO: Remove static variable declaration in a non-static block. buildHistory(location); regenerate(); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cleardiscordqueue.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cleardiscordqueue.java index e71cd564..b6d94fa9 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cleardiscordqueue.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cleardiscordqueue.java @@ -13,7 +13,12 @@ public class Command_cleardiscordqueue extends FreedomCommand @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - plugin.dc.clearQueue(); + if (plugin.dc == null) { + msg("Discord is not enabled."); + return true; + } + + plugin.dc.getUtils().clearQueue(); msg("Cleared the discord message queue."); return true; } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clownfish.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clownfish.java index af75bf1e..9eb0e1c3 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clownfish.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clownfish.java @@ -1,7 +1,8 @@ package me.totalfreedom.totalfreedommod.command; import me.totalfreedom.totalfreedommod.rank.Rank; -import me.totalfreedom.totalfreedommod.shop.ShopItem; +import me.totalfreedom.shop.ShopItem; +import net.kyori.adventure.text.Component; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -15,6 +16,11 @@ public class Command_clownfish extends FreedomCommand @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { + if (plugin.sh == null) { + sender.sendMessage(Component.text("The shop is currently disabled.")); + return true; + } + if (plugin.pl.getData(playerSender).hasItem(ShopItem.CLOWN_FISH) && (!plugin.lp.CLOWNFISH_TOGGLE.contains(playerSender.getName()))) { playerSender.getInventory().addItem(plugin.sh.getClownFish()); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_coins.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_coins.java index c9e3e226..00d27e45 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_coins.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_coins.java @@ -19,7 +19,7 @@ public class Command_coins extends FreedomCommand @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - if (!ConfigEntry.SHOP_ENABLED.getBoolean()) + if (plugin.sh == null || !ConfigEntry.SHOP_ENABLED.getBoolean()) { msg("The shop is currently disabled!", ChatColor.RED); return true; @@ -30,13 +30,12 @@ public class Command_coins extends FreedomCommand switch (args.length) { // Mode for seeing how many coins the sender has (doesn't work from console) - case 0: + case 0 -> { if (senderIsConsole) { msg("When used from the console, you must define a target player."); - } - else + } else { PlayerData playerData = getData(playerSender); msg(prefix + ChatColor.GREEN + "You have " + ChatColor.RED + playerData.getCoins() + ChatColor.GREEN @@ -45,16 +44,16 @@ public class Command_coins extends FreedomCommand return true; } + // Mode for seeing how many coins a player has. - case 1: + case 1 -> { Player target = getPlayer(args[0]); if (target == null) { msg(PLAYER_NOT_FOUND); - } - else + } else { PlayerData playerData = getData(target); msg(prefix + ChatColor.GREEN + target.getName() + " has " + ChatColor.RED + playerData.getCoins() + ChatColor.GREEN + " coins."); @@ -62,8 +61,9 @@ public class Command_coins extends FreedomCommand return true; } + // Mode for paying another player coins - case 3: + case 3 -> { if (args[0].equalsIgnoreCase("pay")) { @@ -79,8 +79,7 @@ public class Command_coins extends FreedomCommand { // Prevents players from trying to be cheeky with negative numbers. coinsToTransfer = Math.max(Math.abs(Integer.parseInt(args[2])), 1); - } - catch (NumberFormatException ex) + } catch (NumberFormatException ex) { msg("Invalid number: " + args[2], ChatColor.RED); return true; @@ -96,8 +95,7 @@ public class Command_coins extends FreedomCommand if (target == null) { msg(PLAYER_NOT_FOUND); - } - else + } else { PlayerData playerData = getData(target); playerData.setCoins(playerData.getCoins() + coinsToTransfer); @@ -119,9 +117,9 @@ public class Command_coins extends FreedomCommand return true; } + return true; } - - default: + default -> { return false; } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_commandlist.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_commandlist.java index b7fb63df..0dcf720a 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_commandlist.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_commandlist.java @@ -1,10 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; import me.totalfreedom.totalfreedommod.rank.Rank; import org.apache.commons.lang.StringUtils; import org.bukkit.command.Command; @@ -13,7 +8,13 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; -@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH) +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +@CommandPermissions(rank = Rank.NON_OP, source = SourceType.BOTH) @CommandParameters(description = "Show all commands for all server plugins.", usage = "/", aliases = "cmdlist") public class Command_commandlist extends FreedomCommand { @@ -35,8 +36,7 @@ public class Command_commandlist extends FreedomCommand String command_name = entry.getKey(); commands.add(command_name); } - } - catch (Throwable ignored) + } catch (Throwable ignored) { } } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_consolesay.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_consolesay.java index 0a0fcb38..d948575a 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_consolesay.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_consolesay.java @@ -22,8 +22,13 @@ public class Command_consolesay extends FreedomCommand } String message = StringUtils.join(args, " "); - FUtil.bcastMsg(String.format("§7[CONSOLE] §c%s §8\u00BB §f%s", sender.getName(), StringUtils.join(args, " "))); - plugin.dc.messageChatChannel("[CONSOLE] " + sender.getName() + " \u00BB " + ChatColor.stripColor(message)); + FUtil.bcastMsg(String.format("§7[CONSOLE] §c%s §8» §f%s", sender.getName(), StringUtils.join(args, " "))); + + if (plugin.dc != null) { + plugin.dc.getUtils().messageChatChannel("[CONSOLE] " + sender.getName() + " \u00BB " + ChatColor.stripColor(message), true); + + } + return true; } } \ No newline at end of file diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_doom.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_doom.java index 5cdf6ae3..b97b3f0d 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_doom.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_doom.java @@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod.command; import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.banning.Ban; import me.totalfreedom.totalfreedommod.config.ConfigEntry; -import me.totalfreedom.totalfreedommod.discord.Discord; import me.totalfreedom.totalfreedommod.punishments.Punishment; import me.totalfreedom.totalfreedommod.punishments.PunishmentType; import me.totalfreedom.totalfreedommod.rank.Rank; @@ -52,9 +51,9 @@ public class Command_doom extends FreedomCommand admin.setActive(false); plugin.al.save(admin); plugin.al.updateTables(); - if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean()) + if (plugin.dc != null && plugin.dc.isEnabled() && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean()) { - Discord.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID()); + plugin.dc.getBot().syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID()); } } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fireball.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fireball.java index 8f175373..28aebecd 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fireball.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fireball.java @@ -1,7 +1,7 @@ package me.totalfreedom.totalfreedommod.command; import me.totalfreedom.totalfreedommod.rank.Rank; -import me.totalfreedom.totalfreedommod.shop.ShopItem; +import me.totalfreedom.shop.ShopItem; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -15,6 +15,11 @@ public class Command_fireball extends FreedomCommand @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { + if (plugin.sh == null) { + msg("The shop is currently disabled.", ChatColor.RED); + return true; + } + if (plugin.pl.getData(playerSender).hasItem(ShopItem.FIRE_BALL)) { playerSender.getInventory().addItem(plugin.sh.getFireBall()); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_grapplinghook.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_grapplinghook.java index 1d493310..a13aef3e 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_grapplinghook.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_grapplinghook.java @@ -1,7 +1,7 @@ package me.totalfreedom.totalfreedommod.command; +import me.totalfreedom.shop.ShopItem; import me.totalfreedom.totalfreedommod.rank.Rank; -import me.totalfreedom.totalfreedommod.shop.ShopItem; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -11,16 +11,19 @@ import org.bukkit.entity.Player; @CommandParameters(description = "Obtain a grappling hook", usage = "/") public class Command_grapplinghook extends FreedomCommand { - @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { + if (plugin.sh == null) { + msg("The shop is currently disabled.", ChatColor.RED); + return true; + } + if (plugin.pl.getData(playerSender).hasItem(ShopItem.GRAPPLING_HOOK)) { playerSender.getInventory().addItem(plugin.sh.getGrapplingHook()); msg("You have been given a Grappling Hook", ChatColor.GREEN); - } - else + } else { msg("You do not own a Grappling Hook! Purchase one from the shop.", ChatColor.RED); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_lightningrod.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_lightningrod.java index 02543f38..de109494 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_lightningrod.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_lightningrod.java @@ -1,7 +1,7 @@ package me.totalfreedom.totalfreedommod.command; import me.totalfreedom.totalfreedommod.rank.Rank; -import me.totalfreedom.totalfreedommod.shop.ShopItem; +import me.totalfreedom.shop.ShopItem; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -15,6 +15,11 @@ public class Command_lightningrod extends FreedomCommand @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { + if (plugin.sh == null) { + msg("The shop is currently disabled.", ChatColor.RED); + return true; + } + if (plugin.pl.getData(playerSender).hasItem(ShopItem.LIGHTNING_ROD)) { playerSender.getInventory().addItem(plugin.sh.getLightningRod()); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_linkdiscord.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_linkdiscord.java index 9424e9ef..bf626335 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_linkdiscord.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_linkdiscord.java @@ -1,6 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import me.totalfreedom.totalfreedommod.discord.Discord; import me.totalfreedom.totalfreedommod.player.PlayerData; import me.totalfreedom.totalfreedommod.rank.Rank; import org.bukkit.ChatColor; @@ -16,7 +15,7 @@ public class Command_linkdiscord extends FreedomCommand @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - if (!plugin.dc.enabled) + if (plugin.dc == null || !plugin.dc.isEnabled()) { msg("The Discord integration system is currently disabled.", ChatColor.RED); return true; @@ -45,17 +44,16 @@ public class Command_linkdiscord extends FreedomCommand return true; } - if (Discord.LINK_CODES.containsValue(data)) + if (plugin.dc.getBot().getLinkCodes().containsValue(data)) { - code = Discord.getCode(data); - } - else + code = plugin.dc.getBot().getCode(data); + } else { - code = plugin.dc.generateCode(5); - Discord.LINK_CODES.put(code, data); + code = plugin.dc.getBot().generateCode(5); + plugin.dc.getBot().getLinkCodes().put(code, data); } msg("Your linking code is " + ChatColor.AQUA + code, ChatColor.GREEN); - msg("Take this code and DM the server bot (" + plugin.dc.formatBotTag() + ") the code (do not put anything else in the message, only the code)"); + msg("Take this code and DM the server bot (" + plugin.dc.getBot().formatBotTag() + ") the code (do not put anything else in the message, only the code)"); return true; } } \ No newline at end of file diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_links.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_links.java index e040b419..acbdccd7 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_links.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_links.java @@ -26,15 +26,14 @@ public class Command_links extends FreedomCommand List lines = new ArrayList<>(); - for (String key : values.keySet()) + values.keySet() + .stream() + .filter(key -> values.get(key) instanceof String) + .forEach(key -> { - if (!(values.get(key) instanceof String)) - { - continue; - } - String link = (String)values.get(key); + String link = (String) values.get(key); lines.add(ChatColor.GOLD + "- " + key + ": " + ChatColor.AQUA + link); - } + }); msg("Social Media Links:", ChatColor.AQUA); sender.sendMessage(lines.toArray(new String[0])); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_loginmessage.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_loginmessage.java index 60ca78dc..504977a2 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_loginmessage.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_loginmessage.java @@ -2,7 +2,7 @@ package me.totalfreedom.totalfreedommod.command; import me.totalfreedom.totalfreedommod.player.PlayerData; import me.totalfreedom.totalfreedommod.rank.Rank; -import me.totalfreedom.totalfreedommod.shop.ShopItem; +import me.totalfreedom.shop.ShopItem; import org.apache.commons.lang.StringUtils; import org.bukkit.ChatColor; import org.bukkit.command.Command; @@ -16,9 +16,9 @@ public class Command_loginmessage extends FreedomCommand @Override public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - if (!plugin.pl.getData(playerSender).hasItem(ShopItem.LOGIN_MESSAGES) && !isAdmin(playerSender)) + if (plugin.sh == null || !plugin.pl.getData(playerSender).hasItem(ShopItem.LOGIN_MESSAGES) && !isAdmin(playerSender)) { - msg("You did not purchase the ability to use login messages! Purchase the ability from the shop.", ChatColor.RED); + msg("You did not purchase the ability to use login messages, or the shop is not present! Purchase the ability from the shop.", ChatColor.RED); return true; } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manageshop.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manageshop.java index 1c8056d0..9922728a 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manageshop.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manageshop.java @@ -2,7 +2,7 @@ package me.totalfreedom.totalfreedommod.command; import me.totalfreedom.totalfreedommod.player.PlayerData; import me.totalfreedom.totalfreedommod.rank.Rank; -import me.totalfreedom.totalfreedommod.shop.ShopItem; +import me.totalfreedom.shop.ShopItem; import me.totalfreedom.totalfreedommod.util.FUtil; import org.apache.commons.lang.StringUtils; import org.bukkit.ChatColor; @@ -17,6 +17,10 @@ public class Command_manageshop extends FreedomCommand @Override public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { + if (plugin.sh == null) { + msg("The shop is currently disabled.", ChatColor.RED); + return true; + } if (!FUtil.isExecutive(sender.getName())) { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java index 91745443..ae5a9416 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java @@ -1,12 +1,7 @@ package me.totalfreedom.totalfreedommod.command; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.config.ConfigEntry; -import me.totalfreedom.totalfreedommod.discord.Discord; import me.totalfreedom.totalfreedommod.player.PlayerData; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FUtil; @@ -16,6 +11,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + @CommandPermissions(rank = Rank.ADMIN, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Manage your admin entry.", usage = "/ [-o ] | setscformat | clearscformat> | syncroles>") public class Command_myadmin extends FreedomCommand @@ -73,8 +73,7 @@ public class Command_myadmin extends FreedomCommand if (init == null) { FUtil.adminAction(sender.getName(), "Clearing my IPs", true); - } - else + } else { FUtil.adminAction(sender.getName(), "Clearing " + target.getName() + "'s IPs", true); } @@ -104,8 +103,7 @@ public class Command_myadmin extends FreedomCommand if (init == null) { msg("That IP is not registered to you."); - } - else + } else { msg("That IP does not belong to that player."); } @@ -117,8 +115,7 @@ public class Command_myadmin extends FreedomCommand if (init == null) { msg("You cannot remove your current IP."); - } - else + } else { msg("You cannot remove that admins current IP."); } @@ -163,7 +160,7 @@ public class Command_myadmin extends FreedomCommand case "syncroles": { - if (plugin.dc.enabled) + if (plugin.dc != null && plugin.dc.isEnabled()) { if (!ConfigEntry.DISCORD_ROLE_SYNC.getBoolean()) { @@ -176,12 +173,11 @@ public class Command_myadmin extends FreedomCommand msg("Please run /linkdiscord first!", ChatColor.RED); return true; } - boolean synced = Discord.syncRoles(target, playerData.getDiscordID()); + boolean synced = plugin.dc.getBot().syncRoles(target, playerData.getDiscordID()); if (synced) { msg("Successfully synced your roles.", ChatColor.GREEN); - } - else + } else { msg("Failed to sync your roles, please check the console.", ChatColor.RED); } @@ -214,31 +210,27 @@ public class Command_myadmin extends FreedomCommand options.addAll(singleArguments); options.addAll(doubleArguments); return options; - } - else if (args.length == 2) + } else if (args.length == 2) { if (args[0].equalsIgnoreCase("-o")) { return FUtil.getPlayerList(); - } - else + } else { if (doubleArguments.contains(args[0]) && args[0].equalsIgnoreCase("clearip")) { List ips = plugin.al.getAdmin(sender).getIps(); - ips.remove(FUtil.getIp((Player)sender)); + ips.remove(FUtil.getIp((Player) sender)); return ips; } } - } - else if (args.length == 3 && args[0].equalsIgnoreCase("-o")) + } else if (args.length == 3 && args[0].equalsIgnoreCase("-o")) { List options = new ArrayList<>(); options.addAll(singleArguments); options.addAll(doubleArguments); return options; - } - else if (args.length == 4 && args[0].equalsIgnoreCase("-o") && args[2].equalsIgnoreCase("clearip")) + } else if (args.length == 4 && args[0].equalsIgnoreCase("-o") && args[2].equalsIgnoreCase("clearip")) { Admin admin = plugin.al.getEntryByName(args[1]); if (admin != null) diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_permissions.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_permissions.java index 0adc14f3..22a77a52 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_permissions.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_permissions.java @@ -8,7 +8,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.permissions.PermissionAttachmentInfo; -@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.NON_OP, source = SourceType.BOTH) @CommandParameters(description = "Check your permissions", usage = "/ [prefix | reload]") public class Command_permissions extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_plotworld.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_plotworld.java index e764e94f..dce1af3c 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_plotworld.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_plotworld.java @@ -7,7 +7,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.NON_OP, source = SourceType.ONLY_IN_GAME) +@CommandPermissions(rank = Rank.NON_OP, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Go to the PlotWorld.", usage = "/", aliases = "pw") public class Command_plotworld extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_plugincontrol.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_plugincontrol.java index 9e262500..e92a29b0 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_plugincontrol.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_plugincontrol.java @@ -10,7 +10,7 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Enable, disable, or reload a specified plugin, as well as list all plugins on the server.", usage = "/ < > | list>", aliases = "plc") public class Command_plugincontrol extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java index d8db4b9b..1a34cf83 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java @@ -13,7 +13,7 @@ import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -@CommandPermissions(level = Rank.OP, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH) @CommandParameters( description = "Manipulate your potion effects. Duration is measured in server ticks (~20 ticks per second).", usage = "/ [target name]>", @@ -44,6 +44,7 @@ public class Command_potion extends FreedomCommand server.getOnlinePlayers().forEach(target -> target.getActivePotionEffects().forEach(effect -> target.removePotionEffect(effect.getType()))); } + return true; } case 2: diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potionspy.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potionspy.java index 277b6ac3..ca9ab20f 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potionspy.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potionspy.java @@ -15,7 +15,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.entity.ThrownPotion; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_IN_GAME) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Allows admins to see potions that are thrown.", usage = "/ | history [player] ", aliases = "potspy") public class Command_potionspy extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_purgeall.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_purgeall.java index efee00ac..9db65663 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_purgeall.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_purgeall.java @@ -11,7 +11,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Purge current mutes, command blocks, orbits, freezes, potion effects, cages, and entities.", usage = "/") public class Command_purgeall extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rank.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rank.java index d84846f3..785c57e6 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rank.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rank.java @@ -7,7 +7,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.NON_OP, source = SourceType.BOTH) @CommandParameters(description = "Show the rank of the sender or a specified user.", usage = "/ [player]") public class Command_rank extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rawsay.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rawsay.java index 0610c030..3a3df6c8 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rawsay.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rawsay.java @@ -7,7 +7,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.SENIOR_ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Broadcasts the given message. Supports colors.", usage = "/ ") public class Command_rawsay extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_reactionbar.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_reactionbar.java index 6aa9ab96..70190306 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_reactionbar.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_reactionbar.java @@ -2,11 +2,12 @@ package me.totalfreedom.totalfreedommod.command; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FUtil; +import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.SENIOR_ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Forcefully start a reaction", usage = "/") public class Command_reactionbar extends FreedomCommand { @@ -14,6 +15,11 @@ public class Command_reactionbar extends FreedomCommand @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { + if (plugin.sh == null) { + msg("The shop is currently disabled", ChatColor.RED); + return true; + } + if (!FUtil.isDeveloper(playerSender)) { return noPerms(); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_report.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_report.java index 554c1f6d..83182885 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_report.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_report.java @@ -9,7 +9,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME, blockHostConsole = true) +@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME, blockHostConsole = true) @CommandParameters(description = "Report a player for all admins to see.", usage = "/ ") public class Command_report extends FreedomCommand { @@ -54,9 +54,9 @@ public class Command_report extends FreedomCommand boolean logged = false; - if (plugin.dc.enabled) + if (plugin.dc != null && plugin.dc.isEnabled()) { - logged = (player == null) ? plugin.dc.sendReportOffline(playerSender, offlinePlayer, report) : plugin.dc.sendReport(playerSender, player, report); + logged = (player == null) ? plugin.dc.getUtils().sendReportOffline(playerSender, offlinePlayer, report) : plugin.dc.getUtils().sendReport(playerSender, player, report); } msg(ChatColor.GREEN + "Thank you, your report has been successfully logged." diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java index 25623bd0..73768f92 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java @@ -13,7 +13,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; -@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Ride on the top of the specified player.", usage = "/ >") public class Command_ride extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rideablepearl.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rideablepearl.java index b4e02d6f..15777970 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rideablepearl.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rideablepearl.java @@ -1,13 +1,13 @@ package me.totalfreedom.totalfreedommod.command; import me.totalfreedom.totalfreedommod.rank.Rank; -import me.totalfreedom.totalfreedommod.shop.ShopItem; +import me.totalfreedom.shop.ShopItem; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Obtain a rideable ender pearl", usage = "/") public class Command_rideablepearl extends FreedomCommand { @@ -15,6 +15,12 @@ public class Command_rideablepearl extends FreedomCommand @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { + if (plugin.sh == null) + { + msg("The shop is currently disabled.", ChatColor.RED); + return true; + } + if (plugin.pl.getData(playerSender).hasItem(ShopItem.RIDEABLE_PEARL)) { playerSender.getInventory().addItem(plugin.sh.getRideablePearl()); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ro.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ro.java index e51dc061..a5dfe67b 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ro.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ro.java @@ -17,7 +17,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Remove all blocks of a certain type in the radius of certain players.", usage = "/ [radius (default=50)] [player]") public class Command_ro extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rock.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rock.java index fed36ec4..d98253d9 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rock.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rock.java @@ -10,7 +10,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "You have thrown a rock, but you have also summoned a meteor!", usage = "/") public class Command_rock extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java index 2fab3cf2..1ba5a0f5 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java @@ -7,7 +7,6 @@ import java.util.Date; import java.util.List; import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.config.ConfigEntry; -import me.totalfreedom.totalfreedommod.discord.Discord; import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FUtil; @@ -17,7 +16,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH) @CommandParameters(description = "List, add, remove, or set the rank of admins, clean or reload the admin list, or view admin information.", usage = "/ | >", aliases = "slconfig") public class Command_saconfig extends FreedomCommand { @@ -107,9 +106,9 @@ public class Command_saconfig extends FreedomCommand plugin.rm.updateDisplay(player); } - if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean()) + if (plugin.dc != null && plugin.dc.isEnabled() && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean()) { - Discord.syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID()); + plugin.dc.getBot().syncRoles(admin, plugin.pl.getData(admin.getName()).getDiscordID()); } msg("Set " + admin.getName() + "'s rank to " + rank.getName()); @@ -203,9 +202,9 @@ public class Command_saconfig extends FreedomCommand plugin.al.updateTables(); plugin.rm.updateDisplay(player); - if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean()) + if (plugin.dc != null && plugin.dc.isEnabled() && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean()) { - Discord.syncRoles(admin, plugin.pl.getData(player).getDiscordID()); + plugin.dc.getBot().syncRoles(admin, plugin.pl.getData(player).getDiscordID()); } } @@ -257,9 +256,9 @@ public class Command_saconfig extends FreedomCommand plugin.rm.updateDisplay(player); } - if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean()) + if (plugin.dc != null && plugin.dc.isEnabled() && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean()) { - Discord.syncRoles(admin, plugin.pl.getData(adminName).getDiscordID()); + plugin.dc.getBot().syncRoles(admin, plugin.pl.getData(adminName).getDiscordID()); } return true; diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_say.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_say.java index a79af9ae..0bef2569 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_say.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_say.java @@ -8,7 +8,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Broadcasts the given message as the server, includes sender name.", usage = "/ ") public class Command_say extends FreedomCommand { @@ -41,7 +41,11 @@ public class Command_say extends FreedomCommand } FUtil.bcastMsg(String.format("[Server:%s] %s", sender.getName(), message), ChatColor.LIGHT_PURPLE); - plugin.dc.messageChatChannel(String.format("[Server:%s] \u00BB %s", sender.getName(), message)); + + if (plugin.dc != null) { + plugin.dc.getUtils().messageChatChannel(String.format("[Server:%s] \u00BB %s", sender.getName(), message), true); + } + return true; } } \ No newline at end of file diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_scare.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_scare.java index 15da84ec..46a627d7 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_scare.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_scare.java @@ -11,7 +11,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.SENIOR_ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Sends a guardian particle effect with an enderman scream to the specified player.", usage = "/ ") public class Command_scare extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_seed.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_seed.java index c1381fa9..d1fa2052 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_seed.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_seed.java @@ -14,7 +14,7 @@ import org.bukkit.generator.WorldInfo; import java.util.List; -@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.NON_OP, source = SourceType.BOTH) @CommandParameters(description = "Get the seed of the world you are currently in.", usage = "/seed [world]") public class Command_seed extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_serverstats.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_serverstats.java index 6f3a3f35..5b4f2d88 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_serverstats.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_serverstats.java @@ -7,7 +7,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH) @CommandParameters(description = "Check the status of the server, including opped players, admins, etc.", usage = "/", aliases = "ss") public class Command_serverstats extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setcompass.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setcompass.java index aeafe711..c5bb81e7 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setcompass.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setcompass.java @@ -7,7 +7,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Set your compass to the specified position.", usage = "/ ") public class Command_setcompass extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java index 2df3c253..d3480d42 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java @@ -13,7 +13,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.NON_OP, source = SourceType.BOTH) @CommandParameters(description = "Set the on/off state of the lever at position x, y, z in world 'worldname'.", usage = "/ ") public class Command_setlever extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlimit.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlimit.java index bfe9511e..3a341591 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlimit.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlimit.java @@ -7,7 +7,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Sets everyone's WorldEdit block modification limit to the default limit or to a custom limit.", usage = "/ [limit]", aliases = "setl,swl") public class Command_setlimit extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setplayerlimit.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setplayerlimit.java index fb9f640e..cd17f66e 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setplayerlimit.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setplayerlimit.java @@ -8,7 +8,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Sets a specific player's WorldEdit block modification limit to the default limit or to a custom limit.", usage = "/ [limit]", aliases = "setpl,spl") public class Command_setplayerlimit extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setspawnworld.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setspawnworld.java index 49c2dee8..01375904 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setspawnworld.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setspawnworld.java @@ -7,7 +7,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_IN_GAME) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Set the spawn point of the world you are in.", usage = "/") public class Command_setspawnworld extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_settotalvotes.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_settotalvotes.java index 3c6de7be..440c591e 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_settotalvotes.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_settotalvotes.java @@ -8,7 +8,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE) +@CommandPermissions(rank = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE) @CommandParameters(description = "Set a player's total votes", usage = "/ ") public class Command_settotalvotes extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_shop.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_shop.java index 89c6381a..c3e4c724 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_shop.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_shop.java @@ -7,7 +7,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Open the shop GUI", usage = "/", aliases = "sh") public class Command_shop extends FreedomCommand { @@ -15,7 +15,7 @@ public class Command_shop extends FreedomCommand @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - if (!ConfigEntry.SHOP_ENABLED.getBoolean()) + if (plugin.sh == null || !ConfigEntry.SHOP_ENABLED.getBoolean()) { msg("The shop is currently disabled!", ChatColor.RED); return true; diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java index 92b73d0d..267d60ab 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java @@ -14,7 +14,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Someone being a little bitch? Smite them down...", usage = "/ [reason] [-ci | -q]") public class Command_smite extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spawnmob.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spawnmob.java index ff6b372b..b3f0f809 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spawnmob.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spawnmob.java @@ -14,7 +14,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Spawns the specified entity.", usage = "/ [amount]", aliases = "spawnentity") public class Command_spawnmob extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectate.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectate.java index c3d8edbe..715a0ff5 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectate.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectate.java @@ -8,7 +8,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_IN_GAME) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Quickly spectate someone.", usage = "/ ", aliases = "spec") public class Command_spectate extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectator.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectator.java index 808beb93..7a64f456 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectator.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectator.java @@ -6,7 +6,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Quickly change your own gamemode to spectator, or define someone's username to change theirs.", usage = "/ <[partialname]>", aliases = "gmsp") public class Command_spectator extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stackingpotato.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stackingpotato.java index 7a1514f5..e4a13ef6 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stackingpotato.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stackingpotato.java @@ -1,13 +1,13 @@ package me.totalfreedom.totalfreedommod.command; import me.totalfreedom.totalfreedommod.rank.Rank; -import me.totalfreedom.totalfreedommod.shop.ShopItem; +import me.totalfreedom.shop.ShopItem; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Obtain a stacking potato", usage = "/") public class Command_stackingpotato extends FreedomCommand { @@ -15,6 +15,11 @@ public class Command_stackingpotato extends FreedomCommand @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { + if (plugin.sh == null) { + msg("The shop is currently disabled.", ChatColor.RED); + return true; + } + if (plugin.pl.getData(playerSender).hasItem(ShopItem.STACKING_POTATO)) { playerSender.getInventory().addItem(plugin.sh.getStackingPotato()); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_status.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_status.java index 99de6a3d..4d8187d2 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_status.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_status.java @@ -7,7 +7,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.NON_OP, source = SourceType.BOTH) @CommandParameters(description = "Shows Minecraft server info, such as authentication status.", usage = "/") public class Command_status extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stop.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stop.java index c160c59f..19d6ed48 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stop.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stop.java @@ -11,7 +11,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Kicks everyone and stops the server.", usage = "/ [reason]") public class Command_stop extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stopsound.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stopsound.java index 1e0acb92..3c38b845 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stopsound.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_stopsound.java @@ -10,7 +10,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Stops all sounds or a specified sound.", usage = "/ [sound]") public class Command_stopsound extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_survival.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_survival.java index 2a600dfe..b8f963c1 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_survival.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_survival.java @@ -7,7 +7,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH) @CommandParameters(description = "Quickly change your own gamemode to survival, or define someone's username to change theirs.", usage = "/ <[partialname] | -a>", aliases = "gms") public class Command_survival extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java index 6c151039..461f6a16 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java @@ -15,7 +15,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH) @CommandParameters(description = "Allows you to set your own prefix.", usage = "/ [-s[ave]] | list | gradient | off | clear | clearall>") public class Command_tag extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagnyan.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagnyan.java index f2618fd8..3be325e6 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagnyan.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagnyan.java @@ -10,7 +10,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Give yourself a prefix with random colors", usage = "/ ", aliases = "tn") public class Command_tagnyan extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagrainbow.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagrainbow.java index 3795a8c6..98b86bc6 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagrainbow.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tagrainbow.java @@ -9,7 +9,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Give yourself a prefix with rainbow colors.", usage = "/ ") public class Command_tagrainbow extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tempban.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tempban.java index 3789f40b..55a8ffac 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tempban.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tempban.java @@ -20,7 +20,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Temporarily ban someone.", usage = "/ [-q] [duration] [reason]", aliases = "tban,noob") public class Command_tempban extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java index 2639b9d5..e10a9430 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggle.java @@ -12,7 +12,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Toggles TotalFreedomMod settings", usage = "/ [option] [value] [value]") public class Command_toggle extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglechat.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglechat.java index 30a3fb28..c2f19d3f 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglechat.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglechat.java @@ -7,7 +7,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Toggle online players' ability to chat.", usage = "/", aliases = "tc") public class Command_togglechat extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggleclownfish.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggleclownfish.java index a4f05a39..74f5a278 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggleclownfish.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_toggleclownfish.java @@ -5,7 +5,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Toggle whether or not a player has the ability to use clownfish", usage = "/ ", aliases = "togglecf") public class Command_toggleclownfish extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglediscord.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglediscord.java index 69397339..a6ec0ff1 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglediscord.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglediscord.java @@ -6,7 +6,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Toggle the display of Discord messages in-game.", usage = "/", aliases = "tdiscord,tdisc") public class Command_togglediscord extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglepickup.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglepickup.java index df9c8294..45e0abb5 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglepickup.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_togglepickup.java @@ -6,7 +6,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Toggle item pickup.", usage = "/") public class Command_togglepickup extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tossmob.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tossmob.java index 586691ac..a4dd5eb9 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tossmob.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tossmob.java @@ -14,7 +14,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Throw a mob in the direction you are facing when you right click with a bone.", usage = "/ ") public class Command_tossmob extends FreedomCommand diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_totalfreedommod.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_totalfreedommod.java index aad66572..7094b8eb 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_totalfreedommod.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_totalfreedommod.java @@ -12,7 +12,7 @@ import org.bukkit.entity.Player; /* * See https://github.com/TotalFreedom/License - This file may not be edited or removed. */ -@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.NON_OP, source = SourceType.BOTH) @CommandParameters(description = "Shows information about TotalFreedomMod or reloads it", usage = "/ [reload]", aliases = "tfm") public class Command_totalfreedommod extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tprandom.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tprandom.java index ab4ef62e..858dbb57 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tprandom.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tprandom.java @@ -9,7 +9,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Go to a random location in the current world you are in", usage = "/", aliases = "tpr,rtp") public class Command_tprandom extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_trail.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_trail.java index 16d82e97..3b243065 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_trail.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_trail.java @@ -1,13 +1,13 @@ package me.totalfreedom.totalfreedommod.command; import me.totalfreedom.totalfreedommod.rank.Rank; -import me.totalfreedom.totalfreedommod.shop.ShopItem; +import me.totalfreedom.shop.ShopItem; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Trails rainbow wool behind you as you walk/fly.", usage = "/") public class Command_trail extends FreedomCommand { @@ -15,6 +15,11 @@ public class Command_trail extends FreedomCommand @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { + if (plugin.sh == null) { + msg("Shop is not enabled.", ChatColor.RED); + return true; + } + if (!plugin.pl.getData(playerSender).hasItem(ShopItem.RAINBOW_TRAIL)) { msg("You didn't purchase the ability to have a " + ShopItem.RAINBOW_TRAIL.getName() + "! Purchase it from the shop.", ChatColor.RED); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unban.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unban.java index daf3b32c..1b77cbbe 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unban.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unban.java @@ -8,7 +8,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Unbans the specified player.", usage = "/ [-r]") public class Command_unban extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unbanip.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unbanip.java index 03cbaef7..1824a10f 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unbanip.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unbanip.java @@ -8,7 +8,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Unbans the specified ip.", usage = "/ [-q]") public class Command_unbanip extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unbanname.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unbanname.java index cf925674..83a23470 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unbanname.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unbanname.java @@ -8,7 +8,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Unbans the specified name.", usage = "/ [-q]") public class Command_unbanname extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unblockcmd.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unblockcmd.java index d6f551bb..2d8c5076 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unblockcmd.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unblockcmd.java @@ -8,7 +8,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Unblocks commands for a player.", usage = "/ ", aliases = "unblockcommand,unblockcommands,ubcmds,unblockcmds,ubc") public class Command_unblockcmd extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_uncage.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_uncage.java index ccfd1d1d..f0241de9 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_uncage.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_uncage.java @@ -8,7 +8,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Uncage a player", usage = "/ ") public class Command_uncage extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_undisguiseall.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_undisguiseall.java index ba510c73..83410f3a 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_undisguiseall.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_undisguiseall.java @@ -6,7 +6,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Undisguise all online players on the server", usage = "/ [-a]", aliases = "uall") public class Command_undisguiseall extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unlinkdiscord.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unlinkdiscord.java index e34df0c9..d858e50f 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unlinkdiscord.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unlinkdiscord.java @@ -7,7 +7,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Unlink your Discord account from your Minecraft account", usage = "/ [player]") public class Command_unlinkdiscord extends FreedomCommand { @@ -15,7 +15,7 @@ public class Command_unlinkdiscord extends FreedomCommand @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - if (!plugin.dc.enabled) + if (plugin.dc == null || !plugin.dc.isEnabled()) { msg("The Discord integration system is currently disabled.", ChatColor.RED); return true; diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unmute.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unmute.java index 725f6146..a2c0b505 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unmute.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unmute.java @@ -9,7 +9,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Unmutes a player", usage = "/ [-q] ") public class Command_unmute extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java index 12c3b2c9..532a872d 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java @@ -15,7 +15,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_IN_GAME) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Vanish/unvanish yourself.", usage = "/ [-s[ilent]]", aliases = "v") public class Command_vanish extends FreedomCommand { @@ -46,7 +46,10 @@ public class Command_vanish extends FreedomCommand FUtil.bcastMsg(plugin.rm.craftLoginMessage(playerSender, null)); server.broadcast(Component.translatable("multiplayer.player.joined", Component.text(playerSender.getName())) .color(NamedTextColor.YELLOW)); - plugin.dc.messageChatChannel("**" + playerSender.getName() + " joined the server" + "**", true); + + if (plugin.dc != null) { + plugin.dc.getUtils().messageChatChannel("**" + playerSender.getName() + " joined the server" + "**", true); + } } PlayerData playerData = plugin.pl.getData(playerSender); @@ -97,7 +100,9 @@ public class Command_vanish extends FreedomCommand msg("You have vanished.", ChatColor.GOLD); server.broadcast(Component.translatable("multiplayer.player.left", Component.text(playerSender.getName())) .color(NamedTextColor.YELLOW)); - plugin.dc.messageChatChannel("**" + playerSender.getName() + " left the server" + "**", true); + if (plugin.dc != null) { + plugin.dc.getUtils().messageChatChannel("**" + playerSender.getName() + " left the server" + "**", true); + } } FLog.info(playerSender.getName() + " is now vanished."); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vote.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vote.java index 3f1df406..6b838671 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vote.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vote.java @@ -10,7 +10,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH) @CommandParameters(description = "Information on how to vote", usage = "/") public class Command_vote extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_warn.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_warn.java index 17be800f..bca2124a 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_warn.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_warn.java @@ -11,7 +11,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH) @CommandParameters(description = "Warns the specified player.", usage = "/ [-q] ") public class Command_warn extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whitelist.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whitelist.java index f8398db4..c07824d9 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whitelist.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whitelist.java @@ -10,7 +10,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH) @CommandParameters(description = "Manage the whitelist.", usage = "/ | remove | addall | purge>") public class Command_whitelist extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whohas.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whohas.java index 4ec832f3..22dc8f89 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whohas.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whohas.java @@ -12,7 +12,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.OP, source = SourceType.BOTH) +@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH) @CommandParameters(description = "See who has an item and optionally clear the specified item.", usage = "/ [clear]", aliases = "wh") public class Command_whohas extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wildcard.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wildcard.java index a4d74e4c..e4ee30e5 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wildcard.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wildcard.java @@ -12,7 +12,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH, blockHostConsole = true) +@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH, blockHostConsole = true) @CommandParameters(description = "Run any command on all users, username placeholder = ?.", usage = "/ [fluff] ? [fluff] ?") public class Command_wildcard extends FreedomCommand { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java index 08ae5252..41b6290c 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java @@ -1,35 +1,14 @@ package me.totalfreedom.totalfreedommod.fun; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.SplittableRandom; -import java.util.UUID; +import me.totalfreedom.shop.ShopItem; import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.player.PlayerData; -import me.totalfreedom.totalfreedommod.shop.ShopItem; import me.totalfreedom.totalfreedommod.util.FUtil; -import org.bukkit.ChatColor; -import org.bukkit.Color; -import org.bukkit.FireworkEffect; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.SoundCategory; +import org.bukkit.*; import org.bukkit.block.Block; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.EnderPearl; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Fireball; -import org.bukkit.entity.Firework; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; +import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.Action; @@ -45,6 +24,8 @@ import org.bukkit.inventory.meta.FireworkMeta; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.util.Vector; +import java.util.*; + public class ItemFun extends FreedomService { @@ -61,8 +42,7 @@ public class ItemFun extends FreedomService List featureList = new ArrayList<>(); featureList.add(item.getDataName()); cooldownTracker.put(player.getName(), featureList); - } - else + } else { cooldownTracker.get(player.getName()).add(item.getDataName()); } @@ -73,7 +53,7 @@ public class ItemFun extends FreedomService { cooldownTracker.get(player.getName()).remove(item.getDataName()); } - }.runTaskLater(plugin, seconds * 20); + }.runTaskLater(plugin, seconds * 20L); } public boolean onCooldown(Player player, ShopItem item) @@ -98,6 +78,7 @@ public class ItemFun extends FreedomService @EventHandler public void onPlayerEntityInteract(PlayerInteractEntityEvent event) { + if (plugin.sh == null) return; // This is to prevent an NPE if the Shoppe isn't present. Player player = event.getPlayer(); Entity entity = event.getRightClicked(); @@ -126,7 +107,7 @@ public class ItemFun extends FreedomService Location playerLoc = player.getLocation(); Vector direction = playerLoc.getDirection().normalize(); - LivingEntity livingEntity = (LivingEntity)event.getRightClicked(); + LivingEntity livingEntity = (LivingEntity) event.getRightClicked(); EntityType entityType = livingEntity.getType(); if (entityType != fPlayer.mobThrowerCreature()) { @@ -141,6 +122,8 @@ public class ItemFun extends FreedomService @EventHandler(priority = EventPriority.MONITOR) public void onEntityDamage(EntityDamageByEntityEvent event) { + if (plugin.sh == null) return; // This is to prevent an NPE if the Shoppe isn't present. + Entity entity = event.getEntity(); if (entity instanceof Player || !(event.getDamager() instanceof Player)) @@ -148,7 +131,7 @@ public class ItemFun extends FreedomService return; } - Player player = (Player)event.getDamager(); + Player player = (Player) event.getDamager(); if (!player.getInventory().getItemInMainHand().getType().equals(Material.POTATO)) { @@ -167,6 +150,8 @@ public class ItemFun extends FreedomService @EventHandler public void onPlayerInteractEvent(PlayerInteractEvent event) { + if (plugin.sh == null) return; // This is to prevent an NPE if the Shoppe isn't present. + if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) { @@ -178,7 +163,7 @@ public class ItemFun extends FreedomService switch (event.getMaterial()) { - case GUNPOWDER: + case GUNPOWDER -> { if (!fPlayer.isMP44Armed()) { @@ -190,15 +175,12 @@ public class ItemFun extends FreedomService if (fPlayer.toggleMP44Firing()) { fPlayer.startArrowShooter(plugin); - } - else + } else { fPlayer.stopArrowShooter(); } - break; } - - case BLAZE_ROD: + case BLAZE_ROD -> { if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.LIGHTNING_ROD, player.getInventory(), plugin.sh.getLightningRod())) { @@ -219,10 +201,8 @@ public class ItemFun extends FreedomService player.getWorld().strikeLightning(targetBlock.getLocation()); } cooldown(player, ShopItem.LIGHTNING_ROD, 10); - break; } - - case FIRE_CHARGE: + case FIRE_CHARGE -> { if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.FIRE_BALL, player.getInventory(), plugin.sh.getFireBall())) { @@ -240,14 +220,12 @@ public class ItemFun extends FreedomService FIRE_BALL_UUIDS.add(fireball.getUniqueId()); fireball.setVelocity(player.getLocation().getDirection().multiply(2)); cooldown(player, ShopItem.FIRE_BALL, 5); - break; } - - case TROPICAL_FISH: + case TROPICAL_FISH -> { final int RADIUS_HIT = 5; final int STRENGTH = 4; - + if (plugin.lp.CLOWNFISH_TOGGLE.contains(player.getName())) { player.sendMessage(ChatColor.GRAY + "An admin has disabled your ability to use clownfish."); @@ -284,8 +262,7 @@ public class ItemFun extends FreedomService target.setVelocity(targetPosVec.subtract(playerLocVec).normalize().multiply(STRENGTH)); didHit = true; } - } - catch (IllegalArgumentException ignored) + } catch (IllegalArgumentException ignored) { } } @@ -302,12 +279,10 @@ public class ItemFun extends FreedomService } cooldown(player, ShopItem.CLOWN_FISH, 30); } - break; } - default: + default -> { // Do nothing - break; } } } @@ -315,10 +290,12 @@ public class ItemFun extends FreedomService @EventHandler public void onProjectileLaunch(ProjectileLaunchEvent event) { + if (plugin.sh == null) return; + Projectile entity = event.getEntity(); if (entity instanceof EnderPearl && entity.getShooter() instanceof Player) { - Player player = (Player)entity.getShooter(); + Player player = (Player) entity.getShooter(); if (plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.RIDEABLE_PEARL, player.getInventory(), plugin.sh.getRideablePearl())) { entity.addPassenger(player); @@ -333,7 +310,7 @@ public class ItemFun extends FreedomService Arrow arrow = null; if (entity instanceof Arrow) { - arrow = (Arrow)entity; + arrow = (Arrow) entity; } //Redundant Player cast is required to avoid suspicious method calls. if (arrow != null @@ -349,7 +326,7 @@ public class ItemFun extends FreedomService if (FIRE_BALL_UUIDS.contains(entity.getUniqueId())) { FIRE_BALL_UUIDS.remove(entity.getUniqueId()); - Firework firework = (Firework)entity.getWorld().spawnEntity(entity.getLocation(), EntityType.FIREWORK); + Firework firework = (Firework) entity.getWorld().spawnEntity(entity.getLocation(), EntityType.FIREWORK); firework.setSilent(true); FireworkMeta meta = firework.getFireworkMeta(); FireworkEffect explosionEffect = FireworkEffect.builder().withColor(Color.ORANGE).withFade(Color.YELLOW).with(FireworkEffect.Type.BALL_LARGE).trail(true).build(); @@ -376,6 +353,8 @@ public class ItemFun extends FreedomService @EventHandler public void onFish(PlayerFishEvent event) { + if (plugin.sh == null) return; + Player player = event.getPlayer(); PlayerData data = plugin.pl.getData(player); PlayerInventory inv = event.getPlayer().getInventory(); @@ -404,40 +383,32 @@ public class ItemFun extends FreedomService if (orientation >= 0.0 && orientation < 22.5) { zVel = speed; - } - else if (orientation >= 22.5 && orientation < 67.5) + } else if (orientation >= 22.5 && orientation < 67.5) { xVel = -(speed / 2.0); zVel = speed / 2.0; - } - else if (orientation >= 67.5 && orientation < 112.5) + } else if (orientation >= 67.5 && orientation < 112.5) { xVel = -speed; - } - else if (orientation >= 112.5 && orientation < 157.5) + } else if (orientation >= 112.5 && orientation < 157.5) { xVel = -(speed / 2.0); zVel = -(speed / 2.0); - } - else if (orientation >= 157.5 && orientation < 202.5) + } else if (orientation >= 157.5 && orientation < 202.5) { zVel = -speed; - } - else if (orientation >= 202.5 && orientation < 247.5) + } else if (orientation >= 202.5 && orientation < 247.5) { xVel = speed / 2.0; zVel = -(speed / 2.0); - } - else if (orientation >= 247.5 && orientation < 292.5) + } else if (orientation >= 247.5 && orientation < 292.5) { xVel = speed; - } - else if (orientation >= 292.5 && orientation < 337.5) + } else if (orientation >= 292.5 && orientation < 337.5) { xVel = speed / 2.0; zVel = speed / 2.0; - } - else if (orientation >= 337.5 && orientation < 360.0) + } else if (orientation >= 337.5 && orientation < 360.0) { zVel = speed; } @@ -447,8 +418,7 @@ public class ItemFun extends FreedomService if (event.getState() == PlayerFishEvent.State.FISHING) { orientationTracker.put(player, player.getLocation().getYaw()); - } - else + } else { orientationTracker.remove(player); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/Trailer.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/Trailer.java index e603b242..7ccf8692 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/Trailer.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/Trailer.java @@ -7,7 +7,7 @@ import java.util.SplittableRandom; import java.util.UUID; import me.totalfreedom.totalfreedommod.FreedomService; -import me.totalfreedom.totalfreedommod.shop.ShopItem; +import me.totalfreedom.shop.ShopItem; import me.totalfreedom.totalfreedommod.util.Groups; import org.bukkit.Location; import org.bukkit.Material; @@ -36,6 +36,8 @@ public class Trailer extends FreedomService @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerMove(PlayerMoveEvent event) { + if (plugin.sh == null) return; // Shop is disabled + /* Doesn't continue any further if... * - The trail list is empty * - The player doesn't have their trail enabled in the first place @@ -63,6 +65,7 @@ public class Trailer extends FreedomService return; } + // TODO: Make this particles instead of blocks! fromBlock.setType(Groups.WOOL_COLORS.get(random.nextInt(Groups.WOOL_COLORS.size()))); BlockData data = fromBlock.getBlockData(); Material material = Material.getMaterial(String.valueOf(fromBlock.getType())); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java index bd15bf1e..4640d32c 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java @@ -5,7 +5,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.*; -import me.totalfreedom.totalfreedommod.shop.ShopItem; +import me.totalfreedom.shop.ShopItem; import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FUtil; import org.apache.commons.lang.StringUtils; diff --git a/discord/src/main/java/me/totalfreedom/discord/Bot.java b/discord/src/main/java/me/totalfreedom/discord/Bot.java index 2870566b..078e4d7f 100644 --- a/discord/src/main/java/me/totalfreedom/discord/Bot.java +++ b/discord/src/main/java/me/totalfreedom/discord/Bot.java @@ -5,7 +5,8 @@ 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.Member; +import discord4j.core.object.entity.Role; import discord4j.core.object.entity.channel.TextChannel; import me.totalfreedom.discord.command.HelpCommand; import me.totalfreedom.discord.command.ListCommand; @@ -13,19 +14,19 @@ 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.admin.Admin; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.player.PlayerData; +import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FLog; import net.dv8tion.jda.internal.utils.concurrent.CountingThreadFactory; +import org.apache.commons.lang.RandomStringUtils; 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 @@ -45,6 +46,10 @@ public class Bot .login() .block(); + this.tfm = new TFM_Bridge(this); + } + + public void initialize() { if (client == null) throw new IllegalStateException(); final CommandHandler handler = new CommandHandler(client.getRestClient()); @@ -71,12 +76,125 @@ public class Bot .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); } + public String getCode(PlayerData playerData) { + for (String code : LINK_CODES.keySet()) + { + if (LINK_CODES.get(code).equals(playerData)) + { + return code; + } + } + return ""; + } + + public String generateCode(int size) + { + return RandomStringUtils.randomNumeric(size); + } + + public String formatBotTag() { + return client.getSelf() + .blockOptional() + .orElseThrow() + .getUsername() + "#" + client.getSelf() + .blockOptional() + .orElseThrow() + .getDiscriminator(); + } + + public boolean syncRoles(Admin admin, String discordID) + { + if (discordID == null) + { + return false; + } + + Guild server = client.getGuildById(SnowflakeEntry.serverID) + .blockOptional() + .orElseThrow(); + + Member member = server.getMemberById(Snowflake.of(discordID)) + .blockOptional() + .orElseThrow(); + + Role adminRole = server.getRoleById(SnowflakeEntry.adminRoleID) + .blockOptional() + .orElseThrow(); + + Role senioradminRole = server.getRoleById(SnowflakeEntry.seniorRoleID) + .blockOptional() + .orElseThrow(); + + if (!admin.isActive()) + { + syncRolesActivityCheck(member, adminRole, senioradminRole); + return true; + } + + if (admin.getRank().equals(Rank.ADMIN)) + { + syncRolesAdminAssignment(member, adminRole, senioradminRole); + return true; + } + else if (admin.getRank().equals(Rank.SENIOR_ADMIN)) + { + syncRolesSeniorAssignment(member, adminRole, senioradminRole); + return true; + } + return false; + } + + private void syncRolesAdminAssignment(Member member, Role adminRole, Role senioradminRole) { + member.getRoles().doFirst(() -> { + if (!member.getRoles().collectList().blockOptional().orElseThrow().contains(adminRole)) + { + member.addRole(adminRole.getId()).block(); + } + }).doOnEach(r -> { + Role role = r.get(); + if (role == null) return; + + if (role.equals(senioradminRole)) + { + member.removeRole(role.getId()).block(); + } + }).subscribe(); + } + + private void syncRolesActivityCheck(Member member, Role adminRole, Role senioradminRole) { + member.getRoles().doOnEach(r -> { + Role role = r.get(); + if (role == null) return; + + if (role.equals(adminRole) || role.equals(senioradminRole)) + { + member.removeRole(role.getId()).block(); + } + }).subscribe(); + } + + private void syncRolesSeniorAssignment(Member member, Role adminRole, Role senioradminRole) { + member.getRoles().doFirst(() -> { + if (!member.getRoles().collectList().blockOptional().orElseThrow().contains(senioradminRole)) + { + member.addRole(senioradminRole.getId()).block(); + } + }).doOnEach(r -> { + Role role = r.get(); + if (role == null) return; + + if (role.equals(adminRole)) + { + member.removeRole(role.getId()).block(); + } + }).subscribe(); + } + + private String poolIdentifier() { return "TFD4J"; 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 index b082735f..f47ff443 100644 --- a/discord/src/main/java/me/totalfreedom/discord/util/TFM_Bridge.java +++ b/discord/src/main/java/me/totalfreedom/discord/util/TFM_Bridge.java @@ -60,85 +60,6 @@ public class TFM_Bridge }).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 index f79dd97c..f918cb31 100644 --- a/discord/src/main/java/me/totalfreedom/discord/util/Utilities.java +++ b/discord/src/main/java/me/totalfreedom/discord/util/Utilities.java @@ -3,14 +3,18 @@ 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.Channel; import discord4j.core.object.entity.channel.TextChannel; import discord4j.core.object.reaction.ReactionEmoji; import discord4j.core.spec.EmbedCreateSpec; import discord4j.core.spec.MessageCreateSpec; +import discord4j.discordjson.json.EmojiData; +import discord4j.discordjson.json.ReactionData; 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.OfflinePlayer; import org.bukkit.entity.Player; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -23,7 +27,7 @@ import java.util.Objects; public class Utilities { - private final Flux sentMessages = Flux.fromIterable(new ArrayList<>()); + private Flux sentMessages = Flux.fromIterable(new ArrayList<>()); private final TFD4J tfd4J; private final ImmutableList DISCORD_SUBDOMAINS = (ImmutableList) List.of("discordapp.com", @@ -35,6 +39,11 @@ public class Utilities this.tfd4J = tfd4J; } + public void clearQueue() + { + sentMessages = Flux.fromIterable(new ArrayList<>()); + } + public String sanitizeChatMessage(String message) { String newMessage = message; @@ -116,6 +125,48 @@ public class Utilities } } + public boolean sendReportOffline(Player reporter, OfflinePlayer reported, String reason) + { + if (!tfd4J.getBot().shouldISendReport()) + { + return false; + } + + final Guild server = tfd4J.getBot().getGuildById().block(); + + if (server == null) return false; + + final Channel channel = server.getChannelById(SnowflakeEntry.reportChannelID).block(); + + if (!(channel instanceof TextChannel tch)) return false; + + final EmbedCreateSpec.Builder builder = EmbedCreateSpec.builder() + .title("Report for " + reported.getName() + " (offline)") + .description(reason) + .footer("Reported by " + reporter.getName(), "https://minotar.net/helm/" + reporter.getName() + ".png") + .timestamp(Instant.from(ZonedDateTime.now())); + if (tfd4J.getBot().getTFM().getCommons().esb.isEnabled()) + { + com.earth2me.essentials.User user = tfd4J.getBot().getTFM().getCommons().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(); + builder.addField("Location", location, true); + builder.addField("God Mode", WordUtils.capitalizeFully(String.valueOf(user.isGodModeEnabled())), true); + if (user.getNickname() != null) + { + builder.addField("Nickname", user.getNickname(), true); + } + } + EmbedCreateSpec embed = builder.build(); + Message message = tch.createMessage(embed).block(); + + if (message != null && !ConfigEntry.DISCORD_REPORT_ARCHIVE_CHANNEL_ID.getString().isEmpty()) + { + message.addReaction(ReactionEmoji.unicode("\uD83D\uDCCB")).subscribe(); + } + + return true; + } + public boolean sendReport(Player reporter, Player reported, String reason) { if (!tfd4J.getBot().shouldISendReport()) diff --git a/discord/src/main/resources/plugin.yml b/discord/src/main/resources/plugin.yml index 1f715274..70ccb8a6 100644 --- a/discord/src/main/resources/plugin.yml +++ b/discord/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: TFD4J main: me.totalfreedom.discord.TFD4J -version: 1.0 +version: 2023.03 api-version: 1.19 depend: [TotalFreedomMod] libraries: diff --git a/shop/pom.xml b/shop/pom.xml index a5414282..1d7cd6da 100644 --- a/shop/pom.xml +++ b/shop/pom.xml @@ -11,6 +11,15 @@ shop + + + me.totalfreedom + commons + 2023.02 + provided + + + 17 17 diff --git a/shop/src/main/resources/plugin.yml b/shop/src/main/resources/plugin.yml new file mode 100644 index 00000000..5e9a7221 --- /dev/null +++ b/shop/src/main/resources/plugin.yml @@ -0,0 +1,6 @@ +name: TF-Shoppe +main: me.totalfreedom.shop.Shop +version: ${project.version} +authors: [AtlasMediaGroup, TotalFreedom] +api-version: 1.19 +depend: [TotalFreedomMod] \ No newline at end of file