ServerUi

Jun 21, 2019
ServerUi
  • Text Type Legend:
    Bold: Required
    Underlined: Recommended


    Using ServerUi on your server(top)

    1) Download the plugin and put it in your server's plugin folder.
    2) Restart/Start/Reload your server.
    3) Use the gui to enable a plugin, disable a plugin, and even stop or reload your server!
    4) Configure it (see Creating custom buttons without coding) to your liking!

    Creating custom buttons without coding(top)

    Using the config.yml file that comes with the plugin, you can create buttons that run commands! So, how do you do this? Go into the config.yml file and in the list called 'command-buttons' add a string like the default one, 'help'. You can use this for any command you like, although some commands might send an error if they are sent by the console!

    For example, the help command:
    Code (YAML):
    command-buttons: ['help']
    You can add multiple commands by separating them with a comma like this:
    Code (YAML):
    command-buttons: ['help', 'serverui']
    You can add a '/' in the command and it doesn't really matter, I just like the look of it without the '/'.
    Now, take a look at the buttons we just made!
    [​IMG]

    Using the ServerUi API to make a Button(top)

    Using the ServerUi API you can add buttons to the ServerUi interface!

    So, to get started, make sure you have the latest version of ServerUi.
    Import the API into your plugin's project and go into your onEnable() function and create a JButton. You need to make sure you change the values of the JButton before you add it to the API, like this:
    Code (Java):
    JButton button = new JButton("Tutorial Button");
    Now that we made a button, you can add values like a listener to it like this:
    Code (Java):
    button.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                Bukkit.getLogger().info("Button clicked!");
            }
     
    });
    Which will log 'Button clicked!' whenever we click the button! I am just doing this as an example, but you can add almost anything to the button!

    Now, we need to tell the ServerUi API we want it to use our button, so we can just add it using the ServerGui.addButton(Plugin p, JButton b) function.
    For me the plugin class is the same class I am adding the button in so I will use 'this' instead of 'Plugin p', and the JButton will be the JButton we just created, like this:
    Code (Java):
    ServerGui.addButton(this, button);
    And there we go! Your final code should look something like this:
    Code (Java):
    package <your package>

    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;

    import javax.swing.JButton;

    import org.bukkit.Bukkit;
    import org.bukkit.plugin.java.JavaPlugin;

    import me.astronomize.serverui.gui.ServerGui;

    public class Plugin extends JavaPlugin {

        public void onEnable() {
            JButton button = new JButton("Tutorial Button");
     
            button.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent arg0) {
                    Bukkit.getLogger().info("Button clicked!");
                }
     
            });
            ServerGui.addButton(this, button);
        }
    }
     
    And thats all you need to do to create a simple button! As I said before, you can do alot of things with this, all you need is your imagination(maybe also some java knowledge :p)!
  • Loading...
  • Loading...