mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2026-04-25 16:00:27 +00:00
unfinished new plugin message system
This commit is contained in:
31
plugin-message-api/redisbungee/build.gradle.kts
Normal file
31
plugin-message-api/redisbungee/build.gradle.kts
Normal file
@@ -0,0 +1,31 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":Limework-Plugin-Message-API-Protocol"))
|
||||
compileOnly(libs.guava)
|
||||
}
|
||||
|
||||
tasks {
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.release.set(8) // use java 8 for shit servers that still stuck on 1.8
|
||||
}
|
||||
javadoc {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
}
|
||||
processResources {
|
||||
filteringCharset = Charsets.UTF_8.name()
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.limework.valiobungee.pluginmessage.models;
|
||||
|
||||
public class Proxy {
|
||||
|
||||
private String proxyId;
|
||||
|
||||
private int players;
|
||||
|
||||
public Proxy() {
|
||||
}
|
||||
|
||||
public Proxy(String proxyId, int players) {
|
||||
this.proxyId = proxyId;
|
||||
this.players = players;
|
||||
}
|
||||
|
||||
public String proxyId() {
|
||||
return proxyId;
|
||||
}
|
||||
|
||||
public int players() {
|
||||
return players;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package net.limework.valiobungee.pluginmessage.protocol;
|
||||
|
||||
import net.limework.pluginmessageapi.protocol.PluginMessageHandler;
|
||||
import net.limework.valiobungee.pluginmessage.protocol.messages.proxybound.RequestProxiesListMessage;
|
||||
|
||||
public class ProxyboundHandler implements PluginMessageHandler {
|
||||
|
||||
public void handle(RequestProxiesListMessage message) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.limework.valiobungee.pluginmessage.protocol;
|
||||
|
||||
import net.limework.pluginmessageapi.protocol.PluginMessageHandler;
|
||||
import net.limework.valiobungee.pluginmessage.protocol.messages.servebound.ProxiesListMessage;
|
||||
|
||||
public class ServerboundHandler implements PluginMessageHandler {
|
||||
|
||||
public void handle(ProxiesListMessage message) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.limework.valiobungee.pluginmessage.protocol.messages.proxybound;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import net.limework.pluginmessageapi.protocol.PluginMessage;
|
||||
|
||||
|
||||
public abstract class RequestMessage extends PluginMessage {
|
||||
|
||||
|
||||
public RequestMessage() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteArrayDataOutput out) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(ByteArrayDataInput in) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package net.limework.valiobungee.pluginmessage.protocol.messages.proxybound;
|
||||
|
||||
import net.limework.pluginmessageapi.protocol.PluginMessageHandler;
|
||||
import net.limework.valiobungee.pluginmessage.protocol.ProxyboundHandler;
|
||||
|
||||
public class RequestProxiesListMessage extends RequestMessage{
|
||||
@Override
|
||||
public void handle(PluginMessageHandler handler) {
|
||||
((ProxyboundHandler) handler).handle(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package net.limework.valiobungee.pluginmessage.protocol.messages.servebound;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import net.limework.pluginmessageapi.protocol.PluginMessage;
|
||||
import net.limework.pluginmessageapi.protocol.PluginMessageHandler;
|
||||
import net.limework.valiobungee.pluginmessage.models.Proxy;
|
||||
import net.limework.valiobungee.pluginmessage.protocol.ServerboundHandler;
|
||||
|
||||
public class ProxiesListMessage extends PluginMessage {
|
||||
|
||||
private Proxy[] proxies;
|
||||
|
||||
public ProxiesListMessage(Proxy[] proxies) {
|
||||
this.proxies = proxies;
|
||||
}
|
||||
|
||||
public Proxy[] proxies() {
|
||||
return proxies;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(ByteArrayDataInput in) {
|
||||
int proxiesNumber = in.readInt();
|
||||
this.proxies = new Proxy[proxiesNumber];
|
||||
for (int i = 0; i < proxiesNumber; i++) {
|
||||
String id = in.readUTF();
|
||||
int players = in.readInt();
|
||||
proxies[i] = new Proxy(id, players);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteArrayDataOutput out) {
|
||||
out.writeInt(proxies.length);
|
||||
for (Proxy proxy : proxies) {
|
||||
out.writeUTF(proxy.proxyId());
|
||||
out.writeInt(proxy.players());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PluginMessageHandler handler) {
|
||||
((ServerboundHandler) handler).handle(this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user