From c4fce3f0f962ae70af00d1bbeb2748c3453784e9 Mon Sep 17 00:00:00 2001 From: Video Date: Mon, 5 Apr 2021 17:13:26 -0600 Subject: [PATCH 1/5] Right, so this change applies only to commands. For the sake of code consistency, I tried to change as many as possible to use `FreedomCommand.msg` instead of `CommandSender.sendMessage` for their messages. Here are a list of the files containing those changes: * Command_adminworld.java * Command_adventure.java * Command_banip.java * Command_blockedit.java * Command_blockpvp.java * Command_cage.java * Command_cartsit.java * Command_clearchat.java * Command_clearinventory.java * Command_commandlist.java * Command_creative.java * Command_deop.java * Command_deopall.java * Command_dispfill.java * Command_doom.java * Command_gcmd.java * Command_hubworld.java * Command_inspect.java * Command_list.java * Command_lockup.java * Command_manageshop.java * Command_manuallyverify.java * Command_masterbuilderworld.java * Command_mbconfig.java * Command_moblimiter.java * Command_mp44.java * Command_mute.java * Command_nickfilter.java * Command_op.java * Command_opall.java * Command_opme.java * Command_potion.java (Also corrected the inconsistent "player not found" message's color) * Command_rank.java * Command_ride.java * Command_saconfig.java * Command_scare.java * Command_setplayerlimit.java * Command_settotalvotes.java * Command_smite.java * Command_spectator.java * Command_survival.java * Command_unblockcmd.java * Command_uncage.java * Command_unmute.java * Command_verifynoadmin.java Here are some commands I added functionality to: * Command_dispfill.java: Added some code that hooks into the CoreProtect API to log the items being removed from and added into the dispensers. * Command_setlever.java: Added some code that hooks into the CoreProtect API to log the levers being interacted with. Here's a command I fixed a critical bug in: * Command_setlever.java --- .../command/Command_adminworld.java | 2 +- .../command/Command_adventure.java | 4 ++-- .../totalfreedommod/command/Command_banip.java | 4 ++-- .../command/Command_blockedit.java | 2 +- .../command/Command_blockpvp.java | 2 +- .../totalfreedommod/command/Command_cage.java | 6 +++--- .../totalfreedommod/command/Command_cartsit.java | 4 ++-- .../command/Command_clearchat.java | 2 +- .../command/Command_clearinventory.java | 2 +- .../command/Command_commandlist.java | 2 +- .../command/Command_creative.java | 4 ++-- .../totalfreedommod/command/Command_deop.java | 2 +- .../totalfreedommod/command/Command_deopall.java | 2 +- .../command/Command_dispfill.java | 9 +++++---- .../totalfreedommod/command/Command_doom.java | 2 +- .../totalfreedommod/command/Command_gcmd.java | 2 +- .../command/Command_hubworld.java | 2 +- .../totalfreedommod/command/Command_inspect.java | 10 +++++----- .../totalfreedommod/command/Command_list.java | 8 ++++---- .../totalfreedommod/command/Command_lockup.java | 4 ++-- .../command/Command_manageshop.java | 14 +++++++------- .../command/Command_manuallyverify.java | 4 ++-- .../command/Command_masterbuilderworld.java | 2 +- .../command/Command_mbconfig.java | 2 +- .../command/Command_moblimiter.java | 2 +- .../totalfreedommod/command/Command_mp44.java | 2 +- .../totalfreedommod/command/Command_mute.java | 2 +- .../command/Command_nickfilter.java | 6 +++--- .../totalfreedommod/command/Command_op.java | 2 +- .../totalfreedommod/command/Command_opall.java | 2 +- .../totalfreedommod/command/Command_opme.java | 2 +- .../totalfreedommod/command/Command_potion.java | 8 ++++---- .../totalfreedommod/command/Command_rank.java | 2 +- .../totalfreedommod/command/Command_ride.java | 16 ++++++++-------- .../command/Command_saconfig.java | 2 +- .../totalfreedommod/command/Command_scare.java | 2 +- .../command/Command_setlever.java | 10 ++++++++++ .../command/Command_setplayerlimit.java | 2 +- .../command/Command_settotalvotes.java | 2 +- .../totalfreedommod/command/Command_smite.java | 4 ++-- .../command/Command_spectator.java | 4 ++-- .../command/Command_survival.java | 4 ++-- .../command/Command_unblockcmd.java | 2 +- .../totalfreedommod/command/Command_uncage.java | 2 +- .../totalfreedommod/command/Command_unmute.java | 2 +- .../command/Command_verifynoadmin.java | 4 ++-- 46 files changed, 96 insertions(+), 85 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminworld.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminworld.java index 9067e1b7..42942e2f 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminworld.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminworld.java @@ -137,7 +137,7 @@ public class Command_adminworld extends FreedomCommand { return noPerms(); } - sender.sendMessage(ex.getMessage()); + msg(ex.getMessage()); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adventure.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adventure.java index 1d70d095..605b6de2 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adventure.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adventure.java @@ -19,7 +19,7 @@ public class Command_adventure extends FreedomCommand { if (isConsole()) { - sender.sendMessage("When used from the console, you must define a target player."); + msg("When used from the console, you must define a target player."); return true; } @@ -46,7 +46,7 @@ public class Command_adventure extends FreedomCommand if (player == null) { - sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); + msg(PLAYER_NOT_FOUND); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_banip.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_banip.java index a727c8e2..9066e83c 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_banip.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_banip.java @@ -72,8 +72,8 @@ public class Command_banip extends FreedomCommand { // Broadcast FLog.info(ChatColor.RED + sender.getName() + " - Banned the IP " + ip); - String message = ChatColor.RED + sender.getName() + " - Banned " + (plugin.al.isAdmin(player) ? "the IP " + ip : "an IP"); - player.sendMessage(message); + String message = sender.getName() + " - Banned " + (plugin.al.isAdmin(player) ? "the IP " + ip : "an IP"); + msg(player, message, ChatColor.RED); } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockedit.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockedit.java index f8347503..e1904553 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockedit.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockedit.java @@ -92,7 +92,7 @@ public class Command_blockedit extends FreedomCommand final Player player2 = getPlayer(args[0]); if (player2 == null) { - sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); + msg(PLAYER_NOT_FOUND); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockpvp.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockpvp.java index ac07ec15..0471724c 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockpvp.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockpvp.java @@ -93,7 +93,7 @@ public class Command_blockpvp extends FreedomCommand final Player p = getPlayer(args[0]); if (p == null) { - sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); + msg(PLAYER_NOT_FOUND); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java index 1c1dc161..2ba3812d 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java @@ -42,14 +42,14 @@ public class Command_cage extends FreedomCommand Player player = getPlayer(args[0]); if (player == null) { - sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); + msg(PLAYER_NOT_FOUND); return true; } final FPlayer fPlayer = plugin.pl.getPlayer(player); if (fPlayer.getCageData().isCaged()) { - sender.sendMessage(ChatColor.RED + "That player is already caged."); + msg("That player is already caged.", ChatColor.RED); return true; } @@ -80,7 +80,7 @@ public class Command_cage extends FreedomCommand outerMaterial = Material.matchMaterial(args[2]); break; } - sender.sendMessage(ChatColor.RED + "Invalid block!"); + msg("Invalid block!", ChatColor.RED); break; } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cartsit.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cartsit.java index 8d5cdc9c..5e90f925 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cartsit.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cartsit.java @@ -23,7 +23,7 @@ public class Command_cartsit extends FreedomCommand if (targetPlayer == null) { - sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); + msg(PLAYER_NOT_FOUND); return true; } } @@ -32,7 +32,7 @@ public class Command_cartsit extends FreedomCommand { if (targetPlayer == null) { - sender.sendMessage("When used from the console, you must define a target player: /cartsit "); + msg("When used from the console, you must define a target player: /cartsit "); return true; } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearchat.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearchat.java index b476d3fa..3e891b9d 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearchat.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearchat.java @@ -20,7 +20,7 @@ public class Command_clearchat extends FreedomCommand { for (int i = 0; i < 100; i++) { - player.sendMessage(""); + msg(player, ""); } } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearinventory.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearinventory.java index 68898d0d..a5574813 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearinventory.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearinventory.java @@ -52,7 +52,7 @@ public class Command_clearinventory extends FreedomCommand player.getInventory().clear(); msg("Cleared " + player.getName() + "'s inventory."); - player.sendMessage(sender.getName() + " has cleared your inventory."); + msg(player, sender.getName() + " has cleared your inventory."); } } else diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_commandlist.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_commandlist.java index d2af1cef..b7fb63df 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_commandlist.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_commandlist.java @@ -43,7 +43,7 @@ public class Command_commandlist extends FreedomCommand Collections.sort(commands); - sender.sendMessage(StringUtils.join(commands, ", ")); + msg(StringUtils.join(commands, ", ")); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_creative.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_creative.java index 32f3dad0..a24c8043 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_creative.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_creative.java @@ -19,7 +19,7 @@ public class Command_creative extends FreedomCommand { if (isConsole()) { - sender.sendMessage("When used from the console, you must define a target player."); + msg("When used from the console, you must define a target player."); return true; } @@ -46,7 +46,7 @@ public class Command_creative extends FreedomCommand if (player == null) { - sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); + msg(PLAYER_NOT_FOUND); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deop.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deop.java index b9ec6b62..1cdddbe6 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deop.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deop.java @@ -39,7 +39,7 @@ public class Command_deop extends FreedomCommand { matchedPlayerNames.add(player.getName()); player.setOp(false); - player.sendMessage(FreedomCommand.YOU_ARE_NOT_OP); + msg(player, YOU_ARE_NOT_OP); plugin.rm.updateDisplay(player); } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deopall.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deopall.java index 4a8ec1f8..84817ad7 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deopall.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deopall.java @@ -19,7 +19,7 @@ public class Command_deopall extends FreedomCommand for (Player player : server.getOnlinePlayers()) { player.setOp(false); - player.sendMessage(FreedomCommand.YOU_ARE_NOT_OP); + msg(player, YOU_ARE_NOT_OP); plugin.rm.updateDisplay(player); } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_dispfill.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_dispfill.java index f8d26d64..77d72ef3 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_dispfill.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_dispfill.java @@ -43,7 +43,7 @@ public class Command_dispfill extends FreedomCommand } catch (NumberFormatException ex) { - sender.sendMessage("Invalid radius."); + msg("Invalid radius."); return true; } @@ -60,7 +60,7 @@ public class Command_dispfill extends FreedomCommand } else { - sender.sendMessage("Skipping invalid item: " + searchItem); + msg("Skipping invalid item: " + searchItem); } } @@ -80,7 +80,8 @@ public class Command_dispfill extends FreedomCommand { if (targetBlock.getType().equals(Material.DISPENSER)) { - sender.sendMessage("Filling dispenser @ " + FUtil.formatLocation(targetBlock.getLocation())); + msg("Filling dispenser @ " + FUtil.formatLocation(targetBlock.getLocation())); + plugin.cpb.getCoreProtectAPI().logContainerTransaction(sender.getName(), targetBlock.getLocation()); setDispenserContents(targetBlock, itemsArray); affected++; } @@ -89,7 +90,7 @@ public class Command_dispfill extends FreedomCommand } } - sender.sendMessage("Done. " + affected + " dispenser(s) filled."); + msg("Done. " + affected + " dispenser(s) filled."); } else { diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_doom.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_doom.java index 92126067..d6711948 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_doom.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_doom.java @@ -36,7 +36,7 @@ public class Command_doom extends FreedomCommand if (player == null) { - sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); + msg(PLAYER_NOT_FOUND); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gcmd.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gcmd.java index 7d88d686..c25f0c12 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gcmd.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gcmd.java @@ -23,7 +23,7 @@ public class Command_gcmd extends FreedomCommand if (player == null) { - sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); + msg(PLAYER_NOT_FOUND); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_hubworld.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_hubworld.java index f2742988..cf6da0d0 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_hubworld.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_hubworld.java @@ -138,7 +138,7 @@ public class Command_hubworld extends FreedomCommand { return noPerms(); } - sender.sendMessage(ex.getMessage()); + msg(ex.getMessage()); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_inspect.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_inspect.java index 81c6001a..87ab52a1 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_inspect.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_inspect.java @@ -39,7 +39,7 @@ public class Command_inspect extends FreedomCommand } catch (NumberFormatException e) { - sender.sendMessage(ChatColor.RED + "Invalid number"); + msg("Invalid number", ChatColor.RED); } } @@ -48,19 +48,19 @@ public class Command_inspect extends FreedomCommand { if (pageIndex < 1 || pageIndex > paged.getPageCount()) { - sender.sendMessage(ChatColor.RED + "Not a valid page number"); + msg("Not a valid page number", ChatColor.RED); return true; } - sender.sendMessage("---- " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector" + ChatColor.WHITE + " ---- "); + msg("---- " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector" + ChatColor.WHITE + " ---- ", ChatColor.WHITE); List page = paged.getPage(pageIndex); for (String entries : page) { - sender.sendMessage(entries); + msg(entries); } - sender.sendMessage("Page " + pageIndex + "/" + paged.getPageCount() + " | To index through the pages, type " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "/ins history "); + msg("Page " + pageIndex + "/" + paged.getPageCount() + " | To index through the pages, type " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "/ins history ", ChatColor.WHITE); return true; } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java index fd6ef859..5097477c 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java @@ -141,13 +141,13 @@ public class Command_list extends FreedomCommand .append(StringUtils.join(n, ChatColor.WHITE + ", ")); if (senderIsConsole) { - sender.sendMessage(ChatColor.stripColor(onlineStats.toString())); - sender.sendMessage(ChatColor.stripColor(onlineUsers.toString())); + msg(ChatColor.stripColor(onlineStats.toString())); + msg(ChatColor.stripColor(onlineUsers.toString())); } else { - sender.sendMessage(onlineStats.toString()); - sender.sendMessage(onlineUsers.toString()); + msg(onlineStats.toString()); + msg(onlineUsers.toString()); } n.clear(); return true; diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_lockup.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_lockup.java index 6d31cf47..e707bd70 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_lockup.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_lockup.java @@ -53,7 +53,7 @@ public class Command_lockup extends FreedomCommand if (player == null) { - sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); + msg(PLAYER_NOT_FOUND); return true; } @@ -70,7 +70,7 @@ public class Command_lockup extends FreedomCommand if (player == null) { - sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); + msg(PLAYER_NOT_FOUND); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manageshop.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manageshop.java index 8bad2b61..60c786c3 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manageshop.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manageshop.java @@ -54,7 +54,7 @@ public class Command_manageshop extends FreedomCommand Player player = getPlayer(args[3]); if (player != null) { - player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins()); + msg(player, sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins(), ChatColor.GREEN); } } else @@ -64,7 +64,7 @@ public class Command_manageshop extends FreedomCommand PlayerData playerData = plugin.pl.getData(player); playerData.setCoins(playerData.getCoins() + amount); plugin.pl.save(playerData); - player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins()); + msg(player, sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins(), ChatColor.GREEN); } msg("Successfully added " + amount + " coins to all online players.", ChatColor.GREEN); } @@ -97,7 +97,7 @@ public class Command_manageshop extends FreedomCommand Player player = getPlayer(args[3]); if (player != null) { - player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins()); + msg(player, sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins(), ChatColor.RED); } } else @@ -111,7 +111,7 @@ public class Command_manageshop extends FreedomCommand playerData.setCoins(0); } plugin.pl.save(playerData); - player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins()); + msg(player, sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins(), ChatColor.RED); } msg("Successfully took " + amount + " coins from all online players.", ChatColor.GREEN); } @@ -138,7 +138,7 @@ public class Command_manageshop extends FreedomCommand Player player = getPlayer(args[3]); if (player != null) { - player.sendMessage(ChatColor.GREEN + sender.getName() + " set your coin balance to " + amount); + msg(player, sender.getName() + " set your coin balance to " + amount, ChatColor.GREEN); } return true; } @@ -183,7 +183,7 @@ public class Command_manageshop extends FreedomCommand Player player = getPlayer(args[3]); if (player != null) { - player.sendMessage(ChatColor.GREEN + sender.getName() + " gave the " + item.getName() + " to you"); + msg(player, sender.getName() + " gave the " + item.getName() + " to you", ChatColor.GREEN); } return true; } @@ -208,7 +208,7 @@ public class Command_manageshop extends FreedomCommand Player player = getPlayer(args[3]); if (player != null) { - player.sendMessage(ChatColor.RED + sender.getName() + " took the " + item.getName() + " from you"); + msg(player, sender.getName() + " took the " + item.getName() + " from you", ChatColor.RED); } return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manuallyverify.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manuallyverify.java index f79473a2..1776538f 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manuallyverify.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_manuallyverify.java @@ -48,12 +48,12 @@ public class Command_manuallyverify extends FreedomCommand FUtil.adminAction(sender.getName(), "Manually verifying player " + player.getName(), false); player.setOp(true); - player.sendMessage(YOU_ARE_OP); + msg(player, YOU_ARE_OP); if (plugin.pl.getPlayer(player).getFreezeData().isFrozen()) { plugin.pl.getPlayer(player).getFreezeData().setFrozen(false); - player.sendMessage(ChatColor.GRAY + "You have been unfrozen."); + msg(player, "You have been unfrozen."); } plugin.pl.verify(player, null); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_masterbuilderworld.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_masterbuilderworld.java index 7542386e..ee249abe 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_masterbuilderworld.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_masterbuilderworld.java @@ -138,7 +138,7 @@ public class Command_masterbuilderworld extends FreedomCommand { return noPerms(); } - sender.sendMessage(ex.getMessage()); + msg(ex.getMessage()); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mbconfig.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mbconfig.java index b1231416..23320e41 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mbconfig.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mbconfig.java @@ -129,7 +129,7 @@ public class Command_mbconfig extends FreedomCommand plugin.pl.verify(player, null); plugin.rm.updateDisplay(player); player.setOp(true); - player.sendMessage(YOU_ARE_OP); + msg(player, YOU_ARE_OP); } } else if (!data.isMasterBuilder()) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_moblimiter.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_moblimiter.java index d8884d69..575ccf8e 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_moblimiter.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_moblimiter.java @@ -65,7 +65,7 @@ public class Command_moblimiter extends FreedomCommand if (ConfigEntry.MOB_LIMITER_ENABLED.getBoolean()) { - sender.sendMessage("Moblimiter enabled. Maximum mobcount set to: " + ConfigEntry.MOB_LIMITER_MAX.getInteger() + "."); + msg("Moblimiter enabled. Maximum mobcount set to: " + ConfigEntry.MOB_LIMITER_MAX.getInteger() + "."); msg("Dragon: " + (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean() ? "disabled" : "enabled") + "."); msg("Giant: " + (ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean() ? "disabled" : "enabled") + "."); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mp44.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mp44.java index a5c003be..8cb0a9a9 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mp44.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mp44.java @@ -45,7 +45,7 @@ public class Command_mp44 extends FreedomCommand { playerdata.disarmMP44(); - sender.sendMessage(ChatColor.GREEN + "mp44 Disarmed."); + msg("mp44 Disarmed.", ChatColor.GREEN); } return true; diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mute.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mute.java index 5e8a90bb..0ce530d4 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mute.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mute.java @@ -109,7 +109,7 @@ public class Command_mute extends FreedomCommand final Player player = getPlayer(args[0]); if (player == null) { - sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); + msg(PLAYER_NOT_FOUND); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickfilter.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickfilter.java index 6a67581e..82166dce 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickfilter.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickfilter.java @@ -81,7 +81,7 @@ public class Command_nickfilter extends FreedomCommand if (player == null || !plugin.al.isVanished(player.getName()) && !plugin.al.isAdmin(sender)) { - sender.sendMessage(ChatColor.GRAY + "Can't find player by nickname: " + displayName); + msg("Can't find player by nickname: " + displayName); return true; } } @@ -101,7 +101,7 @@ public class Command_nickfilter extends FreedomCommand if (!nickMatched) { - sender.sendMessage("No nicknames replaced in command."); + msg("No nicknames replaced in command."); return true; } @@ -113,7 +113,7 @@ public class Command_nickfilter extends FreedomCommand return true; } - sender.sendMessage("Sending command: \"" + newCommand + "\"."); + msg("Sending command: \"" + newCommand + "\"."); server.dispatchCommand(sender, newCommand); return true; diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_op.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_op.java index a45c9c43..ece9abba 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_op.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_op.java @@ -40,7 +40,7 @@ public class Command_op extends FreedomCommand { matchedPlayerNames.add(player.getName()); player.setOp(true); - player.sendMessage(FreedomCommand.YOU_ARE_OP); + msg(player, YOU_ARE_OP); plugin.rm.updateDisplay(player); } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opall.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opall.java index 9436c8dd..a02671cc 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opall.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opall.java @@ -21,7 +21,7 @@ public class Command_opall extends FreedomCommand if (!player.isOp()) { player.setOp(true); - player.sendMessage(FreedomCommand.YOU_ARE_OP); + msg(player, YOU_ARE_OP); plugin.rm.updateDisplay(player); } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opme.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opme.java index b2b979cc..93d71319 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opme.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opme.java @@ -16,7 +16,7 @@ public class Command_opme extends FreedomCommand { FUtil.adminAction(sender.getName(), "Opping " + sender.getName(), false); sender.setOp(true); - sender.sendMessage(FreedomCommand.YOU_ARE_OP); + msg(YOU_ARE_OP); plugin.rm.updateDisplay(playerSender); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java index dd508c54..f130d51a 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_potion.java @@ -106,7 +106,7 @@ public class Command_potion extends FreedomCommand { if (!plugin.al.isAdmin(sender) && !getPlayer(args[4]).equals(getPlayer(sender.getName()))) { - sender.sendMessage(ChatColor.RED + "Only admins can apply potion effects to other players."); + msg("Only admins can apply potion effects to other players.", ChatColor.RED); return true; } @@ -114,7 +114,7 @@ public class Command_potion extends FreedomCommand if (target == null || plugin.al.isVanished(target.getName()) && !plugin.al.isAdmin(sender)) { - msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED); + msg(PLAYER_NOT_FOUND); return true; } } @@ -122,7 +122,7 @@ public class Command_potion extends FreedomCommand { if (senderIsConsole) { - sender.sendMessage("You must specify a target player when using this command from the console."); + msg("You must specify a target player when using this command from the console."); return true; } } @@ -130,7 +130,7 @@ public class Command_potion extends FreedomCommand PotionEffectType potion_effect_type = PotionEffectType.getByName(args[1]); if (potion_effect_type == null) { - sender.sendMessage(ChatColor.AQUA + "Invalid potion effect type."); + msg("Invalid potion effect type.", ChatColor.AQUA); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rank.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rank.java index be356d1b..d84846f3 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rank.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rank.java @@ -39,7 +39,7 @@ public class Command_rank extends FreedomCommand if (player == null) { - sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); + msg(PLAYER_NOT_FOUND); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java index d2a3a486..9b8ca1d3 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ride.java @@ -52,7 +52,7 @@ public class Command_ride extends FreedomCommand } msg("Request accepted."); - requester.sendMessage(ChatColor.GRAY + "Your request has been accepted."); + msg(requester, "Your request has been accepted."); if (requester.getWorld() != playerSender.getWorld()) { @@ -80,7 +80,7 @@ public class Command_ride extends FreedomCommand } msg("Request denied."); RIDE_REQUESTS.remove(playerSender); - requester.sendMessage(ChatColor.GRAY + "Your request has been denied."); + msg(requester, "Your request has been denied."); return true; } @@ -123,10 +123,10 @@ public class Command_ride extends FreedomCommand if (playerData.getRideMode().equals("ask") && !FUtil.isExecutive(playerSender.getName())) { msg("Sent a request to the player.", ChatColor.GREEN); - player.sendMessage(ChatColor.AQUA + sender.getName() + " has requested to ride you."); - player.sendMessage(ChatColor.AQUA + "Type " + ChatColor.GREEN + "/ride accept" + ChatColor.AQUA + " to allow the player to ride you."); - player.sendMessage(ChatColor.AQUA + "Type " + ChatColor.RED + "/ride deny" + ChatColor.AQUA + " to deny the player permission."); - player.sendMessage(ChatColor.AQUA + "Request will expire in 30 seconds."); + msg(player, sender.getName() + " has requested to ride you.", ChatColor.AQUA); + msg(player, "Type " + ChatColor.GREEN + "/ride accept" + ChatColor.AQUA + " to allow the player to ride you.", ChatColor.AQUA); + msg(player, "Type " + ChatColor.RED + "/ride deny" + ChatColor.AQUA + " to deny the player permission.", ChatColor.AQUA); + msg(player, "Request will expire in 30 seconds.", ChatColor.AQUA); RIDE_REQUESTS.put(player, playerSender); new BukkitRunnable() @@ -139,8 +139,8 @@ public class Command_ride extends FreedomCommand } RIDE_REQUESTS.remove(player); - playerSender.sendMessage(ChatColor.RED + "It has been 30 seconds and " + player.getName() + " has not accepted your request."); - player.sendMessage(ChatColor.RED + "Request expired."); + msg(playerSender, "It has been 30 seconds and " + player.getName() + " has not accepted your request.", ChatColor.RED); + msg(player, "Request expired.", ChatColor.RED); } }.runTaskLater(plugin, 20 * 30); return true; diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java index 76582c77..0a1c06dc 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java @@ -243,7 +243,7 @@ public class Command_saconfig extends FreedomCommand if (!player.isOp()) { player.setOp(true); - player.sendMessage(YOU_ARE_OP); + msg(player, YOU_ARE_OP); } return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_scare.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_scare.java index bf8289fa..15da84ec 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_scare.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_scare.java @@ -38,7 +38,7 @@ public class Command_scare extends FreedomCommand } msg("Scared " + player.getName()); - player.sendMessage(ChatColor.RED + "ZING"); + msg(player, "ZING", ChatColor.RED); player.spawnParticle(Particle.MOB_APPEARANCE, player.getLocation(), 4); for (int i = 0; i < 10; ++i) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java index dfec52c8..654e9032 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java @@ -1,6 +1,8 @@ package me.totalfreedom.totalfreedommod.command; import java.util.List; + +import me.totalfreedom.totalfreedommod.MovementValidator; import me.totalfreedom.totalfreedommod.rank.Rank; import org.bukkit.Location; import org.bukkit.Material; @@ -39,6 +41,12 @@ public class Command_setlever extends FreedomCommand return true; } + if (x > 29999998 || x < -29999998 || y > 29999998 || y < -29999998 || z > 29999998 || z < -29999998) + { + msg("Coordinates cannot be larger than 29999998 or smaller than -29999998 blocks."); + return true; + } + World world = null; final String needleWorldName = args[3].trim(); final List worlds = server.getWorlds(); @@ -72,6 +80,8 @@ public class Command_setlever extends FreedomCommand caster.setPowered(leverOn); state.setBlockData(data); state.update(); + + plugin.cpb.getCoreProtectAPI().logInteraction(sender.getName(), leverLocation); } else { diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setplayerlimit.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setplayerlimit.java index f518bd86..fb9f640e 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setplayerlimit.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setplayerlimit.java @@ -21,7 +21,7 @@ public class Command_setplayerlimit extends FreedomCommand Player player = Bukkit.getPlayer(args[0]); if (player == null) { - sender.sendMessage(PLAYER_NOT_FOUND); + msg(PLAYER_NOT_FOUND); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_settotalvotes.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_settotalvotes.java index 04d7b3cf..3c6de7be 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_settotalvotes.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_settotalvotes.java @@ -55,7 +55,7 @@ public class Command_settotalvotes extends FreedomCommand if (player != null) { - player.sendMessage(ChatColor.GREEN + sender.getName() + " has set your total votes to " + votes); + msg(player, sender.getName() + " has set your total votes to " + votes, ChatColor.GREEN); } return true; diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java index 708d36bf..59b802e1 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_smite.java @@ -44,7 +44,7 @@ public class Command_smite extends FreedomCommand } else { - sender.sendMessage(ChatColor.GRAY + "Smitten " + player.getName() + " quietly."); + sender.sendMessage("Smitten " + player.getName() + " quietly."); } // Deop @@ -112,7 +112,7 @@ public class Command_smite extends FreedomCommand if (player == null) { - msg(FreedomCommand.PLAYER_NOT_FOUND); + msg(PLAYER_NOT_FOUND); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectator.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectator.java index 43fe0c1d..808beb93 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectator.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectator.java @@ -18,7 +18,7 @@ public class Command_spectator extends FreedomCommand { if (isConsole()) { - sender.sendMessage("When used from the console, you must define a target player."); + msg("When used from the console, you must define a target player."); return true; } @@ -31,7 +31,7 @@ public class Command_spectator extends FreedomCommand if (player == null) { - sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); + msg(PLAYER_NOT_FOUND); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_survival.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_survival.java index 89f2d738..2a600dfe 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_survival.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_survival.java @@ -19,7 +19,7 @@ public class Command_survival extends FreedomCommand { if (isConsole()) { - sender.sendMessage("When used from the console, you must define a target player."); + msg("When used from the console, you must define a target player."); return true; } @@ -46,7 +46,7 @@ public class Command_survival extends FreedomCommand if (player == null) { - sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); + msg(PLAYER_NOT_FOUND); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unblockcmd.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unblockcmd.java index 8579db8b..d6f551bb 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unblockcmd.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unblockcmd.java @@ -24,7 +24,7 @@ public class Command_unblockcmd extends FreedomCommand Player player = getPlayer(args[0]); if (player == null) { - sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); + msg(PLAYER_NOT_FOUND); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_uncage.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_uncage.java index 31f7acf2..ccfd1d1d 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_uncage.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_uncage.java @@ -25,7 +25,7 @@ public class Command_uncage extends FreedomCommand Player player = getPlayer(args[0]); if (player == null) { - sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); + msg(PLAYER_NOT_FOUND); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unmute.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unmute.java index 5876227c..725f6146 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unmute.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unmute.java @@ -37,7 +37,7 @@ public class Command_unmute extends FreedomCommand final Player player = getPlayer(args[0]); if (player == null) { - sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); + msg(PLAYER_NOT_FOUND); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verifynoadmin.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verifynoadmin.java index 2c479c6f..426566f1 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verifynoadmin.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verifynoadmin.java @@ -54,12 +54,12 @@ public class Command_verifynoadmin extends FreedomCommand plugin.rm.updateDisplay(player); FUtil.adminAction(sender.getName(), "Verified " + player.getName() + ", without admin permissions.", true); player.setOp(true); - player.sendMessage(YOU_ARE_OP); + msg(player, YOU_ARE_OP); final FPlayer fPlayer = plugin.pl.getPlayer(player); if (fPlayer.getFreezeData().isFrozen()) { fPlayer.getFreezeData().setFrozen(false); - player.sendMessage(ChatColor.GRAY + "You have been unfrozen."); + msg(player, "You have been unfrozen."); } msg("Verified " + player.getName() + " but didn't give them admin permissions", ChatColor.GREEN); } From a7529b41fb5846d7d5ad53093a287c616fcf154f Mon Sep 17 00:00:00 2001 From: Video Date: Mon, 5 Apr 2021 18:08:24 -0600 Subject: [PATCH 2/5] Oops --- .../totalfreedom/totalfreedommod/command/Command_nickfilter.java | 1 - .../totalfreedom/totalfreedommod/command/Command_setlever.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickfilter.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickfilter.java index 82166dce..fef2ee56 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickfilter.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickfilter.java @@ -7,7 +7,6 @@ import java.util.regex.Pattern; import me.totalfreedom.totalfreedommod.rank.Rank; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java index 654e9032..b8430169 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java @@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.command; import java.util.List; -import me.totalfreedom.totalfreedommod.MovementValidator; import me.totalfreedom.totalfreedommod.rank.Rank; import org.bukkit.Location; import org.bukkit.Material; From df21bdfa7e104aabbef956151783503a4ea309fc Mon Sep 17 00:00:00 2001 From: Video Date: Wed, 7 Apr 2021 19:40:19 -0600 Subject: [PATCH 3/5] Other bug fixes Credit to Fleek for some of the code here. Bugs that were fixed: * [Media] showing up with an extra space at the beginning of blank messages with attachments * Admin chat using incorrect colors for its ranks in messages from Discord to Minecraft * Admin notes not sending to admins, only admin impostors --- .../totalfreedommod/LoginProcess.java | 2 +- .../discord/DiscordToAdminChatListener.java | 28 +++++++++++-------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java b/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java index 21ff89c1..90a3a4ea 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java @@ -246,7 +246,7 @@ public class LoginProcess extends FreedomService FLog.info(noteMessage); for (Player p : server.getOnlinePlayers()) { - if (plugin.al.isAdminImpostor(p)) + if (plugin.al.isAdmin(p)) { notice.send(p); } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToAdminChatListener.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToAdminChatListener.java index fed58efb..6a9c512a 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToAdminChatListener.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToAdminChatListener.java @@ -39,7 +39,7 @@ public class DiscordToAdminChatListener extends ListenerAdapter Member member = event.getMember(); String tag = dtml.getDisplay(member); Message msg = event.getMessage(); - String mediamessage = ChatColor.YELLOW + " [Media]"; + String mediamessage = ChatColor.YELLOW + "[Media]"; StringBuilder logmessage = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "] " + ChatColor.RESET); String lm = ChatColor.DARK_RED + member.getEffectiveName() + " " @@ -65,10 +65,10 @@ public class DiscordToAdminChatListener extends ListenerAdapter String format = admin.getAcFormat(); if (!Strings.isNullOrEmpty(format)) { - Displayable display = TotalFreedomMod.getPlugin().rm.getDisplay(player); + Displayable display = getDisplay(member); net.md_5.bungee.api.ChatColor color = getColor(display); String m = format.replace("%name%", member.getEffectiveName()) - .replace("%rank%", getDisplay(member)) + .replace("%rank%", display.getAbbr()) .replace("%rankcolor%", color.toString()) .replace("%msg%", FUtil.colorize(msg.getContentDisplay())); builder.append(FUtil.colorize(m)); @@ -86,8 +86,12 @@ public class DiscordToAdminChatListener extends ListenerAdapter { for (Message.Attachment attachment : msg.getAttachments()) { - TextComponent text = new TextComponent(mediamessage); + TextComponent text = new TextComponent((msg.getContentDisplay().isEmpty() ? "" : " ") + mediamessage); text.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl())); + if (!msg.getContentDisplay().isEmpty()) + { + builder.append(" "); + } builder.append(text); } } @@ -98,43 +102,43 @@ public class DiscordToAdminChatListener extends ListenerAdapter } // Needed to display tags in custom AC messages - public String getDisplay(Member member) + public Displayable getDisplay(Member member) { Guild server = Discord.bot.getGuildById(ConfigEntry.DISCORD_SERVER_ID.getString()); // Server Owner if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_SERVER_OWNER_ROLE_ID.getString()))) { - return Title.OWNER.getAbbr(); + return Title.OWNER; } // Developers else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_DEVELOPER_ROLE_ID.getString()))) { - return Title.DEVELOPER.getAbbr(); + return Title.DEVELOPER; } // Executives else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_EXECUTIVE_ROLE_ID.getString()))) { - return Title.EXECUTIVE.getAbbr(); + return Title.EXECUTIVE; } // Senior Admins else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_SENIOR_ADMIN_ROLE_ID.getString()))) { - return Rank.SENIOR_ADMIN.getAbbr(); + return Rank.SENIOR_ADMIN; } // Admins else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_NEW_ADMIN_ROLE_ID.getString()))) { - return Rank.ADMIN.getAbbr(); + return Rank.ADMIN; } // Master Builders else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_MASTER_BUILDER_ROLE_ID.getString()))) { - return Title.MASTER_BUILDER.getAbbr(); + return Title.MASTER_BUILDER; } // OP, returning null breaks? else { - return Rank.OP.getAbbr(); + return Rank.OP; } } } From a33c310757916c5a45e1acd51d4caf14fd88d50e Mon Sep 17 00:00:00 2001 From: Video Date: Wed, 7 Apr 2021 19:41:13 -0600 Subject: [PATCH 4/5] Fucking shit --- .../totalfreedommod/discord/DiscordToAdminChatListener.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToAdminChatListener.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToAdminChatListener.java index 6a9c512a..84e1dc32 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToAdminChatListener.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToAdminChatListener.java @@ -19,7 +19,6 @@ import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.entity.Player; public class DiscordToAdminChatListener extends ListenerAdapter { From 16e06bd932f5393319e24a34d1a9aadbc29c9a9e Mon Sep 17 00:00:00 2001 From: Video Date: Wed, 7 Apr 2021 19:45:03 -0600 Subject: [PATCH 5/5] Forgot I had this there --- .../totalfreedommod/discord/DiscordToAdminChatListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToAdminChatListener.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToAdminChatListener.java index 84e1dc32..633b0e8f 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToAdminChatListener.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/discord/DiscordToAdminChatListener.java @@ -85,7 +85,7 @@ public class DiscordToAdminChatListener extends ListenerAdapter { for (Message.Attachment attachment : msg.getAttachments()) { - TextComponent text = new TextComponent((msg.getContentDisplay().isEmpty() ? "" : " ") + mediamessage); + TextComponent text = new TextComponent(mediamessage); text.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl())); if (!msg.getContentDisplay().isEmpty()) {