SpigotBridge API

May 23, 2016
SpigotBridge API
  • SpigotBridge
    Config Setup | Variables | Tutorial | API
    Step 1: Create a class that extends fadidev.spigotbridge.handlers.PluginHandler
    Code (PluginHandler Example):
    import fadidev.spigotbridge.handlers.PluginHandler;
    import fadidev.spigotbridge.handlers.Variable;

    public class ExamplePluginHandler extends PluginHandler {

        private Variable[] variables;

        public ExamplePluginHandler(long interval, Variable[] variables) {
            this.variables = variables;

            this.setInterval(interval);
            this.startTask();
        }

        // The variable which will be used in BungeeMSG will look like this: %<nameplugin>-<variablename>% or %<nameplugin>-<variablename>-p1/p2%
        // Let this method return your plugin name, for example: 'essentials'.
        @Override
        public String getVariableName() {
            return " < Name of your plugin > ";
        }

        @Override
        public Variable[] getVariables() {
            return variables;
        }
    }
    Step 2: Create a class that extends fadidev.spigotbridge.handlers.Variable
    Code (Variable Example):
    import fadidev.spigotbridge.handlers.Variable;
    import fadidev.spigotbridge.utils.enums.VariableType;
    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;

    import java.util.Collection;

    public class ExampleVariable extends Variable {

        // The variable which will be used in BungeeMSG will look like this: %<nameplugin>-<variablename>%or %<nameplugin>-<variablename>-p1/p2%
        // Let this method return your variable name, for example: 'worldname'.
        @Override
        public String getVariable() {
            return " < Variable Name > ";
        }

        // This method gives SpigotBridge the following instructions:
        // PLAYERDATA: The value which the method returns will be a different value for each player.
        // STANDARD: The value which the method returns will be one standard value.
        @Override
        public VariableType getType() {
            return VariableType.PLAYERDATA;
        }

        // Use this method if your VariableType is STANDARD.
        @Override
        public String getReplacement() {
            return null;
        }
       
        // Use this method if your VariableType is PLAYERDATA.
        @Override
        public String getReplacement(Player p) {
            return p.getWorld().getName();
        }

        // This method returns a collection of players of which a value is sent to the BungeeMSG plugin.
        @Override
        public Collection<? extends Player> getPlayers() {
            return Bukkit.getOnlinePlayers();
        }
    }
    Step 3: Register your variables when your plugin is enabled.
    Code (Register Variables):
    // 20L = 1 second, 100L = 5 seconds (The interval between the variables to be updated in BungeeMSG)
    long interval = 100;
    // Place all your variables in an Array.
    Variable[] variables = { new ExampleVariable() };
    // Register the PluginHandler
    SpigotBridge.getInstance().registerPluginHandler(new ExamplePluginHandler(interval, variables));

    How to create a vanish variable: (Hide players from TAB and target-able commands)
    - Let getVariableType(); return VariableType.PLAYERDATA;
    - Let getVariable(); return "vanish";
    - Let getReplacement(Player p); return "true"; or return "false"; (true if player is hidden, false if not hidden)
    Code (Implemented Methods):
    // Reset all variables in the BungeeMSG plugin.
    SpigotBridge.getInstance().clearData();

    // Reset all variables for a specific player in the BungeeMSG plugin.
    SpigotBridge.getInstance().clearData(Player p);

    // Update all variables.
    SpigotBridge.getInstance().updateData();

    // Update all variables for a specific player.
    SpigotBridge.getInstance().updateData(Player p);

    Don't forget to add softdepend: [SpigotBridge] or depend: [SpigotBrigde] to your plugin.yml

    << Back to the SpigotBridge plugin
  • Loading...
  • Loading...