Interface ITokenEnchant


public interface ITokenEnchant
ITokenEnchant provides the basic APIs which allow anyone to create a custom enchantment.
The cusom enchantment effects developed using this API can be automatically loaded and integrated into TokenEnchant plugin.

You can also access this plugin's token management methods through its public methods as:
 
 import com.vk2gpz.tokenenchant.api.*;
 ...
 ITokenEnchant teAPI = ITokenEnchant.getInstance();
 if (teAPI != null) {
 int token =  teAPI.getTokensImpl(player); //player can be OfflinePlayer
 teAPI.setTokensImpl(p, amount); // current = amount
 teAPI.addTokensImpl(p, amount);  // current = current +amount
 teAPI.removeTokensImpl(p, amount);// current = current - amount
 }
 ...
 
 
See Also:
  • JavaPlugin
  • Method Summary

    Modifier and Type
    Method
    Description
    org.bukkit.inventory.ItemStack
    addEnchantments(org.bukkit.inventory.ItemStack itemstack, Map<CEHandler,Integer> enchantments)
     
    double
    addTokens(org.bukkit.OfflinePlayer player, double amount)
    This method adds the specified amount of tokens to the specified player's current balance.
    double
    addTokens(org.bukkit.OfflinePlayer p, double amount, boolean applymulti)
     
    int
    calcCooldown(CEHandler cehandler, int currentlevel)
     
    int
    calcCooldown(String enchant, int currentlevel)
    This method will compute the cooldown value or the currentlevel.
    double
    calcCost(org.bukkit.entity.Player player, CEHandler handler, int oldlevel, int newlevel)
    This method will compute the cost needed to increase the enchantment level from oldlvel to newlevel.
    double
    calcCost(org.bukkit.entity.Player player, String enchant)
    This method will compute the cost needed to apply the enchantment to the specified player.
    double
    calcCost(org.bukkit.entity.Player player, String enchant, int addlevel)
     
    double
    calcCost(org.bukkit.entity.Player player, String enchant, int oldlevel, int newlevel)
    This method will compute the cost needed to increase the enchantment level from oldlvel to newlevel.
    double
    calcOccurrence(String enchant, int currentlevel)
     
    double
    calcOccurrence(org.bukkit.entity.Player player, CEHandler cehandler, int currentlevel)
     
    double
    calcOccurrence(org.bukkit.entity.Player player, String enchant, int currentlevel)
    This method will compute the occurrence (chance) value or the currentlevel.
    double
    calcRepairCost(org.bukkit.inventory.ItemStack item)
    This method will compute the cost needed to repair the specified item.
    void
    This method initiates the calculation of balance top.
    boolean
    canUse(org.bukkit.entity.Player player, org.bukkit.enchantments.Enchantment enchant)
    This method will check whether the player can use the specified enchantment or not.
    boolean
     
    org.bukkit.inventory.ItemStack
    disenchant(org.bukkit.entity.Player p, org.bukkit.inventory.ItemStack item, String enchantname, boolean refund, boolean force)
    This method will decrement the specified enchant from the provided item and refund corresponding tokens.
    org.bukkit.inventory.ItemStack
    enchant(org.bukkit.entity.Player p, org.bukkit.inventory.ItemStack item, String enchantname, int level, boolean add, double cost, boolean validcheck)
    This method will enchant the specified item with the specified enchantment.
    boolean
    exceedsMaximumEnchantNumber(org.bukkit.entity.Player p, org.bukkit.inventory.ItemStack is)
    This method will check whether the itemstack has more enchantments than the player is permitted to have.
    org.bukkit.OfflinePlayer[]
    This method returns a list of players whose token balance is in top X.
    org.bukkit.OfflinePlayer[]
    getBalanceTop(int topX)
    This method returns a list of players whose token balance is in top X.
     
     
     
     
    Given a common/alias name or official name of an enchantment, it returns the instance of CEHandler object.
    getEnchantment(org.bukkit.enchantments.Enchantment ench)
    Given a common/alias name or official name of an enchantment, it returns the instance of CEHandler object.
     
    getEnchantments(org.bukkit.inventory.ItemStack itemstack)
     
    This returns the instance of TokenEnchant plugin.
    int
    Given a common/alias name or official name of an enchantment, it returns the maximum level of enchantment one can have.
    Given a common/alias name or official name of an enchantment, it returns the permission node of the specified enchantment.
    Given a common/alias name of an enchantment, it returns the offical name of the enchantment listed in the config file.
    double
    getTokens(org.bukkit.OfflinePlayer player)
    This method returns the amount of tokens the specified player currently holds.
    getTokensInString(org.bukkit.OfflinePlayer player)
    This method returns the amount of tokens the specified player currently holds in the form of String.
    boolean
     
    boolean
    This method initiates the calculation of balance top.
    static boolean
     
    boolean
    isValid(String enchantment, org.bukkit.Location location)
    Returns true if enchantment is valid at the specified location, false otherwise.
    void
    loadPlayerData(org.bukkit.OfflinePlayer p)
     
    double
    removeTokens(org.bukkit.OfflinePlayer player, double amount)
    This method subtracts the specified amount of tokens from the specified player's current balance.
    void
    removeTokensInfo(org.bukkit.OfflinePlayer p)
     
    org.bukkit.inventory.ItemStack
    repair(org.bukkit.entity.Player p, org.bukkit.inventory.ItemStack item)
    This method will remove the specified enchant from the provided item and refund corresponding tokens.
    org.bukkit.inventory.ItemStack
    repair(org.bukkit.entity.Player p, org.bukkit.inventory.ItemStack item, double cost)
    This method will remove the specified enchant from the provided item and refund corresponding tokens.
    void
    savePlayerData(org.bukkit.OfflinePlayer p, boolean deleteCache)
     
    double
    setTokens(org.bukkit.OfflinePlayer player, double amount)
    This method sets the specified amount of tokens to the specified player's balance.
    boolean
     
  • Method Details

    • getInstance

      static ITokenEnchant getInstance()
      This returns the instance of TokenEnchant plugin.
      Returns:
      the instance of TokenEnchant plugin.
    • getTokens

      double getTokens(org.bukkit.OfflinePlayer player)
      This method returns the amount of tokens the specified player currently holds.
      Parameters:
      player - the plaer whose token balance is inquired.
      Returns:
      the current token balance
    • getTokensInString

      String getTokensInString(org.bukkit.OfflinePlayer player)
      This method returns the amount of tokens the specified player currently holds in the form of String.
      Parameters:
      player - the plaer whose token balance is inquired.
      Returns:
      the current token balance in String
    • setTokens

      double setTokens(org.bukkit.OfflinePlayer player, double amount)
      This method sets the specified amount of tokens to the specified player's balance.
      Parameters:
      player - the plaer whose token balance is inquired.
      amount - the amount of token to be set.
      Returns:
      the new token balance
    • addTokens

      double addTokens(org.bukkit.OfflinePlayer player, double amount)
      This method adds the specified amount of tokens to the specified player's current balance.
      Parameters:
      player - the plaer whose token balance is inquired.
      amount - the amount of token to be added.
      Returns:
      the new token balance
    • addTokens

      double addTokens(org.bukkit.OfflinePlayer p, double amount, boolean applymulti)
    • removeTokens

      double removeTokens(org.bukkit.OfflinePlayer player, double amount)
      This method subtracts the specified amount of tokens from the specified player's current balance.
      Parameters:
      player - the plaer whose token balance is inquired.
      amount - the amount of token to be subtracted.
      Returns:
      the new token balance
    • isBalanceTopAvailable

      boolean isBalanceTopAvailable()
      This method initiates the calculation of balance top.
      Returns:
      true if the balance top information is available
    • calculateBalanceTop

      void calculateBalanceTop()
      This method initiates the calculation of balance top.
    • getBalanceTop

      org.bukkit.OfflinePlayer[] getBalanceTop()
      This method returns a list of players whose token balance is in top X. This method should be invoked after calculateBalanceTopImpl(), if calculation of balance top has not completed, this method will keep returning null.
      Returns:
      the array of players sorted according to their token balance, if computation is finished.
    • getBalanceTop

      org.bukkit.OfflinePlayer[] getBalanceTop(int topX)
      This method returns a list of players whose token balance is in top X. This method should be invoked after calculateBalanceTopImpl(), if calculation of balance top has not completed, this method will keep returning null.
      Parameters:
      topX - the number of top players listed under balance top.
      Returns:
      the array of players sorted according to their token balance, if computation is finished.
    • removeTokensInfo

      void removeTokensInfo(org.bukkit.OfflinePlayer p)
    • loadPlayerData

      void loadPlayerData(org.bukkit.OfflinePlayer p)
    • savePlayerData

      void savePlayerData(org.bukkit.OfflinePlayer p, boolean deleteCache)
    • isValid

      boolean isValid(String enchantment, org.bukkit.Location location)
      Returns true if enchantment is valid at the specified location, false otherwise.
      Parameters:
      enchantment - official name of the enchantment.
      location - location where this enchantmnet is used.
      Returns:
      true if the enchantment is valid to be used, false otherwise.
    • getRealName

      String getRealName(String name)
      Given a common/alias name of an enchantment, it returns the offical name of the enchantment listed in the config file.
      Parameters:
      name - common/alias name of the enchantment.
      Returns:
      the official name of the enchantment.
    • getEnchantment

      CEHandler getEnchantment(String name)
      Given a common/alias name or official name of an enchantment, it returns the instance of CEHandler object.
      Parameters:
      name - common/alias or official name of the enchantment.
      Returns:
      the instance of CEHandler.
    • getEnchantment

      CEHandler getEnchantment(org.bukkit.enchantments.Enchantment ench)
      Given a common/alias name or official name of an enchantment, it returns the instance of CEHandler object.
      Parameters:
      ench - enchantment object.
      Returns:
      the instance of CEHandler.
    • getMaxFor

      int getMaxFor(String name)
      Given a common/alias name or official name of an enchantment, it returns the maximum level of enchantment one can have.
      Parameters:
      name - common/alias or official name of the enchantment.
      Returns:
      the maximum level of enchantment.
    • getPermissionNode

      String getPermissionNode(String name)
      Given a common/alias name or official name of an enchantment, it returns the permission node of the specified enchantment.
      Parameters:
      name - common/alias or official name of the enchantment.
      Returns:
      the permission node of the enchantment.
    • enchant

      org.bukkit.inventory.ItemStack enchant(org.bukkit.entity.Player p, org.bukkit.inventory.ItemStack item, String enchantname, int level, boolean add, double cost, boolean validcheck)
      This method will enchant the specified item with the specified enchantment.
      Parameters:
      p - a player who will receive any messages from this method (can be null).
      item - an item to be enchanted. you should always get the actual ItemStack returned. this item will not be changed.
      enchantname - the name of enchantment.
      level - the level of enchantment.
      add - a flag indicating whether the level should be added or set.
      cost - the token cost of executing this enchantment. (can be 0).
      validcheck - a flag indicating whether validity check should be executed against TE's config.
      Returns:
      the enchanted item, which is different from item specified in the argument.
    • disenchant

      org.bukkit.inventory.ItemStack disenchant(org.bukkit.entity.Player p, org.bukkit.inventory.ItemStack item, String enchantname, boolean refund, boolean force)
      This method will decrement the specified enchant from the provided item and refund corresponding tokens.
      Parameters:
      p - a player who will receive any messages from this method (can be null).
      item - an item to be enchanted. you should always get the actual ItemStack returned. this item will not be changed.
      enchantname - the name of enchantment.
      refund - a flag indicating whether disenchanting incure refund or not.
      force - a flag indicating whether disenchanting is forced despite TE's refund function is disabled.
      Returns:
      the item that has the specified enchantment decremented by 1 level.
    • repair

      org.bukkit.inventory.ItemStack repair(org.bukkit.entity.Player p, org.bukkit.inventory.ItemStack item)
      This method will remove the specified enchant from the provided item and refund corresponding tokens.
      Parameters:
      p - a player who will receive any messages from this method (can be null).
      item - an item to be enchanted. you should always get the actual ItemStack returned. this item will not be changed.
      Returns:
      the item that is fully repaired.
    • repair

      org.bukkit.inventory.ItemStack repair(org.bukkit.entity.Player p, org.bukkit.inventory.ItemStack item, double cost)
      This method will remove the specified enchant from the provided item and refund corresponding tokens.
      Parameters:
      p - a player who will receive any messages from this method (can be null).
      item - an item to be enchanted. you should always get the actual ItemStack returned. this item will not be changed.
      cost - a cost of repair.
      Returns:
      the item that is fully repaired.
    • calcRepairCost

      double calcRepairCost(org.bukkit.inventory.ItemStack item)
      This method will compute the cost needed to repair the specified item.
      Parameters:
      item - an item to be repaired.
      Returns:
      the cost to repair the specified item.
    • exceedsMaximumEnchantNumber

      boolean exceedsMaximumEnchantNumber(org.bukkit.entity.Player p, org.bukkit.inventory.ItemStack is)
      This method will check whether the itemstack has more enchantments than the player is permitted to have.
      Parameters:
      p - The player to be examined.
      is - The itemstack the player is holding or wearing
      Returns:
      true if the item is in question has more enchantments than the player is permitted.
    • canUse

      boolean canUse(org.bukkit.entity.Player player, org.bukkit.enchantments.Enchantment enchant)
      This method will check whether the player can use the specified enchantment or not.
      Parameters:
      player - the player whose permission is checked.
      enchant - the enchantment object.
      Returns:
      true if the player is permitted to use the specifed enchant.
    • getDefaultMergeMode

      CEHandler.MergeMode getDefaultMergeMode()
    • getEnchantments

      Map<CEHandler,Integer> getEnchantments(org.bukkit.inventory.ItemStack itemstack)
    • addEnchantments

      org.bukkit.inventory.ItemStack addEnchantments(org.bukkit.inventory.ItemStack itemstack, Map<CEHandler,Integer> enchantments)
    • calcCost

      double calcCost(org.bukkit.entity.Player player, String enchant, int oldlevel, int newlevel)
      This method will compute the cost needed to increase the enchantment level from oldlvel to newlevel.
      Parameters:
      enchant - the name of the enchantment.
      oldlevel - the enchantment level before.
      newlevel - the resulting enchantment level.
      Returns:
      the cost to increase the enchantment level.
    • calcCost

      double calcCost(org.bukkit.entity.Player player, CEHandler handler, int oldlevel, int newlevel)
      This method will compute the cost needed to increase the enchantment level from oldlvel to newlevel.
      Parameters:
      handler - Custom Enchantment handler.
      oldlevel - the enchantment level before.
      newlevel - the resulting enchantment level.
      Returns:
      the cost to increase the enchantment level.
    • calcCost

      double calcCost(org.bukkit.entity.Player player, String enchant)
      This method will compute the cost needed to apply the enchantment to the specified player.
      Parameters:
      player - the player whose cost will be calculated.
      enchant - the name of the enchantment.
      Returns:
      the cost to apply the enchantment to the specified player.
    • calcCost

      double calcCost(org.bukkit.entity.Player player, String enchant, int addlevel)
      Parameters:
      player - the player whose cost will be calculated.
      enchant - the name of the enchantment.
      addlevel - the level to be added.
      Returns:
      the cost of enchantment for the player.
    • calcCooldown

      int calcCooldown(String enchant, int currentlevel)
      This method will compute the cooldown value or the currentlevel.
      Parameters:
      enchant - the name of the enchantment.
      currentlevel - the current enventment level.
      Returns:
      the cooldown in seconds.
    • calcCooldown

      int calcCooldown(CEHandler cehandler, int currentlevel)
    • calcOccurrence

      double calcOccurrence(org.bukkit.entity.Player player, String enchant, int currentlevel)
      This method will compute the occurrence (chance) value or the currentlevel.
      Parameters:
      enchant - the name of the enchantment.
      currentlevel - the current enventment level.
      Returns:
      the occurrence (chance) value.
    • calcOccurrence

      double calcOccurrence(org.bukkit.entity.Player player, CEHandler cehandler, int currentlevel)
    • calcOccurrence

      double calcOccurrence(String enchant, int currentlevel)
    • getEnchantmentLorePrefix

      String getEnchantmentLorePrefix()
    • getDisabledSuffix

      String getDisabledSuffix()
    • useWorldEditToClearExplosion

      boolean useWorldEditToClearExplosion()
    • getDefaultAvailabilities

      Set<CEHandler.Availability> getDefaultAvailabilities()
    • isAvailable

      boolean isAvailable(CEHandler.Availability availability)
    • getCostFunc

      Invocable getCostFunc()
    • debugged

      boolean debugged(String key)
    • isDebugged

      static boolean isDebugged(String key)