mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2026-04-02 21:20:47 +00:00
make the api the plugin
This commit is contained in:
parent
06873938b6
commit
d7387956ee
@ -15,4 +15,33 @@
|
||||
*/
|
||||
package net.limework.valiobungee.api;
|
||||
|
||||
public interface ValioBungeeAPI {}
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import net.limework.valiobungee.api.entity.NetworkPlayer;
|
||||
import net.limework.valiobungee.api.entity.NetworkProxy;
|
||||
|
||||
public interface ValioBungeeAPI {
|
||||
|
||||
Optional<NetworkPlayer> getNetworkPlayer(UUID uuid);
|
||||
|
||||
Optional<NetworkProxy> getNetworkProxy(String id);
|
||||
|
||||
NetworkProxy getLocalProxy();
|
||||
|
||||
Set<NetworkProxy> getNetworkProxies();
|
||||
|
||||
Set<NetworkPlayer> getLocalProxyPlayers();
|
||||
|
||||
Set<NetworkPlayer> getNetworkPlayers();
|
||||
|
||||
/**
|
||||
* @return Version based on the build
|
||||
*/
|
||||
String getVersion();
|
||||
|
||||
/**
|
||||
* @return GIT COMMIT based on the build
|
||||
*/
|
||||
String getGitCommit();
|
||||
}
|
||||
|
||||
@ -32,12 +32,12 @@ public interface NetworkProxy {
|
||||
/**
|
||||
* @return online players number in this proxy
|
||||
*/
|
||||
int onlinePlayersCount();
|
||||
int onlinePlayerCount();
|
||||
|
||||
/**
|
||||
* @return Returns set of players in this proxy
|
||||
*/
|
||||
Set<NetworkPlayer> networkPlayers();
|
||||
Set<NetworkPlayer> getProxyPlayers();
|
||||
|
||||
/**
|
||||
* @return returns true if this object is proxy on it
|
||||
|
||||
@ -17,4 +17,10 @@ package net.limework.valiobungee.velocity.api;
|
||||
|
||||
import net.limework.valiobungee.api.ValioBungeeAPI;
|
||||
|
||||
/**
|
||||
* Valiobungee velocity specific API
|
||||
*
|
||||
* @author Ham1255
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface VelocityValioBungeeAPI extends ValioBungeeAPI {}
|
||||
|
||||
@ -13,26 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package net.limework.valiobungee.api;
|
||||
package net.limework.valiobungee.velocity.api.entities;
|
||||
|
||||
import net.limework.valiobungee.api.entity.NetworkPlayer;
|
||||
|
||||
/**
|
||||
* this class provides the API object and access to the version and git commit
|
||||
* Velocity Network player.
|
||||
*
|
||||
* @author Ham1255
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface ValioBungeeAPIProvider {
|
||||
/**
|
||||
* @return The api object {@link ValioBungeeAPI}
|
||||
*/
|
||||
ValioBungeeAPI getAPI();
|
||||
|
||||
/**
|
||||
* @return version of the build
|
||||
*/
|
||||
String getVersion();
|
||||
|
||||
/**
|
||||
* @return GIT COMMIT based on the build
|
||||
*/
|
||||
String getGitCommit();
|
||||
}
|
||||
public interface VelocityNetworkPlayer extends NetworkPlayer {}
|
||||
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2026 ValioBungee contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package net.limework.valiobungee.velocity.api.entities;
|
||||
|
||||
import net.limework.valiobungee.api.entity.NetworkProxy;
|
||||
|
||||
/**
|
||||
* Proxy is an object for online proxy in a velocity network
|
||||
*
|
||||
* @author Ham1255
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface VelocityNetworkProxy extends NetworkProxy {}
|
||||
@ -27,7 +27,7 @@ dependencies {
|
||||
api(libs.protobuf)
|
||||
api(libs.caffeine)
|
||||
api(libs.slf4j)
|
||||
|
||||
api(libs.redisson)
|
||||
testImplementation(libs.testing.juipter)
|
||||
testImplementation(libs.testing.slf4j.simple)
|
||||
}
|
||||
|
||||
@ -33,12 +33,12 @@ import org.slf4j.Logger;
|
||||
* locally Why abstract? Because it allows us to develop alternative implementation to use other
|
||||
* software than valkey or redis
|
||||
*/
|
||||
public abstract class ProxyManager {
|
||||
public abstract class ProxyNetworkManager {
|
||||
|
||||
protected final UUID proxyManagerId = UUID.randomUUID();
|
||||
protected final ValioBungeePlatform platform;
|
||||
|
||||
public ProxyManager(ValioBungeePlatform platform) {
|
||||
public ProxyNetworkManager(ValioBungeePlatform platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@ -18,10 +18,9 @@
|
||||
*/
|
||||
package net.limework.valiobungee.core;
|
||||
|
||||
import net.limework.valiobungee.api.ValioBungeeAPIProvider;
|
||||
import net.limework.valiobungee.core.api.entities.NetworkEntitiesProvider;
|
||||
import net.limework.valiobungee.api.ValioBungeeAPI;
|
||||
|
||||
public interface ValioBungeePlatform extends NetworkEntitiesProvider, ValioBungeeAPIProvider {
|
||||
public interface ValioBungeePlatform extends ValioBungeeAPI {
|
||||
|
||||
int localOnlinePlayers();
|
||||
|
||||
@ -31,7 +30,7 @@ public interface ValioBungeePlatform extends NetworkEntitiesProvider, ValioBunge
|
||||
|
||||
String proxyId();
|
||||
|
||||
ProxyManager proxyManager();
|
||||
ProxyNetworkManager proxyNetworkManager();
|
||||
|
||||
@Override
|
||||
default String getGitCommit() {
|
||||
|
||||
@ -39,8 +39,8 @@ public abstract class AbstractNetworkProxy implements NetworkProxy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onlinePlayersCount() {
|
||||
return this.platform.proxyManager().onlinePlayersCount(this.proxyId);
|
||||
public int onlinePlayerCount() {
|
||||
return this.platform.proxyNetworkManager().onlinePlayersCount(this.proxyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2013 RedisBungee contributors
|
||||
* Copyright (c) 2026 RedisBungee contributors
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
|
||||
@ -29,7 +29,7 @@ tasks {
|
||||
options.links(
|
||||
"https://hub.spigotmc.org/jenkins/job/BungeeCord/ws/api/target/reports/apidocs", // bungeecord api
|
||||
)
|
||||
val apiDocs = File(rootProject.projectDir, "api/build/docs/javadoc")
|
||||
val apiDocs = File(rootProject.projectDir, "redisbungee/api/build/docs/javadoc")
|
||||
options.linksOffline("https://ci.limework.net/ValioBungee/api/build/docs/javadoc", apiDocs.path)
|
||||
}
|
||||
compileJava {
|
||||
|
||||
@ -34,7 +34,7 @@ tasks {
|
||||
options.links(
|
||||
"https://jd.papermc.io/velocity/3.0.0/", // velocity api
|
||||
)
|
||||
val apiDocs = File(rootProject.projectDir, "api/build/docs/javadoc")
|
||||
val apiDocs = File(rootProject.projectDir, "redisbungee/api/build/docs/javadoc")
|
||||
options.linksOffline("https://ci.limework.net/ValioBungee/api/build/docs/javadoc", apiDocs.path)
|
||||
}
|
||||
compileJava {
|
||||
|
||||
@ -21,11 +21,18 @@ package net.limework.valiobungee.velocity;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import net.limework.valiobungee.core.ConstantVariables;
|
||||
import net.limework.valiobungee.core.ValioBungeePlatform;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
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.entities.ImplVelocityNetworkProxy;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@Plugin(
|
||||
id = "valiobungee",
|
||||
@ -38,13 +45,76 @@ public class VelocityValioBungeePlugin implements ValioBungeePlatform {
|
||||
private final ProxyServer server;
|
||||
private final Logger logger;
|
||||
private final Path dataFolder;
|
||||
private final ProxyNetworkManager proxyNetworkManager;
|
||||
|
||||
public VelocityValioBungeePlugin( ProxyServer server, Logger logger, @DataDirectory Path dataDirectory) {
|
||||
public VelocityValioBungeePlugin(
|
||||
ProxyServer server, Logger logger, @DataDirectory Path dataDirectory) {
|
||||
this.server = server;
|
||||
this.logger = logger;
|
||||
this.dataFolder = dataDirectory;
|
||||
// init logging
|
||||
LogProviderFactory.register(logger);
|
||||
this.proxyNetworkManager = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int localOnlinePlayers() {
|
||||
return this.server.getPlayerCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String platformProxyVendor() {
|
||||
return "velocity";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProxyNetworkManager proxyNetworkManager() {
|
||||
return this.proxyNetworkManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String proxyId() {
|
||||
return "test-ido";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String networkId() {
|
||||
return "development";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<NetworkPlayer> getNetworkPlayer(UUID uuid) {
|
||||
logger.warn("not implemented api call returned as Optional empty");
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkProxy getLocalProxy() {
|
||||
return new ImplVelocityNetworkProxy(this, proxyId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<NetworkProxy> getNetworkProxies() {
|
||||
logger.warn("not implemented api call returned as Optional empty");
|
||||
return Set.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<NetworkPlayer> getLocalProxyPlayers() {
|
||||
logger.warn("not implemented api call returned as Optional empty");
|
||||
return Set.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<NetworkPlayer> getNetworkPlayers() {
|
||||
logger.warn("not implemented api call returned as Optional empty");
|
||||
return Set.of();
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,17 +16,15 @@
|
||||
* 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.core.api.entities;
|
||||
package net.limework.valiobungee.velocity.api.entities;
|
||||
|
||||
import java.util.UUID;
|
||||
import net.limework.valiobungee.api.entity.NetworkPlayer;
|
||||
import net.limework.valiobungee.api.entity.NetworkProxy;
|
||||
import net.limework.valiobungee.core.ValioBungeePlatform;
|
||||
import net.limework.valiobungee.core.api.entities.AbstractNetworkPlayer;
|
||||
|
||||
public interface NetworkEntitiesProvider {
|
||||
|
||||
NetworkPlayer getNetworkPlayer(UUID uuid);
|
||||
|
||||
NetworkProxy getNetworkProxy(String id);
|
||||
|
||||
NetworkProxy getSelfProxy();
|
||||
public class ImplVelocityNetworkPlayer extends AbstractNetworkPlayer {
|
||||
public ImplVelocityNetworkPlayer(ValioBungeePlatform platform, UUID uuid, NetworkProxy proxy) {
|
||||
super(platform, uuid, proxy);
|
||||
}
|
||||
}
|
||||
@ -16,8 +16,21 @@
|
||||
* 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.core.api;
|
||||
package net.limework.valiobungee.velocity.api.entities;
|
||||
|
||||
import net.limework.valiobungee.api.ValioBungeeAPI;
|
||||
import java.util.Set;
|
||||
import net.limework.valiobungee.api.entity.NetworkPlayer;
|
||||
import net.limework.valiobungee.core.api.entities.AbstractNetworkProxy;
|
||||
import net.limework.valiobungee.velocity.VelocityValioBungeePlugin;
|
||||
|
||||
public class AbstractValioBungeeAPI implements ValioBungeeAPI {}
|
||||
public class ImplVelocityNetworkProxy extends AbstractNetworkProxy {
|
||||
|
||||
public ImplVelocityNetworkProxy(VelocityValioBungeePlugin platform, String proxyId) {
|
||||
super(platform, proxyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<NetworkPlayer> getProxyPlayers() {
|
||||
return Set.of();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user