Skip to content

Commit

Permalink
Implement new osgan version
Browse files Browse the repository at this point in the history
  • Loading branch information
HttpMarco committed Nov 29, 2024
1 parent b3aee0c commit f1e5287
Show file tree
Hide file tree
Showing 15 changed files with 13 additions and 101 deletions.
12 changes: 0 additions & 12 deletions api/src/main/java/dev/httpmarco/polocloud/api/CloudAPI.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.httpmarco.polocloud.api;

import dev.httpmarco.osgan.networking.ClassSupplier;
import dev.httpmarco.polocloud.api.event.EventProvider;
import dev.httpmarco.polocloud.api.groups.ClusterGroupProvider;
import dev.httpmarco.polocloud.api.players.ClusterPlayerProvider;
Expand All @@ -26,15 +25,4 @@ public CloudAPI() {

public abstract ClusterPlayerProvider playerProvider();

public abstract ClassSupplier classSupplier();

public abstract void classSupplier(ClassSupplier classSupplier);

public Class<?> classByName(String name) throws ClassNotFoundException {
if (classSupplier() == null) {
throw new NullPointerException("The classSupplier on this instance is null! This means you either don't have the PoloCloud plugin installed or your main class does not call CommunicationClient#classLoader()");
}

return classSupplier().classByName(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public RedirectPacket(UUID target, Packet packet) {
}

public Packet buildPacket() throws ClassNotFoundException {
var packet = (Packet) PacketAllocator.allocate(CloudAPI.instance().classByName(this.packetClassName));
var packet = (Packet) PacketAllocator.allocate(Class.forName(this.packetClassName));
packet.read(new PacketBuffer(this.buffer.getOrigin().copy()));
return packet;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import dev.httpmarco.polocloud.api.event.util.PacketAllocator;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.SneakyThrows;
import lombok.experimental.Accessors;

@Getter
Expand All @@ -24,7 +23,7 @@ public EventCallPacket(Event event) {
}

public Event buildEvent() throws ClassNotFoundException {
var event = (Event) PacketAllocator.allocate(CloudAPI.instance().classByName(this.className));
var event = (Event) PacketAllocator.allocate(Class.forName(this.className));
event.read(new PacketBuffer(this.buffer.getOrigin().copy()));
return event;
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ nexusPublish = "2.0.0"
maven-artifact = "4.0.0-rc-1"

# network
osgan = "1.1.0-20241028.200418-1"
osgan = "1.1.1-SNAPSHOT"
netty5 = "5.0.0.Alpha5"

#logging
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.httpmarco.polocloud.instance;

import dev.httpmarco.osgan.networking.ClassSupplier;
import dev.httpmarco.osgan.networking.client.CommunicationClient;
import dev.httpmarco.osgan.networking.client.CommunicationClientAction;
import dev.httpmarco.polocloud.api.CloudAPI;
Expand Down Expand Up @@ -63,14 +62,4 @@ public ClusterInstance(String[] args) {

this.serviceProvider = new ClusterInstanceServiceProvider(this.client);
}

@Override
public ClassSupplier classSupplier() {
return this.client.classSupplier();
}

@Override
public void classSupplier(ClassSupplier classSupplier) {
this.client.classSupplier(classSupplier);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void main(String[] args) {
var nettyResolverDependency = new Dependency("io.netty", "netty5-resolver", "5.0.0.Alpha5");
var nettyBufferDependency = new Dependency("io.netty", "netty5-buffer", "5.0.0.Alpha5");
var nettyTransportEpollDependency = new Dependency("io.netty", "netty5-transport-classes-epoll", "5.0.0.Alpha5");
var osganNettyDependency = new Dependency("dev.httpmarco", "osgan-netty", "1.1.0-SNAPSHOT", "1.1.0-20241028.200418-1", Repository.MAVEN_CENTRAL_SNAPSHOT);
var osganNettyDependency = new Dependency("dev.httpmarco", "osgan-netty", "1.1.1-SNAPSHOT", "1.1.1-20241129.233215-1", Repository.MAVEN_CENTRAL_SNAPSHOT);

// add boot file to the current classpath
CLASS_LOADER.addURL(boot.bootFile().toURI().toURL());
Expand Down
11 changes: 0 additions & 11 deletions node/src/main/java/dev/httpmarco/polocloud/node/Node.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.httpmarco.polocloud.node;

import dev.httpmarco.osgan.networking.ClassSupplier;
import dev.httpmarco.osgan.networking.server.CommunicationServer;
import dev.httpmarco.polocloud.api.CloudAPI;
import dev.httpmarco.polocloud.api.event.EventProvider;
Expand Down Expand Up @@ -114,16 +113,6 @@ public Node() {
this.serviceProvider.clusterServiceQueue().start();
}

@Override
public ClassSupplier classSupplier() {
return this.server().classSupplier();
}

@Override
public void classSupplier(ClassSupplier classSupplier) {
this.server().classSupplier(classSupplier);
}

public void updateNodeConfig() {
Configurations.writeContent(Path.of("config.json"), this.nodeConfig);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import lombok.extern.log4j.Log4j2;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
Expand Down Expand Up @@ -110,7 +111,7 @@ public void runGroupService(ClusterGroup group) {

var path = "../../local/dependencies/";
//todo use dynamic queue
var neededDependencies = List.of("polocloud-instance.jar", "polocloud-api.jar", "osgan-netty-1.1.0-SNAPSHOT.jar", "netty5-buffer-5.0.0.Alpha5.jar", "netty5-codec-5.0.0.Alpha5.jar", "netty5-common-5.0.0.Alpha5.jar", "netty5-resolver-5.0.0.Alpha5.jar", "netty5-transport-5.0.0.Alpha5.jar", "netty5-transport-classes-epoll-5.0.0.Alpha5.jar");
var neededDependencies = List.of("polocloud-instance.jar", "polocloud-api.jar", "osgan-netty-1.1.1-SNAPSHOT.jar", "netty5-buffer-5.0.0.Alpha5.jar", "netty5-codec-5.0.0.Alpha5.jar", "netty5-common-5.0.0.Alpha5.jar", "netty5-resolver-5.0.0.Alpha5.jar", "netty5-transport-5.0.0.Alpha5.jar", "netty5-transport-classes-epoll-5.0.0.Alpha5.jar");

arguments.add(String.join(System.getProperty("os.name").toLowerCase().contains("win") ? ";" : ":", neededDependencies.stream().map(it -> path + it).toList()));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.httpmarco.polocloud.plugin.bungeecord;

import dev.httpmarco.osgan.networking.ClassSupplier;
import dev.httpmarco.polocloud.api.CloudAPI;
import dev.httpmarco.polocloud.plugin.ProxyPlatformParameterAdapter;
import dev.httpmarco.polocloud.plugin.ProxyPluginPlatform;
Expand All @@ -9,15 +8,13 @@
import net.md_5.bungee.api.plugin.Plugin;
import org.jetbrains.annotations.NotNull;

public final class BungeeCordPlatformBootstrap extends Plugin implements ProxyPlatformParameterAdapter<ProxiedPlayer>, ClassSupplier {
public final class BungeeCordPlatformBootstrap extends Plugin implements ProxyPlatformParameterAdapter<ProxiedPlayer> {

@Override
public void onEnable() {
var platform = new ProxyPluginPlatform<>(new BungeeCordPlatformAction(), new BungeeCordPlatformServerHandler(), this);
var instance = ProxyServer.getInstance();

CloudAPI.instance().classSupplier(this);

instance.getConfigurationAdapter().getServers().clear();
instance.getPluginManager().registerListener(this, new BungeeCordPlatformListeners(ProxyServer.getInstance(), platform));
instance.getPluginManager().registerCommand(this, new BungeeCordCloudCommand());
Expand All @@ -35,9 +32,4 @@ public boolean hasPermission(@NotNull ProxiedPlayer player, String permission) {
public int onlinePlayers() {
return ProxyServer.getInstance().getOnlineCount();
}

@Override
public Class<?> classByName(String name) throws ClassNotFoundException {
return Class.forName(name);
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
package dev.httpmarco.polocloud.plugin.fabric;

import dev.httpmarco.osgan.networking.ClassSupplier;
import dev.httpmarco.polocloud.api.CloudAPI;
import dev.httpmarco.polocloud.plugin.PluginPlatform;
import net.fabricmc.api.ModInitializer;

public final class FabricPlatformBootstrap implements ModInitializer, ClassSupplier {
public final class FabricPlatformBootstrap implements ModInitializer {

private final PluginPlatform platform = new PluginPlatform();

@Override
public void onInitialize() {
platform.presentServiceAsOnline();

CloudAPI.instance().classSupplier(this);
}

@Override
public Class<?> classByName(String name) throws ClassNotFoundException {
return Class.forName(name);
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
package dev.httpmarco.polocloud.plugin.nukkit;

import cn.nukkit.plugin.PluginBase;
import dev.httpmarco.osgan.networking.ClassSupplier;
import dev.httpmarco.polocloud.api.CloudAPI;
import dev.httpmarco.polocloud.plugin.PluginPlatform;

public final class NukkitPlatformBootstrap extends PluginBase implements ClassSupplier {
public final class NukkitPlatformBootstrap extends PluginBase {

private final PluginPlatform platform = new PluginPlatform();

@Override
public void onEnable() {
platform.presentServiceAsOnline();

CloudAPI.instance().classSupplier(this);
}

@Override
public Class<?> classByName(String name) throws ClassNotFoundException {
return Class.forName(name);
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
package dev.httpmarco.polocloud.plugin.spigot;

import dev.httpmarco.osgan.networking.ClassSupplier;
import dev.httpmarco.polocloud.api.CloudAPI;
import dev.httpmarco.polocloud.plugin.PluginPlatform;
import org.bukkit.plugin.java.JavaPlugin;

public final class SpigotPlatformBootstrap extends JavaPlugin implements ClassSupplier {
public final class SpigotPlatformBootstrap extends JavaPlugin {

private final PluginPlatform platform = new PluginPlatform();

@Override
public void onEnable() {
platform.presentServiceAsOnline();

CloudAPI.instance().classSupplier(this);
}

@Override
public Class<?> classByName(String name) throws ClassNotFoundException {
return Class.forName(name);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.httpmarco.polocloud.plugin.sponge;

import com.google.inject.Inject;
import dev.httpmarco.osgan.networking.ClassSupplier;
import dev.httpmarco.polocloud.api.CloudAPI;
import dev.httpmarco.polocloud.plugin.PluginPlatform;
import org.spongepowered.api.Server;
Expand All @@ -10,7 +9,7 @@
import org.spongepowered.plugin.builtin.jvm.Plugin;

@Plugin("Polocloud-plugin")
public final class SpongePlatformBootstrap implements ClassSupplier {
public final class SpongePlatformBootstrap {

private final PluginPlatform platform;

Expand All @@ -22,12 +21,5 @@ public final class SpongePlatformBootstrap implements ClassSupplier {
@Listener
private void onConstructPlugin2(final StartedEngineEvent<Server> event) {
platform.presentServiceAsOnline();

CloudAPI.instance().classSupplier(this);
}

@Override
public Class<?> classByName(String name) throws ClassNotFoundException {
return Class.forName(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,20 @@
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import dev.httpmarco.osgan.networking.ClassSupplier;
import dev.httpmarco.polocloud.api.CloudAPI;
import dev.httpmarco.polocloud.plugin.ProxyPlatformParameterAdapter;
import dev.httpmarco.polocloud.plugin.ProxyPluginPlatform;
import org.jetbrains.annotations.NotNull;

@Plugin(id = "polocloud", name = "PoloCloud-Plugin", version = "1.0.0", authors = "HttpMarco")
public final class VelocityPlatformBootstrap implements ProxyPlatformParameterAdapter<Player>, ClassSupplier {
public final class VelocityPlatformBootstrap implements ProxyPlatformParameterAdapter<Player> {
private final ProxyServer server;
private final ProxyPluginPlatform<Player> platform;

@Inject
public VelocityPlatformBootstrap(ProxyServer server) {
this.server = server;

CloudAPI.instance().classSupplier(this);

this.platform = new ProxyPluginPlatform<>(new VelocityPlatformAction(this.server), new VelocityProxyServerHandler(this.server), this);
}

Expand All @@ -48,8 +45,4 @@ public int onlinePlayers() {
return server.getPlayerCount();
}

@Override
public Class<?> classByName(String name) throws ClassNotFoundException {
return Class.forName(name);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.httpmarco.polocloud.plugin.waterdog;

import dev.httpmarco.osgan.networking.ClassSupplier;
import dev.httpmarco.polocloud.api.CloudAPI;
import dev.httpmarco.polocloud.plugin.ProxyPlatformParameterAdapter;
import dev.httpmarco.polocloud.plugin.ProxyPluginPlatform;
Expand All @@ -13,16 +12,14 @@

@Getter
@Accessors(fluent = true)
public final class WaterdogPlatformBootstrap extends Plugin implements ProxyPlatformParameterAdapter<ProxiedPlayer>, ClassSupplier {
public final class WaterdogPlatformBootstrap extends Plugin implements ProxyPlatformParameterAdapter<ProxiedPlayer> {

private ProxyPluginPlatform<ProxiedPlayer> platform;

@Override
public void onEnable() {
this.platform = new ProxyPluginPlatform<>(new WaterdogPlatformAction(this.getProxy()), new WaterdogServerHandler(this.getProxy()), this);

CloudAPI.instance().classSupplier(this);

new WaterdogPlatformListeners(this.getProxy(), this.platform);
this.platform.presentServiceAsOnline();
}
Expand All @@ -37,8 +34,4 @@ public int onlinePlayers() {
return ProxyServer.getInstance().getPlayerManager().getPlayerCount();
}

@Override
public Class<?> classByName(String name) throws ClassNotFoundException {
return Class.forName(name);
}
}

0 comments on commit f1e5287

Please sign in to comment.