Giter Site home page Giter Site logo

connector-addons's Introduction

Connector-Addons

Repository with compiled addons for ServerSelectorX connector

How to write an addon

In this tutorial I use the Eclipse IDE. The steps should not be much different for other IDEs.

  1. Create a new standard java project
  2. Right click your project -> Build Path -> Add External Archives -> Select your SSX Connector jar file
  3. Now repeat for spigot/bukkit
  4. Without creating a package, create a new class called "code" lower case (I know this goes against conventions)
  5. Let this class extend AddonClass
  6. Insert the required method getPlaceholders()

This is where you add your custom placeholders. First create a new hashmap, then add your placeholders to the hashmap like this:

// Adds placeholder {players} which is replaced with the number of online players
Map<String, String> map = new HashMap<>();
map.put("players", String.valueOf(Bukkit.getOnlinePlayers()));
return map;

Your class should now look like this:

public class code extends AddonClass {

  @Override
  public Map<String, String> getPlaceholders() {
    Map<String, String> placeholders = new HashMap<>();
    if (true){
      placeholders.put("example", config.getString("on"));
    } else {
      placeholders.put("example", config.getString("off"));
    }
    return placeholders;
  }

}

Configuration

If you need a config create a config.yml file in the same directory as code.class For this example something like this:

# {example} will be replaced with 'custom text' or 'custom text 2'
on: 'custom text'
off: 'custom text 2'

info.yml

This file should be in the same directory as code.java (and config.yml). An example should be clear enough:

name: Total Money
description: 'Adds the placeholder {money} which is the combined balance of all players on the server'
author: Derkades
version: 1.0.2
license: MIT
depends: [Vault] #If your addon depends on another plugin. See note 2 at the bottom of this file.

Compiling

  1. Save your work
  2. At the top, go to Project and click Clean...
  3. Make sure that your project is selected (or all projects selected), then click Clean.
  4. Right click project > Show In > System Explorer then open the selected directory
  5. In the bin directory, you should find the files code.class and info.yml
  6. Copy both files into a new folder. Optionally add a source file.
  7. If your folder now looks like this you are done!
  8. Submit a pull request to this repo so your addon is listed here.

Good to know

  • If you use any methods that are only available in certain versions of Bukkit, please explain in the description of your addon
  • You can use APIs from other plugins, just make sure that you put that plugin as a dependency in your info.yml and as a soft dependency in SSX connector plugin.yml. If you are using a public plugin please submit a pull request. Otherwise, open the jar using 7-zip and edit plugin.yml.
  • If you need to do something when your addon is loaded, you can override the method onLoad(). The config is loaded before onLoad() is called.
  • You can add any listener you want to the class, they are registered automatically. AddonClass already implements Listener.

connector-addons's People

Contributors

derkades avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.