Providing multipliers - AlonsoAliaga/VaultMultipliers GitHub Wiki

Adding multipliers to the plugin

If you are a developer and want to provide your own multipliers for currency follow this guide.
Adding new multipliers is really simple.

First, we need to make sure the plugin is enabled.

    @Override
    public void onEnable() {
        if(getServer().getPluginManager().getPlugin("VaultMultiplier") != null) {
            //Code here
        }
    }


Second, we need to create a class that extends com.alonsoaliaga.vaultmultipliers.multipliers.Multiplier.
We create the class and implement the methods.
We also add a boolean to check if it's enabled in case we want.

public class MultiplierHook extends Multiplier {
    private MainClass plugin;
    private boolean registered;
    public MultiplierHook(AlonsoLevels plugin) {
        super(plugin);
        this.plugin = plugin;
        registered = register();
    }
    @Override
    public double getAdditionalMultiplier(Player player) {
        return 0;
    }
    @Override
    public double getAdditionalMultiplier(UUID uuid) {
        return 0;
    }
    public boolean isRegistered() {
        return registered;
    }
}


Third, in our main class we create a new instance for MultiplierHook.

    @Override
    public void onEnable() {
       if(getServer().getPluginManager().getPlugin("VaultMultiplier") != null) {
          MultiplierHook multiplierHook = new MultiplierHook(this);
          if(multiplierHook.isRegistered()) {
             getServer().getConsoleSender().sendMessage("VaultMultiplier hooked successfully!");
          }else{
             getServer().getConsoleSender().sendMessage("VaultMultiplier couldn't be hooked successfully!");
          }
      }
   }

Forth, we connect the methods we implemented with our own multiplier system.

public class MultiplierHook extends Multiplier {
    private MainClass plugin;
    private boolean registered;
    //This is an example
    private HashMap<UUID,Double> multiplierMap = new HashMap<>();
    public MultiplierHook(AlonsoLevels plugin) {
        super(plugin);
        this.plugin = plugin;
        registered = register();
        //This is an example too
        multiplierMap.put(UUID.fromString("e1c1a194-7e86-414f-86bb-42d82a21cfb8"),2.5);
        multiplierMap.put(UUID.fromString("800352cc-9f72-4b85-bde4-fbb626a95b53"),1.0);
    }
    @Override
    public double getAdditionalMultiplier(Player player) {
        return multiplierMap.getOrDefault(player.getUniqueId(),0.0);
    }
    @Override
    public double getAdditionalMultiplier(UUID uuid) {
        return multiplierMap.getOrDefault(uuid,0.0);
    }
    public boolean isRegistered() {
        return registered;
    }
}


Remember multiplierMap is just an example, you must provide a method that returns the correct multiplier amount based on player/uuid.

Congratulations! You plugin is now providing additional multiplier for other plugins!

Check this guide to know how to use multipliers from other plugins.