mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2026-04-02 13:10:52 +00:00
setup velocity, ValioBungee api
This commit is contained in:
parent
e4fe6014ac
commit
06873938b6
@ -1,20 +1,5 @@
|
||||
description = "Api functions for valiobungee"
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.blossom)
|
||||
alias(libs.plugins.indragit)
|
||||
}
|
||||
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
blossom {
|
||||
javaSources {
|
||||
property("apiversion", project.property("api-version").toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
withJavadocJar()
|
||||
|
||||
@ -15,4 +15,4 @@
|
||||
*/
|
||||
package net.limework.valiobungee.api;
|
||||
|
||||
public interface NetworkPlayer {}
|
||||
public interface ValioBungeeAPI {}
|
||||
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
/**
|
||||
* this class provides the API object and access to the version and git commit
|
||||
*
|
||||
* @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();
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.api.entity;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Network player.
|
||||
*
|
||||
* @author Ham1255
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface NetworkPlayer {
|
||||
/**
|
||||
* @return player unique id
|
||||
*/
|
||||
UUID getUUID();
|
||||
|
||||
/**
|
||||
* @return proxy player on
|
||||
*/
|
||||
NetworkProxy getProxy();
|
||||
}
|
||||
@ -13,7 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package net.limework.valiobungee.api;
|
||||
package net.limework.valiobungee.api.entity;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Proxy is an object for online proxy in a network
|
||||
@ -30,7 +32,12 @@ public interface NetworkProxy {
|
||||
/**
|
||||
* @return online players number in this proxy
|
||||
*/
|
||||
int onlinePlayers();
|
||||
int onlinePlayersCount();
|
||||
|
||||
/**
|
||||
* @return Returns set of players in this proxy
|
||||
*/
|
||||
Set<NetworkPlayer> networkPlayers();
|
||||
|
||||
/**
|
||||
* @return returns true if this object is proxy on it
|
||||
49
api/velocity/build.gradle.kts
Normal file
49
api/velocity/build.gradle.kts
Normal file
@ -0,0 +1,49 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.platform.velocity)
|
||||
api(project(":valiobungee-api"))
|
||||
}
|
||||
|
||||
description = "ValioBungee Velocity API"
|
||||
|
||||
java {
|
||||
withJavadocJar()
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
tasks {
|
||||
withType<Javadoc> {
|
||||
dependsOn(project(":valiobungee-api").getTasksByName("javadoc", false))
|
||||
val options = options as StandardJavadocDocletOptions
|
||||
options.use()
|
||||
options.isDocFilesSubDirs = true
|
||||
options.links(
|
||||
"https://jd.papermc.io/velocity/3.5.0/", // velocity api
|
||||
)
|
||||
val apiDocs = File(rootProject.projectDir, "api/build/docs/javadoc")
|
||||
//options.linksOffline("https://ci.limework.net/ValioBungee/api/build/docs/javadoc", apiDocs.path)
|
||||
}
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.release.set(21) // required by velocity
|
||||
}
|
||||
javadoc {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
}
|
||||
processResources {
|
||||
filteringCharset = Charsets.UTF_8.name()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -13,9 +13,8 @@
|
||||
* 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;
|
||||
|
||||
public class APIConstantVariables {
|
||||
import net.limework.valiobungee.api.ValioBungeeAPI;
|
||||
|
||||
public static final String API_VERSION = "{{ apiversion }}";
|
||||
}
|
||||
public interface VelocityValioBungeeAPI extends ValioBungeeAPI {}
|
||||
@ -26,11 +26,13 @@ subprojects {
|
||||
}
|
||||
extensions.configure<com.diffplug.gradle.spotless.SpotlessExtension> {
|
||||
var redisBungeeProjects = sequenceOf("RedisBungee-API", "RedisBungee-Lang", "RedisBungee-Commands", "RedisBungee-Bungee", "RedisBungee-Proxy-Bungee", "RedisBungee-Velocity", "RedisBungee-Proxy-Velocity")
|
||||
var apiProjects = sequenceOf("valiobungee-api", "valiobungee-velocity-api")
|
||||
|
||||
java {
|
||||
removeUnusedImports()
|
||||
googleJavaFormat()
|
||||
if (project.name == "valiobungee-api") {
|
||||
licenseHeaderFile(file("copyright_header.txt"))
|
||||
if (apiProjects.contains(project.name)) {
|
||||
licenseHeaderFile(rootProject.file("api/copyright_header.txt"))
|
||||
} else if (redisBungeeProjects.contains(project.name)) {
|
||||
licenseHeaderFile(rootProject.file("redisbungee/copyright_header.txt"))
|
||||
} else {
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.core;
|
||||
|
||||
public abstract class PlayerManager {}
|
||||
@ -18,7 +18,10 @@
|
||||
*/
|
||||
package net.limework.valiobungee.core;
|
||||
|
||||
public interface ValioBungeePlatform {
|
||||
import net.limework.valiobungee.api.ValioBungeeAPIProvider;
|
||||
import net.limework.valiobungee.core.api.entities.NetworkEntitiesProvider;
|
||||
|
||||
public interface ValioBungeePlatform extends NetworkEntitiesProvider, ValioBungeeAPIProvider {
|
||||
|
||||
int localOnlinePlayers();
|
||||
|
||||
@ -29,4 +32,14 @@ public interface ValioBungeePlatform {
|
||||
String proxyId();
|
||||
|
||||
ProxyManager proxyManager();
|
||||
|
||||
@Override
|
||||
default String getGitCommit() {
|
||||
return ConstantVariables.GIT_COMMIT;
|
||||
}
|
||||
|
||||
@Override
|
||||
default String getVersion() {
|
||||
return ConstantVariables.VERSION;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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.core.api;
|
||||
|
||||
import net.limework.valiobungee.api.ValioBungeeAPI;
|
||||
|
||||
public class AbstractValioBungeeAPI implements ValioBungeeAPI {}
|
||||
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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.core.api.entities;
|
||||
|
||||
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.core.ValioBungeePlatform;
|
||||
|
||||
public abstract class AbstractNetworkPlayer implements NetworkPlayer {
|
||||
|
||||
private final ValioBungeePlatform platform;
|
||||
private final UUID uuid;
|
||||
private final NetworkProxy proxy;
|
||||
|
||||
public AbstractNetworkPlayer(ValioBungeePlatform platform, UUID uuid, NetworkProxy proxy) {
|
||||
this.platform = platform;
|
||||
this.uuid = uuid;
|
||||
this.proxy = proxy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkProxy getProxy() {
|
||||
return this.proxy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof AbstractNetworkPlayer that)) return false;
|
||||
return Objects.equals(uuid, that.uuid) && Objects.equals(proxy, that.proxy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(uuid, proxy);
|
||||
}
|
||||
}
|
||||
@ -16,18 +16,19 @@
|
||||
* 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.impl;
|
||||
package net.limework.valiobungee.core.api.entities;
|
||||
|
||||
import net.limework.valiobungee.api.NetworkProxy;
|
||||
import java.util.Objects;
|
||||
import net.limework.valiobungee.api.entity.NetworkProxy;
|
||||
import net.limework.valiobungee.core.ValioBungeePlatform;
|
||||
|
||||
public class ImplNetworkProxy implements NetworkProxy {
|
||||
public abstract class AbstractNetworkProxy implements NetworkProxy {
|
||||
|
||||
private final ValioBungeePlatform platform;
|
||||
|
||||
private final String proxyId;
|
||||
|
||||
public ImplNetworkProxy(ValioBungeePlatform platform, String proxyId) {
|
||||
public AbstractNetworkProxy(ValioBungeePlatform platform, String proxyId) {
|
||||
this.platform = platform;
|
||||
this.proxyId = proxyId;
|
||||
}
|
||||
@ -38,7 +39,7 @@ public class ImplNetworkProxy implements NetworkProxy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onlinePlayers() {
|
||||
public int onlinePlayersCount() {
|
||||
return this.platform.proxyManager().onlinePlayersCount(this.proxyId);
|
||||
}
|
||||
|
||||
@ -46,4 +47,15 @@ public class ImplNetworkProxy implements NetworkProxy {
|
||||
public boolean isMe() {
|
||||
return this.platform.proxyId().equals(proxyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof AbstractNetworkProxy that)) return false;
|
||||
return Objects.equals(proxyId, that.proxyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(proxyId);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.core.api.entities;
|
||||
|
||||
import java.util.UUID;
|
||||
import net.limework.valiobungee.api.entity.NetworkPlayer;
|
||||
import net.limework.valiobungee.api.entity.NetworkProxy;
|
||||
|
||||
public interface NetworkEntitiesProvider {
|
||||
|
||||
NetworkPlayer getNetworkPlayer(UUID uuid);
|
||||
|
||||
NetworkProxy getNetworkProxy(String id);
|
||||
|
||||
NetworkProxy getSelfProxy();
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
group=net.limework
|
||||
version=1.0.0-SNAPSHOT
|
||||
api-version=v1
|
||||
|
||||
redisbungee-group=com.imaginarycode.minecraft
|
||||
redisbungee-version=0.13.0-SNAPSHOT
|
||||
@ -1,4 +1,5 @@
|
||||
@file:Suppress("UnstableApiUsage")
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
@ -11,6 +12,12 @@ fun configureProject(name: String) {
|
||||
val projectName = ":valiobungee-$name"
|
||||
configureProject(projectName, name)
|
||||
}
|
||||
|
||||
fun configureAPIProject(name: String) {
|
||||
val projectName = ":valiobungee-$name-api"
|
||||
configureProject(projectName, "api/$name")
|
||||
}
|
||||
|
||||
fun configureProject(name: String, path: String) {
|
||||
include(name)
|
||||
project(name).projectDir = file(path)
|
||||
@ -27,7 +34,10 @@ dependencyResolutionManagement {
|
||||
}
|
||||
|
||||
// main project stuff
|
||||
sequenceOf("core", "api").forEach{configureProject(it)}
|
||||
sequenceOf("api", "core", "velocity").forEach { configureProject(it) }
|
||||
// api
|
||||
sequenceOf("velocity").forEach { configureAPIProject(it) }
|
||||
|
||||
// RedisBunggee Project
|
||||
configureProject(":RedisBungee-API", "redisbungee/api")
|
||||
configureProject(":RedisBungee-Lang", "redisbungee/lang")
|
||||
|
||||
35
velocity/build.gradle.kts
Normal file
35
velocity/build.gradle.kts
Normal file
@ -0,0 +1,35 @@
|
||||
plugins {
|
||||
java
|
||||
alias(libs.plugins.shadow)
|
||||
alias(libs.plugins.run.velocity)
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
implementation(project(":valiobungee-velocity-api"))
|
||||
implementation(project(":valiobungee-core"))
|
||||
compileOnly(libs.platform.velocity)
|
||||
annotationProcessor(libs.platform.velocity)
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
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;
|
||||
|
||||
@Plugin(
|
||||
id = "valiobungee",
|
||||
name = "valiobungee",
|
||||
version = ConstantVariables.VERSION,
|
||||
url = "https://github.com/ProxioDev/ValioBungee",
|
||||
authors = {"limework", "ProxioDev"})
|
||||
public class VelocityValioBungeePlugin implements ValioBungeePlatform {
|
||||
|
||||
private final ProxyServer server;
|
||||
private final Logger logger;
|
||||
private final Path dataFolder;
|
||||
|
||||
public VelocityValioBungeePlugin( ProxyServer server, Logger logger, @DataDirectory Path dataDirectory) {
|
||||
this.server = server;
|
||||
this.logger = logger;
|
||||
this.dataFolder = dataDirectory;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user