[Plugin] Shoebill 1.1 - SA-MP Java Development Kit

I don't know which JPA you are using. Shoebill does not affect the behavior of JPA's, you may just have to look into the documentation of the JPA you are using right now. Maybe you can show us your folder structure, the code & error, maybe we can help you.
Reply

I attached my project (NetBeans). The class serverSAMPerrr contains a method onEnable. At the start of the method code which is identical to the code in the class NewClass.java. When I run the class NewClass.java there are no errors. But when I run the server with my game mode I get an exception:

javax.persistence.PersistenceException: No Persistence provider for EntityManager named ServerSAMPPU.

I think i get this exception because java does not see my persistence.xml. So I thought that the file persistece.xml need to put in a special server folder.

I use eclipce persistance API.

Sorry for my English.
Reply

I you don't use Maven, you will have to add your runtime libraries to the resources.yml's "runtimes" section.
You will need a .jar file that provides the driver for your JPA. Put it in the shoebill/libraries folder and add the file to your resources.yml in the "runtimes" section (don't add the .jar at the filename in the resources.yml)
Reply

Hi, help me please!

getEventManager().registerHandler(MenuSelectedEven t.class, (e)->{
if(e.getMenu()==null)
System.out.println("WTF");
});

why in this code e.getMenu() return null?
Reply

A question. Timer.TimerCallback method onTick. Does that tick represent a tick at each timer interval?

Код:
Timer.create(1000, 2, (interval) -> {
     // will this be called once per second twice?
    // And what is the interval variable? 
});
Question #2. Why is the createExplosion method in player class? In Pawn it didn't require any player data.
Reply

@dusk:

Q1: The callback will call when the interval has elapsed. It will call as many times as the timer runs. If you use 2 repeats (like in the example) the callback will be called twice. The first one will be called after 1 second and the second one will be called after 2 seconds. After that, the timer will be destroyed, no need for manually calling .destroy(). Please keep in mind, that Java uses Garbage Collection and if you lose the reference to the timer object, it might be destroyed too early. You will want to keep a reference to it somehow, like creating a global variable and assigning the timer to it.

Q2: There is a explosion for only a specific player and also a explosion for the world. If you look into the api documentation you can see, that the World class also contains a method called createExplosion. If you use this method, the explosion will be seen by everybody, if you use the Player's createExplosion, only the player will see it.

@OspIrAnt: It might be a bug. I will take a look at it at the weekend.
Reply

1.Aren't timers kept internally? Isn't that enough for them not to be reclaimed by the garbage collector? Although I do notice you its a list of references to timers.. Is that similiar to WeakReference?

2. Oh never knew that you can create explosions per player! Thanks.
Reply

Shoebill will automatically remove all timers if you do not assign a variable to it. This will prevent that unwanted timers will keep running in the background forever (look at the code @ getTimers()).
Reply

Hello,
Do you have a link for a tutorial about how to start up using Shoebill, because though I have knowledges in java, I'm a bit lost
Reply

Quote:
Originally Posted by PiR
Посмотреть сообщение
Hello,
Do you have a link for a tutorial about how to start up using Shoebill, because though I have knowledges in java, I'm a bit lost
There are a few tutorials actually:

Quote:
Originally Posted by mk124
Посмотреть сообщение

Watch our ******* Instruction Videos:

One more question.

I have a Pawn function which calls a Java method:
Код:
GivePlayerBasicItem(playerid, itemid, amount, itemtype, stackable)
{
	printf("GivePlayerBasicItem(%d, %d, %d, %d, %d) called", playerid, itemid, amount,  itemtype, stackable);
	new val = CallShoebillFunction("tryGivePlayerItemType", playerid, itemtype, itemid, amount,  itemtype, stackable);
	printf("GivePlayerBasicItem returned %d", val);
	return val;
}
Код:
eventManager.registerHandler(AmxLoadEvent.class, e -> {
            e.getAmxInstance().registerFunction("tryGivePlayerItemType", params -> {
            logger.debug("tryGivePlayerItemType called");
            ......
        });
The interesting thing is that "tryGivePlayerItemType called" is printed out each time while "GivePlayerBasicItem" only once.

Why is that? I noticed that the function is registered in two amx instances.
Reply

@dusk: You will need to call the Pawn method in your pawn code. If the debug message from pawn is not called, there might be a problem in your pawn code.
Reply

That's the weird part. Pawn debug message is printed once, but the one in Java is printed twice.
Reply

@dusk: I will take a look at it at the weekend. Which Shoebill version are you using? 1.2 (beta) or 1.1 ?
Reply

I'm using 1.2.

I do have a theory though.

I noticed that the method is called from different amx handles. And that kind of makes sense, I do register that method to all of them(with AmxLoadEvent). But, I only used CallShoebillFunction in one of my Pawn scripts.

I may have an answer. This code is from SampEventDispatcher class:
Код:
@Override
    public int onRegisteredFunctionCall(String name, Object[] parameters) {
        try {
            int returnValue = 0;
            for(AmxInstance instance : AmxInstanceManager.get().getAmxInstances()) {
                if(instance.hasRegisteredFunction(name)) {
                    returnValue = instance.callRegisteredFunction(name, parameters);
                }
            }
            return returnValue;
        } catch (Throwable e) {
            e.printStackTrace();
            return 0;
        }
    }
I don't really know C++, but I believe that that method is called from the plugin(not directly it seems).

So this code doesn't care WHERE did the CallShoebillFunction call came from, it simply calls it on every amx instance that registered that function.
My suggested sollution is passing the origin(amx handle) of the script that CallShoebillFunction was called(assuming that possible).
Reply

@valych: Nice to hear. You can create a global field to access an EventManager in your game mode, but keep in mind, that you should use the correct EventManager for each plugin and game mode. Don't share EventManagers between (Shoebill) Plugins and (Shoebill) Gamemodes.

I will take a look at your problem with the CreationFailedException and report back when I found / fixed something.

//Edit: Can you show many any code related to this issue? And are you using Shoebill 1.2?
Reply

Hmm interesting. I tried configuring the build for Visual Studio 14 2015. It generates it with only one issue which shouldn't affect my problem(i think)
Код:
The C compiler identification is MSVC 19.0.23026.0
The CXX compiler identification is MSVC 19.0.23026.0
Check for working C compiler using: Visual Studio 14 2015
Check for working C compiler using: Visual Studio 14 2015 -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler using: Visual Studio 14 2015
Check for working CXX compiler using: Visual Studio 14 2015 -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Looking for alloca.h
Looking for alloca.h - not found
Looking for inttypes.h
Looking for inttypes.h - found
Looking for malloc.h
Looking for malloc.h - found
Looking for stdint.h
Looking for stdint.h - found
Found JNI: C:/Program Files (x86)/Java/jdk1.8.0_05/lib/jawt.lib  
JNI_INCLUDE_DIRS=C:/Program Files (x86)/Java/jdk1.8.0_05/include;C:/Program Files (x86)/Java/jdk1.8.0_05/include/win32;C:/Program Files (x86)/Java/jdk1.8.0_05/include
JNI_LIBRARIES=C:/Program Files (x86)/Java/jdk1.8.0_05/lib/jawt.lib;C:/Program Files (x86)/Java/jdk1.8.0_05/lib/jvm.lib
Configuring done
Generating done
If I try to open this build with my Visual Studio 14 2015 enterprise edition I get the following error:

Код:
Unsupported
This version of Visual Studio is unable to open the following projects. The project types may not be installed or this version of Visual Studio may not support them. 
For more information on enabling these project types or otherwise migrating your assets, please see the details in the "Migration Report" displayed after clicking OK.
	 - ALL_BUILD, "F:\AAAA\Shoebill\ShoebillPlugin\Build\ALL_BUILD.vcxproj"
	 - INSTALL, "F:\AAAA\Shoebill\ShoebillPlugin\Build\INSTALL.vcxproj"
	 - Shoebill, "F:\AAAA\Shoebill\ShoebillPlugin\Build\src\Shoebill.vcxproj"
	 - ZERO_CHECK, "F:\AAAA\Shoebill\ShoebillPlugin\Build\ZERO_CHECK.vcxproj"
	 - amx, "F:\AAAA\Shoebill\ShoebillPlugin\Build\src\sampplugin\amx.vcxproj"
	 - hook, "F:\AAAA\Shoebill\ShoebillPlugin\Build\src\hook\hook.vcxproj"


No changes required
These projects can be opened in Visual Studio 2015, Visual Studio 2013, Visual Studio 2012, and Visual Studio 2010 SP1 without changing them.
	 - CMakePredefinedTargets, "CMakePredefinedTargets"
	 - ShoebillPlugin, "F:\AAAA\Shoebill\ShoebillPlugin\Build\ShoebillPlugin.sln"

I think I found another issue in the plugin.

This JNI function
Consider this scenario:
  1. A vehicle is created(meaning all param values are VEHICLE_PARAMS_UNSET which is -1)
  2. I manually set doors(just an example).
  3. VehicleParamImpl method setDoors calls getVehicleParamsEx(which returns engine=-1, lights=-1, alarm=-1, doors=-1, objective=-1
  4. VehicleParamImpl method setDoors calls its method set
  5. VehicleParamImpl method set calls setVehicleParamsEx(with values engine=-1, lights=-1, alarm=-1, doors=myusedvalue, objective=-1
  6. Java_net_gtaun_shoebill_SampNativeFunction_setVehi cleParamsEx will cast those values to boolean. Which produces(engine=true, lights=true, alarm=true, doors=myvalue, objective=true)
This is because when casting to bool, 0 is false and anything else is true. Therefore, other vehicle params are set to values you don't want them to be set.
Reply

@dusk: I think you generate your project files with a never version of Visual Studio than you are using when opening them.

I see the problem with the GetVehicleParamsEx function. Unfortunately the function made by sampgdk accepts booleans. I made a workaround for it, but I maybe create an issue on sampgdk's Github page.
Reply

That's the interesting thing. I generate it for "Visual studio 14 2015" and I AM using "Visual studio 14 2015". So I really don't understand why does it say it isn't the right version...
Reply

Where did you download CMake? I downloaded mine from their official site: https://cmake.org/files/v3.4/cmake-3.4.1-win32-x86.exe
Reply

@mk124, I dont think that examples are necessary, because there are just a lot of objects that are simply created by CreateDynamicObject function in pawn.
Also, if it is necessary I can use your lvdm game mode with a bare pawn game mode to check if there is the same problem with this exception.
Reply


Forum Jump:


Users browsing this thread: 18 Guest(s)