2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2026-04-08 16:10:26 +00:00

finished but untest

This commit is contained in:
2022-04-13 22:17:38 +04:00
parent 9f09ed21f1
commit 7de457b6fa
10 changed files with 665 additions and 20 deletions

View File

@@ -10,6 +10,18 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>RedisBungee-API</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<source>8</source>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
</dependencies>

View File

@@ -147,9 +147,10 @@ public abstract class DataManager<P, PL, PD, PS> {
serverCache.invalidate(uuid);
proxyCache.invalidate(uuid);
}
// Invalidate all entries related to this player, since they now lie. (call invalidate(uuid))
public abstract void onPostLogin(PL event);
// Invalidate all entries related to this player, since they now lie. (call invalidate(uuid))
public abstract void onPlayerDisconnect(PD event);
public abstract void onPubSubMessage(PS event);
@@ -227,7 +228,6 @@ public abstract class DataManager<P, PL, PD, PS> {
}
}
public static class DataManagerMessage {
private final UUID target;
private final String source;

View File

@@ -17,20 +17,30 @@ import java.util.concurrent.TimeUnit;
public interface RedisBungeePlugin<P> {
void enable();
default void enable() {
void disable();
}
default void disable() {
}
RedisBungeeConfiguration getConfiguration();
int getCount();
int getCurrentCount();
Set<String> getLocalPlayersAsUuidStrings();
DataManager<P, ?, ?, ?> getDataManager();
Set<UUID> getPlayers();
Jedis requestJedis();
boolean isJedisAvailable();
RedisBungeeAPI getApi();
UUIDTranslator getUuidTranslator();
@@ -43,15 +53,17 @@ public interface RedisBungeePlugin<P> {
List<String> getServerIds();
List<String > getCurrentServerIds(boolean nag, boolean lagged);
PubSubListener getPubSubListener();
void sendChannelMessage(String channel, String message);
void executeAsync(Runnable runnable);
void executeAsyncAfter(Runnable runnable, TimeUnit timeUnit, int seconds);
void executeAsyncAfter(Runnable runnable, TimeUnit timeUnit, int time);
void callEvent(Object object);
void callEvent(Object event);
boolean isOnlineMode();
@@ -61,8 +73,6 @@ public interface RedisBungeePlugin<P> {
void logFatal(String msg);
boolean isPlayerServerNull(P player);
P getPlayer(UUID uuid);
P getPlayer(String name);
@@ -77,7 +87,7 @@ public interface RedisBungeePlugin<P> {
InetAddress getPlayerIp(P player);
void executeProxyCommand(String cmd);
void sendProxyCommand(String cmd);
default Class<?> getPubSubEventClass() {
return PubSubMessageEvent.class;
@@ -95,4 +105,8 @@ public interface RedisBungeePlugin<P> {
return PlayerLeftNetworkEvent.class;
}
long getRedisTime(List<String> timeRes);
void loadConfig() throws Exception;
}

View File

@@ -0,0 +1,24 @@
local c = redis.call
local curTime = c("TIME")
local time = tonumber(curTime[1])
local heartbeats = c("HGETALL", "heartbeats")
local total = 0
local key
for _, v in ipairs(heartbeats) do
if not key then
key = v
else
local n = tonumber(v)
if n then
if n + 30 >= time then
total = total + c("SCARD", "proxy:" .. key .. ":usersOnline")
end
end
key = nil
end
end
return total

View File

@@ -0,0 +1,18 @@
local call = redis.call
local ipairs = ipairs
local serverToData = {}
for _, proxy in ipairs(ARGV) do
local players = call("SMEMBERS", "proxy:" .. proxy .. ":usersOnline")
for _, player in ipairs(players) do
local server = call("HGET", "player:" .. player, "server")
if server then
local sz = #serverToData
serverToData[sz + 1] = server
serverToData[sz + 2] = player
end
end
end
return serverToData