diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml new file mode 100644 index 0000000..f502d6a --- /dev/null +++ b/dependency-reduced-pom.xml @@ -0,0 +1,164 @@ + + + 4.0.0 + net.artelnatif + nicko + Nicko + 1.0-SNAPSHOT + + + + true + ${basedir}/src/main/resources/ + + + + + maven-surefire-plugin + 3.0.0-M7 + + + maven-shade-plugin + 3.4.1 + + + package + + shade + + + + + net.wesjd:anvilgui + xyz.xenondevs.invui:* + com.github.jsixface:* + com.fasterxml.jackson.dataformat + com.fasterxml.jackson.core + org.mariadb.jdbc + + + + + net.wesjd.anvilgui + net.artelnatif.libs.anvilgui + + + xyz.xenondevs.invui + net.artelnatif.libs.invui + + + com.github.jsixface + net.artelnatif.libs.yaml + + + com.fasterxml.jackson.dataformat + net.artelnatif.libs.jackson.yaml + + + com.fasterxml.jackson.core + net.artelnatif.libs.jackson.core + + + org.mariadb.jdbc + net.artelnatif.libs.mariadb + + + false + + + + + + + + + papermc + https://repo.papermc.io/repository/maven-public/ + + + spigot-repo + https://hub.spigotmc.org/nexus/content/groups/public/ + + + codemc-snapshots + https://repo.codemc.io/repository/maven-snapshots/ + + + placeholderapi + https://repo.extendedclip.com/content/repositories/placeholderapi/ + + + + + com.github.retrooper.packetevents + spigot + 2.0.0-SNAPSHOT + provided + + + me.clip + placeholderapi + 2.11.2 + provided + + + org.spigotmc + spigot-api + 1.19.4-R0.1-SNAPSHOT + provided + + + com.google.guava + guava + 31.1-jre + provided + + + com.github.seeseemelk + MockBukkit-v1.19 + 2.29.0 + test + + + paper-api + io.papermc.paper + + + junit-jupiter + org.junit.jupiter + + + hamcrest-library + org.hamcrest + + + adventure-platform-bungeecord + net.kyori + + + maven-resolver-provider + org.apache.maven + + + maven-resolver-connector-basic + org.apache.maven.resolver + + + maven-resolver-transport-http + org.apache.maven.resolver + + + + + redis.clients + jedis + 4.3.0 + compile + + + + 17 + 17 + UTF-8 + + diff --git a/pom.xml b/pom.xml index d0ef690..d975ad7 100644 --- a/pom.xml +++ b/pom.xml @@ -16,10 +16,6 @@ - - dmulloy2-repo - https://repo.dmulloy2.net/repository/public/ - papermc https://repo.papermc.io/repository/maven-public/ @@ -40,9 +36,9 @@ - com.comphenix.protocol - ProtocolLib - 5.0.0-SNAPSHOT + com.github.retrooper.packetevents + spigot + 2.0.0-SNAPSHOT provided diff --git a/src/main/java/net/artelnatif/nicko/NickoBukkit.java b/src/main/java/net/artelnatif/nicko/NickoBukkit.java index fc8e1bf..c8a798b 100644 --- a/src/main/java/net/artelnatif/nicko/NickoBukkit.java +++ b/src/main/java/net/artelnatif/nicko/NickoBukkit.java @@ -1,7 +1,5 @@ package net.artelnatif.nicko; -import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.ProtocolManager; import net.artelnatif.nicko.command.NickoCommand; import net.artelnatif.nicko.config.Configuration; import net.artelnatif.nicko.config.ConfigurationManager; @@ -39,7 +37,6 @@ public class NickoBukkit extends JavaPlugin { private Configuration configuration; private LocaleFileManager localeFileManager; private PlayerNameStore nameStore; - private ProtocolManager protocolManager; public NickoBukkit() { this.unitTesting = false; } @@ -66,7 +63,6 @@ public class NickoBukkit extends JavaPlugin { configurationManager = new ConfigurationManager(getDataFolder()); configurationManager.saveDefaultConfig(); - protocolManager = ProtocolLibrary.getProtocolManager(); mojangAPI = new MojangAPI(); dataStore = new PlayerDataStore(mojangAPI, getNickoConfig()); nameStore = new PlayerNameStore(); @@ -154,6 +150,4 @@ public class NickoBukkit extends JavaPlugin { public LocaleFileManager getLocaleFileManager() { return localeFileManager; } - - public ProtocolManager getProtocolManager() { return protocolManager; } } diff --git a/src/main/java/net/artelnatif/nicko/appearance/AppearanceManager.java b/src/main/java/net/artelnatif/nicko/appearance/AppearanceManager.java index 7ce4a3b..e182d64 100644 --- a/src/main/java/net/artelnatif/nicko/appearance/AppearanceManager.java +++ b/src/main/java/net/artelnatif/nicko/appearance/AppearanceManager.java @@ -1,9 +1,13 @@ 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 com.github.retrooper.packetevents.PacketEvents; +import com.github.retrooper.packetevents.protocol.player.TextureProperty; +import com.github.retrooper.packetevents.protocol.player.UserProfile; +import com.github.retrooper.packetevents.protocol.world.Difficulty; +import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerPlayerInfoRemove; +import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerPlayerInfoUpdate; +import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerRespawn; +import io.github.retrooper.packetevents.util.SpigotConversionUtil; import net.artelnatif.nicko.NickoBukkit; import net.artelnatif.nicko.disguise.ActionResult; import net.artelnatif.nicko.disguise.NickoProfile; @@ -12,14 +16,15 @@ import net.artelnatif.nicko.mojang.MojangAPI; import net.artelnatif.nicko.mojang.MojangSkin; import net.artelnatif.nicko.storage.PlayerDataStore; import net.artelnatif.nicko.storage.name.PlayerNameStore; +import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; import java.io.IOException; +import java.util.EnumSet; import java.util.List; import java.util.Optional; -import java.util.Set; import java.util.UUID; import java.util.concurrent.ExecutionException; @@ -99,16 +104,17 @@ public class AppearanceManager { public ActionResult updatePlayer(boolean skinChange) { final String displayName = profile.getName() == null ? player.getName() : profile.getName(); - final WrappedGameProfile gameProfile = new WrappedGameProfile(player.getUniqueId(), displayName); + Bukkit.broadcastMessage("Building UserProfile"); + final UserProfile userProfile = new UserProfile(player.getUniqueId(), displayName); - final ActionResult result = updateGameProfileSkin(gameProfile, skinChange); + final ActionResult result = updateGameProfileSkin(userProfile, skinChange); if (!result.isError()) { - updateTabList(gameProfile, displayName); + updateTabList(userProfile, displayName); } return new ActionResult<>(); } - private ActionResult updateGameProfileSkin(WrappedGameProfile gameProfile, boolean skinChange) { + private ActionResult updateGameProfileSkin(UserProfile userProfile, boolean skinChange) { final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName()); if (skinChange || changeOnlyName) { @@ -120,9 +126,9 @@ public class AppearanceManager { skin = mojang.getSkin(uuid.get()); if (skin.isPresent()) { final MojangSkin skinResult = skin.get(); - final Multimap properties = gameProfile.getProperties(); - properties.removeAll("textures"); - properties.put("textures", new WrappedSignedProperty("textures", skinResult.getValue(), skinResult.getSignature())); + final List properties = userProfile.getTextureProperties(); + properties.clear(); + properties.add(new TextureProperty("textures", skinResult.getValue(), skinResult.getSignature())); Bukkit.broadcastMessage("Modified properties"); } } @@ -139,47 +145,43 @@ public class AppearanceManager { } 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); + final World world = player.getWorld(); + final WrapperPlayServerRespawn respawn = new WrapperPlayServerRespawn( + SpigotConversionUtil.fromBukkitWorld(world), + world.getName(), + Difficulty.getById(world.getDifficulty().ordinal()), + world.getSeed(), + SpigotConversionUtil.fromBukkitGameMode(player.getGameMode()), + null, + false, + false, + false, + null, + null + ); + PacketEvents.getAPI().getPlayerManager().sendPacket(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 + private void updateTabList(UserProfile userProfile, String displayName) { + final WrapperPlayServerPlayerInfoUpdate infoAdd = new WrapperPlayServerPlayerInfoUpdate(EnumSet.of( + WrapperPlayServerPlayerInfoUpdate.Action.ADD_PLAYER, + WrapperPlayServerPlayerInfoUpdate.Action.UPDATE_GAME_MODE, + WrapperPlayServerPlayerInfoUpdate.Action.UPDATE_DISPLAY_NAME, + WrapperPlayServerPlayerInfoUpdate.Action.UPDATE_LISTED, + WrapperPlayServerPlayerInfoUpdate.Action.UPDATE_LATENCY + ), new WrapperPlayServerPlayerInfoUpdate.PlayerInfo( + userProfile, + true, + 0, + SpigotConversionUtil.fromBukkitGameMode(player.getGameMode()), + Component.text(displayName), + null )); - infoAdd.getPlayerInfoDataLists().write(1, List.of(new PlayerInfoData( - gameProfile, - 0, - EnumWrappers.NativeGameMode.fromBukkit(player.getGameMode()), - WrappedChatComponent.fromText(displayName) - ))); + final WrapperPlayServerPlayerInfoRemove infoRemove = new WrapperPlayServerPlayerInfoRemove(player.getUniqueId()); + Bukkit.broadcastMessage("Updating tablist"); + PacketEvents.getAPI().getPlayerManager().sendPacket(player, infoRemove); + PacketEvents.getAPI().getPlayerManager().sendPacket(player, infoAdd); - 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); } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index af81d31..9599f7a 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -4,7 +4,8 @@ version: 1.0-SNAPSHOT author: Ineanto api-version: 1.13 softdepend: [ PlaceholderAPI ] -depend: [ ProtocolLib ] +load: POSTWORLD +depend: [ packetevents ] commands: nicko: description: "Opens Nicko's GUI."