Skip to content

Commit

Permalink
globally rename MCLoader to Server to better fit generic nature of RC…
Browse files Browse the repository at this point in the history
… now.
  • Loading branch information
Nathan Martin committed Jul 23, 2024
1 parent 1d2f8fa commit 81be8f8
Show file tree
Hide file tree
Showing 35 changed files with 171 additions and 171 deletions.
30 changes: 15 additions & 15 deletions core/src/main/java/group/aelysium/rustyconnector/RC.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import group.aelysium.rustyconnector.common.absolute_redundancy.Particle;
import group.aelysium.rustyconnector.common.events.EventManager;
import group.aelysium.rustyconnector.mc_loader.MCLoaderAdapter;
import group.aelysium.rustyconnector.mc_loader.MCLoaderFlame;
import group.aelysium.rustyconnector.mc_loader.lang.MCLoaderLang;
import group.aelysium.rustyconnector.mc_loader.ServerAdapter;
import group.aelysium.rustyconnector.mc_loader.ServerFlame;
import group.aelysium.rustyconnector.mc_loader.lang.ServerLang;
import group.aelysium.rustyconnector.proxy.ProxyAdapter;
import group.aelysium.rustyconnector.proxy.ProxyFlame;
import group.aelysium.rustyconnector.proxy.family.Families;
Expand Down Expand Up @@ -73,8 +73,8 @@ static Optional<Family> Family(String id) throws NoSuchElementException {
return Optional.ofNullable(family);
}

static Optional<Server> MCLoader(UUID uuid) throws NoSuchElementException {
return RustyConnector.Toolkit.Proxy().orElseThrow().orElseThrow().LocalStorage().mcloaders().fetch(uuid);
static Optional<Server> Server(UUID uuid) throws NoSuchElementException {
return RustyConnector.Toolkit.Proxy().orElseThrow().orElseThrow().LocalStorage().servers().fetch(uuid);
}

static Optional<Player> Player(UUID uuid) throws NoSuchElementException {
Expand All @@ -83,27 +83,27 @@ static Optional<Player> Player(UUID uuid) throws NoSuchElementException {
}

/**
* The interface containing MCLoader based operations.
* The interface containing Server based operations.
*/
interface M {
static MCLoaderFlame Kernel() throws NoSuchElementException {
return RustyConnector.Toolkit.MCLoader().orElseThrow().orElseThrow();
interface S {
static ServerFlame Kernel() throws NoSuchElementException {
return RustyConnector.Toolkit.Server().orElseThrow().orElseThrow();
}

static group.aelysium.rustyconnector.mc_loader.magic_link.MagicLink MagicLink() throws NoSuchElementException {
return RustyConnector.Toolkit.MCLoader().orElseThrow().orElseThrow().MagicLink().orElseThrow();
return RustyConnector.Toolkit.Server().orElseThrow().orElseThrow().MagicLink().orElseThrow();
}

static MCLoaderAdapter Adapter() throws NoSuchElementException {
return RustyConnector.Toolkit.MCLoader().orElseThrow().orElseThrow().Adapter();
static ServerAdapter Adapter() throws NoSuchElementException {
return RustyConnector.Toolkit.Server().orElseThrow().orElseThrow().Adapter();
}

static LangLibrary<MCLoaderLang> Lang() throws NoSuchElementException {
return RustyConnector.Toolkit.MCLoader().orElseThrow().orElseThrow().Lang().orElseThrow();
static LangLibrary<ServerLang> Lang() throws NoSuchElementException {
return RustyConnector.Toolkit.Server().orElseThrow().orElseThrow().Lang().orElseThrow();
}

static EventManager EventManager() throws NoSuchElementException {
return RustyConnector.Toolkit.MCLoader().orElseThrow().orElseThrow().EventManager();
return RustyConnector.Toolkit.Server().orElseThrow().orElseThrow().EventManager();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package group.aelysium.rustyconnector;

import group.aelysium.rustyconnector.common.absolute_redundancy.Particle;
import group.aelysium.rustyconnector.mc_loader.MCLoaderFlame;
import group.aelysium.rustyconnector.mc_loader.ServerFlame;
import group.aelysium.rustyconnector.proxy.ProxyFlame;
import org.jetbrains.annotations.NotNull;

import java.util.Optional;

public class RustyConnector {
public static class Toolkit {
private static Particle.Flux<MCLoaderFlame> mcLoaderKernel = null;
private static Particle.Flux<ServerFlame> serverKernel = null;
private static Particle.Flux<ProxyFlame> velocityKernel = null;

/**
* Fetches the MCLoader API for RustyConnector.
* @return {@link MCLoaderFlame}
* Fetches the Server API for RustyConnector.
* @return {@link ServerFlame}
*/
public static Optional<Particle.Flux<MCLoaderFlame>> MCLoader() throws IllegalAccessError {
return Optional.ofNullable(mcLoaderKernel);
public static Optional<Particle.Flux<ServerFlame>> Server() throws IllegalAccessError {
return Optional.ofNullable(serverKernel);
}

/**
Expand All @@ -28,15 +28,15 @@ public static Optional<Particle.Flux<ProxyFlame>> Proxy() throws IllegalAccessEr
return Optional.ofNullable(velocityKernel);
}

public static void registerMCLoader(@NotNull Particle.Flux<MCLoaderFlame> kernel) {
mcLoaderKernel = kernel;
public static void registerServerKernel(@NotNull Particle.Flux<ServerFlame> kernel) {
serverKernel = kernel;
}
public static void registerProxy(@NotNull Particle.Flux<ProxyFlame> kernel) {
public static void registerProxyKernel(@NotNull Particle.Flux<ProxyFlame> kernel) {
velocityKernel = kernel;
}

public static void unregister() {
mcLoaderKernel = null;
serverKernel = null;
velocityKernel = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@ private void assignTargetAndSender(@NotNull Packet.Target target, Target sender)
if(sender != null) this.builder.sender(sender);

try {
this.builder.sender(Target.mcLoader(RustyConnector.Toolkit.Proxy().orElseThrow().orElseThrow().uuid()));
this.builder.sender(Target.server(RustyConnector.Toolkit.Proxy().orElseThrow().orElseThrow().uuid()));
return;
} catch (Exception ignore) {}
try {
this.builder.sender(Target.mcLoader(RustyConnector.Toolkit.MCLoader().orElseThrow().orElseThrow().uuid()));
this.builder.sender(Target.server(RustyConnector.Toolkit.Server().orElseThrow().orElseThrow().uuid()));
return;
} catch (Exception ignore) {}
throw new RuntimeException("No available flames existed in order to send the packet!");
Expand Down Expand Up @@ -236,7 +236,7 @@ private MagicLinkCore fetchMagicLink() {
return RC.P.MagicLink();
} catch (Exception ignore) {}
try {
return RC.M.MagicLink();
return RC.S.MagicLink();
} catch (Exception ignore) {}
throw new RuntimeException("No available flames existed in order to send the packet!");
}
Expand Down Expand Up @@ -323,8 +323,8 @@ public static Target fromJSON(JsonObject object) {
);
}

public static Target mcLoader(UUID uuid) {
return new Target(uuid, Origin.MCLOADER);
public static Target server(UUID uuid) {
return new Target(uuid, Origin.SERVER);
}
public static Target proxy(UUID uuid) {
return new Target(uuid, Origin.PROXY);
Expand Down Expand Up @@ -372,25 +372,25 @@ public int hashCode() {
public enum Origin {
PROXY,
ANY_PROXY,
MCLOADER,
ANY_MCLOADER
SERVER,
ANY_SERVER
;

public static Origin fromInteger(int number) {
return switch (number) {
case 0 -> Origin.PROXY;
case 1 -> Origin.ANY_PROXY;
case 2 -> Origin.MCLOADER;
case 3 -> Origin.ANY_MCLOADER;
case 2 -> Origin.SERVER;
case 3 -> Origin.ANY_SERVER;
default -> throw new ClassCastException(number+" has no associated value!");
};
}
public static int toInteger(Origin origin) {
return switch (origin) {
case PROXY -> 0;
case ANY_PROXY -> 1;
case MCLOADER -> 2;
case ANY_MCLOADER -> 3;
case SERVER -> 2;
case ANY_SERVER -> 3;
};
}
}
Expand Down Expand Up @@ -470,48 +470,48 @@ interface Parameters {

public interface BuiltInIdentifications {
/**
* `MCLoader > Proxy` | MCLoader requesting to interface with Proxy.
* | If the MCLoader is new, it will attempt to be registered.
* | If the MCLoader is already registered, it's connection will refresh.
* `Server > Proxy` | Server requesting to interface with Proxy.
* | If the Server is new, it will attempt to be registered.
* | If the Server is already registered, it's connection will refresh.
*
* | This packet is simultaneously a handshake initializer and a keep-alive packet.
*/
PacketIdentification MAGICLINK_HANDSHAKE_PING = PacketIdentification.from("RC","MLH");

/**
* `Proxy > MCLoader` | Tells the MCLoader it couldn't be registered
* `Proxy > Server` | Tells the Server it couldn't be registered
*/
PacketIdentification MAGICLINK_HANDSHAKE_FAIL = PacketIdentification.from("RC","MLHF");

/**
* `Proxy > MCLoader` | Tells the MCLoader it was registered and how it should configure itself
* `Proxy > Server` | Tells the Server it was registered and how it should configure itself
*/
PacketIdentification MAGICLINK_HANDSHAKE_SUCCESS = PacketIdentification.from("RC","MLHS");

/**
* `MCLoader > Proxy` | Tells the Proxy to drop the Magic Link between this MCLoader.
* | Typically used when the MCLoader is shutting down so that Magic Link doesn't have to manually scan it.
* `Server > Proxy` | Tells the Proxy to drop the Magic Link between this Server.
* | Typically used when the Server is shutting down so that Magic Link doesn't have to manually scan it.
*/
PacketIdentification MAGICLINK_HANDSHAKE_DISCONNECT = PacketIdentification.from("RC","MLHK");

/**
* `Proxy > MCLoader` | Informs the MCLoader that it's connection to the proxy has gone stale.
* | It is expected that, if the MCLoader is still available it will respond to this message with a {@link BuiltInIdentifications#MAGICLINK_HANDSHAKE_PING}
* `Proxy > Server` | Informs the Server that it's connection to the proxy has gone stale.
* | It is expected that, if the Server is still available it will respond to this message with a {@link BuiltInIdentifications#MAGICLINK_HANDSHAKE_PING}
*/
PacketIdentification MAGICLINK_HANDSHAKE_STALE_PING = PacketIdentification.from("RC","MLHSP");

/**
* `MCLoader > Proxy` | Request to send a player to a family
* `Server > Proxy` | Request to send a player to a family
*/
PacketIdentification SEND_PLAYER = PacketIdentification.from("RC","SP");

/**
* `Server > MCLoader` | Tells the proxy to open a server.
* `Server > Server` | Tells the proxy to open a server.
*/
PacketIdentification UNLOCK_SERVER = PacketIdentification.from("RC","US");

/**
* `MCLoader > Proxy` | Tells the proxy to close a server.
* `Server > Proxy` | Tells the proxy to close a server.
*/
PacketIdentification LOCK_SERVER = PacketIdentification.from("RC","LS");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import java.util.UUID;

/**
* The MCLoader adapter exists to take loader specific actions and adapt them so that RustyConnector
* The Server adapter exists to take loader specific actions and adapt them so that RustyConnector
* can properly execute them regardless of disparate data types between the wrapper and RustyConnector.
*/
public abstract class MCLoaderAdapter {
public abstract class ServerAdapter {
/**
* Set the maximum number of players that this server will allow to connect to it.
* @param max The max number of players that can join this server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import group.aelysium.rustyconnector.common.events.EventManager;
import group.aelysium.rustyconnector.common.magic_link.MagicLinkCore;
import group.aelysium.rustyconnector.common.magic_link.packet.Packet;
import group.aelysium.rustyconnector.mc_loader.lang.MCLoaderLang;
import group.aelysium.rustyconnector.mc_loader.lang.ServerLang;
import group.aelysium.rustyconnector.mc_loader.magic_link.MagicLink;
import group.aelysium.rustyconnector.proxy.util.Version;
import group.aelysium.rustyconnector.common.lang.LangLibrary;
Expand All @@ -13,21 +13,21 @@
import java.net.InetSocketAddress;
import java.util.*;

public class MCLoaderFlame implements Particle {
public class ServerFlame implements Particle {
private final UUID uuid;
private final Version version;
private final MCLoaderAdapter adapter;
private final Flux<LangLibrary<MCLoaderLang>> lang;
private final ServerAdapter adapter;
private final Flux<LangLibrary<ServerLang>> lang;
private final String displayName;
private final InetSocketAddress address;
private final Flux<MagicLink> magicLink;
private final EventManager eventManager;

protected MCLoaderFlame(
protected ServerFlame(
@NotNull UUID uuid,
@NotNull Version version,
@NotNull MCLoaderAdapter adapter,
@NotNull Flux<LangLibrary<MCLoaderLang>> lang,
@NotNull ServerAdapter adapter,
@NotNull Flux<LangLibrary<ServerLang>> lang,
@NotNull String displayName,
@NotNull InetSocketAddress address,
@NotNull Flux<MagicLink> magicLink,
Expand All @@ -44,8 +44,8 @@ protected MCLoaderFlame(
}

/**
* Gets the session uuid of this MCLoader.
* The MCLoader's uuid won't change while it's alive, but once it's restarted or reloaded, the session uuid will change.
* Gets the session uuid of this Server.
* The Server's uuid won't change while it's alive, but once it's restarted or reloaded, the session uuid will change.
* @return {@link UUID}
*/
public UUID uuid() {
Expand All @@ -61,7 +61,7 @@ public Version version() {
}

/**
* The display name of this MCLoader.
* The display name of this Server.
*/
public String displayName() {
return this.displayName;
Expand All @@ -85,7 +85,7 @@ public int playerCount() {
}

/**
* Locks this MCLoader so that players can't join it via the family's load balancer.
* Locks this Server so that players can't join it via the family's load balancer.
*/
public void lock() {
Packet.New()
Expand All @@ -95,7 +95,7 @@ public void lock() {
}

/**
* Unlocks this MCLoader so that players can join it via the family's load balancer.
* Unlocks this Server so that players can join it via the family's load balancer.
*/
public void unlock() {
Packet.New()
Expand All @@ -119,23 +119,23 @@ public void send(UUID player, String familyID) {
}

/**
* Sends a player to a specific MCLoader if it exists.
* Sends a player to a specific Server if it exists.
* @param player The uuid of the player to send.
* @param mcloader The uuid of the mcloader to send to.
* @param server The uuid of the server to send to.
*/
public void send(UUID player, UUID mcloader) {
public void send(UUID player, UUID server) {

}

public Flux<MagicLink> MagicLink() {
return this.magicLink;
}

public MCLoaderAdapter Adapter() {
public ServerAdapter Adapter() {
return this.adapter;
}

public Flux<LangLibrary<MCLoaderLang>> Lang() {
public Flux<LangLibrary<ServerLang>> Lang() {
return this.lang;
}

Expand All @@ -148,11 +148,11 @@ public void close() throws Exception {
this.magicLink.close();
}

public static class Tinder extends Particle.Tinder<MCLoaderFlame> {
public static class Tinder extends Particle.Tinder<ServerFlame> {
private final UUID uuid;
private final Version version;
private final MCLoaderAdapter adapter;
private final LangLibrary.Tinder<MCLoaderLang> lang;
private final ServerAdapter adapter;
private final LangLibrary.Tinder<ServerLang> lang;
private final String displayName;
private final InetSocketAddress address;
private final MagicLink.Tinder magicLink;
Expand All @@ -161,8 +161,8 @@ public static class Tinder extends Particle.Tinder<MCLoaderFlame> {
public Tinder(
@NotNull UUID uuid,
@NotNull Version version,
@NotNull MCLoaderAdapter adapter,
@NotNull LangLibrary.Tinder<MCLoaderLang> lang,
@NotNull ServerAdapter adapter,
@NotNull LangLibrary.Tinder<ServerLang> lang,
@NotNull String displayName,
@NotNull InetSocketAddress address,
@NotNull MagicLink.Tinder magicLink,
Expand All @@ -179,8 +179,8 @@ public Tinder(
}

@Override
public @NotNull MCLoaderFlame ignite() throws Exception {
return new MCLoaderFlame(
public @NotNull ServerFlame ignite() throws Exception {
return new ServerFlame(
uuid,
version,
adapter,
Expand Down
Loading

0 comments on commit 81be8f8

Please sign in to comment.