PrisonRanksX API

Jul 28, 2019
PrisonRanksX API
  • API Usage:
    1.Loading the API

    Code (Java):
    PRXAPI api; //make a new field

    public class test extends JavaPlugin {

      public void onEnable() {
        api = new PRXAPI();  //load it in onEnable
      }
        public String getRank(Player player) { //example method to get player rank
          api.getPlayerRank(player.getName()); //get player rank for offline mode
          api.getPlayerRank(player.getUniqueId().toString());  //get player rank when the USE-UUID is Enabled
         
        }
    }
    2.getSafePlayer(Player); method
    this method will return a UUID as a String or a Player Name according to USE-UUID whether its true or false. so for example to use it in any prisonranksx method.
    Code (Java):
    @EventHandler
    pubilc void onJoin(PlayerJoinEvent e) {
      String rank = PRXAPI.getPlayerRank(getSafePlayer(e.getPlayer());
      e.getPlayer().sendMessage("Your rank is: " + rank);
    }
    instead of doing this:
    Code (Java):
    @EventHandler
    public void onJoin(PlayerJoinEvent e) {
      if(PRXAPI.UUIDOption() == true) {
        e.getPlayer().sendMessage("Your rank is: " + PRXAPI.getPlayerRank(e.getPlayer().getUniqueId().toString());
      } else {
        e.getPlayer().sendMessage("Your rank is: " + PRXAPI.getPlayerRank(e.getPlayer().getName());
      }
    }
    3.Events

    Code (Java):
    @EventHandler
    public void onRankup(XRankupEvent e) {} //fired when you rankup OR rankset/rankreset a player | Can be cancelled

    @EventHandler
    public void onRankupMax(XRankupMaxEvent e) {} //fired when you do /rankupmax | Can be cancelled

    @EventHandler
    public void onPrestige(XPrestigeEvent e) {} //fired when you do /prestige OR setprestige/delplayerprestige/resetprestige | Can be cancelled

    @EventHandler
    public void onAutoRankup(XAutoRankupEvent e) {} //fired everytime you rankup while the autorankup is enabled | Can be cancelled
    4.Other stuff
    you can get the plugin main class using this method

    Code (Java):
    PRXAPI.getPluginMainClass();
    you can use the other classes i used in prisonranksx

    Code (Java):
    com.prisonranksx.NumberAPI(); //useful methods to manage numbers
    com.prisonranksx.reflections.Actionbar(); //version independent actionbar class
    com.prisonranksx.OnlinePlayers(); //version independent online players class
    com.prisonranksx.ListUtils(); //somehow useless
  • Loading...
  • Loading...