SA-MP Forums Archive
[Plugin] Shoebill 1.1 - SA-MP Java Development Kit - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Plugin Development (https://sampforum.blast.hk/forumdisplay.php?fid=18)
+--- Thread: [Plugin] Shoebill 1.1 - SA-MP Java Development Kit (/showthread.php?tid=397735)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37


Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit - dusk - 24.08.2014

Quote:
Originally Posted by CoaPsyFactor
Посмотреть сообщение
You can create your own class, and implement player into it, and in that class add your methods
That part I did. But when will their body be defined? I mean, it's an interface - I don't create those methods. So how will it actually know what to do in my added methods?


Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit - CoaPsyFactor - 24.08.2014

oh, you maybe want to extend their class, go into source and do your thing


Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit - dusk - 24.08.2014

That's not good practice, I believe.

I also believe that things like Vehicle and Player should be classes so we extend it and add our own stuff.


Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit - DrumYum - 24.08.2014

Hi guys! I have collected a few questions about coding and I don't know where I can find help. So, can I post them here? If not, could somebody show me thread about Shoebill coding?

1. Why commands written in @Command-style continue processing after return true in them? For example:
PHP код:
@Command
public boolean kill(Player p)
{
    
p.setHealth(0F);
    return 
true;
}
@
CustomCommand
public boolean customHandler(Player pString cmdString params)
{
    
p.sendMessage(new Color(-1), "Unknown command.");
    return 
true;

In game after /kill command I see "Unknown command.", but it should send only if command return false or command not processed at all, is not it? How can I fix it?

2. Why in cmd.exe (terminal) I see two logs at the same time? How can I fix it?


3. Why I must destroy commandManager and eventManagerNode before disabling server? Or it optional?

4. I can't find SQLite functions like db_create, db_query etc. Does they exist in Shoebill?


Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit - 123marvin123 - 24.08.2014

@DrumYum:
First question: I don't think CustomCommand was made for this purpose. Maybe mk124 can tell us more.
2.: Because the SA-MP Server & Shoebill prints both out.
3.: You don't need to destroy CommandManager / EventManager.
4.: You need to use Java Libraries for this. Shoebill only gives you SA-MP functions. Maybe this can help you:
http://www.tutorialspoint.com/sqlite/sqlite_java.htm


Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit - dusk - 24.08.2014

@DrumYum.

1. I'm not sure what the @CustomCommand annotation is for, but I do know a way to send a default message if the command doesn't exist. This is taken from the LVDM example gamemode, PlayerManager class:
Код:
eventManagerNode.registerHandler(PlayerCommandEvent.class, HandlerPriority.BOTTOM, (e) ->
		{
			Player player = e.getPlayer();
			player.sendMessage(Color.RED, "Unknown command. Type /help to see help.");
			e.setProcessed();
		});
The priority is "BOTTOM" which means it's the lowest one. Add you commands with a hight priority and this will only be executed if higher priority commands return false. You can find this class at shoebills github: https://github.com/Shoebill/examplel...erManager.java

Marvin, SAMP does have SQL functions: https://sampwiki.blast.hk/wiki/Category:SQLite


Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit - 123marvin123 - 24.08.2014

@dusk: I know, but I mean only Player, Vehicle and Object functions


Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit - DrumYum - 24.08.2014

Thanks for your answers, guys!

dusk, I saw this in LVDM-example, but I thought @CustomCommand it's like OnPlayerCommand analogue without automatic splitting arguments etc. Ok, I will try this way.

123marvin123, can I somehow disable one of log?

And I have new question: how I can connect Pawn script and Shoebill gamemode? I have administration system with 3k+ lines of code and I too lazy to rewrite it in Java. Maybe exists analogue of CallRemoteFunction? I saw SampCallbackManager class in javadoc, but I don't know what it is and how I can use it if this is what I need.


Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit - dusk - 24.08.2014

Quote:
Originally Posted by DrumYum
Посмотреть сообщение
Thanks for your answers, guys!

And I have new question: how I can connect Pawn script and Shoebill gamemode? I have administration system with 3k+ lines of code and I too lazy to rewrite it in Java. Maybe exists analogue of CallRemoteFunction? I saw SampCallbackManager class in javadoc, but I don't know what it is and how I can use it if this is what I need.
This is not yet possible. But I believe it's a feature that will be added in 1.1.


Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit - DrumYum - 25.08.2014

Oh, how long to wait before 1.1 release? :\

(Already passed: http://forum.sa-mp.com/showpost.php?...1&postcount=96)


Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit - 123marvin123 - 25.08.2014

We don't know a exact date. It will be released when it's finished.


Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit - Rancho - 25.08.2014

Still not cross-platform? If yes, I will try to compile it in linux.


Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit - CoaPsyFactor - 25.08.2014

I don't know if there is option not to be cross platform, isn't Java cross-platform language o.O


AW: Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit - NaS - 25.08.2014

Quote:
Originally Posted by CoaPsyFactor
Посмотреть сообщение
I don't know if there is option not to be cross platform, isn't Java cross-platform language o.O
Almost everything written in Java is (except GUI stuff sometimes, or OS related things), but the plugin itself isn't written in Java :O


Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit - 123marvin123 - 26.08.2014

@Rancho: This plugin is cross-platform compatible, you don't need to compile it yourself.


Re: AW: Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit - CoaPsyFactor - 26.08.2014

Quote:
Originally Posted by NaS
Посмотреть сообщение
Almost everything written in Java is (except GUI stuff sometimes, or OS related things), but the plugin itself isn't written in Java :O
LOL, you don't say plugin is not written in Java... and I was so sure it is -.-'

Really, I'm not stupid, sure know that....


Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit - DrumYum - 26.08.2014

If I don't need to destroy PlayerCommandManager and EventManagerNode, for what in example-lvdm they uninitialized?

Also, could anyone tell me, what is CommandGroup, HandlerPriority, .setHelpMessageSupplier and .setUsageMessageSupplier, also how and for what I can use all of it? I know by their names what they must do, but I want to know everything in detail.

UPD: oh, also I need to split admin commands by levels. I have idea to add level argument in @Command annotation, but I don't know, how to do it and I don't know is it possible or not. Or maybe I should split all levels in different classes? Level_1, Level_2 etc. and add to them @BeforeCheck with check for player level?

Thanks in advance.


Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit - 123marvin123 - 27.08.2014

@DrumYum: If you destroy a EventManagerNode / PlayerCommandManager, you will destroy all the events that are attached to it. So, if you add a PlayerConnectEvent to a Node, it won't be called anymore if you destroy it.

HandlerPriority defines the Priority of a Event. If you add a PlayerConnectEvent with High priority, and one with low priority, the one with the high priority will be called first.

The .setUsageMessageSupplier defines the message that appears if a person enters wrong arguments. If you have a command like this -> /mycmd [name] [level] you can display a custom message when the players enters wrong args.

You can make one like this:
PHP код:
        commandManager.setUsageMessageSupplier((playercommandprefixparamshelp) -> {
            
String message prefix command;
            for (
String param params) {
                
message += " [" param "]";
            }
            return 
message;
        }); 
You don't need to split your admin commands. Just create a new CommandGroup, for example:
PHP код:
commandManager.installCommandHandler(HandlerPriority.NORMAL);
commandManager.registerCommands(new MyCommands());
adminCommands = new CommandGroup();
adminCommands.registerCommands(new AdminCommands());
commandManager.registerChildGroup(adminCommands"admin"); 
with this method, you can access your admin commands like /admin -command- (/admin kick)


Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit - DrumYum - 27.08.2014

123marvin123, thank you very much! You saved me!


Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit - 123marvin123 - 27.08.2014

No problem, if you have any questions, you can post them here.