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 deradic deradic Dec 20, 2014 at 03:08 UTC - 0 likes

    @Unreal852: Go I received your PM.

    I don't know what OS you are running or which SwiftApi version you want to use.

    The stable public SwiftApi release is 1.7. It requires at least Thrift 0.9.1. I dont use Windows, but i recommend installing Chocolatey, a package manager for windows (assuming you use windows). It is probably the easiest way to get going:

    Open up a command prompt (cmd.exe) with administrator rights. Copy/paste: `@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin`

    It will install chocolatey. When it's done, close the command prompt. You can now install software using 2 methods: - command line (cmd.exe) - run command ([win] + [R])

    Type in `choco install thrift`. It will install thrift 0.9.1. Aditionally you might want to: - `choco install javaruntime` - `choco install java.jdk` - `choco install maven`

    Or just simply chain em into 1 command `choco install thrift javaruntime java.jdk maven`. After installation, close + reopen command prompt (with admin rights) and you should be able to use the `thrift` command. If not; locate the folder that has the thrift binary/executable/.bat/.exe and add that folder to your PATH. Then i'tll work.

    If you are using SwiftApi 2.0, you need thrift 0.9.2. You can download it [from this page](https://thrift.apache.org/download). I think the .exe is usable using the command prompt, but im not sure.

    Both swiftapi versions are not going to be updated anymore for Bukkit.

  • Avatar of Unreal852 Unreal852 Dec 17, 2014 at 19:26 UTC - 0 likes

    Hi, can someone send me the C# and Java libraries because i can't get the thrift compiler to work.

  • Avatar of adamwbb adamwbb Dec 08, 2014 at 16:39 UTC - 0 likes

    bukkit has been restored by MD_5

    you can obtain bukkit through spigot website

  • Avatar of deradic deradic Dec 04, 2014 at 14:20 UTC - 0 likes

    @J5lx: Go I doubt we'll see a stable plugin popping up that bridges bukkit plugins perfectly to sponge.

    I'm very positive about Sponge being the way 2 go. Api looks good and the core developers are experienced.

    API 1.0 Release news from Sponge just yesterday.

    Apache Thrift v0.9.2 has also been release in mean time, which was a requirement for SwiftApi v2 release.

    I moved over the repository to Github so i could integrate it with my fancy Github Pages for documentation etc. http:robinradic.github.io/swiftapi/, i will start to slowly recode the plugin towards Sponge.

  • 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

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,884
Recent files

Authors