我正在尝试创建一个发送包含虚假实体的数据包的插件。 此外,我希望虚假实体能够在玩家看起来的位置后不断传送。
故障:
我的代码:
package com.gmail.apply55gx.UltimateAntiCheat.Packets;
public class PacketsCore implements Listener{
private EntityPlayer npc;
Player GhostPlayer;
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
WorldServer world = ((CraftWorld)Bukkit.getServer().getWorlds().get(0)).getHandle();
@EventHandler
public void Join(PlayerJoinEvent event){
Random r = new Random();
ArrayList<Player> RandomGhostPlayer = new ArrayList<Player>();
for(Player online : Bukkit.getServer().getOnlinePlayers()) {
RandomGhostPlayer.add(online);
}
int index = r.nextInt(RandomGhostPlayer.size());
GhostPlayer = (Player) RandomGhostPlayer.get(index);
npc = new EntityPlayer(server, world, new GameProfile(GhostPlayer.getUniqueId(), GhostPlayer.getName()), new PlayerInteractManager(world));
//NPC
npc.teleportTo(event.getPlayer().getEyeLocation().add(0,2,0),false);
PlayerConnection connection = ((CraftPlayer) event.getPlayer()).getHandle().playerConnection;
connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc));
connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
}
@EventHandler
public void move(PlayerMoveEvent event){
Player p = event.getPlayer();
try {
npc.teleportTo((p.getLocation().add(0,3,0)),false);
PlayerConnection connection = ((CraftPlayer) event.getPlayer()).getHandle().playerConnection;
connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc));
connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
npc.setLocation(p.getLocation().getX(),p.getLocation().getY() + 3,p.getLocation().getZ(),p.getLocation().getDirection().getBlockX(),p.getLocation().getDirection().getBlockY());
}catch (Exception e){}
p.sendMessage("tp");
}
}
我的错误:
19:19:10 [FATAL] Error executing task
19:19:10 java.util.concurrent.ExecutionException: java.lang.NullPointerException
19:19:10 at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_65]
19:19:10 at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_65]
19:19:10 at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:45) [craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:10 at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:10 at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:10 at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:10 at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:10 at java.lang.Thread.run(Thread.java:745) [?:1.8.0_65]
19:19:10 Caused by: java.lang.NullPointerException
19:19:10 at net.minecraft.server.v1_8_R3.WorldServer.sendParticles(WorldServer.java:1179) ~[craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:10 at net.minecraft.server.v1_8_R3.EntityLiving.a(EntityLiving.java:152) ~[craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:10 at net.minecraft.server.v1_8_R3.EntityPlayer.a(EntityPlayer.java:621) ~[craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:10 at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:456) ~[craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:10 at net.minecraft.server.v1_8_R3.PacketPlayInFlying.a(SourceFile:126) ~[craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:10 at net.minecraft.server.v1_8_R3.PacketPlayInFlying.a(SourceFile:8) ~[craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:10 at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) ~[craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:10 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_65]
19:19:10 at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_65]
19:19:10 at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) ~[craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:10 ... 5 more
19:19:10 [FATAL] Error executing task
19:19:10 java.util.concurrent.ExecutionException: java.lang.NullPointerException
19:19:11 at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_65]
19:19:11 at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_65]
19:19:11 at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:45) [craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:11 at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:11 at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:11 at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:11 at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:11 at java.lang.Thread.run(Thread.java:745) [?:1.8.0_65]
19:19:11 Caused by: java.lang.NullPointerException
19:19:11 at net.minecraft.server.v1_8_R3.WorldServer.sendParticles(WorldServer.java:1179) ~[craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:11 at net.minecraft.server.v1_8_R3.EntityLiving.a(EntityLiving.java:152) ~[craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:11 at net.minecraft.server.v1_8_R3.EntityPlayer.a(EntityPlayer.java:621) ~[craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:11 at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:456) ~[craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:11 at net.minecraft.server.v1_8_R3.PacketPlayInFlying.a(SourceFile:126) ~[craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:11 at net.minecraft.server.v1_8_R3.PacketPlayInFlying.a(SourceFile:8) ~[craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:11 at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) ~[craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:11 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_65]
19:19:11 at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_65]
19:19:11 at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) ~[craftbukkit.jar:git-Spigot-db6de12-18fbb24]
19:19:11 ... 5 more
屏幕上发生了什么:
答案 0 :(得分:0)
如果您想创建和移动假玩家,请查看ProtocolLib和PacketWrappers。此外,您还可以找到FakePlayer here的开源实现。
编辑:由于您可能正在编写反热编程,请查看Killaura-Bot-Check。