SwiftApi

SwiftApi Logo

What is SwiftApi?

SwiftApi is an Apache Thrift based API for CraftBukkit Minecraft servers. This API allows simple calls to Bukkit methods over the internet using your favorite programming language. This plugin acts as the server component, allowing you to write client programs/websites/apps that can talk to your CraftBukkit server in almost any programming language!

SwiftApi 2.0

SwiftApi-2.0-alpha is now available for download together with SwiftApiVault-1.0-alpha. Check out the wiki for more information.

What can you do with it?

Basically, SwiftApi allows you write awesome code and apps that can talk to and control your Minecraft server.

An example of such an app is MineCenter. Check it out at http://minecenter.org

Configuration Options

Edit the plugins/SwiftApi/config.yml file to your liking.

The most important options are:

# Authentication Information (CHANGE THESE)
username: admin
password: password
salt: saltines

Leaving these at default would make it easy for an attacker to use this API on your server.

Creating a Client App

Once you have downloaded the Apache Thrift compiler, you can create a client app in a few lines of code.

Check out the example PHP project here: https://github.com/phybros/swiftapi-example-php

Try the C#.NET/VB.NET tutorial here: http://dev.bukkit.org/server-mods/swiftapi/pages/examples/c-net-vb-net/

Generate the Client Library

You can generate the client library (example is in C#) by typing

thrift -r --gen csharp SwiftApi.thrift

The -r option tells the compiler to generate code for all files (including ones that are referenced in SwiftApi.thrift with the include directive. The gen csharp option tells the compiler to generate C# code. This command will leave you with a gen-csharp directory with all the code you need to connect to a server running the SwiftApi plugin.

Include the Code in your App

If you're using C#, you can just drag all the source files right into your client app to use them, or alternatively you could create a new project with the generated files to keep your code and the generated code seperate.

Examples

Visit the Examples page for examples of how to use the code.

Here's an example in C#:


//open a connection to a server running SwiftApi
TSocket socket = new TSocket("your.bukkitserver.org", 21111);
socket.Open();

//create a new SwiftApi client object
TBinaryProtocol protocol = new TBinaryProtocol(new TFramedTransport(socket));
SwiftApi.Client client = new SwiftApi.Client(protocol);

//get the server version and output it
Console.WriteLine("Server Version: " + client.getServerVersion(authString));

//close the connection
socket.Close();

Because the code is based on Apache thrift, you have access to many of the complex types in the CraftBukkit API, such as the Player object.

This example is in C#, but the thrift compiler is able to create libraries for almost ANY programming language.

Visit the Examples page for examples in some other languages

Available Programming Languages

As of version 0.9.0 of Apache Thrift, the following languages are available:

  • Actionscript 3 (AS3)
  • C (using GLib)
  • C
  • C#
  • Cocoa (Objective-C on Mac OS and iOS)
  • Delphi
  • Erlang
  • Go
  • Haskell
  • Java
  • Javascript
  • OCaml
  • Perl
  • PHP
  • Python (including Twisted async support)
  • Ruby
  • Smalltalk

Documentation

Full API documentation (generated by the Thrift compiler!) is available at http://willwarren.com/docs/swiftapi/latest.

Code

Think you can improve SwiftApi? Fork the repo on Bitbucket and submit a pull request!

Repo URL: https://bitbucket.org/phybros/swiftapi

Notes

This plugin sends anonymous usage statistics to http://mcstats.org/

To opt out, set opt-out to true in plugins/PluginMetrics/config.yml

You must login to post a comment. Don't have an account? Register to get one!

  • Avatar of J5lx J5lx Nov 18, 2014 at 16:32 UTC - 0 likes

    @deradic: Go

    Thanks for the link to the topic in the Sponge forums. I already knew the other sites though :) In meantime it also seems to me that Sponge will have some kind of support for Bukkit plugins ("Bukkit plugins may run on Sponge without change due to efforts by the community." - no clue whether that means API or ABI compatibility or whether the latter one is even important in Java), and KHobbits (Essentials) as well as sk89q (WorldEdit/-Guard) are involved with Sponge anyway, so I'm quite open-minded regarding Sponge by now, let's see how it works out. However, thanks for your response!

  • Avatar of deradic deradic Oct 03, 2014 at 13:29 UTC - 0 likes

    <<reply 2355455="">>

    Take a minute to read this topic a bit: http://forums.spongepowered.org/t/isnt-dinnerbone-updating-bukkit-to-1-8/2375/16

    More information:
    http://www.reddit.com/r/spongeproject
    http://spongepowered.org/

    SwiftApi 2.0 will be released for sponge only. Bukkit is dead.

  • Avatar of J5lx J5lx Sep 29, 2014 at 15:27 UTC - 0 likes

    @deradic: Go

    AFAIK it is not that clear whether Bukkit can be continued or not at the moment. Will SwiftApi 2.0 be released for Bukkit if it becomes clear that the project will be continued?

    Last edited Sep 29, 2014 by J5lx: sdfsdf
  • Avatar of deradic deradic Sep 08, 2014 at 20:30 UTC - 1 like

    Phybros has transfered project ownership to me.
    Considering bukkit is now dead, SwiftApi 2.0 will not be released for Bukkit.

    I do however have full intention of making SwiftApi 2.0 for the new Sponge project, which has taken up shape really fast as the "next gen Bukkit"

    Stay tuned for more

  • Avatar of deradic deradic Aug 08, 2014 at 17:13 UTC - 0 likes

    @Nensec: Go

    Far from it! Most of it is done.

    The release will not be before Apache updates Thrift to v0.9.2, which should be soon. There's already a release candidate going.

  • Avatar of Nensec Nensec Aug 04, 2014 at 09:32 UTC - 0 likes

    I hope this project didn't end up abandoned, at least on the extension part? : /

    Last edited Aug 04, 2014 by Nensec
  • Avatar of phybros phybros Jul 30, 2014 at 13:39 UTC - 0 likes

    @Alkaline756: Go

    Very impressive! I will give this a try!

  • Avatar of Alkaline756 Alkaline756 Jul 30, 2014 at 12:52 UTC - 1 like

    I just want to say thank you for that great plugin. I programmed a tool which works with your API: http://minecraftserverlauncher.besaba.com/

  • Avatar of tunabomber tunabomber Jul 22, 2014 at 20:15 UTC - 1 like

    Thanks phybros! I am so glad to get this 1.7 version. I haven't seen any issues with it yet. I should get some of the outstanding MineCenter items addressed soon now.

  • Avatar of phybros phybros Jul 20, 2014 at 01:10 UTC - 0 likes

    @Nensec: Go

    Thanks for the input - I agree with your angle

Facts

Date created
Sep 03, 2012
Categories
Last update
Sep 01, 2014
Development stage
Release
Language
  • enUS
License
GNU General Public License version 3 (GPLv3)
Curse link
SwiftApi
Downloads
6,536
Recent files

Authors