25.04.2016, 13:16
@mk124 I've been trying to diagnose that null pointer exception on my own by adding some custom debug prints to shoebill-api... Here's what I added:
Resource.java:
My plugin onEnable:
Output
And I must say, this makes no sense...
Resource.java:
Код:
protected void enable() throws Throwable { System.out.println("Resource:enable rootEventManager:" + rootEventManager); this.eventManager = rootEventManager.createChildNode(); System.out.println("Resource:enable eventManager: "+ eventManager); System.out.println("Resource:enable getEventManager:" + getEventManager()); onEnable(); isEnabled = true; ResourceEnableEvent event = new ResourceEnableEvent(this); eventManager.dispatchEvent(event, getEventManager(), this); }
Код:
@Override public void onEnable() throws Throwable { Instance.instance = this; this.vehicles = new ArrayList<>(); this.maxSpeeds = new HashMap<>(); this.random = new Random(); this.vehicleEngineTimers = new HashMap<>(); if(getEventManager() == null) logger.error("How can it be null?"); // this.eventManager = getEventManager().createChildNode(); if(Shoebill.get().getResourceManager().getPlugin(DatabasePlugin.class) != null) { System.out.println("Database plugin is loaded..."); load(); } else { eventManager.registerHandler(ResourceEnableEvent.class, e -> { if(e.getResource().getClass().equals(DatabasePlugin.class)) { load(); } }); } } private void load() { System.out.println("Is it still null? " + getEventManager()); this.eventManager = getEventManager().createChildNode(); // This is line 82 of file VehiclePlugin.java: the null pointer exception originates here. // Stuff that I commented out logger.info("Vehicle manager initialized"); }
Код:
2016-04-25 16:15:24,170 INFO [out] - Resource:enable rootEventManager:net.gtaun.util.event.EventManagerRoot@94f96a 2016-04-25 16:15:24,171 INFO [out] - Resource:enable eventManager: net.gtaun.util.event.EventManagerChild@7e20cf 2016-04-25 16:15:24,171 INFO [out] - Resource:enable getEventManager:null 2016-04-25 16:15:24,171 ERROR [VehiclePlugin] - How can it be null? 2016-04-25 16:15:24,171 INFO [out] - Database plugin is loaded... 2016-04-25 16:15:24,172 INFO [out] - Is it still null? null 2016-04-25 16:15:24,172 ERROR [err] - java.lang.NullPointerException 2016-04-25 16:15:24,172 ERROR [err] - at lt.ltrp.VehiclePlugin.load(VehiclePlugin.java:82)