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>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>net.artelnatif:*</artifact>
<excludes>
<exclude>META-INF/*.MF</exclude>
</excludes>
</filter>
</filters>
<relocations>
<relocation>
<pattern>net.wesjd.anvilgui</pattern>
@ -170,8 +162,6 @@
</dependency>
</dependencies>
<properties>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View file

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

View file

@ -13,7 +13,7 @@ public class BungeeCordSupport {
public void warnNickoNotHookedToBungeeCord() {
final Server server = instance.getServer();
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("that BungeeCord support is not enabled inside Nicko.");
instance.getLogger().warning("If this is intentional, you can safely ignore this message.");
@ -24,7 +24,7 @@ public class BungeeCordSupport {
public boolean stopIfBungeeCordIsNotEnabled() {
final Server server = instance.getServer();
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("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.");

View file

@ -87,7 +87,7 @@ public class NickoBukkit extends JavaPlugin {
mojangAPI = new MojangAPI(nicko);
localeFileManager = new LocaleFileManager();
if (nicko.getConfig().customLocale()) {
if (nicko.getConfig().isCustomLocale()) {
if (localeFileManager.dumpFromLocale(Locale.ENGLISH)) {
getLogger().info("Successfully loaded custom language file.");
} else {
@ -111,7 +111,7 @@ public class NickoBukkit extends JavaPlugin {
final BungeeCordSupport support = new BungeeCordSupport(this);
support.warnNickoNotHookedToBungeeCord();
if (nicko.getConfig().bungeecord()) {
if (nicko.getConfig().isBungeecord()) {
if (support.stopIfBungeeCordIsNotEnabled()) {
getLogger().info("Enabling BungeeCord support...");
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().unregisterOutgoingPluginChannel(this);
}

View file

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

View file

@ -28,7 +28,7 @@ public class NickoCheckSubCmd {
}
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()) {
builder.add("§cThis player has not data.");
} else {

View file

@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
public class NickoDebugSubCmd {
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;
String name, skin;

View file

@ -24,7 +24,7 @@ public class SettingsGUI {
};
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");
}

View file

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

View file

@ -29,9 +29,9 @@ public class I18N {
try {
formatter.applyPattern(translation);
return instance.getNicko().getConfig().prefix() + formatter.format(arguments);
return instance.getNicko().getConfig().getPrefix() + formatter.format(arguments);
} 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;
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 Admin {
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 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();
}
return switch (params) {
case "name" -> name;
case "skin" -> skin;
case "locale" -> locale;
case "bungeecord" -> String.valueOf(bungeecord);
default -> null;
};
switch (params) {
case "name": return name;
case "skin": return skin;
case "locale": return locale;
case "bungeecord": return String.valueOf(bungeecord);
default: return null;
}
}
}

View file

@ -1,14 +1,53 @@
package net.artelnatif.nicko.config;
public record Configuration(
String address,
String username,
String password,
String prefix,
Boolean local,
Boolean bungeecord,
Boolean customLocale) {
public class Configuration {
private final String address;
private final String username;
private final String password;
private final String prefix;
private final Boolean local;
private final Boolean bungeecord;
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() {
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_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
public Optional<MojangSkin> load(@Nonnull String uuid) throws Exception {
return getSkinFromMojang(uuid);
@ -77,15 +77,13 @@ public class MojangAPI {
con.setRequestMethod("GET");
switch (con.getResponseCode()) {
case 400 -> {
case 400:
nicko.getLogger().warning("Failed to parse request: Invalid Name");
return getErrorObject();
}
case 429 -> {
case 429:
nicko.getLogger().warning("Failed to parse request: The connection is throttled.");
return getErrorObject();
}
case 200 -> {
case 200:
final BufferedReader input = new BufferedReader(new InputStreamReader(con.getInputStream()));
final StringBuilder builder = new StringBuilder();
String line;
@ -100,13 +98,11 @@ public class MojangAPI {
nicko.getLogger().warning("Failed to parse request (" + parametrizedUrl + ")!");
return getErrorObject();
}
}
default -> {
default:
nicko.getLogger().warning("Unhandled response code from Mojang: " + con.getResponseCode());
return getErrorObject();
}
}
}
private JsonObject getErrorObject() {
final JsonObject errorObject = new JsonObject();

View file

@ -2,12 +2,27 @@ package net.artelnatif.nicko.mojang;
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) {
final String name = object.get("name").getAsString();
final JsonObject properties = object.get("properties").getAsJsonArray().get(0).getAsJsonObject();
final String value = properties.get("value").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) {
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) {

View file

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

View file

@ -25,9 +25,9 @@ public class SQLStorageProvider implements StorageProvider {
try {
final Configuration config = nicko.getConfig();
dataSource = new MariaDbDataSource();
dataSource.setUrl("jdbc:mariadb://" + config.address());
dataSource.setUser(config.username());
dataSource.setPassword(config.password());
dataSource.setUrl("jdbc:mariadb://" + config.getAddress());
dataSource.setUser(config.getUsername());
dataSource.setPassword(config.getPassword());
connection = dataSource.getConnection();
final boolean initialized = connection != null && !connection.isClosed();
@ -59,15 +59,8 @@ public class SQLStorageProvider implements StorageProvider {
private void createTable() {
final Connection connection = getConnection();
final 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)
)
""".formatted(schemaName);
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))";
query = query.replace("%s", schemaName);
try {
final PreparedStatement statement = connection.prepareStatement(query);
@ -82,9 +75,8 @@ public class SQLStorageProvider implements StorageProvider {
private void createDatabase() {
final Connection connection = getConnection();
final String query = """
CREATE DATABASE IF NOT EXISTS %s
""".formatted(schemaName);
String query = "CREATE DATABASE IF NOT EXISTS %s";
query = query.replace("%s", schemaName);
try {
final PreparedStatement statement = connection.prepareStatement(query);

View file

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

View file

@ -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;
}
}
}

View file

@ -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_R2.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_R2 implements Internals {
@Override
@ -69,7 +71,7 @@ public class v1_13_R2 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_R2 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_R2 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_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;
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_14_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_14_R1 implements Internals {
@Override
@ -67,7 +69,7 @@ public class v1_14_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);
}
}
@ -76,12 +78,14 @@ public class v1_14_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();
@ -101,4 +105,22 @@ public class v1_14_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_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;
import com.google.common.collect.Lists;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
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.NickoProfile;
import net.artelnatif.nicko.mojang.MojangSkin;
import org.bukkit.Bukkit;
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.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_15_R1 implements Internals {
@Override
@ -70,7 +72,7 @@ public class v1_15_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);
}
}
@ -79,12 +81,14 @@ public class v1_15_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();
@ -104,4 +108,22 @@ public class v1_15_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_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;
import com.google.common.collect.Lists;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
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.NickoProfile;
import net.artelnatif.nicko.mojang.MojangSkin;
import org.bukkit.Bukkit;
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.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_16_R1 implements Internals {
@Override
@ -73,7 +75,7 @@ public class v1_16_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);
}
}
@ -82,12 +84,14 @@ public class v1_16_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();
@ -107,4 +111,22 @@ public class v1_16_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_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;
import com.google.common.collect.Lists;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
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.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_16_R2 implements Internals {
@Override
@ -73,7 +75,7 @@ public class v1_16_R2 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);
}
}
@ -82,12 +84,14 @@ public class v1_16_R2 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();
@ -107,4 +111,22 @@ public class v1_16_R2 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_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;
import com.google.common.collect.Lists;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
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.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_16_R3 implements Internals {
@Override
@ -73,7 +75,7 @@ public class v1_16_R3 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);
}
}
@ -82,13 +84,18 @@ public class v1_16_R3 implements Internals {
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
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
final PacketPlayOutPlayerInfo.PlayerInfoData data = remove.new PlayerInfoData(gameProfile,
player.getPing(),
EnumGamemode.getById(player.getGameMode().ordinal()), name);
final ArrayList<PacketPlayOutPlayerInfo.PlayerInfoData> list = new ArrayList<>();
list.add(data);
spoofPlayerInfoPacket(add, list);
// ok so what the actual fuck
// the PlayerDataInfo inner class is NOT public
// thus the compiler can't access it when compiling??????
// i swear this is so dumb that i have to resort to doing this
final Object infoData = yes(
add,
gameProfile,
entityPlayer.ping,
EnumGamemode.getById(player.getGameMode().ordinal()),
name
);
spoofPlayerInfoPacket(add, Lists.newArrayList(infoData));
Bukkit.getOnlinePlayers().forEach(online -> {
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() + ")");
}
}
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 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);
}
}

View file

@ -79,7 +79,7 @@ public class v1_18_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);
}
}

View file

@ -79,7 +79,7 @@ public class v1_18_R2 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);
}
}

View file

@ -79,7 +79,7 @@ public class v1_19_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);
}
}

View file

@ -82,7 +82,7 @@ public class v1_19_R2 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);
}
}