From 99037df730cca8ed09aac2bb3232e679d12ae773 Mon Sep 17 00:00:00 2001 From: Xinecraft Date: Mon, 24 Jun 2024 07:29:30 +0530 Subject: [PATCH] fixes lag issue on proxy --- build.gradle | 2 +- .../minetrax/bukkit/MinetraxBukkit.java | 1 - .../PlayerAdvancementDoneListener.java | 16 ---------- .../listeners/ServerConnectedListener.java | 28 +++++++++--------- .../listeners/ServerConnectedListener.java | 29 +++++++++---------- 5 files changed, 27 insertions(+), 49 deletions(-) delete mode 100644 bukkit/src/main/java/com/xinecraft/minetrax/bukkit/listeners/PlayerAdvancementDoneListener.java diff --git a/build.gradle b/build.gradle index d105a3e..99ce7aa 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ plugins { allprojects { group = 'com.xinecraft' description = 'Minetrax' - version = '6.0.2' + version = '6.2.0' repositories { mavenLocal() diff --git a/bukkit/src/main/java/com/xinecraft/minetrax/bukkit/MinetraxBukkit.java b/bukkit/src/main/java/com/xinecraft/minetrax/bukkit/MinetraxBukkit.java index 37871d4..069640a 100644 --- a/bukkit/src/main/java/com/xinecraft/minetrax/bukkit/MinetraxBukkit.java +++ b/bukkit/src/main/java/com/xinecraft/minetrax/bukkit/MinetraxBukkit.java @@ -163,7 +163,6 @@ public void onEnable() { Objects.requireNonNull(getCommand("ww")).setExecutor(new PlayerWhoisCommand()); // Register Listeners - getServer().getPluginManager().registerEvents(new PlayerAdvancementDoneListener(), this); getServer().getPluginManager().registerEvents(new PlayerChatListener(), this); getServer().getPluginManager().registerEvents(new PlayerDeathListener(), this); getServer().getPluginManager().registerEvents(new PlayerJoinLeaveListener(), this); diff --git a/bukkit/src/main/java/com/xinecraft/minetrax/bukkit/listeners/PlayerAdvancementDoneListener.java b/bukkit/src/main/java/com/xinecraft/minetrax/bukkit/listeners/PlayerAdvancementDoneListener.java deleted file mode 100644 index 1d8f623..0000000 --- a/bukkit/src/main/java/com/xinecraft/minetrax/bukkit/listeners/PlayerAdvancementDoneListener.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.xinecraft.minetrax.bukkit.listeners; - -import com.xinecraft.minetrax.common.utils.LoggingUtil; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerAdvancementDoneEvent; - -public class PlayerAdvancementDoneListener implements Listener { - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onPlayerAdvancementDone(PlayerAdvancementDoneEvent event) - { - LoggingUtil.info("Advancement Made:" + event.getAdvancement().getKey().toString()); - } -} diff --git a/bungee/src/main/java/com/xinecraft/minetrax/bungee/listeners/ServerConnectedListener.java b/bungee/src/main/java/com/xinecraft/minetrax/bungee/listeners/ServerConnectedListener.java index 5e0e95e..7c49e4a 100644 --- a/bungee/src/main/java/com/xinecraft/minetrax/bungee/listeners/ServerConnectedListener.java +++ b/bungee/src/main/java/com/xinecraft/minetrax/bungee/listeners/ServerConnectedListener.java @@ -20,22 +20,20 @@ public void sendUpdateSkinMessageOnServerConnected(ServerConnectedEvent event) { } ProxiedPlayer player = event.getPlayer(); - SkinProperty skinProperty = SkinUtil.getSkinForPlayer(player.getUniqueId(), player.getName()); + MinetraxBungee.getPlugin().getProxy().getScheduler().runAsync(MinetraxBungee.getPlugin(), () -> { + SkinProperty skinProperty = SkinUtil.getSkinForPlayer(player.getUniqueId(), player.getName()); + if (skinProperty != null) { + String skinPropertyJson = MinetraxBungee.getPlugin().getGson().toJson(skinProperty); + String skinTextureId = PropertyUtils.getSkinTextureUrlStripped(skinProperty); + String playerUuid = player.getUniqueId().toString(); - if (skinProperty != null) { - String skinPropertyJson = MinetraxBungee.getPlugin().getGson().toJson(skinProperty); - String skinTextureId = PropertyUtils.getSkinTextureUrlStripped(skinProperty); - String playerUuid = player.getUniqueId().toString(); - - ByteArrayDataOutput out = ByteStreams.newDataOutput(); - out.writeUTF("UpdatePlayerSkin"); - out.writeUTF(playerUuid); - out.writeUTF(skinPropertyJson); - out.writeUTF(skinTextureId); - - MinetraxBungee.getPlugin().getProxy().getScheduler().runAsync(MinetraxBungee.getPlugin(), () -> { + ByteArrayDataOutput out = ByteStreams.newDataOutput(); + out.writeUTF("UpdatePlayerSkin"); + out.writeUTF(playerUuid); + out.writeUTF(skinPropertyJson); + out.writeUTF(skinTextureId); event.getServer().sendData(MinetraxCommon.PLUGIN_MESSAGE_CHANNEL, out.toByteArray()); - }); - } + } + }); } } diff --git a/velocity/src/main/java/com/xinecraft/minetrax/velocity/listeners/ServerConnectedListener.java b/velocity/src/main/java/com/xinecraft/minetrax/velocity/listeners/ServerConnectedListener.java index 0bace07..84749c1 100644 --- a/velocity/src/main/java/com/xinecraft/minetrax/velocity/listeners/ServerConnectedListener.java +++ b/velocity/src/main/java/com/xinecraft/minetrax/velocity/listeners/ServerConnectedListener.java @@ -20,23 +20,20 @@ public void sendUpdateSkinMessageOnServerConnected(ServerConnectedEvent event) { Player player = event.getPlayer(); RegisteredServer server = event.getServer(); - SkinProperty skinProperty = SkinUtil.getSkinForPlayer(player.getUniqueId(), player.getUsername()); + MinetraxVelocity.getPlugin().getProxyServer().getScheduler().buildTask(MinetraxVelocity.getPlugin(), () -> { + SkinProperty skinProperty = SkinUtil.getSkinForPlayer(player.getUniqueId(), player.getUsername()); + if (skinProperty != null) { + String skinPropertyJson = MinetraxVelocity.getPlugin().getGson().toJson(skinProperty); + String skinTextureId = PropertyUtils.getSkinTextureUrlStripped(skinProperty); + String playerUuid = player.getUniqueId().toString(); - if (skinProperty != null) { - String skinPropertyJson = MinetraxVelocity.getPlugin().getGson().toJson(skinProperty); - String skinTextureId = PropertyUtils.getSkinTextureUrlStripped(skinProperty); - String playerUuid = player.getUniqueId().toString(); - - ByteArrayDataOutput out = ByteStreams.newDataOutput(); - out.writeUTF("UpdatePlayerSkin"); - out.writeUTF(playerUuid); - out.writeUTF(skinPropertyJson); - out.writeUTF(skinTextureId); - - // Run after 1 seconds as plugin message channel is not ready yet. - MinetraxVelocity.getPlugin().getProxyServer().getScheduler().buildTask(MinetraxVelocity.getPlugin(), () -> { + ByteArrayDataOutput out = ByteStreams.newDataOutput(); + out.writeUTF("UpdatePlayerSkin"); + out.writeUTF(playerUuid); + out.writeUTF(skinPropertyJson); + out.writeUTF(skinTextureId); server.sendPluginMessage(MinetraxVelocity.PLUGIN_MESSAGE_CHANNEL, out.toByteArray()); - }).delay(1, java.util.concurrent.TimeUnit.SECONDS).schedule(); - } + } + }).delay(1, java.util.concurrent.TimeUnit.SECONDS).schedule(); // Run after 1 seconds as plugin message channel is not ready yet. } }