Skip to content
Permalink
Browse files

Format /seen account history list, optimize map loading.

  • Loading branch information...
khobbits committed Apr 18, 2014
1 parent 2180aa8 commit b941234d67e46701941aa5146567c1579e1433e2
@@ -170,7 +170,6 @@ else if (templateName != null)
finally
{
inputStream.close();
save();
}
}
catch (IOException ex)
@@ -117,6 +117,10 @@ public void forceWriteUUIDMap()
public Future<?> _writeUUIDMap()
{
final ConcurrentSkipListMap<String, UUID> names = ess.getUserMap().getNames().clone();
if (names.size() < 1)
{
return null;
}
pendingDiskWrites.incrementAndGet();
Future<?> future = EXECUTOR_SERVICE.submit(new WriteRunner(ess.getDataFolder(), userList, names, pendingDiskWrites));
return future;
@@ -15,6 +15,7 @@
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.concurrent.ExecutionException;
import net.ess3.api.IEssentials;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;


@@ -33,7 +34,6 @@ public UserMap(final IEssentials ess)
this.ess = ess;
uuidMap = new UUIDMap(ess);
users = CacheBuilder.newBuilder().maximumSize(ess.getSettings().getMaxUserCacheCount()).softValues().build(this);
loadAllUsersAsync(ess);
}

private void loadAllUsersAsync(final IEssentials ess)
@@ -43,33 +43,34 @@ private void loadAllUsersAsync(final IEssentials ess)
@Override
public void run()
{
final File userdir = new File(ess.getDataFolder(), "userdata");
if (!userdir.exists())
{
return;
}
keys.clear();
names.clear();
users.invalidateAll();
for (String string : userdir.list())
synchronized (users)
{
if (!string.endsWith(".yml"))
{
continue;
}
final String name = string.substring(0, string.length() - 4);
try
final File userdir = new File(ess.getDataFolder(), "userdata");
if (!userdir.exists())
{
keys.add(UUID.fromString(name));
return;
}
catch (IllegalArgumentException ex)
keys.clear();
names.clear();
users.invalidateAll();
for (String string : userdir.list())
{
//Ignore these users till they rejoin.
if (!string.endsWith(".yml"))
{
continue;
}
final String name = string.substring(0, string.length() - 4);
try
{
keys.add(UUID.fromString(name));
}
catch (IllegalArgumentException ex)
{
//Ignore these users till they rejoin.
}
}
uuidMap.loadAllUsers(names, history);
}

uuidMap.loadAllUsers(names, history);

}
});
}
@@ -164,7 +165,7 @@ public User load(final UUID uuid) throws Exception

if (userFile.exists())
{
player = new OfflinePlayer(uuid, ess.getServer());
player = new OfflinePlayer(uuid, ess.getServer());
final User user = new User(player, ess);
((OfflinePlayer)player).setName(user.getLastAccountName());
trackUUID(uuid, user.getName());
@@ -212,7 +213,7 @@ public int getUniqueUsers()
{
return history;
}

public List<String> getUserHistory(final UUID uuid)
{
return history.get(uuid);
@@ -74,9 +74,9 @@ private void seenOnline(final Server server, final CommandSource sender, final U
sender.sendMessage(tl("seenOnline", user.getDisplayName(), DateUtil.formatDateDiff(user.getLastLogin())));

List<String> history = ess.getUserMap().getUserHistory(user.getBase().getUniqueId());
if (history.size() > 1)
if (history != null && history.size() > 1)
{
sender.sendMessage("User has also been known as: " + StringUtil.joinList(history)); //TODO: TL
sender.sendMessage(tl("seenAccounts", StringUtil.joinListSkip(", ", user.getName(), history)));
}

if (user.isAfk())
@@ -119,9 +119,9 @@ private void seenOffline(final Server server, final CommandSource sender, User u
}

List<String> history = ess.getUserMap().getUserHistory(user.getBase().getUniqueId());
if (history.size() > 1)
if (history != null && history.size() > 1)
{
sender.sendMessage("User has also been known as: " + StringUtil.joinList(history)); //TODO: TL
sender.sendMessage(tl("seenAccounts", StringUtil.joinListSkip(", ", user.getName(), history)));
}

if (user.getBase().isBanned())
@@ -60,6 +60,40 @@ public static String joinList(String seperator, Object... list)
}
return buf.toString();
}

public static String joinListSkip(String seperator, String skip, Object... list)
{
StringBuilder buf = new StringBuilder();
for (Object each : list)
{
if (each.toString().equalsIgnoreCase(skip)) {
continue;
}

if (buf.length() > 0)
{
buf.append(seperator);
}

if (each instanceof Collection)
{
buf.append(joinListSkip(seperator, skip, ((Collection)each).toArray()));
}
else
{
try
{
buf.append(each.toString());
}
catch (Exception e)
{
buf.append(each.toString());
}
}
}
return buf.toString();
}

private StringUtil()
{
}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000 characters.
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000 characters.
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
gameModeInvalid=\u00a74You need to specify a valid player/mode.
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}
@@ -23,6 +23,7 @@
<actionName>build</actionName>
<goals>
<goal>package</goal>
<goal>dependency:copy</goal>
</goals>
</action>
</actions>

0 comments on commit b941234

Please sign in to comment.
You can’t perform that action at this time.