feat: 1.19.4 support
disguise seems broken for others as of late, and I can't seem to figure out the root cause.
This commit is contained in:
parent
45bca01366
commit
32e8bb0bcf
5 changed files with 215 additions and 1 deletions
|
@ -53,7 +53,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.19.3-R0.1-SNAPSHOT</version>
|
<version>1.19.4-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Inventory Lib -->
|
<!-- Inventory Lib -->
|
||||||
|
|
5
dist/pom.xml
vendored
5
dist/pom.xml
vendored
|
@ -106,5 +106,10 @@
|
||||||
<artifactId>v1_19_R2</artifactId>
|
<artifactId>v1_19_R2</artifactId>
|
||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.artelnatif</groupId>
|
||||||
|
<artifactId>v1_19_R3</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
1
pom.xml
1
pom.xml
|
@ -25,6 +25,7 @@
|
||||||
<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>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
68
v1_19_R3/pom.xml
Normal file
68
v1_19_R3/pom.xml
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
<?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>
|
140
v1_19_R3/src/main/java/net/artelnatif/nicko/impl/v1_19_R3.java
Normal file
140
v1_19_R3/src/main/java/net/artelnatif/nicko/impl/v1_19_R3.java
Normal file
|
@ -0,0 +1,140 @@
|
||||||
|
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()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
updateSelf(player);
|
||||||
|
// 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