diff --git a/Spigot_1_16_R3/build.gradle b/Spigot_1_16_R3/build.gradle new file mode 100644 index 0000000..09cc934 --- /dev/null +++ b/Spigot_1_16_R3/build.gradle @@ -0,0 +1,5 @@ +apply plugin: 'java' +dependencies { + compileOnly 'org.spigotmc:spigot:1.16.4-R0.1-SNAPSHOT' +} + diff --git a/Spigot_1_16_R3/src/main/java/nl/thedutchmc/SkinFixer/changeSkin/changeGameProfile/ChangeGameProfile_1_16_r3.java b/Spigot_1_16_R3/src/main/java/nl/thedutchmc/SkinFixer/changeSkin/changeGameProfile/ChangeGameProfile_1_16_r3.java new file mode 100644 index 0000000..f7ccca7 --- /dev/null +++ b/Spigot_1_16_R3/src/main/java/nl/thedutchmc/SkinFixer/changeSkin/changeGameProfile/ChangeGameProfile_1_16_r3.java @@ -0,0 +1,50 @@ +package nl.thedutchmc.SkinFixer.changeSkin.changeGameProfile; + +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer; +import org.bukkit.entity.Player; + +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import com.mojang.authlib.properties.PropertyMap; + +import net.minecraft.server.v1_16_R3.EntityPlayer; +import net.minecraft.server.v1_16_R3.PacketPlayOutPlayerInfo; +import net.minecraft.server.v1_16_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction; + +public class ChangeGameProfile_1_16_r3 { + + public static void changeProfile(UUID uuid, String skinValue, String skinSignature) { + Player player = Bukkit.getPlayer(uuid); + + //Fetch the EntityPlayer and their GameProfile + EntityPlayer ep = ((CraftPlayer)player).getHandle(); + GameProfile gp = ep.getProfile(); + + //Get the skin texture property + PropertyMap pm = gp.getProperties(); + + //Check if the propertyMap contains a texture value, if so, remove it. + if(pm.containsKey("textures")) { + Property property = pm.get("textures").iterator().next(); + pm.remove("textures", property); + } + + //Remove the old texture, and set the new one. + pm.put("textures", new Property("textures", skinValue, skinSignature)); + + //Reload the skin for the player itself + reloadSkinForSelf(player); + } + + public static void reloadSkinForSelf(Player player) { + final EntityPlayer ep = ((CraftPlayer) player).getHandle(); + final PacketPlayOutPlayerInfo removeInfo = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, ep); + final PacketPlayOutPlayerInfo addInfo = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, ep); + + ep.playerConnection.sendPacket(removeInfo); + ep.playerConnection.sendPacket(addInfo); + } +} diff --git a/build.gradle b/build.gradle index 7ce90da..f20e118 100644 --- a/build.gradle +++ b/build.gradle @@ -53,6 +53,8 @@ dependencies { //NMS classes compile project('Spigot_1_16_R1') compile project('Spigot_1_16_R2') + compile project('Spigot_1_16_R3') + } shadowJar() { diff --git a/gradle.properties b/gradle.properties index 8ddf396..89015a0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -pluginVersion = 1.1 +pluginVersion = 1.2 pluginGroup = nl.thedutchmc pluginName = SkinFixer pluginAuthor = TheDutchMC diff --git a/settings.gradle b/settings.gradle index d8d1b6d..7c1b662 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,4 @@ rootProject.name = pluginName include ':Spigot_1_16_R1' -include ':Spigot_1_16_R2' \ No newline at end of file +include ':Spigot_1_16_R2' +include ':Spigot_1_16_R3' \ No newline at end of file diff --git a/src/main/java/nl/thedutchmc/SkinFixer/changeSkin/SkinChangeOrchestrator.java b/src/main/java/nl/thedutchmc/SkinFixer/changeSkin/SkinChangeOrchestrator.java index b3e140f..cf46ab0 100644 --- a/src/main/java/nl/thedutchmc/SkinFixer/changeSkin/SkinChangeOrchestrator.java +++ b/src/main/java/nl/thedutchmc/SkinFixer/changeSkin/SkinChangeOrchestrator.java @@ -13,8 +13,7 @@ import net.md_5.bungee.api.ChatColor; import nl.thedutchmc.SkinFixer.SkinFixer; import nl.thedutchmc.SkinFixer.SkinObject; -import nl.thedutchmc.SkinFixer.changeSkin.changeGameProfile.ChangeGameProfile_1_16_r1; -import nl.thedutchmc.SkinFixer.changeSkin.changeGameProfile.ChangeGameProfile_1_16_r2; +import nl.thedutchmc.SkinFixer.changeSkin.changeGameProfile.*; import nl.thedutchmc.SkinFixer.fileHandlers.StorageHandler; public class SkinChangeOrchestrator { @@ -90,6 +89,7 @@ public void run() { switch(SkinFixer.NMS_VERSION) { case "v1_16_R1": ChangeGameProfile_1_16_r1.changeProfile(player.getUniqueId(), skinValue, skinSignature); break; case "v1_16_R2": ChangeGameProfile_1_16_r2.changeProfile(player.getUniqueId(), skinValue, skinSignature); break; + case "v1_16_R3": ChangeGameProfile_1_16_r3.changeProfile(player.getUniqueId(), skinValue, skinSignature); break; default: //We dont support the version that the user is running, so we inform them of this. //Calls to the Bukkit API may only be sync, so it's inside a BukkitRunnable