SwiftApi
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
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
If anyone is still intrested, I have a working version of MineCenter
I compiled a new version from the source from which I've removed a lot of the features in favour of faster loading.
The Swift API plugin still works as of Spigot 1.9.4, yet to test on 1.10
If you download the avalible Minecenter from their website, you'll see that the console will not load at all.
You can get the working version from here, which I've named 'MinecenterLite' http://www.filedropper.com/minecenterlitepublic
I orignally compiled this to make it more reliable since this is the only application I use to view my console, and as it was getting older things were breaking.
If for any reason the link breaks, add me on skype and I'll send you a copy: skype: samadair15
Is there a working remote terminal for 1.7.10 that someone could point me in the direction to? I see minecenter.org has been dead for half a year, so theres no point barking up that tree.
@Unreal852 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.
Hi, can someone send me the C# and Java libraries because i can't get the thrift compiler to work.
bukkit has been restored by MD_5
you can obtain bukkit through spigot website
@J5lx 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.
@deradic
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!
<<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.
@deradic
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?
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
@Nensec
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.
I hope this project didn't end up abandoned, at least on the extension part? : /
@Alkaline756
Very impressive! I will give this a try!
I just want to say thank you for that great plugin. I programmed a tool which works with your API: http://minecraftserverlauncher.besaba.com/
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.
@Nensec
Thanks for the input - I agree with your angle
@Nensec
I think creating an extension api to easily create SwiftApi extensions like i proposed in this forum thread:http://dev.bukkit.org/bukkit-plugins/swiftapi/forum/68837-implementing-an-extension-api/?unread would be required in order not to bloat the core jar file.
It would also allow other developers to create extensions with ease. Though i think it would still be preferable to first know the impact on memory/cpu of the thrift generated code. Because i will most defiantly create the extensions listed in that topic and add them to my server, so it has to be tuned for good performance.
I've started to implement SwiftAPI in a project for my MC server, so far really loving the strong typed interface through this thrift ( never heard of it before! ) to communicate with my MC server!
I suggest that if you intend to add things like Vault or Essentials you should keep the thrifty strong-typed interface, perhaps simply make them addons to the swift api instead of part of the core jar. If you (just) add one generic method for all plugins you gain compatibility with all mods, but you lose the strong-typed interface. So doing both might be an idea?
After all these are server jars, not client. Keeping size down is nice, but not essential. Chopping it up into pieces you allow people to not have a bloated jar if they don't use essentials or vault, but for those who do you can just add them.
Just my 2 euro cents.
-deleted
@phybros
Funny coincidence, i was just toying around with making bukkit plugins and extending swiftapi. I have created some minor working testing plugins but yet have to create a working swiftapi extension.
I'm not a Java programmer, but i do feel i can contribute with some help/tips along the way. but most importantly i certainly want to and most probably will do anyways for personal requirements (web-cms for minecraft).
I've created several forum threads instead not to fill up the comments here and allow better way of handling the issues/questions.
If you could check those out i can start writing