18.01.2011, 14:52
(
Последний раз редактировалось Faab234; 20.02.2011 в 13:08.
)
Welcome.
Today, I was working on an API for SAMP written in Java. Finally, I'm done with version 1.1.0 Alpha.
Currently.
Currently, JSA-MP has only support for the Query Mechanism.
Requirements.
http://code.******.com/p/jsa-mp/
Examples, tutorials
Here I'll post tutorials and examples..
Example Code: Get info of your Server.
End
Credits: Faab234 A.K.A Fabian M
Rate/Hate.
Today, I was working on an API for SAMP written in Java. Finally, I'm done with version 1.1.0 Alpha.
Currently.
Currently, JSA-MP has only support for the Query Mechanism.
Requirements.
- JVM (Java Virtual Machine)
- JDK
- Apache Mina (NIO Library)
- slf4j Library
- Eclipse
http://code.******.com/p/jsa-mp/
Examples, tutorials
Here I'll post tutorials and examples..
Example Code: Get info of your Server.
Код:
/** * Copyright © 2011 Fabian M <faabtech.com> * * More information about the JSAMP API may be found on these websites: * http://faabtech.com/projects/java/jsampn...4.78131550 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the fsollowing conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ package jsamp.example; import org.faabtech.jsamp.event.OnReadyListener; import org.faabtech.jsamp.event.SAMPAdapter; import org.faabtech.jsamp.query.QueryHandler; /** * @author Fabian * */ public class Example { /** * Our variables */ private static final String ADDRESS = ""; // Your SAMP IP private static final int PORT = 7777; //Your SAMP port usually 7777 private static final char COMMAND = QueryHandler.INFO; // The query command /** * @param args */ public static void main(String[] args) { /** * We will construct an new Instance of the queryhandler */ QueryHandler query = new QueryHandler(ADDRESS, PORT, COMMAND); /** * We're adding an on ready listener. * This event will executed when the Query is sended and decoded. */ query.setOnReadyListener(new OnReadyListener() { // New instance of the on ready listener /* * (non-Javadoc) * @see org.faabtech.jsamp.event.OnReadyListener#run(org.faabtech.jsamp.event.SAMPAdapter) */ @Override public void run(SAMPAdapter adapter) { // Because the Superclass of QueryHandler is the SAMPAdapter, the param is SAMPAdapter /** * This method will be executed when the query is sended and decoded. */ QueryHandler current = ((QueryHandler) (adapter)); // Because the param adapter only contains the members of SAMPAdapter we need to cast it. int players = current.getInfo().getPlayers(); // Get the players System.out.println(players); }}); } }
Credits: Faab234 A.K.A Fabian M
Rate/Hate.