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

more changes

This commit is contained in:
2026-04-03 18:54:01 +04:00
parent 42e8a861a3
commit f58a212782
19 changed files with 226 additions and 73 deletions

View File

@@ -14,22 +14,9 @@ dependencies {
description = "ValioBungee Velocity implementation"
java {
withSourcesJar()
}
tasks {
runVelocity {
velocityVersion(libs.versions.velocity.get())
}
compileJava {
options.encoding = Charsets.UTF_8.name()
options.release.set(21) // required by velocity
}
processResources {
filteringCharset = Charsets.UTF_8.name()
}
}

View File

@@ -18,6 +18,10 @@
*/
package net.limework.valiobungee.velocity;
import com.google.inject.Inject;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.ProxyServer;
@@ -25,12 +29,16 @@ import java.nio.file.Path;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;
import net.limework.valiobungee.api.entity.NetworkPlayer;
import net.limework.valiobungee.api.entity.NetworkProxy;
import net.limework.valiobungee.core.ConstantVariables;
import net.limework.valiobungee.core.ProxyNetworkManager;
import net.limework.valiobungee.core.ValioBungeePlatform;
import net.limework.valiobungee.core.util.logging.LogProviderFactory;
import net.limework.valiobungee.velocity.api.TestProxyNetworkManager;
import net.limework.valiobungee.velocity.api.entities.ImplVelocityNetworkPlayer;
import net.limework.valiobungee.velocity.api.entities.ImplVelocityNetworkProxy;
import org.slf4j.Logger;
@@ -47,6 +55,7 @@ public class VelocityValioBungeePlugin implements ValioBungeePlatform {
private final Path dataFolder;
private final ProxyNetworkManager proxyNetworkManager;
@Inject
public VelocityValioBungeePlugin(
ProxyServer server, Logger logger, @DataDirectory Path dataDirectory) {
this.server = server;
@@ -54,9 +63,20 @@ public class VelocityValioBungeePlugin implements ValioBungeePlatform {
this.dataFolder = dataDirectory;
// init logging
LogProviderFactory.register(logger);
this.proxyNetworkManager = null;
this.proxyNetworkManager = new TestProxyNetworkManager(this);
}
@Subscribe(priority = Short.MAX_VALUE) // this really important so MAKE IT MAX
public void onProxyInitializeEvent(ProxyInitializeEvent event) {
logger.info(
"initializing ValioBungee for {} platform, version {}",
platformProxyVendor(),
ConstantVariables.VERSION);
}
@Subscribe(priority = Short.MIN_VALUE) // this really import so Make it AT LOWEST
public void onProxyShutdownEvent(ProxyShutdownEvent event) {}
@Override
public int localOnlinePlayers() {
return this.server.getPlayerCount();
@@ -72,9 +92,16 @@ public class VelocityValioBungeePlugin implements ValioBungeePlatform {
return this.proxyNetworkManager;
}
@Override
public NetworkProxy proxyPlatformCreator(String id) {
return new ImplVelocityNetworkProxy(this, id);
}
private final String id = "test-ido-" + ThreadLocalRandom.current().nextInt(10);
@Override
public String proxyId() {
return "test-ido";
return id;
}
@Override
@@ -90,9 +117,7 @@ public class VelocityValioBungeePlugin implements ValioBungeePlatform {
@Override
public Optional<NetworkProxy> getNetworkProxy(String id) {
if (this.proxyId().equals(id)) return Optional.of(getLocalProxy());
logger.warn("not implemented api call returned as Optional empty");
return Optional.empty();
return this.proxyNetworkManager.getNetworkProxy(id);
}
@Override
@@ -102,14 +127,15 @@ public class VelocityValioBungeePlugin implements ValioBungeePlatform {
@Override
public Set<NetworkProxy> getNetworkProxies() {
logger.warn("not implemented api call returned as Optional empty");
return Set.of();
return proxyNetworkManager.getNetworkProxies();
}
@Override
public Set<NetworkPlayer> getLocalProxyPlayers() {
logger.warn("not implemented api call returned as Optional empty");
return Set.of();
NetworkProxy proxy = getLocalProxy();
return this.server.getAllPlayers().stream()
.map(p -> new ImplVelocityNetworkPlayer(this, p.getUniqueId(), getLocalProxy(), p))
.collect(Collectors.toSet());
}
@Override

View File

@@ -0,0 +1,40 @@
/*
* Copyright (c) 2026 ValioBungee contributors
*
* This file is part of ValioBungee.
*
* ValioBungee is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ValioBungee is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ValioBungee. If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
*/
package net.limework.valiobungee.velocity.api;
import net.limework.valiobungee.core.ProxyNetworkManager;
import net.limework.valiobungee.core.ValioBungeePlatform;
public class TestProxyNetworkManager extends ProxyNetworkManager {
public TestProxyNetworkManager(ValioBungeePlatform platform) {
super(platform);
}
@Override
protected void publishDeathPayload() {}
@Override
protected void publishHeartbeatPayload() {}
@Override
public void init() {}
@Override
public void close() {}
}

View File

@@ -18,13 +18,40 @@
*/
package net.limework.valiobungee.velocity.api.entities;
import com.velocitypowered.api.proxy.Player;
import java.util.Optional;
import java.util.UUID;
import net.limework.valiobungee.api.entity.NetworkProxy;
import net.limework.valiobungee.core.ValioBungeePlatform;
import net.limework.valiobungee.core.api.entities.AbstractNetworkPlayer;
import net.limework.valiobungee.core.api.entities.AbstractUUIDNetworkPlayer;
import net.limework.valiobungee.core.util.logging.LogProviderFactory;
public class ImplVelocityNetworkPlayer extends AbstractNetworkPlayer {
public ImplVelocityNetworkPlayer(ValioBungeePlatform platform, UUID uuid, NetworkProxy proxy) {
public class ImplVelocityNetworkPlayer extends AbstractUUIDNetworkPlayer
implements VelocityNetworkPlayer {
private final Player handle;
public ImplVelocityNetworkPlayer(
ValioBungeePlatform platform, UUID uuid, NetworkProxy proxy, Player handle) {
super(platform, uuid, proxy);
this.handle = handle;
}
@Override
public Optional<Player> getHandle() {
return Optional.ofNullable(handle);
}
@Override
public boolean isLocal() {
return handle != null;
}
@Override
public boolean isOnline() {
if (isLocal()) {
return handle.isActive();
}
LogProviderFactory.get().warn("NOT IMPLEMENTED IS ONLINE for Velocity network player");
return false;
}
}

View File

@@ -23,7 +23,7 @@ import net.limework.valiobungee.api.entity.NetworkPlayer;
import net.limework.valiobungee.core.api.entities.AbstractNetworkProxy;
import net.limework.valiobungee.velocity.VelocityValioBungeePlugin;
public class ImplVelocityNetworkProxy extends AbstractNetworkProxy {
public class ImplVelocityNetworkProxy extends AbstractNetworkProxy implements VelocityNetworkProxy {
public ImplVelocityNetworkProxy(VelocityValioBungeePlugin platform, String proxyId) {
super(platform, proxyId);