Command Cleanup

This commit is contained in:
KHobbits 2011-12-01 13:42:39 +00:00
parent a8a9fc3dd6
commit 2dc6f8c202
22 changed files with 34 additions and 56 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;
}

View File

@ -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;

View File

@ -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);

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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]));
}

View File

@ -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)
{

View File

@ -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")));
}

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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

View File

@ -22,6 +22,7 @@ public class YamlStorageReader implements IStorageReader
this.reader = reader;
}
@Override
public <T extends StorageObject> T load(final Class<? extends T> clazz)
{
Yaml yaml = preparedYamls.get(clazz);

View File

@ -30,6 +30,7 @@ public class YamlStorageWriter implements IStorageWriter
this.writer = writer;
}
@Override
public void save(final StorageObject object)
{
try

View File

@ -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;