From 2dc6f8c20236dfa76b09bd4bd9e522cd0d1c354b Mon Sep 17 00:00:00 2001 From: KHobbits Date: Thu, 1 Dec 2011 13:42:39 +0000 Subject: Command Cleanup --- .../src/com/earth2me/essentials/EssentialsConf.java | 1 - .../earth2me/essentials/EssentialsPlayerListener.java | 2 +- .../src/com/earth2me/essentials/OfflinePlayer.java | 1 - Essentials/src/com/earth2me/essentials/Settings.java | 8 +------- Essentials/src/com/earth2me/essentials/UserMap.java | 2 -- .../com/earth2me/essentials/commands/Commandenchant.java | 8 ++------ .../src/com/earth2me/essentials/commands/Commandr.java | 16 ++++++++-------- .../earth2me/essentials/commands/Commandrealname.java | 6 +++--- .../com/earth2me/essentials/commands/Commandrules.java | 2 +- .../com/earth2me/essentials/commands/Commandseen.java | 2 +- .../com/earth2me/essentials/commands/Commandsell.java | 2 +- .../com/earth2me/essentials/commands/Commandsethome.java | 2 +- .../com/earth2me/essentials/commands/Commandsetjail.java | 2 +- .../com/earth2me/essentials/commands/Commandsetwarp.java | 4 ++-- .../earth2me/essentials/commands/Commandsetworth.java | 2 +- .../earth2me/essentials/commands/Commandsocialspy.java | 2 +- .../com/earth2me/essentials/commands/Commandspawner.java | 3 +-- .../earth2me/essentials/commands/Commandspawnmob.java | 10 +++++----- .../earth2me/essentials/storage/BukkitConstructor.java | 6 +----- .../earth2me/essentials/storage/YamlStorageReader.java | 1 + .../earth2me/essentials/storage/YamlStorageWriter.java | 1 + .../src/com/earth2me/essentials/userdata/UserData.java | 7 +------ 22 files changed, 34 insertions(+), 56 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsConf.java b/Essentials/src/com/earth2me/essentials/EssentialsConf.java index 8b8b79279..c47161135 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsConf.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsConf.java @@ -2,7 +2,6 @@ package com.earth2me.essentials; import static com.earth2me.essentials.I18n._; import java.io.*; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Locale; diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index ad7a396d7..f4b3a595a 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -1,8 +1,8 @@ package com.earth2me.essentials; +import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.craftbukkit.EnchantmentFix; import com.earth2me.essentials.craftbukkit.SetBed; -import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.textreader.IText; import com.earth2me.essentials.textreader.KeywordReplacer; import com.earth2me.essentials.textreader.TextInput; diff --git a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java index deccf6516..d8c871b5b 100644 --- a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java +++ b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java @@ -4,7 +4,6 @@ import static com.earth2me.essentials.I18n._; import java.net.InetSocketAddress; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Set; import java.util.UUID; import lombok.Delegate; diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index 42f6764b3..ac74329ec 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -3,13 +3,7 @@ package com.earth2me.essentials; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.commands.IEssentialsCommand; import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.ChatColor; diff --git a/Essentials/src/com/earth2me/essentials/UserMap.java b/Essentials/src/com/earth2me/essentials/UserMap.java index 708494296..25f8c0c0e 100644 --- a/Essentials/src/com/earth2me/essentials/UserMap.java +++ b/Essentials/src/com/earth2me/essentials/UserMap.java @@ -10,8 +10,6 @@ import java.util.Collections; import java.util.Locale; import java.util.Set; import java.util.concurrent.ExecutionException; -import java.util.logging.Level; -import java.util.logging.Logger; import org.bukkit.entity.Player; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java b/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java index 3ef886347..22462cea0 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java @@ -1,18 +1,14 @@ package com.earth2me.essentials.commands; +import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; import com.earth2me.essentials.craftbukkit.EnchantmentFix; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; +import java.util.*; import java.util.regex.Pattern; import org.bukkit.Server; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; -import static com.earth2me.essentials.I18n._; public class Commandenchant extends EssentialsCommand diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandr.java b/Essentials/src/com/earth2me/essentials/commands/Commandr.java index c53ef1bf0..1da198444 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandr.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandr.java @@ -17,18 +17,18 @@ public class Commandr extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } - String message = getFinalArg(args, 0); - IReplyTo replyTo = sender instanceof Player ? ess.getUser((Player)sender) : Console.getConsoleReplyTo(); - String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME; - CommandSender target = replyTo.getReplyTo(); - String targetName = target instanceof Player ? ((Player)target).getDisplayName() : Console.NAME; + final String message = getFinalArg(args, 0); + final IReplyTo replyTo = sender instanceof Player ? ess.getUser((Player)sender) : Console.getConsoleReplyTo(); + final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME; + final CommandSender target = replyTo.getReplyTo(); + final String targetName = target instanceof Player ? ((Player)target).getDisplayName() : Console.NAME; if (target == null) { @@ -38,8 +38,8 @@ public class Commandr extends EssentialsCommand sender.sendMessage(_("msgFormat", _("me"), targetName, message)); if (target instanceof Player) { - User u = ess.getUser(target); - if (u.isIgnoredPlayer(sender instanceof Player ? ((Player)sender).getName() : Console.NAME)) + User player = ess.getUser(target); + if (player.isIgnoredPlayer(sender instanceof Player ? ((Player)sender).getName() : Console.NAME)) { return; } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java b/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java index d3d82860d..6266b5178 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java @@ -17,16 +17,16 @@ public class Commandrealname extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } final String whois = args[0].toLowerCase(Locale.ENGLISH); - for (Player p : server.getOnlinePlayers()) + for (Player onlinePlayer : server.getOnlinePlayers()) { - final User u = ess.getUser(p); + final User u = ess.getUser(onlinePlayer); if (u.isHidden()) { continue; diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrules.java b/Essentials/src/com/earth2me/essentials/commands/Commandrules.java index a981fb2f1..d87c4f41b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandrules.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrules.java @@ -16,7 +16,7 @@ public class Commandrules extends EssentialsCommand } @Override - public void run(final Server server, final CommandSender sender, final String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { final IText input = new TextInput(sender, "rules", true, ess); final IText output = new KeywordReplacer(input, sender, ess); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java index 391ed36b3..49e39876e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java @@ -15,7 +15,7 @@ public class Commandseen extends EssentialsCommand } @Override - protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java index 554bb4a2e..f0e1cb150 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java @@ -20,7 +20,7 @@ public class Commandsell extends EssentialsCommand } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java b/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java index 6d05e4e3e..e7687fcfd 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java @@ -14,7 +14,7 @@ public class Commandsethome extends EssentialsCommand } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, String[] args) throws Exception { if (args.length > 0) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java index 506829ad9..a4d6c4ba7 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java @@ -13,7 +13,7 @@ public class Commandsetjail extends EssentialsCommand } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java index 77bbee7c0..bf5c11abe 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java @@ -14,14 +14,14 @@ public class Commandsetwarp extends EssentialsCommand } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } - Location loc = user.getLocation(); + final Location loc = user.getLocation(); ess.getWarps().setWarp(args[0], loc); user.sendMessage(_("warpSet", args[0])); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java index 3f80fddf1..1d236b70a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java @@ -14,7 +14,7 @@ public class Commandsetworth extends EssentialsCommand } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { if (args.length < 2) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java b/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java index b7ce4edcb..6080642a1 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java @@ -13,7 +13,7 @@ public class Commandsocialspy extends EssentialsCommand } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { user.sendMessage("ยง7SocialSpy " + (user.toggleSocialSpy() ? _("enabled") : _("disabled"))); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java index e3b1ef366..73c86eba4 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java @@ -8,7 +8,6 @@ import java.util.Locale; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Server; -import org.bukkit.block.Block; import org.bukkit.block.CreatureSpawner; @@ -20,7 +19,7 @@ public class Commandspawner extends EssentialsCommand } @Override - protected void run(Server server, User user, String commandLabel, String[] args) throws Exception + protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { if (args.length < 1 || args[0].length() < 2) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java index d42437368..2c1466167 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java @@ -22,7 +22,7 @@ public class Commandspawnmob extends EssentialsCommand } @Override - public void run(Server server, User user, String commandLabel, String[] args) throws Exception + public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { @@ -30,7 +30,7 @@ public class Commandspawnmob extends EssentialsCommand } - String[] mountparts = args[0].split(","); + final String[] mountparts = args[0].split(","); String[] parts = mountparts[0].split(":"); String mobType = parts[0]; String mobData = null; @@ -76,8 +76,8 @@ public class Commandspawnmob extends EssentialsCommand { throw new Exception(_("unableToSpawnMob")); } - Location loc = block.getLocation(); - Location sloc = Util.getSafeDestination(loc); + final Location loc = block.getLocation(); + final Location sloc = Util.getSafeDestination(loc); try { spawnedMob = mob.spawn(user, server, sloc); @@ -179,7 +179,7 @@ public class Commandspawnmob extends EssentialsCommand } } - private void changeMobData(CreatureType type, Entity spawned, String data, User user) throws Exception + private void changeMobData(final CreatureType type, final Entity spawned, final String data, final User user) throws Exception { if (type == CreatureType.SLIME || type == CreatureType.MAGMA_CUBE) { diff --git a/Essentials/src/com/earth2me/essentials/storage/BukkitConstructor.java b/Essentials/src/com/earth2me/essentials/storage/BukkitConstructor.java index 7ed12b6d5..c3cd9a022 100644 --- a/Essentials/src/com/earth2me/essentials/storage/BukkitConstructor.java +++ b/Essentials/src/com/earth2me/essentials/storage/BukkitConstructor.java @@ -10,11 +10,7 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.material.MaterialData; import org.yaml.snakeyaml.constructor.Constructor; -import org.yaml.snakeyaml.nodes.MappingNode; -import org.yaml.snakeyaml.nodes.Node; -import org.yaml.snakeyaml.nodes.NodeId; -import org.yaml.snakeyaml.nodes.NodeTuple; -import org.yaml.snakeyaml.nodes.ScalarNode; +import org.yaml.snakeyaml.nodes.*; public class BukkitConstructor extends Constructor diff --git a/Essentials/src/com/earth2me/essentials/storage/YamlStorageReader.java b/Essentials/src/com/earth2me/essentials/storage/YamlStorageReader.java index 2881c1f18..321f5fc3c 100644 --- a/Essentials/src/com/earth2me/essentials/storage/YamlStorageReader.java +++ b/Essentials/src/com/earth2me/essentials/storage/YamlStorageReader.java @@ -22,6 +22,7 @@ public class YamlStorageReader implements IStorageReader this.reader = reader; } + @Override public T load(final Class clazz) { Yaml yaml = preparedYamls.get(clazz); diff --git a/Essentials/src/com/earth2me/essentials/storage/YamlStorageWriter.java b/Essentials/src/com/earth2me/essentials/storage/YamlStorageWriter.java index 48540483d..fd1f0f863 100644 --- a/Essentials/src/com/earth2me/essentials/storage/YamlStorageWriter.java +++ b/Essentials/src/com/earth2me/essentials/storage/YamlStorageWriter.java @@ -30,6 +30,7 @@ public class YamlStorageWriter implements IStorageWriter this.writer = writer; } + @Override public void save(final StorageObject object) { try diff --git a/Essentials/src/com/earth2me/essentials/userdata/UserData.java b/Essentials/src/com/earth2me/essentials/userdata/UserData.java index bce62f5fa..fe537cae8 100644 --- a/Essentials/src/com/earth2me/essentials/userdata/UserData.java +++ b/Essentials/src/com/earth2me/essentials/userdata/UserData.java @@ -4,12 +4,7 @@ import com.earth2me.essentials.storage.ListType; import com.earth2me.essentials.storage.MapKeyType; import com.earth2me.essentials.storage.MapValueType; import com.earth2me.essentials.storage.StorageObject; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import lombok.Data; import lombok.EqualsAndHashCode; import org.bukkit.Location; -- cgit v1.2.3