initial project commit
This commit is contained in:
commit
d7c79d7eac
117 changed files with 2561 additions and 0 deletions
29
v1_18_R1/pom.xml
Normal file
29
v1_18_R1/pom.xml
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?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_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>nicko-core</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
132
v1_18_R1/src/main/java/net/artelnatif/impl/v1_18_R1.java
Normal file
132
v1_18_R1/src/main/java/net/artelnatif/impl/v1_18_R1.java
Normal file
|
@ -0,0 +1,132 @@
|
|||
package net.artelnatif.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.NickoProfile;
|
||||
import net.artelnatif.nicko.impl.Internals;
|
||||
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;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
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();
|
||||
final ItemStack itemOnCursor = player.getItemOnCursor();
|
||||
entityPlayer.b.a(respawn);
|
||||
player.setFlying(wasFlying);
|
||||
player.setItemOnCursor(itemOnCursor);
|
||||
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);
|
||||
|
||||
/*
|
||||
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 DataWatcher dataWatcher = entityPlayer.ai();
|
||||
final DataWatcherObject<Byte> displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a);
|
||||
dataWatcher.b(displayedSkinPartDataWatcher, (byte) 0x7f); // 127, all masks combined
|
||||
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 void updateProfile(Player player, NickoProfile profile, boolean skinChange) {
|
||||
final CraftPlayer craftPlayer = (CraftPlayer) player;
|
||||
final EntityPlayer entityPlayer = craftPlayer.getHandle();
|
||||
Optional<MojangSkin> skin;
|
||||
|
||||
final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.e, entityPlayer);
|
||||
entityPlayer.b.a(remove);
|
||||
|
||||
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a);
|
||||
final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profile.getName());
|
||||
|
||||
if (skinChange) {
|
||||
try {
|
||||
final Optional<String> uuid = NickoBukkit.getInstance().getMojangAPI().getUUID(profile.getSkin());
|
||||
if (uuid.isPresent()) {
|
||||
skin = NickoBukkit.getInstance().getMojangAPI().getSkin(uuid.get());
|
||||
if (skin.isPresent()) {
|
||||
final PropertyMap properties = gameProfile.getProperties();
|
||||
properties.put("textures", new Property("textures", skin.get().value(), skin.get().signature()));
|
||||
updateSelf(player);
|
||||
} else {
|
||||
player.sendMessage(NickoBukkit.getInstance().getNickoConfig().getPrefix() + "§cFailed to get skin from Mojang.");
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(NickoBukkit.getInstance().getNickoConfig().getPrefix() + "§cFailed to get username from Mojang. Does the user exists?");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
player.sendMessage(NickoBukkit.getInstance().getNickoConfig().getPrefix() + "§cAn error occurred.");
|
||||
} catch (ExecutionException e) {
|
||||
player.sendMessage(NickoBukkit.getInstance().getNickoConfig().getPrefix() + "§cFailed to get skin from cache.");
|
||||
}
|
||||
}
|
||||
|
||||
add.b().clear();
|
||||
add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile,
|
||||
player.getPing(),
|
||||
EnumGamemode.a(player.getGameMode().ordinal()), IChatBaseComponent.a(profile.getName())));
|
||||
entityPlayer.b.a(add);
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(online -> {
|
||||
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
|
||||
onlineEntityPlayer.b.a(remove);
|
||||
onlineEntityPlayer.b.a(add);
|
||||
});
|
||||
updateOthers(player);
|
||||
}
|
||||
}
|
BIN
v1_18_R1/target/classes/net/artelnatif/impl/v1_18_R1.class
Normal file
BIN
v1_18_R1/target/classes/net/artelnatif/impl/v1_18_R1.class
Normal file
Binary file not shown.
5
v1_18_R1/target/maven-archiver/pom.properties
Normal file
5
v1_18_R1/target/maven-archiver/pom.properties
Normal file
|
@ -0,0 +1,5 @@
|
|||
#Generated by Maven
|
||||
#Thu Oct 13 10:30:56 CEST 2022
|
||||
groupId=net.artelnatif
|
||||
artifactId=nicko-v1_18_R1
|
||||
version=1.0-SNAPSHOT
|
|
@ -0,0 +1 @@
|
|||
net/artelnatif/impl/v1_18_R1.class
|
|
@ -0,0 +1 @@
|
|||
/home/aro/IdeaProjects/Nicko/v1_18_R1/src/main/java/net/artelnatif/impl/v1_18_R1.java
|
BIN
v1_18_R1/target/nicko-v1_18_R1-1.0-SNAPSHOT.jar
Normal file
BIN
v1_18_R1/target/nicko-v1_18_R1-1.0-SNAPSHOT.jar
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue