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:
aro 2023-01-31 18:11:05 +01:00
parent 5fa12e0ef7
commit 2bba64e521
31 changed files with 337 additions and 142 deletions

View file

@ -40,14 +40,6 @@
<include>org.mariadb.jdbc</include> <include>org.mariadb.jdbc</include>
</includes> </includes>
</artifactSet> </artifactSet>
<filters>
<filter>
<artifact>net.artelnatif:*</artifact>
<excludes>
<exclude>META-INF/*.MF</exclude>
</excludes>
</filter>
</filters>
<relocations> <relocations>
<relocation> <relocation>
<pattern>net.wesjd.anvilgui</pattern> <pattern>net.wesjd.anvilgui</pattern>
@ -170,8 +162,6 @@
</dependency> </dependency>
</dependencies> </dependencies>
<properties> <properties>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
</project> </project>

View file

@ -14,8 +14,6 @@
</parent> </parent>
<properties> <properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>

View file

@ -13,7 +13,7 @@ public class BungeeCordSupport {
public void warnNickoNotHookedToBungeeCord() { public void warnNickoNotHookedToBungeeCord() {
final Server server = instance.getServer(); final Server server = instance.getServer();
final YamlConfiguration config = server.spigot().getConfig(); final YamlConfiguration config = server.spigot().getConfig();
if (config.getConfigurationSection("settings").getBoolean("bungeecord") && !instance.getNicko().getConfig().bungeecord()) { if (config.getConfigurationSection("settings").getBoolean("bungeecord") && !instance.getNicko().getConfig().isBungeecord()) {
instance.getLogger().warning("Hummm. Your server is hooked to BungeeCord, but it seems"); instance.getLogger().warning("Hummm. Your server is hooked to BungeeCord, but it seems");
instance.getLogger().warning("that BungeeCord support is not enabled inside Nicko."); instance.getLogger().warning("that BungeeCord support is not enabled inside Nicko.");
instance.getLogger().warning("If this is intentional, you can safely ignore this message."); instance.getLogger().warning("If this is intentional, you can safely ignore this message.");
@ -24,7 +24,7 @@ public class BungeeCordSupport {
public boolean stopIfBungeeCordIsNotEnabled() { public boolean stopIfBungeeCordIsNotEnabled() {
final Server server = instance.getServer(); final Server server = instance.getServer();
final YamlConfiguration config = server.spigot().getConfig(); final YamlConfiguration config = server.spigot().getConfig();
if (!config.getConfigurationSection("settings").getBoolean("bungeecord") && instance.getNicko().getConfig().bungeecord()) { if (!config.getConfigurationSection("settings").getBoolean("bungeecord") && instance.getNicko().getConfig().isBungeecord()) {
instance.getLogger().severe("Hummm. You have enabled BungeeCord support inside Nicko,"); instance.getLogger().severe("Hummm. You have enabled BungeeCord support inside Nicko,");
instance.getLogger().severe("but it seems that your server is not hooked to your BungeeCord instance."); instance.getLogger().severe("but it seems that your server is not hooked to your BungeeCord instance.");
instance.getLogger().severe("Please enable BungeeCord support inside your spigot.yml as well."); instance.getLogger().severe("Please enable BungeeCord support inside your spigot.yml as well.");

View file

@ -87,7 +87,7 @@ public class NickoBukkit extends JavaPlugin {
mojangAPI = new MojangAPI(nicko); mojangAPI = new MojangAPI(nicko);
localeFileManager = new LocaleFileManager(); localeFileManager = new LocaleFileManager();
if (nicko.getConfig().customLocale()) { if (nicko.getConfig().isCustomLocale()) {
if (localeFileManager.dumpFromLocale(Locale.ENGLISH)) { if (localeFileManager.dumpFromLocale(Locale.ENGLISH)) {
getLogger().info("Successfully loaded custom language file."); getLogger().info("Successfully loaded custom language file.");
} else { } else {
@ -111,7 +111,7 @@ public class NickoBukkit extends JavaPlugin {
final BungeeCordSupport support = new BungeeCordSupport(this); final BungeeCordSupport support = new BungeeCordSupport(this);
support.warnNickoNotHookedToBungeeCord(); support.warnNickoNotHookedToBungeeCord();
if (nicko.getConfig().bungeecord()) { if (nicko.getConfig().isBungeecord()) {
if (support.stopIfBungeeCordIsNotEnabled()) { if (support.stopIfBungeeCordIsNotEnabled()) {
getLogger().info("Enabling BungeeCord support..."); getLogger().info("Enabling BungeeCord support...");
getServer().getMessenger().registerIncomingPluginChannel(this, NickoBungee.PROXY_UPDATE, new PluginMessageHandler()); getServer().getMessenger().registerIncomingPluginChannel(this, NickoBungee.PROXY_UPDATE, new PluginMessageHandler());
@ -133,7 +133,7 @@ public class NickoBukkit extends JavaPlugin {
} }
} }
if (nicko.getConfig().bungeecord()) { if (nicko.getConfig().isBungeecord()) {
getServer().getMessenger().unregisterIncomingPluginChannel(this); getServer().getMessenger().unregisterIncomingPluginChannel(this);
getServer().getMessenger().unregisterOutgoingPluginChannel(this); getServer().getMessenger().unregisterOutgoingPluginChannel(this);
} }

View file

@ -10,20 +10,25 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class NickoCommand implements CommandExecutor { public class NickoCommand implements CommandExecutor {
private String helpMessage = """ private String helpMessage = "§cNicko §8§o[{version}] §f- §2Help:\n" +
§cNicko §8§o[{version}] §f- §2Help: "§6/nicko §f- §7Open the GUI.\n" +
§6/nicko §f- §7Open the GUI. "§6/nicko help §f- §7Print this help message.\n";
§6/nicko help §f- §7Print this help message.
""";
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player player) { if (sender instanceof Player) {
Player player = (Player) sender;
if (args.length >= 1) { if (args.length >= 1) {
switch (args[0]) { switch (args[0]) {
case "debug" -> new NickoDebugSubCmd().execute(sender, args); case "debug":
case "check" -> new NickoCheckSubCmd().execute(player, args); new NickoDebugSubCmd().execute(player, args);
default -> sendHelpMessage(sender); break;
case "check":
new NickoCheckSubCmd().execute(player, args);
break;
default:
sendHelpMessage(sender);
break;
} }
return false; return false;
} }

View file

@ -28,7 +28,7 @@ public class NickoCheckSubCmd {
} }
final StringJoiner builder = new StringJoiner("\n"); final StringJoiner builder = new StringJoiner("\n");
builder.add("§c" + NickoBukkit.getInstance().getNicko().getConfig().prefix() + "§6Check for: §f§o" + targetName); builder.add("§c" + NickoBukkit.getInstance().getNicko().getConfig().getPrefix() + "§6Check for: §f§o" + targetName);
if (!appearanceManager.hasData()) { if (!appearanceManager.hasData()) {
builder.add("§cThis player has not data."); builder.add("§cThis player has not data.");
} else { } else {

View file

@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
public class NickoDebugSubCmd { public class NickoDebugSubCmd {
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
final String prefix = NickoBukkit.getInstance().getNicko().getConfig().prefix(); final String prefix = NickoBukkit.getInstance().getNicko().getConfig().getPrefix();
Player target; Player target;
String name, skin; String name, skin;

View file

@ -24,7 +24,7 @@ public class SettingsGUI {
}; };
final Nicko nicko = NickoBukkit.getInstance().getNicko(); final Nicko nicko = NickoBukkit.getInstance().getNicko();
if (!nicko.getConfig().bungeecord() && nicko.isBungeecord()) { if (!nicko.getConfig().isBungeecord() && nicko.isBungeecord()) {
dynamicStructure[1] = dynamicStructure[1].replace("T", "U"); dynamicStructure[1] = dynamicStructure[1].replace("T", "U");
} }

View file

@ -52,7 +52,7 @@ public class LanguageCycling {
final ArrayList<Locale> localesToGenerate = new ArrayList<>(); final ArrayList<Locale> localesToGenerate = new ArrayList<>();
Collections.addAll(localesToGenerate, Locale.values()); Collections.addAll(localesToGenerate, Locale.values());
if (!instance.getNicko().getConfig().customLocale()) { if (!instance.getNicko().getConfig().isCustomLocale()) {
localesToGenerate.remove(Locale.CUSTOM); localesToGenerate.remove(Locale.CUSTOM);
} }
localesToGenerate.forEach(locale -> items.add(generateItem(locale, localesToGenerate))); localesToGenerate.forEach(locale -> items.add(generateItem(locale, localesToGenerate)));

View file

@ -29,9 +29,9 @@ public class I18N {
try { try {
formatter.applyPattern(translation); formatter.applyPattern(translation);
return instance.getNicko().getConfig().prefix() + formatter.format(arguments); return instance.getNicko().getConfig().getPrefix() + formatter.format(arguments);
} catch (Exception e) { } catch (Exception e) {
return instance.getNicko().getConfig().prefix() + key.key(); return instance.getNicko().getConfig().getPrefix() + key.key();
} }
} }

View file

@ -1,6 +1,10 @@
package net.artelnatif.nicko.bukkit.i18n; package net.artelnatif.nicko.bukkit.i18n;
public record I18NDict(String key) { public class I18NDict {
private final String key;
public I18NDict(String key) { this.key = key; }
public static class Event { public static class Event {
public static class Admin { public static class Admin {
public static final I18NDict CACHE_CLEAN = new I18NDict("event.admin.cache_clear"); public static final I18NDict CACHE_CLEAN = new I18NDict("event.admin.cache_clear");
@ -33,4 +37,8 @@ public record I18NDict(String key) {
public static final I18NDict SQL_ERROR = new I18NDict("error.sql"); public static final I18NDict SQL_ERROR = new I18NDict("error.sql");
public static final I18NDict JSON_ERROR = new I18NDict("error.json"); public static final I18NDict JSON_ERROR = new I18NDict("error.json");
} }
public String key() {
return key;
}
} }

View file

@ -59,12 +59,12 @@ public class NickoExpansion extends PlaceholderExpansion {
bungeecord = profile.isBungeecordTransfer(); bungeecord = profile.isBungeecordTransfer();
} }
return switch (params) { switch (params) {
case "name" -> name; case "name": return name;
case "skin" -> skin; case "skin": return skin;
case "locale" -> locale; case "locale": return locale;
case "bungeecord" -> String.valueOf(bungeecord); case "bungeecord": return String.valueOf(bungeecord);
default -> null; default: return null;
}; }
} }
} }

View file

@ -1,14 +1,53 @@
package net.artelnatif.nicko.config; package net.artelnatif.nicko.config;
public record Configuration( public class Configuration {
String address, private final String address;
String username, private final String username;
String password, private final String password;
String prefix, private final String prefix;
Boolean local, private final Boolean local;
Boolean bungeecord, private final Boolean bungeecord;
Boolean customLocale) { private final Boolean customLocale;
public Configuration(String address, String username, String password, String prefix, Boolean local, Boolean bungeecord, Boolean customLocale) {
this.address = address;
this.username = username;
this.password = password;
this.prefix = prefix;
this.local = local;
this.bungeecord = bungeecord;
this.customLocale = customLocale;
}
public Configuration() { public Configuration() {
this("", "", "", "", false, false, false); this("", "", "", "", false, false, false);
} }
public String getAddress() {
return address;
}
public String getUsername() {
return username;
}
public String getPassword() {
return password;
}
public String getPrefix() {
return prefix;
}
public Boolean isLocal() {
return local;
}
public Boolean isBungeecord() {
return bungeecord;
}
public Boolean isCustomLocale() {
return customLocale;
}
} }

View file

@ -23,7 +23,7 @@ public class MojangAPI {
public static final String URL_NAME = "https://api.mojang.com/users/profiles/minecraft/{name}"; public static final String URL_NAME = "https://api.mojang.com/users/profiles/minecraft/{name}";
public static final String URL_SKIN = "https://sessionserver.mojang.com/session/minecraft/profile/{uuid}?unsigned=false"; public static final String URL_SKIN = "https://sessionserver.mojang.com/session/minecraft/profile/{uuid}?unsigned=false";
private final CacheLoader<String, Optional<MojangSkin>> loader = new CacheLoader<>() { private final CacheLoader<String, Optional<MojangSkin>> loader = new CacheLoader<String, Optional<MojangSkin>>() {
@Nonnull @Nonnull
public Optional<MojangSkin> load(@Nonnull String uuid) throws Exception { public Optional<MojangSkin> load(@Nonnull String uuid) throws Exception {
return getSkinFromMojang(uuid); return getSkinFromMojang(uuid);
@ -77,15 +77,13 @@ public class MojangAPI {
con.setRequestMethod("GET"); con.setRequestMethod("GET");
switch (con.getResponseCode()) { switch (con.getResponseCode()) {
case 400 -> { case 400:
nicko.getLogger().warning("Failed to parse request: Invalid Name"); nicko.getLogger().warning("Failed to parse request: Invalid Name");
return getErrorObject(); return getErrorObject();
} case 429:
case 429 -> {
nicko.getLogger().warning("Failed to parse request: The connection is throttled."); nicko.getLogger().warning("Failed to parse request: The connection is throttled.");
return getErrorObject(); return getErrorObject();
} case 200:
case 200 -> {
final BufferedReader input = new BufferedReader(new InputStreamReader(con.getInputStream())); final BufferedReader input = new BufferedReader(new InputStreamReader(con.getInputStream()));
final StringBuilder builder = new StringBuilder(); final StringBuilder builder = new StringBuilder();
String line; String line;
@ -100,11 +98,9 @@ public class MojangAPI {
nicko.getLogger().warning("Failed to parse request (" + parametrizedUrl + ")!"); nicko.getLogger().warning("Failed to parse request (" + parametrizedUrl + ")!");
return getErrorObject(); return getErrorObject();
} }
} default:
default -> {
nicko.getLogger().warning("Unhandled response code from Mojang: " + con.getResponseCode()); nicko.getLogger().warning("Unhandled response code from Mojang: " + con.getResponseCode());
return getErrorObject(); return getErrorObject();
}
} }
} }

View file

@ -2,12 +2,27 @@ package net.artelnatif.nicko.mojang;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
public record MojangSkin(String name, String value, String signature) { public class MojangSkin {
private final String value;
private final String signature;
public MojangSkin(String value, String signature) {
this.value = value;
this.signature = signature;
}
public static MojangSkin buildFromJson(JsonObject object) { public static MojangSkin buildFromJson(JsonObject object) {
final String name = object.get("name").getAsString();
final JsonObject properties = object.get("properties").getAsJsonArray().get(0).getAsJsonObject(); final JsonObject properties = object.get("properties").getAsJsonArray().get(0).getAsJsonObject();
final String value = properties.get("value").getAsString(); final String value = properties.get("value").getAsString();
final String signature = properties.get("signature").getAsString(); final String signature = properties.get("signature").getAsString();
return new MojangSkin(name, value, signature); return new MojangSkin(value, signature);
}
public String getValue() {
return value;
}
public String getSignature() {
return signature;
} }
} }

View file

@ -20,7 +20,7 @@ public class PlayerDataStore {
public PlayerDataStore(Nicko nicko) { public PlayerDataStore(Nicko nicko) {
this.nicko = nicko; this.nicko = nicko;
this.storage = nicko.getConfig().local() && !nicko.isBungeecord() ? new JSONStorage(nicko) : new SQLStorage(nicko); this.storage = nicko.getConfig().isLocal() && !nicko.isBungeecord() ? new JSONStorage(nicko) : new SQLStorage(nicko);
} }
public void storeName(Player player) { public void storeName(Player player) {

View file

@ -37,12 +37,7 @@ public class SQLStorage extends Storage {
if (connection == null) return new ActionResult<>(I18NDict.Error.SQL_ERROR); if (connection == null) return new ActionResult<>(I18NDict.Error.SQL_ERROR);
try { try {
final String sql = """ final String sql = "INSERT IGNORE INTO nicko.DATA (`uuid`, `name`, `skin`, `bungeecord`) VALUES (?, ?, ?, ?)";
INSERT IGNORE INTO nicko.DATA
(`uuid`, `name`, `skin`, `bungeecord`)
VALUES
(?, ?, ?, ?)
""";
final PreparedStatement statement = connection.prepareStatement(sql); final PreparedStatement statement = connection.prepareStatement(sql);
statement.setObject(1, uuidToBin(uuid)); statement.setObject(1, uuidToBin(uuid));

View file

@ -25,9 +25,9 @@ public class SQLStorageProvider implements StorageProvider {
try { try {
final Configuration config = nicko.getConfig(); final Configuration config = nicko.getConfig();
dataSource = new MariaDbDataSource(); dataSource = new MariaDbDataSource();
dataSource.setUrl("jdbc:mariadb://" + config.address()); dataSource.setUrl("jdbc:mariadb://" + config.getAddress());
dataSource.setUser(config.username()); dataSource.setUser(config.getUsername());
dataSource.setPassword(config.password()); dataSource.setPassword(config.getPassword());
connection = dataSource.getConnection(); connection = dataSource.getConnection();
final boolean initialized = connection != null && !connection.isClosed(); final boolean initialized = connection != null && !connection.isClosed();
@ -59,15 +59,8 @@ public class SQLStorageProvider implements StorageProvider {
private void createTable() { private void createTable() {
final Connection connection = getConnection(); final Connection connection = getConnection();
final String query = """ String query = "CREATE TABLE IF NOT EXISTS %s.DATA (uuid binary(16) NOT NULL,name varchar(16) NOT NULL,skin varchar(16) NOT NULL,bungeecord boolean NOT NULL,PRIMARY KEY (UUID))";
CREATE TABLE IF NOT EXISTS %s.DATA ( query = query.replace("%s", schemaName);
uuid binary(16) NOT NULL,
name varchar(16) NOT NULL,
skin varchar(16) NOT NULL,
bungeecord boolean NOT NULL,
PRIMARY KEY (UUID)
)
""".formatted(schemaName);
try { try {
final PreparedStatement statement = connection.prepareStatement(query); final PreparedStatement statement = connection.prepareStatement(query);
@ -82,9 +75,8 @@ public class SQLStorageProvider implements StorageProvider {
private void createDatabase() { private void createDatabase() {
final Connection connection = getConnection(); final Connection connection = getConnection();
final String query = """ String query = "CREATE DATABASE IF NOT EXISTS %s";
CREATE DATABASE IF NOT EXISTS %s query = query.replace("%s", schemaName);
""".formatted(schemaName);
try { try {
final PreparedStatement statement = connection.prepareStatement(query); final PreparedStatement statement = connection.prepareStatement(query);

View file

@ -28,7 +28,7 @@
</modules> </modules>
<properties> <properties>
<maven.compiler.source>17</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
</properties> </properties>
</project> </project>

View file

@ -1,5 +1,6 @@
package net.artelnatif.nicko.impl; package net.artelnatif.nicko.impl;
import com.google.common.collect.Lists;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap; 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.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.lang.reflect.InvocationTargetException;
public class v1_13_R1 implements Internals { public class v1_13_R1 implements Internals {
@Override @Override
@ -69,7 +71,7 @@ public class v1_13_R1 implements Internals {
final MojangSkin skin = skinFetch.getResult(); final MojangSkin skin = skinFetch.getResult();
final PropertyMap properties = gameProfile.getProperties(); final PropertyMap properties = gameProfile.getProperties();
properties.removeAll("textures"); 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); updateSelf(player);
} }
} }
@ -78,12 +80,14 @@ public class v1_13_R1 implements Internals {
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER); final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
final IChatBaseComponent name = new ChatComponentText(profileName); final IChatBaseComponent name = new ChatComponentText(profileName);
final PacketPlayOutPlayerInfo.PlayerInfoData data = remove.new PlayerInfoData(gameProfile, final Object infoData = yes(
add,
gameProfile,
entityPlayer.ping, entityPlayer.ping,
EnumGamemode.getById(player.getGameMode().ordinal()), name); EnumGamemode.getById(player.getGameMode().ordinal()),
final ArrayList<PacketPlayOutPlayerInfo.PlayerInfoData> list = new ArrayList<>(); name
list.add(data); );
spoofPlayerInfoPacket(add, list); spoofPlayerInfoPacket(add, Lists.newArrayList(infoData));
Bukkit.getOnlinePlayers().forEach(online -> { Bukkit.getOnlinePlayers().forEach(online -> {
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); 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() + ")"); 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;
}
}
} }

View file

@ -1,5 +1,6 @@
package net.artelnatif.nicko.impl; package net.artelnatif.nicko.impl;
import com.google.common.collect.Lists;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap; import com.mojang.authlib.properties.PropertyMap;
@ -13,8 +14,9 @@ import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.lang.reflect.InvocationTargetException;
public class v1_13_R2 implements Internals { public class v1_13_R2 implements Internals {
@Override @Override
@ -69,7 +71,7 @@ public class v1_13_R2 implements Internals {
final MojangSkin skin = skinFetch.getResult(); final MojangSkin skin = skinFetch.getResult();
final PropertyMap properties = gameProfile.getProperties(); final PropertyMap properties = gameProfile.getProperties();
properties.removeAll("textures"); 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); updateSelf(player);
} }
} }
@ -78,12 +80,14 @@ public class v1_13_R2 implements Internals {
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER); final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
final IChatBaseComponent name = new ChatComponentText(profileName); final IChatBaseComponent name = new ChatComponentText(profileName);
final PacketPlayOutPlayerInfo.PlayerInfoData data = remove.new PlayerInfoData(gameProfile, final Object infoData = yes(
add,
gameProfile,
entityPlayer.ping, entityPlayer.ping,
EnumGamemode.getById(player.getGameMode().ordinal()), name); EnumGamemode.getById(player.getGameMode().ordinal()),
final ArrayList<PacketPlayOutPlayerInfo.PlayerInfoData> list = new ArrayList<>(); name
list.add(data); );
spoofPlayerInfoPacket(add, list); spoofPlayerInfoPacket(add, Lists.newArrayList(infoData));
Bukkit.getOnlinePlayers().forEach(online -> { Bukkit.getOnlinePlayers().forEach(online -> {
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
@ -103,4 +107,22 @@ public class v1_13_R2 implements Internals {
NickoBukkit.getInstance().getLogger().warning("Unable to spoof packet, that's bad! (" + e.getMessage() + ")"); 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_R2.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;
}
}
} }

View file

@ -1,5 +1,6 @@
package net.artelnatif.nicko.impl; package net.artelnatif.nicko.impl;
import com.google.common.collect.Lists;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap; import com.mojang.authlib.properties.PropertyMap;
@ -13,8 +14,9 @@ import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.lang.reflect.InvocationTargetException;
public class v1_14_R1 implements Internals { public class v1_14_R1 implements Internals {
@Override @Override
@ -67,7 +69,7 @@ public class v1_14_R1 implements Internals {
final MojangSkin skin = skinFetch.getResult(); final MojangSkin skin = skinFetch.getResult();
final PropertyMap properties = gameProfile.getProperties(); final PropertyMap properties = gameProfile.getProperties();
properties.removeAll("textures"); 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); updateSelf(player);
} }
} }
@ -76,12 +78,14 @@ public class v1_14_R1 implements Internals {
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER); final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
final IChatBaseComponent name = new ChatComponentText(profileName); final IChatBaseComponent name = new ChatComponentText(profileName);
final PacketPlayOutPlayerInfo.PlayerInfoData data = remove.new PlayerInfoData(gameProfile, final Object infoData = yes(
add,
gameProfile,
entityPlayer.ping, entityPlayer.ping,
EnumGamemode.getById(player.getGameMode().ordinal()), name); EnumGamemode.getById(player.getGameMode().ordinal()),
final ArrayList<PacketPlayOutPlayerInfo.PlayerInfoData> list = new ArrayList<>(); name
list.add(data); );
spoofPlayerInfoPacket(add, list); spoofPlayerInfoPacket(add, Lists.newArrayList(infoData));
Bukkit.getOnlinePlayers().forEach(online -> { Bukkit.getOnlinePlayers().forEach(online -> {
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
@ -101,4 +105,22 @@ public class v1_14_R1 implements Internals {
NickoBukkit.getInstance().getLogger().warning("Unable to spoof packet, that's bad! (" + e.getMessage() + ")"); 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_14_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;
}
}
} }

View file

@ -1,5 +1,6 @@
package net.artelnatif.nicko.impl; package net.artelnatif.nicko.impl;
import com.google.common.collect.Lists;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap; import com.mojang.authlib.properties.PropertyMap;
@ -7,15 +8,16 @@ import net.artelnatif.nicko.bukkit.NickoBukkit;
import net.artelnatif.nicko.disguise.ActionResult; import net.artelnatif.nicko.disguise.ActionResult;
import net.artelnatif.nicko.disguise.NickoProfile; import net.artelnatif.nicko.disguise.NickoProfile;
import net.artelnatif.nicko.mojang.MojangSkin; import net.artelnatif.nicko.mojang.MojangSkin;
import org.bukkit.Bukkit;
import net.minecraft.server.v1_15_R1.*; import net.minecraft.server.v1_15_R1.*;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld; import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.lang.reflect.InvocationTargetException;
public class v1_15_R1 implements Internals { public class v1_15_R1 implements Internals {
@Override @Override
@ -70,7 +72,7 @@ public class v1_15_R1 implements Internals {
final MojangSkin skin = skinFetch.getResult(); final MojangSkin skin = skinFetch.getResult();
final PropertyMap properties = gameProfile.getProperties(); final PropertyMap properties = gameProfile.getProperties();
properties.removeAll("textures"); 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); updateSelf(player);
} }
} }
@ -79,12 +81,14 @@ public class v1_15_R1 implements Internals {
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER); final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
final IChatBaseComponent name = new ChatComponentText(profileName); final IChatBaseComponent name = new ChatComponentText(profileName);
final PacketPlayOutPlayerInfo.PlayerInfoData data = remove.new PlayerInfoData(gameProfile, final Object infoData = yes(
add,
gameProfile,
entityPlayer.ping, entityPlayer.ping,
EnumGamemode.getById(player.getGameMode().ordinal()), name); EnumGamemode.getById(player.getGameMode().ordinal()),
final ArrayList<PacketPlayOutPlayerInfo.PlayerInfoData> list = new ArrayList<>(); name
list.add(data); );
spoofPlayerInfoPacket(add, list); spoofPlayerInfoPacket(add, Lists.newArrayList(infoData));
Bukkit.getOnlinePlayers().forEach(online -> { Bukkit.getOnlinePlayers().forEach(online -> {
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
@ -104,4 +108,22 @@ public class v1_15_R1 implements Internals {
NickoBukkit.getInstance().getLogger().warning("Unable to spoof packet, that's bad! (" + e.getMessage() + ")"); 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_15_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;
}
}
} }

View file

@ -1,5 +1,6 @@
package net.artelnatif.nicko.impl; package net.artelnatif.nicko.impl;
import com.google.common.collect.Lists;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap; import com.mojang.authlib.properties.PropertyMap;
@ -7,15 +8,16 @@ import net.artelnatif.nicko.bukkit.NickoBukkit;
import net.artelnatif.nicko.disguise.ActionResult; import net.artelnatif.nicko.disguise.ActionResult;
import net.artelnatif.nicko.disguise.NickoProfile; import net.artelnatif.nicko.disguise.NickoProfile;
import net.artelnatif.nicko.mojang.MojangSkin; import net.artelnatif.nicko.mojang.MojangSkin;
import org.bukkit.Bukkit;
import net.minecraft.server.v1_16_R1.*; import net.minecraft.server.v1_16_R1.*;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_16_R1.CraftWorld; import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.lang.reflect.InvocationTargetException;
public class v1_16_R1 implements Internals { public class v1_16_R1 implements Internals {
@Override @Override
@ -73,7 +75,7 @@ public class v1_16_R1 implements Internals {
final MojangSkin skin = skinFetch.getResult(); final MojangSkin skin = skinFetch.getResult();
final PropertyMap properties = gameProfile.getProperties(); final PropertyMap properties = gameProfile.getProperties();
properties.removeAll("textures"); 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); updateSelf(player);
} }
} }
@ -82,12 +84,14 @@ public class v1_16_R1 implements Internals {
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER); final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
final IChatBaseComponent name = new ChatComponentText(profileName); final IChatBaseComponent name = new ChatComponentText(profileName);
final PacketPlayOutPlayerInfo.PlayerInfoData data = remove.new PlayerInfoData(gameProfile, final Object infoData = yes(
add,
gameProfile,
entityPlayer.ping, entityPlayer.ping,
EnumGamemode.getById(player.getGameMode().ordinal()), name); EnumGamemode.getById(player.getGameMode().ordinal()),
final ArrayList<PacketPlayOutPlayerInfo.PlayerInfoData> list = new ArrayList<>(); name
list.add(data); );
spoofPlayerInfoPacket(add, list); spoofPlayerInfoPacket(add, Lists.newArrayList(infoData));
Bukkit.getOnlinePlayers().forEach(online -> { Bukkit.getOnlinePlayers().forEach(online -> {
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
@ -107,4 +111,22 @@ public class v1_16_R1 implements Internals {
NickoBukkit.getInstance().getLogger().warning("Unable to spoof packet, that's bad! (" + e.getMessage() + ")"); 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_16_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;
}
}
} }

View file

@ -1,5 +1,6 @@
package net.artelnatif.nicko.impl; package net.artelnatif.nicko.impl;
import com.google.common.collect.Lists;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap; import com.mojang.authlib.properties.PropertyMap;
@ -14,8 +15,9 @@ import org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.lang.reflect.InvocationTargetException;
public class v1_16_R2 implements Internals { public class v1_16_R2 implements Internals {
@Override @Override
@ -73,7 +75,7 @@ public class v1_16_R2 implements Internals {
final MojangSkin skin = skinFetch.getResult(); final MojangSkin skin = skinFetch.getResult();
final PropertyMap properties = gameProfile.getProperties(); final PropertyMap properties = gameProfile.getProperties();
properties.removeAll("textures"); 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); updateSelf(player);
} }
} }
@ -82,12 +84,14 @@ public class v1_16_R2 implements Internals {
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER); final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
final IChatBaseComponent name = new ChatComponentText(profileName); final IChatBaseComponent name = new ChatComponentText(profileName);
final PacketPlayOutPlayerInfo.PlayerInfoData data = remove.new PlayerInfoData(gameProfile, final Object infoData = yes(
add,
gameProfile,
entityPlayer.ping, entityPlayer.ping,
EnumGamemode.getById(player.getGameMode().ordinal()), name); EnumGamemode.getById(player.getGameMode().ordinal()),
final ArrayList<PacketPlayOutPlayerInfo.PlayerInfoData> list = new ArrayList<>(); name
list.add(data); );
spoofPlayerInfoPacket(add, list); spoofPlayerInfoPacket(add, Lists.newArrayList(infoData));
Bukkit.getOnlinePlayers().forEach(online -> { Bukkit.getOnlinePlayers().forEach(online -> {
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
@ -107,4 +111,22 @@ public class v1_16_R2 implements Internals {
NickoBukkit.getInstance().getLogger().warning("Unable to spoof packet, that's bad! (" + e.getMessage() + ")"); 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_16_R2.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;
}
}
} }

View file

@ -1,5 +1,6 @@
package net.artelnatif.nicko.impl; package net.artelnatif.nicko.impl;
import com.google.common.collect.Lists;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap; import com.mojang.authlib.properties.PropertyMap;
@ -14,8 +15,9 @@ import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.lang.reflect.InvocationTargetException;
public class v1_16_R3 implements Internals { public class v1_16_R3 implements Internals {
@Override @Override
@ -73,7 +75,7 @@ public class v1_16_R3 implements Internals {
final MojangSkin skin = skinFetch.getResult(); final MojangSkin skin = skinFetch.getResult();
final PropertyMap properties = gameProfile.getProperties(); final PropertyMap properties = gameProfile.getProperties();
properties.removeAll("textures"); 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); updateSelf(player);
} }
} }
@ -82,13 +84,18 @@ public class v1_16_R3 implements Internals {
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER); final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
final IChatBaseComponent name = new ChatComponentText(profileName); final IChatBaseComponent name = new ChatComponentText(profileName);
// what the fuck? didn't even KNOW instantiating a new class from an existing object was possible in java // ok so what the actual fuck
final PacketPlayOutPlayerInfo.PlayerInfoData data = remove.new PlayerInfoData(gameProfile, // the PlayerDataInfo inner class is NOT public
player.getPing(), // thus the compiler can't access it when compiling??????
EnumGamemode.getById(player.getGameMode().ordinal()), name); // i swear this is so dumb that i have to resort to doing this
final ArrayList<PacketPlayOutPlayerInfo.PlayerInfoData> list = new ArrayList<>(); final Object infoData = yes(
list.add(data); add,
spoofPlayerInfoPacket(add, list); gameProfile,
entityPlayer.ping,
EnumGamemode.getById(player.getGameMode().ordinal()),
name
);
spoofPlayerInfoPacket(add, Lists.newArrayList(infoData));
Bukkit.getOnlinePlayers().forEach(online -> { Bukkit.getOnlinePlayers().forEach(online -> {
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
@ -108,4 +115,22 @@ public class v1_16_R3 implements Internals {
NickoBukkit.getInstance().getLogger().warning("Unable to spoof packet, that's bad! (" + e.getMessage() + ")"); 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_16_R3.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;
}
}
} }

View file

@ -77,7 +77,7 @@ public class v1_17_R1 implements Internals {
final MojangSkin skin = skinFetch.getResult(); final MojangSkin skin = skinFetch.getResult();
final PropertyMap properties = gameProfile.getProperties(); final PropertyMap properties = gameProfile.getProperties();
properties.removeAll("textures"); 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); updateSelf(player);
} }
} }

View file

@ -79,7 +79,7 @@ public class v1_18_R1 implements Internals {
final MojangSkin skin = skinFetch.getResult(); final MojangSkin skin = skinFetch.getResult();
final PropertyMap properties = gameProfile.getProperties(); final PropertyMap properties = gameProfile.getProperties();
properties.removeAll("textures"); 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); updateSelf(player);
} }
} }

View file

@ -79,7 +79,7 @@ public class v1_18_R2 implements Internals {
final MojangSkin skin = skinFetch.getResult(); final MojangSkin skin = skinFetch.getResult();
final PropertyMap properties = gameProfile.getProperties(); final PropertyMap properties = gameProfile.getProperties();
properties.removeAll("textures"); 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); updateSelf(player);
} }
} }

View file

@ -79,7 +79,7 @@ public class v1_19_R1 implements Internals {
final MojangSkin skin = skinFetch.getResult(); final MojangSkin skin = skinFetch.getResult();
final PropertyMap properties = gameProfile.getProperties(); final PropertyMap properties = gameProfile.getProperties();
properties.removeAll("textures"); 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); updateSelf(player);
} }
} }

View file

@ -82,7 +82,7 @@ public class v1_19_R2 implements Internals {
final MojangSkin skin = skinFetch.getResult(); final MojangSkin skin = skinFetch.getResult();
final PropertyMap properties = gameProfile.getProperties(); final PropertyMap properties = gameProfile.getProperties();
properties.removeAll("textures"); 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); updateSelf(player);
} }
} }