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

@dusk: Fixed with http://ci.gtaun.net/job/shoebill-common/146/.

Please keep in mind that this is not the "correct" way of creating commands. I think you know that already, but you can take a look at this example: https://github.com/Shoebill/example-...mCommands.java
Reply

I'm aware of the @Command way, but as you see it merely sends some text, so I chose the easy path.

I also would like to remind you of a suggestion I made a while ago http://forum.sa-mp.com/showpost.php?...&postcount=426
Reply

@dusk: I will keep this suggestion in mind and implement it when I have the time.
Reply

Great. Hmm I updated the shoebill-common and now when I use the command /takelesson I get the usage message.
Reply

@dusk: That's strange because I copied your code and just changed the event handler and it was working fine. I will have to test it again tomorrow because it is too late now

//Edit: I tested it today and it is working fine for me! This is my code:
PHP код:
commandManager.registerCommand("takelesson", new Class[0], new String[0], (playerqueue) -> {
            
player.sendMessage(Color.GREEN"* OK!!!");
            return 
true;
        }, 
nullnull); 
Reply

@dusk: I added your suggestion today to shoebill-common version 1.3-SNAPSHOT (new). You can take a look at the build and the commit here: http://ci.gtaun.net/job/shoebill-common/149/

A few other things have changed:
- The UsageMessageSupplier is now simplified and only supplies you with the player, the prefix and the CommandEntry object which allows you to access all the information of the command.
- The .getParamNames() has moved into the .getParameters() method.

Something to note:
- Shoebill will automatically create a CommandParameter annotation with the variable name as the name if no annotation was provided. Everything that is related to working with the command's parameters is now related to the @CommandParameter annotation. It is guaranteed that this array will never be null.

But this is how to use the @CommandParameter annotation for custom naming and describing parameters:
PHP код:
@Command
public boolean adminvehicle(Player player,
                                         @
CommandParameter(name "Model ID"description "The model id of the vehicle that should be created."int vehId) {
    ... 
    return 
true;

Shoebill's new default usage message supplier will show the name that has been given in the CommandParameter annotation by default. So in this example the usage message would look like this: "Usage /adminvehicle [Model ID]". The description is not used by default from Shoebill but you can make your own usage message supplier that makes use of the description. Every parameter should only use one @CommandParameter.

Btw: You can leave the description out if you don't want to use a description. This will shorten the line.
Reply

Amazing!

Will the wrapper generator work with streamer plugin to generate all types of objects, for example dynamic Areas?
Reply

@dusk: The wrapper generator will only create native function calls and callback hooks. If you want to have a "java feeling" you will still have to add own classes. The wrapper for the streamer plugin is made by hand at the moment.
Reply

Alright, I was writing my own streamer wrapper using the generator.
  • How are .idl files generated or am I supposed to type them by hand?
  • In streamer.idl file from generators idl directory the polygon functions are commented out. Is it because they require passing float arrays by reference?(which shoebill does not yet support)
  • If I use ReferenceFloat, do I need to get the value or will it be in the String object I provided when creating the ReferenceString object?
Reply

@dusk:

- You need to make the .idl files by hand
- Yes, some functions are not yet supported by Shoebill / the wrapper generator. Maybe in version 1.3 it will be fully supported.
- When you use ReferenceFloats or ReferenceStrings, you pass the variable to the call method. After the call method, you can call the getValue() function and you will get the changed value.
Reply

I'm having trouble with my streamer wrapper.
StreamerPlugin.java
Код:
@Override
    public void onEnable() throws Throwable {
        instance = this;
        logger = getLogger();

        Callbacks.registerHandlers(AmxInstanceManager.get()); // line 35
        Functions.registerFunctions(AmxInstance.getDefault());
        logger.info("Streamer wrapper initialized");
    }
Callbacks.java(generated via wrapper-generator)
Код:
public static void registerHandlers(AmxInstanceManager instanceManager) {
        EventManager eventManager = StreamerPlugin.getInstance().getEventManager();
        // The usual implementation
}
Код:
2016-02-17 14:12:31,497 ERROR [err] - java.lang.NoSuchMethodError: lt.maze.Callbacks.registerHandlers(Lnet/gtaun/shoebill/amx/AmxInstanceManager;)V
2016-02-17 14:12:31,497 ERROR [err] - 	at lt.maze.StreamerPlugin.onEnable(StreamerPlugin.java:35)
2016-02-17 14:12:31,498 ERROR [err] - 	at net.gtaun.shoebill.resource.Resource.enable(Resource.java:91)
2016-02-17 14:12:31,498 ERROR [err] - 	at net.gtaun.shoebill.resource.Plugin.enable(Plugin.java:52)
2016-02-17 14:12:31,498 ERROR [err] - 	at net.gtaun.shoebill.resource.ResourceManagerImpl.loadPlugin(ResourceManagerImpl.java:109)
2016-02-17 14:12:31,498 ERROR [err] - 	at net.gtaun.shoebill.resource.ResourceManagerImpl.loadPlugin(ResourceManagerImpl.java:89)
2016-02-17 14:12:31,499 ERROR [err] - 	at net.gtaun.shoebill.resource.ResourceManagerImpl$$Lambda$32/31094415.accept(Unknown Source)
2016-02-17 14:12:31,499 ERROR [err] - 	at java.util.ArrayList.forEach(ArrayList.java:1234)
2016-02-17 14:12:31,499 ERROR [err] - 	at net.gtaun.shoebill.resource.ResourceManagerImpl.loadAllResource(ResourceManagerImpl.java:61)
2016-02-17 14:12:31,499 ERROR [err] - 	at net.gtaun.shoebill.ShoebillImpl.loadPluginsAndGamemode(ShoebillImpl.java:289)
2016-02-17 14:12:31,500 ERROR [err] - 	at net.gtaun.shoebill.ShoebillImpl.access$100(ShoebillImpl.java:47)
2016-02-17 14:12:31,500 ERROR [err] - 	at net.gtaun.shoebill.ShoebillImpl$1.onAmxLoad(ShoebillImpl.java:233)
2016-02-17 14:12:31,500 ERROR [err] - 	at net.gtaun.shoebill.samp.SampCallbackManagerImpl$1.lambda$null$80(SampCallbackManagerImpl.java:60)
2016-02-17 14:12:31,500 ERROR [err] - 	at net.gtaun.shoebill.samp.SampCallbackManagerImpl$1$$Lambda$31/30327649.call(Unknown Source)
2016-02-17 14:12:31,501 ERROR [err] - 	at net.gtaun.shoebill.util.TryUtils.tryTo(TryUtils.java:21)
2016-02-17 14:12:31,501 ERROR [err] - 	at net.gtaun.shoebill.util.TryUtils.tryTo(TryUtils.java:14)
2016-02-17 14:12:31,501 ERROR [err] - 	at net.gtaun.shoebill.samp.SampCallbackManagerImpl$1.lambda$onAmxLoad$81(SampCallbackManagerImpl.java:60)
2016-02-17 14:12:31,501 ERROR [err] - 	at net.gtaun.shoebill.samp.SampCallbackManagerImpl$1$$Lambda$30/33016375.accept(Unknown Source)
2016-02-17 14:12:31,502 ERROR [err] - 	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
2016-02-17 14:12:31,502 ERROR [err] - 	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
2016-02-17 14:12:31,502 ERROR [err] - 	at java.util.concurrent.ConcurrentLinkedQueue$CLQSpliterator.forEachRemaining(ConcurrentLinkedQueue.java:851)
2016-02-17 14:12:31,502 ERROR [err] - 	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:512)
2016-02-17 14:12:31,502 ERROR [err] - 	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502)
2016-02-17 14:12:31,503 ERROR [err] - 	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
2016-02-17 14:12:31,503 ERROR [err] - 	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
2016-02-17 14:12:31,509 ERROR [err] - 	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
2016-02-17 14:12:31,509 ERROR [err] - 	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
2016-02-17 14:12:31,509 ERROR [err] - 	at net.gtaun.shoebill.samp.SampCallbackManagerImpl$1.onAmxLoad(SampCallbackManagerImpl.java:60)
I tried to decompile Callbacks.class to confirm the function does end up there, but sadly my decompiler failed.
Reply

What this ?
Reply

@Amunra this is a plugin that lets you develop your SAMP gamemode with the Java programming language instead of Pawm
Reply

@dusk: That's strange, are you sure that the file is not corrupted? Have you tried regenerating the files? Maybe something went wrong while writing / moving the files. If you want you upload the .class file and I will try to take a look at it. It's usually not normal that the decompiler crashes, the Callbacks file should be easily decompileable.
Reply

I tried rebuilding the module multiple times. Here's the file http://s000.tinyupload.com/?file_id=...34538345655483

I did manage to dceompile it with IntelliJ and the method is there!
Reply

Can you try to use another package and class name?
Reply

Wow. I'm not sure how did you came up with that but it helped! And it also makes perfect sense, I also have an Audio plugin wrapper which also contains class lt.maze.Callbacks so their namespaces are identical.. I'll probably change them both to represent the plugin name, but I also noticed that restricted access to both of them(protected) works aswell.
Reply

@dusk: Your streamer project is probably not in the same project as your audio project is, that's why the compiler is not throwing out errors. The problem is only occurring at runtime, because the compiler cannot know that you will be using both at the same time. I was a little bit confused at first when I saw your problem, but I guess it makes sense if you have a conflict with your other plugins.
Reply

New question:
How to output a message to a player if he typed CommandGroup command without any other parameters? For example in lvdm, with a command /test. You type "/test", and how to show a player all possible commands in /test command (drink, pickup and so on)?
Reply

@valych: You will have to create an "/test help" command, because CommandGroups are not meant for simple commands such as "/use [water/food/cigarette]". You can use the CommandManager to get all commands in the specific command prefix:

PHP код:
List<CommandEntryentries commandManager.getCommandEntries("test"); 
Reply


Forum Jump:


Users browsing this thread: 23 Guest(s)