Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.mojang.authlib.GameProfile;
- import net.minecraft.server.v1_8_R3.*;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
- import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
- import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
- import org.bukkit.entity.Player;
- /**
- * @author VINETOS on 26/10/2015.
- */
- public class FakePlayer {
- private String name;
- private EntityPlayer ep;
- public FakePlayer(String name){
- this.name = name;
- }
- public void spawn(Player p){
- MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
- WorldServer world = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle();
- EntityPlayer npc = new EntityPlayer(server, world, new GameProfile(p.getUniqueId(), name), new PlayerInteractManager(world));
- Location loc = p.getLocation();
- npc.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
- for(Player pls : Bukkit.getOnlinePlayers()){
- PlayerConnection connection = ((CraftPlayer)pls).getHandle().playerConnection;
- connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc));
- connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
- }
- ep = npc;
- }
- public void dispawn(){
- for(Player pls : Bukkit.getOnlinePlayers()){
- PlayerConnection connection = ((CraftPlayer)pls).getHandle().playerConnection;
- connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, ep));
- connection.sendPacket(new PacketPlayOutEntityDestroy(new int[]{ep.getId()}));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment