Skip to content

Commit

Permalink
Merge pull request #2 from Aelysium-Group/development
Browse files Browse the repository at this point in the history
- Added Folia Implementation
- Updated /tpa to work with Folia
- Rewrite base-level RC core api
- Remove garbage debug logs (woops!)
- Fix null API call on Proxy heartbeat init
  • Loading branch information
nathan-i-martin authored Apr 17, 2023
2 parents 11dec72 + 48c4bd1 commit 66d02ff
Show file tree
Hide file tree
Showing 63 changed files with 1,064 additions and 795 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
# [Modrinth](https://modrinth.com/plugin/rustyconnector) | [Paper Forums](https://forums.papermc.io/threads/rustyconnector-advanced-velocity-server-and-player-connection-manager.663/) | [Hangar](https://hangar.papermc.io/nathan-i-martin/RustyConnector)
---
- ### ✅ Built for large networks
- ### ✅ Register brand new servers to the proxy during runtime
- ### ✅ Register brand new servers to the virtualProxyProcessor during runtime
- ### ✅ Blazing fast data transmission with Redis integration
- ### ✅ Create pre-defined whitelist configs and activate them dynamically
- ### ✅ Register similar servers into families with family-level whitelists and load balancing
- ### ✅ Automatically unregister frozen servers from the proxy
- ### ✅ Automatically unregister frozen servers from the virtualProxyProcessor
- ### ✅ Set soft and hard player limits for servers
- ### ✅ Whitelist players based on permission, Username, UUID, or IP Address
- ### ✅ Allow players to /tpa between servers
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package group.aelysium.rustyconnector.core.central;

import group.aelysium.rustyconnector.core.lib.model.VirtualProcessor;

import java.io.InputStream;

public abstract class PluginAPI<S> {
/**
* Gets a resource by name and returns it as a stream.
* @param filename The name of the resource to get.
* @return The resource as a stream.
*/
abstract public InputStream getResourceAsStream(String filename);

abstract public S getScheduler();

abstract public PluginLogger getLogger();

abstract public VirtualProcessor getVirtualProcessor();

abstract public String getDataFolder();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package group.aelysium.rustyconnector.core.central;

import group.aelysium.rustyconnector.core.lib.exception.DuplicateLifecycleException;

public abstract class PluginLifecycle {
protected boolean isRunning = false;

public boolean isRunning() {
return this.isRunning;
}

public abstract boolean start() throws DuplicateLifecycleException;
public abstract void stop();

protected abstract boolean loadConfigs();
protected abstract boolean loadCommands();
protected abstract boolean loadEvents();
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package group.aelysium.rustyconnector.core.lib.lang_messaging;
package group.aelysium.rustyconnector.core.central;

import group.aelysium.rustyconnector.core.lib.lang_messaging.LoggerGate;
import net.kyori.adventure.text.Component;

public interface Logger {
public interface PluginLogger {
LoggerGate getGate();

void log(String message);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package group.aelysium.rustyconnector.core.central;

import group.aelysium.rustyconnector.core.lib.database.Redis;

public interface PluginRuntime {
Redis redis = null;

static PluginAPI<?> getAPI() {
return null;
}

static PluginLifecycle getLifecycle() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package group.aelysium.rustyconnector.core.lib.database;

import group.aelysium.rustyconnector.core.central.PluginAPI;
import group.aelysium.rustyconnector.core.central.PluginLogger;
import group.aelysium.rustyconnector.core.lib.data_messaging.RedisMessageType;
import group.aelysium.rustyconnector.core.lib.lang_messaging.Lang;
import net.kyori.adventure.text.Component;
Expand All @@ -8,7 +10,7 @@
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.JedisPubSub;
import group.aelysium.rustyconnector.core.RustyConnector;
import group.aelysium.rustyconnector.core.central.PluginRuntime;

import java.net.InetSocketAddress;
import java.util.Map;
Expand All @@ -27,20 +29,15 @@ public class Redis {

public Redis() {}

/**
* Sets the connection
*/
public void setConnection(String host, int port, String password, String dataChannel) {
this.host = host;
this.port = port;
this.password = password;
this.dataChannel = dataChannel;
}

/**
* Tests the connection to the provided Redis server
*/
public void connect(RustyConnector plugin) throws ExceptionInInitializerError{

public void connect(PluginAPI api) throws ExceptionInInitializerError {
try{
if(!(this.client == null)) return;

Expand All @@ -50,9 +47,10 @@ public void connect(RustyConnector plugin) throws ExceptionInInitializerError{

final JedisPoolConfig poolConfig = new JedisPoolConfig();
this.pool = new JedisPool(poolConfig, this.host, this.port, 0);

this.jedisSubscriber = this.pool.getResource();
this.jedisSubscriber.auth(this.password);
this.subscriber = new Subscriber(plugin);
this.subscriber = new Subscriber(api);

this.subscriberThread = new Thread(() -> {
try {
Expand All @@ -64,17 +62,14 @@ public void connect(RustyConnector plugin) throws ExceptionInInitializerError{

this.subscriberThread.start();
} catch (Exception e) {
Lang.BOXED_MESSAGE_COLORED.send(plugin.logger(), Component.text("REDIS: "+ e.getMessage()), NamedTextColor.RED);
Lang.BOXED_MESSAGE_COLORED.send(api.getLogger(), Component.text("REDIS: "+ e.getMessage()), NamedTextColor.RED);
}
}

protected void publish(String message) throws IllegalArgumentException {
this.client.publish(this.dataChannel, message);
}

/**
* When redis disconnects
*/
public void disconnect() throws ExceptionInInitializerError {
try {
this.subscriber.unsubscribe();
Expand All @@ -97,10 +92,10 @@ public void disconnect() throws ExceptionInInitializerError {
public void onMessage(String rawMessage) {}

public class Subscriber extends JedisPubSub {
private RustyConnector plugin;
private PluginAPI api;

public Subscriber(RustyConnector plugin) {
this.plugin = plugin;
public Subscriber(PluginAPI api) {
this.api = api;
}

@Override
Expand All @@ -121,6 +116,5 @@ public void onMessage(String channel, String rawMessage) {
* @param parameters Additional parameters
* @throws IllegalArgumentException If message parameters contains parameters: `pk`, `type`, or `ip`
*/
public void sendMessage(String privateKey, RedisMessageType type, InetSocketAddress address, Map<String, String> parameters) throws IllegalArgumentException {
}
public void sendMessage(String privateKey, RedisMessageType type, InetSocketAddress address, Map<String, String> parameters) throws IllegalArgumentException {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package group.aelysium.rustyconnector.core.lib.exception;

public class DuplicateLifecycleException extends Exception {
public DuplicateLifecycleException(String errorMessage) {
super(errorMessage);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package group.aelysium.rustyconnector.core.lib.lang_messaging;

import group.aelysium.rustyconnector.core.central.PluginLogger;
import group.aelysium.rustyconnector.core.lib.data_messaging.cache.CacheableMessage;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.JoinConfiguration;
Expand Down Expand Up @@ -164,11 +165,11 @@ static JoinConfiguration newlines() {
interface Message {
Component build();

default void send(Logger sender) {
default void send(PluginLogger sender) {
sender.send(
join(
newlines(),
text(""),
text("RustyConnector:"),
build()
)
);
Expand All @@ -177,11 +178,11 @@ default void send(Logger sender) {
interface ParameterizedMessage1<A1> {
Component build(A1 arg1);

default void send(Logger sender, A1 arg1) {
default void send(PluginLogger sender, A1 arg1) {
sender.send(
join(
JoinConfiguration.separator(newline()),
text(""),
text("RustyConnector:"),
build(arg1)
)
);
Expand All @@ -190,11 +191,11 @@ default void send(Logger sender, A1 arg1) {
interface ParameterizedMessage2<A1, A2> {
Component build(A1 arg1, A2 arg2);

default void send(Logger sender, A1 arg1, A2 arg2) {
default void send(PluginLogger sender, A1 arg1, A2 arg2) {
sender.send(
join(
newlines(),
text(""),
text("RustyConnector:"),
build(arg1, arg2)
)
);
Expand All @@ -203,11 +204,11 @@ default void send(Logger sender, A1 arg1, A2 arg2) {
interface ParameterizedMessage3<A1, A2, A3> {
Component build(A1 arg1, A2 arg2, A3 arg3);

default void send(Logger sender, A1 arg1, A2 arg2, A3 arg3) {
default void send(PluginLogger sender, A1 arg1, A2 arg2, A3 arg3) {
sender.send(
join(
newlines(),
text(""),
text("RustyConnector:"),
build(arg1, arg2, arg3)
)
);
Expand All @@ -216,11 +217,11 @@ default void send(Logger sender, A1 arg1, A2 arg2, A3 arg3) {
interface ParameterizedMessage4<A1, A2, A3, A4> {
Component build(A1 arg1, A2 arg2, A3 arg3, A4 arg4);

default void send(Logger sender, A1 arg1, A2 arg2, A3 arg3, A4 arg4) {
default void send(PluginLogger sender, A1 arg1, A2 arg2, A3 arg3, A4 arg4) {
sender.send(
join(
newlines(),
text(""),
text("RustyConnector:"),
build(arg1, arg2, arg3, arg4)
)
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package group.aelysium.rustyconnector.core.lib.model;

public interface Server extends Sortable {
public interface PlayerServer extends Sortable {

/**
* Get the number of players on this server
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package group.aelysium.rustyconnector.core.lib.model;

public interface VirtualProcessor {
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package group.aelysium.rustyconnector.core.lib.util;

import group.aelysium.rustyconnector.core.lib.lang_messaging.Logger;
import group.aelysium.rustyconnector.core.central.PluginLogger;
import group.aelysium.rustyconnector.core.lib.model.Sortable;

import java.util.*;
Expand All @@ -12,7 +12,7 @@ public class WeightedQuickSort {
* Assumes that start is 0 and the final index is equal to size.
* @param array The array to sort.
*/
public static <I extends Sortable> void sort(List<I> array, Logger logger) {
public static <I extends Sortable> void sort(List<I> array) {
QuickSort.sort(array); // Put array in order of index.

// Pull out different weight levels and put them into their own lists.
Expand Down
16 changes: 16 additions & 0 deletions paper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>dev.folia</groupId>
<artifactId>folia-api</artifactId>
<version>1.19.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</exclusion>
<exclusion>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-gson</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>group.aelysium.rustyconnector</groupId>
<artifactId>core</artifactId>
Expand Down
Loading

0 comments on commit 66d02ff

Please sign in to comment.