Small Updates

This commit is contained in:
J.T. McQuigg 2022-08-28 23:17:26 -04:00
parent 6bca75b3ac
commit 61add85e86
4 changed files with 13 additions and 25 deletions

View File

@ -4,7 +4,7 @@ This is a Velocity plugin that makes it possible to host a modern forge server b
Unlike other solutions, this plugin does not require any special modifications to the client. (The player doesn't need to do anything)
This plugin is right now in it's alpha stage and should not be used in production, use it at your own risk, you have been warned.
This plugin is right now in its alpha stage and should not be used in production, use it at your own risk, you have been warned.
## How to get started:
### On the Velocity proxy side:
1. Download and install this plugin to your proxy.
@ -17,7 +17,8 @@ This plugin is right now in it's alpha stage and should not be used in productio
1. Download and install "Ambassador-Forge" as a mod to your forge server. (Found at https://github.com/adde0109/Ambassador-Forge)
2. Start the server.
3. If you wish to use modern forwarding, close the server and open "ambassador-common.toml" in the config folder and put your forwarding secret in the "forwardingSecret" field.
4. You are now ready to start the server and connect to it with Velocity!
4. In Server.Properties make sure online-mode is set to false.
5. You are now ready to start the server and connect to it with Velocity!
## Features
* Server Switching.

View File

@ -15,11 +15,11 @@ repositories {
}
dependencies {
implementation 'com.velocitypowered:velocity-api:3.1.1'
implementation 'com.velocitypowered:velocity-api:3.1.2-SNAPSHOT'
implementation 'com.electronwill.night-config:toml:3.6.5'
implementation 'org.bstats:bstats-velocity:3.0.0'
implementation 'org.apache.commons:commons-collections4:4.4'
annotationProcessor 'com.velocitypowered:velocity-api:3.1.1'
annotationProcessor 'com.velocitypowered:velocity-api:3.1.2-SNAPSHOT'
}
shadowJar {

View File

@ -9,19 +9,15 @@ import com.velocitypowered.api.event.proxy.ProxyReloadEvent;
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.ProxyServer;
import java.util.concurrent.Callable;
import org.adde0109.ambassador.forge.ForgeConnection;
import org.adde0109.ambassador.forge.ForgeHandshakeHandler;
import org.adde0109.ambassador.forge.ForgeHandshakeUtils;
import org.adde0109.ambassador.forge.ForgeServerSwitchHandler;
import org.bstats.MetricsBase;
import org.bstats.charts.SingleLineChart;
import org.bstats.velocity.Metrics;
import org.slf4j.Logger;
import java.nio.file.Path;
import java.util.*;
@Plugin(id = "ambassador", name = "Ambassador", version = "0.5.1", authors = {"adde0109"})
public class Ambassador {
@ -91,11 +87,6 @@ public class Ambassador {
private void initMetrics() {
Metrics metrics = metricsFactory.make(this, 15655);
metrics.addCustomChart(new SingleLineChart("modern_forge_players", new Callable<Integer>() {
@Override
public Integer call() throws Exception {
return (forgeHandshakeHandler != null) ? forgeHandshakeHandler.getAmountOfForgeConnections() : 0;
}
}));
metrics.addCustomChart(new SingleLineChart("modern_forge_players", () -> (forgeHandshakeHandler != null) ? forgeHandshakeHandler.getAmountOfForgeConnections() : 0));
}
}

View File

@ -11,15 +11,15 @@ import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import java.net.InetSocketAddress;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TranslatableComponent;
import net.kyori.adventure.text.format.NamedTextColor;
import org.adde0109.ambassador.Ambassador;
import org.bstats.velocity.Metrics;
import java.net.InetSocketAddress;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
public class ForgeHandshakeHandler {
@ -52,9 +52,7 @@ public class ForgeHandshakeHandler {
});
if (ambassador.forgeServerSwitchHandler.reSyncMap.containsKey(event.getUsername())) {
forgeConnection.sync(ambassador.forgeServerSwitchHandler.reSyncMap.remove(event.getUsername())).thenAccept((done) -> {
continuation.resume();
});
forgeConnection.sync(ambassador.forgeServerSwitchHandler.reSyncMap.remove(event.getUsername())).thenAccept((done) -> continuation.resume());
forgeConnection.setForced(true);
} else if (defaultServer != null) {
//If a connection does not already exist, create one.
@ -62,9 +60,7 @@ public class ForgeHandshakeHandler {
forgeServerConnectionMap.put(defaultServer, new ForgeServerConnection(defaultServer));
}
//Forge Handshake
forgeConnection.sync(forgeServerConnectionMap.get(defaultServer)).thenAccept((done) -> {
continuation.resume();
});
forgeConnection.sync(forgeServerConnectionMap.get(defaultServer)).thenAccept((done) -> continuation.resume());
forgeConnection.setForced(ambassador.config.getForced(forgeConnection.getConnection().getProtocolVersion().getProtocol()));
} else {
continuation.resume();