feat: 1.19.3 skin support
This commit is contained in:
parent
95b3e420bc
commit
052ff6bc9d
6 changed files with 237 additions and 3 deletions
33
dist/dependency-reduced-pom.xml
vendored
33
dist/dependency-reduced-pom.xml
vendored
|
@ -31,6 +31,39 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>net.md-5</groupId>
|
||||||
|
<artifactId>specialsource-maven-plugin</artifactId>
|
||||||
|
<version>1.2.4</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>remap-obf</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>remap</goal>
|
||||||
|
</goals>
|
||||||
|
<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>
|
||||||
|
<id>remap-spigot</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>remap</goal>
|
||||||
|
</goals>
|
||||||
|
<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>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|
40
dist/pom.xml
vendored
40
dist/pom.xml
vendored
|
@ -37,6 +37,39 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<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>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
@ -66,7 +99,10 @@
|
||||||
<artifactId>nicko-v1_19_R1</artifactId>
|
<artifactId>nicko-v1_19_R1</artifactId>
|
||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.artelnatif</groupId>
|
||||||
|
<artifactId>nicko-v1_19_R2</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -71,7 +71,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.studiocode.invui</groupId>
|
<groupId>de.studiocode.invui</groupId>
|
||||||
<artifactId>InvUI</artifactId>
|
<artifactId>InvUI</artifactId>
|
||||||
<version>0.8.2</version>
|
<version>0.10.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- AnvilGUI -->
|
<!-- AnvilGUI -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
1
pom.xml
1
pom.xml
|
@ -17,6 +17,7 @@
|
||||||
<module>v1_18_R1</module>
|
<module>v1_18_R1</module>
|
||||||
<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>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
30
v1_19_R2/pom.xml
Normal file
30
v1_19_R2/pom.xml
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<?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>nicko-v1_19_R2</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<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>nicko-core</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
134
v1_19_R2/src/main/java/net/artelnatif/nicko/impl/v1_19_R2.java
Normal file
134
v1_19_R2/src/main/java/net/artelnatif/nicko/impl/v1_19_R2.java
Normal file
|
@ -0,0 +1,134 @@
|
||||||
|
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.i18n.I18NDict;
|
||||||
|
import net.artelnatif.nicko.mojang.MojangAPI;
|
||||||
|
import net.artelnatif.nicko.mojang.MojangSkin;
|
||||||
|
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.level.Level;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
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 CraftWorld world = level.getWorld();
|
||||||
|
// last boolean is: "has death location" attribute, if true, the optional contains the death dimension and position.
|
||||||
|
// with the boolean being false, we don't need to provide a value, and thus we return an empty optional.
|
||||||
|
final ClientboundRespawnPacket respawn = new ClientboundRespawnPacket(serverPlayer.level.dimensionTypeId(),
|
||||||
|
levelResourceKey, world.getSeed(),
|
||||||
|
serverPlayer.gameMode.getPreviousGameModeForPlayer(), serverPlayer.gameMode.getGameModeForPlayer(),
|
||||||
|
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);
|
||||||
|
|
||||||
|
/*
|
||||||
|
BIT MASKS:
|
||||||
|
0x01 Cape enabled
|
||||||
|
0x02 Jacket enabled
|
||||||
|
0x04 Left sleeve enabled
|
||||||
|
0x08 Right sleeve enabled
|
||||||
|
0x10 Left pants leg enabled
|
||||||
|
0x20 Right pants leg enabled
|
||||||
|
0x40 Hat enabled
|
||||||
|
*/
|
||||||
|
final SynchedEntityData entityData = serverPlayer.getEntityData();
|
||||||
|
final EntityDataAccessor<Byte> skinPartAccessor = new EntityDataAccessor<>(17, EntityDataSerializers.BYTE);
|
||||||
|
entityData.set(skinPartAccessor, (byte) 0x7f); // 127, all masks combined
|
||||||
|
final ClientboundSetEntityDataPacket entityMetadata = new ClientboundSetEntityDataPacket(serverPlayer.getBukkitEntity().getEntityId(), entityData.getNonDefaultValues());
|
||||||
|
|
||||||
|
Bukkit.getOnlinePlayers().forEach(online -> {
|
||||||
|
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 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();
|
||||||
|
Optional<MojangSkin> skin;
|
||||||
|
|
||||||
|
final ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
final GameProfile gameProfile = serverPlayer.getGameProfile();
|
||||||
|
|
||||||
|
final ClientboundPlayerInfoRemovePacket remove = new ClientboundPlayerInfoRemovePacket(List.of(player.getUniqueId()));
|
||||||
|
// TODO: 1/20/23 Sets Gamemode to Survival but keeps the flying? Visual effect only?
|
||||||
|
final ClientboundPlayerInfoUpdatePacket init = ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(serverPlayer));
|
||||||
|
|
||||||
|
|
||||||
|
if (skinChange || changeOnlyName) {
|
||||||
|
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()));
|
||||||
|
if (skin.isPresent()) {
|
||||||
|
final PropertyMap properties = gameProfile.getProperties();
|
||||||
|
properties.removeAll("textures");
|
||||||
|
properties.put("textures", new Property("textures", skin.get().value(), skin.get().signature()));
|
||||||
|
updateSelf(player);
|
||||||
|
} else {
|
||||||
|
return new ActionResult(I18NDict.Error.SKIN_FAIL_MOJANG);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
serverPlayer.connection.send(remove);
|
||||||
|
serverPlayer.connection.send(init);
|
||||||
|
Bukkit.getOnlinePlayers().forEach(online -> {
|
||||||
|
ServerPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
||||||
|
onlineEntityPlayer.connection.send(remove);
|
||||||
|
onlineEntityPlayer.connection.send(init);
|
||||||
|
});
|
||||||
|
updateOthers(player);
|
||||||
|
return new ActionResult();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue