Skip to content

Commit

Permalink
breaking(deps): Update to WaterdogPE 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
funniray committed Jun 8, 2023
1 parent 2171534 commit ca2a46b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 29 deletions.
14 changes: 5 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,20 @@

<repositories>
<repository>
<id>waterdog-repo</id>
<url>https://repo.waterdog.dev/artifactory/main</url>
<id>waterdogpe-snapshots</id>
<url>https://repo.waterdog.dev/snapshots</url>
</repository>
<repository>
<id>opencollab-releases</id>
<url>https://repo.opencollab.dev/maven-releases/</url>
</repository>
<repository>
<id>opencollab-snapshots</id>
<url>https://repo.opencollab.dev/maven-snapshots/</url>
<id>waterdogpe-releases</id>
<url>https://repo.waterdog.dev/releases</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>dev.waterdog.waterdogpe</groupId>
<artifactId>waterdog</artifactId>
<version>1.2.4</version>
<version>2.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
26 changes: 13 additions & 13 deletions src/main/java/com/funniray/lobbybalancer/CacheThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@

package com.funniray.lobbybalancer;

import com.nukkitx.network.raknet.RakNetPong;
import dev.waterdog.waterdogpe.network.serverinfo.ServerInfo;

import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

public class CacheThread {

Expand All @@ -48,16 +45,19 @@ private static boolean pingServer(ServerInfo server) {
}

//Otherwise, attempt to ping the server
try {
RakNetPong pong = server.ping(LobbyBalancer.getInstance().getConfig().getInt("pingtimeout"), TimeUnit.SECONDS).get();
return true;
} catch (InterruptedException | ExecutionException e) {
//e.printStackTrace(); //This will spam the console
if (LobbyBalancer.getInstance().getConfig().getBoolean("logfailedpings")) {
LobbyBalancer.getInstance().getLogger().warn("The server " + server.getServerName() + " appears to be offline.");
}
return false; //If it errors, it's offline
}
//Ping function was removed, don't really care to fix it

// try {
// RakNetPong pong = server.ping(LobbyBalancer.getInstance().getConfig().getInt("pingtimeout"), TimeUnit.SECONDS).get();
// return true;
// } catch (InterruptedException | ExecutionException e) {
// //e.printStackTrace(); //This will spam the console
// if (LobbyBalancer.getInstance().getConfig().getBoolean("logfailedpings")) {
// LobbyBalancer.getInstance().getLogger().warn("The server " + server.getServerName() + " appears to be offline.");
// }
// return false; //If it errors, it's offline
// }
return true;
}

public static boolean isServerOnline(ServerInfo server) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/funniray/lobbybalancer/Listeners.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

package com.funniray.lobbybalancer;

import dev.waterdog.waterdogpe.event.defaults.PreTransferEvent;
import dev.waterdog.waterdogpe.event.defaults.ServerTransferRequestEvent;
import dev.waterdog.waterdogpe.network.serverinfo.ServerInfo;

public class Listeners {

public static void PreTransferHandler(PreTransferEvent e) {
public static void PreTransferHandler(ServerTransferRequestEvent e) {
if (e.getTargetServer().getServerName().equals(LobbyBalancer.getInstance().getConfig().getString("lobbyprefix"))){
//Don't let the player join the server they're currently on
ServerInfo info = Utils.findServer(e.getPlayer().getServerInfo());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/funniray/lobbybalancer/LobbyBalancer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.funniray.lobbybalancer.commands.LobbyCommand;
import com.funniray.lobbybalancer.handlers.LobbyJoinHandler;
import com.funniray.lobbybalancer.handlers.LobbyReconnectHandler;
import dev.waterdog.waterdogpe.event.defaults.PreTransferEvent;
import dev.waterdog.waterdogpe.event.defaults.ServerTransferRequestEvent;
import dev.waterdog.waterdogpe.plugin.Plugin;

import java.io.File;
Expand Down Expand Up @@ -68,7 +68,7 @@ public void onEnable() {

this.getProxy().setJoinHandler(new LobbyJoinHandler());
this.getProxy().setReconnectHandler(new LobbyReconnectHandler());
this.getProxy().getEventManager().subscribe(PreTransferEvent.class, Listeners::PreTransferHandler);
this.getProxy().getEventManager().subscribe(ServerTransferRequestEvent.class, Listeners::PreTransferHandler);

this.getProxy().getCommandMap().registerCommand(new LobbyCommand());
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/funniray/lobbybalancer/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import dev.waterdog.waterdogpe.ProxyServer;
import dev.waterdog.waterdogpe.network.serverinfo.BedrockServerInfo;
import dev.waterdog.waterdogpe.network.serverinfo.ServerInfo;
import jline.internal.Nullable;

import javax.annotation.Nullable;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
package com.funniray.lobbybalancer.handlers;

import com.funniray.lobbybalancer.Utils;
import dev.waterdog.waterdogpe.network.connection.handler.IJoinHandler;
import dev.waterdog.waterdogpe.network.serverinfo.ServerInfo;
import dev.waterdog.waterdogpe.player.ProxiedPlayer;
import dev.waterdog.waterdogpe.utils.types.IJoinHandler;

public class LobbyJoinHandler implements IJoinHandler {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
package com.funniray.lobbybalancer.handlers;

import com.funniray.lobbybalancer.Utils;
import dev.waterdog.waterdogpe.network.connection.handler.IReconnectHandler;
import dev.waterdog.waterdogpe.network.serverinfo.ServerInfo;
import dev.waterdog.waterdogpe.player.ProxiedPlayer;
import dev.waterdog.waterdogpe.utils.types.IReconnectHandler;

public class LobbyReconnectHandler implements IReconnectHandler {
@Override
Expand Down

0 comments on commit ca2a46b

Please sign in to comment.