Skip to content

Commit b941234

Browse files
committed
Format /seen account history list, optimize map loading.
1 parent 2180aa8 commit b941234

29 files changed

+91
-29
lines changed

Essentials/src/com/earth2me/essentials/EssentialsConf.java

-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ else if (templateName != null)
170170
finally
171171
{
172172
inputStream.close();
173-
save();
174173
}
175174
}
176175
catch (IOException ex)

Essentials/src/com/earth2me/essentials/UUIDMap.java

+4
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ public void forceWriteUUIDMap()
117117
public Future<?> _writeUUIDMap()
118118
{
119119
final ConcurrentSkipListMap<String, UUID> names = ess.getUserMap().getNames().clone();
120+
if (names.size() < 1)
121+
{
122+
return null;
123+
}
120124
pendingDiskWrites.incrementAndGet();
121125
Future<?> future = EXECUTOR_SERVICE.submit(new WriteRunner(ess.getDataFolder(), userList, names, pendingDiskWrites));
122126
return future;

Essentials/src/com/earth2me/essentials/UserMap.java

+25-24
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.util.concurrent.ConcurrentSkipListSet;
1616
import java.util.concurrent.ExecutionException;
1717
import net.ess3.api.IEssentials;
18+
import org.bukkit.Bukkit;
1819
import org.bukkit.entity.Player;
1920

2021

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

3939
private void loadAllUsersAsync(final IEssentials ess)
@@ -43,33 +43,34 @@ private void loadAllUsersAsync(final IEssentials ess)
4343
@Override
4444
public void run()
4545
{
46-
final File userdir = new File(ess.getDataFolder(), "userdata");
47-
if (!userdir.exists())
48-
{
49-
return;
50-
}
51-
keys.clear();
52-
names.clear();
53-
users.invalidateAll();
54-
for (String string : userdir.list())
46+
synchronized (users)
5547
{
56-
if (!string.endsWith(".yml"))
57-
{
58-
continue;
59-
}
60-
final String name = string.substring(0, string.length() - 4);
61-
try
48+
final File userdir = new File(ess.getDataFolder(), "userdata");
49+
if (!userdir.exists())
6250
{
63-
keys.add(UUID.fromString(name));
51+
return;
6452
}
65-
catch (IllegalArgumentException ex)
53+
keys.clear();
54+
names.clear();
55+
users.invalidateAll();
56+
for (String string : userdir.list())
6657
{
67-
//Ignore these users till they rejoin.
58+
if (!string.endsWith(".yml"))
59+
{
60+
continue;
61+
}
62+
final String name = string.substring(0, string.length() - 4);
63+
try
64+
{
65+
keys.add(UUID.fromString(name));
66+
}
67+
catch (IllegalArgumentException ex)
68+
{
69+
//Ignore these users till they rejoin.
70+
}
6871
}
72+
uuidMap.loadAllUsers(names, history);
6973
}
70-
71-
uuidMap.loadAllUsers(names, history);
72-
7374
}
7475
});
7576
}
@@ -164,7 +165,7 @@ public User load(final UUID uuid) throws Exception
164165

165166
if (userFile.exists())
166167
{
167-
player = new OfflinePlayer(uuid, ess.getServer());
168+
player = new OfflinePlayer(uuid, ess.getServer());
168169
final User user = new User(player, ess);
169170
((OfflinePlayer)player).setName(user.getLastAccountName());
170171
trackUUID(uuid, user.getName());
@@ -212,7 +213,7 @@ public ConcurrentSkipListMap<UUID, ArrayList<String>> getHistory()
212213
{
213214
return history;
214215
}
215-
216+
216217
public List<String> getUserHistory(final UUID uuid)
217218
{
218219
return history.get(uuid);

Essentials/src/com/earth2me/essentials/commands/Commandseen.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ private void seenOnline(final Server server, final CommandSource sender, final U
7474
sender.sendMessage(tl("seenOnline", user.getDisplayName(), DateUtil.formatDateDiff(user.getLastLogin())));
7575

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

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

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

127127
if (user.getBase().isBanned())

Essentials/src/com/earth2me/essentials/utils/StringUtil.java

+34
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,40 @@ public static String joinList(String seperator, Object... list)
6060
}
6161
return buf.toString();
6262
}
63+
64+
public static String joinListSkip(String seperator, String skip, Object... list)
65+
{
66+
StringBuilder buf = new StringBuilder();
67+
for (Object each : list)
68+
{
69+
if (each.toString().equalsIgnoreCase(skip)) {
70+
continue;
71+
}
72+
73+
if (buf.length() > 0)
74+
{
75+
buf.append(seperator);
76+
}
77+
78+
if (each instanceof Collection)
79+
{
80+
buf.append(joinListSkip(seperator, skip, ((Collection)each).toArray()));
81+
}
82+
else
83+
{
84+
try
85+
{
86+
buf.append(each.toString());
87+
}
88+
catch (Exception e)
89+
{
90+
buf.append(each.toString());
91+
}
92+
}
93+
}
94+
return buf.toString();
95+
}
96+
6397
private StringUtil()
6498
{
6599
}

Essentials/src/messages.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000 characters.
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_cs.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_da.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_de.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_en.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000 characters.
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_es.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_et.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_fi.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_fr.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_hu.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_it.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_ko.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_lt.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_nl.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_pl.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_pt.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_ro.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_ru.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_sv.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_tr.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_zh.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_zh_HK.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

Essentials/src/messages_zh_TW.properties

+1
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,4 @@ weatherInvalidWorld=World named {0} not found\!
545545
gameModeInvalid=\u00a74You need to specify a valid player/mode.
546546
mailTooLong=\u00a74Mail message too long. Try to keep it below 1000
547547
mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
548+
seenAccounts=\u00a76Player has also been known as:\u00a7c {0}

nbactions.xml

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<actionName>build</actionName>
2424
<goals>
2525
<goal>package</goal>
26+
<goal>dependency:copy</goal>
2627
</goals>
2728
</action>
2829
</actions>

0 commit comments

Comments
 (0)