Generic cleanup of warnings, whitespace and style.

By: Erik Broes <erikbroes@grum.nl>
This commit is contained in:
Bukkit/Spigot
2011-12-25 16:02:30 +01:00
parent 98960fd73e
commit aaab1cba23
257 changed files with 1408 additions and 1152 deletions

View File

@@ -149,7 +149,6 @@ public abstract class Command {
return false;
}
private boolean allowChangesFrom(CommandMap commandMap) {
return (null == this.commandMap || this.commandMap == commandMap);
}
@@ -237,7 +236,7 @@ public abstract class Command {
for (Permissible user : users) {
if (user instanceof CommandSender) {
CommandSender target = (CommandSender)user;
CommandSender target = (CommandSender) user;
if (target instanceof ConsoleCommandSender) {
target.sendMessage(result);

View File

@@ -3,6 +3,7 @@ package org.bukkit.command;
/**
* Thrown when an unhandled exception occurs during the execution of a Command
*/
@SuppressWarnings("serial")
public class CommandException extends RuntimeException {
/**
@@ -12,6 +13,7 @@ public class CommandException extends RuntimeException {
/**
* Constructs an instance of <code>CommandException</code> with the specified detail message.
*
* @param msg the detail message.
*/
public CommandException(String msg) {

View File

@@ -1,4 +1,4 @@
package org.bukkit.command;
public interface ConsoleCommandSender extends CommandSender{
public interface ConsoleCommandSender extends CommandSender {
}

View File

@@ -1,4 +1,3 @@
package org.bukkit.command;
/**

View File

@@ -43,7 +43,7 @@ public final class PluginCommand extends Command {
}
if (!success && usageMessage.length() > 0) {
for (String line: usageMessage.replace("<command>", commandLabel).split("\n")) {
for (String line : usageMessage.replace("<command>", commandLabel).split("\n")) {
sender.sendMessage(line);
}
}

View File

@@ -1,4 +1,4 @@
package org.bukkit.command;
public interface RemoteConsoleCommandSender extends CommandSender{
public interface RemoteConsoleCommandSender extends CommandSender {
}

View File

@@ -79,7 +79,7 @@ public class SimpleCommandMap implements CommandMap {
public boolean register(String label, String fallbackPrefix, Command command) {
boolean registeredPassedLabel = register(label, fallbackPrefix, command, false);
Iterator iterator = command.getAliases().iterator();
Iterator<String> iterator = command.getAliases().iterator();
while (iterator.hasNext()) {
if (!register((String) iterator.next(), fallbackPrefix, command, true)) {
iterator.remove();
@@ -94,12 +94,13 @@ public class SimpleCommandMap implements CommandMap {
/**
* Registers a command with the given name is possible, otherwise uses fallbackPrefix to create a unique name if its not an alias
*
* @param name the name of the command, without the '/'-prefix.
* @param fallbackPrefix a prefix which is prepended to the command with a ':' one or more times to make the command unique
* @param command the command to register
* @return true if command was registered with the passed in label, false otherwise.
* If isAlias was true a return of false indicates no command was registerd
* If isAlias was false a return of false indicates the fallbackPrefix was used one or more times to create a unique name for the command
* If isAlias was true a return of false indicates no command was registerd
* If isAlias was false a return of false indicates the fallbackPrefix was used one or more times to create a unique name for the command
*/
private synchronized boolean register(String label, String fallbackPrefix, Command command, boolean isAlias) {
String lowerLabel = label.trim().toLowerCase();

View File

@@ -29,7 +29,7 @@ public class DeopCommand extends VanillaCommand {
player.setOp(false);
if (player instanceof Player) {
((Player)player).sendMessage(ChatColor.YELLOW + "You are no longer op!");
((Player) player).sendMessage(ChatColor.YELLOW + "You are no longer op!");
}
return true;

View File

@@ -28,7 +28,7 @@ public class ExpCommand extends VanillaCommand {
try {
int exp = Integer.parseInt(args[1]);
Command.broadcastCommandMessage(sender, "Giving " + exp + " exp to " + player.getName());
Command.broadcastCommandMessage(sender, "Giving " + exp + " exp to " + player.getName());
player.giveExp(exp);
} catch (NumberFormatException ex) {

View File

@@ -18,7 +18,7 @@ public class KillCommand extends VanillaCommand {
if (!testPermission(sender)) return true;
if (sender instanceof Player) {
Player player = (Player)sender;
Player player = (Player) sender;
EntityDamageEvent ede = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.SUICIDE, 1000);
Bukkit.getPluginManager().callEvent(ede);

View File

@@ -23,10 +23,10 @@ public class MeCommand extends VanillaCommand {
StringBuilder message = new StringBuilder();
message.append(sender.getName());
if (args.length > 0) {
for (int i = 0; i < args.length; i++) {
message.append(" ");
message.append(args[i]);
}
for (String arg : args) {
message.append(" ");
message.append(arg);
}
}
Bukkit.broadcastMessage("* " + message.toString());

View File

@@ -29,7 +29,7 @@ public class OpCommand extends VanillaCommand {
player.setOp(true);
if (player instanceof Player) {
((Player)player).sendMessage(ChatColor.YELLOW + "You are now op!");
((Player) player).sendMessage(ChatColor.YELLOW + "You are now op!");
}
return true;

View File

@@ -19,7 +19,7 @@ public class PluginsCommand extends Command {
@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
if (!testPermission(sender)) return true;
sender.sendMessage("Plugins: " + getPluginList());
return true;
}
@@ -27,13 +27,13 @@ public class PluginsCommand extends Command {
private String getPluginList() {
StringBuilder pluginList = new StringBuilder();
Plugin[] plugins = Bukkit.getPluginManager().getPlugins();
for (Plugin plugin : plugins) {
if (pluginList.length() > 0) {
pluginList.append(ChatColor.WHITE);
pluginList.append(", ");
}
pluginList.append(plugin.isEnabled() ? ChatColor.GREEN : ChatColor.RED);
pluginList.append(plugin.getDescription().getName());
}

View File

@@ -23,11 +23,11 @@ public class SayCommand extends VanillaCommand {
StringBuilder message = new StringBuilder();
if (args.length > 0) {
message.append(args[0]);
for (int i = 1; i < args.length; i++) {
message.append(" ");
message.append(args[i]);
}
message.append(args[0]);
for (int i = 1; i < args.length; i++) {
message.append(" ");
message.append(args[i]);
}
}
if (!(sender instanceof ConsoleCommandSender)) {

View File

@@ -15,7 +15,7 @@ public class TimeCommand extends VanillaCommand {
@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
if (args.length != 2) {
if (args.length != 2) {
sender.sendMessage(ChatColor.RED + "Incorrect usage. Correct usage:\n" + usageMessage);
return false;
}

View File

@@ -29,7 +29,7 @@ public class ToggleDownfallCommand extends VanillaCommand {
return true;
}
} else if (sender instanceof Player) {
world = ((Player)sender).getWorld();
world = ((Player) sender).getWorld();
} else {
world = Bukkit.getWorlds().get(0);
}

View File

@@ -12,7 +12,7 @@ import org.bukkit.plugin.PluginDescriptionFile;
public class VersionCommand extends Command {
public VersionCommand(String name) {
super(name);
this.description = "Gets the version of this server including any plugins in use";
this.usageMessage = "/version [plugin name]";
this.setPermission("bukkit.command.version");
@@ -22,7 +22,7 @@ public class VersionCommand extends Command {
@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
if (!testPermission(sender)) return true;
if (args.length == 0) {
sender.sendMessage("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")");
} else {
@@ -32,7 +32,7 @@ public class VersionCommand extends Command {
if (name.length() > 0) {
name.append(' ');
}
name.append(arg);
}
@@ -83,7 +83,7 @@ public class VersionCommand extends Command {
result.append(ChatColor.GREEN);
result.append(authors.get(i));
}
return result.toString();
}
}