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,12 +1,12 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.DateUtil;
import java.util.GregorianCalendar;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -18,7 +18,7 @@ public class Commandtempban extends EssentialsCommand
}
@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 < 2)
{
@ -27,8 +27,8 @@ public class Commandtempban extends EssentialsCommand
final User user = getPlayer(server, args, 0, true, true);
if (!user.isOnline())
{
if (sender instanceof Player
&& !ess.getUser(sender).isAuthorized("essentials.tempban.offline"))
if (sender.isPlayer()
&& !ess.getUser(sender.getPlayer()).isAuthorized("essentials.tempban.offline"))
{
sender.sendMessage(_("tempbanExempt"));
return;
@ -47,13 +47,13 @@ public class Commandtempban extends EssentialsCommand
final long maxBanLength = ess.getSettings().getMaxTempban() * 1000;
if (maxBanLength > 0 && ((banTimestamp - GregorianCalendar.getInstance().getTimeInMillis()) > maxBanLength)
&& sender instanceof Player && !(ess.getUser(sender).isAuthorized("essentials.tempban.unlimited")))
&& sender.isPlayer() && !(ess.getUser(sender.getPlayer()).isAuthorized("essentials.tempban.unlimited")))
{
sender.sendMessage(_("oversizedTempban"));
throw new NoChargeException();
}
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
final String senderName = sender.isPlayer() ? sender.getPlayer().getDisplayName() : Console.NAME;
final String banReason = _("tempBanned", DateUtil.formatDateDiff(banTimestamp), senderName);
user.setBanReason(banReason);
user.setBanTimeout(banTimestamp);