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

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?
Reply

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

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.
Reply

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?
Reply

@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
Reply

@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
Reply

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

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.
Reply

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.
Reply

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

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

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

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

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

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
Reply

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

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....
Reply

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.
Reply

@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)
Reply

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

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


Forum Jump:


Users browsing this thread: 25 Guest(s)