13
0
geforkt von Mirrors/Paper

Update commands to match 1.3 vanilla commands

By: feildmaster <admin@feildmaster.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2012-08-06 04:45:18 -05:00
Ursprung d6f528e808
Commit 3d3c769de0
17 geänderte Dateien mit 39 neuen und 20 gelöschten Zeilen

Datei anzeigen

@ -292,11 +292,15 @@ public abstract class Command {
} }
public static void broadcastCommandMessage(CommandSender source, String message) { public static void broadcastCommandMessage(CommandSender source, String message) {
broadcastCommandMessage(source, message, true);
}
public static void broadcastCommandMessage(CommandSender source, String message, boolean sendToSource) {
Set<Permissible> users = Bukkit.getPluginManager().getPermissionSubscriptions(Server.BROADCAST_CHANNEL_ADMINISTRATIVE); Set<Permissible> users = Bukkit.getPluginManager().getPermissionSubscriptions(Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
String result = source.getName() + ": " + message; 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); source.sendMessage(message);
} }

Datei anzeigen

@ -3,6 +3,7 @@ package org.bukkit.command.defaults;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -30,7 +31,7 @@ public class BanCommand extends VanillaCommand {
player.kickPlayer("Banned by admin."); player.kickPlayer("Banned by admin.");
} }
sender.sendMessage("Banned player " + args[0]); Command.broadcastCommandMessage(sender, "Banned player " + args[0]);
return true; return true;
} }

Datei anzeigen

@ -4,6 +4,7 @@ import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -35,6 +36,7 @@ public class BanIpCommand extends VanillaCommand {
sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
return false; return false;
} }
processIPBan(player.getAddress().getAddress().getHostAddress(), sender); processIPBan(player.getAddress().getAddress().getHostAddress(), sender);
} }
@ -50,7 +52,7 @@ public class BanIpCommand extends VanillaCommand {
// TODO: Kick on ban // TODO: Kick on ban
Bukkit.banIP(ip); Bukkit.banIP(ip);
sender.sendMessage("Banned IP Address " + ip); Command.broadcastCommandMessage(sender, "Banned IP Address " + ip);
} }
@Override @Override

Datei anzeigen

@ -2,6 +2,7 @@ package org.bukkit.command.defaults;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class DefaultGameModeCommand extends VanillaCommand { public class DefaultGameModeCommand extends VanillaCommand {
@ -21,7 +22,7 @@ public class DefaultGameModeCommand extends VanillaCommand {
public boolean execute(CommandSender sender, String commandLabel, String[] args) { public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!testPermission(sender)) return true; if (!testPermission(sender)) return true;
if (args.length == 0) { if (args.length == 0) {
sender.sendMessage("Useage: " + usageMessage); sender.sendMessage("Usage: " + usageMessage);
return false; return false;
} }
@ -45,7 +46,7 @@ public class DefaultGameModeCommand extends VanillaCommand {
} }
Bukkit.getServer().setDefaultGameMode(mode); 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; return true;
} }

Datei anzeigen

@ -2,6 +2,7 @@ package org.bukkit.command.defaults;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -31,7 +32,7 @@ public class ExpCommand extends VanillaCommand {
if (player != null) { if (player != null) {
player.giveExp(exp); player.giveExp(exp);
sender.sendMessage("Giving " + exp + " exp to " + player.getName()); Command.broadcastCommandMessage(sender, "Given " + exp + " exp to " + player.getName());
} else { } else {
sender.sendMessage("Can't find user, was one provided?\n" + ChatColor.RED + "Usage: " + usageMessage); sender.sendMessage("Can't find user, was one provided?\n" + ChatColor.RED + "Usage: " + usageMessage);
} }

Datei anzeigen

@ -5,6 +5,7 @@ import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.command.Command;
public class GameModeCommand extends VanillaCommand { public class GameModeCommand extends VanillaCommand {
public GameModeCommand() { public GameModeCommand() {
@ -56,7 +57,13 @@ public class GameModeCommand extends VanillaCommand {
if (mode != player.getGameMode()) { if (mode != player.getGameMode()) {
sender.sendMessage("Game mode change for " + player.getName() + " failed!"); sender.sendMessage("Game mode change for " + player.getName() + " failed!");
} else { } 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 { } else {
sender.sendMessage(player.getName() + " already has game mode " + mode.getValue()); sender.sendMessage(player.getName() + " already has game mode " + mode.getValue());

Datei anzeigen

@ -3,6 +3,7 @@ package org.bukkit.command.defaults;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -44,7 +45,7 @@ public class GiveCommand extends VanillaCommand {
player.getInventory().addItem(new ItemStack(material, amount, data)); 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 { } else {
sender.sendMessage("There's no item called " + args[1]); sender.sendMessage("There's no item called " + args[1]);
} }

Datei anzeigen

@ -2,6 +2,7 @@ package org.bukkit.command.defaults;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -31,7 +32,7 @@ public class KickCommand extends VanillaCommand {
} }
player.kickPlayer(reason); 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 { } else {
sender.sendMessage( args[0] + " not found."); sender.sendMessage( args[0] + " not found.");
} }

Datei anzeigen

@ -3,6 +3,7 @@ package org.bukkit.command.defaults;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class OpCommand extends VanillaCommand { public class OpCommand extends VanillaCommand {
@ -24,7 +25,7 @@ public class OpCommand extends VanillaCommand {
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]); OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
player.setOp(true); player.setOp(true);
sender.sendMessage("Opped " + args[0]); Command.broadcastCommandMessage(sender, "Opped " + args[0]);
return true; return true;
} }

Datei anzeigen

@ -2,6 +2,7 @@ package org.bukkit.command.defaults;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class PardonCommand extends VanillaCommand { public class PardonCommand extends VanillaCommand {
@ -21,7 +22,7 @@ public class PardonCommand extends VanillaCommand {
} }
Bukkit.getOfflinePlayer(args[0]).setBanned(false); Bukkit.getOfflinePlayer(args[0]).setBanned(false);
sender.sendMessage("Pardoned " + args[0]); Command.broadcastCommandMessage(sender, "Pardoned " + args[0]);
return true; return true;
} }

Datei anzeigen

@ -2,6 +2,7 @@ package org.bukkit.command.defaults;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class PardonIpCommand extends VanillaCommand { public class PardonIpCommand extends VanillaCommand {
@ -22,7 +23,7 @@ public class PardonIpCommand extends VanillaCommand {
if (BanIpCommand.ipValidity.matcher(args[0]).matches()) { if (BanIpCommand.ipValidity.matcher(args[0]).matches()) {
Bukkit.unbanIP(args[0]); Bukkit.unbanIP(args[0]);
sender.sendMessage("Pardoned ip " + args[0]); Command.broadcastCommandMessage(sender, "Pardoned ip " + args[0]);
} else { } else {
sender.sendMessage("Invalid ip"); sender.sendMessage("Invalid ip");
} }

Datei anzeigen

@ -3,7 +3,6 @@ package org.bukkit.command.defaults;
import java.util.Arrays; import java.util.Arrays;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;

Datei anzeigen

@ -3,7 +3,6 @@ package org.bukkit.command.defaults;
import java.util.Arrays; import java.util.Arrays;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class ReloadCommand extends BukkitCommand { public class ReloadCommand extends BukkitCommand {

Datei anzeigen

@ -21,7 +21,6 @@ public class SaveOffCommand extends VanillaCommand {
world.setAutoSave(false); world.setAutoSave(false);
} }
Command.broadcastCommandMessage(sender, "Disabled level saving.."); Command.broadcastCommandMessage(sender, "Disabled level saving..");
return true; return true;
} }

Datei anzeigen

@ -3,7 +3,6 @@ package org.bukkit.command.defaults;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class SayCommand extends VanillaCommand { public class SayCommand extends VanillaCommand {

Datei anzeigen

@ -3,6 +3,7 @@ package org.bukkit.command.defaults;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
@ -38,15 +39,17 @@ public class TeleportCommand extends VanillaCommand {
if (player == null) { if (player == null) {
sender.sendMessage("Player not found: " + args[0]); sender.sendMessage("Player not found: " + args[0]);
return true;
} }
if (args.length < 3) { if (args.length < 3) {
Player target = Bukkit.getPlayerExact(args[args.length - 1]); Player target = Bukkit.getPlayerExact(args[args.length - 1]);
if (target == null) { if (target == null) {
sender.sendMessage("Can't find user " + args[args.length - 1] + ". No tp."); sender.sendMessage("Can't find user " + args[args.length - 1] + ". No tp.");
return true;
} }
player.teleport(target, TeleportCause.COMMAND); 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) { } else if (player.getWorld() != null) {
int x = getInteger(sender, args[args.length - 3], -30000000, 30000000); int x = getInteger(sender, args[args.length - 3], -30000000, 30000000);
int y = getInteger(sender, args[args.length - 2], 0, 256); 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); Location location = new Location(player.getWorld(), x, y, z);
player.teleport(location); player.teleport(location);
sender.sendMessage("Teleported " + player.getName() + " to " + x + "," + y + "," + z); Command.broadcastCommandMessage(sender, "Teleported " + player.getName() + " to " + + x + "," + y + "," + z);
} }
return true; return true;
} }

Datei anzeigen

@ -39,7 +39,6 @@ public class TellCommand extends VanillaCommand {
if (sender instanceof ConsoleCommandSender) { if (sender instanceof ConsoleCommandSender) {
Bukkit.getLogger().info("[" + sender.getName() + "->" + player.getName() + "] " + message); Bukkit.getLogger().info("[" + sender.getName() + "->" + player.getName() + "] " + message);
Bukkit.getLogger().info(result);
} }
player.sendMessage(result); player.sendMessage(result);