Extract CommandSender to CommandSource, this should prevent Ess user object leaks.

This commit is contained in:
KHobbits 2013-10-16 20:59:39 +01:00
parent cf9d79d24c
commit 6f85761f7f
145 changed files with 1848 additions and 590 deletions

View file

@ -1,9 +1,9 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
@ -16,7 +16,7 @@ public class Commandkill extends EssentialsLoopCommand
}
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
@ -27,16 +27,16 @@ public class Commandkill extends EssentialsLoopCommand
}
@Override
protected void updatePlayer(final Server server, final CommandSender sender, final User user, final String[] args) throws PlayerExemptException
protected void updatePlayer(final Server server, final CommandSource sender, final User user, final String[] args) throws PlayerExemptException
{
final Player matchPlayer = user.getBase();
if (sender instanceof Player && user.isAuthorized("essentials.kill.exempt") && !ess.getUser(sender).isAuthorized("essentials.kill.force"))
if (sender.isPlayer() && user.isAuthorized("essentials.kill.exempt") && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.kill.force"))
{
throw new PlayerExemptException(_("killExempt", matchPlayer.getDisplayName()));
}
final EntityDamageEvent ede = new EntityDamageEvent(matchPlayer, sender instanceof Player && ((Player)sender).getName().equals(matchPlayer.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, Short.MAX_VALUE);
server.getPluginManager().callEvent(ede);
if (ede.isCancelled() && sender instanceof Player && !ess.getUser(sender).isAuthorized("essentials.kill.force"))
if (ede.isCancelled() && sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.kill.force"))
{
return;
}