Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.90 KB | None | 0 0
  1. GameProfile gameProfile = new GameProfile(UUID.fromString("0a2b7487-fa7b-4f48-b00f-106356c6e836"), "skin696561374");
  2.             gameProfile.getProperties().removeAll("textures");
  3.             gameProfile.getProperties().put("textures", new Property("textures", "eyJ0aW1lc3RhbXAiOjE1ODY0NDM1NjAwNzgsInByb2ZpbGVJZCI6IjgyYzYwNmM1YzY1MjRiNzk4YjkxYTEyZDNhNjE2OTc3IiwicHJvZmlsZU5hbWUiOiJOb3ROb3RvcmlvdXNOZW1vIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS82ODc0NjEyMWI1OWEzODY2NzM4N2Q4OTRiMzczMjYwYWY5MzU1OGIwOTY2YzdiZWRmODAzZTExNDBmZmIyYWE2IiwibWV0YWRhdGEiOnsibW9kZWwiOiJzbGltIn19fX0=", "AVnFmYfgysy4OXmrW3PlVkIhPY/b+Ma3Re544q0hsRpRpSyZm7v4+7gbeaS8NmyiETt1X2TX2NfniVJ5TcKf6BLOKjEXep1FZ+uTZk39rL0dH/vi/ysZwnVBTnpzRrVBNMFN3VjmNb9CrNPR1Djp9q2b0jKJSQ2xMM1Ek4AsooE9BGGdR6HNtHVzYBHEaRl51L+iIOZNSVA3wjw6Ko1wjiMqq7hKm0+TV5UqP7gnvIQ+ck29YkgRGZ/O8d6MHhWXxaxokIbIfJKmvNo4Evepxsc6k/MW0kWnXM0BKsCXjRi/MPbJBbVwtlaIZ1JSO83YPVobhRXsV1n9NqXG2SsrbRIPqyx5ee570CyghTXzxZFj4JGpqKAaEGT5QjyUcioaO0FzF/S+kANAaLk8Ni69LqMQrzXY0p4MMEToVIctAiWzwfJ6yt1aji/CO3zXNdhoCAU1CTiHq2ji02SJoVdJg8GzpxuQ1ezwa1ZByzCVFTOIHvHA2EHKQ23ZXx9u3cDRLF3en51aYKz1XrbEgWCjbSUfN3RxW43i9478/JgvT1e5q8W+2Lb5edodvEqZql6iCukTya5b4nxqda2cXflKET7x7gkkU6tReQoRyvthkdmxTY3F0h73RmphH3oIJGr1zNX8LR1gPJ/sw4eegnxxqAl/aYWqgq8hUX5QgjmCvRE="));
  4.  
  5. spawnNPC(bwTeam.getStuffPNJLocation(), gameProfileStuff);
  6. spawnNPC(bwTeam.getUpgradePNJLocation(), gameProfile);
  7.  
  8. public void spawnNPC(Location location, GameProfile gameProfile) {
  9.         NPC npc = new NPC(location, gameProfile);
  10.         Bukkit.getOnlinePlayers().forEach(npc::sendNpcToPlayer);
  11. }
  12.  
  13.  
  14. public class NPC {
  15.  
  16.     private Location location;
  17.     private String name;
  18.     private EntityPlayer npc;
  19.  
  20.     public NPC(Location location, GameProfile gameProfile) {
  21.  
  22.         this.location = location;
  23.  
  24.         MinecraftServer nmsServer = ((CraftServer) Bukkit.getServer()).getServer();
  25.         WorldServer nmsWorld = ((CraftWorld) location.getWorld()).getHandle();
  26.         PlayerInteractManager pim = new PlayerInteractManager(nmsWorld);
  27.  
  28.         npc = new EntityPlayer(nmsServer, nmsWorld, gameProfile, new PlayerInteractManager(nmsWorld));
  29.         Player npcPlayer = npc.getBukkitEntity().getPlayer();
  30.         npcPlayer.setPlayerListName("");
  31.  
  32.         npc.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
  33.  
  34.         npc.setInvulnerable(true);
  35.  
  36.     }
  37.  
  38.     public void sendNpcToPlayer(Player player) {
  39.         PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
  40.         connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc));
  41.         connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
  42.         connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, npc));
  43.     }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement