SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 03/04/2016, 05:31 PM   #791
mk124
Huge Clucker
 
mk124's Avatar
 
Join Date: Jul 2007
Location: Nanning, China
Posts: 319
Reputation: 59
Default Re: [UPDATE][SNAPSHOT][Java 8] Shoebill 1.1 - SA-MP Java Development Kit

@Su37Erich: The UsageMessageSupplier changed in 1.3, it now looks like this:
PHP Code:
    @FunctionalInterface
    
public interface UsageMessageSupplier {
        
String get(Player playerString prefixCommandEntry command);
    } 
and the default one looks like this:
PHP Code:
public static final UsageMessageSupplier DEFAULT_USAGE_MESSAGE_SUPPLIER = (playerprefixcommand) ->
    {
        
StringBuilder stringBuilder = new StringBuilder("Usage: " prefix command.getCommand());
        if(
command.getParameters().length 0) {
            for(
int i 0command.getParameters().lengthi++) {
                
stringBuilder.append(" [").append(command.getParameters()[i].name()).append("]");
            }
        }
        if(
command.getHelpMessage() != null)
            
stringBuilder.append(" - ").append(command.getHelpMessage());
        return 
stringBuilder.toString();
    }; 
__________________
mk124 is offline   Reply With Quote
Old 03/04/2016, 06:07 PM   #792
Su37Erich
Huge Clucker
 
Su37Erich's Avatar
 
Join Date: Dec 2013
Location: USEA Strangereal
Posts: 343
Reputation: 16
Default Re: [UPDATE][SNAPSHOT][Java 8] Shoebill 1.1 - SA-MP Java Development Kit

Thanks!
By the way, something was changed in the PlayerKeyStateChangeEvent? Yesterday it was detecting the keys fine but today it isn't working:
Code:
event.registerHandler(PlayerKeyStateChangeEvent.class, (e) ->{
            Player player= e.getPlayer();
            if(isSpec(player)){
                System.out.println("Work");
                if(player.getKeyState().isKeyPressed(PlayerKey.JUMP)){
                //do something
                }else{
                    System.out.println("Didn't work");
                }
And it prints:
Work
Didn't work
When I press the SPRINT key (I have tested it with other players)
Also it prints something like this
net.gtaun.shoebill.object.impl.PlayerKeyStateImpl@ 17b0699[keys=0,upDown=0,leftRight=0,action=0,crouch=0,fire =0,sprint=0,secondAttack=0,jump=0,lookRight=0,hand break=0,lookLeft=0,subMission=0,lookBehind=0,walk= 0,analogUp=0,analogDown=0,analogLeft=0,analogRight =0]
__________________
Neucom Inc.
Su37Erich is offline   Reply With Quote
Old 03/04/2016, 06:17 PM   #793
mk124
Huge Clucker
 
mk124's Avatar
 
Join Date: Jul 2007
Location: Nanning, China
Posts: 319
Reputation: 59
Default Re: [UPDATE][SNAPSHOT][Java 8] Shoebill 1.1 - SA-MP Java Development Kit

@Su37Erich: I tested it right now and it was working fine. Are you sure that you didn't mix up the Key definitions? In you code you use PlayerKey.JUMP but in your error description you say "When I press SPRINT". JUMP and SPRINT are two different keys (Shift / Spacebar).
__________________
mk124 is offline   Reply With Quote
Old 03/04/2016, 06:30 PM   #794
Su37Erich
Huge Clucker
 
Su37Erich's Avatar
 
Join Date: Dec 2013
Location: USEA Strangereal
Posts: 343
Reputation: 16
Default Re: [UPDATE][SNAPSHOT][Java 8] Shoebill 1.1 - SA-MP Java Development Kit

Oh sorry, I posted it wrong. I did the test using the SPRINT key (and pressing the space bar).
But as I said before, it was working yesterday.
I haven't made any changes on it
Maybe it's because I am using the event manager in another class?
__________________
Neucom Inc.
Su37Erich is offline   Reply With Quote
Old 03/04/2016, 08:28 PM   #795
mk124
Huge Clucker
 
mk124's Avatar
 
Join Date: Jul 2007
Location: Nanning, China
Posts: 319
Reputation: 59
Default Re: [UPDATE][SNAPSHOT][Java 8] Shoebill 1.1 - SA-MP Java Development Kit

@Su37Erich: I will take a look at it tomorrow, but it shouldn't be caused by the EventManager I think.

//Edit:

This code is working perfectly fine with the newest plugin, api and runtime:
PHP Code:
getEventManager().registerHandler(PlayerKeyStateChangeEvent.class, -> {
            
Player player e.getPlayer();
            if(
player.getKeyState().isKeyPressed(PlayerKey.SPRINT)) {
                
player.sendMessage(Color.GREEN"* You pressed SPRINT!");
            } else {
                
player.sendMessage(Color.RED"* You didn't press SPRINT!");
            }
        }); 
You can try to create a new EventManagerNode, but I don't think this is related to this issue.
__________________

Last edited by mk124; 04/04/2016 at 12:38 PM.
mk124 is offline   Reply With Quote
Old 04/04/2016, 07:46 PM   #796
mk124
Huge Clucker
 
mk124's Avatar
 
Join Date: Jul 2007
Location: Nanning, China
Posts: 319
Reputation: 59
Default Re: [UPDATE][SNAPSHOT][Java 8] Shoebill 1.1 - SA-MP Java Development Kit


I just created an Project Generator to create full Shoebill maven projects. The tool is easy-to-use and really quick.
After your project has been generated, you can use your IDE to import the project.

Here you can get a little taste:




Download:
__________________
mk124 is offline   Reply With Quote
Old 05/04/2016, 08:40 PM   #797
kumasro
Little Clucker
 
Join Date: Jul 2014
Location: Slovakia
Posts: 2
Reputation: 0
Default Re: [UPDATE][SNAPSHOT][Java 8] Shoebill 1.1 - SA-MP Java Development Kit

beeest <3 nice job bro !!! i really like this !
kumasro is offline   Reply With Quote
Old 06/04/2016, 10:14 AM   #798
mk124
Huge Clucker
 
mk124's Avatar
 
Join Date: Jul 2007
Location: Nanning, China
Posts: 319
Reputation: 59
Default Re: [UPDATE][SNAPSHOT][Java 8] Shoebill 1.1 - SA-MP Java Development Kit

@kumasro: Thank you, I'm glad you like it
__________________
mk124 is offline   Reply With Quote
Old 06/04/2016, 07:38 PM   #799
Su37Erich
Huge Clucker
 
Su37Erich's Avatar
 
Join Date: Dec 2013
Location: USEA Strangereal
Posts: 343
Reputation: 16
Default Re: [UPDATE][SNAPSHOT][Java 8] Shoebill 1.1 - SA-MP Java Development Kit

Thanks for your answer, I'll be trying to find out what's happening.
Furthermore, I have tried to change the default message but I can't figure how, here is what I tried:
Code:
public final PlayerCommandManager.UsageMessageSupplier CMESSAGE = (player, prefix, command) ->
    {
        StringBuilder stringBuilder = new StringBuilder(" Correct usage: " + prefix + command.getCommand());
        if(command.getParameters().length > 0) {
            for(int i = 0; i < command.getParameters().length; i++) {
                stringBuilder.append(" <").append(command.getParameters()[i].name()).append(">");
            }
        }
        if(command.getHelpMessage() != null)
            stringBuilder.append(" - ").append(command.getHelpMessage());
        return stringBuilder.toString();
    };
Code:
commandManager.setUsageMessageSupplier(CMESSAGE);
Another try:
Code:
commandManager.setUsageMessageSupplier((player, prefix, command) ->
        {
            StringBuilder stringBuilder = new StringBuilder(" Correct usage: " + prefix + command.getCommand());
            if(command.getParameters().length > 0) {
                for(int i = 0; i < command.getParameters().length; i++) {
                    stringBuilder.append(" <").append(command.getParameters()[i].name()).append(">");
                }
            }
            if(command.getHelpMessage() != null)
                stringBuilder.append(" - ").append(command.getHelpMessage());
            return stringBuilder.toString();
        });
But I always get something like this:
java.lang.AbstractMethodError: dev.acesamp.EventManager$$Lambda$1548/21424390.get(Lnet/gtaun/shoebill/object/Player;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/StringLjava/lang/String;
__________________
Neucom Inc.
Su37Erich is offline   Reply With Quote
Old 06/04/2016, 07:59 PM   #800
mk124
Huge Clucker
 
mk124's Avatar
 
Join Date: Jul 2007
Location: Nanning, China
Posts: 319
Reputation: 59
Default Re: [UPDATE][SNAPSHOT][Java 8] Shoebill 1.1 - SA-MP Java Development Kit

@Su37Erich: Please keep in mind that UsageMessageSuppliers are now assigned to CommandGroups and not to the PlayerCommandManager. You can set a different MessageSupplier for each CommandGroup. If you don't change it when you create a CommandGroup, the default one will be used.

Please make sure that you got the newest API and Common version (look at your pom.xml and your resources.yml and make sure that resources.yml uses shoebill-common version 1.3 too).
__________________
mk124 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] [SHOEBILL] Gamemode Reloader mk124 Tools and Files 10 16/05/2016 06:29 PM
[Plugin] [ALPHA] Project Shoebill - Java for SA:MP Development Kit - Milestone 1 (20110701) mk124 Plugin Development 57 05/04/2016 08:23 PM
[GameMode] [Java] PROJECT NEW WL-World (Based on Shoebill, WIP) mk124 Gamemode Scripts 12 01/11/2014 11:16 PM
[FilterScript] Dealership plugin for shoebill (Java) 123marvin123 Filterscripts 4 08/06/2014 02:17 PM


All times are GMT. The time now is 12:33 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.