feat: remove NMS dependency
This commit is contained in:
parent
d37a0bd3ba
commit
35e2db02e9
35 changed files with 127 additions and 2139 deletions
14
core/pom.xml
14
core/pom.xml
|
@ -18,6 +18,10 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>dmulloy2-repo</id>
|
||||||
|
<url>https://repo.dmulloy2.net/repository/public/</url>
|
||||||
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>papermc</id>
|
<id>papermc</id>
|
||||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||||
|
@ -37,6 +41,12 @@
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.comphenix.protocol</groupId>
|
||||||
|
<artifactId>ProtocolLib</artifactId>
|
||||||
|
<version>5.0.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<!-- PlaceHolder API -->
|
<!-- PlaceHolder API -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.clip</groupId>
|
<groupId>me.clip</groupId>
|
||||||
|
@ -92,12 +102,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-core</artifactId>
|
<artifactId>jackson-core</artifactId>
|
||||||
<version>2.14.2</version>
|
<version>2.13.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||||
<artifactId>jackson-dataformat-yaml</artifactId>
|
<artifactId>jackson-dataformat-yaml</artifactId>
|
||||||
<version>2.14.2</version>
|
<version>2.13.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Redis -->
|
<!-- Redis -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -1,19 +1,16 @@
|
||||||
package net.artelnatif.nicko;
|
package net.artelnatif.nicko;
|
||||||
|
|
||||||
import net.artelnatif.nicko.gui.items.common.OptionUnavailable;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import xyz.xenondevs.invui.gui.structure.Structure;
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
|
||||||
import xyz.xenondevs.invui.item.impl.SimpleItem;
|
|
||||||
import net.artelnatif.nicko.command.NickoCommand;
|
import net.artelnatif.nicko.command.NickoCommand;
|
||||||
import net.artelnatif.nicko.config.Configuration;
|
import net.artelnatif.nicko.config.Configuration;
|
||||||
import net.artelnatif.nicko.config.ConfigurationManager;
|
import net.artelnatif.nicko.config.ConfigurationManager;
|
||||||
import net.artelnatif.nicko.event.PlayerJoinListener;
|
import net.artelnatif.nicko.event.PlayerJoinListener;
|
||||||
import net.artelnatif.nicko.event.PlayerQuitListener;
|
import net.artelnatif.nicko.event.PlayerQuitListener;
|
||||||
|
import net.artelnatif.nicko.gui.items.common.OptionUnavailable;
|
||||||
import net.artelnatif.nicko.gui.items.main.ExitGUI;
|
import net.artelnatif.nicko.gui.items.main.ExitGUI;
|
||||||
import net.artelnatif.nicko.i18n.Locale;
|
import net.artelnatif.nicko.i18n.Locale;
|
||||||
import net.artelnatif.nicko.i18n.LocaleFileManager;
|
import net.artelnatif.nicko.i18n.LocaleFileManager;
|
||||||
import net.artelnatif.nicko.impl.Internals;
|
|
||||||
import net.artelnatif.nicko.impl.InternalsProvider;
|
|
||||||
import net.artelnatif.nicko.mojang.MojangAPI;
|
import net.artelnatif.nicko.mojang.MojangAPI;
|
||||||
import net.artelnatif.nicko.placeholder.PlaceHolderHook;
|
import net.artelnatif.nicko.placeholder.PlaceHolderHook;
|
||||||
import net.artelnatif.nicko.storage.PlayerDataStore;
|
import net.artelnatif.nicko.storage.PlayerDataStore;
|
||||||
|
@ -24,6 +21,9 @@ import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||||
|
import xyz.xenondevs.invui.gui.structure.Structure;
|
||||||
|
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
||||||
|
import xyz.xenondevs.invui.item.impl.SimpleItem;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -39,6 +39,7 @@ public class NickoBukkit extends JavaPlugin {
|
||||||
private Configuration configuration;
|
private Configuration configuration;
|
||||||
private LocaleFileManager localeFileManager;
|
private LocaleFileManager localeFileManager;
|
||||||
private PlayerNameStore nameStore;
|
private PlayerNameStore nameStore;
|
||||||
|
private ProtocolManager protocolManager;
|
||||||
|
|
||||||
public NickoBukkit() { this.unitTesting = false; }
|
public NickoBukkit() { this.unitTesting = false; }
|
||||||
|
|
||||||
|
@ -65,6 +66,7 @@ public class NickoBukkit extends JavaPlugin {
|
||||||
configurationManager = new ConfigurationManager(getDataFolder());
|
configurationManager = new ConfigurationManager(getDataFolder());
|
||||||
configurationManager.saveDefaultConfig();
|
configurationManager.saveDefaultConfig();
|
||||||
|
|
||||||
|
protocolManager = ProtocolLibrary.getProtocolManager();
|
||||||
mojangAPI = new MojangAPI();
|
mojangAPI = new MojangAPI();
|
||||||
dataStore = new PlayerDataStore(mojangAPI, getNickoConfig());
|
dataStore = new PlayerDataStore(mojangAPI, getNickoConfig());
|
||||||
nameStore = new PlayerNameStore();
|
nameStore = new PlayerNameStore();
|
||||||
|
@ -78,14 +80,6 @@ public class NickoBukkit extends JavaPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!unitTesting) {
|
if (!unitTesting) {
|
||||||
getLogger().info("Loading internals...");
|
|
||||||
if (getInternals() == null) {
|
|
||||||
getLogger().severe("Nicko could not find a valid implementation for this server version. Is your server supported?");
|
|
||||||
dataStore.getStorage().setError(true);
|
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
localeFileManager = new LocaleFileManager();
|
localeFileManager = new LocaleFileManager();
|
||||||
if (configuration.isCustomLocale()) {
|
if (configuration.isCustomLocale()) {
|
||||||
if (localeFileManager.dumpFromLocale(Locale.ENGLISH)) {
|
if (localeFileManager.dumpFromLocale(Locale.ENGLISH)) {
|
||||||
|
@ -161,7 +155,5 @@ public class NickoBukkit extends JavaPlugin {
|
||||||
return localeFileManager;
|
return localeFileManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Internals getInternals() {
|
public ProtocolManager getProtocolManager() { return protocolManager; }
|
||||||
return InternalsProvider.getInternals();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,27 @@
|
||||||
package net.artelnatif.nicko.appearance;
|
package net.artelnatif.nicko.appearance;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.wrappers.*;
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
import net.artelnatif.nicko.NickoBukkit;
|
import net.artelnatif.nicko.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.i18n.I18NDict;
|
||||||
|
import net.artelnatif.nicko.mojang.MojangAPI;
|
||||||
|
import net.artelnatif.nicko.mojang.MojangSkin;
|
||||||
import net.artelnatif.nicko.storage.PlayerDataStore;
|
import net.artelnatif.nicko.storage.PlayerDataStore;
|
||||||
import net.artelnatif.nicko.storage.name.PlayerNameStore;
|
import net.artelnatif.nicko.storage.name.PlayerNameStore;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
public class AppearanceManager {
|
public class AppearanceManager {
|
||||||
private final NickoProfile profile;
|
private final NickoProfile profile;
|
||||||
|
@ -80,10 +93,93 @@ public class AppearanceManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult<Void> resetPlayer() {
|
public ActionResult<Void> resetPlayer() {
|
||||||
return NickoBukkit.getInstance().getInternals().updateProfile(player, profile, true, true);
|
// TODO: 4/3/23 Reset player
|
||||||
|
return new ActionResult<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult<Void> updatePlayer(boolean skinChange) {
|
public ActionResult<Void> updatePlayer(boolean skinChange) {
|
||||||
return NickoBukkit.getInstance().getInternals().updateProfile(player, profile, skinChange, false);
|
final String displayName = profile.getName() == null ? player.getName() : profile.getName();
|
||||||
|
final WrappedGameProfile gameProfile = new WrappedGameProfile(player.getUniqueId(), displayName);
|
||||||
|
|
||||||
|
final ActionResult<Void> result = updateGameProfileSkin(gameProfile, skinChange);
|
||||||
|
if (!result.isError()) {
|
||||||
|
updateTabList(gameProfile, displayName);
|
||||||
|
}
|
||||||
|
return new ActionResult<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ActionResult<Void> updateGameProfileSkin(WrappedGameProfile gameProfile, boolean skinChange) {
|
||||||
|
final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName());
|
||||||
|
|
||||||
|
if (skinChange || changeOnlyName) {
|
||||||
|
Optional<MojangSkin> skin;
|
||||||
|
try {
|
||||||
|
final MojangAPI mojang = NickoBukkit.getInstance().getMojangAPI();
|
||||||
|
final Optional<String> uuid = mojang.getUUID(profile.getSkin());
|
||||||
|
if (uuid.isPresent()) {
|
||||||
|
skin = mojang.getSkin(uuid.get());
|
||||||
|
if (skin.isPresent()) {
|
||||||
|
final MojangSkin skinResult = skin.get();
|
||||||
|
final Multimap<String, WrappedSignedProperty> properties = gameProfile.getProperties();
|
||||||
|
properties.removeAll("textures");
|
||||||
|
properties.put("textures", new WrappedSignedProperty("textures", skinResult.getValue(), skinResult.getSignature()));
|
||||||
|
Bukkit.broadcastMessage("Modified properties");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Bukkit.broadcastMessage("Respawning player");
|
||||||
|
respawnPlayer();
|
||||||
|
return new ActionResult<>();
|
||||||
|
} catch (ExecutionException e) {
|
||||||
|
return new ActionResult<>(I18NDict.Error.SKIN_FAIL_CACHE);
|
||||||
|
} catch (IOException e) {
|
||||||
|
return new ActionResult<>(I18NDict.Error.NAME_FAIL_MOJANG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ActionResult<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void respawnPlayer() {
|
||||||
|
final PacketContainer respawnOtherWorld = getRespawnPacket(Bukkit.getWorld("world_the_end"));
|
||||||
|
final PacketContainer respawn = getRespawnPacket(player.getWorld());
|
||||||
|
instance.getProtocolManager().sendServerPacket(player, respawnOtherWorld);
|
||||||
|
instance.getProtocolManager().sendServerPacket(player, respawn);
|
||||||
|
}
|
||||||
|
|
||||||
|
private PacketContainer getRespawnPacket(World world) {
|
||||||
|
final PacketContainer packet = new PacketContainer(PacketType.Play.Server.RESPAWN);
|
||||||
|
final EnumWrappers.NativeGameMode gamemode = EnumWrappers.NativeGameMode.fromBukkit(player.getGameMode());
|
||||||
|
packet.getWorldKeys().write(0, world);
|
||||||
|
packet.getLongs().write(0, world.getSeed());
|
||||||
|
|
||||||
|
packet.getGameModes().write(0, gamemode); // gamemode
|
||||||
|
packet.getGameModes().write(1, gamemode); // previous gamemode
|
||||||
|
|
||||||
|
packet.getBooleans().write(0, false);
|
||||||
|
packet.getBooleans().write(1, false);
|
||||||
|
return packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateTabList(WrappedGameProfile gameProfile, String displayName) {
|
||||||
|
final PacketContainer infoAdd = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
||||||
|
infoAdd.getPlayerInfoActions().write(0, Set.of(
|
||||||
|
EnumWrappers.PlayerInfoAction.ADD_PLAYER,
|
||||||
|
EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE,
|
||||||
|
EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME,
|
||||||
|
EnumWrappers.PlayerInfoAction.UPDATE_LISTED,
|
||||||
|
EnumWrappers.PlayerInfoAction.UPDATE_LATENCY
|
||||||
|
));
|
||||||
|
|
||||||
|
infoAdd.getPlayerInfoDataLists().write(1, List.of(new PlayerInfoData(
|
||||||
|
gameProfile,
|
||||||
|
0,
|
||||||
|
EnumWrappers.NativeGameMode.fromBukkit(player.getGameMode()),
|
||||||
|
WrappedChatComponent.fromText(displayName)
|
||||||
|
)));
|
||||||
|
|
||||||
|
final PacketContainer infoRemove = new PacketContainer(PacketType.Play.Server.PLAYER_INFO_REMOVE);
|
||||||
|
infoRemove.getUUIDLists().write(0, List.of(player.getUniqueId()));
|
||||||
|
|
||||||
|
instance.getProtocolManager().broadcastServerPacket(infoRemove);
|
||||||
|
instance.getProtocolManager().broadcastServerPacket(infoAdd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class PlayerJoinListener implements Listener {
|
||||||
if (!actionResult.isError()) {
|
if (!actionResult.isError()) {
|
||||||
player.sendMessage(I18N.translate(player, I18NDict.Event.PreviousSkin.SUCCESS));
|
player.sendMessage(I18N.translate(player, I18NDict.Event.PreviousSkin.SUCCESS));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(I18N.translate(player, I18NDict.Event.PreviousSkin.FAIL, I18N.translate(player, actionResult.getErrorMessage())));
|
player.sendMessage(I18N.translate(player, I18NDict.Event.PreviousSkin.FAIL, I18N.translateWithoutPrefix(player, actionResult.getErrorMessage())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 20L);
|
}, 20L);
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
package net.artelnatif.nicko.impl;
|
|
||||||
|
|
||||||
import net.artelnatif.nicko.NickoBukkit;
|
|
||||||
import net.artelnatif.nicko.disguise.NickoProfile;
|
|
||||||
import net.artelnatif.nicko.disguise.ActionResult;
|
|
||||||
import net.artelnatif.nicko.i18n.I18NDict;
|
|
||||||
import net.artelnatif.nicko.mojang.MojangAPI;
|
|
||||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
public interface Internals {
|
|
||||||
void updateSelf(Player player);
|
|
||||||
|
|
||||||
void updateOthers(Player player);
|
|
||||||
|
|
||||||
ActionResult<Void> updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset);
|
|
||||||
|
|
||||||
default ActionResult<MojangSkin> fetchSkinTextures(NickoProfile profile, boolean reset) {
|
|
||||||
Optional<MojangSkin> skin;
|
|
||||||
try {
|
|
||||||
final MojangAPI mojang = NickoBukkit.getInstance().getMojangAPI();
|
|
||||||
final Optional<String> uuid = mojang.getUUID(profile.getSkin());
|
|
||||||
if (uuid.isPresent()) {
|
|
||||||
skin = (reset ? mojang.getSkinWithoutCaching(uuid.get()) : mojang.getSkin(uuid.get()));
|
|
||||||
return skin.map(ActionResult::new).orElseGet(() -> new ActionResult<>(I18NDict.Error.SKIN_FAIL_MOJANG));
|
|
||||||
}
|
|
||||||
return new ActionResult<>(I18NDict.Error.NAME_FAIL_MOJANG);
|
|
||||||
} catch (ExecutionException e) {
|
|
||||||
return new ActionResult<>(I18NDict.Error.SKIN_FAIL_CACHE);
|
|
||||||
} catch (IOException e) {
|
|
||||||
return new ActionResult<>(I18NDict.Error.NAME_FAIL_MOJANG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
package net.artelnatif.nicko.impl;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
public class InternalsProvider {
|
|
||||||
private static final Logger logger = Logger.getLogger("Internals");
|
|
||||||
private static Internals internals;
|
|
||||||
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
final String packageName = Internals.class.getPackage().getName();
|
|
||||||
final String bukkitVersion = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
|
||||||
final String fullClassName = packageName + "." + bukkitVersion;
|
|
||||||
final Class<?> clazz = Class.forName(fullClassName);
|
|
||||||
internals = (Internals) clazz.getConstructors()[0].newInstance();
|
|
||||||
logger.info("Loaded support for " + bukkitVersion);
|
|
||||||
} catch (InvocationTargetException | ClassNotFoundException | InstantiationException | IllegalAccessException |
|
|
||||||
ClassCastException exception) {
|
|
||||||
internals = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Internals getInternals() {
|
|
||||||
return internals;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -25,7 +25,7 @@ public class MojangAPI {
|
||||||
|
|
||||||
private final Logger logger = Logger.getLogger("MojangAPI");
|
private final Logger logger = Logger.getLogger("MojangAPI");
|
||||||
|
|
||||||
private final CacheLoader<String, Optional<MojangSkin>> loader = new CacheLoader<String, Optional<MojangSkin>>() {
|
private final CacheLoader<String, Optional<MojangSkin>> loader = new CacheLoader<>() {
|
||||||
@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);
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
name: Nicko
|
name: Nicko
|
||||||
main: net.artelnatif.nicko.NickoBukkit
|
main: net.artelnatif.nicko.NickoBukkit
|
||||||
version: 1.0-SNAPSHOT
|
version: 1.0-SNAPSHOT
|
||||||
author: Aro
|
author: Ineanto
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
softdepend: [ PlaceholderAPI ]
|
softdepend: [ PlaceholderAPI ]
|
||||||
|
depend: [ ProtocolLib ]
|
||||||
commands:
|
commands:
|
||||||
nicko:
|
nicko:
|
||||||
description: "Opens Nicko's GUI."
|
description: "Opens Nicko's GUI."
|
||||||
|
|
8
pom.xml
8
pom.xml
|
@ -13,7 +13,7 @@
|
||||||
<modules>
|
<modules>
|
||||||
<module>core</module>
|
<module>core</module>
|
||||||
<module>dist</module>
|
<module>dist</module>
|
||||||
<module>v1_13_R1</module>
|
<!--<module>v1_13_R1</module>
|
||||||
<module>v1_13_R2</module>
|
<module>v1_13_R2</module>
|
||||||
<module>v1_14_R1</module>
|
<module>v1_14_R1</module>
|
||||||
<module>v1_15_R1</module>
|
<module>v1_15_R1</module>
|
||||||
|
@ -25,11 +25,11 @@
|
||||||
<module>v1_18_R2</module>
|
<module>v1_18_R2</module>
|
||||||
<module>v1_19_R1</module>
|
<module>v1_19_R1</module>
|
||||||
<module>v1_19_R2</module>
|
<module>v1_19_R2</module>
|
||||||
<module>v1_19_R3</module>
|
<module>v1_19_R3</module>-->
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
<maven.compiler.target>11</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
|
@ -1,28 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>nicko-parent</artifactId>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>v1_13_R1</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<version>1.13-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<artifactId>core</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
|
@ -1,128 +0,0 @@
|
||||||
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;
|
|
||||||
import net.artelnatif.nicko.NickoBukkit;
|
|
||||||
import net.artelnatif.nicko.disguise.ActionResult;
|
|
||||||
import net.artelnatif.nicko.disguise.NickoProfile;
|
|
||||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
|
||||||
import net.minecraft.server.v1_13_R1.*;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
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.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
public class v1_13_R1 implements Internals {
|
|
||||||
@Override
|
|
||||||
public void updateSelf(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final WorldServer worldServer = entityPlayer.getWorldServer();
|
|
||||||
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(worldServer.dimension,
|
|
||||||
worldServer.getDifficulty(),
|
|
||||||
worldServer.worldData.getType(),
|
|
||||||
entityPlayer.playerInteractManager.getGameMode());
|
|
||||||
|
|
||||||
final boolean wasFlying = player.isFlying();
|
|
||||||
entityPlayer.playerConnection.sendPacket(respawn);
|
|
||||||
player.setFlying(wasFlying);
|
|
||||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
|
||||||
player.updateInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateOthers(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId());
|
|
||||||
final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer);
|
|
||||||
|
|
||||||
final DataWatcher dataWatcher = entityPlayer.getDataWatcher();
|
|
||||||
final DataWatcherObject<Byte> displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a);
|
|
||||||
dataWatcher.set(displayedSkinPartDataWatcher, (byte) 0x7f);
|
|
||||||
final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true);
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
|
||||||
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(destroy);
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(spawn);
|
|
||||||
}
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(entityMetadata);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResult<Void> updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) {
|
|
||||||
final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName());
|
|
||||||
final String profileName = profile.getName() == null ? player.getName() : profile.getName();
|
|
||||||
|
|
||||||
final CraftPlayer craftPlayer = (CraftPlayer) player;
|
|
||||||
final EntityPlayer entityPlayer = craftPlayer.getHandle();
|
|
||||||
final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName);
|
|
||||||
|
|
||||||
if (skinChange || changeOnlyName) {
|
|
||||||
final ActionResult<MojangSkin> skinFetch = fetchSkinTextures(profile, reset);
|
|
||||||
if (!skinFetch.isError()) {
|
|
||||||
final MojangSkin skin = skinFetch.getResult();
|
|
||||||
final PropertyMap properties = gameProfile.getProperties();
|
|
||||||
properties.removeAll("textures");
|
|
||||||
properties.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
|
||||||
updateSelf(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityPlayer);
|
|
||||||
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
|
|
||||||
final IChatBaseComponent name = new ChatComponentText(profileName);
|
|
||||||
|
|
||||||
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();
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(remove);
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(add);
|
|
||||||
});
|
|
||||||
updateOthers(player);
|
|
||||||
return new ActionResult<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void spoofPlayerInfoPacket(Object object, Object newValue) {
|
|
||||||
try {
|
|
||||||
final Field field = object.getClass().getDeclaredField("b");
|
|
||||||
field.setAccessible(true);
|
|
||||||
field.set(object, newValue);
|
|
||||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>nicko-parent</artifactId>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>v1_13_R2</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<artifactId>core</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
|
@ -1,128 +0,0 @@
|
||||||
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;
|
|
||||||
import net.artelnatif.nicko.NickoBukkit;
|
|
||||||
import net.artelnatif.nicko.disguise.ActionResult;
|
|
||||||
import net.artelnatif.nicko.disguise.NickoProfile;
|
|
||||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
|
||||||
import net.minecraft.server.v1_13_R2.*;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
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.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
public class v1_13_R2 implements Internals {
|
|
||||||
@Override
|
|
||||||
public void updateSelf(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final WorldServer worldServer = entityPlayer.getWorldServer();
|
|
||||||
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(worldServer.dimension,
|
|
||||||
worldServer.getDifficulty(),
|
|
||||||
worldServer.S(),
|
|
||||||
entityPlayer.playerInteractManager.getGameMode());
|
|
||||||
|
|
||||||
final boolean wasFlying = player.isFlying();
|
|
||||||
entityPlayer.playerConnection.sendPacket(respawn);
|
|
||||||
player.setFlying(wasFlying);
|
|
||||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
|
||||||
player.updateInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateOthers(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId());
|
|
||||||
final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer);
|
|
||||||
|
|
||||||
final DataWatcher dataWatcher = entityPlayer.getDataWatcher();
|
|
||||||
final DataWatcherObject<Byte> displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a);
|
|
||||||
dataWatcher.set(displayedSkinPartDataWatcher, (byte) 0x7f);
|
|
||||||
final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true);
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
|
||||||
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(destroy);
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(spawn);
|
|
||||||
}
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(entityMetadata);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResult<Void> updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) {
|
|
||||||
final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName());
|
|
||||||
final String profileName = profile.getName() == null ? player.getName() : profile.getName();
|
|
||||||
|
|
||||||
final CraftPlayer craftPlayer = (CraftPlayer) player;
|
|
||||||
final EntityPlayer entityPlayer = craftPlayer.getHandle();
|
|
||||||
final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName);
|
|
||||||
|
|
||||||
if (skinChange || changeOnlyName) {
|
|
||||||
final ActionResult<MojangSkin> skinFetch = fetchSkinTextures(profile, reset);
|
|
||||||
if (!skinFetch.isError()) {
|
|
||||||
final MojangSkin skin = skinFetch.getResult();
|
|
||||||
final PropertyMap properties = gameProfile.getProperties();
|
|
||||||
properties.removeAll("textures");
|
|
||||||
properties.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
|
||||||
updateSelf(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityPlayer);
|
|
||||||
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
|
|
||||||
final IChatBaseComponent name = new ChatComponentText(profileName);
|
|
||||||
|
|
||||||
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();
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(remove);
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(add);
|
|
||||||
});
|
|
||||||
updateOthers(player);
|
|
||||||
return new ActionResult<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void spoofPlayerInfoPacket(Object object, Object newValue) {
|
|
||||||
try {
|
|
||||||
final Field field = object.getClass().getDeclaredField("b");
|
|
||||||
field.setAccessible(true);
|
|
||||||
field.set(object, newValue);
|
|
||||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>nicko-parent</artifactId>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>v1_14_R1</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<version>1.14.4-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<artifactId>core</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
|
@ -1,126 +0,0 @@
|
||||||
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;
|
|
||||||
import net.artelnatif.nicko.NickoBukkit;
|
|
||||||
import net.artelnatif.nicko.disguise.ActionResult;
|
|
||||||
import net.artelnatif.nicko.disguise.NickoProfile;
|
|
||||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
|
||||||
import net.minecraft.server.v1_14_R1.*;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
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.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
public class v1_14_R1 implements Internals {
|
|
||||||
@Override
|
|
||||||
public void updateSelf(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorldServer().getWorldProvider().getDimensionManager(),
|
|
||||||
entityPlayer.getWorld().P(),
|
|
||||||
entityPlayer.playerInteractManager.getGameMode());
|
|
||||||
|
|
||||||
final boolean wasFlying = player.isFlying();
|
|
||||||
entityPlayer.playerConnection.sendPacket(respawn);
|
|
||||||
player.setFlying(wasFlying);
|
|
||||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
|
||||||
player.updateInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateOthers(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId());
|
|
||||||
final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer);
|
|
||||||
|
|
||||||
final DataWatcher dataWatcher = entityPlayer.getDataWatcher();
|
|
||||||
final DataWatcherObject<Byte> displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a);
|
|
||||||
dataWatcher.set(displayedSkinPartDataWatcher, (byte) 0x7f);
|
|
||||||
final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true);
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
|
||||||
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(destroy);
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(spawn);
|
|
||||||
}
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(entityMetadata);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResult<Void> updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) {
|
|
||||||
final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName());
|
|
||||||
final String profileName = profile.getName() == null ? player.getName() : profile.getName();
|
|
||||||
|
|
||||||
final CraftPlayer craftPlayer = (CraftPlayer) player;
|
|
||||||
final EntityPlayer entityPlayer = craftPlayer.getHandle();
|
|
||||||
final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName);
|
|
||||||
|
|
||||||
if (skinChange || changeOnlyName) {
|
|
||||||
final ActionResult<MojangSkin> skinFetch = fetchSkinTextures(profile, reset);
|
|
||||||
if (!skinFetch.isError()) {
|
|
||||||
final MojangSkin skin = skinFetch.getResult();
|
|
||||||
final PropertyMap properties = gameProfile.getProperties();
|
|
||||||
properties.removeAll("textures");
|
|
||||||
properties.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
|
||||||
updateSelf(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityPlayer);
|
|
||||||
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
|
|
||||||
final IChatBaseComponent name = new ChatComponentText(profileName);
|
|
||||||
|
|
||||||
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();
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(remove);
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(add);
|
|
||||||
});
|
|
||||||
updateOthers(player);
|
|
||||||
return new ActionResult<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void spoofPlayerInfoPacket(Object object, Object newValue) {
|
|
||||||
try {
|
|
||||||
final Field field = object.getClass().getDeclaredField("b");
|
|
||||||
field.setAccessible(true);
|
|
||||||
field.set(object, newValue);
|
|
||||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>nicko-parent</artifactId>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>v1_15_R1</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<artifactId>core</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
|
@ -1,129 +0,0 @@
|
||||||
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;
|
|
||||||
import net.artelnatif.nicko.NickoBukkit;
|
|
||||||
import net.artelnatif.nicko.disguise.ActionResult;
|
|
||||||
import net.artelnatif.nicko.disguise.NickoProfile;
|
|
||||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
|
||||||
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.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
public class v1_15_R1 implements Internals {
|
|
||||||
@Override
|
|
||||||
public void updateSelf(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final CraftWorld world = entityPlayer.getWorld().getWorld();
|
|
||||||
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorldServer().getWorldProvider().getDimensionManager(),
|
|
||||||
world.getSeed(),
|
|
||||||
entityPlayer.getWorld().P(),
|
|
||||||
entityPlayer.playerInteractManager.getGameMode());
|
|
||||||
|
|
||||||
final boolean wasFlying = player.isFlying();
|
|
||||||
entityPlayer.playerConnection.sendPacket(respawn);
|
|
||||||
player.setFlying(wasFlying);
|
|
||||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
|
||||||
player.updateInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateOthers(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId());
|
|
||||||
final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer);
|
|
||||||
|
|
||||||
final DataWatcher dataWatcher = entityPlayer.getDataWatcher();
|
|
||||||
final DataWatcherObject<Byte> displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a);
|
|
||||||
dataWatcher.set(displayedSkinPartDataWatcher, (byte) 0x7f);
|
|
||||||
final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true);
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
|
||||||
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(destroy);
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(spawn);
|
|
||||||
}
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(entityMetadata);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResult<Void> updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) {
|
|
||||||
final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName());
|
|
||||||
final String profileName = profile.getName() == null ? player.getName() : profile.getName();
|
|
||||||
|
|
||||||
final CraftPlayer craftPlayer = (CraftPlayer) player;
|
|
||||||
final EntityPlayer entityPlayer = craftPlayer.getHandle();
|
|
||||||
final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName);
|
|
||||||
|
|
||||||
if (skinChange || changeOnlyName) {
|
|
||||||
final ActionResult<MojangSkin> skinFetch = fetchSkinTextures(profile, reset);
|
|
||||||
if (!skinFetch.isError()) {
|
|
||||||
final MojangSkin skin = skinFetch.getResult();
|
|
||||||
final PropertyMap properties = gameProfile.getProperties();
|
|
||||||
properties.removeAll("textures");
|
|
||||||
properties.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
|
||||||
updateSelf(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityPlayer);
|
|
||||||
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
|
|
||||||
final IChatBaseComponent name = new ChatComponentText(profileName);
|
|
||||||
|
|
||||||
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();
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(remove);
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(add);
|
|
||||||
});
|
|
||||||
updateOthers(player);
|
|
||||||
return new ActionResult<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void spoofPlayerInfoPacket(Object object, Object newValue) {
|
|
||||||
try {
|
|
||||||
final Field field = object.getClass().getDeclaredField("b");
|
|
||||||
field.setAccessible(true);
|
|
||||||
field.set(object, newValue);
|
|
||||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>nicko-parent</artifactId>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>v1_16_R1</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<artifactId>core</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
|
@ -1,132 +0,0 @@
|
||||||
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;
|
|
||||||
import net.artelnatif.nicko.NickoBukkit;
|
|
||||||
import net.artelnatif.nicko.disguise.ActionResult;
|
|
||||||
import net.artelnatif.nicko.disguise.NickoProfile;
|
|
||||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
|
||||||
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.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
public class v1_16_R1 implements Internals {
|
|
||||||
@Override
|
|
||||||
public void updateSelf(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final ResourceKey<World> levelResourceKey = entityPlayer.getWorld().getDimensionKey();
|
|
||||||
final CraftWorld world = entityPlayer.getWorld().getWorld();
|
|
||||||
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorld().getTypeKey(),
|
|
||||||
levelResourceKey, world.getSeed(),
|
|
||||||
entityPlayer.playerInteractManager.c(), entityPlayer.playerInteractManager.getGameMode(),
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false);
|
|
||||||
|
|
||||||
final boolean wasFlying = player.isFlying();
|
|
||||||
entityPlayer.playerConnection.sendPacket(respawn);
|
|
||||||
player.setFlying(wasFlying);
|
|
||||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
|
||||||
player.updateInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateOthers(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId());
|
|
||||||
final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer);
|
|
||||||
|
|
||||||
final DataWatcher dataWatcher = entityPlayer.getDataWatcher();
|
|
||||||
final DataWatcherObject<Byte> displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a);
|
|
||||||
dataWatcher.set(displayedSkinPartDataWatcher, (byte) 0x7f);
|
|
||||||
final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true);
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
|
||||||
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(destroy);
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(spawn);
|
|
||||||
}
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(entityMetadata);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResult<Void> updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) {
|
|
||||||
final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName());
|
|
||||||
final String profileName = profile.getName() == null ? player.getName() : profile.getName();
|
|
||||||
|
|
||||||
final CraftPlayer craftPlayer = (CraftPlayer) player;
|
|
||||||
final EntityPlayer entityPlayer = craftPlayer.getHandle();
|
|
||||||
final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName);
|
|
||||||
|
|
||||||
if (skinChange || changeOnlyName) {
|
|
||||||
final ActionResult<MojangSkin> skinFetch = fetchSkinTextures(profile, reset);
|
|
||||||
if (!skinFetch.isError()) {
|
|
||||||
final MojangSkin skin = skinFetch.getResult();
|
|
||||||
final PropertyMap properties = gameProfile.getProperties();
|
|
||||||
properties.removeAll("textures");
|
|
||||||
properties.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
|
||||||
updateSelf(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityPlayer);
|
|
||||||
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
|
|
||||||
final IChatBaseComponent name = new ChatComponentText(profileName);
|
|
||||||
|
|
||||||
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();
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(remove);
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(add);
|
|
||||||
});
|
|
||||||
updateOthers(player);
|
|
||||||
return new ActionResult<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void spoofPlayerInfoPacket(Object object, Object newValue) {
|
|
||||||
try {
|
|
||||||
final Field field = object.getClass().getDeclaredField("b");
|
|
||||||
field.setAccessible(true);
|
|
||||||
field.set(object, newValue);
|
|
||||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>nicko-parent</artifactId>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>v1_16_R2</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<version>1.16.3-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<artifactId>core</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
|
@ -1,132 +0,0 @@
|
||||||
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;
|
|
||||||
import net.artelnatif.nicko.NickoBukkit;
|
|
||||||
import net.artelnatif.nicko.disguise.ActionResult;
|
|
||||||
import net.artelnatif.nicko.disguise.NickoProfile;
|
|
||||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
|
||||||
import net.minecraft.server.v1_16_R2.*;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.craftbukkit.v1_16_R2.CraftWorld;
|
|
||||||
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.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
public class v1_16_R2 implements Internals {
|
|
||||||
@Override
|
|
||||||
public void updateSelf(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final ResourceKey<World> levelResourceKey = entityPlayer.getWorld().getDimensionKey();
|
|
||||||
final CraftWorld world = entityPlayer.getWorld().getWorld();
|
|
||||||
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorld().getDimensionManager(),
|
|
||||||
levelResourceKey, world.getSeed(),
|
|
||||||
entityPlayer.playerInteractManager.c(), entityPlayer.playerInteractManager.getGameMode(),
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false);
|
|
||||||
|
|
||||||
final boolean wasFlying = player.isFlying();
|
|
||||||
entityPlayer.playerConnection.sendPacket(respawn);
|
|
||||||
player.setFlying(wasFlying);
|
|
||||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
|
||||||
player.updateInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateOthers(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId());
|
|
||||||
final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer);
|
|
||||||
|
|
||||||
final DataWatcher dataWatcher = entityPlayer.getDataWatcher();
|
|
||||||
final DataWatcherObject<Byte> displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a);
|
|
||||||
dataWatcher.set(displayedSkinPartDataWatcher, (byte) 0x7f);
|
|
||||||
final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true);
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
|
||||||
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(destroy);
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(spawn);
|
|
||||||
}
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(entityMetadata);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResult<Void> updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) {
|
|
||||||
final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName());
|
|
||||||
final String profileName = profile.getName() == null ? player.getName() : profile.getName();
|
|
||||||
|
|
||||||
final CraftPlayer craftPlayer = (CraftPlayer) player;
|
|
||||||
final EntityPlayer entityPlayer = craftPlayer.getHandle();
|
|
||||||
final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName);
|
|
||||||
|
|
||||||
if (skinChange || changeOnlyName) {
|
|
||||||
final ActionResult<MojangSkin> skinFetch = fetchSkinTextures(profile, reset);
|
|
||||||
if (!skinFetch.isError()) {
|
|
||||||
final MojangSkin skin = skinFetch.getResult();
|
|
||||||
final PropertyMap properties = gameProfile.getProperties();
|
|
||||||
properties.removeAll("textures");
|
|
||||||
properties.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
|
||||||
updateSelf(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityPlayer);
|
|
||||||
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
|
|
||||||
final IChatBaseComponent name = new ChatComponentText(profileName);
|
|
||||||
|
|
||||||
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();
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(remove);
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(add);
|
|
||||||
});
|
|
||||||
updateOthers(player);
|
|
||||||
return new ActionResult<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void spoofPlayerInfoPacket(Object object, Object newValue) {
|
|
||||||
try {
|
|
||||||
final Field field = object.getClass().getDeclaredField("b");
|
|
||||||
field.setAccessible(true);
|
|
||||||
field.set(object, newValue);
|
|
||||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>nicko-parent</artifactId>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>v1_16_R3</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<version>1.16.5-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<artifactId>core</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
|
@ -1,136 +0,0 @@
|
||||||
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;
|
|
||||||
import net.artelnatif.nicko.NickoBukkit;
|
|
||||||
import net.artelnatif.nicko.disguise.ActionResult;
|
|
||||||
import net.artelnatif.nicko.disguise.NickoProfile;
|
|
||||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
|
||||||
import net.minecraft.server.v1_16_R3.*;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
|
|
||||||
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.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
public class v1_16_R3 implements Internals {
|
|
||||||
@Override
|
|
||||||
public void updateSelf(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final ResourceKey<World> levelResourceKey = entityPlayer.getWorld().getDimensionKey();
|
|
||||||
final CraftWorld world = entityPlayer.getWorld().getWorld();
|
|
||||||
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorld().getDimensionManager(),
|
|
||||||
levelResourceKey, world.getSeed(),
|
|
||||||
entityPlayer.playerInteractManager.c(), entityPlayer.playerInteractManager.getGameMode(),
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false);
|
|
||||||
|
|
||||||
final boolean wasFlying = player.isFlying();
|
|
||||||
entityPlayer.playerConnection.sendPacket(respawn);
|
|
||||||
player.setFlying(wasFlying);
|
|
||||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
|
||||||
player.updateInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateOthers(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId());
|
|
||||||
final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer);
|
|
||||||
|
|
||||||
final DataWatcher dataWatcher = entityPlayer.getDataWatcher();
|
|
||||||
final DataWatcherObject<Byte> displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a);
|
|
||||||
dataWatcher.set(displayedSkinPartDataWatcher, (byte) 0x7f);
|
|
||||||
final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true);
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
|
||||||
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(destroy);
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(spawn);
|
|
||||||
}
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(entityMetadata);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResult<Void> updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) {
|
|
||||||
final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName());
|
|
||||||
final String profileName = profile.getName() == null ? player.getName() : profile.getName();
|
|
||||||
|
|
||||||
final CraftPlayer craftPlayer = (CraftPlayer) player;
|
|
||||||
final EntityPlayer entityPlayer = craftPlayer.getHandle();
|
|
||||||
final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName);
|
|
||||||
|
|
||||||
if (skinChange || changeOnlyName) {
|
|
||||||
final ActionResult<MojangSkin> skinFetch = fetchSkinTextures(profile, reset);
|
|
||||||
if (!skinFetch.isError()) {
|
|
||||||
final MojangSkin skin = skinFetch.getResult();
|
|
||||||
final PropertyMap properties = gameProfile.getProperties();
|
|
||||||
properties.removeAll("textures");
|
|
||||||
properties.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
|
||||||
updateSelf(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityPlayer);
|
|
||||||
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER);
|
|
||||||
final IChatBaseComponent name = new ChatComponentText(profileName);
|
|
||||||
|
|
||||||
// ok so what the actual fuck
|
|
||||||
// the PlayerDataInfo inner class is NOT static
|
|
||||||
// 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();
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(remove);
|
|
||||||
onlineEntityPlayer.playerConnection.sendPacket(add);
|
|
||||||
});
|
|
||||||
updateOthers(player);
|
|
||||||
return new ActionResult<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void spoofPlayerInfoPacket(Object object, Object newValue) {
|
|
||||||
try {
|
|
||||||
final Field field = object.getClass().getDeclaredField("b");
|
|
||||||
field.setAccessible(true);
|
|
||||||
field.set(object, newValue);
|
|
||||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>nicko-parent</artifactId>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>v1_17_R1</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<artifactId>core</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
|
@ -1,101 +0,0 @@
|
||||||
package net.artelnatif.nicko.impl;
|
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import com.mojang.authlib.properties.Property;
|
|
||||||
import com.mojang.authlib.properties.PropertyMap;
|
|
||||||
import net.artelnatif.nicko.disguise.ActionResult;
|
|
||||||
import net.artelnatif.nicko.disguise.NickoProfile;
|
|
||||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
|
||||||
import net.minecraft.network.chat.IChatBaseComponent;
|
|
||||||
import net.minecraft.network.protocol.game.*;
|
|
||||||
import net.minecraft.network.syncher.DataWatcher;
|
|
||||||
import net.minecraft.network.syncher.DataWatcherObject;
|
|
||||||
import net.minecraft.network.syncher.DataWatcherRegistry;
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
|
||||||
import net.minecraft.server.level.EntityPlayer;
|
|
||||||
import net.minecraft.world.level.EnumGamemode;
|
|
||||||
import net.minecraft.world.level.World;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
|
||||||
|
|
||||||
public class v1_17_R1 implements Internals {
|
|
||||||
@Override
|
|
||||||
public void updateSelf(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final ResourceKey<World> levelResourceKey = entityPlayer.getWorld().getDimensionKey();
|
|
||||||
final CraftWorld world = entityPlayer.getWorld().getWorld();
|
|
||||||
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.getWorld().getDimensionManager(),
|
|
||||||
levelResourceKey, world.getSeed(),
|
|
||||||
entityPlayer.c.getGamemode(), entityPlayer.d.c(),
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false);
|
|
||||||
|
|
||||||
final boolean wasFlying = player.isFlying();
|
|
||||||
entityPlayer.b.sendPacket(respawn);
|
|
||||||
player.setFlying(wasFlying);
|
|
||||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
|
||||||
player.updateInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateOthers(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId());
|
|
||||||
final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer);
|
|
||||||
|
|
||||||
final DataWatcher dataWatcher = entityPlayer.getDataWatcher();
|
|
||||||
final DataWatcherObject<Byte> displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a);
|
|
||||||
dataWatcher.set(displayedSkinPartDataWatcher, (byte) 0x7f);
|
|
||||||
final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true);
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
|
||||||
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
|
|
||||||
onlineEntityPlayer.b.sendPacket(destroy);
|
|
||||||
onlineEntityPlayer.b.sendPacket(spawn);
|
|
||||||
}
|
|
||||||
onlineEntityPlayer.b.sendPacket(entityMetadata);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResult<Void> updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) {
|
|
||||||
final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName());
|
|
||||||
final String profileName = profile.getName() == null ? player.getName() : profile.getName();
|
|
||||||
|
|
||||||
final CraftPlayer craftPlayer = (CraftPlayer) player;
|
|
||||||
final EntityPlayer entityPlayer = craftPlayer.getHandle();
|
|
||||||
final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName);
|
|
||||||
|
|
||||||
if (skinChange || changeOnlyName) {
|
|
||||||
final ActionResult<MojangSkin> skinFetch = fetchSkinTextures(profile, reset);
|
|
||||||
if (!skinFetch.isError()) {
|
|
||||||
final MojangSkin skin = skinFetch.getResult();
|
|
||||||
final PropertyMap properties = gameProfile.getProperties();
|
|
||||||
properties.removeAll("textures");
|
|
||||||
properties.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
|
||||||
updateSelf(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.e, entityPlayer);
|
|
||||||
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a);
|
|
||||||
|
|
||||||
add.b().clear();
|
|
||||||
add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile,
|
|
||||||
player.getPing(),
|
|
||||||
EnumGamemode.getById(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName)));
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
|
||||||
onlineEntityPlayer.b.sendPacket(remove);
|
|
||||||
onlineEntityPlayer.b.sendPacket(add);
|
|
||||||
});
|
|
||||||
updateOthers(player);
|
|
||||||
return new ActionResult<>();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<artifactId>nicko-parent</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>v1_18_R1</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<version>1.18.1-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<artifactId>core</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
|
@ -1,103 +0,0 @@
|
||||||
package net.artelnatif.nicko.impl;
|
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import com.mojang.authlib.properties.Property;
|
|
||||||
import com.mojang.authlib.properties.PropertyMap;
|
|
||||||
import net.artelnatif.nicko.disguise.ActionResult;
|
|
||||||
import net.artelnatif.nicko.disguise.NickoProfile;
|
|
||||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
|
||||||
import net.minecraft.network.chat.IChatBaseComponent;
|
|
||||||
import net.minecraft.network.protocol.game.*;
|
|
||||||
import net.minecraft.network.syncher.DataWatcher;
|
|
||||||
import net.minecraft.network.syncher.DataWatcherObject;
|
|
||||||
import net.minecraft.network.syncher.DataWatcherRegistry;
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
|
||||||
import net.minecraft.server.level.EntityPlayer;
|
|
||||||
import net.minecraft.world.level.EnumGamemode;
|
|
||||||
import net.minecraft.world.level.World;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R1.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
|
||||||
|
|
||||||
public class v1_18_R1 implements Internals {
|
|
||||||
@Override
|
|
||||||
public void updateSelf(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final ResourceKey<World> levelResourceKey = entityPlayer.x().aa();
|
|
||||||
final CraftWorld world = entityPlayer.W().getWorld();
|
|
||||||
// again, wtf is that
|
|
||||||
// f*ck obfuscation
|
|
||||||
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.W().q_(),
|
|
||||||
levelResourceKey, world.getSeed(),
|
|
||||||
entityPlayer.d.b(), entityPlayer.d.c(),
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false);
|
|
||||||
|
|
||||||
final boolean wasFlying = player.isFlying();
|
|
||||||
entityPlayer.b.a(respawn);
|
|
||||||
player.setFlying(wasFlying);
|
|
||||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
|
||||||
player.updateInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateOthers(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId());
|
|
||||||
final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer);
|
|
||||||
|
|
||||||
final DataWatcher dataWatcher = entityPlayer.ai();
|
|
||||||
final DataWatcherObject<Byte> displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a);
|
|
||||||
dataWatcher.b(displayedSkinPartDataWatcher, (byte) 0x7f);
|
|
||||||
final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true);
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
|
||||||
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
|
|
||||||
onlineEntityPlayer.b.a(destroy);
|
|
||||||
onlineEntityPlayer.b.a(spawn);
|
|
||||||
}
|
|
||||||
onlineEntityPlayer.b.a(entityMetadata);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResult<Void> updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) {
|
|
||||||
final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName());
|
|
||||||
final String profileName = profile.getName() == null ? player.getName() : profile.getName();
|
|
||||||
|
|
||||||
final CraftPlayer craftPlayer = (CraftPlayer) player;
|
|
||||||
final EntityPlayer entityPlayer = craftPlayer.getHandle();
|
|
||||||
final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName);
|
|
||||||
|
|
||||||
if (skinChange || changeOnlyName) {
|
|
||||||
final ActionResult<MojangSkin> skinFetch = fetchSkinTextures(profile, reset);
|
|
||||||
if (!skinFetch.isError()) {
|
|
||||||
final MojangSkin skin = skinFetch.getResult();
|
|
||||||
final PropertyMap properties = gameProfile.getProperties();
|
|
||||||
properties.removeAll("textures");
|
|
||||||
properties.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
|
||||||
updateSelf(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.e, entityPlayer);
|
|
||||||
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a);
|
|
||||||
|
|
||||||
add.b().clear();
|
|
||||||
add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile,
|
|
||||||
player.getPing(),
|
|
||||||
EnumGamemode.a(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName)));
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
|
||||||
onlineEntityPlayer.b.a(remove);
|
|
||||||
onlineEntityPlayer.b.a(add);
|
|
||||||
});
|
|
||||||
updateOthers(player);
|
|
||||||
return new ActionResult<>();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<artifactId>nicko-parent</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>v1_18_R2</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<version>1.18.2-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<artifactId>core</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
|
@ -1,103 +0,0 @@
|
||||||
package net.artelnatif.nicko.impl;
|
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import com.mojang.authlib.properties.Property;
|
|
||||||
import com.mojang.authlib.properties.PropertyMap;
|
|
||||||
import net.artelnatif.nicko.disguise.ActionResult;
|
|
||||||
import net.artelnatif.nicko.disguise.NickoProfile;
|
|
||||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
|
||||||
import net.minecraft.core.Holder;
|
|
||||||
import net.minecraft.network.chat.IChatBaseComponent;
|
|
||||||
import net.minecraft.network.protocol.game.*;
|
|
||||||
import net.minecraft.network.syncher.DataWatcher;
|
|
||||||
import net.minecraft.network.syncher.DataWatcherObject;
|
|
||||||
import net.minecraft.network.syncher.DataWatcherRegistry;
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
|
||||||
import net.minecraft.server.level.EntityPlayer;
|
|
||||||
import net.minecraft.world.level.EnumGamemode;
|
|
||||||
import net.minecraft.world.level.World;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
|
||||||
|
|
||||||
public class v1_18_R2 implements Internals {
|
|
||||||
@Override
|
|
||||||
public void updateSelf(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final ResourceKey<World> levelResourceKey = entityPlayer.x().aa();
|
|
||||||
final CraftWorld world = entityPlayer.s.getWorld();
|
|
||||||
// wtf is that ?
|
|
||||||
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(Holder.a(entityPlayer.s.q_()),
|
|
||||||
levelResourceKey, world.getSeed(),
|
|
||||||
entityPlayer.d.b(), entityPlayer.d.c(),
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false);
|
|
||||||
|
|
||||||
final boolean wasFlying = player.isFlying();
|
|
||||||
entityPlayer.b.a(respawn);
|
|
||||||
player.setFlying(wasFlying);
|
|
||||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
|
||||||
player.updateInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateOthers(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId());
|
|
||||||
final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer);
|
|
||||||
|
|
||||||
final DataWatcher dataWatcher = entityPlayer.ai();
|
|
||||||
final DataWatcherObject<Byte> displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a);
|
|
||||||
dataWatcher.b(displayedSkinPartDataWatcher, (byte) 0x7f);
|
|
||||||
final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true);
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
|
||||||
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
|
|
||||||
onlineEntityPlayer.b.a(destroy);
|
|
||||||
onlineEntityPlayer.b.a(spawn);
|
|
||||||
}
|
|
||||||
onlineEntityPlayer.b.a(entityMetadata);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResult<Void> updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) {
|
|
||||||
final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName());
|
|
||||||
final String profileName = profile.getName() == null ? player.getName() : profile.getName();
|
|
||||||
|
|
||||||
final CraftPlayer craftPlayer = (CraftPlayer) player;
|
|
||||||
final EntityPlayer entityPlayer = craftPlayer.getHandle();
|
|
||||||
final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName);
|
|
||||||
|
|
||||||
if (skinChange || changeOnlyName) {
|
|
||||||
final ActionResult<MojangSkin> skinFetch = fetchSkinTextures(profile, reset);
|
|
||||||
if (!skinFetch.isError()) {
|
|
||||||
final MojangSkin skin = skinFetch.getResult();
|
|
||||||
final PropertyMap properties = gameProfile.getProperties();
|
|
||||||
properties.removeAll("textures");
|
|
||||||
properties.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
|
||||||
updateSelf(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.e, entityPlayer);
|
|
||||||
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a);
|
|
||||||
|
|
||||||
add.b().clear();
|
|
||||||
add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile,
|
|
||||||
player.getPing(),
|
|
||||||
EnumGamemode.a(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName)));
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
|
||||||
onlineEntityPlayer.b.a(remove);
|
|
||||||
onlineEntityPlayer.b.a(add);
|
|
||||||
});
|
|
||||||
updateOthers(player);
|
|
||||||
return new ActionResult<>();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<artifactId>nicko-parent</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>v1_19_R1</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<version>1.19.2-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<artifactId>core</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
|
@ -1,107 +0,0 @@
|
||||||
package net.artelnatif.nicko.impl;
|
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import com.mojang.authlib.properties.Property;
|
|
||||||
import com.mojang.authlib.properties.PropertyMap;
|
|
||||||
import net.artelnatif.nicko.disguise.ActionResult;
|
|
||||||
import net.artelnatif.nicko.disguise.NickoProfile;
|
|
||||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
|
||||||
import net.minecraft.network.chat.IChatBaseComponent;
|
|
||||||
import net.minecraft.network.protocol.game.*;
|
|
||||||
import net.minecraft.network.syncher.DataWatcher;
|
|
||||||
import net.minecraft.network.syncher.DataWatcherObject;
|
|
||||||
import net.minecraft.network.syncher.DataWatcherRegistry;
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
|
||||||
import net.minecraft.server.level.EntityPlayer;
|
|
||||||
import net.minecraft.world.entity.player.ProfilePublicKey;
|
|
||||||
import net.minecraft.world.level.EnumGamemode;
|
|
||||||
import net.minecraft.world.level.World;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class v1_19_R1 implements Internals {
|
|
||||||
@Override
|
|
||||||
public void updateSelf(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final ResourceKey<World> levelResourceKey = entityPlayer.x().ab();
|
|
||||||
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.x().Z(),
|
|
||||||
levelResourceKey, entityPlayer.s.getWorld().getSeed(),
|
|
||||||
entityPlayer.d.b(), entityPlayer.d.c(),
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
Optional.empty());
|
|
||||||
|
|
||||||
final boolean wasFlying = player.isFlying();
|
|
||||||
entityPlayer.b.a(respawn);
|
|
||||||
player.setFlying(wasFlying);
|
|
||||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
|
||||||
player.updateInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateOthers(Player player) {
|
|
||||||
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId());
|
|
||||||
final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer);
|
|
||||||
|
|
||||||
final DataWatcher dataWatcher = entityPlayer.ai();
|
|
||||||
final DataWatcherObject<Byte> displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a);
|
|
||||||
dataWatcher.b(displayedSkinPartDataWatcher, (byte) 0x7f);
|
|
||||||
final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true);
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
|
||||||
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
|
|
||||||
onlineEntityPlayer.b.a(destroy);
|
|
||||||
onlineEntityPlayer.b.a(spawn);
|
|
||||||
}
|
|
||||||
onlineEntityPlayer.b.a(entityMetadata);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResult<Void> updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) {
|
|
||||||
final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName());
|
|
||||||
final String profileName = profile.getName() == null ? player.getName() : profile.getName();
|
|
||||||
|
|
||||||
final CraftPlayer craftPlayer = (CraftPlayer) player;
|
|
||||||
final EntityPlayer entityPlayer = craftPlayer.getHandle();
|
|
||||||
final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName);
|
|
||||||
|
|
||||||
if (skinChange || changeOnlyName) {
|
|
||||||
final ActionResult<MojangSkin> skinFetch = fetchSkinTextures(profile, reset);
|
|
||||||
if (!skinFetch.isError()) {
|
|
||||||
final MojangSkin skin = skinFetch.getResult();
|
|
||||||
final PropertyMap properties = gameProfile.getProperties();
|
|
||||||
properties.removeAll("textures");
|
|
||||||
properties.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
|
||||||
updateSelf(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a);
|
|
||||||
final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.e, entityPlayer);
|
|
||||||
// "It's a Surprise Tool That Will Help Us Later!"
|
|
||||||
final ProfilePublicKey.a key = remove.b().get(0).e();
|
|
||||||
|
|
||||||
add.b().clear();
|
|
||||||
add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile,
|
|
||||||
player.getPing(),
|
|
||||||
EnumGamemode.a(player.getGameMode().ordinal()),
|
|
||||||
IChatBaseComponent.a(profileName),
|
|
||||||
key)); // f mojang
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
|
||||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
|
||||||
onlineEntityPlayer.b.a(remove);
|
|
||||||
onlineEntityPlayer.b.a(add);
|
|
||||||
});
|
|
||||||
updateOthers(player);
|
|
||||||
return new ActionResult<>();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,68 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<artifactId>nicko-parent</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>v1_19_R2</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>net.md-5</groupId>
|
|
||||||
<artifactId>specialsource-maven-plugin</artifactId>
|
|
||||||
<version>1.2.4</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>remap</goal>
|
|
||||||
</goals>
|
|
||||||
<id>remap-obf</id>
|
|
||||||
<configuration>
|
|
||||||
<srgIn>org.spigotmc:minecraft-server:1.19.3-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
|
|
||||||
<reverse>true</reverse>
|
|
||||||
<remappedDependencies>org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
|
|
||||||
<remappedArtifactAttached>true</remappedArtifactAttached>
|
|
||||||
<remappedClassifierName>remapped-obf</remappedClassifierName>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>remap</goal>
|
|
||||||
</goals>
|
|
||||||
<id>remap-spigot</id>
|
|
||||||
<configuration>
|
|
||||||
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
|
|
||||||
<srgIn>org.spigotmc:minecraft-server:1.19.3-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
|
|
||||||
<remappedDependencies>org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<version>1.19.3-R0.1-SNAPSHOT</version>
|
|
||||||
<classifier>remapped-mojang</classifier>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<artifactId>core</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
|
@ -1,132 +0,0 @@
|
||||||
package net.artelnatif.nicko.impl;
|
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import com.mojang.authlib.properties.Property;
|
|
||||||
import com.mojang.authlib.properties.PropertyMap;
|
|
||||||
import net.artelnatif.nicko.NickoBukkit;
|
|
||||||
import net.artelnatif.nicko.disguise.ActionResult;
|
|
||||||
import net.artelnatif.nicko.disguise.NickoProfile;
|
|
||||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.network.chat.RemoteChatSession;
|
|
||||||
import net.minecraft.network.protocol.game.*;
|
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
|
||||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.world.entity.player.ProfilePublicKey;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class v1_19_R2 implements Internals {
|
|
||||||
@Override
|
|
||||||
public void updateSelf(Player player) {
|
|
||||||
final ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final ServerLevel level = serverPlayer.getLevel();
|
|
||||||
final ResourceKey<Level> levelResourceKey = serverPlayer.getLevel().dimension();
|
|
||||||
final ClientboundRespawnPacket respawn = new ClientboundRespawnPacket(serverPlayer.level.dimensionTypeId(),
|
|
||||||
levelResourceKey, level.getWorld().getSeed(),
|
|
||||||
serverPlayer.gameMode.getGameModeForPlayer(), serverPlayer.gameMode.getPreviousGameModeForPlayer(),
|
|
||||||
level.isDebug(),
|
|
||||||
level.isFlat(),
|
|
||||||
(byte) 0x00,
|
|
||||||
Optional.empty());
|
|
||||||
|
|
||||||
final boolean wasFlying = player.isFlying();
|
|
||||||
serverPlayer.connection.send(respawn);
|
|
||||||
player.setFlying(wasFlying);
|
|
||||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
|
||||||
player.updateInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateOthers(Player player) {
|
|
||||||
final ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final ClientboundRemoveEntitiesPacket remove = new ClientboundRemoveEntitiesPacket(serverPlayer.getBukkitEntity().getEntityId());
|
|
||||||
final ClientboundAddEntityPacket add = new ClientboundAddEntityPacket(serverPlayer);
|
|
||||||
|
|
||||||
final SynchedEntityData entityData = serverPlayer.getEntityData();
|
|
||||||
final EntityDataAccessor<Byte> skinPartAccessor = new EntityDataAccessor<>(17, EntityDataSerializers.BYTE);
|
|
||||||
entityData.set(skinPartAccessor, (byte) 0x7f);
|
|
||||||
final ClientboundSetEntityDataPacket entityMetadata = new ClientboundSetEntityDataPacket(serverPlayer.getBukkitEntity().getEntityId(), entityData.getNonDefaultValues());
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
|
||||||
final ServerPlayer onlineServerPlayer = ((CraftPlayer) online).getHandle();
|
|
||||||
if (onlineServerPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
|
|
||||||
onlineServerPlayer.connection.send(remove);
|
|
||||||
onlineServerPlayer.connection.send(add);
|
|
||||||
}
|
|
||||||
onlineServerPlayer.connection.send(entityMetadata);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResult<Void> updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) {
|
|
||||||
final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName());
|
|
||||||
final String profileName = profile.getName() == null ? player.getName() : profile.getName();
|
|
||||||
|
|
||||||
final ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName);
|
|
||||||
|
|
||||||
if (skinChange || changeOnlyName) {
|
|
||||||
final ActionResult<MojangSkin> skinFetch = fetchSkinTextures(profile, reset);
|
|
||||||
if (!skinFetch.isError()) {
|
|
||||||
final MojangSkin skin = skinFetch.getResult();
|
|
||||||
final PropertyMap properties = gameProfile.getProperties();
|
|
||||||
properties.removeAll("textures");
|
|
||||||
properties.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
|
||||||
updateSelf(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final ClientboundPlayerInfoUpdatePacket init = ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(Collections.singletonList(serverPlayer));
|
|
||||||
final ClientboundPlayerInfoRemovePacket remove = new ClientboundPlayerInfoRemovePacket(Collections.singletonList(player.getUniqueId()));
|
|
||||||
|
|
||||||
RemoteChatSession chatSession;
|
|
||||||
if (serverPlayer.getChatSession() == null) {
|
|
||||||
NickoBukkit.getInstance().getLogger().warning("Chat Session of " + serverPlayer.displayName + " is null!");
|
|
||||||
NickoBukkit.getInstance().getLogger().warning("If your server is in offline mode/under BungeeCord you can safely ignore this message.");
|
|
||||||
chatSession = null;
|
|
||||||
} else {
|
|
||||||
final UUID uuid = serverPlayer.getChatSession().sessionId();
|
|
||||||
final ProfilePublicKey ppk = serverPlayer.getChatSession().profilePublicKey();
|
|
||||||
chatSession = new RemoteChatSession(uuid, ppk);
|
|
||||||
}
|
|
||||||
|
|
||||||
spoofPlayerInfoPacket(init, Collections.singletonList(new ClientboundPlayerInfoUpdatePacket.Entry(
|
|
||||||
player.getUniqueId(),
|
|
||||||
gameProfile,
|
|
||||||
true,
|
|
||||||
serverPlayer.latency,
|
|
||||||
serverPlayer.gameMode.getGameModeForPlayer(),
|
|
||||||
Component.literal(profileName),
|
|
||||||
chatSession == null ? null : chatSession.asData()
|
|
||||||
)));
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
|
||||||
final ServerPlayer onlinePlayer = ((CraftPlayer) online).getHandle();
|
|
||||||
onlinePlayer.connection.send(remove);
|
|
||||||
onlinePlayer.connection.send(init);
|
|
||||||
});
|
|
||||||
updateOthers(player);
|
|
||||||
return new ActionResult<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void spoofPlayerInfoPacket(Object object, Object newValue) {
|
|
||||||
try {
|
|
||||||
final Field field = object.getClass().getDeclaredField("b");
|
|
||||||
field.setAccessible(true);
|
|
||||||
field.set(object, newValue);
|
|
||||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
|
||||||
NickoBukkit.getInstance().getLogger().warning("Unable to spoof packet, that's bad! (" + e.getMessage() + ")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,68 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<artifactId>nicko-parent</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>v1_19_R3</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>net.md-5</groupId>
|
|
||||||
<artifactId>specialsource-maven-plugin</artifactId>
|
|
||||||
<version>1.2.4</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>remap</goal>
|
|
||||||
</goals>
|
|
||||||
<id>remap-obf</id>
|
|
||||||
<configuration>
|
|
||||||
<srgIn>org.spigotmc:minecraft-server:1.19.4-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
|
|
||||||
<reverse>true</reverse>
|
|
||||||
<remappedDependencies>org.spigotmc:spigot:1.19.4-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
|
|
||||||
<remappedArtifactAttached>true</remappedArtifactAttached>
|
|
||||||
<remappedClassifierName>remapped-obf</remappedClassifierName>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>remap</goal>
|
|
||||||
</goals>
|
|
||||||
<id>remap-spigot</id>
|
|
||||||
<configuration>
|
|
||||||
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
|
|
||||||
<srgIn>org.spigotmc:minecraft-server:1.19.4-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
|
|
||||||
<remappedDependencies>org.spigotmc:spigot:1.19.4-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<version>1.19.4-R0.1-SNAPSHOT</version>
|
|
||||||
<classifier>remapped-mojang</classifier>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.artelnatif</groupId>
|
|
||||||
<artifactId>core</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
|
@ -1,140 +0,0 @@
|
||||||
package net.artelnatif.nicko.impl;
|
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import com.mojang.authlib.properties.Property;
|
|
||||||
import com.mojang.authlib.properties.PropertyMap;
|
|
||||||
import net.artelnatif.nicko.NickoBukkit;
|
|
||||||
import net.artelnatif.nicko.disguise.ActionResult;
|
|
||||||
import net.artelnatif.nicko.disguise.NickoProfile;
|
|
||||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.network.chat.RemoteChatSession;
|
|
||||||
import net.minecraft.network.protocol.game.*;
|
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
|
||||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
|
||||||
import net.minecraft.resources.ResourceKey;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.world.entity.player.ProfilePublicKey;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
public class v1_19_R3 implements Internals {
|
|
||||||
final Logger logger = Bukkit.getLogger();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateSelf(Player player) {
|
|
||||||
final ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final ServerLevel level = serverPlayer.getLevel();
|
|
||||||
final ResourceKey<Level> levelResourceKey = serverPlayer.getLevel().dimension();
|
|
||||||
final ClientboundRespawnPacket respawn = new ClientboundRespawnPacket(serverPlayer.level.dimensionTypeId(),
|
|
||||||
levelResourceKey, level.getWorld().getSeed(),
|
|
||||||
serverPlayer.gameMode.getGameModeForPlayer(), serverPlayer.gameMode.getPreviousGameModeForPlayer(),
|
|
||||||
level.isDebug(),
|
|
||||||
level.isFlat(),
|
|
||||||
(byte) 0x00,
|
|
||||||
Optional.empty());
|
|
||||||
|
|
||||||
final boolean wasFlying = player.isFlying();
|
|
||||||
serverPlayer.connection.send(respawn);
|
|
||||||
player.setFlying(wasFlying);
|
|
||||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
|
||||||
player.updateInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateOthers(Player player) {
|
|
||||||
final ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
|
|
||||||
final ClientboundRemoveEntitiesPacket remove = new ClientboundRemoveEntitiesPacket(serverPlayer.getBukkitEntity().getEntityId());
|
|
||||||
final ClientboundAddEntityPacket add = new ClientboundAddEntityPacket(serverPlayer);
|
|
||||||
|
|
||||||
final SynchedEntityData entityData = serverPlayer.getEntityData();
|
|
||||||
final EntityDataAccessor<Byte> skinPartAccessor = new EntityDataAccessor<>(17, EntityDataSerializers.BYTE);
|
|
||||||
entityData.set(skinPartAccessor, (byte) 0x7f);
|
|
||||||
final ClientboundSetEntityDataPacket entityMetadata = new ClientboundSetEntityDataPacket(serverPlayer.getBukkitEntity().getEntityId(), entityData.getNonDefaultValues());
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
|
||||||
final ServerPlayer onlineServerPlayer = ((CraftPlayer) online).getHandle();
|
|
||||||
if (onlineServerPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
|
|
||||||
onlineServerPlayer.connection.send(remove);
|
|
||||||
onlineServerPlayer.connection.send(add);
|
|
||||||
}
|
|
||||||
onlineServerPlayer.connection.send(entityMetadata);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResult<Void> updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) {
|
|
||||||
final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName());
|
|
||||||
final String profileName = profile.getName() == null ? player.getName() : profile.getName();
|
|
||||||
|
|
||||||
final ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
|
||||||
final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName);
|
|
||||||
|
|
||||||
if (skinChange || changeOnlyName) {
|
|
||||||
final ActionResult<MojangSkin> skinFetch = fetchSkinTextures(profile, reset);
|
|
||||||
if (!skinFetch.isError()) {
|
|
||||||
final MojangSkin skin = skinFetch.getResult();
|
|
||||||
final PropertyMap properties = gameProfile.getProperties();
|
|
||||||
properties.removeAll("textures");
|
|
||||||
properties.put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
|
||||||
updateSelf(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final ClientboundPlayerInfoUpdatePacket init = ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(Collections.singletonList(serverPlayer));
|
|
||||||
final ClientboundPlayerInfoRemovePacket remove = new ClientboundPlayerInfoRemovePacket(Collections.singletonList(player.getUniqueId()));
|
|
||||||
|
|
||||||
RemoteChatSession chatSession;
|
|
||||||
if (serverPlayer.getChatSession() == null) {
|
|
||||||
NickoBukkit.getInstance().getLogger().warning("Chat Session of " + serverPlayer.displayName + " is null!");
|
|
||||||
NickoBukkit.getInstance().getLogger().warning("If your server is in offline mode/under BungeeCord you can safely ignore this message.");
|
|
||||||
chatSession = null;
|
|
||||||
} else {
|
|
||||||
final UUID uuid = serverPlayer.getChatSession().sessionId();
|
|
||||||
final ProfilePublicKey ppk = serverPlayer.getChatSession().profilePublicKey();
|
|
||||||
chatSession = new RemoteChatSession(uuid, ppk);
|
|
||||||
}
|
|
||||||
|
|
||||||
spoofPlayerInfoPacket(init, Collections.singletonList(new ClientboundPlayerInfoUpdatePacket.Entry(
|
|
||||||
player.getUniqueId(),
|
|
||||||
gameProfile,
|
|
||||||
true,
|
|
||||||
serverPlayer.latency,
|
|
||||||
serverPlayer.gameMode.getGameModeForPlayer(),
|
|
||||||
Component.literal(profileName),
|
|
||||||
chatSession == null ? null : chatSession.asData()
|
|
||||||
)));
|
|
||||||
|
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
|
||||||
final ServerPlayer onlinePlayer = ((CraftPlayer) online).getHandle();
|
|
||||||
onlinePlayer.connection.send(remove);
|
|
||||||
onlinePlayer.connection.send(init);
|
|
||||||
});
|
|
||||||
// TODO: 3/17/23 Update signature to avoid duplicate for loop
|
|
||||||
updateOthers(player);
|
|
||||||
return new ActionResult<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void spoofPlayerInfoPacket(Object object, Object newValue) {
|
|
||||||
try {
|
|
||||||
final Field field = object.getClass().getDeclaredField("b");
|
|
||||||
field.setAccessible(true);
|
|
||||||
field.set(object, newValue);
|
|
||||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
|
||||||
NickoBukkit.getInstance().getLogger().warning("Unable to spoof packet, that's bad! (" + e.getMessage() + ")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue