danik159

Untitled

Aug 10th, 2019
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. package com.chickenstyle.npc;
  2.  
  3. import java.util.UUID;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
  7. import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
  8. import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
  9. import org.bukkit.event.EventHandler;
  10. import org.bukkit.event.Listener;
  11. import org.bukkit.event.player.PlayerJoinEvent;
  12. import org.bukkit.plugin.java.JavaPlugin;
  13.  
  14. import com.mojang.authlib.GameProfile;
  15.  
  16. import net.minecraft.server.v1_14_R1.EntityPlayer;
  17. import net.minecraft.server.v1_14_R1.PacketPlayOutNamedEntitySpawn;
  18. import net.minecraft.server.v1_14_R1.PacketPlayOutPlayerInfo;
  19. import net.minecraft.server.v1_14_R1.PlayerConnection;
  20. import net.minecraft.server.v1_14_R1.PlayerInteractManager;
  21.  
  22. // -177 41 216 -137.5 7.1
  23.  
  24. public class Main extends JavaPlugin implements Listener {
  25. EntityPlayer npc;
  26. //-177 41 216 138 6
  27. public void onEnable() {
  28. Bukkit.getPluginManager().registerEvents(this, this);
  29. npc = new EntityPlayer(
  30. ((CraftServer) Bukkit.getServer()).getServer(),
  31. ((CraftWorld) Bukkit.getWorld("world")).getHandle(),
  32. new GameProfile(UUID.fromString("5f18003a-0428-43e8-86c7-ae22d73105ab"), "§6§lBob"),
  33. new PlayerInteractManager(((CraftWorld) Bukkit.getWorld("world")).getHandle()));
  34. npc.setLocation(-176.5,41.0,216.5, -138 ,0);
  35. }
  36. @EventHandler
  37. public void onJoin(PlayerJoinEvent e) {
  38. PlayerConnection connection = ((CraftPlayer) e.getPlayer()).getHandle().playerConnection;
  39.  
  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.  
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment