diff --git a/pom.xml b/pom.xml
index 5d49247..8305827 100644
--- a/pom.xml
+++ b/pom.xml
@@ -18,16 +18,6 @@
-
-
- .
- true
- .
-
- velocity-plugin.json
-
-
-
@@ -41,7 +31,7 @@
com.velocitypowered
velocity-api
- 4.0.0-SNAPSHOT
+ 3.2.0-SNAPSHOT
provided
diff --git a/src/main/java/de/strifel/VTools/VTools.java b/src/main/java/de/strifel/VTools/VTools.java
index 85c9e42..2496e5f 100644
--- a/src/main/java/de/strifel/VTools/VTools.java
+++ b/src/main/java/de/strifel/VTools/VTools.java
@@ -1,7 +1,7 @@
package de.strifel.VTools;
import com.velocitypowered.api.event.Subscribe;
-import com.velocitypowered.api.event.lifecycle.ProxyInitializeEvent;
+import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.proxy.ProxyServer;
import de.strifel.VTools.commands.*;
@@ -16,6 +16,7 @@ public class VTools {
public static final TextColor COLOR_RED = TextColor.fromCSSHexString("#FF5555");
public static final TextColor COLOR_YELLOW = TextColor.fromCSSHexString("#FFFF55");
+ public static final TextColor COLOR_ORANGE = TextColor.fromCSSHexString("#FFA500");
@Inject
public VTools(ProxyServer server, Logger logger) {
@@ -25,13 +26,13 @@ public class VTools {
@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {
- server.commandManager().register("send", new CommandSend(server));
- server.commandManager().register("broadcast", new CommandBroadcast(server), "bc", "alert");
- server.commandManager().register("find", new CommandFind(server), "search");
- server.commandManager().register("staffchat", new CommandStaffChat(server), "sc");
- server.commandManager().register("restart", new CommandRestart(server));
- server.commandManager().register("tps", new CommandTp(server), "jump");
- server.commandManager().register("servers", new CommandServers(server), "allservers");
+ server.getCommandManager().register("send", new CommandSend(server));
+ server.getCommandManager().register("broadcast", new CommandBroadcast(server), "bc", "alert");
+ server.getCommandManager().register("find", new CommandFind(server), "search");
+ server.getCommandManager().register("staffchat", new CommandStaffChat(server), "sc");
+ server.getCommandManager().register("restart", new CommandRestart(server));
+ server.getCommandManager().register("tps", new CommandTp(server), "jump");
+ server.getCommandManager().register("servers", new CommandServers(server), "allservers");
}
}
diff --git a/src/main/java/de/strifel/VTools/commands/CommandBroadcast.java b/src/main/java/de/strifel/VTools/commands/CommandBroadcast.java
index 27e6b35..8945c81 100644
--- a/src/main/java/de/strifel/VTools/commands/CommandBroadcast.java
+++ b/src/main/java/de/strifel/VTools/commands/CommandBroadcast.java
@@ -2,7 +2,7 @@ package de.strifel.VTools.commands;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.command.SimpleCommand;
-import com.velocitypowered.api.proxy.connection.Player;
+import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import net.kyori.adventure.text.Component;
@@ -25,7 +25,7 @@ public class CommandBroadcast implements SimpleCommand {
if (strings.length > 0) {
String message = String.join(" ", strings).replace("&", "§");
- for (Player player : server.connectedPlayers()) {
+ for (Player player : server.getAllPlayers()) {
player.sendMessage(Component.text(message));
}
} else {
diff --git a/src/main/java/de/strifel/VTools/commands/CommandFind.java b/src/main/java/de/strifel/VTools/commands/CommandFind.java
index 7fea6c4..b360a91 100644
--- a/src/main/java/de/strifel/VTools/commands/CommandFind.java
+++ b/src/main/java/de/strifel/VTools/commands/CommandFind.java
@@ -2,12 +2,13 @@ package de.strifel.VTools.commands;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.command.SimpleCommand;
-import com.velocitypowered.api.proxy.connection.Player;
+import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import net.kyori.adventure.text.Component;
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
import static de.strifel.VTools.VTools.COLOR_RED;
import static de.strifel.VTools.VTools.COLOR_YELLOW;
@@ -26,9 +27,9 @@ public class CommandFind implements SimpleCommand {
String[] strings = invocation.arguments();
if (strings.length == 1) {
- Player player = server.player(strings[0]);
- if (player != null && player.connectedServer() != null) {
- commandSource.sendMessage(Component.text("Player " + strings[0] + " is on " + player.connectedServer().serverInfo().name() + "!").color(COLOR_YELLOW));
+ Optional player = server.getPlayer(strings[0]);
+ if (player.isPresent() && player.get().getCurrentServer().isPresent()) {
+ commandSource.sendMessage(Component.text("Player " + strings[0] + " is on " + player.get().getCurrentServer().get().getServerInfo().getName() + "!").color(COLOR_YELLOW));
} else {
commandSource.sendMessage(Component.text("The player is not online!").color(COLOR_YELLOW));
}
@@ -43,8 +44,8 @@ public class CommandFind implements SimpleCommand {
List arg = new ArrayList<>();
if (currentArgs.length <= 1 && invocation.source().hasPermission("vtools.find.autocomplete")) {
- for (Player player : server.connectedPlayers()) {
- arg.add(player.username());
+ for (Player player : server.getAllPlayers()) {
+ arg.add(player.getUsername());
}
}
return arg;
diff --git a/src/main/java/de/strifel/VTools/commands/CommandRestart.java b/src/main/java/de/strifel/VTools/commands/CommandRestart.java
index 4e51eb2..a5f85c2 100644
--- a/src/main/java/de/strifel/VTools/commands/CommandRestart.java
+++ b/src/main/java/de/strifel/VTools/commands/CommandRestart.java
@@ -2,7 +2,7 @@ package de.strifel.VTools.commands;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.command.SimpleCommand;
-import com.velocitypowered.api.proxy.connection.Player;
+import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import net.kyori.adventure.text.Component;
@@ -24,11 +24,11 @@ public class CommandRestart implements SimpleCommand {
if (strings.length > 0) {
String message = String.join(" ", strings).replace("&", "§");
- for (Player player : server.connectedPlayers()) {
+ for (Player player : server.getAllPlayers()) {
player.disconnect(Component.text(message));
}
}
- server.commandManager().execute(server.consoleCommandSource(), "shutdown");
+ server.getCommandManager().executeAsync(server.getConsoleCommandSource(), "shutdown");
}
@Override
diff --git a/src/main/java/de/strifel/VTools/commands/CommandSend.java b/src/main/java/de/strifel/VTools/commands/CommandSend.java
index c8c3dac..b1e3253 100644
--- a/src/main/java/de/strifel/VTools/commands/CommandSend.java
+++ b/src/main/java/de/strifel/VTools/commands/CommandSend.java
@@ -2,21 +2,24 @@ package de.strifel.VTools.commands;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.command.SimpleCommand;
-import com.velocitypowered.api.proxy.player.ConnectionRequestBuilder;
-import com.velocitypowered.api.proxy.connection.Player;
+import com.velocitypowered.api.proxy.ConnectionRequestBuilder;
+import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
+import com.velocitypowered.api.proxy.ServerConnection;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import net.kyori.adventure.text.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import static de.strifel.VTools.VTools.COLOR_RED;
import static de.strifel.VTools.VTools.COLOR_YELLOW;
+import static de.strifel.VTools.VTools.COLOR_ORANGE;
public class CommandSend implements SimpleCommand {
private final ProxyServer server;
@@ -33,12 +36,19 @@ public class CommandSend implements SimpleCommand {
if (strings.length == 2) {
List oPlayer = new ArrayList<>();
if (strings[0].equals("all")) {
- oPlayer.addAll(server.connectedPlayers());
+ for (Player player : server.getAllPlayers()) {
+ oPlayer.add(player);
+ }
}
else if (strings[0].equals("current")) {
if (commandSource instanceof Player) {
Player playerSource = (Player)commandSource;
- oPlayer.addAll(playerSource.connectedServer().target().connectedPlayers());
+ Optional conn = playerSource.getCurrentServer();
+ if (conn.isPresent()) {
+ for (Player player : conn.get().getServer().getPlayersConnected()) {
+ oPlayer.add(player);
+ }
+ }
}
else {
commandSource.sendMessage(Component.text("Command is only for players.").color(COLOR_RED));
@@ -46,36 +56,37 @@ public class CommandSend implements SimpleCommand {
}
}
else {
- Player p = server.player(strings[0]);
- if (p != null) {
- oPlayer.add(p);
+ Optional p = server.getPlayer(strings[0]);
+ if (p.isPresent()) {
+ oPlayer.add(p.get());
}
}
HashMap> futures = new HashMap<>();
- RegisteredServer server = this.server.server(strings[1]);
- if (!oPlayer.isEmpty() && server != null) {
+ Optional oServer = server.getServer(strings[1]);
+ if (!oPlayer.isEmpty() && oServer.isPresent()) {
+ RegisteredServer server = oServer.get();
for (Player player : oPlayer) {
CompletableFuture future = player.createConnectionRequest(server).connect();
futures.put(player, future);
- if (oPlayer.size() == 1) {
- commandSource.sendMessage(Component.text("Sending " + player.username() + " to " + server.serverInfo().name()).color(COLOR_YELLOW));
+ if (oPlayer.size() <= 1) {
+ commandSource.sendMessage(Component.text("Sending " + player.getUsername() + " to " + server.getServerInfo().getName()).color(COLOR_ORANGE));
}
}
if (oPlayer.size() > 1) {
- commandSource.sendMessage(Component.text(String.format("Sending %d players to %s", oPlayer.size(), server.serverInfo().name())).color(COLOR_YELLOW));
+ commandSource.sendMessage(Component.text(String.format("Sending %d players to %s", oPlayer.size(), server.getServerInfo().getName())).color(COLOR_ORANGE));
}
new Thread(() -> {
futures.forEach(((player, future) -> {
future.whenComplete(((result, throwable) -> {
if (result.isSuccessful() && player.hasPermission("vtools.send.recvmsg")) {
- player.sendMessage(Component.text("You got sent to " + server.serverInfo().name()).color(COLOR_YELLOW));
+ player.sendMessage(Component.text("You got sent to " + server.getServerInfo().getName()).color(COLOR_ORANGE));
}
}));
}));
final HashMap results = new HashMap<>();
futures.forEach(((player, future) -> {
try {
- String status = future.get().status().name();
+ String status = future.get().getStatus().name();
results.put(status, results.getOrDefault(status, 0) + 1);
} catch (InterruptedException | ExecutionException e) {
String status = e.getCause().getClass().getSimpleName();
@@ -102,13 +113,13 @@ public class CommandSend implements SimpleCommand {
if (currentArgs.length <= 1) {
arg.add("all");
arg.add("current");
- for (Player player : server.connectedPlayers()) {
- arg.add(player.username());
+ for (Player player : server.getAllPlayers()) {
+ arg.add(player.getUsername());
}
return arg;
} else if (currentArgs.length == 2) {
- for (RegisteredServer server : server.registeredServers()) {
- arg.add(server.serverInfo().name());
+ for (RegisteredServer server : server.getAllServers()) {
+ arg.add(server.getServerInfo().getName());
}
}
return arg;
diff --git a/src/main/java/de/strifel/VTools/commands/CommandServers.java b/src/main/java/de/strifel/VTools/commands/CommandServers.java
index aafaed8..060ebfa 100644
--- a/src/main/java/de/strifel/VTools/commands/CommandServers.java
+++ b/src/main/java/de/strifel/VTools/commands/CommandServers.java
@@ -25,8 +25,8 @@ public class CommandServers implements SimpleCommand {
String[] strings = invocation.arguments();
StringBuilder servers = new StringBuilder();
- for (RegisteredServer server : server.registeredServers()) {
- servers.append(server.serverInfo().name());
+ for (RegisteredServer server : server.getAllServers()) {
+ servers.append(server.getServerInfo().getName());
servers.append(" ");
}
commandSource.sendMessage(Component.text(servers.toString()).color(COLOR_YELLOW));
diff --git a/src/main/java/de/strifel/VTools/commands/CommandStaffChat.java b/src/main/java/de/strifel/VTools/commands/CommandStaffChat.java
index 1079ab8..afc9f5f 100644
--- a/src/main/java/de/strifel/VTools/commands/CommandStaffChat.java
+++ b/src/main/java/de/strifel/VTools/commands/CommandStaffChat.java
@@ -2,7 +2,7 @@ package de.strifel.VTools.commands;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.command.SimpleCommand;
-import com.velocitypowered.api.proxy.connection.Player;
+import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import net.kyori.adventure.text.Component;
@@ -27,8 +27,8 @@ public class CommandStaffChat implements SimpleCommand {
if (strings.length > 0) {
String channel = strings[0].startsWith("c:") && !strings[0].equals("c:") ? strings[0].split(":")[1] : null;
- String message = "§4[Staff]§r " + (commandSource instanceof Player ? ((Player) commandSource).username() : "Console") + (channel != null ? " (" + channel + ")" : "")+ " > " + String.join(" ", Arrays.copyOfRange(strings, channel == null ? 0 : 1, strings.length)).replace("&", "§");
- for (Player player : server.connectedPlayers()) {
+ String message = "§4[Staff]§r " + (commandSource instanceof Player ? ((Player) commandSource).getUsername() : "Console") + (channel != null ? " (" + channel + ")" : "")+ " > " + String.join(" ", Arrays.copyOfRange(strings, channel == null ? 0 : 1, strings.length)).replace("&", "§");
+ for (Player player : server.getAllPlayers()) {
if (player.hasPermission("vtools.staffchat" + (channel != null ? "." + channel : ""))) {
player.sendMessage(Component.text(message));
}
diff --git a/src/main/java/de/strifel/VTools/commands/CommandTp.java b/src/main/java/de/strifel/VTools/commands/CommandTp.java
index 8de0e29..23edb77 100644
--- a/src/main/java/de/strifel/VTools/commands/CommandTp.java
+++ b/src/main/java/de/strifel/VTools/commands/CommandTp.java
@@ -2,7 +2,7 @@ package de.strifel.VTools.commands;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.command.SimpleCommand;
-import com.velocitypowered.api.proxy.connection.Player;
+import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import net.kyori.adventure.text.Component;
@@ -28,9 +28,9 @@ public class CommandTp implements SimpleCommand {
if (commandSource instanceof Player) {
if (strings.length == 1) {
- Player player = server.player(strings[0]);
- if (player != null) {
- Optional.ofNullable(player.connectedServer()).ifPresent(serverConnection -> ((Player) commandSource).createConnectionRequest(serverConnection.target()).fireAndForget());
+ Optional player = server.getPlayer(strings[0]);
+ if (player.isPresent()) {
+ player.get().getCurrentServer().ifPresent(serverConnection -> ((Player) commandSource).createConnectionRequest(serverConnection.getServer()).fireAndForget());
commandSource.sendMessage(Component.text("Connecting to the server of " + strings[0]).color(COLOR_YELLOW));
} else {
commandSource.sendMessage(Component.text("Player does not exists.").color(COLOR_RED));
@@ -47,8 +47,8 @@ public class CommandTp implements SimpleCommand {
public List suggest(Invocation commandInvocation) {
List arg = new ArrayList<>();
if (commandInvocation.arguments().length <= 1) {
- for (Player player : server.connectedPlayers()) {
- arg.add(player.username());
+ for (Player player : server.getAllPlayers()) {
+ arg.add(player.getUsername());
}
}
return arg;
diff --git a/velocity-plugin.json b/velocity-plugin.json
deleted file mode 100644
index 0982e0a..0000000
--- a/velocity-plugin.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "id": "vtools",
- "name": "VTools",
- "version": "1.0-SNAPSHOT",
- "authors": [ "unnamed" ],
- "dependencies": [],
- "main": "de.strifel.VTools.VTools"
-}