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

Hi, thanks for your work. And I sorry for my English. I recently started to write the server using your plugin. And faced with a problem. I tried to connect to Postgresql. I copied the JDBC file to the /libraries directory. But I get an exception on server startup.

java.sql.SQLException: No suitable driver found for jdbcostgresql://localhost:5432/samp

I could not find any information on where to register a libraries such as JDBC. I tried to copy a JDBC file to a /gamemodes folder. And to /gamemodes/lib folder. Also i tried to add JVM options "-Djava.library.path="E:\server samp\shoebill\libraries"". But I also get an exception on server startup.

Help me please. What did I do wrong?
Reply

Quote:
Originally Posted by OspIrAnt
Посмотреть сообщение
Hi, thanks for your work. And I sorry for my English. I recently started to write the server using your plugin. And faced with a problem. I tried to connect to Postgresql. I copied the JDBC file to the /libraries directory. But I get an exception on server startup.

java.sql.SQLException: No suitable driver found for jdbcostgresql://localhost:5432/samp

I could not find any information on where to register a libraries such as JDBC. I tried to copy a JDBC file to a /gamemodes folder. And to /gamemodes/lib folder. Also i tried to add JVM options "-Djava.library.path="E:\server samp\shoebill\libraries"". But I also get an exception on server startup.

Help me please. What did I do wrong?
Do you use Maven?

Add your .Jar files to server/shoebill/libraries, if they're there, they will be loaded.



Question to author: Why does the first argument of command methods must be of type Player? In my case, I have a wrapper for it so I'd really like my commands have that wrapper as an argument... But it seems it's not achievable without rewriting CommandGroup class....
Reply

My problem is that I have copied the JDBC library to server/shoebill/libreries/ directory. And the server does not load it. Please watch the video for understand what I mean.

https://www.youtube.com/watch?v=wBi9...ature=*********
Reply

I resolve the problom. I forgot to do : Class.forName("org.postgresql.Driver"); before DriverManager.getConnection("jdbcostgresql://localhost:5432/samp", "postgres", "admin");

thank you)
Reply

Yo, I've bumped into a problem trying to use functions from Shoebill in pawn.
I've created a class with static method where all functions are registered in amx-instances:
PHP код:
public class InitMethodsForPawn {
    static 
EventManagerNode eventManagerNode;
    public static 
void initialize(EventManager rootEventManager) {
        
eventManagerNode rootEventManager.createChildNode();
        
eventManagerNode.registerHandler(AmxLoadEvent.class, -> {
            
e.getAmxInstance().registerFunction("GetPlayerFactionName"objects -> {
                
Player player Player.get((Integer) objects[0]);
                
//Do something to get player's faction etc.
                
objects[1] = "Los Santos PoPo";
                
//Return value for pawn (not always needed)
                
return 1;
            }, 
Integer.class, String.class);
        });
    }
    public static 
void uninitialize() {
        
eventManagerNode.registerHandler(AmxUnloadEvent.class, -> {
            
e.getAmxInstance().unregisterFunction("GetPlayerFactionName");
        });
    }

Then, in class which extends Gamemode class I call this static method in onEnable() method:
PHP код:
EventManager eventManager getEventManager();
InitMethodsForPawn.initialize(eventManager); 
In onDisable():
PHP код:
InitMethodsForPawn.uninitialize(); 
Code in pawn in OnGameModeInit():
PHP код:
    new test[32];
    
test "test";
    
CallShoebillFunction("GetPlayerFactionName"0test);
    
printf("test = %s"test); 
And when I'm trying to call GetPlayerFucntion I'm getting next message in server console all the time:
[SHOEBILL] Function GetPlayerFactionName is not registered.
And of couse test is equals to "test".

Did I do something wrong?
Reply

@mk124, will a timer solve this problem? For example, in method onEnable() I create a timer, which will register those functions in 10 secs after server's startup?
Reply

@valych: No, you don't need a timer. Keep your code from post #447 but move the pawn code away from OnGameModeInit() and create a public function in pawn called OnShoebillInitialized() (don't forget to use forward OnShoebillInitialized()) and in there you will write your code from OnGameModeInit(). In Java, you will call the Pawn public function when you registered all your Java methods:

PHP Code:
eventManagerNode.registerHandler(AmxLoadEvent.class, (e) -> {
    
e.getAmxInstance().registerFunction(....);
    
AmxCallable initFunction e.getAmxInstance().getPublic("OnShoebillInitialized");
    if (
initFunction != null) {
        
initFunction.call();
    }
}); 
Reply

@mk124, maybe I misunderstood you, but I called Shoebill function in OnGameModeInit just for an example. Even if I call that function with a command, it's still said to be unregistered.
Tried your example above and it seems that AmxLoadEvent is not being occurred at all or initFunction is equals to null.
I removed code from OnGameModeInit() and added this one:
PHP Code:
forward OnShoebillInitialized();
public 
OnShoebillInitialized() 
{
    
printf("OnShoebillInitialized called");
    new 
test[32];
    
test "damn";
    
CallShoebillFunction("GetPlayerFactionName"0test);
    
printf("test = %s"test);

Then did some changes to Java code:
PHP Code:
public static void initialize(EventManager rootEventManager) {
        
eventManagerNode rootEventManager.createChildNode();
        
eventManagerNode.registerHandler(AmxLoadEvent.class, -> {
            
e.getAmxInstance().registerFunction("GetPlayerFactionName"objects -> {
//                Player player = Player.get((Integer) objects[0]);
                //Do something to get player's faction etc.
                
objects[1] = "Los Santos PoPo";
                
//Return value for pawn (not always needed)
                
return 1;
            }, 
Integer.class, String.class);
            
AmxCallable initFunction e.getAmxInstance().getPublic("OnShoebillInitialized");
            if (
initFunction != null) {
                
initFunction.call();
            }
        });

The code in OnShoebillInitialized wasnt executed (I didnt get any messages in server console).
Also, in OnPlayerConnect I called OnShoebillInitialized() and it tells me that [SHOEBILL] Function GetPlayerFactionName is not registered.
Reply

@valych: Ok, are you sure that you changed your gamemode line in server config to your .amx file?
If yes, move the .registerFunction(...) section to a seperate method and call it "registerPawnFunctions(AmxInstance instance)". In onEnable() do:
PHP Code:
for(AmxInstance instance Shoebill.get().getAmxInstanceManager().getAmxInstances()) {
    
registerPawnFunctions(instance);

(And call registerPawnFunctions also in the AmxLoadEvent)
Reply

@mk124, yeah, that solved my problem, thank you
Also, I was curious and tried this code to check if the AmxLoadEvent is being occurred:
In onEnable():
PHP Code:
        eventManagerNode.registerHandler(AmxLoadEvent.class, -> {
            
getLogger().info("AmxLoadEvent called");
        }); 
And there were no messages matching this: "AmxLoadEvent called", maybe there is a problem with this event?
Reply

@valych: No, there is no problem with the event. The problem is that the Amx Gamemode will be loaded before the Shoebill Gamemode, so you will have to iterate also through all already existing AmxInstances at onEnable().
Reply

Hello, as usually, another problem. When I startup a server with SHoebill plugin AND with a game mode written in pawn, the crashdetect plugin reports Stack underflow runtime error. But when I startup the server without Shoebill plugin everything runs smoothly, without any problem.
I've spent a couple of days trying to fix this, like lowering amount of iterations in timers, amount of data stored in arrays and so on... But nothing seemed to be changed.
And the crashdetect plugin starts reporting that error only after player connects, before that (when there is no players on the server) - no error outputted.
Any ideas how to fix this?
Reply

Are you sure that you use the latest version of the shoebill plugin? If yes, it would be nice if you could provide me with your Pawn Gamemode and I will try to check what's wrong. It should be a problem in the ShoebillPlugin and not with your game mode.
Reply

Quote:
Originally Posted by valych
View Post
Hello, as usually, another problem. When I startup a server with SHoebill plugin AND with a game mode written in pawn, the crashdetect plugin reports Stack underflow runtime error. But when I startup the server without Shoebill plugin everything runs smoothly, without any problem.
I've spent a couple of days trying to fix this, like lowering amount of iterations in timers, amount of data stored in arrays and so on... But nothing seemed to be changed.
And the crashdetect plugin starts reporting that error only after player connects, before that (when there is no players on the server) - no error outputted.
Any ideas how to fix this?
I've got a similiar issue. Only the error is
pawn Code:
[debug] Run time error 20: "Invalid index parameter (bad entry point)"
I wasn't able to pinpoint its location yet, but I believe it occurs when a player connects.
Reply

Hi dusk,

I will release a snapshot version of Shoebill 1.2 today which will fix this problem. Shoebill 1.2 uses sampgdk and should be more compatible than 1.1.
Reply

[Image: 1lo1zqn]
The first snapshot version of Shoebill 1.2 is now available for download. Keep in mind, that this version is not yet stable. You might experience unexpected behavior. The main change in this version is, that Shoebill changed it's internal components. It's now using sampgdk, instead of it's own hooking system. This will provide better compatibility with other plugins and game modes.

Done:
  • Replace internal hooking system with sampgdk
  • Support for new Dialog types introduced in SAMP 0.3.7


Planned:
  • Fix broken functions caused by change of hooking system
  • ?

The shoebill-api has changed a little bit in it's way of handling the Amx Interfaces. You will have to change your version of shoebill-api to 1.2-SNAPSHOT. In your resources.yml you will need to change the version of the runtime to 1.2-SNAPSHOT. You will also have to update your Plugin and the Launcher, preferably through the Shoebill Updater (execute update-shoebill.bat/.sh) or manually downloading the plugin and the launcher:
(Copy the plugin into the plugins directory and the launcher into shoebill/bootstrap)
Make sure to disable offlineMode in resources.yml and let shoebill download the newest artifacts from our Repository (http://repo.gtaun.net/)

(Updates may or may not occur in short periods of time, please check for updates before reporting a bug)
Reply

The new Dialog types of SAMP 0.3.7 can now be accessed via shoebill-common-1.2-SNAPSHOT.

You need to change / add the following in your pom.xml:
Код:
<dependency>
       <groupId>net.gtaun</groupId>
       <artifactId>shoebill-common</artifactId>
       <version>1.2-SNAPSHOT</version>
       <type>jar</type>
       <scope>compile</scope>
</dependency>
After that, you can create TabListDialogs with and without headers like this:
PHP код:
        TabListDialog.create(playereventManager)
                .
caption("My Dialog")
                .
buttonOk("Buy")
                .
buttonCancel("Cancel")
                .
header(0"Weapon")
                .
header(1"Price ($)")
                .
item(TabListDialogItem.create()
                        .
column(0ListDialogItem.create().itemText("Deagle").build())
                        .
column(1ListDialogItem.create().itemText("$500").build())
                        .
onSelect((itemo) -> {
                            
//Give player a Deagle
                        
})
                        .
build())
                .
item(TabListDialogItem.create()
                        .
column(0ListDialogItem.create().itemText("M4").build())
                        .
column(1ListDialogItem.create().itemText("$12000").build())
                        .
onSelect((item1o1) -> {
                            
//Give player a m4
                        
})
                        .
build())
                .
build()
                .
show(); 
You can set 0-3 headers via the .header() function and add rows via the .item() function.
You will need to use TabListDialogItems instead of normal ListDialogItems. When using the TabListDialogItem, you can use .column() to set the content of column 0-3. The content will be a ListDialogItem and can be everything you can do with a ListDialogItem (also RadioItems etc.). You will want to add a handler via the .onSelect() method.

Here's a screenshot:
Reply

Hmm I changed my pom.xml. But it says that the dependency is not found. Here's the repo I use:
Код:
 <repository>
            <id>gtaun-public-repo</id>
            <name>GTAUN Public Repository</name>
            <url>http://repo.gtaun.net/content/groups/public</url>
        </repository>
I also tried running the server. /shoebill/repository/net/gtaun/shoebill-common created a folder for 1.2-SNAPSHOT but the only file I found there was resolver-status.properties and its contents:
Код:
maven-metadata-sonatype-oss-snapshots.xml.error=
maven-metadata-sonatype-oss-snapshots.xml.lastUpdated=1448896152416
maven-metadata-central.xml.error=
maven-metadata-central.xml.lastUpdated=1448896152185
maven-metadata-gtaun-public-repo.xml/@default-gtaun-public-repo-http\://repo.gtaun.net/content/groups/public/.lastUpdated=1448896152001
maven-metadata-gtaun-public-repo.xml.error=Could not transfer metadata net.gtaun\:shoebill-common\:1.2-SNAPSHOT/maven-metadata.xml from/to gtaun-public-repo (http\://repo.gtaun.net/content/groups/public)\: repo.gtaun.net
Reply

Are you sure that the resources.yml contains the shoebill repo? Your resources.yml should look like this:



If you want to use Shoebill 1.2, don't forget to use the shoebill-updater and replace the old versions to 1.2-SNAPSHOT in your game mode's pom.xml.
Reply

Hey, help me please. I try to use java persistens api in my game mode, but i get an exception when I run the server: javax.persistence.PersistenceException: No Persistence provider for EntityManager named ServerSAMPPU.

Where should I put persistentse.xml in your server?
Reply


Forum Jump:


Users browsing this thread: 17 Guest(s)