From 3859f51e00903e7c95b4b9a77577352f682f0c4b Mon Sep 17 00:00:00 2001 From: games647 Date: Fri, 10 Jun 2016 11:47:37 +0200 Subject: [PATCH] Fixed instant updates for BungeeCord servers (users don't see the new skin) --- CHANGELOG.md | 4 ++++ bukkit/pom.xml | 2 +- .../bukkit/listener/BungeeCordListener.java | 17 +++++++++++++++-- .../changeskin/bukkit/tasks/SkinUpdater.java | 1 - bungee/pom.xml | 2 +- .../changeskin/bungee/ChangeSkinBungee.java | 6 ++++-- core/pom.xml | 2 +- pom.xml | 2 +- universal/pom.xml | 2 +- 9 files changed, 28 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84701774..21f2da1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ #Changelog +##### 1.4.1 + +* Fixed instant updates for BungeeCord servers + ##### 1.4 * Added skin cooldown diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 3e4562e8..9ee6439a 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -5,7 +5,7 @@ com.github.games647 changeskin - 1.4 + 1.4.1 ../pom.xml diff --git a/bukkit/src/main/java/com/github/games647/changeskin/bukkit/listener/BungeeCordListener.java b/bukkit/src/main/java/com/github/games647/changeskin/bukkit/listener/BungeeCordListener.java index f21fa706..45b4fd85 100644 --- a/bukkit/src/main/java/com/github/games647/changeskin/bukkit/listener/BungeeCordListener.java +++ b/bukkit/src/main/java/com/github/games647/changeskin/bukkit/listener/BungeeCordListener.java @@ -1,7 +1,12 @@ package com.github.games647.changeskin.bukkit.listener; +import com.comphenix.protocol.wrappers.WrappedGameProfile; +import com.comphenix.protocol.wrappers.WrappedSignedProperty; import com.github.games647.changeskin.bukkit.ChangeSkinBukkit; import com.github.games647.changeskin.bukkit.tasks.SkinUpdater; +import com.github.games647.changeskin.core.ChangeSkinCore; +import com.google.common.io.ByteArrayDataInput; +import com.google.common.io.ByteStreams; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -21,8 +26,16 @@ public void onPluginMessageReceived(String channel, Player player, byte[] messag return; } -// ByteArrayDataInput dataInput = ByteStreams.newDataInput(message); -// String subchannel = dataInput.readUTF(); + ByteArrayDataInput dataInput = ByteStreams.newDataInput(message); + String subchannel = dataInput.readUTF(); + + WrappedGameProfile gameProfile = WrappedGameProfile.fromPlayer(player); + //remove existing skins + gameProfile.getProperties().clear(); + WrappedSignedProperty property = WrappedSignedProperty + .fromValues(ChangeSkinCore.SKIN_KEY, dataInput.readUTF(), dataInput.readUTF()); + gameProfile.getProperties().put(ChangeSkinCore.SKIN_KEY, property); + Bukkit.getScheduler().runTask(plugin, new SkinUpdater(plugin, null, player)); } } diff --git a/bukkit/src/main/java/com/github/games647/changeskin/bukkit/tasks/SkinUpdater.java b/bukkit/src/main/java/com/github/games647/changeskin/bukkit/tasks/SkinUpdater.java index addc7376..2290587a 100644 --- a/bukkit/src/main/java/com/github/games647/changeskin/bukkit/tasks/SkinUpdater.java +++ b/bukkit/src/main/java/com/github/games647/changeskin/bukkit/tasks/SkinUpdater.java @@ -43,7 +43,6 @@ public void run() { } WrappedGameProfile gameProfile = WrappedGameProfile.fromPlayer(receiver); - if (plugin.getStorage() != null) { UserPreferences preferences = plugin.getStorage().getPreferences(receiver.getUniqueId(), false); SkinData targetSkin = preferences.getTargetSkin(); diff --git a/bungee/pom.xml b/bungee/pom.xml index 15d7bb0a..e43a359d 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -5,7 +5,7 @@ com.github.games647 changeskin - 1.4 + 1.4.1 ../pom.xml diff --git a/bungee/src/main/java/com/github/games647/changeskin/bungee/ChangeSkinBungee.java b/bungee/src/main/java/com/github/games647/changeskin/bungee/ChangeSkinBungee.java index 8b2440b9..01d248b2 100644 --- a/bungee/src/main/java/com/github/games647/changeskin/bungee/ChangeSkinBungee.java +++ b/bungee/src/main/java/com/github/games647/changeskin/bungee/ChangeSkinBungee.java @@ -18,10 +18,10 @@ import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.logging.Level; + import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.chat.TextComponent; - import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.config.Configuration; @@ -124,7 +124,9 @@ public void applySkin(ProxiedPlayer player, SkinData skinData) { if (player.getServer() != null) { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF("UpdateSkin"); - player.getServer().sendData(this.getDescription().getName(), out.toByteArray()); + out.writeUTF(skinData.getEncodedData()); + out.writeUTF(skinData.getEncodedSignature()); + player.getServer().sendData(getDescription().getName(), out.toByteArray()); } } diff --git a/core/pom.xml b/core/pom.xml index df81af49..85a370b8 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -5,7 +5,7 @@ com.github.games647 changeskin - 1.4 + 1.4.1 ../pom.xml diff --git a/pom.xml b/pom.xml index 1cfb9739..1a2b613e 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ pom ChangeSkin - 1.4 + 1.4.1 2015 http://dev.bukkit.org/bukkit-plugins/changeskin/ diff --git a/universal/pom.xml b/universal/pom.xml index 01364302..ef94de34 100644 --- a/universal/pom.xml +++ b/universal/pom.xml @@ -5,7 +5,7 @@ com.github.games647 changeskin - 1.4 + 1.4.1 ../pom.xml