mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
Move sending player cross server to a 1-tick delayed task and suppress beta warnings
This commit is contained in:
1 parent
f6dba0d317
commit
d5427d76c7
1 file changed
+9
-4
@@ -16,11 +16,14 @@ public class PluginMessage {
|
||||
private static final HuskHomes plugin = HuskHomes.getInstance();
|
||||
|
||||
// Move a player to a different server in the bungee network
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public static void sendPlayer(Player p, String targetServer) {
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF(targetServer);
|
||||
p.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF(targetServer);
|
||||
p.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||
}, 1);
|
||||
}
|
||||
|
||||
private static final String MESSAGE_DATA_SEPARATOR = "$";
|
||||
@@ -77,6 +80,7 @@ public class PluginMessage {
|
||||
* Send the plugin message
|
||||
* @param sender The player to send the message
|
||||
*/
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public void send(Player sender) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
@@ -111,6 +115,7 @@ public class PluginMessage {
|
||||
sendToServer(sender, "ALL");
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public void sendToServer(Player sender, String server) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
|
||||
Reference in new issue
Block a user