SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 24/04/2016, 05:54 PM   #831
mk124
Huge Clucker
 
mk124's Avatar
 
Join Date: Jul 2007
Location: Nanning, China
Posts: 319
Reputation: 59
Default Re: [UPDATE][SNAPSHOT][Java 8] Shoebill 1.1 - SA-MP Java Development Kit

@Su37Erich: The getCommand() problem should be fixed with this commit:https://github.com/Shoebill/shoebill...d0bb20af04eeea

And the Timer problem can be fixed with this: https://github.com/Shoebill/shoebill...6a05c17af93600

You can create TemporaryTimers with TemporaryTimer.create(). You don't need to assign a variable to it, just call start() and it will be automatically deleted when it has stopped running.

The new artifact should be in the repository now.
__________________
mk124 is offline   Reply With Quote
Old 25/04/2016, 01:16 PM   #832
dusk
High-roller
 
dusk's Avatar
 
Join Date: Jul 2008
Posts: 1,113
Reputation: 46
Default Re: [UPDATE][SNAPSHOT][Java 8] Shoebill 1.1 - SA-MP Java Development Kit

@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:

Code:
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);
	}
My plugin onEnable:
Code:
@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");

    }
Output
Code:
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)
And I must say, this makes no sense...
dusk is offline   Reply With Quote
Old 25/04/2016, 01:40 PM   #833
mk124
Huge Clucker
 
mk124's Avatar
 
Join Date: Jul 2007
Location: Nanning, China
Posts: 319
Reputation: 59
Default Re: [UPDATE][SNAPSHOT][Java 8] Shoebill 1.1 - SA-MP Java Development Kit

@dusk: This really makes no sense. Is this occurring only when using a specific plugin? Can you add some debug messages in the disable() method, because it is the only place where the eventManager will be set to null.
__________________
mk124 is offline   Reply With Quote
Old 25/04/2016, 02:02 PM   #834
dusk
High-roller
 
dusk's Avatar
 
Join Date: Jul 2008
Posts: 1,113
Reputation: 46
Default Re: [UPDATE][SNAPSHOT][Java 8] Shoebill 1.1 - SA-MP Java Development Kit

Ahhh I figured it out, as always my stupidity is the answer. A while ago I changed that class to extend Resource but I forgot that it had a method getEventManager which overrode getEventManager in Resource.
dusk is offline   Reply With Quote
Old 25/04/2016, 02:15 PM   #835
mk124
Huge Clucker
 
mk124's Avatar
 
Join Date: Jul 2007
Location: Nanning, China
Posts: 319
Reputation: 59
Default Re: [UPDATE][SNAPSHOT][Java 8] Shoebill 1.1 - SA-MP Java Development Kit

@dusk: Ok, I honestly didn't think it was a bug in Shoebill's code
__________________
mk124 is offline   Reply With Quote
Old 25/04/2016, 02:23 PM   #836
dusk
High-roller
 
dusk's Avatar
 
Join Date: Jul 2008
Posts: 1,113
Reputation: 46
Default Re: [UPDATE][SNAPSHOT][Java 8] Shoebill 1.1 - SA-MP Java Development Kit

Neither did I, but I was all out of ideas..

Anyway new issue. How come shoebill-updater.jar doesn't download shoebill-launcher 1.3?
dusk is offline   Reply With Quote
Old 25/04/2016, 02:25 PM   #837
mk124
Huge Clucker
 
mk124's Avatar
 
Join Date: Jul 2007
Location: Nanning, China
Posts: 319
Reputation: 59
Default Re: [UPDATE][SNAPSHOT][Java 8] Shoebill 1.1 - SA-MP Java Development Kit

@dusk: I'm sorry, I forgot to upload it.
__________________
mk124 is offline   Reply With Quote
Old 25/04/2016, 02:33 PM   #838
dusk
High-roller
 
dusk's Avatar
 
Join Date: Jul 2008
Posts: 1,113
Reputation: 46
Default Re: [UPDATE][SNAPSHOT][Java 8] Shoebill 1.1 - SA-MP Java Development Kit

Seems you forgot the plugin too!
dusk is offline   Reply With Quote
Old 25/04/2016, 02:35 PM   #839
mk124
Huge Clucker
 
mk124's Avatar
 
Join Date: Jul 2007
Location: Nanning, China
Posts: 319
Reputation: 59
Default Re: [UPDATE][SNAPSHOT][Java 8] Shoebill 1.1 - SA-MP Java Development Kit

@dusk: Oh, then the 1.3-SNAPSHOT isn't ready for deployment yet, but I will upload it, because I think it should be stable.

//Edit: Uploaded.
__________________
mk124 is offline   Reply With Quote
Old 25/04/2016, 04:12 PM   #840
Su37Erich
Huge Clucker
 
Su37Erich's Avatar
 
Join Date: Dec 2013
Location: USEA Strangereal
Posts: 343
Reputation: 16
Default Re: [UPDATE][SNAPSHOT][Java 8] Shoebill 1.1 - SA-MP Java Development Kit

Thanks for it, I am going to test it.
By the way, have you checked the issue with the MapAndreas class?
__________________
Neucom Inc.
Su37Erich is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] [SHOEBILL] Gamemode Reloader mk124 Tools and Files 10 16/05/2016 06:29 PM
[Plugin] [ALPHA] Project Shoebill - Java for SA:MP Development Kit - Milestone 1 (20110701) mk124 Plugin Development 57 05/04/2016 08:23 PM
[GameMode] [Java] PROJECT NEW WL-World (Based on Shoebill, WIP) mk124 Gamemode Scripts 12 01/11/2014 11:16 PM
[FilterScript] Dealership plugin for shoebill (Java) 123marvin123 Filterscripts 4 08/06/2014 02:17 PM


All times are GMT. The time now is 11:12 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.