-
Notifications
You must be signed in to change notification settings - Fork 58
Developer API
Ján Kluka edited this page Feb 1, 2023
·
23 revisions
If you would like to see how to create your own custom enchant head over here
- XPrisonEvent
-
- XPrisonPlayerEvent
-
-
- GangJoinEvent
-
-
-
- GangLeaveEvent
-
-
-
- PlayerAutoMinerTimeModifyEvent
-
-
-
- PlayerAutomineEvent
-
-
-
- PlayerTokensLostEvent
-
-
-
- PlayerTokensReceiveEvent
-
-
-
- PlayerGemsLostEvent
-
-
-
- PlayerGemsReceiveEvent
-
-
-
- PlayerMultiplierReceiveEvent
-
-
-
- PlayerPrestigeEvent
-
-
-
- PlayerRankUpEvent
-
-
-
- XPrisonAutoSellEvent
-
-
-
- XPrisonSellAllEvent
-
-
-
- XBlockBreakEvent
-
-
-
- XPlayerEnchantEvent
-
-
-
- XPlayerEnchantTriggerEvent
-
-
-
-
- ExplosionTriggerEvent
-
-
-
-
-
- LayerTriggerEvent
-
-
-
-
-
- NukeTriggerEvent
-
-
To access API please use XPrison#getInstance to grab the instance of UPC. From XPrison's instance, get respective module via getter, and then call #getApi on it to access API eg XPrison#getInstance#getEnchants#getApi
package dev.drawethree.xprison.autosell.api;
import dev.drawethree.xprison.autosell.model.SellRegion;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.Collection;
import java.util.List;
public interface XPrisonAutoSellAPI {
/**
* Method to get current earnings of player
*
* @param player Player
* @return Current earnings
*/
double getCurrentEarnings(Player player);
/**
* Method to get price for ItemStack in specified mine region
*
* @param regionName Name of region
* @param item ItemStack
* @return Price for item
*/
double getPriceForItem(String regionName, ItemStack item);
/**
* Method to get price for Block
*
* @param block Block
* @return Price for block
*/
double getPriceForBlock(Block block);
/**
* Sells the given blocks
*
* @param player Player
* @param blocks List of blocks
*/
void sellBlocks(Player player, List<Block> blocks);
/**
* Method to get if player has autosell enabled
*
* @param p Player
* @return true if player has autosell enabled, otherwise false
*/
boolean hasAutoSellEnabled(Player p);
/**
* Method to get all sell regions
*
* @return Collection of all loaded and active Sell Regions
*/
Collection<SellRegion> getSellRegions();
/**
* Method to get SellRegion at specified location
*
* @return Sell Region at given location or null if not present.
*/
SellRegion getSellRegionAtLocation(Location location);
}
package dev.drawethree.xprison.autominer.api;
import org.bukkit.entity.Player;
public interface XPrisonAutoMinerAPI {
/**
* Returns true if player is in autominer region, otherwise return false
*
* @param player Player
* @return returns true if player is in autominer region, otherwise return false
*/
boolean isInAutoMinerRegion(Player player);
/**
* Returns remaining autominer time in seconds for specific player
*
* @param player Player
* @return time in seconds left for specific player autominer
*/
int getAutoMinerTime(Player player);
}
package dev.drawethree.xprison.enchants.api;
import dev.drawethree.xprison.enchants.model.XPrisonEnchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.Map;
public interface XPrisonEnchantsAPI {
/**
* Method to get all custom enchants applied on specific ItemStack
*
* @param itemStack ItemStack
* @return
*/
Map<XPrisonEnchantment, Integer> getEnchants(ItemStack itemStack);
/**
* Method to check if item has specific enchant
*
* @param item {@link ItemStack}
* @param enchantment {@link XPrisonEnchantment}
* @return true if item has enchant
*/
boolean hasEnchant(ItemStack item, XPrisonEnchantment enchantment);
/**
* Method to get enchant level of specific ItemStack
*
* @param item ItemStack
* @param enchantment {@link XPrisonEnchantment}
* @return 0 if enchant was not found, otherwise level of enchant
*/
int getEnchantLevel(ItemStack item, XPrisonEnchantment enchantment);
/**
* Method to set enchant with specific level to pickaxe
*
* @param item pickaxe
* @param enchantment {@link XPrisonEnchantment}
* @param level Enchant Level
* @return modified ItemStack
*/
ItemStack setEnchantLevel(Player player, ItemStack item, XPrisonEnchantment enchantment, int level);
/**
* Method to remove enchant from pickaxe
*
* @param item ItemStack pickaxe
* @param enchantment {@link XPrisonEnchantment}
* @return modified ItemStack
*/
ItemStack removeEnchant(Player player, ItemStack item, XPrisonEnchantment enchantment);
/**
* Method to get Enchant by ID
*
* @param id enchant id
* @return XPrisonEnchantment
*/
XPrisonEnchantment getById(int id);
/**
* Method to get Enchant by ID
*
* @param rawName enchant rawname
* @return XPrisonEnchantment
*/
XPrisonEnchantment getByName(String rawName);
/**
* Registers a specific {@link XPrisonEnchantment}
*
* @param enchantment
* @return
*/
boolean registerEnchant(XPrisonEnchantment enchantment);
/**
* Unregisters a specific {@link XPrisonEnchantment}
*
* @param enchantment
* @return
*/
boolean unregisterEnchant(XPrisonEnchantment enchantment);
}
package dev.drawethree.xprison.gems.api;
import dev.drawethree.xprison.api.enums.ReceiveCause;
import org.bukkit.OfflinePlayer;
public interface XPrisonGemsAPI {
/**
* Method to get player gems
*
* @param p Player
* @return Player gems amount
*/
long getPlayerGems(OfflinePlayer p);
/**
* Method to check if player has more or equal gems than specified amount
*
* @param p Player
* @param amount amount
* @return true if player has more or equal gems
*/
boolean hasEnough(OfflinePlayer p, long amount);
/**
* Method to remove gems from player
*
* @param p Player
* @param amount amount
*/
void removeGems(OfflinePlayer p, long amount);
/**
* Method to add gems to player
*
* @param p Player
* @param amount amount
* @param cause - Represents why player get these gemes
*/
void addGems(OfflinePlayer p, long amount, ReceiveCause cause);
}
package dev.drawethree.xprison.multipliers.api;
import dev.drawethree.xprison.multipliers.enums.MultiplierType;
import dev.drawethree.xprison.multipliers.multiplier.GlobalMultiplier;
import dev.drawethree.xprison.multipliers.multiplier.Multiplier;
import dev.drawethree.xprison.multipliers.multiplier.PlayerMultiplier;
import org.bukkit.entity.Player;
public interface XPrisonMultipliersAPI {
/**
* Method to get current global sell multiplier
*
* @return GlobalMultiplier
*/
GlobalMultiplier getGlobalSellMultiplier();
/**
* Method to get current global token multiplier
*
* @return GlobalMultiplier
*/
GlobalMultiplier getGlobalTokenMultiplier();
/**
* Method to get player's sell multiplier
*
* @param p Player
* @return PlayerMultiplier
*/
PlayerMultiplier getSellMultiplier(Player p);
/**
* Method to get player's token multiplier
*
* @param p Player
* @return PlayerMultiplier
*/
PlayerMultiplier getTokenMultiplier(Player p);
/**
* Method to get player's rank multiplier
*
* @param p Player
* @return Multiplier
*/
Multiplier getRankMultiplier(Player p);
/**
* Method to get overall player's multiplier based on multiplier type (SELL / TOKENS)
*
* @param p Player
* @param multiplierType MultiplierType
* @return overall player's multiplier
*/
double getPlayerMultiplier(Player p, MultiplierType multiplierType);
/**
* Method to calculate total amount to deposit (tokens / money )
*
* @param p Player
* @param deposit original amount to deposit
* @param type MultiplierType
* @return new amount to deposit
*/
default double getTotalToDeposit(Player p, double deposit, MultiplierType type) {
return deposit * (1.0 + this.getPlayerMultiplier(p, type));
}
}
package dev.drawethree.xprison.ranks.api;
import dev.drawethree.xprison.ranks.model.Rank;
import org.bukkit.entity.Player;
import java.util.Optional;
public interface XPrisonRanksAPI {
/**
* Method to get player Rank
*
* @param p Player
* @return Rank
*/
Rank getPlayerRank(Player p);
/**
* Method to get next player rank
*
* @param player Player
* @return null if he has max rank, otherwise next Rank
*/
Optional<Rank> getNextPlayerRank(Player player);
/**
* Method to get player's rankup progress
*
* @param player Player
* @return int 0-100 percentage
*/
int getRankupProgress(Player player);
/**
* Sets a rank to online player
*
* @param player Player
* @param rank Rank
*/
void setPlayerRank(Player player, Rank rank);
}
package dev.drawethree.xprison.prestiges.api;
import dev.drawethree.xprison.prestiges.model.Prestige;
import org.bukkit.entity.Player;
public interface XPrisonPrestigesAPI {
/**
* Method to get player Prestige
*
* @param p Player
* @return Prestige
*/
Prestige getPlayerPrestige(Player p);
/**
* Sets a prestige to online player
*
* @param player Player
* @param prestige Prestige
*/
void setPlayerPrestige(Player player, Prestige prestige);
/**
* Sets a prestige to online player
*
* @param player Player
* @param prestige Prestige
*/
void setPlayerPrestige(Player player, long prestige);
}
package dev.drawethree.xprison.tokens.api;
import dev.drawethree.xprison.api.enums.LostCause;
import dev.drawethree.xprison.api.enums.ReceiveCause;
import org.bukkit.OfflinePlayer;
public interface XPrisonTokensAPI {
/**
* Method to get player's tokens
*
* @param p Player
* @return amount of player's tokens
*/
long getPlayerTokens(OfflinePlayer p);
/**
* Method to check if player has more or equal tokens than specified amount
*
* @param p Player
* @param amount amount
* @return true if player has more or equal tokens than amount
*/
boolean hasEnough(OfflinePlayer p, long amount);
/**
* Method to remove tokens from player
*
* @param p Player
* @param amount amount
*/
void removeTokens(OfflinePlayer p, long amount, LostCause cause);
/**
* Method to add tokens to player
*
* @param p Player
* @param amount amount
* @param cause - Represents why player get these tokens
*/
void addTokens(OfflinePlayer p, long amount, ReceiveCause cause);
}
package dev.drawethree.xprison.gangs.api;
import dev.drawethree.xprison.gangs.model.Gang;
import org.bukkit.OfflinePlayer;
import java.util.Collection;
import java.util.Optional;
public interface XPrisonGangsAPI {
/**
* Method to get Gang from player
*
* @param player OfflinePlayer
* @return Optional<Gang> gang
*/
Optional<Gang> getPlayerGang(OfflinePlayer player);
/**
* Method to get Gang from name
*
* @param name name of gang
* @return Optional<Gang> gang
*/
Optional<Gang> getByName(String name);
/**
* Method to get all gangs
*
* @return List of gangs
*/
Collection<Gang> getAllGangs();
}
package dev.drawethree.xprison.pickaxelevels.api;
import dev.drawethree.xprison.pickaxelevels.model.PickaxeLevel;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.Optional;
public interface XPrisonPickaxeLevelsAPI {
/**
* Method to get PickaxeLevel of itemstack
*
* @param item ItemStack
* @return instance of PickaxeLevel
*/
Optional<PickaxeLevel> getPickaxeLevel(ItemStack item);
/**
* Method to get PickaxeLevel of Player
*
* @param player Player
* @return instance of PickaxeLevel
*/
Optional<PickaxeLevel> getPickaxeLevel(Player player);
/**
* Method to get PickaxeLevel by specific level
*
* @param level level
* @return instance of PickaxeLevel
*/
Optional<PickaxeLevel> getPickaxeLevel(int level);
/**
* Method to set PickaxeLevel of itemstack
*
* @param player Player
* @param item ItemStack to change
* @param level PickaxeLevel to set
*/
void setPickaxeLevel(Player player, ItemStack item, PickaxeLevel level);
/**
* Method to set PickaxeLevel of itemstack
*
* @param player Player
* @param item ItemStack to change
* @param level level to set
*/
void setPickaxeLevel(Player player, ItemStack item, int level);
/**
* Method to get progress bar of PickaxeLevel progress for given player
*
* @param player Player
*/
String getProgressBar(Player player);
}
package dev.drawethree.xprison.mines.api;
import dev.drawethree.xprison.mines.model.mine.Mine;
import org.bukkit.Location;
public interface XPrisonMinesAPI {
/**
* Gets a mine by name
*
* @param name String
* @return Mine.class
*/
Mine getMineByName(String name);
/**
* Gets a mine by location
*
* @param loc Location
* @return Mine.class
*/
Mine getMineAtLocation(Location loc);
}
package dev.drawethree.xprison.history.api;
import dev.drawethree.xprison.XPrisonModule;
import dev.drawethree.xprison.history.model.HistoryLine;
import org.bukkit.OfflinePlayer;
import java.util.List;
public interface XPrisonHistoryAPI {
/**
* Gets players history
*
* @param player Player
* @return List containing all HistoryLine.class of Player
*/
List<HistoryLine> getPlayerHistory(OfflinePlayer player);
/**
* Creates a new history line for player
*
* @param player Player
* @param context Context of the history
* @param module XPrisonModule associated with the history
*/
void createHistoryLine(OfflinePlayer player, XPrisonModule module, String context);
}