mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-10 04:31:06 +00:00
Added Javadoc
This commit is contained in:
parent
f52be003ab
commit
80a32bf0dc
@ -39,6 +39,13 @@ public class Commands extends BukkitCommand {
|
|||||||
this.perm = plugin.getPermission();
|
this.perm = plugin.getPermission();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a command to ShopChest
|
||||||
|
*
|
||||||
|
* @param command Command to register
|
||||||
|
* @param plugin Instance of ShopChest
|
||||||
|
* @throws ReflectiveOperationException
|
||||||
|
*/
|
||||||
public static void registerCommand(Command command, ShopChest plugin) throws ReflectiveOperationException {
|
public static void registerCommand(Command command, ShopChest plugin) throws ReflectiveOperationException {
|
||||||
Method commandMap = plugin.getServer().getClass().getMethod("getCommandMap");
|
Method commandMap = plugin.getServer().getClass().getMethod("getCommandMap");
|
||||||
Object cmdmap = commandMap.invoke(plugin.getServer());
|
Object cmdmap = commandMap.invoke(plugin.getServer());
|
||||||
@ -131,10 +138,14 @@ public class Commands extends BukkitCommand {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A given player checks for updates
|
||||||
|
* @param player The command executor
|
||||||
|
*/
|
||||||
private void checkUpdates(Player player) {
|
private void checkUpdates(Player player) {
|
||||||
player.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CHECKING));
|
player.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CHECKING));
|
||||||
|
|
||||||
UpdateChecker uc = new UpdateChecker(ShopChest.getInstance(), ShopChest.getInstance().getDescription().getWebsite());
|
UpdateChecker uc = new UpdateChecker(ShopChest.getInstance());
|
||||||
UpdateCheckerResult result = uc.updateNeeded();
|
UpdateCheckerResult result = uc.updateNeeded();
|
||||||
|
|
||||||
if (result == UpdateCheckerResult.TRUE) {
|
if (result == UpdateCheckerResult.TRUE) {
|
||||||
@ -190,10 +201,20 @@ public class Commands extends BukkitCommand {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A given player reloads the shops
|
||||||
|
* @param player The command executor
|
||||||
|
*/
|
||||||
private void reload(Player player) {
|
private void reload(Player player) {
|
||||||
player.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.RELOADED_SHOPS, new LocalizedMessage.ReplacedRegex(Regex.AMOUNT, String.valueOf(ShopUtils.reloadShops()))));
|
player.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.RELOADED_SHOPS, new LocalizedMessage.ReplacedRegex(Regex.AMOUNT, String.valueOf(ShopUtils.reloadShops()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A given player creates a shop
|
||||||
|
* @param args Arguments of the entered command
|
||||||
|
* @param shopType The {@link ShopType}, the shop will have
|
||||||
|
* @param p The command executor
|
||||||
|
*/
|
||||||
private void create(String[] args, ShopType shopType, Player p) {
|
private void create(String[] args, ShopType shopType, Player p) {
|
||||||
int amount;
|
int amount;
|
||||||
double buyPrice, sellPrice;
|
double buyPrice, sellPrice;
|
||||||
@ -307,21 +328,33 @@ public class Commands extends BukkitCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ClickType.addPlayerClickType(p, new ClickType(EnumClickType.CREATE, itemStack, buyPrice, sellPrice, shopType));
|
ClickType.setPlayerClickType(p, new ClickType(EnumClickType.CREATE, itemStack, buyPrice, sellPrice, shopType));
|
||||||
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CLICK_CHEST_CREATE));
|
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CLICK_CHEST_CREATE));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A given player removes a shop
|
||||||
|
* @param p The command executor
|
||||||
|
*/
|
||||||
private void remove(Player p) {
|
private void remove(Player p) {
|
||||||
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CLICK_CHEST_REMOVE));
|
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CLICK_CHEST_REMOVE));
|
||||||
ClickType.addPlayerClickType(p, new ClickType(EnumClickType.REMOVE));
|
ClickType.setPlayerClickType(p, new ClickType(EnumClickType.REMOVE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A given player retrieves information about a shop
|
||||||
|
* @param p The command executor
|
||||||
|
*/
|
||||||
private void info(Player p) {
|
private void info(Player p) {
|
||||||
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CLICK_CHEST_INFO));
|
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CLICK_CHEST_INFO));
|
||||||
ClickType.addPlayerClickType(p, new ClickType(EnumClickType.INFO));
|
ClickType.setPlayerClickType(p, new ClickType(EnumClickType.INFO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends the basic help message to a given player
|
||||||
|
* @param player Player who will receive the message
|
||||||
|
*/
|
||||||
private void sendBasicHelpMessage(Player player) {
|
private void sendBasicHelpMessage(Player player) {
|
||||||
player.sendMessage(ChatColor.GREEN + "/" + Config.main_command_name + " create <amount> <buy-price> <sell-price> [normal|admin] - " + LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_CREATE));
|
player.sendMessage(ChatColor.GREEN + "/" + Config.main_command_name + " create <amount> <buy-price> <sell-price> [normal|admin] - " + LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_CREATE));
|
||||||
player.sendMessage(ChatColor.GREEN + "/" + Config.main_command_name + " remove - " + LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_REMOVE));
|
player.sendMessage(ChatColor.GREEN + "/" + Config.main_command_name + " remove - " + LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_REMOVE));
|
||||||
|
@ -3,11 +3,11 @@ package de.epiceric.shopchest;
|
|||||||
import de.epiceric.shopchest.config.Config;
|
import de.epiceric.shopchest.config.Config;
|
||||||
import de.epiceric.shopchest.config.LanguageConfiguration;
|
import de.epiceric.shopchest.config.LanguageConfiguration;
|
||||||
import de.epiceric.shopchest.config.Regex;
|
import de.epiceric.shopchest.config.Regex;
|
||||||
import de.epiceric.shopchest.listeners.*;
|
|
||||||
import de.epiceric.shopchest.interfaces.JsonBuilder;
|
import de.epiceric.shopchest.interfaces.JsonBuilder;
|
||||||
import de.epiceric.shopchest.interfaces.jsonbuilder.*;
|
import de.epiceric.shopchest.interfaces.jsonbuilder.*;
|
||||||
import de.epiceric.shopchest.language.LanguageUtils;
|
import de.epiceric.shopchest.language.LanguageUtils;
|
||||||
import de.epiceric.shopchest.language.LocalizedMessage;
|
import de.epiceric.shopchest.language.LocalizedMessage;
|
||||||
|
import de.epiceric.shopchest.listeners.*;
|
||||||
import de.epiceric.shopchest.shop.Shop;
|
import de.epiceric.shopchest.shop.Shop;
|
||||||
import de.epiceric.shopchest.shop.Shop.ShopType;
|
import de.epiceric.shopchest.shop.Shop.ShopType;
|
||||||
import de.epiceric.shopchest.sql.Database;
|
import de.epiceric.shopchest.sql.Database;
|
||||||
@ -50,10 +50,19 @@ public class ShopChest extends JavaPlugin {
|
|||||||
private String[] broadcast = null;
|
private String[] broadcast = null;
|
||||||
private LanguageConfiguration langConfig;
|
private LanguageConfiguration langConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an instance of ShopChest
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static ShopChest getInstance() {
|
public static ShopChest getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up the economy of Vault
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
private boolean setupEconomy() {
|
private boolean setupEconomy() {
|
||||||
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
|
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
|
||||||
if (rsp == null) {
|
if (rsp == null) {
|
||||||
@ -63,12 +72,19 @@ public class ShopChest extends JavaPlugin {
|
|||||||
return econ != null;
|
return econ != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up the permissions of Vault
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
private boolean setupPermissions() {
|
private boolean setupPermissions() {
|
||||||
RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
|
RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
|
||||||
perm = rsp.getProvider();
|
perm = rsp.getProvider();
|
||||||
return perm != null;
|
return perm != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the language configuration
|
||||||
|
*/
|
||||||
private void initLanguageConfig() {
|
private void initLanguageConfig() {
|
||||||
langConfig = new LanguageConfiguration(this);
|
langConfig = new LanguageConfiguration(this);
|
||||||
File langFolder = new File(getDataFolder(), "lang");
|
File langFolder = new File(getDataFolder(), "lang");
|
||||||
@ -246,7 +262,7 @@ public class ShopChest extends JavaPlugin {
|
|||||||
lockette = getServer().getPluginManager().getPlugin("Lockette") != null;
|
lockette = getServer().getPluginManager().getPlugin("Lockette") != null;
|
||||||
lwc = getServer().getPluginManager().getPlugin("LWC") != null;
|
lwc = getServer().getPluginManager().getPlugin("LWC") != null;
|
||||||
|
|
||||||
UpdateChecker uc = new UpdateChecker(this, getDescription().getWebsite());
|
UpdateChecker uc = new UpdateChecker(this);
|
||||||
UpdateCheckerResult result = uc.updateNeeded();
|
UpdateCheckerResult result = uc.updateNeeded();
|
||||||
|
|
||||||
if (Config.enable_broadcast) broadcast = uc.getBroadcast();
|
if (Config.enable_broadcast) broadcast = uc.getBroadcast();
|
||||||
@ -352,63 +368,112 @@ public class ShopChest extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the shops
|
||||||
|
*/
|
||||||
private void initializeShops() {
|
private void initializeShops() {
|
||||||
int count = ShopUtils.reloadShops();
|
int count = ShopUtils.reloadShops();
|
||||||
getLogger().info("Initialized " + String.valueOf(count) + " Shops");
|
getLogger().info("Initialized " + String.valueOf(count) + " Shops");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ShopChest's {@link LanguageConfiguration}
|
||||||
|
*/
|
||||||
public LanguageConfiguration getLanguageConfig() {
|
public LanguageConfiguration getLanguageConfig() {
|
||||||
return langConfig;
|
return langConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Registered Economy of Vault
|
||||||
|
*/
|
||||||
public Economy getEconomy() {
|
public Economy getEconomy() {
|
||||||
return econ;
|
return econ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Registered Permission of Vault
|
||||||
|
*/
|
||||||
public Permission getPermission() {
|
public Permission getPermission() {
|
||||||
return perm;
|
return perm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ShopChest's shop database
|
||||||
|
*/
|
||||||
public Database getShopDatabase() {
|
public Database getShopDatabase() {
|
||||||
return database;
|
return database;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Whether LWC is available
|
||||||
|
*/
|
||||||
public boolean hasLWC() {
|
public boolean hasLWC() {
|
||||||
return lwc;
|
return lwc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Whether Lockette is available
|
||||||
|
*/
|
||||||
public boolean hasLockette() {
|
public boolean hasLockette() {
|
||||||
return lockette;
|
return lockette;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Whether an update is needed (will return false if not checked)
|
||||||
|
*/
|
||||||
public boolean isUpdateNeeded() {
|
public boolean isUpdateNeeded() {
|
||||||
return isUpdateNeeded;
|
return isUpdateNeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether an update is needed
|
||||||
|
* @param isUpdateNeeded Whether an update should be needed
|
||||||
|
*/
|
||||||
public void setUpdateNeeded(boolean isUpdateNeeded) {
|
public void setUpdateNeeded(boolean isUpdateNeeded) {
|
||||||
this.isUpdateNeeded = isUpdateNeeded;
|
this.isUpdateNeeded = isUpdateNeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The latest version of ShopChest (will return null if not checked or if no update is available)
|
||||||
|
*/
|
||||||
public String getLatestVersion() {
|
public String getLatestVersion() {
|
||||||
return latestVersion;
|
return latestVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the latest version
|
||||||
|
* @param latestVersion Version to set as latest version
|
||||||
|
*/
|
||||||
public void setLatestVersion(String latestVersion) {
|
public void setLatestVersion(String latestVersion) {
|
||||||
this.latestVersion = latestVersion;
|
this.latestVersion = latestVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The download link of the latest version (will return null if not checked or if no update is available)
|
||||||
|
*/
|
||||||
public String getDownloadLink() {
|
public String getDownloadLink() {
|
||||||
return downloadLink;
|
return downloadLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the download Link of the latest version (will return null if not checked or if no update is available)
|
||||||
|
* @param downloadLink Link to set as Download Link
|
||||||
|
*/
|
||||||
public void setDownloadLink(String downloadLink) {
|
public void setDownloadLink(String downloadLink) {
|
||||||
this.downloadLink = downloadLink;
|
this.downloadLink = downloadLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The broadcast message as a string array of lines (will return null if not checked or if no message is available)
|
||||||
|
*/
|
||||||
public String[] getBroadcast() {
|
public String[] getBroadcast() {
|
||||||
return broadcast;
|
return broadcast;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the broadcast message
|
||||||
|
* @param broadcast Broadcast message as a string array of lines to set
|
||||||
|
*/
|
||||||
public void setBroadcast(String[] broadcast) {
|
public void setBroadcast(String[] broadcast) {
|
||||||
this.broadcast = broadcast;
|
this.broadcast = broadcast;
|
||||||
}
|
}
|
||||||
|
@ -12,46 +12,84 @@ public class Config {
|
|||||||
|
|
||||||
private static ShopChest plugin = ShopChest.getInstance();
|
private static ShopChest plugin = ShopChest.getInstance();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hostname used in ShopChest's MySQL database
|
||||||
|
**/
|
||||||
public static String database_mysql_host = plugin.getConfig().getString("database.mysql.hostname");
|
public static String database_mysql_host = plugin.getConfig().getString("database.mysql.hostname");
|
||||||
|
|
||||||
|
/** The port used for ShopChest's MySQL database **/
|
||||||
public static int database_mysql_port = plugin.getConfig().getInt("database.mysql.port");
|
public static int database_mysql_port = plugin.getConfig().getInt("database.mysql.port");
|
||||||
|
|
||||||
|
/** The database used for ShopChest's MySQL database **/
|
||||||
public static String database_mysql_database = plugin.getConfig().getString("database.mysql.database");
|
public static String database_mysql_database = plugin.getConfig().getString("database.mysql.database");
|
||||||
|
|
||||||
|
/** The username used in ShopChest's MySQL database **/
|
||||||
public static String database_mysql_username = plugin.getConfig().getString("database.mysql.username");
|
public static String database_mysql_username = plugin.getConfig().getString("database.mysql.username");
|
||||||
|
|
||||||
|
/** The password used in ShopChest's MySQL database **/
|
||||||
public static String database_mysql_password = plugin.getConfig().getString("database.mysql.password");
|
public static String database_mysql_password = plugin.getConfig().getString("database.mysql.password");
|
||||||
|
|
||||||
|
/** The database type used for ShopChest. **/
|
||||||
public static Database.DatabaseType database_type = Database.DatabaseType.valueOf(plugin.getConfig().getString("database.type"));
|
public static Database.DatabaseType database_type = Database.DatabaseType.valueOf(plugin.getConfig().getString("database.type"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>The minimum prices for certain items</p>
|
||||||
|
* This returns a key set, which contains e.g "STONE", "STONE:1", of the <i>minimum-prices</i> section in ShopChest's config.
|
||||||
|
* To actually retrieve the price for an item, you have to get the Double <i>minimum-prices.<b>key</b></i>.
|
||||||
|
**/
|
||||||
public static Set<String> minimum_prices = (plugin.getConfig().getConfigurationSection("minimum-prices") == null) ? new HashSet<String>() : plugin.getConfig().getConfigurationSection("minimum-prices").getKeys(true);
|
public static Set<String> minimum_prices = (plugin.getConfig().getConfigurationSection("minimum-prices") == null) ? new HashSet<String>() : plugin.getConfig().getConfigurationSection("minimum-prices").getKeys(true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>The shop limits of certain groups</p>
|
||||||
|
* This returns a key set, which contains the group names, of the <i>shop-limits.group</i> section in ShopChest's config.
|
||||||
|
* To actually retrieve the limits for a group, you have to get the Integer <i>shop-limits.group.<b>key</b></i>.
|
||||||
|
**/
|
||||||
public static Set<String> shopLimits_group = (plugin.getConfig().getConfigurationSection("shop-limits.group") == null) ? new HashSet<String>() : plugin.getConfig().getConfigurationSection("shop-limits.group").getKeys(true);
|
public static Set<String> shopLimits_group = (plugin.getConfig().getConfigurationSection("shop-limits.group") == null) ? new HashSet<String>() : plugin.getConfig().getConfigurationSection("shop-limits.group").getKeys(true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>The shop limits of certain players</p>
|
||||||
|
* This returns a key set, which contains the player names, of the <i>shop-limits.player</i> section in ShopChest's config.
|
||||||
|
* To actually retrieve the limits for a player, you have to get the Integer <i>shop-limits.player.<b>key</b></i>.
|
||||||
|
**/
|
||||||
public static Set<String> shopLimits_player = (plugin.getConfig().getConfigurationSection("shop-limits.player") == null) ? new HashSet<String>() : plugin.getConfig().getConfigurationSection("shop-limits.player").getKeys(true);
|
public static Set<String> shopLimits_player = (plugin.getConfig().getConfigurationSection("shop-limits.player") == null) ? new HashSet<String>() : plugin.getConfig().getConfigurationSection("shop-limits.player").getKeys(true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>List containing items, of which players can't create a shop</p>
|
||||||
|
* If this list contains an item (e.g "STONE", "STONE:1"), it's in the blacklist.
|
||||||
|
**/
|
||||||
public static List<String> blacklist = (plugin.getConfig().getStringList("blacklist") == null) ? new ArrayList<String>() : plugin.getConfig().getStringList("blacklist");
|
public static List<String> blacklist = (plugin.getConfig().getStringList("blacklist") == null) ? new ArrayList<String>() : plugin.getConfig().getStringList("blacklist");
|
||||||
|
|
||||||
|
/** Whether the buy price of a shop must be greater than or equal the sell price **/
|
||||||
public static boolean buy_greater_or_equal_sell = plugin.getConfig().getBoolean("buy-greater-or-equal-sell");
|
public static boolean buy_greater_or_equal_sell = plugin.getConfig().getBoolean("buy-greater-or-equal-sell");
|
||||||
|
|
||||||
|
/** Whether shops should be protected by hoppers **/
|
||||||
public static boolean hopper_protection = plugin.getConfig().getBoolean("hopper-protection");
|
public static boolean hopper_protection = plugin.getConfig().getBoolean("hopper-protection");
|
||||||
|
|
||||||
|
/** Whether shops should be protected by explosions **/
|
||||||
public static boolean explosion_protection = plugin.getConfig().getBoolean("explosion-protection");
|
public static boolean explosion_protection = plugin.getConfig().getBoolean("explosion-protection");
|
||||||
|
|
||||||
|
/** Whether broadcast messages should be enabled **/
|
||||||
public static boolean enable_broadcast = plugin.getConfig().getBoolean("enable-broadcast");
|
public static boolean enable_broadcast = plugin.getConfig().getBoolean("enable-broadcast");
|
||||||
|
|
||||||
|
/** Whether admin shops should be excluded of the shop limits **/
|
||||||
public static boolean exclude_admin_shops = plugin.getConfig().getBoolean("shop-limits.exclude-admin-shops");
|
public static boolean exclude_admin_shops = plugin.getConfig().getBoolean("shop-limits.exclude-admin-shops");
|
||||||
|
|
||||||
|
/** The maximum distance between a player and a shop to see the hologram **/
|
||||||
public static double maximal_distance = plugin.getConfig().getDouble("maximal-distance");
|
public static double maximal_distance = plugin.getConfig().getDouble("maximal-distance");
|
||||||
|
|
||||||
|
/** The price a player has to pay in order to create a normal shop **/
|
||||||
public static double shop_creation_price_normal = plugin.getConfig().getDouble("shop-creation-price.normal");
|
public static double shop_creation_price_normal = plugin.getConfig().getDouble("shop-creation-price.normal");
|
||||||
|
|
||||||
|
/** The price a player has to pay in order to create an admin shop **/
|
||||||
public static double shop_creation_price_admin = plugin.getConfig().getDouble("shop-creation-price.admin");
|
public static double shop_creation_price_admin = plugin.getConfig().getDouble("shop-creation-price.admin");
|
||||||
|
|
||||||
|
/** The default shop limit for players and groups that are not listed in {@link #shopLimits_player} or in {@link #shopLimits_group} **/
|
||||||
public static int default_limit = plugin.getConfig().getInt("shop-limits.default");
|
public static int default_limit = plugin.getConfig().getInt("shop-limits.default");
|
||||||
|
|
||||||
|
/** The main command of ShopChest <i>(default: shop)</i> **/
|
||||||
public static String main_command_name = plugin.getConfig().getString("main-command-name");
|
public static String main_command_name = plugin.getConfig().getString("main-command-name");
|
||||||
|
|
||||||
|
/** The language file to use (e.g <i>en_US</i>, <i>de_DE</i>) **/
|
||||||
public static String language_file = plugin.getConfig().getString("language-file");
|
public static String language_file = plugin.getConfig().getString("language-file");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,20 +4,39 @@ package de.epiceric.shopchest.interfaces;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface Hologram {
|
public interface Hologram {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Location of the hologram
|
||||||
|
*/
|
||||||
Location getLocation();
|
Location getLocation();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param p Player to which the hologram should be shown
|
||||||
|
*/
|
||||||
void showPlayer(OfflinePlayer p);
|
void showPlayer(OfflinePlayer p);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param p Player from which the hologram should be hidden
|
||||||
|
*/
|
||||||
void hidePlayer(OfflinePlayer p);
|
void hidePlayer(OfflinePlayer p);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param p Player to check
|
||||||
|
* @return Whether the hologram is visible to the player
|
||||||
|
*/
|
||||||
boolean isVisible(OfflinePlayer p);
|
boolean isVisible(OfflinePlayer p);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Whether the hologram exists and is not dead
|
||||||
|
*/
|
||||||
boolean exists();
|
boolean exists();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the hologram. <br>
|
||||||
|
* Hologram will be hidden from all players and will be killed
|
||||||
|
*/
|
||||||
void remove();
|
void remove();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,27 +5,27 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public interface JsonBuilder {
|
public interface JsonBuilder {
|
||||||
|
|
||||||
public JsonBuilder parse(String text);
|
JsonBuilder parse(String text);
|
||||||
|
|
||||||
public JsonBuilder withText(String text);
|
JsonBuilder withText(String text);
|
||||||
|
|
||||||
public JsonBuilder withColor(ChatColor color);
|
JsonBuilder withColor(ChatColor color);
|
||||||
|
|
||||||
public JsonBuilder withColor(String color);
|
JsonBuilder withColor(String color);
|
||||||
|
|
||||||
public JsonBuilder withClickEvent(ClickAction action, String value);
|
JsonBuilder withClickEvent(ClickAction action, String value);
|
||||||
|
|
||||||
public JsonBuilder withHoverEvent(HoverAction action, String value);
|
JsonBuilder withHoverEvent(HoverAction action, String value);
|
||||||
|
|
||||||
public String toString();
|
String toString();
|
||||||
|
|
||||||
public void sendJson(Player p);
|
void sendJson(Player p);
|
||||||
|
|
||||||
public enum ClickAction {
|
enum ClickAction {
|
||||||
RUN_COMMAND, SUGGEST_COMMAND, OPEN_URL
|
RUN_COMMAND, SUGGEST_COMMAND, OPEN_URL
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum HoverAction {
|
enum HoverAction {
|
||||||
SHOW_TEXT
|
SHOW_TEXT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,8 +4,15 @@ import org.bukkit.entity.EntityType;
|
|||||||
|
|
||||||
public abstract class SpawnEggMeta {
|
public abstract class SpawnEggMeta {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The NBT Tag <i>EntityTag.id</i> of the Spawn Egg
|
||||||
|
*/
|
||||||
public abstract String getNBTEntityID();
|
public abstract String getNBTEntityID();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param nbtEntityID EntityID returned by {@link #getNBTEntityID()}
|
||||||
|
* @return The {@link EntityType} the Spawn Egg will spawn or <b>null</b> if <i>nbtEntityID</i> is null
|
||||||
|
*/
|
||||||
public EntityType getEntityTypeFromNBTEntityID(String nbtEntityID) {
|
public EntityType getEntityTypeFromNBTEntityID(String nbtEntityID) {
|
||||||
if (nbtEntityID == null) return null;
|
if (nbtEntityID == null) return null;
|
||||||
|
|
||||||
|
@ -12,11 +12,16 @@ public class EnchantmentName {
|
|||||||
this.localizedName = localizedName;
|
this.localizedName = localizedName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Enchantment linked to the name
|
||||||
|
*/
|
||||||
public Enchantment getEnchantment() {
|
public Enchantment getEnchantment() {
|
||||||
return enchantment;
|
return enchantment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Name linked to the enchantment
|
||||||
|
*/
|
||||||
public String getLocalizedName() {
|
public String getLocalizedName() {
|
||||||
return localizedName;
|
return localizedName;
|
||||||
}
|
}
|
||||||
@ -30,10 +35,16 @@ public class EnchantmentName {
|
|||||||
this.localizedName = localizedName;
|
this.localizedName = localizedName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Level linked to the name
|
||||||
|
*/
|
||||||
public int getLevel() {
|
public int getLevel() {
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Name linked to the level
|
||||||
|
*/
|
||||||
public String getLocalizedName() {
|
public String getLocalizedName() {
|
||||||
return localizedName;
|
return localizedName;
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,16 @@ public class EntityName {
|
|||||||
this.localizedName = localizedName;
|
this.localizedName = localizedName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return EntityType linked to the name
|
||||||
|
*/
|
||||||
public EntityType getEntityType() {
|
public EntityType getEntityType() {
|
||||||
return entityType;
|
return entityType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Name linked to the EntityType
|
||||||
|
*/
|
||||||
public String getLocalizedName() {
|
public String getLocalizedName() {
|
||||||
return localizedName;
|
return localizedName;
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,23 @@ public class ItemName {
|
|||||||
this.localizedName = localizedName;
|
this.localizedName = localizedName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Material linked to the name
|
||||||
|
*/
|
||||||
public Material getMaterial() {
|
public Material getMaterial() {
|
||||||
return material;
|
return material;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Sub ID linked to the name
|
||||||
|
*/
|
||||||
public int getSubID() {
|
public int getSubID() {
|
||||||
return subID;
|
return subID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Name linked to the item
|
||||||
|
*/
|
||||||
public String getLocalizedName() {
|
public String getLocalizedName() {
|
||||||
return localizedName;
|
return localizedName;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ public class LanguageUtils {
|
|||||||
|
|
||||||
|
|
||||||
public static void load() {
|
public static void load() {
|
||||||
|
// Add Block Names
|
||||||
itemNames.add(new ItemName(Material.STONE, langConfig.getString("tile.stone.stone.name", "Stone")));
|
itemNames.add(new ItemName(Material.STONE, langConfig.getString("tile.stone.stone.name", "Stone")));
|
||||||
itemNames.add(new ItemName(Material.STONE, 1, langConfig.getString("tile.stone.granite.name", "Granite")));
|
itemNames.add(new ItemName(Material.STONE, 1, langConfig.getString("tile.stone.granite.name", "Granite")));
|
||||||
itemNames.add(new ItemName(Material.STONE, 2, langConfig.getString("tile.stone.graniteSmooth.name", "Polished Granite")));
|
itemNames.add(new ItemName(Material.STONE, 2, langConfig.getString("tile.stone.graniteSmooth.name", "Polished Granite")));
|
||||||
@ -338,6 +339,7 @@ public class LanguageUtils {
|
|||||||
itemNames.add(new ItemName(Material.ACACIA_FENCE, langConfig.getString("tile.acaciaFence.name", "Acacia Fence")));
|
itemNames.add(new ItemName(Material.ACACIA_FENCE, langConfig.getString("tile.acaciaFence.name", "Acacia Fence")));
|
||||||
|
|
||||||
if (Utils.getMajorVersion() >= 9) {
|
if (Utils.getMajorVersion() >= 9) {
|
||||||
|
// Add Block Names of 1.9
|
||||||
itemNames.add(new ItemName(Material.END_ROD, langConfig.getString("tile.endRod.name", "End Rod")));
|
itemNames.add(new ItemName(Material.END_ROD, langConfig.getString("tile.endRod.name", "End Rod")));
|
||||||
itemNames.add(new ItemName(Material.CHORUS_PLANT, langConfig.getString("tile.chorusPlant.name", "Chorus Plant")));
|
itemNames.add(new ItemName(Material.CHORUS_PLANT, langConfig.getString("tile.chorusPlant.name", "Chorus Plant")));
|
||||||
itemNames.add(new ItemName(Material.CHORUS_FLOWER, langConfig.getString("tile.chorusFlower.name", "Chorus Flower")));
|
itemNames.add(new ItemName(Material.CHORUS_FLOWER, langConfig.getString("tile.chorusFlower.name", "Chorus Flower")));
|
||||||
@ -353,6 +355,7 @@ public class LanguageUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.getMajorVersion() >= 10) {
|
if (Utils.getMajorVersion() >= 10) {
|
||||||
|
// Add Block Names of 1.10
|
||||||
itemNames.add(new ItemName(Material.MAGMA, langConfig.getString("tile.magma.name", "Magma Block")));
|
itemNames.add(new ItemName(Material.MAGMA, langConfig.getString("tile.magma.name", "Magma Block")));
|
||||||
itemNames.add(new ItemName(Material.NETHER_WART_BLOCK, langConfig.getString("tile.netherWartBlock.name", "Nether Wart Block")));
|
itemNames.add(new ItemName(Material.NETHER_WART_BLOCK, langConfig.getString("tile.netherWartBlock.name", "Nether Wart Block")));
|
||||||
itemNames.add(new ItemName(Material.RED_NETHER_BRICK, langConfig.getString("tile.redNetherBrick.name", "Red Nether Brick")));
|
itemNames.add(new ItemName(Material.RED_NETHER_BRICK, langConfig.getString("tile.redNetherBrick.name", "Red Nether Brick")));
|
||||||
@ -360,6 +363,7 @@ public class LanguageUtils {
|
|||||||
itemNames.add(new ItemName(Material.STRUCTURE_VOID, langConfig.getString("tile.structureVoid.name", "Structure Void")));
|
itemNames.add(new ItemName(Material.STRUCTURE_VOID, langConfig.getString("tile.structureVoid.name", "Structure Void")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add Item Names
|
||||||
itemNames.add(new ItemName(Material.IRON_SPADE, langConfig.getString("item.shovelIron.name", "Iron Shovel")));
|
itemNames.add(new ItemName(Material.IRON_SPADE, langConfig.getString("item.shovelIron.name", "Iron Shovel")));
|
||||||
itemNames.add(new ItemName(Material.IRON_PICKAXE, langConfig.getString("item.pickaxeIron.name", "Iron Pickaxe")));
|
itemNames.add(new ItemName(Material.IRON_PICKAXE, langConfig.getString("item.pickaxeIron.name", "Iron Pickaxe")));
|
||||||
itemNames.add(new ItemName(Material.IRON_AXE, langConfig.getString("item.hatchetIron.name", "Iron Axe")));
|
itemNames.add(new ItemName(Material.IRON_AXE, langConfig.getString("item.hatchetIron.name", "Iron Axe")));
|
||||||
@ -605,6 +609,7 @@ public class LanguageUtils {
|
|||||||
itemNames.add(new ItemName(Material.RECORD_11, langConfig.getString("item.record.name", "Music Disc")));
|
itemNames.add(new ItemName(Material.RECORD_11, langConfig.getString("item.record.name", "Music Disc")));
|
||||||
itemNames.add(new ItemName(Material.RECORD_12, langConfig.getString("item.record.name", "Music Disc")));
|
itemNames.add(new ItemName(Material.RECORD_12, langConfig.getString("item.record.name", "Music Disc")));
|
||||||
|
|
||||||
|
// Add Enchantment Names
|
||||||
enchantmentNames.add(new EnchantmentName(Enchantment.ARROW_DAMAGE, langConfig.getString("enchantment.arrowDamage", "Power")));
|
enchantmentNames.add(new EnchantmentName(Enchantment.ARROW_DAMAGE, langConfig.getString("enchantment.arrowDamage", "Power")));
|
||||||
enchantmentNames.add(new EnchantmentName(Enchantment.ARROW_FIRE, langConfig.getString("enchantment.arrowFire", "Flame")));
|
enchantmentNames.add(new EnchantmentName(Enchantment.ARROW_FIRE, langConfig.getString("enchantment.arrowFire", "Flame")));
|
||||||
enchantmentNames.add(new EnchantmentName(Enchantment.ARROW_INFINITE, langConfig.getString("enchantment.arrowInfinite", "Infinity")));
|
enchantmentNames.add(new EnchantmentName(Enchantment.ARROW_INFINITE, langConfig.getString("enchantment.arrowInfinite", "Infinity")));
|
||||||
@ -632,10 +637,12 @@ public class LanguageUtils {
|
|||||||
enchantmentNames.add(new EnchantmentName(Enchantment.WATER_WORKER, langConfig.getString("enchantment.waterWorker", "Aqua Affinity")));
|
enchantmentNames.add(new EnchantmentName(Enchantment.WATER_WORKER, langConfig.getString("enchantment.waterWorker", "Aqua Affinity")));
|
||||||
|
|
||||||
if (Utils.getMajorVersion() >= 9) {
|
if (Utils.getMajorVersion() >= 9) {
|
||||||
|
// Add Enchantment Names of 1.9
|
||||||
enchantmentNames.add(new EnchantmentName(Enchantment.FROST_WALKER, langConfig.getString("enchantment.frostWalker", "Frost Walker")));
|
enchantmentNames.add(new EnchantmentName(Enchantment.FROST_WALKER, langConfig.getString("enchantment.frostWalker", "Frost Walker")));
|
||||||
enchantmentNames.add(new EnchantmentName(Enchantment.MENDING, langConfig.getString("enchantment.mending", "Mending")));
|
enchantmentNames.add(new EnchantmentName(Enchantment.MENDING, langConfig.getString("enchantment.mending", "Mending")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add Enchantment Level Names
|
||||||
enchantmentLevelNames.add(new EnchantmentName.EnchantmentLevelName(1, langConfig.getString("enchantment.level.1", "I")));
|
enchantmentLevelNames.add(new EnchantmentName.EnchantmentLevelName(1, langConfig.getString("enchantment.level.1", "I")));
|
||||||
enchantmentLevelNames.add(new EnchantmentName.EnchantmentLevelName(2, langConfig.getString("enchantment.level.2", "II")));
|
enchantmentLevelNames.add(new EnchantmentName.EnchantmentLevelName(2, langConfig.getString("enchantment.level.2", "II")));
|
||||||
enchantmentLevelNames.add(new EnchantmentName.EnchantmentLevelName(3, langConfig.getString("enchantment.level.3", "II")));
|
enchantmentLevelNames.add(new EnchantmentName.EnchantmentLevelName(3, langConfig.getString("enchantment.level.3", "II")));
|
||||||
@ -647,6 +654,7 @@ public class LanguageUtils {
|
|||||||
enchantmentLevelNames.add(new EnchantmentName.EnchantmentLevelName(9, langConfig.getString("enchantment.level.9", "IX")));
|
enchantmentLevelNames.add(new EnchantmentName.EnchantmentLevelName(9, langConfig.getString("enchantment.level.9", "IX")));
|
||||||
enchantmentLevelNames.add(new EnchantmentName.EnchantmentLevelName(10, langConfig.getString("enchantment.level.10", "X")));
|
enchantmentLevelNames.add(new EnchantmentName.EnchantmentLevelName(10, langConfig.getString("enchantment.level.10", "X")));
|
||||||
|
|
||||||
|
// Add Entity Names
|
||||||
entityNames.add(new EntityName(EntityType.CREEPER, langConfig.getString("entity.Creeper.name", "Creeper")));
|
entityNames.add(new EntityName(EntityType.CREEPER, langConfig.getString("entity.Creeper.name", "Creeper")));
|
||||||
entityNames.add(new EntityName(EntityType.SKELETON, langConfig.getString("entity.Skeleton.name", "Skeleton")));
|
entityNames.add(new EntityName(EntityType.SKELETON, langConfig.getString("entity.Skeleton.name", "Skeleton")));
|
||||||
entityNames.add(new EntityName(EntityType.SPIDER, langConfig.getString("entity.Spider.name", "Spider")));
|
entityNames.add(new EntityName(EntityType.SPIDER, langConfig.getString("entity.Spider.name", "Spider")));
|
||||||
@ -676,13 +684,16 @@ public class LanguageUtils {
|
|||||||
entityNames.add(new EntityName(EntityType.VILLAGER, langConfig.getString("entity.Villager.name", "Villager")));
|
entityNames.add(new EntityName(EntityType.VILLAGER, langConfig.getString("entity.Villager.name", "Villager")));
|
||||||
|
|
||||||
if (Utils.getMajorVersion() >= 9) {
|
if (Utils.getMajorVersion() >= 9) {
|
||||||
|
// Add Entity Names of 1.9
|
||||||
entityNames.add(new EntityName(EntityType.SHULKER, langConfig.getString("entity.Shulker.name", "Shulker")));
|
entityNames.add(new EntityName(EntityType.SHULKER, langConfig.getString("entity.Shulker.name", "Shulker")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.getMajorVersion() >= 10) {
|
if (Utils.getMajorVersion() >= 10) {
|
||||||
|
// Add Entity Names of 1.10
|
||||||
entityNames.add(new EntityName(EntityType.POLAR_BEAR, langConfig.getString("entity.PolarBear.name", "Polar Bear")));
|
entityNames.add(new EntityName(EntityType.POLAR_BEAR, langConfig.getString("entity.PolarBear.name", "Polar Bear")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add Potion Effect Names
|
||||||
potionEffectNames.add(new PotionEffectName(PotionType.FIRE_RESISTANCE, langConfig.getString("effect.fireResistance", "Fire Resistance")));
|
potionEffectNames.add(new PotionEffectName(PotionType.FIRE_RESISTANCE, langConfig.getString("effect.fireResistance", "Fire Resistance")));
|
||||||
potionEffectNames.add(new PotionEffectName(PotionType.INSTANT_DAMAGE, langConfig.getString("effect.harm", "Instant Damage")));
|
potionEffectNames.add(new PotionEffectName(PotionType.INSTANT_DAMAGE, langConfig.getString("effect.harm", "Instant Damage")));
|
||||||
potionEffectNames.add(new PotionEffectName(PotionType.INSTANT_HEAL, langConfig.getString("effect.heal", "Instant Health")));
|
potionEffectNames.add(new PotionEffectName(PotionType.INSTANT_HEAL, langConfig.getString("effect.heal", "Instant Health")));
|
||||||
@ -700,12 +711,14 @@ public class LanguageUtils {
|
|||||||
potionEffectNames.add(new PotionEffectName(PotionType.AWKWARD, langConfig.getString("effect.none", "No Effects")));
|
potionEffectNames.add(new PotionEffectName(PotionType.AWKWARD, langConfig.getString("effect.none", "No Effects")));
|
||||||
|
|
||||||
if (Utils.getMajorVersion() >= 9) {
|
if (Utils.getMajorVersion() >= 9) {
|
||||||
|
// Add Potion Effect Names of 1.9
|
||||||
potionEffectNames.add(new PotionEffectName(PotionType.LUCK, langConfig.getString("effect.luck", "Luck")));
|
potionEffectNames.add(new PotionEffectName(PotionType.LUCK, langConfig.getString("effect.luck", "Luck")));
|
||||||
potionEffectNames.add(new PotionEffectName(PotionType.MUNDANE, langConfig.getString("effect.none", "No Effects")));
|
potionEffectNames.add(new PotionEffectName(PotionType.MUNDANE, langConfig.getString("effect.none", "No Effects")));
|
||||||
potionEffectNames.add(new PotionEffectName(PotionType.THICK, langConfig.getString("effect.none", "No Effects")));
|
potionEffectNames.add(new PotionEffectName(PotionType.THICK, langConfig.getString("effect.none", "No Effects")));
|
||||||
potionEffectNames.add(new PotionEffectName(PotionType.UNCRAFTABLE, langConfig.getString("effect.none", "No Effects")));
|
potionEffectNames.add(new PotionEffectName(PotionType.UNCRAFTABLE, langConfig.getString("effect.none", "No Effects")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add Potion Names
|
||||||
potionNames.add(new PotionName(PotionName.PotionItemType.POTION, PotionType.AWKWARD, langConfig.getString("potion.effect.awkward", "Awkward Potion")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.POTION, PotionType.AWKWARD, langConfig.getString("potion.effect.awkward", "Awkward Potion")));
|
||||||
potionNames.add(new PotionName(PotionName.PotionItemType.POTION, PotionType.FIRE_RESISTANCE, langConfig.getString("potion.effect.fire_resistance", "Potion of Fire Resistance")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.POTION, PotionType.FIRE_RESISTANCE, langConfig.getString("potion.effect.fire_resistance", "Potion of Fire Resistance")));
|
||||||
potionNames.add(new PotionName(PotionName.PotionItemType.POTION, PotionType.INSTANT_DAMAGE, langConfig.getString("potion.effect.harming", "Potion of Harming")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.POTION, PotionType.INSTANT_DAMAGE, langConfig.getString("potion.effect.harming", "Potion of Harming")));
|
||||||
@ -723,6 +736,7 @@ public class LanguageUtils {
|
|||||||
potionNames.add(new PotionName(PotionName.PotionItemType.POTION, PotionType.WATER, langConfig.getString("potion.effect.water", "Water Bottle")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.POTION, PotionType.WATER, langConfig.getString("potion.effect.water", "Water Bottle")));
|
||||||
|
|
||||||
if (Utils.getMajorVersion() >= 9) {
|
if (Utils.getMajorVersion() >= 9) {
|
||||||
|
// Add Potion Names of 1.9
|
||||||
potionNames.add(new PotionName(PotionName.PotionItemType.POTION, PotionType.LUCK, langConfig.getString("potion.effect.luck", "Potion of Luck")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.POTION, PotionType.LUCK, langConfig.getString("potion.effect.luck", "Potion of Luck")));
|
||||||
potionNames.add(new PotionName(PotionName.PotionItemType.POTION, PotionType.MUNDANE, langConfig.getString("potion.effect.mundane", "Mundane Potion")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.POTION, PotionType.MUNDANE, langConfig.getString("potion.effect.mundane", "Mundane Potion")));
|
||||||
potionNames.add(new PotionName(PotionName.PotionItemType.POTION, PotionType.THICK, langConfig.getString("potion.effect.thick", "Thick Potion")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.POTION, PotionType.THICK, langConfig.getString("potion.effect.thick", "Thick Potion")));
|
||||||
@ -730,6 +744,7 @@ public class LanguageUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.getMajorVersion() >= 9) {
|
if (Utils.getMajorVersion() >= 9) {
|
||||||
|
// Add Tipped Arrow Names (implemented in Minecraft since 1.9)
|
||||||
potionNames.add(new PotionName(PotionName.PotionItemType.TIPPED_ARROW, PotionType.AWKWARD, langConfig.getString("tipped_arrow.effect.awkward", "Tipped Arrow")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.TIPPED_ARROW, PotionType.AWKWARD, langConfig.getString("tipped_arrow.effect.awkward", "Tipped Arrow")));
|
||||||
potionNames.add(new PotionName(PotionName.PotionItemType.TIPPED_ARROW, PotionType.FIRE_RESISTANCE, langConfig.getString("tipped_arrow.effect.fire_resistance", "Arrow of Fire Resistance")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.TIPPED_ARROW, PotionType.FIRE_RESISTANCE, langConfig.getString("tipped_arrow.effect.fire_resistance", "Arrow of Fire Resistance")));
|
||||||
potionNames.add(new PotionName(PotionName.PotionItemType.TIPPED_ARROW, PotionType.INSTANT_DAMAGE, langConfig.getString("tipped_arrow.effect.harming", "Arrow of Harming")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.TIPPED_ARROW, PotionType.INSTANT_DAMAGE, langConfig.getString("tipped_arrow.effect.harming", "Arrow of Harming")));
|
||||||
@ -751,6 +766,7 @@ public class LanguageUtils {
|
|||||||
potionNames.add(new PotionName(PotionName.PotionItemType.TIPPED_ARROW, PotionType.UNCRAFTABLE, langConfig.getString("tipped_arrow.effect.empty", "Tipped Arrow")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.TIPPED_ARROW, PotionType.UNCRAFTABLE, langConfig.getString("tipped_arrow.effect.empty", "Tipped Arrow")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add Splash Potion Names
|
||||||
potionNames.add(new PotionName(PotionName.PotionItemType.SPLASH_POTION, PotionType.AWKWARD, langConfig.getString("splash_potion.effect.awkward", "Awkward Splash Potion")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.SPLASH_POTION, PotionType.AWKWARD, langConfig.getString("splash_potion.effect.awkward", "Awkward Splash Potion")));
|
||||||
potionNames.add(new PotionName(PotionName.PotionItemType.SPLASH_POTION, PotionType.FIRE_RESISTANCE, langConfig.getString("splash_potion.effect.fire_resistance", "Splash Potion of Fire Resistance")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.SPLASH_POTION, PotionType.FIRE_RESISTANCE, langConfig.getString("splash_potion.effect.fire_resistance", "Splash Potion of Fire Resistance")));
|
||||||
potionNames.add(new PotionName(PotionName.PotionItemType.SPLASH_POTION, PotionType.INSTANT_DAMAGE, langConfig.getString("splash_potion.effect.harming", "Splash Potion of Harming")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.SPLASH_POTION, PotionType.INSTANT_DAMAGE, langConfig.getString("splash_potion.effect.harming", "Splash Potion of Harming")));
|
||||||
@ -768,6 +784,7 @@ public class LanguageUtils {
|
|||||||
potionNames.add(new PotionName(PotionName.PotionItemType.SPLASH_POTION, PotionType.WATER, langConfig.getString("splash_potion.effect.water", "Splash Water Bottle")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.SPLASH_POTION, PotionType.WATER, langConfig.getString("splash_potion.effect.water", "Splash Water Bottle")));
|
||||||
|
|
||||||
if (Utils.getMajorVersion() >= 9) {
|
if (Utils.getMajorVersion() >= 9) {
|
||||||
|
// Add Splash Potion Names of 1.9
|
||||||
potionNames.add(new PotionName(PotionName.PotionItemType.SPLASH_POTION, PotionType.LUCK, langConfig.getString("splash_potion.effect.luck", "Splash Potion of Luck")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.SPLASH_POTION, PotionType.LUCK, langConfig.getString("splash_potion.effect.luck", "Splash Potion of Luck")));
|
||||||
potionNames.add(new PotionName(PotionName.PotionItemType.SPLASH_POTION, PotionType.MUNDANE, langConfig.getString("splash_potion.effect.mundane", "Mundane Splash Potion")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.SPLASH_POTION, PotionType.MUNDANE, langConfig.getString("splash_potion.effect.mundane", "Mundane Splash Potion")));
|
||||||
potionNames.add(new PotionName(PotionName.PotionItemType.SPLASH_POTION, PotionType.THICK, langConfig.getString("splash_potion.effect.thick", "Thick Splash Potion")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.SPLASH_POTION, PotionType.THICK, langConfig.getString("splash_potion.effect.thick", "Thick Splash Potion")));
|
||||||
@ -775,6 +792,7 @@ public class LanguageUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.getMajorVersion() >= 9) {
|
if (Utils.getMajorVersion() >= 9) {
|
||||||
|
// Add Lingering Potion Names (implemented in Minecraft since 1.9)
|
||||||
potionNames.add(new PotionName(PotionName.PotionItemType.LINGERING_POTION, PotionType.AWKWARD, langConfig.getString("lingering_potion.effect.awkward", "Awkward Lingering Potion")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.LINGERING_POTION, PotionType.AWKWARD, langConfig.getString("lingering_potion.effect.awkward", "Awkward Lingering Potion")));
|
||||||
potionNames.add(new PotionName(PotionName.PotionItemType.LINGERING_POTION, PotionType.FIRE_RESISTANCE, langConfig.getString("lingering_potion.effect.fire_resistance", "Lingering Potion of Fire Resistance")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.LINGERING_POTION, PotionType.FIRE_RESISTANCE, langConfig.getString("lingering_potion.effect.fire_resistance", "Lingering Potion of Fire Resistance")));
|
||||||
potionNames.add(new PotionName(PotionName.PotionItemType.LINGERING_POTION, PotionType.INSTANT_DAMAGE, langConfig.getString("lingering_potion.effect.harming", "Lingering Potion of Harming")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.LINGERING_POTION, PotionType.INSTANT_DAMAGE, langConfig.getString("lingering_potion.effect.harming", "Lingering Potion of Harming")));
|
||||||
@ -796,6 +814,7 @@ public class LanguageUtils {
|
|||||||
potionNames.add(new PotionName(PotionName.PotionItemType.LINGERING_POTION, PotionType.UNCRAFTABLE, langConfig.getString("lingering_potion.effect.empty", "Lingering Uncraftable Potion")));
|
potionNames.add(new PotionName(PotionName.PotionItemType.LINGERING_POTION, PotionType.UNCRAFTABLE, langConfig.getString("lingering_potion.effect.empty", "Lingering Uncraftable Potion")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add Music Disc Titles
|
||||||
musicDiscNames.add(new MusicDiscName(Material.GOLD_RECORD, langConfig.getString("item.record.13.desc", "C418 - 13")));
|
musicDiscNames.add(new MusicDiscName(Material.GOLD_RECORD, langConfig.getString("item.record.13.desc", "C418 - 13")));
|
||||||
musicDiscNames.add(new MusicDiscName(Material.GREEN_RECORD, langConfig.getString("item.record.cat.desc", "C418 - cat")));
|
musicDiscNames.add(new MusicDiscName(Material.GREEN_RECORD, langConfig.getString("item.record.cat.desc", "C418 - cat")));
|
||||||
musicDiscNames.add(new MusicDiscName(Material.RECORD_3, langConfig.getString("item.record.blocks.desc", "C418 - blocks")));
|
musicDiscNames.add(new MusicDiscName(Material.RECORD_3, langConfig.getString("item.record.blocks.desc", "C418 - blocks")));
|
||||||
@ -809,6 +828,7 @@ public class LanguageUtils {
|
|||||||
musicDiscNames.add(new MusicDiscName(Material.RECORD_11, langConfig.getString("item.record.11.desc", "C418 - 11")));
|
musicDiscNames.add(new MusicDiscName(Material.RECORD_11, langConfig.getString("item.record.11.desc", "C418 - 11")));
|
||||||
musicDiscNames.add(new MusicDiscName(Material.RECORD_12, langConfig.getString("item.record.wait.desc", "C418 - wait")));
|
musicDiscNames.add(new MusicDiscName(Material.RECORD_12, langConfig.getString("item.record.wait.desc", "C418 - wait")));
|
||||||
|
|
||||||
|
// Add ShopChest Messages
|
||||||
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_CREATED, langConfig.getString("message.shop-created", "&6Shop created.")));
|
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_CREATED, langConfig.getString("message.shop-created", "&6Shop created.")));
|
||||||
messages.add(new LocalizedMessage(LocalizedMessage.Message.CHEST_ALREADY_SHOP, langConfig.getString("message.chest-already-shop", "&cChest already shop.")));
|
messages.add(new LocalizedMessage(LocalizedMessage.Message.CHEST_ALREADY_SHOP, langConfig.getString("message.chest-already-shop", "&cChest already shop.")));
|
||||||
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_REMOVED, langConfig.getString("message.shop-removed", "&6Shop removed.")));
|
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_REMOVED, langConfig.getString("message.shop-removed", "&6Shop removed.")));
|
||||||
@ -881,6 +901,10 @@ public class LanguageUtils {
|
|||||||
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_LIMITS, langConfig.getString("message.commandDescription.limits", "View shop limits.")));
|
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_LIMITS, langConfig.getString("message.commandDescription.limits", "View shop limits.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param stack Item whose name to lookup
|
||||||
|
* @return Localized Name of the Item, the custom name, or if <i>stack</i> is a book, the title of the book
|
||||||
|
*/
|
||||||
public static String getItemName(ItemStack stack) {
|
public static String getItemName(ItemStack stack) {
|
||||||
if (stack.hasItemMeta()) {
|
if (stack.hasItemMeta()) {
|
||||||
ItemMeta meta = stack.getItemMeta();
|
ItemMeta meta = stack.getItemMeta();
|
||||||
@ -959,7 +983,7 @@ public class LanguageUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return itemName.getLocalizedName() + " " + capitalizeDefaultString(spawnedType.toString());
|
return itemName.getLocalizedName() + " " + formatDefaultString(spawnedType.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -969,11 +993,16 @@ public class LanguageUtils {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return capitalizeDefaultString(material.toString());
|
return formatDefaultString(material.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param enchantment Enchantment whose name should be looked up
|
||||||
|
* @param level Level of the enchantment
|
||||||
|
* @return Localized Name of the enchantment with the given level afterwards
|
||||||
|
*/
|
||||||
public static String getEnchantmentName(Enchantment enchantment, int level) {
|
public static String getEnchantmentName(Enchantment enchantment, int level) {
|
||||||
String enchantmentString = capitalizeDefaultString(enchantment.getName());
|
String enchantmentString = formatDefaultString(enchantment.getName());
|
||||||
String levelString = langConfig.getString("enchantment.level." + level, String.valueOf(level));
|
String levelString = langConfig.getString("enchantment.level." + level, String.valueOf(level));
|
||||||
|
|
||||||
for (EnchantmentName enchantmentName : enchantmentNames) {
|
for (EnchantmentName enchantmentName : enchantmentNames) {
|
||||||
@ -991,10 +1020,14 @@ public class LanguageUtils {
|
|||||||
return enchantmentString + " " + levelString;
|
return enchantmentString + " " + levelString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param itemStack Potion Item whose base effect name should be looked up
|
||||||
|
* @return Localized Name of the Base Potion Effect
|
||||||
|
*/
|
||||||
public static String getPotionEffectName(ItemStack itemStack) {
|
public static String getPotionEffectName(ItemStack itemStack) {
|
||||||
PotionMeta potionMeta = (PotionMeta) itemStack.getItemMeta();
|
PotionMeta potionMeta = (PotionMeta) itemStack.getItemMeta();
|
||||||
|
|
||||||
String potionEffectString = capitalizeDefaultString(potionMeta.getBasePotionData().getType().toString());
|
String potionEffectString = formatDefaultString(potionMeta.getBasePotionData().getType().toString());
|
||||||
String upgradeString = potionMeta.getBasePotionData().isUpgraded() ? "II" : "";
|
String upgradeString = potionMeta.getBasePotionData().isUpgraded() ? "II" : "";
|
||||||
|
|
||||||
for (PotionEffectName potionEffectName : potionEffectNames) {
|
for (PotionEffectName potionEffectName : potionEffectNames) {
|
||||||
@ -1006,6 +1039,10 @@ public class LanguageUtils {
|
|||||||
return potionEffectString + (upgradeString.length() > 0 ? " " + upgradeString : "");
|
return potionEffectString + (upgradeString.length() > 0 ? " " + upgradeString : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param musicDiscMaterial Material of the Music Disc whose name should be looked up
|
||||||
|
* @return Localized title of the Music Disc
|
||||||
|
*/
|
||||||
public static String getMusicDiscName(Material musicDiscMaterial) {
|
public static String getMusicDiscName(Material musicDiscMaterial) {
|
||||||
for (MusicDiscName musicDiscName : musicDiscNames) {
|
for (MusicDiscName musicDiscName : musicDiscNames) {
|
||||||
if (musicDiscMaterial == musicDiscName.getMusicDiscMaterial()) {
|
if (musicDiscMaterial == musicDiscName.getMusicDiscMaterial()) {
|
||||||
@ -1016,6 +1053,11 @@ public class LanguageUtils {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param message Message which should be translated
|
||||||
|
* @param replacedRegexes Regexes which might be required to be replaced in the message
|
||||||
|
* @return Localized Message
|
||||||
|
*/
|
||||||
public static String getMessage(LocalizedMessage.Message message, LocalizedMessage.ReplacedRegex... replacedRegexes) {
|
public static String getMessage(LocalizedMessage.Message message, LocalizedMessage.ReplacedRegex... replacedRegexes) {
|
||||||
String _message = ChatColor.RED + "An error occurred: Message not found: " + message.toString();
|
String _message = ChatColor.RED + "An error occurred: Message not found: " + message.toString();
|
||||||
|
|
||||||
@ -1055,7 +1097,13 @@ public class LanguageUtils {
|
|||||||
return _message;
|
return _message;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String capitalizeDefaultString(String string) {
|
/**
|
||||||
|
* Underscores will be replaced by spaces and the first letter of each word will be capitalized
|
||||||
|
*
|
||||||
|
* @param string String to format
|
||||||
|
* @return Formatted String with underscores replaced by spaces and the first letter of each word capitalized
|
||||||
|
*/
|
||||||
|
private static String formatDefaultString(String string) {
|
||||||
string = string.replace("_", " ");
|
string = string.replace("_", " ");
|
||||||
String newString = "";
|
String newString = "";
|
||||||
|
|
||||||
|
@ -20,14 +20,23 @@ public class LocalizedMessage {
|
|||||||
this.localizedString = ChatColor.translateAlternateColorCodes('&', localizedString);
|
this.localizedString = ChatColor.translateAlternateColorCodes('&', localizedString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link Message} linked to this object
|
||||||
|
*/
|
||||||
public Message getMessage() {
|
public Message getMessage() {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Array of {@link Regex}, which are required by the message
|
||||||
|
*/
|
||||||
public Regex[] getRegexes() {
|
public Regex[] getRegexes() {
|
||||||
return regexes;
|
return regexes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Localized Message
|
||||||
|
*/
|
||||||
public String getLocalizedString() {
|
public String getLocalizedString() {
|
||||||
return localizedString;
|
return localizedString;
|
||||||
}
|
}
|
||||||
@ -102,7 +111,7 @@ public class LocalizedMessage {
|
|||||||
COMMAND_DESC_INFO,
|
COMMAND_DESC_INFO,
|
||||||
COMMAND_DESC_RELOAD,
|
COMMAND_DESC_RELOAD,
|
||||||
COMMAND_DESC_UPDATE,
|
COMMAND_DESC_UPDATE,
|
||||||
COMMAND_DESC_LIMITS;
|
COMMAND_DESC_LIMITS
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ReplacedRegex {
|
public static class ReplacedRegex {
|
||||||
@ -115,10 +124,16 @@ public class LocalizedMessage {
|
|||||||
this.replace = replace;
|
this.replace = replace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return String which will replace the regex
|
||||||
|
*/
|
||||||
public String getReplace() {
|
public String getReplace() {
|
||||||
return replace;
|
return replace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Regex that will be replaced
|
||||||
|
*/
|
||||||
public Regex getRegex() {
|
public Regex getRegex() {
|
||||||
return regex;
|
return regex;
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,16 @@ public class MusicDiscName {
|
|||||||
this.localizedName = localizedName;
|
this.localizedName = localizedName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Localized Title of the Music Disc
|
||||||
|
*/
|
||||||
public String getLocalizedName() {
|
public String getLocalizedName() {
|
||||||
return localizedName;
|
return localizedName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Material of the Music Disc
|
||||||
|
*/
|
||||||
public Material getMusicDiscMaterial() {
|
public Material getMusicDiscMaterial() {
|
||||||
return musicDiscMaterial;
|
return musicDiscMaterial;
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,16 @@ public class PotionEffectName {
|
|||||||
this.localizedName = localizedName;
|
this.localizedName = localizedName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Potion Effect linked to the name
|
||||||
|
*/
|
||||||
public PotionType getEffect() {
|
public PotionType getEffect() {
|
||||||
return effect;
|
return effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Localized Name of the potion effect
|
||||||
|
*/
|
||||||
public String getLocalizedName() {
|
public String getLocalizedName() {
|
||||||
return localizedName;
|
return localizedName;
|
||||||
}
|
}
|
||||||
|
@ -15,14 +15,23 @@ public class PotionName {
|
|||||||
this.potionType = potionType;
|
this.potionType = potionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link PotionItemType} linked to the Potion name
|
||||||
|
*/
|
||||||
public PotionItemType getPotionItemType() {
|
public PotionItemType getPotionItemType() {
|
||||||
return potionItemType;
|
return potionItemType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Potion Type linked to the Potion name
|
||||||
|
*/
|
||||||
public PotionType getPotionType() {
|
public PotionType getPotionType() {
|
||||||
return potionType;
|
return potionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Localized Name of the Potion
|
||||||
|
*/
|
||||||
public String getLocalizedName() {
|
public String getLocalizedName() {
|
||||||
return localizedName;
|
return localizedName;
|
||||||
}
|
}
|
||||||
@ -31,6 +40,6 @@ public class PotionName {
|
|||||||
POTION,
|
POTION,
|
||||||
LINGERING_POTION,
|
LINGERING_POTION,
|
||||||
SPLASH_POTION,
|
SPLASH_POTION,
|
||||||
TIPPED_ARROW;
|
TIPPED_ARROW
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,6 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
|||||||
|
|
||||||
public class HologramUpdateListener implements Listener {
|
public class HologramUpdateListener implements Listener {
|
||||||
|
|
||||||
public HologramUpdateListener() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerMove(PlayerMoveEvent e) {
|
public void onPlayerMove(PlayerMoveEvent e) {
|
||||||
|
|
||||||
|
@ -223,6 +223,16 @@ public class ShopInteractListener implements Listener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new shop
|
||||||
|
*
|
||||||
|
* @param executor Player, who executed the command, will receive the message and become the vendor of the shop
|
||||||
|
* @param location Where the shop will be located
|
||||||
|
* @param product Product of the Shop
|
||||||
|
* @param buyPrice Buy price
|
||||||
|
* @param sellPrice Sell price
|
||||||
|
* @param shopType Type of the shop
|
||||||
|
*/
|
||||||
private void create(Player executor, Location location, ItemStack product, double buyPrice, double sellPrice, ShopType shopType) {
|
private void create(Player executor, Location location, ItemStack product, double buyPrice, double sellPrice, ShopType shopType) {
|
||||||
Shop shop = new Shop(database.getNextFreeID(), plugin, executor, product, location, buyPrice, sellPrice, shopType);
|
Shop shop = new Shop(database.getNextFreeID(), plugin, executor, product, location, buyPrice, sellPrice, shopType);
|
||||||
|
|
||||||
@ -235,11 +245,21 @@ public class ShopInteractListener implements Listener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a shop
|
||||||
|
* @param executor Player, who executed the command and will receive the message
|
||||||
|
* @param shop Shop to be removed
|
||||||
|
*/
|
||||||
private void remove(Player executor, Shop shop) {
|
private void remove(Player executor, Shop shop) {
|
||||||
ShopUtils.removeShop(shop, true);
|
ShopUtils.removeShop(shop, true);
|
||||||
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_REMOVED));
|
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_REMOVED));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param executor Player, who executed the command and will retrieve the information
|
||||||
|
* @param shop Shop from which the information will be retrieved
|
||||||
|
*/
|
||||||
private void info(Player executor, Shop shop) {
|
private void info(Player executor, Shop shop) {
|
||||||
Chest c = (Chest) shop.getLocation().getBlock().getState();
|
Chest c = (Chest) shop.getLocation().getBlock().getState();
|
||||||
|
|
||||||
@ -308,6 +328,11 @@ public class ShopInteractListener implements Listener {
|
|||||||
executor.sendMessage(" ");
|
executor.sendMessage(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A player buys from a shop
|
||||||
|
* @param executor Player, who executed the command and will buy the product
|
||||||
|
* @param shop Shop, from which the player buys
|
||||||
|
*/
|
||||||
private void buy(Player executor, Shop shop) {
|
private void buy(Player executor, Shop shop) {
|
||||||
if (econ.getBalance(executor) >= shop.getBuyPrice()) {
|
if (econ.getBalance(executor) >= shop.getBuyPrice()) {
|
||||||
|
|
||||||
@ -390,6 +415,11 @@ public class ShopInteractListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A player sells to a shop
|
||||||
|
* @param executor Player, who executed the command and will sell the product
|
||||||
|
* @param shop Shop, to which the player sells
|
||||||
|
*/
|
||||||
private void sell(Player executor, Shop shop) {
|
private void sell(Player executor, Shop shop) {
|
||||||
if (econ.getBalance(shop.getVendor()) >= shop.getSellPrice() || shop.getShopType() == ShopType.ADMIN) {
|
if (econ.getBalance(shop.getVendor()) >= shop.getSellPrice() || shop.getShopType() == ShopType.ADMIN) {
|
||||||
|
|
||||||
@ -463,6 +493,12 @@ public class ShopInteractListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds items to an inventory
|
||||||
|
* @param inventory The inventory, to which the items will be added
|
||||||
|
* @param itemStack Items to add
|
||||||
|
* @return Whether all items were added to the inventory
|
||||||
|
*/
|
||||||
private boolean addToInventory(Inventory inventory, ItemStack itemStack) {
|
private boolean addToInventory(Inventory inventory, ItemStack itemStack) {
|
||||||
HashMap<Integer, ItemStack> inventoryItems = new HashMap<>();
|
HashMap<Integer, ItemStack> inventoryItems = new HashMap<>();
|
||||||
int amount = itemStack.getAmount();
|
int amount = itemStack.getAmount();
|
||||||
@ -513,6 +549,12 @@ public class ShopInteractListener implements Listener {
|
|||||||
return (added == amount);
|
return (added == amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes items to from an inventory
|
||||||
|
* @param inventory The inventory, from which the items will be removed
|
||||||
|
* @param itemStack Items to remove
|
||||||
|
* @return Whether all items were removed from the inventory
|
||||||
|
*/
|
||||||
private boolean removeFromInventory(Inventory inventory, ItemStack itemStack) {
|
private boolean removeFromInventory(Inventory inventory, ItemStack itemStack) {
|
||||||
HashMap<Integer, ItemStack> inventoryItems = new HashMap<>();
|
HashMap<Integer, ItemStack> inventoryItems = new HashMap<>();
|
||||||
int amount = itemStack.getAmount();
|
int amount = itemStack.getAmount();
|
||||||
|
@ -22,7 +22,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Shop {
|
public class Shop {
|
||||||
@ -65,6 +64,9 @@ public class Shop {
|
|||||||
if (item == null || item.isDead()) createItem();
|
if (item == null || item.isDead()) createItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the hologram of the shop if it doesn't exist
|
||||||
|
*/
|
||||||
public void removeHologram() {
|
public void removeHologram() {
|
||||||
if (hologram != null && hologram.exists()) {
|
if (hologram != null && hologram.exists()) {
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
@ -75,11 +77,18 @@ public class Shop {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the floating item of the shop
|
||||||
|
*/
|
||||||
public void removeItem() {
|
public void removeItem() {
|
||||||
if (item != null && !item.isDead())
|
if (item != null && !item.isDead())
|
||||||
item.remove();
|
item.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Creates the floating item of the shop</p>
|
||||||
|
* <b>Call this after {@link #createHologram()}, because it depends on the hologram's location</b>
|
||||||
|
*/
|
||||||
private void createItem() {
|
private void createItem() {
|
||||||
Item item;
|
Item item;
|
||||||
Location itemLocation;
|
Location itemLocation;
|
||||||
@ -101,6 +110,9 @@ public class Shop {
|
|||||||
this.item = item;
|
this.item = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the hologram of the shop
|
||||||
|
*/
|
||||||
private void createHologram() {
|
private void createHologram() {
|
||||||
boolean doubleChest;
|
boolean doubleChest;
|
||||||
|
|
||||||
@ -188,38 +200,65 @@ public class Shop {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The ID of the shop
|
||||||
|
*/
|
||||||
public int getID() {
|
public int getID() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Vendor of the shop; probably the creator of it
|
||||||
|
*/
|
||||||
public OfflinePlayer getVendor() {
|
public OfflinePlayer getVendor() {
|
||||||
return vendor;
|
return vendor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Product the shop sells (or buys)
|
||||||
|
*/
|
||||||
public ItemStack getProduct() {
|
public ItemStack getProduct() {
|
||||||
return product;
|
return product;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Location of (one of) the shop's chest
|
||||||
|
*/
|
||||||
public Location getLocation() {
|
public Location getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Buy price of the shop
|
||||||
|
*/
|
||||||
public double getBuyPrice() {
|
public double getBuyPrice() {
|
||||||
return buyPrice;
|
return buyPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Sell price of the shop
|
||||||
|
*/
|
||||||
public double getSellPrice() {
|
public double getSellPrice() {
|
||||||
return sellPrice;
|
return sellPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Type of the shop
|
||||||
|
*/
|
||||||
public ShopType getShopType() {
|
public ShopType getShopType() {
|
||||||
return shopType;
|
return shopType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Hologram of the shop
|
||||||
|
*/
|
||||||
public Hologram getHologram() {
|
public Hologram getHologram() {
|
||||||
return hologram;
|
return hologram;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Chest of the shop. If double chest, only one chest is returned
|
||||||
|
*/
|
||||||
public Chest getChest() {
|
public Chest getChest() {
|
||||||
return chest;
|
return chest;
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,15 @@ public abstract class Database {
|
|||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Connection to the database
|
||||||
|
*/
|
||||||
public abstract Connection getConnection();
|
public abstract Connection getConnection();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the database. <br>
|
||||||
|
* Creates the table (if doesn't exist) and tests the connection
|
||||||
|
*/
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
connection = getConnection();
|
connection = getConnection();
|
||||||
|
|
||||||
@ -57,6 +64,9 @@ public abstract class Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Lowest possible ID which is not used (> 0)
|
||||||
|
*/
|
||||||
public int getNextFreeID() {
|
public int getNextFreeID() {
|
||||||
for (int i = 1; i < getHighestID() + 1; i++) {
|
for (int i = 1; i < getHighestID() + 1; i++) {
|
||||||
if (get(i, ShopInfo.X) == null) {
|
if (get(i, ShopInfo.X) == null) {
|
||||||
@ -71,6 +81,9 @@ public abstract class Database {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Highest ID which is used
|
||||||
|
*/
|
||||||
public int getHighestID() {
|
public int getHighestID() {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
@ -98,6 +111,11 @@ public abstract class Database {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a shop from the database
|
||||||
|
*
|
||||||
|
* @param shop Shop to remove
|
||||||
|
*/
|
||||||
public void removeShop(Shop shop) {
|
public void removeShop(Shop shop) {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
|
|
||||||
@ -112,6 +130,11 @@ public abstract class Database {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param id ID of the shop
|
||||||
|
* @param shopInfo What to get
|
||||||
|
* @return Value you wanted to get. This needs to be casted to the right type!
|
||||||
|
*/
|
||||||
public Object get(int id, ShopInfo shopInfo) {
|
public Object get(int id, ShopInfo shopInfo) {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
@ -186,6 +209,10 @@ public abstract class Database {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a shop to the database
|
||||||
|
* @param shop Shop to add
|
||||||
|
*/
|
||||||
public void addShop(Shop shop) {
|
public void addShop(Shop shop) {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
|
|
||||||
@ -211,6 +238,11 @@ public abstract class Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes a {@link PreparedStatement} and a {@link ResultSet}
|
||||||
|
* @param ps {@link PreparedStatement} to close
|
||||||
|
* @param rs {@link ResultSet} to close
|
||||||
|
*/
|
||||||
private void close(PreparedStatement ps, ResultSet rs) {
|
private void close(PreparedStatement ps, ResultSet rs) {
|
||||||
try {
|
try {
|
||||||
if (ps != null)
|
if (ps != null)
|
||||||
@ -233,11 +265,11 @@ public abstract class Database {
|
|||||||
LOCATION,
|
LOCATION,
|
||||||
BUYPRICE,
|
BUYPRICE,
|
||||||
SELLPRICE,
|
SELLPRICE,
|
||||||
SHOPTYPE;
|
SHOPTYPE
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum DatabaseType {
|
public enum DatabaseType {
|
||||||
SQLite,
|
SQLite,
|
||||||
MySQL;
|
MySQL
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -27,6 +27,12 @@ public class ClickType {
|
|||||||
this.shopType = shopType;
|
this.shopType = shopType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the click type of a player
|
||||||
|
*
|
||||||
|
* @param player Player whose click type should be gotten
|
||||||
|
* @return The Player's click type or <b>null</b> if he doesn't have one
|
||||||
|
*/
|
||||||
public static ClickType getPlayerClickType(OfflinePlayer player) {
|
public static ClickType getPlayerClickType(OfflinePlayer player) {
|
||||||
if (playerClickType.containsKey(player))
|
if (playerClickType.containsKey(player))
|
||||||
return playerClickType.get(player);
|
return playerClickType.get(player);
|
||||||
@ -34,36 +40,61 @@ public class ClickType {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the click type from a player
|
||||||
|
* @param player Player to remove the click type from
|
||||||
|
*/
|
||||||
public static void removePlayerClickType(OfflinePlayer player) {
|
public static void removePlayerClickType(OfflinePlayer player) {
|
||||||
playerClickType.remove(player);
|
playerClickType.remove(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addPlayerClickType(OfflinePlayer player, ClickType clickType) {
|
/**
|
||||||
|
* Sets the click type of a player
|
||||||
|
*
|
||||||
|
* @param player Player whose click type should be set
|
||||||
|
* @param clickType Click type to set
|
||||||
|
*/
|
||||||
|
public static void setPlayerClickType(OfflinePlayer player, ClickType clickType) {
|
||||||
playerClickType.put(player, clickType);
|
playerClickType.put(player, clickType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Type of the click type
|
||||||
|
*/
|
||||||
public EnumClickType getClickType() {
|
public EnumClickType getClickType() {
|
||||||
return enumClickType;
|
return enumClickType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return If {@link #getClickType()} returns {@link EnumClickType#CREATE}, this returns the item, the player has hold in his hands, else <b>null</b>.
|
||||||
|
*/
|
||||||
public ItemStack getProduct() {
|
public ItemStack getProduct() {
|
||||||
return product;
|
return product;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return If {@link #getClickType()} returns {@link EnumClickType#CREATE}, this returns the buy price, the player has entered, else <b>null</b>.
|
||||||
|
*/
|
||||||
public double getBuyPrice() {
|
public double getBuyPrice() {
|
||||||
return buyPrice;
|
return buyPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return If {@link #getClickType()} returns {@link EnumClickType#CREATE}, this returns the sell price, the player has entered, else <b>null</b>.
|
||||||
|
*/
|
||||||
public double getSellPrice() {
|
public double getSellPrice() {
|
||||||
return sellPrice;
|
return sellPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return If {@link #getClickType()} returns {@link EnumClickType#CREATE}, this returns the shop type, the player has entered, else <b>null</b>.
|
||||||
|
*/
|
||||||
public ShopType getShopType() {
|
public ShopType getShopType() {
|
||||||
return shopType;
|
return shopType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum EnumClickType {
|
public enum EnumClickType {
|
||||||
CREATE, REMOVE, INFO;
|
CREATE, REMOVE, INFO
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,10 @@ import de.epiceric.shopchest.ShopChest;
|
|||||||
import de.epiceric.shopchest.config.Config;
|
import de.epiceric.shopchest.config.Config;
|
||||||
import de.epiceric.shopchest.shop.Shop;
|
import de.epiceric.shopchest.shop.Shop;
|
||||||
import de.epiceric.shopchest.sql.Database;
|
import de.epiceric.shopchest.sql.Database;
|
||||||
import org.bukkit.*;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
import org.bukkit.block.DoubleChest;
|
import org.bukkit.block.DoubleChest;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -23,17 +25,32 @@ public class ShopUtils {
|
|||||||
private static HashMap<Location, Shop> shopLocation = new HashMap<>();
|
private static HashMap<Location, Shop> shopLocation = new HashMap<>();
|
||||||
private static ShopChest plugin = ShopChest.getInstance();
|
private static ShopChest plugin = ShopChest.getInstance();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the shop at a given location
|
||||||
|
*
|
||||||
|
* @param location Location of the shop
|
||||||
|
* @return Shop at the given location or <b>null</b> if no shop is found there
|
||||||
|
*/
|
||||||
public static Shop getShop(Location location) {
|
public static Shop getShop(Location location) {
|
||||||
Location newLocation = new Location(location.getWorld(), location.getX(), location.getY(), location.getZ());
|
Location newLocation = new Location(location.getWorld(), location.getX(), location.getY(), location.getZ());
|
||||||
|
|
||||||
return shopLocation.get(newLocation);
|
return shopLocation.get(newLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether there is a shop at a given location
|
||||||
|
* @param location Location to check
|
||||||
|
* @return Whether there is a shop at the given location
|
||||||
|
*/
|
||||||
public static boolean isShop(Location location) {
|
public static boolean isShop(Location location) {
|
||||||
Location newLocation = new Location(location.getWorld(), location.getX(), location.getY(), location.getZ());
|
Location newLocation = new Location(location.getWorld(), location.getX(), location.getY(), location.getZ());
|
||||||
return shopLocation.containsKey(newLocation);
|
return shopLocation.containsKey(newLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all Shops
|
||||||
|
* @return Array of all Shops
|
||||||
|
*/
|
||||||
public static Shop[] getShops() {
|
public static Shop[] getShops() {
|
||||||
ArrayList<Shop> shops = new ArrayList<>();
|
ArrayList<Shop> shops = new ArrayList<>();
|
||||||
|
|
||||||
@ -44,6 +61,11 @@ public class ShopUtils {
|
|||||||
return shops.toArray(new Shop[shops.size()]);
|
return shops.toArray(new Shop[shops.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a shop
|
||||||
|
* @param shop Shop to add
|
||||||
|
* @param addToDatabase Whether the shop should also be added to the database
|
||||||
|
*/
|
||||||
public static void addShop(Shop shop, boolean addToDatabase) {
|
public static void addShop(Shop shop, boolean addToDatabase) {
|
||||||
InventoryHolder ih = shop.getChest().getInventory().getHolder();
|
InventoryHolder ih = shop.getChest().getInventory().getHolder();
|
||||||
|
|
||||||
@ -63,6 +85,11 @@ public class ShopUtils {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a shop
|
||||||
|
* @param shop Shop to remove
|
||||||
|
* @param removeFromDatabase Whether the shop should also be removed from the database
|
||||||
|
*/
|
||||||
public static void removeShop(Shop shop, boolean removeFromDatabase) {
|
public static void removeShop(Shop shop, boolean removeFromDatabase) {
|
||||||
InventoryHolder ih = shop.getChest().getInventory().getHolder();
|
InventoryHolder ih = shop.getChest().getInventory().getHolder();
|
||||||
|
|
||||||
@ -84,6 +111,11 @@ public class ShopUtils {
|
|||||||
plugin.getShopDatabase().removeShop(shop);
|
plugin.getShopDatabase().removeShop(shop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the shop limits of a player
|
||||||
|
* @param p Player, whose shop limits should be returned
|
||||||
|
* @return The shop limits of the given player
|
||||||
|
*/
|
||||||
public static int getShopLimit(Player p) {
|
public static int getShopLimit(Player p) {
|
||||||
int limit = Config.default_limit;
|
int limit = Config.default_limit;
|
||||||
|
|
||||||
@ -137,6 +169,11 @@ public class ShopUtils {
|
|||||||
return limit;
|
return limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the amount of shops of a player
|
||||||
|
* @param p Player, whose shops should be counted
|
||||||
|
* @return The amount of a shops a player has (if {@link Config#exclude_admin_shops} is true, admin shops won't be counted)
|
||||||
|
*/
|
||||||
public static int getShopAmount(OfflinePlayer p) {
|
public static int getShopAmount(OfflinePlayer p) {
|
||||||
float shopCount = 0;
|
float shopCount = 0;
|
||||||
|
|
||||||
@ -154,6 +191,10 @@ public class ShopUtils {
|
|||||||
return Math.round(shopCount);
|
return Math.round(shopCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reload the shops
|
||||||
|
* @return Amount of shops, which were reloaded
|
||||||
|
*/
|
||||||
public static int reloadShops() {
|
public static int reloadShops() {
|
||||||
for (Shop shop : ShopUtils.getShops()) {
|
for (Shop shop : ShopUtils.getShops()) {
|
||||||
ShopUtils.removeShop(shop, false);
|
ShopUtils.removeShop(shop, false);
|
||||||
|
@ -10,15 +10,18 @@ import java.net.URLConnection;
|
|||||||
public class UpdateChecker {
|
public class UpdateChecker {
|
||||||
|
|
||||||
private ShopChest plugin;
|
private ShopChest plugin;
|
||||||
private String url;
|
|
||||||
private String version;
|
private String version;
|
||||||
private String link;
|
private String link;
|
||||||
|
|
||||||
public UpdateChecker(ShopChest plugin, String url) {
|
public UpdateChecker(ShopChest plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.url = url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if an update is needed
|
||||||
|
*
|
||||||
|
* @return {@link UpdateCheckerResult#TRUE} if an update is available, {@link UpdateCheckerResult#FALSE} of no update is needed and {@link UpdateCheckerResult#ERROR} if an error occurred
|
||||||
|
*/
|
||||||
public UpdateCheckerResult updateNeeded() {
|
public UpdateCheckerResult updateNeeded() {
|
||||||
try {
|
try {
|
||||||
URL url = new URL("http://textuploader.com/all1l/raw");
|
URL url = new URL("http://textuploader.com/all1l/raw");
|
||||||
@ -47,6 +50,10 @@ public class UpdateChecker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the broadcast message
|
||||||
|
* @return A String Array of the lines of the broadcast message or <b>null</b> when no message is available
|
||||||
|
*/
|
||||||
public String[] getBroadcast() {
|
public String[] getBroadcast() {
|
||||||
try {
|
try {
|
||||||
URL url = new URL("http://textuploader.com/5b51f/raw");
|
URL url = new URL("http://textuploader.com/5b51f/raw");
|
||||||
@ -74,10 +81,16 @@ public class UpdateChecker {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Latest Version or <b>null</b> if no update is available
|
||||||
|
*/
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Download Link of the latest version of <b>null</b> if no update is available
|
||||||
|
*/
|
||||||
public String getLink() {
|
public String getLink() {
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
@ -85,7 +98,7 @@ public class UpdateChecker {
|
|||||||
public enum UpdateCheckerResult {
|
public enum UpdateCheckerResult {
|
||||||
TRUE,
|
TRUE,
|
||||||
FALSE,
|
FALSE,
|
||||||
ERROR;
|
ERROR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,6 +11,13 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the amount of items in an inventory
|
||||||
|
*
|
||||||
|
* @param inventory The inventory, in which the items are counted
|
||||||
|
* @param itemStack The items to count
|
||||||
|
* @return Amount of given items in the given inventory
|
||||||
|
*/
|
||||||
public static int getAmount(Inventory inventory, ItemStack itemStack) {
|
public static int getAmount(Inventory inventory, ItemStack itemStack) {
|
||||||
int amount = 0;
|
int amount = 0;
|
||||||
|
|
||||||
@ -42,32 +49,47 @@ public class Utils {
|
|||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The current server version with revision number (e.g. 1_9_R2, 1_10_R1)
|
||||||
|
*/
|
||||||
public static String getServerVersion() {
|
public static String getServerVersion() {
|
||||||
String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
||||||
|
|
||||||
return packageName.substring(packageName.lastIndexOf('.') + 1);
|
return packageName.substring(packageName.lastIndexOf('.') + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The major version of the server (e.g. <i>9</i> for 1.9.2, <i>10</i> for 1.10)
|
||||||
|
*/
|
||||||
public static int getMajorVersion() {
|
public static int getMajorVersion() {
|
||||||
return Integer.valueOf(getServerVersion().split("_")[1]);
|
return Integer.valueOf(getServerVersion().split("_")[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a given String is a UUID
|
||||||
|
* @param string String to check
|
||||||
|
* @return Whether the string is a UUID
|
||||||
|
*/
|
||||||
public static boolean isUUID(String string) {
|
public static boolean isUUID(String string) {
|
||||||
return string.matches("[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[34][0-9a-fA-F]{3}-[89ab][0-9a-fA-F]{3}-[0-9a-fA-F]{12}");
|
return string.matches("[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[34][0-9a-fA-F]{3}-[89ab][0-9a-fA-F]{3}-[0-9a-fA-F]{12}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes an {@link ItemStack} in a Base64 String
|
||||||
|
* @param itemStack {@link ItemStack} to encode
|
||||||
|
* @return Base64 encoded String
|
||||||
|
*/
|
||||||
public static String encode(ItemStack itemStack) {
|
public static String encode(ItemStack itemStack) {
|
||||||
YamlConfiguration config = new YamlConfiguration();
|
YamlConfiguration config = new YamlConfiguration();
|
||||||
config.set("i", itemStack);
|
config.set("i", itemStack);
|
||||||
return new String(Base64.encodeBase64(config.saveToString().getBytes()));
|
return new String(Base64.encodeBase64(config.saveToString().getBytes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toString(ItemStack itemStack) {
|
/**
|
||||||
YamlConfiguration config = new YamlConfiguration();
|
* Decodes an {@link ItemStack} from a Base64 String
|
||||||
config.set("i", itemStack);
|
* @param string Base64 encoded String to decode
|
||||||
return config.saveToString();
|
* @return Decoded {@link ItemStack}
|
||||||
}
|
*/
|
||||||
|
|
||||||
public static ItemStack decode(String string) {
|
public static ItemStack decode(String string) {
|
||||||
YamlConfiguration config = new YamlConfiguration();
|
YamlConfiguration config = new YamlConfiguration();
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user