Use quicker ban lookup to reduce /seen lag.

This commit is contained in:
KHobbits 2014-08-14 01:48:08 +01:00
parent 53a7cd732f
commit 3f1c996959
4 changed files with 45 additions and 8 deletions

View File

@ -1,6 +1,7 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n.tl;
import com.earth2me.essentials.craftbukkit.BanLookup;
import com.earth2me.essentials.craftbukkit.FakeWorld;
import com.earth2me.essentials.settings.Spawns;
import com.earth2me.essentials.storage.YamlStorageWriter;
@ -729,7 +730,7 @@ public class EssentialsUpgrade
banTimeout = 0L;
}
if (ess.getServer().getBanList(BanList.Type.NAME).isBanned(playerName))
if (BanLookup.isBanned(ess, playerName))
{
updateBan(playerName, banReason, banTimeout);
}

View File

@ -4,15 +4,14 @@ import com.earth2me.essentials.CommandSource;
import static com.earth2me.essentials.I18n.tl;
import com.earth2me.essentials.User;
import com.earth2me.essentials.UserMap;
import com.earth2me.essentials.craftbukkit.BanLookup;
import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.FormatUtil;
import com.earth2me.essentials.utils.StringUtil;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.bukkit.BanList;
import org.bukkit.Bukkit;
import java.util.UUID;
import org.bukkit.BanEntry;
import org.bukkit.Location;
@ -64,9 +63,9 @@ public class Commandseen extends EssentialsCommand
sender.sendMessage(tl("isIpBanned", args[0]));
return;
}
else if (ess.getServer().getBanList(BanList.Type.NAME).isBanned(args[0]))
else if (BanLookup.isBanned(ess, args[0]))
{
sender.sendMessage(tl("whoisBanned", showBan ? ess.getServer().getBanList(BanList.Type.NAME).getBanEntry(args[0]).getReason() : tl("true")));
sender.sendMessage(tl("whoisBanned", showBan ? BanLookup.getBanEntry(ess, args[0]).getReason() : tl("true")));
return;
}
else
@ -145,9 +144,9 @@ public class Commandseen extends EssentialsCommand
sender.sendMessage(tl("seenAccounts", StringUtil.joinListSkip(", ", user.getName(), history)));
}
if (user.getBase().isBanned())
if (BanLookup.isBanned(ess, user))
{
final BanEntry banEntry = ess.getServer().getBanList(BanList.Type.NAME).getBanEntry(user.getName());
final BanEntry banEntry = BanLookup.getBanEntry(ess, user.getName());
final String reason = showBan ? banEntry.getReason() : tl("true");
sender.sendMessage(tl("whoisBanned", reason));
if (banEntry.getExpiration() != null)
@ -161,6 +160,7 @@ public class Commandseen extends EssentialsCommand
sender.sendMessage(tl("whoisTempBanned", expireString));
}
}
final String location = user.getGeoLocation();
if (location != null && (!(sender.isPlayer()) || ess.getUser(sender.getPlayer()).isAuthorized("essentials.geoip.show")))
{

View File

@ -0,0 +1,36 @@
package com.earth2me.essentials.craftbukkit;
import com.earth2me.essentials.User;
import java.util.Iterator;
import java.util.Set;
import net.ess3.api.IEssentials;
import org.bukkit.BanEntry;
import org.bukkit.BanList;
public class BanLookup
{
public static Boolean isBanned(IEssentials ess, User user)
{
return isBanned(ess, user.getName());
}
public static Boolean isBanned(IEssentials ess, String name)
{
return getBanEntry(ess, name) != null;
}
public static BanEntry getBanEntry(IEssentials ess, String name)
{
Set<BanEntry> benteries = ess.getServer().getBanList(BanList.Type.NAME).getBanEntries();
for (BanEntry banEnt : benteries)
{
if (banEnt.getTarget().equals(name))
{
return banEnt;
}
}
return null;
}
}

View File

@ -229,7 +229,7 @@ commands:
mail:
description: Manages inter-player, intra-server mail.
usage: /<command> [read|clear|send [to] [message]|sendall [message]]
aliases: [email,eemail]
aliases: [email,eemail,memo,ememo]
me:
description: Describes an action in the context of the player.
usage: /<command> <description>