Merge branch 'master' into release

This commit is contained in:
snowleo 2011-10-09 17:54:59 +02:00
commit 4595c15bee
5 changed files with 54 additions and 12 deletions

View File

@ -21,6 +21,7 @@ public final class Economy
}
private static final Logger logger = Logger.getLogger("Minecraft");
private static IEssentials ess;
private static final String noCallBeforeLoad = "Essentials API is called before Essentials is loaded.";
/**
* @param aEss the ess to set
@ -66,6 +67,10 @@ public final class Economy
private static User getUserByName(String name)
{
if (ess == null)
{
throw new RuntimeException(noCallBeforeLoad);
}
User user;
Player player = ess.getServer().getPlayer(name);
if (player != null)
@ -176,6 +181,10 @@ public final class Economy
*/
public static void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException
{
if (ess == null)
{
throw new RuntimeException(noCallBeforeLoad);
}
setMoney(name, ess.getSettings().getStartingBalance());
}
@ -231,6 +240,10 @@ public final class Economy
*/
public static String format(double amount)
{
if (ess == null)
{
throw new RuntimeException(noCallBeforeLoad);
}
return Util.formatCurrency(amount, ess);
}

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -13,14 +14,24 @@ public class Commandbanip 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();
}
ess.getServer().banIP(args[0]);
sender.sendMessage(Util.i18n("banIpAddress"));
final User u = ess.getUser(args[0]);
if (u == null)
{
ess.getServer().banIP(args[0]);
sender.sendMessage(Util.i18n("banIpAddress"));
}
else
{
ess.getServer().banIP(u.getAddress().getAddress().getHostAddress());
sender.sendMessage(Util.i18n("banIpAddress"));
}
}
}

View File

@ -4,6 +4,7 @@ import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
public class Commandkill extends EssentialsCommand
@ -23,6 +24,13 @@ public class Commandkill extends EssentialsCommand
for (Player p : server.matchPlayer(args[0]))
{
final EntityDamageEvent ede = new EntityDamageEvent(p, sender instanceof Player && ((Player)sender).getName().equals(p.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, 1000);
server.getPluginManager().callEvent(ede);
if (ede.isCancelled() && !sender.hasPermission("essentials.kill.force"))
{
continue;
}
p.setHealth(0);
sender.sendMessage(Util.format("kill", p.getDisplayName()));
}

View File

@ -10,7 +10,6 @@ import org.bukkit.inventory.ItemStack;
public class SignTrade extends EssentialsSign
{
public SignTrade()
{
super("Trade");
@ -40,11 +39,11 @@ public class SignTrade extends EssentialsSign
substractAmount(sign, 1, stored, ess);
stored.pay(player);
Trade.log("Sign", "Trade", "OwnerInteract", username, null, username, stored, sign.getBlock().getLocation(), ess);
}
}
catch (SignException e)
{
throw new SignException(Util.i18n("tradeSignEmptyOwner"));
}
}
}
else
{
@ -67,11 +66,22 @@ public class SignTrade extends EssentialsSign
if ((sign.getLine(3).length() > 3 && sign.getLine(3).substring(2).equalsIgnoreCase(username))
|| player.isAuthorized("essentials.signs.trade.override"))
{
final Trade stored1 = getTrade(sign, 1, true, false, ess);
final Trade stored2 = getTrade(sign, 2, true, false, ess);
stored1.pay(player);
stored2.pay(player);
Trade.log("Sign", "Trade", "Break", username, stored2, username, stored1, sign.getBlock().getLocation(), ess);
try
{
final Trade stored1 = getTrade(sign, 1, true, false, ess);
final Trade stored2 = getTrade(sign, 2, true, false, ess);
stored1.pay(player);
stored2.pay(player);
Trade.log("Sign", "Trade", "Break", username, stored2, username, stored1, sign.getBlock().getLocation(), ess);
}
catch (SignException e)
{
if (player.isAuthorized("essentials.signs.trade.override"))
{
return true;
}
throw e;
}
return true;
}
else

View File

@ -25,7 +25,7 @@ public class EssentialsChat extends JavaPlugin
chatListener = new HashMap<String, IEssentialsChatListener>();
final EssentialsChatPlayerListener playerListener = new EssentialsChatPlayerListener(getServer(), ess, chatListener);
pluginManager.registerEvent(Type.PLAYER_CHAT, playerListener, Priority.Highest, this);
pluginManager.registerEvent(Type.PLAYER_CHAT, playerListener, Priority.High, this);
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion()))
{
LOGGER.log(Level.WARNING, Util.i18n("versionMismatchAll"));