BananaPuncher714 / NBTEditor

A single class NBT editor for items, skulls, mobs, and tile entities
MIT License
136 stars 30 forks source link

Cannot invoke "Object.getClass()" because "obj" is null #25

Closed DexterSK closed 1 year ago

DexterSK commented 1 year ago

[22:21:52 WARN]: java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "obj" is null [22:21:52 WARN]: at java.base/java.lang.reflect.Method.invoke(Method.java:561) [22:21:52 WARN]: at Cardinal-1.0.jar//sk.DexterSK.Cardinal.utilz.NBTEditor.getCompound(NBTEditor.java:807) [22:21:52 WARN]: at Cardinal-1.0.jar//sk.DexterSK.Cardinal.utilz.NBTEditor.getBlockTag(NBTEditor.java:784) [22:21:52 WARN]: at Cardinal-1.0.jar//sk.DexterSK.Cardinal.utilz.NBTEditor.getValue(NBTEditor.java:942) [22:21:52 WARN]: at Cardinal-1.0.jar//sk.DexterSK.Cardinal.utilz.NBTEditor.contains(NBTEditor.java:1151)

BananaPuncher714 commented 1 year ago

Can you show your code? And are you sure the object that you are passing to NBTEditor is not null?

DexterSK commented 1 year ago

` @EventHandler( priority=EventPriority.LOW ) public void onBlockPlace( BlockPlaceEvent event ) { Player player = event.getPlayer(); Block block = event.getBlock(); EquipmentSlot hand = event.getHand();

    if( config.getBoolean( "VoteParty.Enable" ) )
    {
        if( block == null )
            return;

        if( hand == EquipmentSlot.HAND )
        {
            //if( NBTEditor.contains( block, "VotePartyCrate" ) )
            if( NBTEditor.getBoolean( block, "VotePartyCrate" ) )
            {
                if( config.getBoolean("VoteParty.GuaranteedRewards.Enabled", true) )
                    for( String command : config.getStringList("VoteParty.GuaranteedRewards.Commands") )
                        Bukkit.dispatchCommand( Bukkit.getConsoleSender(), StringUtils.setPlaceholders( player, command.replace("%player_name%", player.getName() ) ) );

                block.setType( Material.AIR );
            }
        }
    }
}```

EDIT:

i will try it in PlayerInteractEvent

DexterSK commented 1 year ago

It works, my bad, sorry for bothering you