mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2026-04-08 16:10:26 +00:00
more changes
This commit is contained in:
@@ -17,17 +17,13 @@ sourceSets {
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
withJavadocJar()
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
api(project(":valiobungee-api"))
|
||||
api(libs.protobuf)
|
||||
api(libs.caffeine)
|
||||
api(libs.slf4j)
|
||||
api(libs.redisson)
|
||||
testImplementation(libs.testing.juipter)
|
||||
testImplementation(libs.testing.slf4j.simple)
|
||||
}
|
||||
|
||||
10
core/redisson/build.gradle.kts
Normal file
10
core/redisson/build.gradle.kts
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":valiobungee-core"))
|
||||
|
||||
}
|
||||
|
||||
description = "ValioBungee Redisson implementation"
|
||||
|
||||
|
||||
|
||||
@@ -23,7 +23,12 @@ import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.RemovalCause;
|
||||
import com.github.benmanes.caffeine.cache.RemovalListener;
|
||||
import java.time.Duration;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import net.limework.valiobungee.api.entity.NetworkProxy;
|
||||
import net.limework.valiobungee.core.proto.messages.*;
|
||||
import net.limework.valiobungee.core.util.logging.LogProviderFactory;
|
||||
import org.slf4j.Logger;
|
||||
@@ -104,6 +109,22 @@ public abstract class ProxyNetworkManager {
|
||||
.build();
|
||||
}
|
||||
|
||||
// return self only if no other proxies
|
||||
public Set<NetworkProxy> getNetworkProxies() {
|
||||
return Stream.concat(
|
||||
this.heartbeats.asMap().values().stream()
|
||||
.map(h -> platform.proxyPlatformCreator(h.getSender().getProxyId())),
|
||||
Stream.of(platform.getLocalProxy()))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public Optional<NetworkProxy> getNetworkProxy(String id) {
|
||||
if (platform.networkId().equals(id)) return Optional.of(platform.proxyPlatformCreator(id));
|
||||
if (!this.heartbeats.asMap().containsKey(id)) return Optional.empty();
|
||||
return Optional.of(
|
||||
platform.proxyPlatformCreator(this.heartbeats.asMap().get(id).getSender().getProxyId()));
|
||||
}
|
||||
|
||||
protected abstract void publishDeathPayload();
|
||||
|
||||
protected abstract void publishHeartbeatPayload();
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package net.limework.valiobungee.core;
|
||||
|
||||
import net.limework.valiobungee.api.ValioBungeeAPI;
|
||||
import net.limework.valiobungee.api.entity.NetworkProxy;
|
||||
|
||||
public interface ValioBungeePlatform extends ValioBungeeAPI {
|
||||
|
||||
@@ -32,6 +33,8 @@ public interface ValioBungeePlatform extends ValioBungeeAPI {
|
||||
|
||||
ProxyNetworkManager proxyNetworkManager();
|
||||
|
||||
NetworkProxy proxyPlatformCreator(String id);
|
||||
|
||||
@Override
|
||||
default String getGitCommit() {
|
||||
return ConstantVariables.GIT_COMMIT;
|
||||
|
||||
@@ -22,22 +22,23 @@ import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import net.limework.valiobungee.api.entity.NetworkPlayer;
|
||||
import net.limework.valiobungee.api.entity.NetworkProxy;
|
||||
import net.limework.valiobungee.api.entity.UUIDPlayer;
|
||||
import net.limework.valiobungee.core.ValioBungeePlatform;
|
||||
|
||||
public abstract class AbstractNetworkPlayer implements NetworkPlayer {
|
||||
public abstract class AbstractUUIDNetworkPlayer implements NetworkPlayer, UUIDPlayer {
|
||||
|
||||
private final ValioBungeePlatform platform;
|
||||
private final UUID uuid;
|
||||
private final NetworkProxy proxy;
|
||||
|
||||
public AbstractNetworkPlayer(ValioBungeePlatform platform, UUID uuid, NetworkProxy proxy) {
|
||||
public AbstractUUIDNetworkPlayer(ValioBungeePlatform platform, UUID uuid, NetworkProxy proxy) {
|
||||
this.platform = platform;
|
||||
this.uuid = uuid;
|
||||
this.proxy = proxy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
public UUID getUniqueId() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
@@ -48,7 +49,7 @@ public abstract class AbstractNetworkPlayer implements NetworkPlayer {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof AbstractNetworkPlayer that)) return false;
|
||||
if (!(o instanceof AbstractUUIDNetworkPlayer that)) return false;
|
||||
return Objects.equals(uuid, that.uuid) && Objects.equals(proxy, that.proxy);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user