mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-24 13:08:02 +00:00
redo module system
This commit is contained in:
parent
e8514b3e8b
commit
765e6fe122
6
.github/workflows/gradle.yml
vendored
6
.github/workflows/gradle.yml
vendored
@ -29,14 +29,14 @@ jobs:
|
||||
# Artifact name
|
||||
name: RedisBungee-Bungee
|
||||
# Destination path
|
||||
path: RedisBungee-Bungee/build/libs/*
|
||||
path: Bungee/build/libs/*
|
||||
- name: Upload Velocity
|
||||
uses: actions/upload-artifact@v2.2.3
|
||||
with:
|
||||
name: RedisBungee-Velocity
|
||||
path: RedisBungee-Velocity/build/libs/*
|
||||
path: Velocity/build/libs/*
|
||||
- name: Upload API
|
||||
uses: actions/upload-artifact@v2.2.3
|
||||
with:
|
||||
name: RedisBungee-API
|
||||
path: RedisBungee-API/build/libs/*
|
||||
path: API/build/libs/*
|
||||
|
@ -1,6 +1,5 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@ -23,11 +22,3 @@ tasks {
|
||||
filteringCharset = Charsets.UTF_8.name()
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +1,11 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
java
|
||||
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||
id("xyz.jpenilla.run-waterfall") version "2.0.0"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":RedisBungee-API"))
|
||||
implementation(project(":RedisBungee-Bungee"))
|
||||
compileOnly(libs.platform.bungeecord) {
|
||||
exclude("com.google.guava", "guava")
|
||||
exclude("com.google.code.gson", "gson")
|
||||
@ -81,11 +80,3 @@ tasks {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
}
|
51
proxies/bungeecord/bungeecord-api/build.gradle.kts
Normal file
51
proxies/bungeecord/bungeecord-api/build.gradle.kts
Normal file
@ -0,0 +1,51 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":RedisBungee-API"))
|
||||
compileOnly(libs.platform.bungeecord) {
|
||||
exclude("com.google.guava", "guava")
|
||||
exclude("com.google.code.gson", "gson")
|
||||
exclude("net.kyori","adventure-api")
|
||||
}
|
||||
}
|
||||
|
||||
description = "RedisBungee Bungeecord API"
|
||||
|
||||
java {
|
||||
withJavadocJar()
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
|
||||
tasks {
|
||||
withType<Javadoc> {
|
||||
dependsOn(project(":RedisBungee-API").getTasksByName("javadoc", false))
|
||||
val path = project(":RedisBungee-API").path
|
||||
val options = options as StandardJavadocDocletOptions
|
||||
options.use()
|
||||
options.isDocFilesSubDirs = true
|
||||
options.links(
|
||||
"https://ci.md-5.net/job/BungeeCord/ws/api/target/apidocs/", // bungeecord api
|
||||
)
|
||||
val apiDocs = File(rootProject.projectDir, "$path/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(17)
|
||||
}
|
||||
javadoc {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2013-present RedisBungee contributors
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
|
||||
package com.imaginarycode.minecraft.redisbungee;
|
||||
|
||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* This platform class exposes some internal RedisBungee functions. You obtain an instance of this object by invoking {@link RedisBungeeAPI#getRedisBungeeApi()}
|
||||
* or somehow you got the Plugin instance by you can call the api using {@link RedisBungeePlugin#getAbstractRedisBungeeApi()}.
|
||||
*
|
||||
* @author tuxed
|
||||
* @since 0.2.3 | updated 0.8.0
|
||||
*/
|
||||
public class RedisBungeeAPI extends AbstractRedisBungeeAPI {
|
||||
|
||||
private static RedisBungeeAPI redisBungeeApi;
|
||||
|
||||
public RedisBungeeAPI(RedisBungeePlugin<?> plugin) {
|
||||
super(plugin);
|
||||
if (redisBungeeApi == null) {
|
||||
redisBungeeApi = this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the server where the specified player is playing. This function also deals with the case of local players
|
||||
* as well, and will return local information on them.
|
||||
*
|
||||
* @param player a player uuid
|
||||
* @return {@link ServerInfo} Can be null if proxy can't find it.
|
||||
* @see #getServerNameFor(UUID)
|
||||
*/
|
||||
@Nullable
|
||||
public final ServerInfo getServerFor(@NonNull UUID player) {
|
||||
String serverName = this.getServerNameFor(player);
|
||||
if (serverName == null) return null;
|
||||
return ((Plugin) this.plugin).getProxy().getServerInfo(serverName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api instance
|
||||
*
|
||||
* @return the API instance.
|
||||
* @since 0.6.5
|
||||
*/
|
||||
public static RedisBungeeAPI getRedisBungeeApi() {
|
||||
return redisBungeeApi;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2013-present RedisBungee contributors
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
|
||||
package com.imaginarycode.minecraft.redisbungee.events;
|
||||
|
||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerChangedServerNetworkEvent;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* This event is sent when a player connects to a new server. RedisBungee sends the event only when
|
||||
* the proxy the player has been connected to is different than the local proxy.
|
||||
* <p>
|
||||
* This event corresponds to {@link net.md_5.bungee.api.event.ServerConnectedEvent}, and is fired
|
||||
* asynchronously.
|
||||
*
|
||||
* @since 0.3.4
|
||||
*/
|
||||
public class PlayerChangedServerNetworkEvent extends Event implements IPlayerChangedServerNetworkEvent {
|
||||
private final UUID uuid;
|
||||
private final String previousServer;
|
||||
private final String server;
|
||||
|
||||
public PlayerChangedServerNetworkEvent(UUID uuid, String previousServer, String server) {
|
||||
this.uuid = uuid;
|
||||
this.previousServer = previousServer;
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreviousServer() {
|
||||
return previousServer;
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2013-present RedisBungee contributors
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
|
||||
package com.imaginarycode.minecraft.redisbungee.events;
|
||||
|
||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerJoinedNetworkEvent;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* This event is sent when a player joins the network. RedisBungee sends the event only when
|
||||
* the proxy the player has been connected to is different than the local proxy.
|
||||
* <p>
|
||||
* This event corresponds to {@link net.md_5.bungee.api.event.PostLoginEvent}, and is fired
|
||||
* asynchronously.
|
||||
*
|
||||
* @since 0.3.4
|
||||
*/
|
||||
public class PlayerJoinedNetworkEvent extends Event implements IPlayerJoinedNetworkEvent {
|
||||
private final UUID uuid;
|
||||
|
||||
public PlayerJoinedNetworkEvent(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2013-present RedisBungee contributors
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
|
||||
package com.imaginarycode.minecraft.redisbungee.events;
|
||||
|
||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerLeftNetworkEvent;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* This event is sent when a player disconnects. RedisBungee sends the event only when
|
||||
* the proxy the player has been connected to is different than the local proxy.
|
||||
* <p>
|
||||
* This event corresponds to {@link net.md_5.bungee.api.event.PlayerDisconnectEvent}, and is fired
|
||||
* asynchronously.
|
||||
*
|
||||
* @since 0.3.4
|
||||
*/
|
||||
public class PlayerLeftNetworkEvent extends Event implements IPlayerLeftNetworkEvent {
|
||||
private final UUID uuid;
|
||||
|
||||
public PlayerLeftNetworkEvent(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2013-present RedisBungee contributors
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
|
||||
package com.imaginarycode.minecraft.redisbungee.events;
|
||||
|
||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPubSubMessageEvent;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
/**
|
||||
* This event is posted when a PubSub message is received.
|
||||
* <p>
|
||||
* <strong>Warning</strong>: This event is fired in a separate thread!
|
||||
*
|
||||
* @since 0.2.6
|
||||
*/
|
||||
|
||||
public class PubSubMessageEvent extends Event implements IPubSubMessageEvent {
|
||||
private final String channel;
|
||||
private final String message;
|
||||
|
||||
public PubSubMessageEvent(String channel, String message) {
|
||||
this.channel = channel;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
@ -1,25 +1,11 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
java
|
||||
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||
id("xyz.jpenilla.run-velocity") version "2.0.0"
|
||||
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
api(project(":RedisBungee-API")) {
|
||||
// Since velocity already includes guava / configurate exlude them
|
||||
exclude("com.google.guava", "guava")
|
||||
exclude("com.google.code.gson", "gson")
|
||||
exclude("org.spongepowered", "configurate-yaml")
|
||||
// exclude also adventure api
|
||||
exclude("net.kyori", "adventure-api")
|
||||
exclude("net.kyori", "adventure-text-serializer-gson")
|
||||
exclude("net.kyori", "adventure-text-serializer-legacy")
|
||||
exclude("net.kyori", "adventure-text-serializer-plain")
|
||||
exclude("net.kyori", "adventure-text-minimessage")
|
||||
}
|
||||
implementation(project(":RedisBungee-Velocity"))
|
||||
compileOnly(libs.platform.velocity)
|
||||
annotationProcessor(libs.platform.velocity)
|
||||
implementation(project(":RedisBungee-Commands"))
|
||||
@ -29,23 +15,8 @@ dependencies {
|
||||
|
||||
description = "RedisBungee Velocity implementation"
|
||||
|
||||
java {
|
||||
withJavadocJar()
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
tasks {
|
||||
withType<Javadoc> {
|
||||
dependsOn(project(":RedisBungee-API").getTasksByName("javadoc", false))
|
||||
val options = options as StandardJavadocDocletOptions
|
||||
options.use()
|
||||
options.isDocFilesSubDirs = true
|
||||
options.links(
|
||||
"https://jd.papermc.io/velocity/3.0.0/", // velocity api
|
||||
)
|
||||
val apiDocs = File(rootProject.projectDir, "RedisBungee-API/build/docs/javadoc")
|
||||
options.linksOffline("https://ci.limework.net/RedisBungee/RedisBungee-API/build/docs/javadoc", apiDocs.path)
|
||||
}
|
||||
runVelocity {
|
||||
velocityVersion("3.3.0-SNAPSHOT")
|
||||
environment["REDISBUNGEE_PROXY_ID"] = "velocity-1"
|
||||
@ -55,9 +26,6 @@ tasks {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.release.set(17)
|
||||
}
|
||||
javadoc {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
}
|
||||
processResources {
|
||||
filteringCharset = Charsets.UTF_8.name()
|
||||
}
|
||||
@ -75,10 +43,3 @@ tasks {
|
||||
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
}
|
@ -68,7 +68,7 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Plugin(id = "redisbungee", name = "RedisBungee", version = Constants.VERSION, url = "https://github.com/ProxioDev/RedisBungee", authors = {"astei", "ProxioDev"})
|
||||
public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, ConfigLoader, LangConfigLoader {
|
||||
public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, ConfigLoader, LangConfigLoader, ServerObjectFetcher {
|
||||
private final ProxyServer server;
|
||||
private final Logger logger;
|
||||
private final Path dataFolder;
|
62
proxies/velocity/velocity-api/build.gradle.kts
Normal file
62
proxies/velocity/velocity-api/build.gradle.kts
Normal file
@ -0,0 +1,62 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":RedisBungee-API")) {
|
||||
// Since velocity already includes guava / configurate exlude them
|
||||
exclude("com.google.guava", "guava")
|
||||
exclude("com.google.code.gson", "gson")
|
||||
exclude("org.spongepowered", "configurate-yaml")
|
||||
// exclude also adventure api
|
||||
exclude("net.kyori", "adventure-api")
|
||||
exclude("net.kyori", "adventure-text-serializer-gson")
|
||||
exclude("net.kyori", "adventure-text-serializer-legacy")
|
||||
exclude("net.kyori", "adventure-text-serializer-plain")
|
||||
exclude("net.kyori", "adventure-text-minimessage")
|
||||
}
|
||||
compileOnly(libs.platform.velocity)
|
||||
|
||||
}
|
||||
|
||||
description = "RedisBungee Velocity API"
|
||||
|
||||
java {
|
||||
withJavadocJar()
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
tasks {
|
||||
withType<Javadoc> {
|
||||
dependsOn(project(":RedisBungee-API").getTasksByName("javadoc", false))
|
||||
val path = project(":RedisBungee-API").path;
|
||||
val options = options as StandardJavadocDocletOptions
|
||||
options.use()
|
||||
options.isDocFilesSubDirs = true
|
||||
options.links(
|
||||
"https://jd.papermc.io/velocity/3.0.0/", // velocity api
|
||||
)
|
||||
val apiDocs = File(rootProject.projectDir, "$path/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(17)
|
||||
}
|
||||
javadoc {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
}
|
||||
processResources {
|
||||
filteringCharset = Charsets.UTF_8.name()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
}
|
@ -49,7 +49,7 @@ public class RedisBungeeAPI extends AbstractRedisBungeeAPI {
|
||||
public final ServerInfo getServerFor(@NonNull UUID player) {
|
||||
String serverName = this.getServerNameFor(player);
|
||||
if (serverName == null) return null;
|
||||
return ((RedisBungeeVelocityPlugin) this.plugin).getProxy().getServer(serverName).map((RegisteredServer::getServerInfo)).orElse(null);
|
||||
return ((ServerObjectFetcher) this.plugin).getProxy().getServer(serverName).map((RegisteredServer::getServerInfo)).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
@ -0,0 +1,10 @@
|
||||
package com.imaginarycode.minecraft.redisbungee;
|
||||
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
|
||||
public interface ServerObjectFetcher {
|
||||
|
||||
ProxyServer getProxy();
|
||||
|
||||
|
||||
}
|
@ -4,12 +4,31 @@ pluginManagement {
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "RedisBungee-Parent"
|
||||
rootProject.name = "ValioBungee"
|
||||
|
||||
include(":RedisBungee-API")
|
||||
project(":RedisBungee-API").projectDir = file("api")
|
||||
|
||||
include(":RedisBungee-Commands")
|
||||
project(":RedisBungee-Commands").projectDir = file("commands")
|
||||
|
||||
include(":RedisBungee-Velocity")
|
||||
include(":RedisBungee-Commands")
|
||||
project(":RedisBungee-Velocity").projectDir = file("proxies/velocity")
|
||||
|
||||
include(":RedisBungee-Bungee")
|
||||
include(":RedisBungee-API")
|
||||
project(":RedisBungee-Bungee").projectDir = file("proxies/bungeecord/bungeecord-api")
|
||||
|
||||
include(":RedisBungee-Proxy-Bungee")
|
||||
project(":RedisBungee-Proxy-Bungee").projectDir = file("proxies/bungeecord")
|
||||
|
||||
include(":RedisBungee-Velocity")
|
||||
project(":RedisBungee-Velocity").projectDir = file("proxies/velocity/velocity-api")
|
||||
|
||||
include(":RedisBungee-Proxy-Velocity")
|
||||
project(":RedisBungee-Proxy-Velocity").projectDir = file("proxies/velocity")
|
||||
|
||||
|
||||
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
@ -73,4 +92,4 @@ dependencyResolutionManagement {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user