More cleanup

This commit is contained in:
KHobbits 2013-07-07 13:02:40 +01:00
parent 3d29248ace
commit 1abacf00df
32 changed files with 83 additions and 78 deletions

View File

@ -222,10 +222,10 @@ public class EssentialsPlayerListener implements Listener
{
try
{
final IText input = new TextInput(user, "motd", true, ess);
final IText output = new KeywordReplacer(input, user, ess);
final IText input = new TextInput(user.getBase(), "motd", true, ess);
final IText output = new KeywordReplacer(input, user.getBase(), ess);
final TextPager pager = new TextPager(output, true);
pager.showPage("1", null, "motd", user);
pager.showPage("1", null, "motd", user.getBase());
}
catch (IOException ex)
{

View File

@ -10,7 +10,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public interface IUser extends CommandSender
public interface IUser
{
long getLastTeleportTimestamp();
@ -86,4 +86,8 @@ public interface IUser extends CommandSender
Map<String, Object> getConfigMap();
Map<String, Object> getConfigMap(String node);
public void sendMessage(String message);
public String getName();
}

View File

@ -169,7 +169,7 @@ public class Kit
try
{
IText input = new SimpleTextInput(items);
IText output = new KeywordReplacer(input, user, ess);
IText output = new KeywordReplacer(input, user.getBase(), ess);
boolean spew = false;
final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();

View File

@ -88,7 +88,7 @@ public class SpawnMob
{
throw new Exception(_("unableToSpawnMob"));
}
spawnmob(ess, server, user, user, block.getLocation(), parts, data, mobCount);
spawnmob(ess, server, user.getBase(), user, block.getLocation(), parts, data, mobCount);
}
// This method spawns a mob at loc, owned by noone

View File

@ -25,7 +25,7 @@ public class Commandclearinventory extends EssentialsCommand
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
parseCommand(server, user, args, user.isAuthorized("essentials.clearinventory.others"), user.isAuthorized("essentials.clearinventory.all"));
parseCommand(server, user.getBase(), args, user.isAuthorized("essentials.clearinventory.others"), user.isAuthorized("essentials.clearinventory.all"));
}
@Override
@ -39,9 +39,9 @@ public class Commandclearinventory extends EssentialsCommand
List<Player> players = new ArrayList<Player>();
int offset = 0;
if (sender instanceof User)
if (sender instanceof Player)
{
players.add(((User)sender).getBase());
players.add((Player)sender);
}
if (allowAll && args.length > 0 && args[0].contentEquals("*"))

View File

@ -63,7 +63,7 @@ public class Commandenchant extends EssentialsCommand
final MetaItemStack metaStack = new MetaItemStack(stack);
final Enchantment enchantment = metaStack.getEnchantment(user, args[0]);
metaStack.addEnchantment(user, allowUnsafe, enchantment, level);
metaStack.addEnchantment(user.getBase(), allowUnsafe, enchantment, level);
user.getInventory().setItemInHand(metaStack.getItemStack());
user.updateInventory();

View File

@ -23,28 +23,28 @@ public class Commandexp extends EssentialsCommand
{
if (args.length == 0)
{
showExp(user, user);
showExp(user.getBase(), user);
}
else if (args.length > 1 && args[0].equalsIgnoreCase("set") && user.isAuthorized("essentials.exp.set"))
{
if (args.length == 3 && user.isAuthorized("essentials.exp.set.others"))
{
expMatch(server, user, args[1], args[2], false);
expMatch(server, user.getBase(), args[1], args[2], false);
}
else
{
setExp(user, user, args[1], false);
setExp(user.getBase(), user, args[1], false);
}
}
else if (args.length > 1 && args[0].equalsIgnoreCase("give") && user.isAuthorized("essentials.exp.give"))
{
if (args.length == 3 && user.isAuthorized("essentials.exp.give.others"))
{
expMatch(server, user, args[1], args[2], true);
expMatch(server, user.getBase(), args[1], args[2], true);
}
else
{
setExp(user, user, args[1], true);
setExp(user.getBase(), user, args[1], true);
}
}
else if (args[0].equalsIgnoreCase("show"))
@ -52,11 +52,11 @@ public class Commandexp extends EssentialsCommand
if (args.length >= 2 && user.isAuthorized("essentials.exp.others"))
{
String match = args[1].trim();
showMatch(server, user, match);
showMatch(server, user.getBase(), match);
}
else
{
showExp(user, user);
showExp(user.getBase(), user);
}
}
else
@ -65,21 +65,21 @@ public class Commandexp extends EssentialsCommand
{
if (args.length >= 2 && user.isAuthorized("essentials.exp.give.others"))
{
expMatch(server, user, args[1], args[0], true);
expMatch(server, user.getBase(), args[1], args[0], true);
}
else
{
setExp(user, user, args[0], true);
setExp(user.getBase(), user, args[0], true);
}
}
else if (args.length >= 1 && user.isAuthorized("essentials.exp.others"))
{
String match = args[0].trim();
showMatch(server, user, match);
showMatch(server, user.getBase(), match);
}
else
{
showExp(user, user);
showExp(user.getBase(), user);
}
}
}

View File

@ -41,7 +41,7 @@ public class Commandext extends EssentialsCommand
throw new PlayerNotFoundException();
}
extinguishPlayers(server, user, args[0]);
extinguishPlayers(server, user.getBase(), args[0]);
}
private void extinguishPlayers(final Server server, final CommandSender sender, final String name) throws Exception

View File

@ -29,7 +29,7 @@ public class Commandfeed extends EssentialsCommand
{
user.healCooldown();
}
feedOtherPlayers(server, user, args[0]);
feedOtherPlayers(server, user.getBase(), args[0]);
return;
}
@ -39,7 +39,7 @@ public class Commandfeed extends EssentialsCommand
}
try
{
feedPlayer(user, user.getBase());
feedPlayer(user.getBase(), user.getBase());
}
catch (QuietAbortException e)
{

View File

@ -113,7 +113,7 @@ public class Commandfirework extends EssentialsCommand
{
try
{
mStack.addFireworkMeta(user, true, arg, ess);
mStack.addFireworkMeta(user.getBase(), true, arg, ess);
}
catch (Exception e)
{

View File

@ -27,20 +27,20 @@ public class Commandfly extends EssentialsToggleCommand
Boolean toggle = matchToggleArgument(args[0]);
if (toggle == null && user.isAuthorized(othersPermission))
{
toggleOtherPlayers(server, user, args);
toggleOtherPlayers(server, user.getBase(), args);
}
else
{
togglePlayer(user, user, toggle);
togglePlayer(user.getBase(), user, toggle);
}
}
else if (args.length == 2 && user.isAuthorized(othersPermission))
{
toggleOtherPlayers(server, user, args);
toggleOtherPlayers(server, user.getBase(), args);
}
else
{
togglePlayer(user, user, null);
togglePlayer(user.getBase(), user, null);
}
}

View File

@ -49,7 +49,7 @@ public class Commandgamemode extends EssentialsCommand
else if (args.length > 1 && args[1].trim().length() > 2 && user.isAuthorized("essentials.gamemode.others"))
{
gameMode = matchGameMode(args[0].toLowerCase(Locale.ENGLISH));
gamemodeOtherPlayers(server, user, gameMode, args[1]);
gamemodeOtherPlayers(server, user.getBase(), gameMode, args[1]);
return;
}
else
@ -63,7 +63,7 @@ public class Commandgamemode extends EssentialsCommand
if (user.isAuthorized("essentials.gamemode.others"))
{
gameMode = matchGameMode(commandLabel);
gamemodeOtherPlayers(server, user, gameMode, args[0]);
gamemodeOtherPlayers(server, user.getBase(), gameMode, args[0]);
return;
}
throw new NotEnoughArgumentsException();

View File

@ -20,10 +20,10 @@ public class Commandgetpos extends EssentialsCommand
if (args.length > 0 && user.isAuthorized("essentials.getpos.others"))
{
final User otherUser = getPlayer(server, user, args, 0);
outputPosition(user, otherUser.getLocation(), user.getLocation());
outputPosition(user.getBase(), otherUser.getLocation(), user.getLocation());
return;
}
outputPosition(user, user.getLocation(), null);
outputPosition(user.getBase(), user.getLocation(), null);
}
@Override

View File

@ -27,20 +27,20 @@ public class Commandgod extends EssentialsToggleCommand
Boolean toggle = matchToggleArgument(args[0]);
if (toggle == null && user.isAuthorized(othersPermission))
{
toggleOtherPlayers(server, user, args);
toggleOtherPlayers(server, user.getBase(), args);
}
else
{
togglePlayer(user, user, toggle);
togglePlayer(user.getBase(), user, toggle);
}
}
else if (args.length == 2 && user.isAuthorized(othersPermission))
{
toggleOtherPlayers(server, user, args);
toggleOtherPlayers(server, user.getBase(), args);
}
else
{
togglePlayer(user, user, null);
togglePlayer(user.getBase(), user, null);
}
}

View File

@ -32,7 +32,7 @@ public class Commandheal extends EssentialsCommand
{
user.healCooldown();
}
healOtherPlayers(server, user, args[0]);
healOtherPlayers(server, user.getBase(), args[0]);
return;
}

View File

@ -23,7 +23,7 @@ public class Commandhelp extends EssentialsCommand
String pageStr = args.length > 0 ? args[0] : null;
String chapterPageStr = args.length > 1 ? args[1] : null;
String command = commandLabel;
final IText input = new TextInput(user, "help", false, ess);
final IText input = new TextInput(user.getBase(), "help", false, ess);
if (input.getLines().isEmpty())
{
@ -45,10 +45,10 @@ public class Commandhelp extends EssentialsCommand
}
else
{
output = new KeywordReplacer(input, user, ess);
output = new KeywordReplacer(input, user.getBase(), ess);
}
final TextPager pager = new TextPager(output);
pager.showPage(pageStr, chapterPageStr, command, user);
pager.showPage(pageStr, chapterPageStr, command, user.getBase());
}
@Override

View File

@ -20,7 +20,7 @@ public class Commandhelpop extends EssentialsCommand
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
user.setDisplayNick();
sendMessage(server, user, user.getDisplayName(), args);
sendMessage(server, user.getBase(), user.getDisplayName(), args);
}
@Override

View File

@ -60,7 +60,7 @@ public class Commanditem extends EssentialsCommand
MetaItemStack metaStack = new MetaItemStack(stack);
final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments() && user.isAuthorized("essentials.enchantments.allowunsafe");
metaStack.parseStringMeta(user, allowUnsafe, args, 2, ess);
metaStack.parseStringMeta(user.getBase(), allowUnsafe, args, 2, ess);
stack = metaStack.getItemStack();
}

View File

@ -69,7 +69,7 @@ public class Commandpotion extends EssentialsCommand
final MetaItemStack mStack = new MetaItemStack(stack);
for (String arg : args)
{
mStack.addPotionMeta(user, true, arg, ess);
mStack.addPotionMeta(user.getBase(), true, arg, ess);
}
if (mStack.completePotion())
{

View File

@ -24,7 +24,7 @@ public class Commandpowertool extends EssentialsCommand
{
final String command = getFinalArg(args, 0);
final ItemStack itemStack = user.getItemInHand();
powertool(server, user, user, commandLabel, itemStack, command);
powertool(server, user.getBase(), user, commandLabel, itemStack, command);
}
@Override

View File

@ -30,7 +30,7 @@ public class Commandseen extends EssentialsCommand
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
seen(server, user, args, user.isAuthorized("essentials.seen.banreason"), user.isAuthorized("essentials.seen.extra"), user.isAuthorized("essentials.seen.ipsearch"));
seen(server, user.getBase(), args, user.isAuthorized("essentials.seen.banreason"), user.isAuthorized("essentials.seen.extra"), user.isAuthorized("essentials.seen.ipsearch"));
}
protected void seen(final Server server, final CommandSender sender, final String[] args, final boolean showBan, final boolean extra, final boolean ipLookup) throws Exception

View File

@ -27,20 +27,20 @@ public class Commandsocialspy extends EssentialsToggleCommand
Boolean toggle = matchToggleArgument(args[0]);
if (toggle == null && user.isAuthorized(othersPermission))
{
toggleOtherPlayers(server, user, args);
toggleOtherPlayers(server, user.getBase(), args);
}
else
{
togglePlayer(user, user, toggle);
togglePlayer(user.getBase(), user, toggle);
}
}
else if (args.length == 2 && user.isAuthorized(othersPermission))
{
toggleOtherPlayers(server, user, args);
toggleOtherPlayers(server, user.getBase(), args);
}
else
{
togglePlayer(user, user, null);
togglePlayer(user.getBase(), user, null);
}
}

View File

@ -43,7 +43,7 @@ public class Commandspawnmob extends EssentialsCommand
if (args.length >= 3)
{
final User target = getPlayer(ess.getServer(), user, args, 2);
SpawnMob.spawnmob(ess, server, user, target, mobParts, mobData, mobCount);
SpawnMob.spawnmob(ess, server, user.getBase(), target, mobParts, mobData, mobCount);
return;
}

View File

@ -53,7 +53,7 @@ public class Commandspeed extends EssentialsCommand
{
throw new PlayerNotFoundException();
}
speedOtherPlayers(server, user, isFly, isBypass, speed, args[2]);
speedOtherPlayers(server, user.getBase(), isFly, isBypass, speed, args[2]);
return;
}
}

View File

@ -69,7 +69,7 @@ public class Commandtpaccept extends EssentialsCommand
catch (Exception ex)
{
user.sendMessage(_("pendingTeleportCancelled"));
ess.showError(target, ex, commandLabel);
ess.showError(target.getBase(), ex, commandLabel);
}
user.requestTeleport(null, false);
throw new NoChargeException();

View File

@ -27,20 +27,20 @@ public class Commandtptoggle extends EssentialsToggleCommand
Boolean toggle = matchToggleArgument(args[0]);
if (toggle == null && user.isAuthorized(othersPermission))
{
toggleOtherPlayers(server, user, args);
toggleOtherPlayers(server, user.getBase(), args);
}
else
{
togglePlayer(user, user, toggle);
togglePlayer(user.getBase(), user, toggle);
}
}
else if (args.length == 2 && user.isAuthorized(othersPermission))
{
toggleOtherPlayers(server, user, args);
toggleOtherPlayers(server, user.getBase(), args);
}
else
{
togglePlayer(user, user, null);
togglePlayer(user.getBase(), user, null);
}
}

View File

@ -1,6 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IUser;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.StringUtil;
@ -34,7 +35,7 @@ public class Commandwarp extends EssentialsCommand
{
throw new Exception(_("warpListPermission"));
}
warpList(user, args);
warpList(user.getBase(), args, user);
throw new NoChargeException();
}
if (args.length > 0)
@ -57,7 +58,7 @@ public class Commandwarp extends EssentialsCommand
{
if (args.length < 2 || NumberUtil.isInt(args[0]))
{
warpList(sender, args);
warpList(sender, args, null);
throw new NoChargeException();
}
User otherUser = getPlayer(server, args, 1, true, false);
@ -67,7 +68,7 @@ public class Commandwarp extends EssentialsCommand
}
//TODO: Use one of the new text classes, like /help ?
private void warpList(final CommandSender sender, final String[] args) throws Exception
private void warpList(final CommandSender sender, final String[] args, final IUser user) throws Exception
{
final IWarps warps = ess.getWarps();
if (warps.isEmpty())
@ -76,13 +77,13 @@ public class Commandwarp extends EssentialsCommand
}
final List<String> warpNameList = new ArrayList<String>(warps.getList());
if (sender instanceof User)
if (user != null)
{
final Iterator<String> iterator = warpNameList.iterator();
while (iterator.hasNext())
{
final String warpName = iterator.next();
if (ess.getSettings().getPerWarpPermission() && !((User)sender).isAuthorized("essentials.warps." + warpName))
if (ess.getSettings().getPerWarpPermission() && !user.isAuthorized("essentials.warps." + warpName))
{
iterator.remove();
}

View File

@ -50,11 +50,11 @@ public class EssentialsSign
}
catch (ChargeException ex)
{
ess.showError(user, ex, signName);
ess.showError(user.getBase(), ex, signName);
}
catch (SignException ex)
{
ess.showError(user, ex, signName);
ess.showError(user.getBase(), ex, signName);
}
// Return true, so the player sees the wrong sign.
return true;
@ -96,12 +96,12 @@ public class EssentialsSign
}
catch (ChargeException ex)
{
ess.showError(user, ex, signName);
ess.showError(user.getBase(), ex, signName);
return false;
}
catch (SignException ex)
{
ess.showError(user, ex, signName);
ess.showError(user.getBase(), ex, signName);
return false;
}
}
@ -118,7 +118,7 @@ public class EssentialsSign
}
catch (SignException ex)
{
ess.showError(user, ex, signName);
ess.showError(user.getBase(), ex, signName);
return false;
}
}
@ -147,11 +147,11 @@ public class EssentialsSign
}
catch (ChargeException ex)
{
ess.showError(user, ex, signName);
ess.showError(user.getBase(), ex, signName);
}
catch (SignException ex)
{
ess.showError(user, ex, signName);
ess.showError(user.getBase(), ex, signName);
}
return false;
}
@ -165,11 +165,11 @@ public class EssentialsSign
}
catch (ChargeException ex)
{
ess.showError(user, ex, signName);
ess.showError(user.getBase(), ex, signName);
}
catch (SignException ex)
{
ess.showError(user, ex, signName);
ess.showError(user.getBase(), ex, signName);
}
return false;
}
@ -183,7 +183,7 @@ public class EssentialsSign
}
catch (SignException ex)
{
ess.showError(user, ex, signName);
ess.showError(user.getBase(), ex, signName);
}
return false;
}

View File

@ -37,10 +37,10 @@ public class SignInfo extends EssentialsSign
final IText input;
try
{
input = new TextInput(player, "info", true, ess);
final IText output = new KeywordReplacer(input, player, ess);
input = new TextInput(player.getBase(), "info", true, ess);
final IText output = new KeywordReplacer(input, player.getBase(), ess);
final TextPager pager = new TextPager(output);
pager.showPage(chapter, page, null, player);
pager.showPage(chapter, page, null, player.getBase());
}
catch (IOException ex)

View File

@ -29,7 +29,7 @@ public class SignSpawnmob extends EssentialsSign
{
List<String> mobParts = SpawnMob.mobParts(sign.getLine(2));
List<String> mobData = SpawnMob.mobData(sign.getLine(2));
SpawnMob.spawnmob(ess, ess.getServer(), player, player, mobParts, mobData, Integer.parseInt(sign.getLine(1)));
SpawnMob.spawnmob(ess, ess.getServer(), player.getBase(), player, mobParts, mobData, Integer.parseInt(sign.getLine(1)));
}
catch (Exception ex)
{

View File

@ -114,7 +114,7 @@ public abstract class EssentialsChatPlayer implements Listener
}
catch (ChargeException e)
{
ess.showError(chatStore.getUser(), e, chatStore.getLongType());
ess.showError(chatStore.getUser().getBase(), e, chatStore.getLongType());
event.setCancelled(true);
return false;
}

View File

@ -108,7 +108,7 @@ public class EssentialsSpawnPlayerListener implements Listener
//This method allows for multiple line player announce messages using multiline yaml syntax #EasterEgg
if (ess.getSettings().getAnnounceNewPlayers())
{
final IText output = new KeywordReplacer(ess.getSettings().getAnnounceNewPlayerFormat(), user, ess);
final IText output = new KeywordReplacer(ess.getSettings().getAnnounceNewPlayerFormat(), user.getBase(), ess);
final SimpleTextPager pager = new SimpleTextPager(output);
for (String line : pager.getLines())