AuraCheck feature

Discussion in 'Plugin Development' started by Lusberd, Feb 28, 2017.

Thread Status:
Not open for further replies.
  1. Offline

    Lusberd

    Im coding a new plugin and im coding a AuraCheck this feature spawn a bot around the player and give a message if the player hit the bot, but the bot spawn only with the 1.7.10 and with 1.8 not work.
    This feature use a protocolLib help me plis guys
     
  2. Online

    timtower Administrator Administrator Moderator

  3. Offline

    Lusberd

    There isn't error bro

    Code:
    public void spawn()
      {
        for (int i = 0; i < numeroPlayerFake; i++)
        {
          WrapperPlayServerNamedEntitySpawn wrapper = getWrapper(check.getLocation().add(vectors[i]).toVector(),
            Main.instance);
          entitiesSpawned.put(Integer.valueOf(wrapper.getEntityID()), Boolean.valueOf(false));
          wrapper.sendPacket(check);
        }
        Bukkit.getScheduler().runTaskLater(Main.instance, new Runnable()
        {
          public void run()
          {
            AbstractMap.SimpleEntry result = CheckAura.this.stop();
           
            Main.instance.remove(CheckAura.check);
            if (((CheckAura.this.controllore instanceof Player)) && (!CheckAura.this.controllore.isOnline())) {
              return;
            }
            CheckAura.this.controllore.sendMessage("§cThe player §7" +check.getName() + " §chave killed §7" + result.getKey() + "§c bots on §7" + result.getValue());
          }
        }, 25L);
      }
     
      protected AbstractMap.SimpleEntry stop()
      {
        int killed = 0;
        for (Map.Entry<Integer, Boolean> entry : entitiesSpawned.entrySet()) {
          if (((Boolean)entry.getValue()).booleanValue()) {
            killed++;
          } else if (check.isOnline()) {
            kill(((Integer)entry.getKey()).intValue()).sendPacket(check);
          }
        }
        int amount = entitiesSpawned.size();
        entitiesSpawned.clear();
        return new AbstractMap.SimpleEntry(Integer.valueOf(killed), Integer.valueOf(amount));
      }
     
      private static AbstractPacket kill(int entity)
      {
        WrapperPlayServerEntityDestroy wrapper = new WrapperPlayServerEntityDestroy();
        wrapper.setEntities(new int[] { entity });
        return wrapper;
      }
     
      public String getState()
      {
        return null;
      }
     
      public static void onKill(Integer valore)
      {
        if (entitiesSpawned.containsKey(valore))
        {
          entitiesSpawned.put(valore, Boolean.valueOf(true));
          kill(valore.intValue()).sendPacket(check);
        }
      }
     
      public static WrapperPlayServerNamedEntitySpawn getWrapper(Vector loc, Main plugin)
      {
        WrapperPlayServerNamedEntitySpawn wrapper = new WrapperPlayServerNamedEntitySpawn();
        wrapper.setEntityID(new Random().nextInt(20000));
        wrapper.setPosition(loc);
        wrapper.setPlayerUUID(UUID.randomUUID().toString());
        byte[] array = new byte[10];
        new Random().nextBytes(array);
        String name = new String(array, Charset.forName("UTF-8"));
        wrapper.setPlayerName("TEST");
        wrapper.setYaw(0.0F);
        wrapper.setPitch(-45.0F);
        WrappedDataWatcher watcher = new WrappedDataWatcher();
        watcher.setObject(6, Float.valueOf(0.5F));
        watcher.setObject(11, Byte.valueOf((byte)1));
        wrapper.setMetadata(watcher);
        return wrapper;
      }
    }
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
  4. Online

    timtower Administrator Administrator Moderator

  5. Offline

    Lusberd

    Bro there isn't a error the console is clean
     
  6. Online

    timtower Administrator Administrator Moderator

    @Lusberd Then how is it not working?
     
  7. Offline

    Lusberd

    The plugin spawn a fake bot around the player but with the 1.7.10 it work and spawn the bot, and with 1.8 bit work not spawn a bot
     
  8. Offline

    Zombie_Striker

    @Lusberd
    First, why are you still on 1.7? That came out almost four years ago. Please read this thread.

    Have you debugged? Is the spawned entity null? Is it an issue with the packets being sent (1.8 may have had different packet requirements than 1.7)?
     
  9. Offline

    Lusberd

    Bro I use paperspigot 1.7.x/ 1.8.x and the plugin work but spawn a fake bot only in 1.7 i think a error of 1.8 how i solve it? I think the error is in the packet
     
  10. Offline

    Zombie_Striker

    @Lusberd
    That is why. First, I don't think bukkit supports servers that supports multiple version, (@timtower ) so this thread should be locked.

    Not only that, but you are receiving this problem because you are using 1.7/1.8 As I posted before, Mojang changed the packets between 1.7 and 1.8, so there is no way to use certain packets for those updates. To fix this, do not use 1.7/1.8 servers and update to 1.11. Again, read the thread above or in my signature.
     
  11. Online

    timtower Administrator Administrator Moderator

    Locked
    Protocol hacks are not supported by Bukkit
     
Thread Status:
Not open for further replies.

Share This Page