Skip to content

Commit

Permalink
2.2.0.4
Browse files Browse the repository at this point in the history
-Renames IdUtil so that it's clear that it's only for local presences

Took 5 minutes
  • Loading branch information
Jake-Moore committed Dec 10, 2023
1 parent 9f001ac commit e3165b2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public OfflinePlayer read(String str, CommandSender sender) throws KamiCommonExc

@Override
public Collection<String> getTabList(CommandSender commandSender, String s) {
return IdUtilLocal.getNames(SenderPresence.LOCAL, SenderType.PLAYER).stream()
return IdUtilLocal.getNames(SenderPresence.ONLINE, SenderType.PLAYER).stream()
.filter(key -> key.toLowerCase().startsWith(s.toLowerCase())).limit(20)
.collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public static void register(CommandSender sender) {
registrySenderToId.put(sender, id);

// Update data before the event is ran so that data is available.
update(id, id, SenderPresence.LOCAL);
update(id, id, SenderPresence.ONLINE);
}

@Contract("null -> fail")
Expand Down Expand Up @@ -415,7 +415,7 @@ public void playerJoinLowest(@NotNull PlayerJoinEvent event) {
String name = player.getName();

// Joining? The player must be local at this point.
update(id, name, SenderPresence.LOCAL);
update(id, name, SenderPresence.ONLINE);
}

// Can't be cancelled
Expand Down Expand Up @@ -839,12 +839,12 @@ public static void loadDatas() {

KamiCommon.get().getLogger().info(Txt.parse("<i>Loading Onlineplayer datas..."));
for (IdData data : getLocalPlayerDatas()) {
update(data.getId(), data.getName(), data.getMillis(), SenderPresence.LOCAL);
update(data.getId(), data.getName(), data.getMillis(), SenderPresence.ONLINE);
}

KamiCommon.get().getLogger().info(Txt.parse("<i>Loading Registry datas..."));
for (String id : registryIdToSender.keySet()) {
update(id, id, SenderPresence.LOCAL);
update(id, id, SenderPresence.ONLINE);
}

KamiCommon.get().getLogger().info(Txt.parse("<i>Saving Cachefile..."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ public boolean removeValueCompletely(String value) {
// UTIL
// -------------------------------------------- //

public static final List<SenderPresence> LOCAL_PRESENCES = ImmutableList.of(SenderPresence.LOCAL, SenderPresence.ONLINE, SenderPresence.ANY);
public static final List<SenderPresence> ONLINE_PRESENCES = ImmutableList.of(SenderPresence.ONLINE, SenderPresence.ANY);
public static final List<SenderPresence> OFFLINE_PRESENCES = ImmutableList.of(SenderPresence.OFFLINE, SenderPresence.ANY);

Expand All @@ -159,7 +158,6 @@ public boolean removeValueCompletely(String value) {
public static @NotNull List<@NotNull SenderPresence> getPresences(SenderPresence presence) {
if (presence == null) throw new NullPointerException("presence");

if (presence == SenderPresence.LOCAL) return LOCAL_PRESENCES;
else if (presence == SenderPresence.ONLINE) return ONLINE_PRESENCES;
else if (presence == SenderPresence.OFFLINE) return OFFLINE_PRESENCES;
else throw new IllegalArgumentException("SenderPresence.ANY is not supported. You must know if it is online or offline.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import org.jetbrains.annotations.Contract;

@SuppressWarnings("unused")
public enum SenderPresence {
// IMP NOTE: These must be sorted, with the most strict first
// and the most loose at the end.
LOCAL, // Online and logged in on this very server.
ONLINE, // Online somewhere on the cloud. May be this server may be another server.

ONLINE, // Online and logged in on this very server.
OFFLINE, // The opposite of online.
ANY, // Any. Local, Online or Offline.

Expand Down

0 comments on commit e3165b2

Please sign in to comment.