feat(global): downgrade project to jre1.8 for compatibility reasons
also fixed the impossibility to compile 1.13 to 1.16 because the PlayerInfoData class is NOT static toying with NMS is not recommended and i can see why but this is on another level
This commit is contained in:
parent
5fa12e0ef7
commit
2bba64e521
31 changed files with 337 additions and 142 deletions
|
@ -1,5 +1,6 @@
|
|||
package net.artelnatif.nicko.impl;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
|
@ -13,8 +14,9 @@ import org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class v1_13_R1 implements Internals {
|
||||
@Override
|
||||
|
@ -69,7 +71,7 @@ public class v1_13_R1 implements Internals {
|
|||
final MojangSkin skin = skinFetch.getResult();
|
||||
final PropertyMap properties = gameProfile.getProperties();
|
||||
properties.removeAll("textures");
|
||||
properties.put("textures", new Property("textures", skin.value(), skin.signature()));
|
||||
properties.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
||||
updateSelf(player);
|
||||
}
|
||||
}
|
||||
|
@ -78,12 +80,14 @@ public class v1_13_R1 implements Internals {
|
|||
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
|
||||
final IChatBaseComponent name = new ChatComponentText(profileName);
|
||||
|
||||
final PacketPlayOutPlayerInfo.PlayerInfoData data = remove.new PlayerInfoData(gameProfile,
|
||||
final Object infoData = yes(
|
||||
add,
|
||||
gameProfile,
|
||||
entityPlayer.ping,
|
||||
EnumGamemode.getById(player.getGameMode().ordinal()), name);
|
||||
final ArrayList<PacketPlayOutPlayerInfo.PlayerInfoData> list = new ArrayList<>();
|
||||
list.add(data);
|
||||
spoofPlayerInfoPacket(add, list);
|
||||
EnumGamemode.getById(player.getGameMode().ordinal()),
|
||||
name
|
||||
);
|
||||
spoofPlayerInfoPacket(add, Lists.newArrayList(infoData));
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
||||
|
@ -103,4 +107,22 @@ public class v1_13_R1 implements Internals {
|
|||
NickoBukkit.getInstance().getLogger().warning("Unable to spoof packet, that's bad! (" + e.getMessage() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
public Object yes(PacketPlayOutPlayerInfo packet, GameProfile gameProfile, int ping, EnumGamemode gamemode, IChatBaseComponent name) {
|
||||
try {
|
||||
final Class<?> clazz = Class.forName("net.minecraft.server.v1_13_R1.PacketPlayOutPlayerInfo$PlayerInfoData");
|
||||
final Constructor<?> infoConstructor = clazz.getDeclaredConstructor(
|
||||
PacketPlayOutPlayerInfo.class,
|
||||
GameProfile.class,
|
||||
int.class,
|
||||
EnumGamemode.class,
|
||||
IChatBaseComponent.class
|
||||
);
|
||||
return infoConstructor.newInstance(packet, gameProfile, ping, gamemode, name);
|
||||
} catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException | InstantiationException |
|
||||
IllegalAccessException e) {
|
||||
NickoBukkit.getInstance().getLogger().warning("Unable to instantiate PlayerInfoData, that's bad! (" + e.getMessage() + ")");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue