Create your first BungeeCord plugin (Proxy) - Historical

Applied By nxtguy: Jun 2, 2014 at 2:40 AM

Create your first BungeeCord plugin (Proxy)
[1] First create a brand new project, the name is up to you, but for the project we are demonstrating in this tutorial, the name is going to be "TestProject".

[2] Make sure you have BungeeCord in your IDE's build path! (Eclipse, IntelliJ, NetBeans, etc)

First you want to start off with the basics!

Code (Text):

/*
* This is going to be your first project, Note: "TestProject" is just a name --- your project name can be * anything
*/
package me.gabe.plugin;

import net.md_5.bungee.api.plugin.Plugin;

public class TestProject extends Plugin {

}

 
[3] Now we're going to move onto the onEnable method.

Code (Text):

package me.gabe.plugin;

import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin;

public class TestProject extends Plugin {

    @Override
    public void onEnable() {
        ProxyServer.getInstance().getPluginManager().registerCommand(this, new Hi(this));
        /*
        * Create the class "Hi"
        */

    }
}
 
[4] Working on the class "Hi" now, the command.

Code (Text):

package me.gabe.plugin;

import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;


class Hi extends Command {


    public Hi(TestProject This) {
        super("command", "permission");
    }

    public void execute(CommandSender sender, String[] args) {
        if ((sender instanceof ProxiedPlayer)) {
          ProxiedPlayer p = (ProxiedPlayer)sender;
          if (p.hasPermission("testproject.hi"))
              p.sendMessage(ChatColor.GOLD + "Created your project! :)");
              }
          }
    }
   
[5] At last you have to create your plugin.yml with the following example code:

Code (Text):

name: TestProject
main: me.gabe.plugin.TestProject
author: Gabe #you can also sentry your name here ;)
#you DON'T have to register the commands in the plugin.yml!
 
[6] You're done! Compile the project and run it on your BungeeCord server in order to test it!

[7] If you want to continue your learning progress and learn more, I suggest going to the Event API Tutorial found here if you haven't already!

- Gabe