#API Problem

25 messages · Page 1 of 1 (latest)

honest bane
#

Hey, I'm creating a Vehicle using

ItemStack vehicle = VehicleUtils.createAndGetItemByUUID(player, "UUID");

and spawning it with:

ItemStack item = event.getCurrentItem(); # Clicked Item (The Vehicle ItemStack)
Vehicle vehicle = VehicleUtils.getVehicle(item);
String license = vehicle.getLicensePlate();
VehicleUtils.spawnVehicle(license, location, event.getWhoClicked().getLocation()));
VehicleUtils.enterVehicle(license, (Player) event.getWhoClicked());

and returns this error:

[06:16:10] [Server thread/ERROR]: Could not pass event InventoryClickEvent to NLVehicles v1.0.0
java.lang.NullPointerException: Cannot invoke "nl.mtvehicles.core.infrastructure.vehicle.Vehicle.getLicensePlate()" because "vehicle" is null
    at me.xii69.nlvehicles.listener.InventoryClickListener.onInventoryClick(InventoryClickListener.java:62) ~[NLVehicles-1.0.0.jar:?]

the line 62 which causes this error is:

String license = vehicle.getLicensePlate();
#

Also to be more clear about

event.getCurrentItem();

i'm making sure its a valid vehicle with this check:

if (item != null && item.getType() == Material.DIAMOND_HOE) { ... }
honest bane
#

@analog ice sorry for pinging you but i've to

frail hollow
honest bane
#

i just replaced it with UUID

#

NLP is a valid vehicle

#

wait

#

i just updated the last night

#

where are my vehicles

#

shit i deleted the archieved backup files

frail hollow
honest bane
#

well there is no vehicle to spawn then

#

i've to create all of them again

#

thanks for support

honest bane
#

I'm creating a NBTItem for my Parking plugin so I can have a Vehicle ItemStack
this is the NBTItem:

NBTItem item = new NBTItem(VehicleUtils.getItemByLicensePlate(playerVehicles.get(index)));
item.setString("mtvehicles.kenteken", playerVehicles.get(index));

playerVehicles is a valid list of player vehicle's licenses
when i try to spawn it like this:

ItemStack item = event.getCurrentItem();
            if (item != null && item.getType() == Material.DIAMOND_HOE) {
                String license = VehicleUtils.getLicensePlate(item);
                VehicleUtils.spawnVehicle(
                        license,
                        Utils.findNearestLocation(LocationManager.getParkingSpawnPoints(), event.getWhoClicked().getLocation())
                );
                VehicleUtils.enterVehicle(license, (Player) event.getWhoClicked());
                event.getView().close();
            }

this happens:

Caused by: java.lang.NullPointerException: ItemStack can't be null/air/amount of 0! This is not a NBTAPI bug!
    at nl.mtvehicles.core.infrastructure.libs.nbtapi.NBTItem.<init>(NBTItem.java:84) ~[MTVehicles.jar:?]
    at nl.mtvehicles.core.infrastructure.libs.nbtapi.NBTItem.<init>(NBTItem.java:40) ~[MTVehicles.jar:?]
    at me.xii69.nlvehicles.gui.ParkingGUI.getParkingGUI(ParkingGUI.java:32) ~[NLVehicles-1.0.0.jar:?]
    at me.xii69.nlvehicles.command.ParkingCommand.onCommand(ParkingCommand.java:16) ~[NLVehicles-1.0.0.jar:?]
#

also Hi

#

this was working in the previous versions of mtv. i don't know when and what have been changed

#

also the NBTItem class of MTV shows that this check causes the problem which i think my itemstack is fine:

if (item != null && item.getType() != Material.AIR && item.getAmount() > 0) {
   ...
} else {
throw new NullPointerException("ItemStack can't be null/air/amount of 0! This is not a NBTAPI bug!");
}
#

ping me on respond thanks

honest bane
#

i searched in the code for a while and i found out you already add the mtvehicles.kenteken nbt, lemme try without my nbt codes and just give the inventory click listener MTV provided itemstack

honest bane
#

i found the problem

#

VehicleUtils#getItemByLicensePlate generates a new license plate for the vehicle which it doesn't exist