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,5 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.UserMap;
@ -10,8 +11,6 @@ import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandseen extends EssentialsCommand
@ -22,7 +21,7 @@ public class Commandseen extends EssentialsCommand
}
@Override
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception
{
seen(server, sender, args, true, true, true);
}
@ -30,10 +29,10 @@ 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.getBase(), args, user.isAuthorized("essentials.seen.banreason"), user.isAuthorized("essentials.seen.extra"), user.isAuthorized("essentials.seen.ipsearch"));
seen(server, user.getSource(), 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
protected void seen(final Server server, final CommandSource sender, final String[] args, final boolean showBan, final boolean extra, final boolean ipLookup) throws Exception
{
if (args.length < 1)
{
@ -67,7 +66,7 @@ public class Commandseen extends EssentialsCommand
}
}
private void seenOnline(final Server server, final CommandSender sender, final User user, final boolean showBan, final boolean extra) throws Exception
private void seenOnline(final Server server, final CommandSource sender, final User user, final boolean showBan, final boolean extra) throws Exception
{
user.setDisplayNick();
@ -89,7 +88,7 @@ public class Commandseen extends EssentialsCommand
: _("true"))));
}
final String location = user.getGeoLocation();
if (location != null && (!(sender instanceof Player) || ess.getUser(sender).isAuthorized("essentials.geoip.show")))
if (location != null && (!(sender.isPlayer()) || ess.getUser(sender.getPlayer()).isAuthorized("essentials.geoip.show")))
{
sender.sendMessage(_("whoisGeoLocation", location));
}
@ -99,7 +98,7 @@ public class Commandseen extends EssentialsCommand
}
}
private void seenOffline(final Server server, final CommandSender sender, User user, final boolean showBan, final boolean extra) throws Exception
private void seenOffline(final Server server, final CommandSource sender, User user, final boolean showBan, final boolean extra) throws Exception
{
user.setDisplayNick();
if (user.getLastLogout() > 0)
@ -115,7 +114,7 @@ public class Commandseen extends EssentialsCommand
sender.sendMessage(_("whoisBanned", showBan ? user.getBanReason() : _("true")));
}
final String location = user.getGeoLocation();
if (location != null && (!(sender instanceof Player) || ess.getUser(sender).isAuthorized("essentials.geoip.show")))
if (location != null && (!(sender.isPlayer()) || ess.getUser(sender.getPlayer()).isAuthorized("essentials.geoip.show")))
{
sender.sendMessage(_("whoisGeoLocation", location));
}
@ -133,7 +132,7 @@ public class Commandseen extends EssentialsCommand
}
}
private void seenIP(final Server server, final CommandSender sender, final String ipAddress) throws Exception
private void seenIP(final Server server, final CommandSource sender, final String ipAddress) throws Exception
{
final UserMap userMap = ess.getUserMap();