Protocollib latest 1.9 / Datawatcher npe

Discussion in 'Spigot Plugin Development' started by sinnlosername, Jun 17, 2016.

  1. Hey,

    I'm trying to create a datawatcher for a fake player / npc.
    The problem is, I'm getting a NullPointerException in line 414 (See the arrow)

    Code (Text):

            dataWatcher = new WrappedDataWatcher();
            ---> /*Right there / BitMask isn't null, I checked it*/ dataWatcher.getWatchableObject(0).setValue(generateBitMask());
            dataWatcher.getWatchableObject(1).setValue(20);
            dataWatcher.getWatchableObject(2).setValue(username);
            dataWatcher.getWatchableObject(3).setValue(true);
            dataWatcher.getWatchableObject(4).setValue(silent);
            dataWatcher.getWatchableObject(5).setValue(0x01);
            dataWatcher.getWatchableObject(6).setValue(health);
            dataWatcher.getWatchableObject(7).setValue(0);
            dataWatcher.getWatchableObject(8).setValue(0);
            dataWatcher.getWatchableObject(9).setValue(0);
            dataWatcher.getWatchableObject(10).setValue(0);
            dataWatcher.getWatchableObject(11).setValue(NPCLib.getRdm().nextInt(10000));
            dataWatcher.getWatchableObject(12).setValue(0x00); // Skin flags
            dataWatcher.getWatchableObject(13).setValue(0x01);
     
    Protocollib Version: Version for 1.9

    Thanks in Advance!
     
    • Agree Agree x 1
  2. Like:
    Code (Text):
        private void set(int index, WrappedDataWatcher watcher, Object value) {
            if (dataWatcher.hasIndex(index))
                watcher.getWatchableObject(index).setValue(value);
            else
                watcher.setObject(index, value);
        }
    ?