mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 22:17:17 +00:00
More implementation, timed teleports, regex, etc
This commit is contained in:
1 parent
7ac52d747f
commit
e335a48888
25 files changed
+803
-157
No files matched your search
@@ -1,6 +1,10 @@
|
||||
package net.william278.huskhomes.cache;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.config.Settings;
|
||||
import net.william278.huskhomes.data.Database;
|
||||
import net.william278.huskhomes.messenger.NetworkMessenger;
|
||||
import net.william278.huskhomes.player.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -8,6 +12,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* A cache used to hold persistently used data
|
||||
@@ -29,6 +34,11 @@ public class Cache {
|
||||
*/
|
||||
public final List<String> warps;
|
||||
|
||||
/**
|
||||
* Cached player list
|
||||
*/
|
||||
public final List<String> players;
|
||||
|
||||
/**
|
||||
* Create a new cache
|
||||
*/
|
||||
@@ -36,6 +46,7 @@ public class Cache {
|
||||
this.homes = new HashMap<>();
|
||||
this.publicHomes = new HashMap<>();
|
||||
this.warps = new ArrayList<>();
|
||||
this.players = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,4 +63,23 @@ public class Cache {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the cached list of online players
|
||||
*
|
||||
* @param plugin the implementing plugin
|
||||
*/
|
||||
public void updatePlayerList(@NotNull HuskHomes plugin, @NotNull Player requester) {
|
||||
if (plugin.getSettings().getBooleanValue(Settings.ConfigOption.ENABLE_PROXY_MODE)) {
|
||||
assert plugin.getNetworkMessenger() != null;
|
||||
CompletableFuture.runAsync(() -> plugin.getNetworkMessenger().
|
||||
getOnlinePlayerNames(requester).thenAcceptAsync(returnedPlayerList -> {
|
||||
players.clear();
|
||||
players.addAll(List.of(returnedPlayerList));
|
||||
}));
|
||||
} else {
|
||||
players.clear();
|
||||
players.addAll(plugin.getOnlinePlayers().stream().map(Player::getName).toList());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user