diff --git a/paper-api/src/main/java/org/bukkit/command/Command.java b/paper-api/src/main/java/org/bukkit/command/Command.java index fca9c91dd7..ec502af595 100644 --- a/paper-api/src/main/java/org/bukkit/command/Command.java +++ b/paper-api/src/main/java/org/bukkit/command/Command.java @@ -292,11 +292,15 @@ public abstract class Command { } public static void broadcastCommandMessage(CommandSender source, String message) { + broadcastCommandMessage(source, message, true); + } + + public static void broadcastCommandMessage(CommandSender source, String message, boolean sendToSource) { Set users = Bukkit.getPluginManager().getPermissionSubscriptions(Server.BROADCAST_CHANNEL_ADMINISTRATIVE); String result = source.getName() + ": " + message; - String colored = ChatColor.GRAY + "(" + result + ")"; + String colored = ChatColor.GRAY + "" + ChatColor.ITALIC + "[" + result + "]"; - if (!(source instanceof ConsoleCommandSender)) { + if (sendToSource && !(source instanceof ConsoleCommandSender)) { source.sendMessage(message); } diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/BanCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/BanCommand.java index 76d4cf6fd8..c4d3a54c73 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/BanCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/BanCommand.java @@ -3,6 +3,7 @@ package org.bukkit.command.defaults; import java.util.List; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -30,7 +31,7 @@ public class BanCommand extends VanillaCommand { player.kickPlayer("Banned by admin."); } - sender.sendMessage("Banned player " + args[0]); + Command.broadcastCommandMessage(sender, "Banned player " + args[0]); return true; } diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/BanIpCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/BanIpCommand.java index 1bb6b0c511..b104973938 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/BanIpCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/BanIpCommand.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.regex.Pattern; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -35,6 +36,7 @@ public class BanIpCommand extends VanillaCommand { sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); return false; } + processIPBan(player.getAddress().getAddress().getHostAddress(), sender); } @@ -50,7 +52,7 @@ public class BanIpCommand extends VanillaCommand { // TODO: Kick on ban Bukkit.banIP(ip); - sender.sendMessage("Banned IP Address " + ip); + Command.broadcastCommandMessage(sender, "Banned IP Address " + ip); } @Override diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/DefaultGameModeCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/DefaultGameModeCommand.java index c633f8add5..63390b1591 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/DefaultGameModeCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/DefaultGameModeCommand.java @@ -2,6 +2,7 @@ package org.bukkit.command.defaults; import org.bukkit.Bukkit; import org.bukkit.GameMode; +import org.bukkit.command.Command; import org.bukkit.command.CommandSender; public class DefaultGameModeCommand extends VanillaCommand { @@ -21,7 +22,7 @@ public class DefaultGameModeCommand extends VanillaCommand { public boolean execute(CommandSender sender, String commandLabel, String[] args) { if (!testPermission(sender)) return true; if (args.length == 0) { - sender.sendMessage("Useage: " + usageMessage); + sender.sendMessage("Usage: " + usageMessage); return false; } @@ -45,7 +46,7 @@ public class DefaultGameModeCommand extends VanillaCommand { } Bukkit.getServer().setDefaultGameMode(mode); - sender.sendMessage("Default game mode set to " + mode.toString().toLowerCase()); + Command.broadcastCommandMessage(sender, "Default game mode set to " + mode.toString().toLowerCase()); return true; } diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/ExpCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/ExpCommand.java index 478100212a..981cfb7b4e 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/ExpCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/ExpCommand.java @@ -2,6 +2,7 @@ package org.bukkit.command.defaults; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -31,7 +32,7 @@ public class ExpCommand extends VanillaCommand { if (player != null) { player.giveExp(exp); - sender.sendMessage("Giving " + exp + " exp to " + player.getName()); + Command.broadcastCommandMessage(sender, "Given " + exp + " exp to " + player.getName()); } else { sender.sendMessage("Can't find user, was one provided?\n" + ChatColor.RED + "Usage: " + usageMessage); } diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/GameModeCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/GameModeCommand.java index 90f3ea533e..087363a055 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/GameModeCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/GameModeCommand.java @@ -5,6 +5,7 @@ import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.GameMode; +import org.bukkit.command.Command; public class GameModeCommand extends VanillaCommand { public GameModeCommand() { @@ -56,7 +57,13 @@ public class GameModeCommand extends VanillaCommand { if (mode != player.getGameMode()) { sender.sendMessage("Game mode change for " + player.getName() + " failed!"); } else { - sender.sendMessage("Game mode set to " + mode.toString() + " for " + player.getName()); + if (player == sender) { + Command.broadcastCommandMessage(sender, "Set own game mode to" + mode.toString() + " mode", false); + } else { + Command.broadcastCommandMessage(sender, "Set " + player.getName() + "'s game mode to" + mode.toString() + " mode", false); + } + + player.sendMessage("Your game mode has been changed"); } } else { sender.sendMessage(player.getName() + " already has game mode " + mode.getValue()); diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/GiveCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/GiveCommand.java index a970d39232..eeac739aad 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/GiveCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/GiveCommand.java @@ -3,6 +3,7 @@ package org.bukkit.command.defaults; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; +import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -44,7 +45,7 @@ public class GiveCommand extends VanillaCommand { player.getInventory().addItem(new ItemStack(material, amount, data)); - sender.sendMessage("Gave " + player.getName() + " some " + material.getId() + " (" + material + ")"); + Command.broadcastCommandMessage(sender, "Gave " + player.getName() + " some " + material.getId() + " (" + material + ")"); } else { sender.sendMessage("There's no item called " + args[1]); } diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/KickCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/KickCommand.java index c82935fb40..1f747d8c1b 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/KickCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/KickCommand.java @@ -2,6 +2,7 @@ package org.bukkit.command.defaults; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -31,7 +32,7 @@ public class KickCommand extends VanillaCommand { } player.kickPlayer(reason); - sender.sendMessage("Kicked player " + player.getName() + ". With reason:\n" + reason); + Command.broadcastCommandMessage(sender, "Kicked player " + player.getName() + ". With reason:\n" + reason); } else { sender.sendMessage( args[0] + " not found."); } diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/OpCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/OpCommand.java index 7806a7691b..4774c7e349 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/OpCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/OpCommand.java @@ -3,6 +3,7 @@ package org.bukkit.command.defaults; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; +import org.bukkit.command.Command; import org.bukkit.command.CommandSender; public class OpCommand extends VanillaCommand { @@ -24,7 +25,7 @@ public class OpCommand extends VanillaCommand { OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]); player.setOp(true); - sender.sendMessage("Opped " + args[0]); + Command.broadcastCommandMessage(sender, "Opped " + args[0]); return true; } diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/PardonCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/PardonCommand.java index b085b6a879..29da200c63 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/PardonCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/PardonCommand.java @@ -2,6 +2,7 @@ package org.bukkit.command.defaults; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.command.Command; import org.bukkit.command.CommandSender; public class PardonCommand extends VanillaCommand { @@ -21,7 +22,7 @@ public class PardonCommand extends VanillaCommand { } Bukkit.getOfflinePlayer(args[0]).setBanned(false); - sender.sendMessage("Pardoned " + args[0]); + Command.broadcastCommandMessage(sender, "Pardoned " + args[0]); return true; } diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/PardonIpCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/PardonIpCommand.java index 6dc91bd968..d97421100c 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/PardonIpCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/PardonIpCommand.java @@ -2,6 +2,7 @@ package org.bukkit.command.defaults; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.command.Command; import org.bukkit.command.CommandSender; public class PardonIpCommand extends VanillaCommand { @@ -22,7 +23,7 @@ public class PardonIpCommand extends VanillaCommand { if (BanIpCommand.ipValidity.matcher(args[0]).matches()) { Bukkit.unbanIP(args[0]); - sender.sendMessage("Pardoned ip " + args[0]); + Command.broadcastCommandMessage(sender, "Pardoned ip " + args[0]); } else { sender.sendMessage("Invalid ip"); } diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/PluginsCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/PluginsCommand.java index d96b3cf74a..8cb45cce23 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/PluginsCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/PluginsCommand.java @@ -3,7 +3,6 @@ package org.bukkit.command.defaults; import java.util.Arrays; import org.bukkit.ChatColor; import org.bukkit.Bukkit; -import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.plugin.Plugin; diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/ReloadCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/ReloadCommand.java index 6abd323f6a..9b090edcd0 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/ReloadCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/ReloadCommand.java @@ -3,7 +3,6 @@ package org.bukkit.command.defaults; import java.util.Arrays; import org.bukkit.ChatColor; import org.bukkit.Bukkit; -import org.bukkit.command.Command; import org.bukkit.command.CommandSender; public class ReloadCommand extends BukkitCommand { diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/SaveOffCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/SaveOffCommand.java index a7a52c5f85..d46cdd3615 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/SaveOffCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/SaveOffCommand.java @@ -21,7 +21,6 @@ public class SaveOffCommand extends VanillaCommand { world.setAutoSave(false); } - Command.broadcastCommandMessage(sender, "Disabled level saving.."); return true; } diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/SayCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/SayCommand.java index 7fcf581d52..44dc7ae0d9 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/SayCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/SayCommand.java @@ -3,7 +3,6 @@ package org.bukkit.command.defaults; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; -import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; public class SayCommand extends VanillaCommand { diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/TeleportCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/TeleportCommand.java index f5dac7857f..ad2a5527fc 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/TeleportCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/TeleportCommand.java @@ -3,6 +3,7 @@ package org.bukkit.command.defaults; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; @@ -38,15 +39,17 @@ public class TeleportCommand extends VanillaCommand { if (player == null) { sender.sendMessage("Player not found: " + args[0]); + return true; } if (args.length < 3) { Player target = Bukkit.getPlayerExact(args[args.length - 1]); if (target == null) { sender.sendMessage("Can't find user " + args[args.length - 1] + ". No tp."); + return true; } player.teleport(target, TeleportCause.COMMAND); - sender.sendMessage("Teleported " + player.getName() + " to " + target.getName()); + Command.broadcastCommandMessage(sender, "Teleported " + player.getName() + " to " + target.getName()); } else if (player.getWorld() != null) { int x = getInteger(sender, args[args.length - 3], -30000000, 30000000); int y = getInteger(sender, args[args.length - 2], 0, 256); @@ -54,7 +57,7 @@ public class TeleportCommand extends VanillaCommand { Location location = new Location(player.getWorld(), x, y, z); player.teleport(location); - sender.sendMessage("Teleported " + player.getName() + " to " + x + "," + y + "," + z); + Command.broadcastCommandMessage(sender, "Teleported " + player.getName() + " to " + + x + "," + y + "," + z); } return true; } diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/TellCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/TellCommand.java index 41c566e94e..56b3af7ac6 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/TellCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/TellCommand.java @@ -39,7 +39,6 @@ public class TellCommand extends VanillaCommand { if (sender instanceof ConsoleCommandSender) { Bukkit.getLogger().info("[" + sender.getName() + "->" + player.getName() + "] " + message); - Bukkit.getLogger().info(result); } player.sendMessage(result);