[Tool/Web/Other] JSA-MP - SA-MP library written in Java.
#1

A while ago I wrote a library for the SAMP Query mechanism in Java. This library was using the Apache MINA API.
Yesterday, I wrote a library for the SAMP Query mechanism using the jBoss Netty API. JSA-MP only supports the INFO opcode. Other opcodes will be released in the next releases.


https://github.com/FabianM/JSA-MP


Server Info Example:

PHP код:
package org.faabtech.jsamp;
import org.faabtech.jsamp.SAMPRequest.Opcode;
import org.faabtech.jsamp.data.DataProvider;
import org.faabtech.jsamp.data.impl.InfoDataProvider;
import org.faabtech.jsamp.event.SAMPResponseListener;
import org.faabtech.jsamp.net.Client;
/**
 * Example class.
 * @author Fabian M.
 */
public class Example {
    public static 
void main(String[] args) {
        
SAMPRequest request = new SAMPRequest(new Client("188.165.206.114"7777), Opcode.INFO);
        
request.send(new SAMPResponseListener() {
            @
Override
            
public void messageReceived(DataProvider dataProvider) {
                
InfoDataProvider info = (InfoDataProviderdataProvider;
                
System.out.println(info.getPlayers());
            }
        });
    }

Server rules example:

PHP код:
package org.faabtech.jsamp;
import org.faabtech.jsamp.SAMPRequest.Opcode;
import org.faabtech.jsamp.data.DataProvider;
import org.faabtech.jsamp.data.impl.InfoDataProvider;
import org.faabtech.jsamp.data.impl.RuleDataProvider;
import org.faabtech.jsamp.event.SAMPResponseListener;
import org.faabtech.jsamp.net.Client;
import org.faabtech.jsamp.server.Rule;
/**
 * Example class.
 * 
 * @author Fabian M.
 */
public class Example {
    public static 
void main(String[] args) {
        
SAMPRequest request = new SAMPRequest(
                new 
Client("188.165.252.63"7852), Opcode.RULES);
        
request.send(new SAMPResponseListener() {
            @
Override
            
public void messageReceived(DataProvider dataProvider) {
                
RuleDataProvider ruleDataProvider = (RuleDataProviderdataProvider;
                for (
Rule rule ruleDataProvider.getRules()) {
                    
System.out.println(rule.getName() + ": " rule.getValue());
                }
            }
        });
    }

Client list example:
PHP код:
package org.faabtech.jsamp;
import org.faabtech.jsamp.SAMPRequest.Opcode;
import org.faabtech.jsamp.data.DataProvider;
import org.faabtech.jsamp.data.impl.ClientListDataProvider;
import org.faabtech.jsamp.event.SAMPResponseListener;
import org.faabtech.jsamp.net.Client;
import org.faabtech.jsamp.server.Player;
import org.faabtech.jsamp.server.Rule;
/**
 * Example class.
 * 
 * @author Fabian M.
 */
public class Example {
    public static 
void main(String[] args) {
        
SAMPRequest request = new SAMPRequest(
                new 
Client("188.165.252.63"7852), Opcode.CLIENT_LIST);
        
request.send(new SAMPResponseListener() {
            @
Override
            
public void messageReceived(DataProvider dataProvider) {
                
ClientListDataProvider clientListDataProvider = (ClientListDataProviderdataProvider;
                for (
Player player clientListDataProvider.getPlayers()) {
                    
System.out.println(player.getUsername() + ": " player.getScore());
                }
            }
        });
    }

Detailed player info example:

PHP код:
package org.faabtech.jsamp;
import org.faabtech.jsamp.SAMPRequest.Opcode;
import org.faabtech.jsamp.data.DataProvider;
import org.faabtech.jsamp.data.impl.PlayerDataProvider;
import org.faabtech.jsamp.event.SAMPResponseListener;
import org.faabtech.jsamp.net.Client;
import org.faabtech.jsamp.server.Player;
/**
 * Example class.
 * 
 * @author Fabian M.
 */
public class Example {
    public static 
void main(String[] args) {
        
SAMPRequest request = new SAMPRequest(
                new 
Client("188.165.252.63"7852), Opcode.DETAILED_PLAYER_INFO);
        
request.send(new SAMPResponseListener() {
            @
Override
            
public void messageReceived(DataProvider dataProvider) {
                
PlayerDataProvider playerDataProvider = (PlayerDataProviderdataProvider;
                for (
Player player playerDataProvider.getPlayers()) {
                    
System.out.println(player.getPlayerId() + ": " player.getPing());
                }
            }
        });
    }

Reply
#2

Amazing, great idea! Maybe you could make a JAVA application for JAVA supporting mobile phones to see their SA-MP stats on their phone.

Good luck!
Reply
#3

Quote:
Originally Posted by Flyfishes
Посмотреть сообщение
Amazing, great idea! Maybe you could make a JAVA application for JAVA supporting mobile phones to see their SA-MP stats on their phone.

Good luck!
Thank you for the Idea.
Reply
#4

Nice!
Reply
#5

Support for the INFO, RULES, CLIENT_LIST and DETAILED_PLAYER_INFO opcodes.

https://github.com/FabianM/JSA-MP
Reply
#6

I'm thinking something like SA-MP and Minecraft. E.G show the SA-MP player numbers on a Minecraft server?

Or have i got the wrong type of java or something...
Reply
#7

Quote:
Originally Posted by linuxthefish
Посмотреть сообщение
I'm thinking something like SA-MP and Minecraft. E.G show the SA-MP player numbers on a Minecraft server?

Or have i got the wrong type of java or something...
Java is java. You're right.
Reply
#8

some screen please ?
Reply
#9

Quote:
Originally Posted by Hip-hop
Посмотреть сообщение
some screen please ?
Uhh?? This isn't a virus, you can easily look at the source code. And by the way, this isn't a custom map or something.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)