Skip to content

Commit

Permalink
fixes lag issue on proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Xinecraft committed Jun 24, 2024
1 parent 81df846 commit 99037df
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 49 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
allprojects {
group = 'com.xinecraft'
description = 'Minetrax'
version = '6.0.2'
version = '6.2.0'

repositories {
mavenLocal()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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());
});
}
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
}

0 comments on commit 99037df

Please sign in to comment.