Skip to content

Commit

Permalink
Added support for 1.16.4
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDutchMC committed Nov 7, 2020
1 parent 449dc32 commit a837641
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 4 deletions.
5 changes: 5 additions & 0 deletions Spigot_1_16_R3/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apply plugin: 'java'
dependencies {
compileOnly 'org.spigotmc:spigot:1.16.4-R0.1-SNAPSHOT'
}

Original file line number Diff line number Diff line change
@@ -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);
}
}
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pluginVersion = 1.1
pluginVersion = 1.2
pluginGroup = nl.thedutchmc
pluginName = SkinFixer
pluginAuthor = TheDutchMC
Expand Down
3 changes: 2 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
rootProject.name = pluginName
include ':Spigot_1_16_R1'
include ':Spigot_1_16_R2'
include ':Spigot_1_16_R2'
include ':Spigot_1_16_R3'
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a837641

Please sign in to comment.