mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-21 23:51:42 +01:00
Format /seen account history list, optimize map loading.
This commit is contained in:
parent
b080187808
commit
b6c0871daa
@ -170,7 +170,6 @@ public class EssentialsConf extends YamlConfiguration
|
||||
finally
|
||||
{
|
||||
inputStream.close();
|
||||
save();
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
|
@ -117,6 +117,10 @@ public class UUIDMap
|
||||
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.ConcurrentSkipListMap;
|
||||
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 class UserMap extends CacheLoader<UUID, User> implements IConf
|
||||
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 @@ public class UserMap extends CacheLoader<UUID, User> implements IConf
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final File userdir = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdir.exists())
|
||||
synchronized (users)
|
||||
{
|
||||
return;
|
||||
final File userdir = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdir.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
keys.clear();
|
||||
names.clear();
|
||||
users.invalidateAll();
|
||||
for (String string : userdir.list())
|
||||
{
|
||||
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);
|
||||
}
|
||||
keys.clear();
|
||||
names.clear();
|
||||
users.invalidateAll();
|
||||
for (String string : userdir.list())
|
||||
{
|
||||
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);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -164,7 +165,7 @@ public class UserMap extends CacheLoader<UUID, User> implements IConf
|
||||
|
||||
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 class UserMap extends CacheLoader<UUID, User> implements IConf
|
||||
{
|
||||
return history;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getUserHistory(final UUID uuid)
|
||||
{
|
||||
return history.get(uuid);
|
||||
|
@ -74,9 +74,9 @@ public class Commandseen extends EssentialsCommand
|
||||
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 @@ public class Commandseen extends EssentialsCommand
|
||||
}
|
||||
|
||||
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 class StringUtil
|
||||
}
|
||||
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>
|
||||
|
Loading…
Reference in New Issue
Block a user