Seite 1 von 1

FakePlayer PlayerInfoData

BeitragVerfasst: Mo 20. Nov 2017, 18:57
von BigJoys
Hallo,
und zwar hab ich seit dem Update auf die 1.12.2 den Fehler das ich beim Exporten meines Systems den Fehler bekomme, dass ich die Spieler nicht mehr sehe. Oder aus dem Server gekickt werde. Hoffe mir kann geholfen werden.

Code: Alles auswählen
  1.         private final int entityID;
  2.         private Location location;
  3.         private static GameProfile gameprofile;
  4.        
  5.        
  6.         public FakePlayer(UUID uuid, String NPCname, int entID , Location location){
  7.                 entityID = entID + 20000;
  8.                 gameprofile = new GameProfile(uuid, NPCname);
  9.                 changeSkin();
  10.                 this.location = location;
  11.         }
  12.        
  13.         public static GameProfile getGameprofile(UUID uuid, String NPCname) {
  14.             gameprofile = new GameProfile(uuid, NPCname);
  15.             changeSkin();
  16.             return gameprofile;
  17.         }
  18.        
  19.         private static void changeSkin(){
  20.            String value = "value...";
  21.            String signature = "signature ...";
  22.            gameprofile.getProperties().put("textures", new Property("textures", value, signature));
  23.         }
  24.        
  25.         public void spawn(){
  26.                 PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn();
  27.                
  28.                 setValue(packet, "a", entityID);
  29.                 setValue(packet, "b", gameprofile.getId());
  30.                 setValue(packet, "c", getFixLocation(location.getX()));
  31.                 setValue(packet, "d", getFixLocation(location.getY()));
  32.                 setValue(packet, "e", getFixLocation(location.getZ()));
  33.                 setValue(packet, "f", getFixRotation(location.getYaw()));
  34.                 setValue(packet, "g", getFixRotation(location.getPitch()));
  35.                 DataWatcher w = new DataWatcher(null);
  36.                 w.register(new DataWatcherObject<>(6, DataWatcherRegistry.c), (float)20F);
  37.                 w.register(new DataWatcherObject<>(10, DataWatcherRegistry.a), (byte)127F);
  38.                 setValue(packet, "h", w);
  39.                 addToTablist();
  40.                 sendPacket(packet);
  41.                 headRotation(location.getYaw(), location.getPitch());
  42.                
  43.                 new BukkitRunnable() {
  44.                     @Override
  45.                 public void run() {
  46.                        rmvFromTablist();
  47.                     }
  48.                 }.runTaskLater(Core.getInstance(),10);
  49.         }
  50.        
  51.         public void spawn1(){
  52.             PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn();
  53.            
  54.           setValue(packet, "a", entityID);
  55.             setValue(packet, "b", gameprofile.getId());
  56.             setValue(packet, "c", location.getX());
  57.             setValue(packet, "d", location.getY());
  58.             setValue(packet, "e", location.getZ());
  59.             setValue(packet, "f", (byte)(int)(location.getYaw() * 256.0F / 360.0F));
  60.             setValue(packet, "g", (byte)(int)(location.getPitch() * 256.0F / 360.0F));
  61.            
  62.             DataWatcher watcher = new DataWatcher(null);
  63.             watcher.register(new DataWatcherObject<>(6, DataWatcherRegistry.c), 20F);
  64.             watcher.register(new DataWatcherObject<>(10, DataWatcherRegistry.a), (byte)127);
  65.             setValue(packet, "h", watcher);
  66.             addToTablist();
  67.             sendPacket(packet);
  68.             headRotation(location.getYaw(), location.getPitch());
  69.            
  70.             new BukkitRunnable() {
  71.                 @Override
  72.             public void run() {
  73.                    rmvFromTablist();
  74.                 }
  75.             }.runTaskLater(Core.getInstance(),10);
  76.        }
  77.        
  78.         public void destroy(int entityID){
  79.             PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(entityID);
  80.             rmvFromTablist();
  81.             sendPacket(packet);
  82.     }
  83.        
  84.         private void headRotation(float yaw, float pitch){
  85.             PacketPlayOutEntityLook packet = new PacketPlayOutEntityLook(entityID, (getFixRotation(yaw)), (getFixRotation(pitch)) , true);
  86.             PacketPlayOutEntityHeadRotation packetHead = new PacketPlayOutEntityHeadRotation();
  87.             setValue(packetHead, "a", entityID);
  88.             setValue(packetHead, "b", getFixRotation(yaw));
  89.            
  90.             sendPacket(packet);
  91.             sendPacket(packetHead);
  92.     }
  93.        
  94.         private void addToTablist(){
  95.                 PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
  96.                 PacketPlayOutPlayerInfo.PlayerInfoData data = packet.new PlayerInfoData(gameprofile, 1, EnumGamemode.NOT_SET, CraftChatMessage.fromString(null)[0]);
  97.                 @SuppressWarnings("unchecked")
  98.             List<PacketPlayOutPlayerInfo.PlayerInfoData> players = (List<PacketPlayOutPlayerInfo.PlayerInfoData>) getValue(packet, "b");
  99.                 players.add(data);
  100.                
  101.                 setValue(packet, "a", EnumPlayerInfoAction.ADD_PLAYER);
  102.                 setValue(packet, "b", players);
  103.                
  104.                 sendPacket(packet);
  105.         }
  106.        
  107.         private void rmvFromTablist(){
  108.                 PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
  109.                 PacketPlayOutPlayerInfo.PlayerInfoData data = packet.new PlayerInfoData(gameprofile, 1, EnumGamemode.NOT_SET, CraftChatMessage.fromString(null)[0]);
  110.                 @SuppressWarnings("unchecked")
  111.                 List<PacketPlayOutPlayerInfo.PlayerInfoData> players = (List<PacketPlayOutPlayerInfo.PlayerInfoData>) getValue(packet, "b");
  112.                 players.add(data);
  113.                
  114.                 setValue(packet, "a", EnumPlayerInfoAction.REMOVE_PLAYER);
  115.                 setValue(packet, "b", players);
  116.                
  117.                 sendPacket(packet);
  118.         }