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

Quote:
Originally Posted by mk124
Посмотреть сообщение
@Chilco: You are using two different versions of shoebill-common. Make sure that the version you use in the pom.xml matches with the one in the resources.yml.
You are right, thanks for the quick response.
Reply

PHP код:

eventManagerNode
.registerHandler(PlayerTextEvent.class, (e) -> {
            
e.disallow();
        }); 
Basically the text still appears in the chat when disallowing the event when I think it should not. I believe this code worked before in an earlier version but I'm not sure.
Reply

Found some confused bug:

https://github.com/Shoebill/shoebill...scription.java at line: 116

catch (NullPointerException e)
{
throw new FileNotFoundException(configFilename);
}

I had NPE but file was found (wrong configuration syntax)
Please do not throw FileNotFoundException in that case. Its very confusing!
Reply

Hello Everybody,

I suggest using netbeans for this API. It is very easy to use and you wont struggle to build your project. I am just struggling on connecting a mysql database to my project.

Thanks for the API. This has helped me a lot. Currently studying Java at university so it is not so difficult for me either.
Reply

Hello!

I'm using hibernate orm to load player data to the game.

Could you show me a good solution how to attach player DB data to Player object?

As I don't want to keep DB objects in the PlayerHelper static list and fork it every time when I need data.
Something like: player.setVarString but for Object
Reply

Hello!
Found some issue. For Menu class there is no onSelectMenu function. This is not suitible to handle common MenuSelectedEvent and keep gamemode flow somewhere. Instad of this I created a class with static methods:

PHP код:
package ru.samp_net;
import java.util.ArrayList;
import java.util.List;
import net.gtaun.shoebill.event.menu.MenuSelectedEvent;
import net.gtaun.shoebill.object.Menu;
import net.gtaun.util.event.EventManager;
import net.gtaun.util.event.EventManagerNode;
/**
 *
 * @author Philipp Khlupin
 */
public class MenuController {
    @
FunctionalInterface
    
public static interface SelectMenuEvent {
        public 
void onSelect(MenuSelectedEvent event);
    }
    private static 
EventManagerNode eventManagerNode;
    private static List<
MenumenuList;
    private static List<
SelectMenuEventeventList;
    
    public static 
void init(EventManager rootEventManager) {
        
eventManagerNode rootEventManager.createChildNode();
        
menuList = new ArrayList<>();
        
eventList = new ArrayList<>();
        
setupEventHandlers();
    }
    public static 
void createMenuHandler(Menu menuSelectMenuEvent event) {
        
menuList.add(menu);
        
eventList.add(event);
    }
    private static 
void setupEventHandlers() {
        
eventManagerNode.registerHandler(MenuSelectedEvent.class, (event) -> onSelectMenu(event));
    }
    public static 
void destroy() {
        
menuList.clear();
    }
    private static 
synchronized void onSelectMenu(MenuSelectedEvent event) {
        
SelectMenuEvent menuEvent;
        for (
int i 0menuList.size(); i++) {
            if (
event.getMenu().getId() == menuList.get(i).getId()) {
                
menuEvent eventList.get(i);
                
menuEvent.onSelect(event);
                
menuList.remove(i);
                
eventList.remove(i);
                return;
            }
        }
        
    }

How to use:

In main gamemode class:

PHP код:
    protected void onEnable() throws Throwable {
        
EventManager eventManager getEventManager();
        
//...
        
MenuController.init(eventManager);
        
//...
    

In somewhere where you need to create a menu (for example "skin shop"):

PHP код:
    private void drawMenu(RolePlayer rolePlayer) {
        
Menu menu SampObjectManager.get().createMenu("Choose skin"150.0f160.0f110.0f0.0f);
        
menu.setColumnHeader(0"Choose skin");
        
menu.addItem(0">> Next");
        
menu.addItem(0"<< Previous");
        
menu.addItem(0"Done");
        
menu.show(rolePlayer.getPlayer());
        
MenuController.createMenuHandler(menu, (event) -> {
            switch (
event.getRow()) {
                case 
1:
                    
// Show next skin
                    
drawMenu(rolePlayer);
                    break;
                case 
2:
                    
// Show previous skin
                    
drawMenu(rolePlayer);
                    break;
                default:
                    
// Save changes
                    
break;
            }
        });
    } 
UPD: Dev team! Please validate my code, i think that synchronized can help the onSelectMenu for concurrent removing elements from arraylist
Reply

Hello!
Could you help me with this issue:

In PlayerKeyStateChange event I can only handle old key but not new one:
Here what I found in Shoebill runtime code class, as you may see you did not propogate new key value at all:
PHP код:
    @Override
    
public boolean onPlayerKeyStateChange(int playerIdint keysint oldKeys) {
        try {
            
Player player sampObjectStore.getPlayer(playerId);
            
PlayerKeyStateChangeEvent event = new PlayerKeyStateChangeEvent(player, new PlayerKeyStateImpl(playeroldKeys));
            
rootEventManager.dispatchEvent(eventplayer);
            return 
event.getResponse() > 0;
        } catch (
Throwable e) {
            
e.printStackTrace();
            return 
false;
        }
    } 
How could I handle new key?
Reply

@diclofoss: With player.getKeyState();
Reply

Thank you
Reply

@mk124 Hello! Could you share me some example with streamer-wrapper?
Reply

Hello! Is it possible that your Maven repository is down?
I get messages like this:
Failed to read artifact descriptor for net.gtaunhoebill-api:jar:1.2-SNAPSHOT
Reply

@The King's Bastard: Hi, you are right, our hoster is currently doing some maintenance work on our hosting system. It should be back soon.
Reply

Alright! Thank you very much for your really fast answer!

//EDIT: How long do you think it will take until the repository is up again?
Reply

The repository is now back online.
Reply

Let's say I'd like to use Guava:
Код:
<dependency>
	<groupId>com.******.guava</groupId>
	<artifactId>guava</artifactId>
	<version>19.0</version>
</dependency>
Everything is compiling fine, but when I want to start the server, I'm getting a
java.lang.NoClassDefFoundError for example for the Strings class in Guava (which has the function isNullOrEmpty()) for example. Obviously the build process is not including those dependencies in the final JAR file.
How do I get Shoebill to load those dependencies (maybe from a repository)?
Reply

You have to add guava to your needed runtime libraries in the resources.yml. It should look like this:

Код:
runtimes:
  - ...
  - com.******.guava:guava:19.0
Reply

Alright, this works fine. Thanks!

Now I'd like to use Hibernate 5.2.2, but the problem is that somehow the server can't seem to find the the EntityManager. I do have a META-INF/persistence.xml in the resources directory just as gamemode.yml.

Do you know what I could be doing wrong?

I'm also loading Hibernate-entitymanager, just like Guava:
Код:
<dependency>
	<groupId>org.hibernate</groupId>
	<artifactId>hibernate-entitymanager</artifactId>
	<version>5.2.2.Final</version>
</dependency>
In my unit test, everything works fine as well and the EntityManager can be created. So somehow it must be unable to find persistence.xml? Because I know that the Hibernate classes are loaded.

The exception I get:
Код:
[22:41:26][ERROR][err] javax.persistence.PersistenceException: No Persistence provider for EntityManager named newventuras
[22:41:26][ERROR][err]  at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:61)
[22:41:26][ERROR][err]  at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
[22:41:26][ERROR][err]  at ch.leadrian.samp.newventuras.NewVenturas.onEnable(NewVenturas.java:26)
[22:41:26][ERROR][err]  at net.gtaun.shoebill.resource.Resource.enable(Resource.java:91)
[22:41:26][ERROR][err]  at net.gtaun.shoebill.resource.ResourceManagerImpl.loadGamemode(ResourceManagerImpl.java:179)
[22:41:26][ERROR][err]  at net.gtaun.shoebill.resource.ResourceManagerImpl.loadAllResource(ResourceManagerImpl.java:62)
[22:41:26][ERROR][err]  at net.gtaun.shoebill.ShoebillImpl.loadPluginsAndGamemode(ShoebillImpl.java:289)
[22:41:26][ERROR][err]  at net.gtaun.shoebill.ShoebillImpl.access$100(ShoebillImpl.java:47)
[22:41:26][ERROR][err]  at net.gtaun.shoebill.ShoebillImpl$1.onAmxLoad(ShoebillImpl.java:233)
[22:41:26][ERROR][err]  at net.gtaun.shoebill.samp.SampCallbackManagerImpl$1.lambda$null$80(SampCallbackManagerImpl.java:60)
[22:41:26][ERROR][err]  at net.gtaun.shoebill.util.TryUtils.tryTo(TryUtils.java:21)
[22:41:26][ERROR][err]  at net.gtaun.shoebill.util.TryUtils.tryTo(TryUtils.java:14)
[22:41:26][ERROR][err]  at net.gtaun.shoebill.samp.SampCallbackManagerImpl$1.lambda$onAmxLoad$81(SampCallbackManagerImpl.java:60)
[22:41:26][ERROR][err]  at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source)
[22:41:26][ERROR][err]  at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
[22:41:26][ERROR][err]  at java.util.concurrent.ConcurrentLinkedQueue$CLQSpliterator.forEachRemaining(Unknown Source)
[22:41:26][ERROR][err]  at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
[22:41:26][ERROR][err]  at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
[22:41:26][ERROR][err]  at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source)
[22:41:26][ERROR][err]  at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source)
[22:41:26][ERROR][err]  at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
[22:41:26][ERROR][err]  at java.util.stream.ReferencePipeline.forEach(Unknown Source)
[22:41:26][ERROR][err]  at net.gtaun.shoebill.samp.SampCallbackManagerImpl$1.onAmxLoad(SampCallbackManagerImpl.java:60)
Reply

@The King's Bastard: You should look into the generated .jar if the persistence.xml file is at the correct path. I don't think I can help you with that, because I have no idea of these persistence frameworks.
Reply

Hello, I am trying to get the server working on my Windows desktop.
I have followed the video guide linked in the main post and I downloaded the full package. I made sure that I have the latest JDK installed, I have set the environment variable (JRE_HOME).

When I start the server I get the following:
Код:
SA-MP Dedicated Server
----------------------
v0.3.7-R2, ©2005-2015 SA-MP Team

[16:58:17] filterscripts = ""  (string)
[16:58:17] 
[16:58:17] Server Plugins
[16:58:17] --------------
[16:58:17]  Loading plugin: Shoebill
[16:58:17]   Failed.
[16:58:17]  Loaded 0 plugins.

[16:58:17] 
[16:58:17] Filterscripts
[16:58:17] ---------------
[16:58:17]   Loaded 0 filterscripts.

[16:58:17] Number of vehicle models: 0
As you can see, it does not give a reason why the Shoebill plugin failed to load.
Reply

Hello mk124

In the generated JAR, persistence.xml is in META-INF.

Is there any way to enable ALL console output? Because during the unit tests I'm seeing console output from Hibernate that does not show up in the SAMP console or in the logs...

This could be helpful for me to find out what I'm doing wrong.

Thanks in advance!

// EDIT:
Well I also tried EclipseLink instead of Hibernate, same problem: Everything works fine during unit test, but when I run the server, it doesn't.
Reply


Forum Jump:


Users browsing this thread: 49 Guest(s)