Renamed config variables

This commit is contained in:
Eric 2018-02-24 20:12:32 +01:00
parent 47b23f126e
commit 5bfb0a1a22
27 changed files with 816 additions and 798 deletions

View File

@ -20,7 +20,7 @@
<project.build.outputEncoding>${projectEncoding}</project.build.outputEncoding> <project.build.outputEncoding>${projectEncoding}</project.build.outputEncoding>
<!-- JDK Version --> <!-- JDK Version -->
<jdkVersion>1.7</jdkVersion> <jdkVersion>1.8</jdkVersion>
<maven.compiler.source>${jdkVersion}</maven.compiler.source> <maven.compiler.source>${jdkVersion}</maven.compiler.source>
<maven.compiler.target>${jdkVersion}</maven.compiler.target> <maven.compiler.target>${jdkVersion}</maven.compiler.target>

View File

@ -11,7 +11,8 @@ import de.epiceric.shopchest.event.ShopInitializedEvent;
import de.epiceric.shopchest.external.PlotSquaredShopFlag; import de.epiceric.shopchest.external.PlotSquaredShopFlag;
import de.epiceric.shopchest.external.WorldGuardShopFlag; import de.epiceric.shopchest.external.WorldGuardShopFlag;
import de.epiceric.shopchest.language.LanguageUtils; import de.epiceric.shopchest.language.LanguageUtils;
import de.epiceric.shopchest.language.LocalizedMessage; import de.epiceric.shopchest.language.Message;
import de.epiceric.shopchest.language.Replacement;
import de.epiceric.shopchest.listeners.AreaShopListener; import de.epiceric.shopchest.listeners.AreaShopListener;
import de.epiceric.shopchest.listeners.BlockExplodeListener; import de.epiceric.shopchest.listeners.BlockExplodeListener;
import de.epiceric.shopchest.listeners.ChestProtectListener; import de.epiceric.shopchest.listeners.ChestProtectListener;
@ -39,7 +40,6 @@ import me.wiefferink.areashop.AreaShop;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import org.bstats.Metrics; import org.bstats.Metrics;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
@ -106,7 +106,7 @@ public class ShopChest extends JavaPlugin {
config = new Config(this); config = new Config(this);
if (config.enable_debug_log) { if (Config.enableDebugLog) {
File debugLogFile = new File(getDataFolder(), "debug.txt"); File debugLogFile = new File(getDataFolder(), "debug.txt");
try { try {
@ -128,7 +128,7 @@ public class ShopChest extends JavaPlugin {
Plugin worldGuardPlugin = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard"); Plugin worldGuardPlugin = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
if (worldGuardPlugin instanceof WorldGuardPlugin) { if (worldGuardPlugin instanceof WorldGuardPlugin) {
worldGuard = (WorldGuardPlugin) worldGuardPlugin; worldGuard = (WorldGuardPlugin) worldGuardPlugin;
WorldGuardShopFlag.register(this, true); WorldGuardShopFlag.register(this);
} }
} }
@ -216,7 +216,7 @@ public class ShopChest extends JavaPlugin {
database.disconnect(); database.disconnect();
} }
if (fw != null && config.enable_debug_log) { if (fw != null && Config.enableDebugLog) {
try { try {
fw.close(); fw.close();
} catch (IOException e) { } catch (IOException e) {
@ -227,21 +227,6 @@ public class ShopChest extends JavaPlugin {
} }
private void loadExternalPlugins() { private void loadExternalPlugins() {
if (worldGuard != null && !WorldGuardShopFlag.isLoaded()) {
WorldGuardShopFlag.register(this, false);
try {
// Reload WorldGuard regions, so that custom flags are applied
for (World world : getServer().getWorlds()) {
worldGuard.getRegionManager(world).load();
}
} catch (Exception e) {
getLogger().severe("Failed to reload WorldGuard region manager. WorldGuard support will probably not work!");
debug("Failed to load WorldGuard region manager");
debug(e);
}
}
Plugin townyPlugin = Bukkit.getServer().getPluginManager().getPlugin("Towny"); Plugin townyPlugin = Bukkit.getServer().getPluginManager().getPlugin("Towny");
if (townyPlugin instanceof Towny) { if (townyPlugin instanceof Towny) {
towny = (Towny) townyPlugin; towny = (Towny) townyPlugin;
@ -307,11 +292,11 @@ public class ShopChest extends JavaPlugin {
metrics.addCustomChart(new Metrics.SimplePie("database_type") { metrics.addCustomChart(new Metrics.SimplePie("database_type") {
@Override @Override
public String getValue() { public String getValue() {
return config.database_type.toString(); return Config.databaseType.toString();
} }
}); });
if (config.database_type == Database.DatabaseType.SQLite) { if (Config.databaseType == Database.DatabaseType.SQLite) {
debug("Using database type: SQLite"); debug("Using database type: SQLite");
getLogger().info("Using SQLite"); getLogger().info("Using SQLite");
database = new SQLite(this); database = new SQLite(this);
@ -319,7 +304,7 @@ public class ShopChest extends JavaPlugin {
debug("Using database type: MySQL"); debug("Using database type: MySQL");
getLogger().info("Using MySQL"); getLogger().info("Using MySQL");
database = new MySQL(this); database = new MySQL(this);
if (config.database_mysql_ping_interval > 0) { if (Config.databaseMySqlPingInterval > 0) {
Bukkit.getScheduler().runTaskTimer(this, new Runnable() { Bukkit.getScheduler().runTaskTimer(this, new Runnable() {
@Override @Override
public void run() { public void run() {
@ -327,7 +312,7 @@ public class ShopChest extends JavaPlugin {
((MySQL) database).ping(); ((MySQL) database).ping();
} }
} }
}, config.database_mysql_ping_interval * 20L, config.database_mysql_ping_interval * 20L); }, Config.databaseMySqlPingInterval * 20L, Config.databaseMySqlPingInterval * 20L);
} }
} }
} }
@ -339,16 +324,16 @@ public class ShopChest extends JavaPlugin {
UpdateChecker uc = new UpdateChecker(ShopChest.this); UpdateChecker uc = new UpdateChecker(ShopChest.this);
UpdateCheckerResult result = uc.check(); UpdateCheckerResult result = uc.check();
Bukkit.getConsoleSender().sendMessage("[ShopChest] " + LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CHECKING)); Bukkit.getConsoleSender().sendMessage("[ShopChest] " + LanguageUtils.getMessage(Message.UPDATE_CHECKING));
if (result == UpdateCheckerResult.TRUE) { if (result == UpdateCheckerResult.TRUE) {
latestVersion = uc.getVersion(); latestVersion = uc.getVersion();
downloadLink = uc.getLink(); downloadLink = uc.getLink();
isUpdateNeeded = true; isUpdateNeeded = true;
Bukkit.getConsoleSender().sendMessage("[ShopChest] " + LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedPlaceholder(Placeholder.VERSION, latestVersion))); Bukkit.getConsoleSender().sendMessage("[ShopChest] " + LanguageUtils.getMessage(Message.UPDATE_AVAILABLE, new Replacement(Placeholder.VERSION, latestVersion)));
for (Player p : getServer().getOnlinePlayers()) { for (Player p : getServer().getOnlinePlayers()) {
if (p.hasPermission(Permissions.UPDATE_NOTIFICATION)) { if (p.hasPermission(Permissions.UPDATE_NOTIFICATION)) {
JsonBuilder jb = new JsonBuilder(ShopChest.this, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedPlaceholder(Placeholder.VERSION, latestVersion)), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), downloadLink); JsonBuilder jb = new JsonBuilder(ShopChest.this, LanguageUtils.getMessage(Message.UPDATE_AVAILABLE, new Replacement(Placeholder.VERSION, latestVersion)), LanguageUtils.getMessage(Message.UPDATE_CLICK_TO_DOWNLOAD), downloadLink);
jb.sendJson(p); jb.sendJson(p);
} }
} }
@ -357,12 +342,12 @@ public class ShopChest extends JavaPlugin {
latestVersion = ""; latestVersion = "";
downloadLink = ""; downloadLink = "";
isUpdateNeeded = false; isUpdateNeeded = false;
Bukkit.getConsoleSender().sendMessage("[ShopChest] " + LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_NO_UPDATE)); Bukkit.getConsoleSender().sendMessage("[ShopChest] " + LanguageUtils.getMessage(Message.UPDATE_NO_UPDATE));
} else { } else {
latestVersion = ""; latestVersion = "";
downloadLink = ""; downloadLink = "";
isUpdateNeeded = false; isUpdateNeeded = false;
Bukkit.getConsoleSender().sendMessage("[ShopChest] " + LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_ERROR)); Bukkit.getConsoleSender().sendMessage("[ShopChest] " + LanguageUtils.getMessage(Message.UPDATE_ERROR));
} }
} }
}.runTaskAsynchronously(this); }.runTaskAsynchronously(this);
@ -409,7 +394,7 @@ public class ShopChest extends JavaPlugin {
* @param message Message to print * @param message Message to print
*/ */
public void debug(String message) { public void debug(String message) {
if (config.enable_debug_log && fw != null) { if (Config.enableDebugLog && fw != null) {
try { try {
Calendar c = Calendar.getInstance(); Calendar c = Calendar.getInstance();
String timestamp = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(c.getTime()); String timestamp = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(c.getTime());
@ -427,7 +412,7 @@ public class ShopChest extends JavaPlugin {
* @param throwable {@link Throwable} whose stacktrace will be printed * @param throwable {@link Throwable} whose stacktrace will be printed
*/ */
public void debug(Throwable throwable) { public void debug(Throwable throwable) {
if (config.enable_debug_log && fw != null) { if (Config.enableDebugLog && fw != null) {
PrintWriter pw = new PrintWriter(fw); PrintWriter pw = new PrintWriter(fw);
throwable.printStackTrace(pw); throwable.printStackTrace(pw);
pw.flush(); pw.flush();

View File

@ -1,18 +1,15 @@
package de.epiceric.shopchest.command; package de.epiceric.shopchest.command;
import de.epiceric.shopchest.ShopChest; import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.config.Placeholder; import de.epiceric.shopchest.config.Placeholder;
import de.epiceric.shopchest.language.LanguageUtils; import de.epiceric.shopchest.language.LanguageUtils;
import de.epiceric.shopchest.language.LocalizedMessage; import de.epiceric.shopchest.language.Message;
import de.epiceric.shopchest.language.Replacement;
import de.epiceric.shopchest.utils.Permissions; import de.epiceric.shopchest.utils.Permissions;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.*;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandMap;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -41,14 +38,13 @@ public class ShopCommand {
} }
this.plugin = plugin; this.plugin = plugin;
this.name = plugin.getShopChestConfig().main_command_name; this.name = Config.mainCommandName;
this.pluginCommand = createPluginCommand(); this.pluginCommand = createPluginCommand();
ShopCommandExecutor executor = new ShopCommandExecutor(plugin); ShopCommandExecutor executor = new ShopCommandExecutor(plugin);
ShopTabCompleter tabCompleter = new ShopTabCompleter(plugin); ShopTabCompleter tabCompleter = new ShopTabCompleter(plugin);
final LocalizedMessage.ReplacedPlaceholder cmdPlaceholder = new LocalizedMessage.ReplacedPlaceholder( final Replacement cmdReplacement = new Replacement(Placeholder.COMMAND, name);
Placeholder.COMMAND, plugin.getShopChestConfig().main_command_name);
addSubCommand(new ShopSubCommand("create", true, executor, tabCompleter) { addSubCommand(new ShopSubCommand("create", true, executor, tabCompleter) {
@Override @Override
@ -65,9 +61,9 @@ public class ShopCommand {
} }
if (sender.hasPermission(Permissions.CREATE_ADMIN)) { if (sender.hasPermission(Permissions.CREATE_ADMIN)) {
return LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_CREATE_ADMIN, cmdPlaceholder); return LanguageUtils.getMessage(Message.COMMAND_DESC_CREATE_ADMIN, cmdReplacement);
} else if (receiveCreateMessage) { } else if (receiveCreateMessage) {
return LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_CREATE, cmdPlaceholder); return LanguageUtils.getMessage(Message.COMMAND_DESC_CREATE, cmdReplacement);
} }
return ""; return "";
@ -77,28 +73,28 @@ public class ShopCommand {
addSubCommand(new ShopSubCommand("remove", true, executor, tabCompleter) { addSubCommand(new ShopSubCommand("remove", true, executor, tabCompleter) {
@Override @Override
public String getHelpMessage(CommandSender sender) { public String getHelpMessage(CommandSender sender) {
return LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_REMOVE, cmdPlaceholder); return LanguageUtils.getMessage(Message.COMMAND_DESC_REMOVE, cmdReplacement);
} }
}); });
addSubCommand(new ShopSubCommand("info", true, executor, tabCompleter) { addSubCommand(new ShopSubCommand("info", true, executor, tabCompleter) {
@Override @Override
public String getHelpMessage(CommandSender sender) { public String getHelpMessage(CommandSender sender) {
return LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_INFO, cmdPlaceholder); return LanguageUtils.getMessage(Message.COMMAND_DESC_INFO, cmdReplacement);
} }
}); });
addSubCommand(new ShopSubCommand("limits", true, executor, tabCompleter) { addSubCommand(new ShopSubCommand("limits", true, executor, tabCompleter) {
@Override @Override
public String getHelpMessage(CommandSender sender) { public String getHelpMessage(CommandSender sender) {
return LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_LIMITS, cmdPlaceholder); return LanguageUtils.getMessage(Message.COMMAND_DESC_LIMITS, cmdReplacement);
} }
}); });
addSubCommand(new ShopSubCommand("open", true, executor, tabCompleter) { addSubCommand(new ShopSubCommand("open", true, executor, tabCompleter) {
@Override @Override
public String getHelpMessage(CommandSender sender) { public String getHelpMessage(CommandSender sender) {
return LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_OPEN, cmdPlaceholder); return LanguageUtils.getMessage(Message.COMMAND_DESC_OPEN, cmdReplacement);
} }
}); });
@ -106,7 +102,7 @@ public class ShopCommand {
@Override @Override
public String getHelpMessage(CommandSender sender) { public String getHelpMessage(CommandSender sender) {
if (sender.hasPermission(Permissions.REMOVE_OTHER)) { if (sender.hasPermission(Permissions.REMOVE_OTHER)) {
return LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_REMOVEALL, cmdPlaceholder); return LanguageUtils.getMessage(Message.COMMAND_DESC_REMOVEALL, cmdReplacement);
} else { } else {
return ""; return "";
} }
@ -117,7 +113,7 @@ public class ShopCommand {
@Override @Override
public String getHelpMessage(CommandSender sender) { public String getHelpMessage(CommandSender sender) {
if (sender.hasPermission(Permissions.RELOAD)) { if (sender.hasPermission(Permissions.RELOAD)) {
return LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_RELOAD, cmdPlaceholder); return LanguageUtils.getMessage(Message.COMMAND_DESC_RELOAD, cmdReplacement);
} else { } else {
return ""; return "";
} }
@ -128,7 +124,7 @@ public class ShopCommand {
@Override @Override
public String getHelpMessage(CommandSender sender) { public String getHelpMessage(CommandSender sender) {
if (sender.hasPermission(Permissions.UPDATE)) { if (sender.hasPermission(Permissions.UPDATE)) {
return LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_UPDATE, cmdPlaceholder); return LanguageUtils.getMessage(Message.COMMAND_DESC_UPDATE, cmdReplacement);
} else { } else {
return ""; return "";
} }
@ -139,7 +135,7 @@ public class ShopCommand {
@Override @Override
public String getHelpMessage(CommandSender sender) { public String getHelpMessage(CommandSender sender) {
if (sender.hasPermission(Permissions.CONFIG)) { if (sender.hasPermission(Permissions.CONFIG)) {
return LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_CONFIG, cmdPlaceholder); return LanguageUtils.getMessage(Message.COMMAND_DESC_CONFIG, cmdReplacement);
} else { } else {
return ""; return "";
} }
@ -208,14 +204,15 @@ public class ShopCommand {
/** /**
* Sends the basic help message * Sends the basic help message
*
* @param sender {@link CommandSender} who will receive the message * @param sender {@link CommandSender} who will receive the message
*/ */
private void sendBasicHelpMessage(CommandSender sender) { private void sendBasicHelpMessage(CommandSender sender) {
plugin.debug("Sending basic help message to " + sender.getName()); plugin.debug("Sending basic help message to " + sender.getName());
sender.sendMessage(" "); sender.sendMessage(" ");
String header = LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_HEADER, String header = LanguageUtils.getMessage(Message.COMMAND_DESC_HEADER,
new LocalizedMessage.ReplacedPlaceholder(Placeholder.COMMAND, plugin.getShopChestConfig().main_command_name)); new Replacement(Placeholder.COMMAND, Config.mainCommandName));
if (!header.trim().isEmpty()) sender.sendMessage(header); if (!header.trim().isEmpty()) sender.sendMessage(header);
@ -228,8 +225,8 @@ public class ShopCommand {
sender.sendMessage(msg); sender.sendMessage(msg);
} }
String footer = LanguageUtils.getMessage(LocalizedMessage.Message.COMMAND_DESC_FOOTER, String footer = LanguageUtils.getMessage(Message.COMMAND_DESC_FOOTER,
new LocalizedMessage.ReplacedPlaceholder(Placeholder.COMMAND, plugin.getShopChestConfig().main_command_name)); new Replacement(Placeholder.COMMAND,Config.mainCommandName));
if (!footer.trim().isEmpty()) sender.sendMessage(footer); if (!footer.trim().isEmpty()) sender.sendMessage(footer);
sender.sendMessage(" "); sender.sendMessage(" ");

View File

@ -1,6 +1,7 @@
package de.epiceric.shopchest.command; package de.epiceric.shopchest.command;
import de.epiceric.shopchest.ShopChest; import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.config.Placeholder; import de.epiceric.shopchest.config.Placeholder;
import de.epiceric.shopchest.event.ShopPreCreateEvent; import de.epiceric.shopchest.event.ShopPreCreateEvent;
import de.epiceric.shopchest.event.ShopPreInfoEvent; import de.epiceric.shopchest.event.ShopPreInfoEvent;
@ -9,7 +10,8 @@ import de.epiceric.shopchest.event.ShopPreRemoveEvent;
import de.epiceric.shopchest.event.ShopReloadEvent; import de.epiceric.shopchest.event.ShopReloadEvent;
import de.epiceric.shopchest.event.ShopRemoveAllEvent; import de.epiceric.shopchest.event.ShopRemoveAllEvent;
import de.epiceric.shopchest.language.LanguageUtils; import de.epiceric.shopchest.language.LanguageUtils;
import de.epiceric.shopchest.language.LocalizedMessage; import de.epiceric.shopchest.language.Message;
import de.epiceric.shopchest.language.Replacement;
import de.epiceric.shopchest.nms.JsonBuilder; import de.epiceric.shopchest.nms.JsonBuilder;
import de.epiceric.shopchest.shop.Shop; import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.utils.Callback; import de.epiceric.shopchest.utils.Callback;
@ -65,19 +67,19 @@ class ShopCommandExecutor implements CommandExecutor {
if (sender.hasPermission(Permissions.RELOAD)) { if (sender.hasPermission(Permissions.RELOAD)) {
reload(sender); reload(sender);
} else { } else {
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_RELOAD)); sender.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_RELOAD));
} }
} else if (subCommand.getName().equalsIgnoreCase("update")) { } else if (subCommand.getName().equalsIgnoreCase("update")) {
if (sender.hasPermission(Permissions.UPDATE)) { if (sender.hasPermission(Permissions.UPDATE)) {
checkUpdates(sender); checkUpdates(sender);
} else { } else {
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_UPDATE)); sender.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_UPDATE));
} }
} else if (subCommand.getName().equalsIgnoreCase("config")) { } else if (subCommand.getName().equalsIgnoreCase("config")) {
if (sender.hasPermission(Permissions.CONFIG)) { if (sender.hasPermission(Permissions.CONFIG)) {
return args.length >= 4 && changeConfig(sender, args); return args.length >= 4 && changeConfig(sender, args);
} else { } else {
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_CONFIG)); sender.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_CONFIG));
} }
} else if (subCommand.getName().equalsIgnoreCase("removeall")) { } else if (subCommand.getName().equalsIgnoreCase("removeall")) {
if (sender.hasPermission(Permissions.REMOVE_OTHER)) { if (sender.hasPermission(Permissions.REMOVE_OTHER)) {
@ -87,7 +89,7 @@ class ShopCommandExecutor implements CommandExecutor {
return false; return false;
} }
} else { } else {
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_REMOVE_OTHERS)); sender.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_REMOVE_OTHERS));
} }
} else { } else {
if (sender instanceof Player) { if (sender instanceof Player) {
@ -103,7 +105,7 @@ class ShopCommandExecutor implements CommandExecutor {
if (p.hasPermission(Permissions.CREATE_ADMIN)) { if (p.hasPermission(Permissions.CREATE_ADMIN)) {
create(args, Shop.ShopType.ADMIN, p); create(args, Shop.ShopType.ADMIN, p);
} else { } else {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_CREATE_ADMIN)); p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_CREATE_ADMIN));
} }
} else { } else {
return false; return false;
@ -118,9 +120,9 @@ class ShopCommandExecutor implements CommandExecutor {
} else if (subCommand.getName().equalsIgnoreCase("limits")) { } else if (subCommand.getName().equalsIgnoreCase("limits")) {
plugin.debug(p.getName() + " is viewing his shop limits: " + shopUtils.getShopAmount(p) + "/" + shopUtils.getShopLimit(p)); plugin.debug(p.getName() + " is viewing his shop limits: " + shopUtils.getShopAmount(p) + "/" + shopUtils.getShopLimit(p));
int limit = shopUtils.getShopLimit(p); int limit = shopUtils.getShopLimit(p);
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.OCCUPIED_SHOP_SLOTS, p.sendMessage(LanguageUtils.getMessage(Message.OCCUPIED_SHOP_SLOTS,
new LocalizedMessage.ReplacedPlaceholder(Placeholder.LIMIT, (limit < 0 ? "" : String.valueOf(limit))), new Replacement(Placeholder.LIMIT, (limit < 0 ? "" : String.valueOf(limit))),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(shopUtils.getShopAmount(p))))); new Replacement(Placeholder.AMOUNT, String.valueOf(shopUtils.getShopAmount(p)))));
} else if (subCommand.getName().equalsIgnoreCase("open")) { } else if (subCommand.getName().equalsIgnoreCase("open")) {
open(p); open(p);
} else { } else {
@ -142,7 +144,7 @@ class ShopCommandExecutor implements CommandExecutor {
private void checkUpdates(CommandSender sender) { private void checkUpdates(CommandSender sender) {
plugin.debug(sender.getName() + " is checking for updates"); plugin.debug(sender.getName() + " is checking for updates");
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CHECKING)); sender.sendMessage(LanguageUtils.getMessage(Message.UPDATE_CHECKING));
UpdateChecker uc = new UpdateChecker(ShopChest.getInstance()); UpdateChecker uc = new UpdateChecker(ShopChest.getInstance());
UpdateChecker.UpdateCheckerResult result = uc.check(); UpdateChecker.UpdateCheckerResult result = uc.check();
@ -153,22 +155,22 @@ class ShopCommandExecutor implements CommandExecutor {
plugin.setUpdateNeeded(true); plugin.setUpdateNeeded(true);
if (sender instanceof Player) { if (sender instanceof Player) {
JsonBuilder jb = new JsonBuilder(plugin, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedPlaceholder(Placeholder.VERSION, uc.getVersion())), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), uc.getLink()); JsonBuilder jb = new JsonBuilder(plugin, LanguageUtils.getMessage(Message.UPDATE_AVAILABLE, new Replacement(Placeholder.VERSION, uc.getVersion())), LanguageUtils.getMessage(Message.UPDATE_CLICK_TO_DOWNLOAD), uc.getLink());
jb.sendJson((Player) sender); jb.sendJson((Player) sender);
} else { } else {
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedPlaceholder(Placeholder.VERSION, uc.getVersion()))); sender.sendMessage(LanguageUtils.getMessage(Message.UPDATE_AVAILABLE, new Replacement(Placeholder.VERSION, uc.getVersion())));
} }
} else if (result == UpdateChecker.UpdateCheckerResult.FALSE) { } else if (result == UpdateChecker.UpdateCheckerResult.FALSE) {
plugin.setLatestVersion(""); plugin.setLatestVersion("");
plugin.setDownloadLink(""); plugin.setDownloadLink("");
plugin.setUpdateNeeded(false); plugin.setUpdateNeeded(false);
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_NO_UPDATE)); sender.sendMessage(LanguageUtils.getMessage(Message.UPDATE_NO_UPDATE));
} else { } else {
plugin.setLatestVersion(""); plugin.setLatestVersion("");
plugin.setDownloadLink(""); plugin.setDownloadLink("");
plugin.setUpdateNeeded(false); plugin.setUpdateNeeded(false);
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_ERROR)); sender.sendMessage(LanguageUtils.getMessage(Message.UPDATE_ERROR));
} }
} }
@ -189,8 +191,8 @@ class ShopCommandExecutor implements CommandExecutor {
shopUtils.reloadShops(true, true, new Callback<Integer>(plugin) { shopUtils.reloadShops(true, true, new Callback<Integer>(plugin) {
@Override @Override
public void onResult(Integer result) { public void onResult(Integer result) {
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.RELOADED_SHOPS, sender.sendMessage(LanguageUtils.getMessage(Message.RELOADED_SHOPS,
new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(result)))); new Replacement(Placeholder.AMOUNT, String.valueOf(result))));
plugin.debug(sender.getName() + " has reloaded " + result + " shops"); plugin.debug(sender.getName() + " has reloaded " + result + " shops");
} }
}); });
@ -214,13 +216,13 @@ class ShopCommandExecutor implements CommandExecutor {
buyPrice = Double.parseDouble(args[2]); buyPrice = Double.parseDouble(args[2]);
sellPrice = Double.parseDouble(args[3]); sellPrice = Double.parseDouble(args[3]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.AMOUNT_PRICE_NOT_NUMBER)); p.sendMessage(LanguageUtils.getMessage(Message.AMOUNT_PRICE_NOT_NUMBER));
plugin.debug(p.getName() + " has entered an invalid amount and/or prices"); plugin.debug(p.getName() + " has entered an invalid amount and/or prices");
return; return;
} }
if (!Utils.hasPermissionToCreateShop(p, Utils.getPreferredItemInHand(p), buyPrice > 0, sellPrice > 0)) { if (!Utils.hasPermissionToCreateShop(p, Utils.getPreferredItemInHand(p), buyPrice > 0, sellPrice > 0)) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_CREATE)); p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_CREATE));
plugin.debug(p.getName() + " is not permitted to create the shop"); plugin.debug(p.getName() + " is not permitted to create the shop");
return; return;
} }
@ -229,8 +231,8 @@ class ShopCommandExecutor implements CommandExecutor {
int limit = shopUtils.getShopLimit(p); int limit = shopUtils.getShopLimit(p);
if (limit != -1) { if (limit != -1) {
if (shopUtils.getShopAmount(p) >= limit) { if (shopUtils.getShopAmount(p) >= limit) {
if (shopType != Shop.ShopType.ADMIN || !plugin.getShopChestConfig().exclude_admin_shops) { if (shopType != Shop.ShopType.ADMIN || !Config.excludeAdminShops) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_LIMIT_REACHED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.LIMIT, String.valueOf(limit)))); p.sendMessage(LanguageUtils.getMessage(Message.SHOP_LIMIT_REACHED, new Replacement(Placeholder.LIMIT, String.valueOf(limit))));
plugin.debug(p.getName() + " has reached the limit"); plugin.debug(p.getName() + " has reached the limit");
return; return;
} }
@ -238,13 +240,13 @@ class ShopCommandExecutor implements CommandExecutor {
} }
if (amount <= 0) { if (amount <= 0) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.AMOUNT_IS_ZERO)); p.sendMessage(LanguageUtils.getMessage(Message.AMOUNT_IS_ZERO));
plugin.debug(p.getName() + " has entered an invalid amount"); plugin.debug(p.getName() + " has entered an invalid amount");
return; return;
} }
if (!plugin.getShopChestConfig().allow_decimals_in_price && (buyPrice != (int) buyPrice || sellPrice != (int) sellPrice)) { if (!Config.allowDecimalsInPrice && (buyPrice != (int) buyPrice || sellPrice != (int) sellPrice)) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.PRICES_CONTAIN_DECIMALS)); p.sendMessage(LanguageUtils.getMessage(Message.PRICES_CONTAIN_DECIMALS));
plugin.debug(p.getName() + " has entered an invalid price"); plugin.debug(p.getName() + " has entered an invalid price");
return; return;
} }
@ -253,7 +255,7 @@ class ShopCommandExecutor implements CommandExecutor {
boolean sellEnabled = sellPrice > 0; boolean sellEnabled = sellPrice > 0;
if (!buyEnabled && !sellEnabled) { if (!buyEnabled && !sellEnabled) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_SELL_DISABLED)); p.sendMessage(LanguageUtils.getMessage(Message.BUY_SELL_DISABLED));
plugin.debug(p.getName() + " has disabled buying and selling"); plugin.debug(p.getName() + " has disabled buying and selling");
return; return;
} }
@ -262,13 +264,13 @@ class ShopCommandExecutor implements CommandExecutor {
// Check if item in hand // Check if item in hand
if (inHand == null) { if (inHand == null) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_ITEM_IN_HAND)); p.sendMessage(LanguageUtils.getMessage(Message.NO_ITEM_IN_HAND));
plugin.debug(p.getName() + " does not have an item in his hand"); plugin.debug(p.getName() + " does not have an item in his hand");
return; return;
} }
// Check if item on blacklist // Check if item on blacklist
for (String item : plugin.getShopChestConfig().blacklist) { for (String item :Config.blacklist) {
ItemStack itemStack = ItemUtils.getItemStack(item); ItemStack itemStack = ItemUtils.getItemStack(item);
if (itemStack == null) { if (itemStack == null) {
@ -278,14 +280,14 @@ class ShopCommandExecutor implements CommandExecutor {
} }
if (itemStack.getType().equals(inHand.getType()) && itemStack.getDurability() == inHand.getDurability()) { if (itemStack.getType().equals(inHand.getType()) && itemStack.getDurability() == inHand.getDurability()) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CANNOT_SELL_ITEM)); p.sendMessage(LanguageUtils.getMessage(Message.CANNOT_SELL_ITEM));
plugin.debug(p.getName() + "'s item is on the blacklist"); plugin.debug(p.getName() + "'s item is on the blacklist");
return; return;
} }
} }
// Check if prices lower than minimum price // Check if prices lower than minimum price
for (String key : plugin.getShopChestConfig().minimum_prices) { for (String key :Config.minimumPrices) {
ItemStack itemStack = ItemUtils.getItemStack(key); ItemStack itemStack = ItemUtils.getItemStack(key);
double minPrice = plugin.getConfig().getDouble("minimum-prices." + key); double minPrice = plugin.getConfig().getDouble("minimum-prices." + key);
@ -298,7 +300,7 @@ class ShopCommandExecutor implements CommandExecutor {
if (itemStack.getType().equals(inHand.getType()) && itemStack.getDurability() == inHand.getDurability()) { if (itemStack.getType().equals(inHand.getType()) && itemStack.getDurability() == inHand.getDurability()) {
if (buyEnabled) { if (buyEnabled) {
if ((buyPrice < amount * minPrice) && (buyPrice > 0)) { if ((buyPrice < amount * minPrice) && (buyPrice > 0)) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_PRICE_TOO_LOW, new LocalizedMessage.ReplacedPlaceholder(Placeholder.MIN_PRICE, String.valueOf(amount * minPrice)))); p.sendMessage(LanguageUtils.getMessage(Message.BUY_PRICE_TOO_LOW, new Replacement(Placeholder.MIN_PRICE, String.valueOf(amount * minPrice))));
plugin.debug(p.getName() + "'s buy price is lower than the minimum"); plugin.debug(p.getName() + "'s buy price is lower than the minimum");
return; return;
} }
@ -306,7 +308,7 @@ class ShopCommandExecutor implements CommandExecutor {
if (sellEnabled) { if (sellEnabled) {
if ((sellPrice < amount * minPrice) && (sellPrice > 0)) { if ((sellPrice < amount * minPrice) && (sellPrice > 0)) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SELL_PRICE_TOO_LOW, new LocalizedMessage.ReplacedPlaceholder(Placeholder.MIN_PRICE, String.valueOf(amount * minPrice)))); p.sendMessage(LanguageUtils.getMessage(Message.SELL_PRICE_TOO_LOW, new Replacement(Placeholder.MIN_PRICE, String.valueOf(amount * minPrice))));
plugin.debug(p.getName() + "'s sell price is lower than the minimum"); plugin.debug(p.getName() + "'s sell price is lower than the minimum");
return; return;
} }
@ -315,7 +317,7 @@ class ShopCommandExecutor implements CommandExecutor {
} }
// Check if prices higher than maximum price // Check if prices higher than maximum price
for (String key : plugin.getShopChestConfig().maximum_prices) { for (String key :Config.maximumPrices) {
ItemStack itemStack = ItemUtils.getItemStack(key); ItemStack itemStack = ItemUtils.getItemStack(key);
double maxPrice = plugin.getConfig().getDouble("maximum-prices." + key); double maxPrice = plugin.getConfig().getDouble("maximum-prices." + key);
@ -328,7 +330,7 @@ class ShopCommandExecutor implements CommandExecutor {
if (itemStack.getType().equals(inHand.getType()) && itemStack.getDurability() == inHand.getDurability()) { if (itemStack.getType().equals(inHand.getType()) && itemStack.getDurability() == inHand.getDurability()) {
if (buyEnabled) { if (buyEnabled) {
if ((buyPrice > amount * maxPrice) && (buyPrice > 0)) { if ((buyPrice > amount * maxPrice) && (buyPrice > 0)) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_PRICE_TOO_HIGH, new LocalizedMessage.ReplacedPlaceholder(Placeholder.MAX_PRICE, String.valueOf(amount * maxPrice)))); p.sendMessage(LanguageUtils.getMessage(Message.BUY_PRICE_TOO_HIGH, new Replacement(Placeholder.MAX_PRICE, String.valueOf(amount * maxPrice))));
plugin.debug(p.getName() + "'s buy price is higher than the maximum"); plugin.debug(p.getName() + "'s buy price is higher than the maximum");
return; return;
} }
@ -336,7 +338,7 @@ class ShopCommandExecutor implements CommandExecutor {
if (sellEnabled) { if (sellEnabled) {
if ((sellPrice > amount * maxPrice) && (sellPrice > 0)) { if ((sellPrice > amount * maxPrice) && (sellPrice > 0)) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SELL_PRICE_TOO_HIGH, new LocalizedMessage.ReplacedPlaceholder(Placeholder.MAX_PRICE, String.valueOf(amount * maxPrice)))); p.sendMessage(LanguageUtils.getMessage(Message.SELL_PRICE_TOO_HIGH, new Replacement(Placeholder.MAX_PRICE, String.valueOf(amount * maxPrice))));
plugin.debug(p.getName() + "'s sell price is higher than the maximum"); plugin.debug(p.getName() + "'s sell price is higher than the maximum");
return; return;
} }
@ -346,9 +348,9 @@ class ShopCommandExecutor implements CommandExecutor {
if (sellEnabled && buyEnabled) { if (sellEnabled && buyEnabled) {
if (plugin.getShopChestConfig().buy_greater_or_equal_sell) { if (Config.buyGreaterOrEqualSell) {
if (buyPrice < sellPrice) { if (buyPrice < sellPrice) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_PRICE_TOO_LOW, new LocalizedMessage.ReplacedPlaceholder(Placeholder.MIN_PRICE, String.valueOf(sellPrice)))); p.sendMessage(LanguageUtils.getMessage(Message.BUY_PRICE_TOO_LOW, new Replacement(Placeholder.MIN_PRICE, String.valueOf(sellPrice))));
plugin.debug(p.getName() + "'s buy price is lower than the sell price"); plugin.debug(p.getName() + "'s buy price is lower than the sell price");
return; return;
} }
@ -359,17 +361,17 @@ class ShopCommandExecutor implements CommandExecutor {
product.setItemMeta(inHand.getItemMeta()); product.setItemMeta(inHand.getItemMeta());
if (Enchantment.DURABILITY.canEnchantItem(product)) { if (Enchantment.DURABILITY.canEnchantItem(product)) {
if (product.getDurability() > 0 && !plugin.getShopChestConfig().allow_broken_items) { if (product.getDurability() > 0 && !Config.allowBrokenItems) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CANNOT_SELL_BROKEN_ITEM)); p.sendMessage(LanguageUtils.getMessage(Message.CANNOT_SELL_BROKEN_ITEM));
plugin.debug(p.getName() + "'s item is broken"); plugin.debug(p.getName() + "'s item is broken");
return; return;
} }
} }
double creationPrice = (shopType == Shop.ShopType.NORMAL) ? plugin.getShopChestConfig().shop_creation_price_normal : plugin.getShopChestConfig().shop_creation_price_admin; double creationPrice = (shopType == Shop.ShopType.NORMAL) ?Config.shopCreationPriceNormal :Config.shopCreationPriceAdmin;
if (creationPrice > 0) { if (creationPrice > 0) {
if (plugin.getEconomy().getBalance(p, p.getWorld().getName()) < creationPrice) { if (plugin.getEconomy().getBalance(p, p.getWorld().getName()) < creationPrice) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_CREATE_NOT_ENOUGH_MONEY, new LocalizedMessage.ReplacedPlaceholder(Placeholder.CREATION_PRICE, String.valueOf(creationPrice)))); p.sendMessage(LanguageUtils.getMessage(Message.SHOP_CREATE_NOT_ENOUGH_MONEY, new Replacement(Placeholder.CREATION_PRICE, String.valueOf(creationPrice))));
plugin.debug(p.getName() + " can not pay the creation price"); plugin.debug(p.getName() + " can not pay the creation price");
return; return;
} }
@ -381,7 +383,7 @@ class ShopCommandExecutor implements CommandExecutor {
if (!event.isCancelled()) { if (!event.isCancelled()) {
ClickType.setPlayerClickType(p, new ClickType(ClickType.EnumClickType.CREATE, product, buyPrice, sellPrice, shopType)); ClickType.setPlayerClickType(p, new ClickType(ClickType.EnumClickType.CREATE, product, buyPrice, sellPrice, shopType));
plugin.debug(p.getName() + " can now click a chest"); plugin.debug(p.getName() + " can now click a chest");
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CLICK_CHEST_CREATE)); p.sendMessage(LanguageUtils.getMessage(Message.CLICK_CHEST_CREATE));
// Remove ClickType after 15 seconds if player has not clicked a chest // Remove ClickType after 15 seconds if player has not clicked a chest
new BukkitRunnable() { new BukkitRunnable() {
@ -410,7 +412,7 @@ class ShopCommandExecutor implements CommandExecutor {
} }
plugin.debug(p.getName() + " can now click a chest"); plugin.debug(p.getName() + " can now click a chest");
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CLICK_CHEST_REMOVE)); p.sendMessage(LanguageUtils.getMessage(Message.CLICK_CHEST_REMOVE));
ClickType.setPlayerClickType(p, new ClickType(ClickType.EnumClickType.REMOVE)); ClickType.setPlayerClickType(p, new ClickType(ClickType.EnumClickType.REMOVE));
// Remove ClickType after 15 seconds if player has not clicked a chest // Remove ClickType after 15 seconds if player has not clicked a chest
@ -437,7 +439,7 @@ class ShopCommandExecutor implements CommandExecutor {
} }
plugin.debug(p.getName() + " can now click a chest"); plugin.debug(p.getName() + " can now click a chest");
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CLICK_CHEST_INFO)); p.sendMessage(LanguageUtils.getMessage(Message.CLICK_CHEST_INFO));
ClickType.setPlayerClickType(p, new ClickType(ClickType.EnumClickType.INFO)); ClickType.setPlayerClickType(p, new ClickType(ClickType.EnumClickType.INFO));
// Remove ClickType after 15 seconds if player has not clicked a chest // Remove ClickType after 15 seconds if player has not clicked a chest
@ -464,7 +466,7 @@ class ShopCommandExecutor implements CommandExecutor {
} }
plugin.debug(p.getName() + " can now click a chest"); plugin.debug(p.getName() + " can now click a chest");
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CLICK_CHEST_OPEN)); p.sendMessage(LanguageUtils.getMessage(Message.CLICK_CHEST_OPEN));
ClickType.setPlayerClickType(p, new ClickType(ClickType.EnumClickType.OPEN)); ClickType.setPlayerClickType(p, new ClickType(ClickType.EnumClickType.OPEN));
// Remove ClickType after 15 seconds if player has not clicked a chest // Remove ClickType after 15 seconds if player has not clicked a chest
@ -484,13 +486,13 @@ class ShopCommandExecutor implements CommandExecutor {
if (args[1].equalsIgnoreCase("set")) { if (args[1].equalsIgnoreCase("set")) {
plugin.getShopChestConfig().set(property, value); plugin.getShopChestConfig().set(property, value);
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CHANGED_CONFIG_SET, new LocalizedMessage.ReplacedPlaceholder(Placeholder.PROPERTY, property), new LocalizedMessage.ReplacedPlaceholder(Placeholder.VALUE, value))); sender.sendMessage(LanguageUtils.getMessage(Message.CHANGED_CONFIG_SET, new Replacement(Placeholder.PROPERTY, property), new Replacement(Placeholder.VALUE, value)));
} else if (args[1].equalsIgnoreCase("add")) { } else if (args[1].equalsIgnoreCase("add")) {
plugin.getShopChestConfig().add(property, value); plugin.getShopChestConfig().add(property, value);
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CHANGED_CONFIG_ADDED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.PROPERTY, property), new LocalizedMessage.ReplacedPlaceholder(Placeholder.VALUE, value))); sender.sendMessage(LanguageUtils.getMessage(Message.CHANGED_CONFIG_ADDED, new Replacement(Placeholder.PROPERTY, property), new Replacement(Placeholder.VALUE, value)));
} else if (args[1].equalsIgnoreCase("remove")) { } else if (args[1].equalsIgnoreCase("remove")) {
plugin.getShopChestConfig().remove(property, value); plugin.getShopChestConfig().remove(property, value);
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CHANGED_CONFIG_REMOVED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.PROPERTY, property), new LocalizedMessage.ReplacedPlaceholder(Placeholder.VALUE, value))); sender.sendMessage(LanguageUtils.getMessage(Message.CHANGED_CONFIG_REMOVED, new Replacement(Placeholder.PROPERTY, property), new Replacement(Placeholder.VALUE, value)));
} else { } else {
return false; return false;
} }
@ -522,8 +524,8 @@ class ShopCommandExecutor implements CommandExecutor {
shopUtils.removeShop(shop, true); shopUtils.removeShop(shop, true);
} }
sender.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ALL_SHOPS_REMOVED, sender.sendMessage(LanguageUtils.getMessage(Message.ALL_SHOPS_REMOVED,
new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(shops.size())), new Replacement(Placeholder.AMOUNT, String.valueOf(shops.size())),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.VENDOR, vendor.getName()))); new Replacement(Placeholder.VENDOR, vendor.getName())));
} }
} }

View File

@ -1,6 +1,7 @@
package de.epiceric.shopchest.command; package de.epiceric.shopchest.command;
import de.epiceric.shopchest.ShopChest; import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter; import org.bukkit.command.TabCompleter;
@ -20,7 +21,7 @@ class ShopTabCompleter implements TabCompleter {
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equalsIgnoreCase(plugin.getShopChestConfig().main_command_name)) { if (command.getName().equalsIgnoreCase(Config.mainCommandName)) {
List<String> createSubCommands = Arrays.asList("admin", "normal"); List<String> createSubCommands = Arrays.asList("admin", "normal");
List<String> configSubCommands = Arrays.asList("add", "remove", "set"); List<String> configSubCommands = Arrays.asList("add", "remove", "set");

View File

@ -20,198 +20,301 @@ import java.util.Set;
public class Config { public class Config {
private ShopChest plugin; /**
* The quality of hologram and item updating (performance saving, or better quality)
**/
public static ShopUpdater.UpdateQuality updateQuality;
private LanguageConfiguration langConfig; /**
* The item with which a player can click a shop to retrieve information
**/
public static ItemStack shopInfoItem;
/** The quality of hologram and item updating (performance saving, or better quality) **/ /**
public ShopUpdater.UpdateQuality update_quality; * The default value for the custom WorldGuard flag 'create-shop'
**/
public static boolean wgAllowCreateShopDefault;
/** The item with which a player can click a shop to retrieve information **/ /**
public ItemStack shop_info_item; * The default value for the custom WorldGuard flag 'use-admin-shop'
**/
public static boolean wgAllowUseAdminShopDefault;
/** The default value for the custom WorldGuard flag 'create-shop' **/ /**
public boolean wg_allow_create_shop_default; * The default value for the custom WorldGuard flag 'use-shop'
**/
public static boolean wgAllowUseShopDefault;
/** The default value for the custom WorldGuard flag 'use-admin-shop' **/ /**
public boolean wg_allow_use_admin_shop_default; * The types of town plots residents are allowed to create shops in
**/
public static List<String> townyShopPlotsResidents;
/** The default value for the custom WorldGuard flag 'use-shop' **/ /**
public boolean wg_allow_use_shop_default; * The types of town plots the mayor is allowed to create shops in
**/
public static List<String> townyShopPlotsMayor;
/** The types of town plots residents are allowed to create shops in **/ /**
public List<String> towny_shop_plots_residents; * The types of town plots the king is allowed to create shops in
**/
public static List<String> townyShopPlotsKing;
/** The types of town plots the mayor is allowed to create shops in **/ /**
public List<String> towny_shop_plots_mayor; * The events of AreaShop when shops in that region should be removed
**/
public static List<String> areashopRemoveShopEvents;
/** The types of town plots the king is allowed to create shops in **/ /**
public List<String> towny_shop_plots_king; * The hostname used in ShopChest's MySQL database
**/
public static String databaseMySqlHost;
/** The events of AreaShop when shops in that region should be removed **/ /**
public List<String> areashop_remove_shop_events; * The port used for ShopChest's MySQL database
**/
public static int databaseMySqlPort;
/** The hostname used in ShopChest's MySQL database **/ /**
public String database_mysql_host; * The database used for ShopChest's MySQL database
**/
public static String databaseMySqlDatabase;
/** The port used for ShopChest's MySQL database **/ /**
public int database_mysql_port; * The username used in ShopChest's MySQL database
**/
public static String databaseMySqlUsername;
/** The database used for ShopChest's MySQL database **/ /**
public String database_mysql_database; * The password used in ShopChest's MySQL database
**/
public static String databaseMySqlPassword;
/** The username used in ShopChest's MySQL database **/ /**
public String database_mysql_username; * The database type used for ShopChest.
**/
public static Database.DatabaseType databaseType;
/** The password used in ShopChest's MySQL database **/ /**
public String database_mysql_password; * The interval in seconds, a ping is sent to the MySQL server
**/
/** The database type used for ShopChest. **/ public static int databaseMySqlPingInterval;
public Database.DatabaseType database_type;
/** The interval in seconds, a ping is sent to the MySQL server **/
public int database_mysql_ping_interval;
/** /**
* <p>The minimum prices for certain items</p> * <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. * 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 minimum price for an item, you have to get the double {@code minimum-prices.<key>}. * To actually retrieve the minimum price for an item, you have to get the double {@code minimum-prices.<key>}.
**/ **/
public Set<String> minimum_prices; public static Set<String> minimumPrices;
/** /**
* <p>The maximum prices for certain items</p> * <p>The maximum prices for certain items</p>
* This returns a key set, which contains e.g "STONE", "STONE:1", of the {@code maximum-prices} section in ShopChest's config. * This returns a key set, which contains e.g "STONE", "STONE:1", of the {@code maximum-prices} section in ShopChest's config.
* To actually retrieve the maximum price for an item, you have to get the double {@code maximum-prices.<key>}. * To actually retrieve the maximum price for an item, you have to get the double {@code maximum-prices.<key>}.
**/ **/
public Set<String> maximum_prices; public static Set<String> maximumPrices;
/** /**
* <p>List containing items, of which players can't create a shop</p> * <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. * If this list contains an item (e.g "STONE", "STONE:1"), it's in the blacklist.
**/ **/
public List<String> blacklist; public static List<String> blacklist;
/** Whether prices may contain decimals **/ /**
public boolean allow_decimals_in_price; * Whether prices may contain decimals
**/
public static boolean allowDecimalsInPrice;
/** Whether the buy price of a shop must be greater than or equal the sell price **/ /**
public boolean buy_greater_or_equal_sell; * Whether the buy price of a shop must be greater than or equal the sell price
**/
public static boolean buyGreaterOrEqualSell;
/** Whether shops should be protected by hoppers **/ /**
public boolean hopper_protection; * Whether shops should be protected by hoppers
**/
public static boolean hopperProtection;
/** Whether shops should be protected by explosions **/ /**
public boolean explosion_protection; * Whether shops should be protected by explosions
**/
public static boolean explosionProtection;
/** Whether buys and sells must be confirmed **/ /**
public boolean confirm_shopping; * Whether buys and sells must be confirmed
**/
public static boolean confirmShopping;
/** Whether quality mode should be enabled **/ /**
public boolean enable_quality_mode; * Whether quality mode should be enabled
**/
public static boolean enableQualityMode;
/** Whether hologram interaction should be enabled **/ /**
public boolean enable_hologram_interaction; * Whether hologram interaction should be enabled
**/
public static boolean enableHologramInteraction;
/** Whether the debug log file should be created **/ /**
public boolean enable_debug_log; * Whether the debug log file should be created
**/
public static boolean enableDebugLog;
/** Whether buys and sells should be logged in the database **/ /**
public boolean enable_ecomomy_log; * Whether buys and sells should be logged in the database
**/
public static boolean enableEcomomyLog;
/** Whether WorldGuard integration should be enabled **/ /**
public boolean enable_worldguard_integration; * Whether WorldGuard integration should be enabled
**/
public static boolean enableWorldGuardIntegration;
/** Whether Towny integration should be enabled **/ /**
public boolean enable_towny_integration; * Whether Towny integration should be enabled
**/
public static boolean enableTownyIntegration;
/** Whether AuthMe integration should be enabled **/ /**
public boolean enable_authme_integration; * Whether AuthMe integration should be enabled
**/
public static boolean enableAuthMeIntegration;
/** Whether PlotSquared integration should be enabled **/ /**
public boolean enable_plotsquared_integration; * Whether PlotSquared integration should be enabled
**/
public static boolean enablePlotsquaredIntegration;
/** Whether uSkyBlock integration should be enabled **/ /**
public boolean enable_uskyblock_integration; * Whether uSkyBlock integration should be enabled
**/
public static boolean enableUSkyblockIntegration;
/** Whether ASkyBlock integration should be enabled **/ /**
public boolean enable_askyblock_integration; * Whether ASkyBlock integration should be enabled
**/
public static boolean enableASkyblockIntegration;
/** Whether IslandWorld integration should be enabled **/ /**
public boolean enable_islandworld_integration; * Whether IslandWorld integration should be enabled
**/
public static boolean enableIslandWorldIntegration;
/** Whether GriefPrevention integration should be enabled **/ /**
public boolean enable_griefprevention_integration; * Whether GriefPrevention integration should be enabled
**/
public static boolean enableGriefPreventionIntegration;
/** Whether AreaShop integration should be enabled **/ /**
public boolean enable_areashop_integration; * Whether AreaShop integration should be enabled
**/
public static boolean enableAreaShopIntegration;
/** Whether the vendor of the shop should get messages about buys and sells **/ /**
public boolean enable_vendor_messages; * Whether the vendor of the shop should get messages about buys and sells
**/
public static boolean enableVendorMessages;
/** Whether admin shops should be excluded of the shop limits **/ /**
public boolean exclude_admin_shops; * Whether admin shops should be excluded of the shop limits
**/
public static boolean excludeAdminShops;
/** Whether the extension of a potion or tipped arrow (if available) should be appended to the item name. **/ /**
public boolean append_potion_level_to_item_name; * Whether the extension of a potion or tipped arrow (if available) should be appended to the item name.
**/
public static boolean appendPotionLevelToItemName;
/** Whether the shop items should be shown **/ /**
public boolean show_shop_items; * Whether the shop items should be shown
**/
public static boolean showShopItems;
/** Whether players are allowed to sell/buy broken items **/ /**
public boolean allow_broken_items; * Whether players are allowed to sell/buy broken items
**/
public static boolean allowBrokenItems;
/** Whether only the shops a player has in sight should be shown to him **/ /**
public boolean only_show_shops_in_sight; * Whether only the shops a player has in sight should be shown to him
**/
public static boolean onlyShowShopsInSight;
/** Whether only the shop a player is looking at should be shown to him **/ /**
public boolean only_show_first_shop_in_sight; * Whether only the shop a player is looking at should be shown to him
**/
public static boolean onlyShowFirstShopInSight;
/** /**
* <p>Whether shops should automatically be removed from the database if an error occurred while loading</p> * <p>Whether shops should automatically be removed from the database if an error occurred while loading</p>
* (e.g. when no chest is found at a shop's location) * (e.g. when no chest is found at a shop's location)
*/ */
public boolean remove_shop_on_error; public static boolean removeShopOnError;
/** Whether the item amount should be calculated to fit the available money or inventory space **/ /**
public boolean auto_calculate_item_amount; * Whether the item amount should be calculated to fit the available money or inventory space
**/
public static boolean autoCalculateItemAmount;
/** /**
* <p>Whether the mouse buttons are inverted</p> * <p>Whether the mouse buttons are inverted</p>
*
* <b>Default:</b><br> * <b>Default:</b><br>
* Right-Click: Buy<br> * Right-Click: Buy<br>
* Left-Click: Sell * Left-Click: Sell
**/ **/
public boolean invert_mouse_buttons; public static boolean invertMouseButtons;
/** Whether the hologram's location should be fixed at the bottom **/ /**
public boolean hologram_fixed_bottom; * Whether the hologram's location should be fixed at the bottom
**/
public static boolean hologramFixedBottom;
/** Amount every hologram should be lifted **/ /**
public double hologram_lift; * Amount every hologram should be lifted
**/
public static double hologramLift;
/** The maximum distance between a player and a shop to see the hologram **/ /**
public double maximal_distance; * The maximum distance between a player and a shop to see the hologram
**/
public static double maximalDistance;
/** The maximum distance between a player and a shop to see the shop item **/ /**
public double maximal_item_distance; * The maximum distance between a player and a shop to see the shop item
**/
public static double maximalItemDistance;
/** The price a player has to pay in order to create a normal shop **/ /**
public double shop_creation_price_normal; * The price a player has to pay in order to create a normal shop
**/
public static double shopCreationPriceNormal;
/** The price a player has to pay in order to create an admin shop **/ /**
public double shop_creation_price_admin; * The price a player has to pay in order to create an admin shop
**/
public static double shopCreationPriceAdmin;
/** The default shop limit for players whose limit is not set via a permission **/ /**
public int default_limit; * The default shop limit for players whose limit is not set via a permission
**/
public static int defaultLimit;
/** The main command of ShopChest <i>(default: shop)</i> **/ /**
public String main_command_name; * The main command of ShopChest <i>(default: shop)</i>
**/
public static String mainCommandName;
/** The language file to use (e.g <i>en_US</i>, <i>de_DE</i>) **/ /**
public String language_file; * The language file to use (e.g <i>en_US</i>, <i>de_DE</i>)
**/
public static String languageFile;
/**
* The language configuration of the currently selected language file
*/
public static LanguageConfiguration langConfig;
private ShopChest plugin;
public Config(ShopChest plugin) { public Config(ShopChest plugin) {
this.plugin = plugin; this.plugin = plugin;
@ -226,7 +329,7 @@ public class Config {
* <i>Config is automatically reloaded</i> * <i>Config is automatically reloaded</i>
* *
* @param property Property to change * @param property Property to change
* @param value Value to set * @param value Value to set
*/ */
public void set(String property, String value) { public void set(String property, String value) {
boolean langChange = (property.equalsIgnoreCase("language-file")); boolean langChange = (property.equalsIgnoreCase("language-file"));
@ -265,8 +368,9 @@ public class Config {
/** /**
* Add a value to a list in the config.yml. * Add a value to a list in the config.yml.
* If the list does not exist, a new list with the given value will be created * If the list does not exist, a new list with the given value will be created
*
* @param property Location of the list * @param property Location of the list
* @param value Value to add * @param value Value to add
*/ */
public void add(String property, String value) { public void add(String property, String value) {
List list = (plugin.getConfig().getList(property) == null) ? new ArrayList<>() : plugin.getConfig().getList(property); List list = (plugin.getConfig().getList(property) == null) ? new ArrayList<>() : plugin.getConfig().getList(property);
@ -344,62 +448,62 @@ public class Config {
public void reload(boolean firstLoad, boolean langReload, boolean showMessages) { public void reload(boolean firstLoad, boolean langReload, boolean showMessages) {
plugin.reloadConfig(); plugin.reloadConfig();
update_quality = ShopUpdater.UpdateQuality.valueOf(plugin.getConfig().getString("update-quality")); updateQuality = ShopUpdater.UpdateQuality.valueOf(plugin.getConfig().getString("update-quality"));
shop_info_item = ItemUtils.getItemStack(plugin.getConfig().getString("shop-info-item")); shopInfoItem = ItemUtils.getItemStack(plugin.getConfig().getString("shop-info-item"));
wg_allow_create_shop_default = plugin.getConfig().getBoolean("worldguard-default-flag-values.create-shop"); wgAllowCreateShopDefault = plugin.getConfig().getBoolean("worldguard-default-flag-values.create-shop");
wg_allow_use_admin_shop_default = plugin.getConfig().getBoolean("worldguard-default-flag-values.use-admin-shop"); wgAllowUseAdminShopDefault = plugin.getConfig().getBoolean("worldguard-default-flag-values.use-admin-shop");
wg_allow_use_shop_default = plugin.getConfig().getBoolean("worldguard-default-flag-values.use-shop"); wgAllowUseShopDefault = plugin.getConfig().getBoolean("worldguard-default-flag-values.use-shop");
towny_shop_plots_residents = plugin.getConfig().getStringList("towny-shop-plots.residents"); townyShopPlotsResidents = plugin.getConfig().getStringList("towny-shop-plots.residents");
towny_shop_plots_mayor = plugin.getConfig().getStringList("towny-shop-plots.mayor"); townyShopPlotsMayor = plugin.getConfig().getStringList("towny-shop-plots.mayor");
towny_shop_plots_king = plugin.getConfig().getStringList("towny-shop-plots.king"); townyShopPlotsKing = plugin.getConfig().getStringList("towny-shop-plots.king");
areashop_remove_shop_events = plugin.getConfig().getStringList("areashop-remove-shops"); areashopRemoveShopEvents = plugin.getConfig().getStringList("areashop-remove-shops");
database_mysql_ping_interval = plugin.getConfig().getInt("database.mysql.ping-interval"); databaseMySqlPingInterval = plugin.getConfig().getInt("database.mysql.ping-interval");
database_mysql_host = plugin.getConfig().getString("database.mysql.hostname"); databaseMySqlHost = plugin.getConfig().getString("database.mysql.hostname");
database_mysql_port = plugin.getConfig().getInt("database.mysql.port"); databaseMySqlPort = plugin.getConfig().getInt("database.mysql.port");
database_mysql_database = plugin.getConfig().getString("database.mysql.database"); databaseMySqlDatabase = plugin.getConfig().getString("database.mysql.database");
database_mysql_username = plugin.getConfig().getString("database.mysql.username"); databaseMySqlUsername = plugin.getConfig().getString("database.mysql.username");
database_mysql_password = plugin.getConfig().getString("database.mysql.password"); databaseMySqlPassword = plugin.getConfig().getString("database.mysql.password");
database_type = Database.DatabaseType.valueOf(plugin.getConfig().getString("database.type")); databaseType = Database.DatabaseType.valueOf(plugin.getConfig().getString("database.type"));
minimum_prices = (plugin.getConfig().getConfigurationSection("minimum-prices") == null) ? new HashSet<String>() : plugin.getConfig().getConfigurationSection("minimum-prices").getKeys(true); minimumPrices = (plugin.getConfig().getConfigurationSection("minimum-prices") == null) ? new HashSet<String>() : plugin.getConfig().getConfigurationSection("minimum-prices").getKeys(true);
maximum_prices = (plugin.getConfig().getConfigurationSection("maximum-prices") == null) ? new HashSet<String>() : plugin.getConfig().getConfigurationSection("maximum-prices").getKeys(true); maximumPrices = (plugin.getConfig().getConfigurationSection("maximum-prices") == null) ? new HashSet<String>() : plugin.getConfig().getConfigurationSection("maximum-prices").getKeys(true);
allow_decimals_in_price = plugin.getConfig().getBoolean("allow-decimals-in-price"); allowDecimalsInPrice = plugin.getConfig().getBoolean("allow-decimals-in-price");
allow_broken_items = plugin.getConfig().getBoolean("allow-broken-items"); allowBrokenItems = plugin.getConfig().getBoolean("allow-broken-items");
auto_calculate_item_amount = (allow_decimals_in_price && plugin.getConfig().getBoolean("auto-calculate-item-amount")); autoCalculateItemAmount = (allowDecimalsInPrice && plugin.getConfig().getBoolean("auto-calculate-item-amount"));
blacklist = (plugin.getConfig().getStringList("blacklist") == null) ? new ArrayList<String>() : plugin.getConfig().getStringList("blacklist"); blacklist = (plugin.getConfig().getStringList("blacklist") == null) ? new ArrayList<String>() : plugin.getConfig().getStringList("blacklist");
buy_greater_or_equal_sell = plugin.getConfig().getBoolean("buy-greater-or-equal-sell"); buyGreaterOrEqualSell = plugin.getConfig().getBoolean("buy-greater-or-equal-sell");
hopper_protection = plugin.getConfig().getBoolean("hopper-protection"); hopperProtection = plugin.getConfig().getBoolean("hopper-protection");
explosion_protection = plugin.getConfig().getBoolean("explosion-protection"); explosionProtection = plugin.getConfig().getBoolean("explosion-protection");
confirm_shopping = plugin.getConfig().getBoolean("confirm-shopping"); confirmShopping = plugin.getConfig().getBoolean("confirm-shopping");
enable_quality_mode = plugin.getConfig().getBoolean("enable-quality-mode"); enableQualityMode = plugin.getConfig().getBoolean("enable-quality-mode");
enable_hologram_interaction = plugin.getConfig().getBoolean("enable-hologram-interaction"); enableHologramInteraction = plugin.getConfig().getBoolean("enable-hologram-interaction");
enable_debug_log = plugin.getConfig().getBoolean("enable-debug-log"); enableDebugLog = plugin.getConfig().getBoolean("enable-debug-log");
enable_ecomomy_log = plugin.getConfig().getBoolean("enable-economy-log"); enableEcomomyLog = plugin.getConfig().getBoolean("enable-economy-log");
enable_worldguard_integration = plugin.getConfig().getBoolean("enable-worldguard-integration"); enableWorldGuardIntegration = plugin.getConfig().getBoolean("enable-worldguard-integration");
enable_towny_integration = plugin.getConfig().getBoolean("enable-towny-integration"); enableTownyIntegration = plugin.getConfig().getBoolean("enable-towny-integration");
enable_authme_integration = plugin.getConfig().getBoolean("enable-authme-integration"); enableAuthMeIntegration = plugin.getConfig().getBoolean("enable-authme-integration");
enable_plotsquared_integration = plugin.getConfig().getBoolean("enable-plotsquared-integration"); enablePlotsquaredIntegration = plugin.getConfig().getBoolean("enable-plotsquared-integration");
enable_uskyblock_integration = plugin.getConfig().getBoolean("enable-uskyblock-integration"); enableUSkyblockIntegration = plugin.getConfig().getBoolean("enable-uskyblock-integration");
enable_askyblock_integration = plugin.getConfig().getBoolean("enable-askyblock-integration"); enableASkyblockIntegration = plugin.getConfig().getBoolean("enable-askyblock-integration");
enable_islandworld_integration = plugin.getConfig().getBoolean("enable-islandworld-integration"); enableIslandWorldIntegration = plugin.getConfig().getBoolean("enable-islandworld-integration");
enable_griefprevention_integration = plugin.getConfig().getBoolean("enable-griefprevention-integration"); enableGriefPreventionIntegration = plugin.getConfig().getBoolean("enable-griefprevention-integration");
enable_areashop_integration = plugin.getConfig().getBoolean("enable-areashop-integration"); enableAreaShopIntegration = plugin.getConfig().getBoolean("enable-areashop-integration");
enable_vendor_messages = plugin.getConfig().getBoolean("enable-vendor-messages"); enableVendorMessages = plugin.getConfig().getBoolean("enable-vendor-messages");
only_show_shops_in_sight = plugin.getConfig().getBoolean("only-show-shops-in-sight"); onlyShowShopsInSight = plugin.getConfig().getBoolean("only-show-shops-in-sight");
only_show_first_shop_in_sight = plugin.getConfig().getBoolean("only-show-first-shop-in-sight"); onlyShowFirstShopInSight = plugin.getConfig().getBoolean("only-show-first-shop-in-sight");
exclude_admin_shops = plugin.getConfig().getBoolean("shop-limits.exclude-admin-shops"); excludeAdminShops = plugin.getConfig().getBoolean("shop-limits.exclude-admin-shops");
append_potion_level_to_item_name = plugin.getConfig().getBoolean("append-potion-level-to-item-name"); appendPotionLevelToItemName = plugin.getConfig().getBoolean("append-potion-level-to-item-name");
show_shop_items = plugin.getConfig().getBoolean("show-shop-items"); showShopItems = plugin.getConfig().getBoolean("show-shop-items");
remove_shop_on_error = plugin.getConfig().getBoolean("remove-shop-on-error"); removeShopOnError = plugin.getConfig().getBoolean("remove-shop-on-error");
invert_mouse_buttons = plugin.getConfig().getBoolean("invert-mouse-buttons"); invertMouseButtons = plugin.getConfig().getBoolean("invert-mouse-buttons");
hologram_fixed_bottom = plugin.getConfig().getBoolean("hologram-fixed-bottom"); hologramFixedBottom = plugin.getConfig().getBoolean("hologram-fixed-bottom");
hologram_lift = plugin.getConfig().getDouble("hologram-lift"); hologramLift = plugin.getConfig().getDouble("hologram-lift");
maximal_distance = plugin.getConfig().getDouble("maximal-distance"); maximalDistance = plugin.getConfig().getDouble("maximal-distance");
maximal_item_distance = plugin.getConfig().getDouble("maximal-item-distance"); maximalItemDistance = plugin.getConfig().getDouble("maximal-item-distance");
shop_creation_price_normal = plugin.getConfig().getDouble("shop-creation-price.normal"); shopCreationPriceNormal = plugin.getConfig().getDouble("shop-creation-price.normal");
shop_creation_price_admin = plugin.getConfig().getDouble("shop-creation-price.admin"); shopCreationPriceAdmin = plugin.getConfig().getDouble("shop-creation-price.admin");
default_limit = plugin.getConfig().getInt("shop-limits.default"); defaultLimit = plugin.getConfig().getInt("shop-limits.default");
main_command_name = plugin.getConfig().getString("main-command-name"); mainCommandName = plugin.getConfig().getString("main-command-name");
language_file = plugin.getConfig().getString("language-file"); languageFile = plugin.getConfig().getString("language-file");
if (firstLoad || langReload) loadLanguageConfig(showMessages); if (firstLoad || langReload) loadLanguageConfig(showMessages);
if (!firstLoad && langReload) LanguageUtils.load(); if (!firstLoad && langReload) LanguageUtils.load();
@ -434,7 +538,7 @@ public class Config {
if (!(new File(langFolder, "de_DE.lang")).exists()) if (!(new File(langFolder, "de_DE.lang")).exists())
plugin.saveResource("lang/de_DE.lang", false); plugin.saveResource("lang/de_DE.lang", false);
File langConfigFile = new File(langFolder, language_file + ".lang"); File langConfigFile = new File(langFolder, languageFile + ".lang");
File langDefaultFile = new File(langFolder, "en_US.lang"); File langDefaultFile = new File(langFolder, "en_US.lang");
if (!langConfigFile.exists()) { if (!langConfigFile.exists()) {
@ -446,7 +550,8 @@ public class Config {
r = getTextResource("lang/en_US.lang", showMessages); r = getTextResource("lang/en_US.lang", showMessages);
if (showMessages) plugin.getLogger().info("Using locale \"en_US\" (Streamed from jar file)"); if (showMessages) plugin.getLogger().info("Using locale \"en_US\" (Streamed from jar file)");
} else { } else {
if (showMessages) plugin.getLogger().info("Using locale \"" + langConfigFile.getName().substring(0, langConfigFile.getName().length() - 5) + "\" (Streamed from jar file)"); if (showMessages)
plugin.getLogger().info("Using locale \"" + langConfigFile.getName().substring(0, langConfigFile.getName().length() - 5) + "\" (Streamed from jar file)");
} }
if (r == null) { if (r == null) {
@ -489,7 +594,8 @@ public class Config {
} }
} else { } else {
try { try {
if (showMessages) plugin.getLogger().info("Using locale \"" + langConfigFile.getName().substring(0, langConfigFile.getName().length() - 5) + "\""); if (showMessages)
plugin.getLogger().info("Using locale \"" + langConfigFile.getName().substring(0, langConfigFile.getName().length() - 5) + "\"");
langConfig.load(langConfigFile); langConfig.load(langConfigFile);
} catch (IOException | InvalidConfigurationException e) { } catch (IOException | InvalidConfigurationException e) {
if (showMessages) { if (showMessages) {

View File

@ -8,7 +8,6 @@ import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.regex.Matcher;
public class LanguageConfiguration extends FileConfiguration { public class LanguageConfiguration extends FileConfiguration {

View File

@ -1,99 +1,29 @@
package de.epiceric.shopchest.external; package de.epiceric.shopchest.external;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.flags.Flag; import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.StateFlag; import com.sk89q.worldguard.protection.flags.StateFlag;
import de.epiceric.shopchest.ShopChest; import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
public class WorldGuardShopFlag { public class WorldGuardShopFlag {
private static Flag<?>[] customFlagList; private static Flag<?>[] customFlagList;
private static boolean loaded = false;
public static final StateFlag CREATE_SHOP; public static final StateFlag CREATE_SHOP;
public static final StateFlag USE_SHOP; public static final StateFlag USE_SHOP;
public static final StateFlag USE_ADMIN_SHOP; public static final StateFlag USE_ADMIN_SHOP;
static { static {
CREATE_SHOP = new StateFlag("create-shop", ShopChest.getInstance().getShopChestConfig().wg_allow_create_shop_default); CREATE_SHOP = new StateFlag("create-shop", Config.wgAllowCreateShopDefault);
USE_SHOP = new StateFlag("use-shop", ShopChest.getInstance().getShopChestConfig().wg_allow_use_shop_default); USE_SHOP = new StateFlag("use-shop", Config.wgAllowUseShopDefault);
USE_ADMIN_SHOP = new StateFlag("use-admin-shop", ShopChest.getInstance().getShopChestConfig().wg_allow_use_admin_shop_default); USE_ADMIN_SHOP = new StateFlag("use-admin-shop", Config.wgAllowUseAdminShopDefault);
customFlagList = new Flag[] {CREATE_SHOP, USE_SHOP, USE_ADMIN_SHOP}; customFlagList = new Flag[] {CREATE_SHOP, USE_SHOP, USE_ADMIN_SHOP};
} }
public static boolean isLoaded() { public static void register(final ShopChest plugin) {
return loaded; plugin.getWorldGuard().getFlagRegistry().registerAll(Lists.newArrayList(customFlagList));
}
public static void register(final ShopChest plugin, boolean onLoad) {
String worldGuardVersion = plugin.getWorldGuard().getDescription().getVersion();
int majorVersion = 0;
int minorVersion = 0;
int fixVersion = 0;
try {
String[] spl = worldGuardVersion.split("\\.");
if (spl.length > 0) {
majorVersion = Integer.parseInt(spl[0]);
if (spl.length > 1) {
minorVersion = Integer.parseInt(spl[1]);
if (spl.length > 2) {
int length = 0;
for (int i = 0; i < spl[2].toCharArray().length; i++) {
char c = spl[2].toCharArray()[i];
if (c >= '0' && c <= '9') {
length++;
} else break;
}
fixVersion = Integer.parseInt(spl[2].substring(0, length));
}
}
} else {
plugin.getLogger().severe("Failed to initialize custom WorldGuard flags.");
plugin.debug("Failed to initialize WorldGuard flags: Unknown/Invalid version: " + worldGuardVersion);
return;
}
} catch (NumberFormatException e) {
plugin.debug("Failed to initialize WorldGuard flags");
plugin.debug(e);
plugin.getLogger().severe("Failed to initialize custom WorldGuard flags.");
return;
}
if (((majorVersion == 6 && minorVersion == 1 && fixVersion >= 3) || (majorVersion == 6 && minorVersion > 1) || majorVersion > 6)) {
if (onLoad) {
plugin.getWorldGuard().getFlagRegistry().registerAll(Lists.newArrayList(customFlagList));
loaded = true;
}
} else {
try {
Field flagListField = DefaultFlag.class.getField("flagsList");
Flag<?>[] flags = new Flag[DefaultFlag.flagsList.length + customFlagList.length];
System.arraycopy(DefaultFlag.flagsList, 0, flags, 0, DefaultFlag.flagsList.length);
System.arraycopy(customFlagList, 0, flags, DefaultFlag.flagsList.length, customFlagList.length);
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(flagListField, flagListField.getModifiers() & ~Modifier.FINAL);
flagListField.set(null, flags);
loaded = true;
} catch (NoSuchFieldException | IllegalAccessException e) {
plugin.debug("Failed to initialize WorldGuard flags");
plugin.debug(e);
plugin.getLogger().severe("Failed to initialize custom WorldGuard flags.");
}
}
} }
} }

View File

@ -1,6 +1,7 @@
package de.epiceric.shopchest.language; package de.epiceric.shopchest.language;
import de.epiceric.shopchest.ShopChest; import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.config.LanguageConfiguration; import de.epiceric.shopchest.config.LanguageConfiguration;
import de.epiceric.shopchest.config.Placeholder; import de.epiceric.shopchest.config.Placeholder;
import de.epiceric.shopchest.nms.CustomBookMeta; import de.epiceric.shopchest.nms.CustomBookMeta;
@ -38,7 +39,7 @@ public class LanguageUtils {
public static void load() { public static void load() {
langConfig = plugin.getShopChestConfig().getLanguageConfig(); langConfig = Config.langConfig;
itemNames.clear(); itemNames.clear();
enchantmentNames.clear(); enchantmentNames.clear();
@ -997,102 +998,102 @@ public class LanguageUtils {
generationNames.add(new BookGenerationName(CustomBookMeta.Generation.TATTERED, langConfig.getString("book.generation.3", "Tattered"))); generationNames.add(new BookGenerationName(CustomBookMeta.Generation.TATTERED, langConfig.getString("book.generation.3", "Tattered")));
// Add ShopChest Messages // Add ShopChest Messages
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_CREATED, langConfig.getString("message.shop-created", "&6You were withdrawn &c%CREATION-PRICE% &6to create this shop."))); messages.add(new LocalizedMessage(Message.SHOP_CREATED, langConfig.getString("message.shop-created", "&6You were withdrawn &c%CREATION-PRICE% &6to create this shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.ADMIN_SHOP_CREATED, langConfig.getString("message.admin-shop-created", "&6You were withdrawn &c%CREATION-PRICE% &6to create this admin shop."))); messages.add(new LocalizedMessage(Message.ADMIN_SHOP_CREATED, langConfig.getString("message.admin-shop-created", "&6You were withdrawn &c%CREATION-PRICE% &6to create this admin shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.CHEST_ALREADY_SHOP, langConfig.getString("message.chest-already-shop", "&cChest already shop."))); messages.add(new LocalizedMessage(Message.CHEST_ALREADY_SHOP, langConfig.getString("message.chest-already-shop", "&cChest already shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.CHEST_BLOCKED, langConfig.getString("message.chest-blocked", "&cThere must not be a block above the chest."))); messages.add(new LocalizedMessage(Message.CHEST_BLOCKED, langConfig.getString("message.chest-blocked", "&cThere must not be a block above the chest.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.DOUBLE_CHEST_BLOCKED, langConfig.getString("message.double-chest-blocked", "&cThere must not be a block above the chest."))); messages.add(new LocalizedMessage(Message.DOUBLE_CHEST_BLOCKED, langConfig.getString("message.double-chest-blocked", "&cThere must not be a block above the chest.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_REMOVED, langConfig.getString("message.shop-removed", "&6Shop removed."))); messages.add(new LocalizedMessage(Message.SHOP_REMOVED, langConfig.getString("message.shop-removed", "&6Shop removed.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.ALL_SHOPS_REMOVED, langConfig.getString("message.all-shops-removed", "&6Removed all (&c%AMOUNT%&6) shop/s of &c%VENDOR%&6."))); messages.add(new LocalizedMessage(Message.ALL_SHOPS_REMOVED, langConfig.getString("message.all-shops-removed", "&6Removed all (&c%AMOUNT%&6) shop/s of &c%VENDOR%&6.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.CHEST_NO_SHOP, langConfig.getString("message.chest-no-shop", "&cChest is not a shop."))); messages.add(new LocalizedMessage(Message.CHEST_NO_SHOP, langConfig.getString("message.chest-no-shop", "&cChest is not a shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_CREATE_NOT_ENOUGH_MONEY, langConfig.getString("message.shop-create-not-enough-money", "&cNot enough money. You need &6%CREATION-PRICE% &cto create a shop."))); messages.add(new LocalizedMessage(Message.SHOP_CREATE_NOT_ENOUGH_MONEY, langConfig.getString("message.shop-create-not-enough-money", "&cNot enough money. You need &6%CREATION-PRICE% &cto create a shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_VENDOR, langConfig.getString("message.shopInfo.vendor", "&6Vendor: &e%VENDOR%"))); messages.add(new LocalizedMessage(Message.SHOP_INFO_VENDOR, langConfig.getString("message.shopInfo.vendor", "&6Vendor: &e%VENDOR%")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_PRODUCT, langConfig.getString("message.shopInfo.product", "&6Product: &e%AMOUNT% x %ITEMNAME%"))); messages.add(new LocalizedMessage(Message.SHOP_INFO_PRODUCT, langConfig.getString("message.shopInfo.product", "&6Product: &e%AMOUNT% x %ITEMNAME%")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_STOCK, langConfig.getString("message.shopInfo.stock", "&6In Stock: &e%STOCK%"))); messages.add(new LocalizedMessage(Message.SHOP_INFO_STOCK, langConfig.getString("message.shopInfo.stock", "&6In Stock: &e%STOCK%")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_ENCHANTMENTS, langConfig.getString("message.shopInfo.enchantments", "&6Enchantments: &e%ENCHANTMENT%"))); messages.add(new LocalizedMessage(Message.SHOP_INFO_ENCHANTMENTS, langConfig.getString("message.shopInfo.enchantments", "&6Enchantments: &e%ENCHANTMENT%")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_POTION_EFFECT, langConfig.getString("message.shopInfo.potion-effect", "&6Potion Effect: &e%POTION-EFFECT% %EXTENDED%"))); messages.add(new LocalizedMessage(Message.SHOP_INFO_POTION_EFFECT, langConfig.getString("message.shopInfo.potion-effect", "&6Potion Effect: &e%POTION-EFFECT% %EXTENDED%")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_MUSIC_TITLE, langConfig.getString("message.shopInfo.music-disc-title", "&6Music Disc Title: &e%MUSIC-TITLE%"))); messages.add(new LocalizedMessage(Message.SHOP_INFO_MUSIC_TITLE, langConfig.getString("message.shopInfo.music-disc-title", "&6Music Disc Title: &e%MUSIC-TITLE%")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_BOOK_GENERATION, langConfig.getString("message.shopInfo.book-generation", "&6Generation: &e%GENERATION%"))); messages.add(new LocalizedMessage(Message.SHOP_INFO_BOOK_GENERATION, langConfig.getString("message.shopInfo.book-generation", "&6Generation: &e%GENERATION%")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_NONE, langConfig.getString("message.shopInfo.none", "&7None"))); messages.add(new LocalizedMessage(Message.SHOP_INFO_NONE, langConfig.getString("message.shopInfo.none", "&7None")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_PRICE, langConfig.getString("message.shopInfo.price", "&6Price: Buy: &e%BUY-PRICE%&6 Sell: &e%SELL-PRICE%"))); messages.add(new LocalizedMessage(Message.SHOP_INFO_PRICE, langConfig.getString("message.shopInfo.price", "&6Price: Buy: &e%BUY-PRICE%&6 Sell: &e%SELL-PRICE%")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_DISABLED, langConfig.getString("message.shopInfo.disabled", "&7Disabled"))); messages.add(new LocalizedMessage(Message.SHOP_INFO_DISABLED, langConfig.getString("message.shopInfo.disabled", "&7Disabled")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_NORMAL, langConfig.getString("message.shopInfo.is-normal", "&6Type: &eNormal"))); messages.add(new LocalizedMessage(Message.SHOP_INFO_NORMAL, langConfig.getString("message.shopInfo.is-normal", "&6Type: &eNormal")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_ADMIN, langConfig.getString("message.shopInfo.is-admin", "&6Type: &eAdmin"))); messages.add(new LocalizedMessage(Message.SHOP_INFO_ADMIN, langConfig.getString("message.shopInfo.is-admin", "&6Type: &eAdmin")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_INFO_EXTENDED, langConfig.getString("message.shopInfo.extended", "(Extended)"))); messages.add(new LocalizedMessage(Message.SHOP_INFO_EXTENDED, langConfig.getString("message.shopInfo.extended", "(Extended)")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.BUY_SELL_DISABLED, langConfig.getString("message.buy-and-sell-disabled", "&cYou can't create a shop with buying and selling disabled."))); messages.add(new LocalizedMessage(Message.BUY_SELL_DISABLED, langConfig.getString("message.buy-and-sell-disabled", "&cYou can't create a shop with buying and selling disabled.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.BUY_SUCCESS, langConfig.getString("message.buy-success", "&aYou bought &6%AMOUNT% x %ITEMNAME%&a for &6%BUY-PRICE%&a from &6%VENDOR%&a."))); messages.add(new LocalizedMessage(Message.BUY_SUCCESS, langConfig.getString("message.buy-success", "&aYou bought &6%AMOUNT% x %ITEMNAME%&a for &6%BUY-PRICE%&a from &6%VENDOR%&a.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.BUY_SUCCESS_ADMIN, langConfig.getString("message.buy-success-admin", "&aYou bought &6%AMOUNT% x %ITEMNAME%&a for &6%BUY-PRICE%&a."))); messages.add(new LocalizedMessage(Message.BUY_SUCCESS_ADMIN, langConfig.getString("message.buy-success-admin", "&aYou bought &6%AMOUNT% x %ITEMNAME%&a for &6%BUY-PRICE%&a.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SELL_SUCCESS, langConfig.getString("message.sell-success", "&aYou sold &6%AMOUNT% x %ITEMNAME%&a for &6%SELL-PRICE%&a to &6%VENDOR%&a."))); messages.add(new LocalizedMessage(Message.SELL_SUCCESS, langConfig.getString("message.sell-success", "&aYou sold &6%AMOUNT% x %ITEMNAME%&a for &6%SELL-PRICE%&a to &6%VENDOR%&a.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SELL_SUCCESS_ADMIN, langConfig.getString("message.sell-success-admin", "&aYou sold &6%AMOUNT% x %ITEMNAME%&a for &6%SELL-PRICE%&a."))); messages.add(new LocalizedMessage(Message.SELL_SUCCESS_ADMIN, langConfig.getString("message.sell-success-admin", "&aYou sold &6%AMOUNT% x %ITEMNAME%&a for &6%SELL-PRICE%&a.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SOMEONE_BOUGHT, langConfig.getString("message.someone-bought", "&6%PLAYER% &abought &6%AMOUNT% x %ITEMNAME%&a for &6%BUY-PRICE%&a from your shop."))); messages.add(new LocalizedMessage(Message.SOMEONE_BOUGHT, langConfig.getString("message.someone-bought", "&6%PLAYER% &abought &6%AMOUNT% x %ITEMNAME%&a for &6%BUY-PRICE%&a from your shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SOMEONE_SOLD, langConfig.getString("message.someone-sold", "&6%PLAYER% &asold &6%AMOUNT% x %ITEMNAME%&a for &6%SELL-PRICE%&a to your shop."))); messages.add(new LocalizedMessage(Message.SOMEONE_SOLD, langConfig.getString("message.someone-sold", "&6%PLAYER% &asold &6%AMOUNT% x %ITEMNAME%&a for &6%SELL-PRICE%&a to your shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.REVENUE_WHILE_OFFLINE, langConfig.getString("message.revenue-while-offline", "&6While you were offline, your shops have made a revenue of &c%REVENUE%&6."))); messages.add(new LocalizedMessage(Message.REVENUE_WHILE_OFFLINE, langConfig.getString("message.revenue-while-offline", "&6While you were offline, your shops have made a revenue of &c%REVENUE%&6.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NOT_ENOUGH_INVENTORY_SPACE, langConfig.getString("message.not-enough-inventory-space", "&cNot enough space in inventory."))); messages.add(new LocalizedMessage(Message.NOT_ENOUGH_INVENTORY_SPACE, langConfig.getString("message.not-enough-inventory-space", "&cNot enough space in inventory.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.CHEST_NOT_ENOUGH_INVENTORY_SPACE, langConfig.getString("message.chest-not-enough-inventory-space", "&cShop is full."))); messages.add(new LocalizedMessage(Message.CHEST_NOT_ENOUGH_INVENTORY_SPACE, langConfig.getString("message.chest-not-enough-inventory-space", "&cShop is full.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NOT_ENOUGH_MONEY, langConfig.getString("message.not-enough-money", "&cNot enough money."))); messages.add(new LocalizedMessage(Message.NOT_ENOUGH_MONEY, langConfig.getString("message.not-enough-money", "&cNot enough money.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NOT_ENOUGH_ITEMS, langConfig.getString("message.not-enough-items", "&cNot enough items."))); messages.add(new LocalizedMessage(Message.NOT_ENOUGH_ITEMS, langConfig.getString("message.not-enough-items", "&cNot enough items.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.VENDOR_NOT_ENOUGH_MONEY, langConfig.getString("message.vendor-not-enough-money", "&cVendor has not enough money."))); messages.add(new LocalizedMessage(Message.VENDOR_NOT_ENOUGH_MONEY, langConfig.getString("message.vendor-not-enough-money", "&cVendor has not enough money.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.OUT_OF_STOCK, langConfig.getString("message.out-of-stock", "&cShop out of stock."))); messages.add(new LocalizedMessage(Message.OUT_OF_STOCK, langConfig.getString("message.out-of-stock", "&cShop out of stock.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.VENDOR_OUT_OF_STOCK, langConfig.getString("message.vendor-out-of-stock", "&cYour shop that sells &6%AMOUNT% x %ITEMNAME% &cis out of stock."))); messages.add(new LocalizedMessage(Message.VENDOR_OUT_OF_STOCK, langConfig.getString("message.vendor-out-of-stock", "&cYour shop that sells &6%AMOUNT% x %ITEMNAME% &cis out of stock.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.ERROR_OCCURRED, langConfig.getString("message.error-occurred", "&cAn error occurred: %ERROR%"))); messages.add(new LocalizedMessage(Message.ERROR_OCCURRED, langConfig.getString("message.error-occurred", "&cAn error occurred: %ERROR%")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.AMOUNT_PRICE_NOT_NUMBER, langConfig.getString("message.amount-and-price-not-number", "&cAmount and price must be a number."))); messages.add(new LocalizedMessage(Message.AMOUNT_PRICE_NOT_NUMBER, langConfig.getString("message.amount-and-price-not-number", "&cAmount and price must be a number.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.AMOUNT_IS_ZERO, langConfig.getString("message.amount-is-zero", "&cAmount must be greater than 0."))); messages.add(new LocalizedMessage(Message.AMOUNT_IS_ZERO, langConfig.getString("message.amount-is-zero", "&cAmount must be greater than 0.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.PRICES_CONTAIN_DECIMALS, langConfig.getString("message.prices-contain-decimals", "&cPrices must not contain decimals."))); messages.add(new LocalizedMessage(Message.PRICES_CONTAIN_DECIMALS, langConfig.getString("message.prices-contain-decimals", "&cPrices must not contain decimals.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_ITEM_IN_HAND, langConfig.getString("message.no-item-in-hand", "&cNo item in hand"))); messages.add(new LocalizedMessage(Message.NO_ITEM_IN_HAND, langConfig.getString("message.no-item-in-hand", "&cNo item in hand")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.CLICK_CHEST_CREATE, langConfig.getString("message.click-chest-to-create-shop", "&aClick a chest within 15 seconds to create a shop."))); messages.add(new LocalizedMessage(Message.CLICK_CHEST_CREATE, langConfig.getString("message.click-chest-to-create-shop", "&aClick a chest within 15 seconds to create a shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.CLICK_CHEST_REMOVE, langConfig.getString("message.click-chest-to-remove-shop", "&aClick a shop within 15 seconds to remove it."))); messages.add(new LocalizedMessage(Message.CLICK_CHEST_REMOVE, langConfig.getString("message.click-chest-to-remove-shop", "&aClick a shop within 15 seconds to remove it.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.CLICK_CHEST_INFO, langConfig.getString("message.click-chest-for-info", "&aClick a shop within 15 seconds to retrieve information."))); messages.add(new LocalizedMessage(Message.CLICK_CHEST_INFO, langConfig.getString("message.click-chest-for-info", "&aClick a shop within 15 seconds to retrieve information.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.CLICK_CHEST_OPEN, langConfig.getString("message.click-chest-to-open-shop", "&aClick a shop within 15 seconds to open it."))); messages.add(new LocalizedMessage(Message.CLICK_CHEST_OPEN, langConfig.getString("message.click-chest-to-open-shop", "&aClick a shop within 15 seconds to open it.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.CLICK_TO_CONFIRM, langConfig.getString("message.click-to-confirm", "&aClick again to confirm."))); messages.add(new LocalizedMessage(Message.CLICK_TO_CONFIRM, langConfig.getString("message.click-to-confirm", "&aClick again to confirm.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.OPENED_SHOP, langConfig.getString("message.opened-shop", "&aYou opened %VENDOR%'s shop."))); messages.add(new LocalizedMessage(Message.OPENED_SHOP, langConfig.getString("message.opened-shop", "&aYou opened %VENDOR%'s shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.CANNOT_BREAK_SHOP, langConfig.getString("message.cannot-break-shop", "&cYou can't break a shop."))); messages.add(new LocalizedMessage(Message.CANNOT_BREAK_SHOP, langConfig.getString("message.cannot-break-shop", "&cYou can't break a shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.CANNOT_SELL_BROKEN_ITEM, langConfig.getString("message.cannot-sell-broken-item", "&cYou can't sell a broken item."))); messages.add(new LocalizedMessage(Message.CANNOT_SELL_BROKEN_ITEM, langConfig.getString("message.cannot-sell-broken-item", "&cYou can't sell a broken item.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.BUY_PRICE_TOO_LOW, langConfig.getString("message.buy-price-too-low", "&cThe buy price must be higher than %MIN-PRICE%."))); messages.add(new LocalizedMessage(Message.BUY_PRICE_TOO_LOW, langConfig.getString("message.buy-price-too-low", "&cThe buy price must be higher than %MIN-PRICE%.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SELL_PRICE_TOO_LOW, langConfig.getString("message.sell-price-too-low", "&cThe sell price must be higher than %MIN-PRICE%."))); messages.add(new LocalizedMessage(Message.SELL_PRICE_TOO_LOW, langConfig.getString("message.sell-price-too-low", "&cThe sell price must be higher than %MIN-PRICE%.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.BUY_PRICE_TOO_HIGH, langConfig.getString("message.buy-price-too-high", "&cThe buy price must be lower than %MAX-PRICE%."))); messages.add(new LocalizedMessage(Message.BUY_PRICE_TOO_HIGH, langConfig.getString("message.buy-price-too-high", "&cThe buy price must be lower than %MAX-PRICE%.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SELL_PRICE_TOO_HIGH, langConfig.getString("message.sell-price-too-high", "&cThe sell price must be lower than %MAX-PRICE%."))); messages.add(new LocalizedMessage(Message.SELL_PRICE_TOO_HIGH, langConfig.getString("message.sell-price-too-high", "&cThe sell price must be lower than %MAX-PRICE%.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.BUYING_DISABLED, langConfig.getString("message.buying-disabled", "&cBuying is disabled at this shop."))); messages.add(new LocalizedMessage(Message.BUYING_DISABLED, langConfig.getString("message.buying-disabled", "&cBuying is disabled at this shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SELLING_DISABLED, langConfig.getString("message.selling-disabled", "&cSelling is disabled at this shop."))); messages.add(new LocalizedMessage(Message.SELLING_DISABLED, langConfig.getString("message.selling-disabled", "&cSelling is disabled at this shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.RELOADED_SHOPS, langConfig.getString("message.reloaded-shops", "&aSuccessfully reloaded %AMOUNT% shop/s."))); messages.add(new LocalizedMessage(Message.RELOADED_SHOPS, langConfig.getString("message.reloaded-shops", "&aSuccessfully reloaded %AMOUNT% shop/s.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.SHOP_LIMIT_REACHED, langConfig.getString("message.shop-limit-reached", "&cYou reached your limit of &6%LIMIT% &cshop/s."))); messages.add(new LocalizedMessage(Message.SHOP_LIMIT_REACHED, langConfig.getString("message.shop-limit-reached", "&cYou reached your limit of &6%LIMIT% &cshop/s.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.OCCUPIED_SHOP_SLOTS, langConfig.getString("message.occupied-shop-slots", "&6You have &c%AMOUNT%/%LIMIT% &6shop slot/s occupied."))); messages.add(new LocalizedMessage(Message.OCCUPIED_SHOP_SLOTS, langConfig.getString("message.occupied-shop-slots", "&6You have &c%AMOUNT%/%LIMIT% &6shop slot/s occupied.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.CANNOT_SELL_ITEM, langConfig.getString("message.cannot-sell-item", "&cYou cannot create a shop with this item."))); messages.add(new LocalizedMessage(Message.CANNOT_SELL_ITEM, langConfig.getString("message.cannot-sell-item", "&cYou cannot create a shop with this item.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.USE_IN_CREATIVE, langConfig.getString("message.use-in-creative", "&cYou cannot use a shop in creative mode."))); messages.add(new LocalizedMessage(Message.USE_IN_CREATIVE, langConfig.getString("message.use-in-creative", "&cYou cannot use a shop in creative mode.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, langConfig.getString("message.update.update-available", "&6&lVersion &c%VERSION% &6of &cShopChest &6is available &chere."))); messages.add(new LocalizedMessage(Message.UPDATE_AVAILABLE, langConfig.getString("message.update.update-available", "&6&lVersion &c%VERSION% &6of &cShopChest &6is available &chere.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD, langConfig.getString("message.update.click-to-download", "Click to download"))); messages.add(new LocalizedMessage(Message.UPDATE_CLICK_TO_DOWNLOAD, langConfig.getString("message.update.click-to-download", "Click to download")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.UPDATE_NO_UPDATE, langConfig.getString("message.update.no-update", "&6&lNo new update available."))); messages.add(new LocalizedMessage(Message.UPDATE_NO_UPDATE, langConfig.getString("message.update.no-update", "&6&lNo new update available.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.UPDATE_CHECKING, langConfig.getString("message.update.checking", "&6&lChecking for updates..."))); messages.add(new LocalizedMessage(Message.UPDATE_CHECKING, langConfig.getString("message.update.checking", "&6&lChecking for updates...")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.UPDATE_ERROR, langConfig.getString("message.update.error", "&c&lError while checking for updates."))); messages.add(new LocalizedMessage(Message.UPDATE_ERROR, langConfig.getString("message.update.error", "&c&lError while checking for updates.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_CREATE, langConfig.getString("message.noPermission.create", "&cYou don't have permission to create a shop."))); messages.add(new LocalizedMessage(Message.NO_PERMISSION_CREATE, langConfig.getString("message.noPermission.create", "&cYou don't have permission to create a shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_CREATE_ADMIN, langConfig.getString("message.noPermission.create-admin", "&cYou don't have permission to create an admin shop."))); messages.add(new LocalizedMessage(Message.NO_PERMISSION_CREATE_ADMIN, langConfig.getString("message.noPermission.create-admin", "&cYou don't have permission to create an admin shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_CREATE_PROTECTED, langConfig.getString("message.noPermission.create-protected", "&cYou don't have permission to create a shop on a protected chest."))); messages.add(new LocalizedMessage(Message.NO_PERMISSION_CREATE_PROTECTED, langConfig.getString("message.noPermission.create-protected", "&cYou don't have permission to create a shop on a protected chest.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_OPEN_OTHERS, langConfig.getString("message.noPermission.open-others", "&cYou don't have permission to open this chest."))); messages.add(new LocalizedMessage(Message.NO_PERMISSION_OPEN_OTHERS, langConfig.getString("message.noPermission.open-others", "&cYou don't have permission to open this chest.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_BUY, langConfig.getString("message.noPermission.buy", "&cYou don't have permission to buy something."))); messages.add(new LocalizedMessage(Message.NO_PERMISSION_BUY, langConfig.getString("message.noPermission.buy", "&cYou don't have permission to buy something.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_SELL, langConfig.getString("message.noPermission.sell", "&cYou don't have permission to sell something."))); messages.add(new LocalizedMessage(Message.NO_PERMISSION_SELL, langConfig.getString("message.noPermission.sell", "&cYou don't have permission to sell something.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_BUY_HERE, langConfig.getString("message.noPermission.buy-here", "&cYou don't have permission to buy something here."))); messages.add(new LocalizedMessage(Message.NO_PERMISSION_BUY_HERE, langConfig.getString("message.noPermission.buy-here", "&cYou don't have permission to buy something here.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_SELL_HERE, langConfig.getString("message.noPermission.sell-here", "&cYou don't have permission to sell something here."))); messages.add(new LocalizedMessage(Message.NO_PERMISSION_SELL_HERE, langConfig.getString("message.noPermission.sell-here", "&cYou don't have permission to sell something here.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_REMOVE_OTHERS, langConfig.getString("message.noPermission.remove-others", "&cYou don't have permission to remove this shop."))); messages.add(new LocalizedMessage(Message.NO_PERMISSION_REMOVE_OTHERS, langConfig.getString("message.noPermission.remove-others", "&cYou don't have permission to remove this shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_REMOVE_ADMIN, langConfig.getString("message.noPermission.remove-admin", "&cYou don't have permission to remove an admin shop."))); messages.add(new LocalizedMessage(Message.NO_PERMISSION_REMOVE_ADMIN, langConfig.getString("message.noPermission.remove-admin", "&cYou don't have permission to remove an admin shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_RELOAD, langConfig.getString("message.noPermission.reload", "&cYou don't have permission to reload the shops."))); messages.add(new LocalizedMessage(Message.NO_PERMISSION_RELOAD, langConfig.getString("message.noPermission.reload", "&cYou don't have permission to reload the shops.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_UPDATE, langConfig.getString("message.noPermission.update", "&cYou don't have permission to check for updates."))); messages.add(new LocalizedMessage(Message.NO_PERMISSION_UPDATE, langConfig.getString("message.noPermission.update", "&cYou don't have permission to check for updates.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_CONFIG, langConfig.getString("message.noPermission.config", "&cYou don't have permission to change configuration values."))); messages.add(new LocalizedMessage(Message.NO_PERMISSION_CONFIG, langConfig.getString("message.noPermission.config", "&cYou don't have permission to change configuration values.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_EXTEND_OTHERS, langConfig.getString("message.noPermission.extend-others", "&cYou don't have permission to extend this chest."))); messages.add(new LocalizedMessage(Message.NO_PERMISSION_EXTEND_OTHERS, langConfig.getString("message.noPermission.extend-others", "&cYou don't have permission to extend this chest.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_PERMISSION_EXTEND_PROTECTED, langConfig.getString("message.noPermission.extend-protected", "&cYou don't have permission to extend this chest to here."))); messages.add(new LocalizedMessage(Message.NO_PERMISSION_EXTEND_PROTECTED, langConfig.getString("message.noPermission.extend-protected", "&cYou don't have permission to extend this chest to here.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_HEADER, langConfig.getString("message.commandDescription.header", "&6==== &c/%COMMAND% &6Help"))); messages.add(new LocalizedMessage(Message.COMMAND_DESC_HEADER, langConfig.getString("message.commandDescription.header", "&6==== &c/%COMMAND% &6Help")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_FOOTER, langConfig.getString("message.commandDescription.footer", "&6==== End"))); messages.add(new LocalizedMessage(Message.COMMAND_DESC_FOOTER, langConfig.getString("message.commandDescription.footer", "&6==== End")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_CREATE, langConfig.getString("message.commandDescription.create", "&a/%COMMAND% create <amount> <buy-price> <sell-price> - Create a shop."))); messages.add(new LocalizedMessage(Message.COMMAND_DESC_CREATE, langConfig.getString("message.commandDescription.create", "&a/%COMMAND% create <amount> <buy-price> <sell-price> - Create a shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_CREATE_ADMIN, langConfig.getString("message.commandDescription.create-admin", "&a/%COMMAND% create <amount> <buy-price> <sell-price> [normal|admin] - Create a shop."))); messages.add(new LocalizedMessage(Message.COMMAND_DESC_CREATE_ADMIN, langConfig.getString("message.commandDescription.create-admin", "&a/%COMMAND% create <amount> <buy-price> <sell-price> [normal|admin] - Create a shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_REMOVE, langConfig.getString("message.commandDescription.remove", "&a/%COMMAND% remove - Remove a shop."))); messages.add(new LocalizedMessage(Message.COMMAND_DESC_REMOVE, langConfig.getString("message.commandDescription.remove", "&a/%COMMAND% remove - Remove a shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_INFO, langConfig.getString("message.commandDescription.info", "&a/%COMMAND% info - Retrieve shop information."))); messages.add(new LocalizedMessage(Message.COMMAND_DESC_INFO, langConfig.getString("message.commandDescription.info", "&a/%COMMAND% info - Retrieve shop information.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_REMOVEALL, langConfig.getString("message.commandDescription.removeall", "&a/%COMMAND% removeall - Remove all shops of a player."))); messages.add(new LocalizedMessage(Message.COMMAND_DESC_REMOVEALL, langConfig.getString("message.commandDescription.removeall", "&a/%COMMAND% removeall - Remove all shops of a player.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_RELOAD, langConfig.getString("message.commandDescription.reload", "&a/%COMMAND% reload - Reload shops."))); messages.add(new LocalizedMessage(Message.COMMAND_DESC_RELOAD, langConfig.getString("message.commandDescription.reload", "&a/%COMMAND% reload - Reload shops.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_UPDATE, langConfig.getString("message.commandDescription.update", "&a/%COMMAND% update - Check for Updates."))); messages.add(new LocalizedMessage(Message.COMMAND_DESC_UPDATE, langConfig.getString("message.commandDescription.update", "&a/%COMMAND% update - Check for Updates.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_LIMITS, langConfig.getString("message.commandDescription.limits", "&a/%COMMAND% limits - View shop limits."))); messages.add(new LocalizedMessage(Message.COMMAND_DESC_LIMITS, langConfig.getString("message.commandDescription.limits", "&a/%COMMAND% limits - View shop limits.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_OPEN, langConfig.getString("message.commandDescription.open", "&a/%COMMAND% open - Open a shop."))); messages.add(new LocalizedMessage(Message.COMMAND_DESC_OPEN, langConfig.getString("message.commandDescription.open", "&a/%COMMAND% open - Open a shop.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.COMMAND_DESC_CONFIG, langConfig.getString("message.commandDescription.config", "&a/%COMMAND% config <set|get|remove> <property> <value> - Change configuration values."))); messages.add(new LocalizedMessage(Message.COMMAND_DESC_CONFIG, langConfig.getString("message.commandDescription.config", "&a/%COMMAND% config <set|get|remove> <property> <value> - Change configuration values.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.CHANGED_CONFIG_SET, langConfig.getString("message.config.set", "&6Changed &a%PROPERTY% &6to &a%VALUE%&6."))); messages.add(new LocalizedMessage(Message.CHANGED_CONFIG_SET, langConfig.getString("message.config.set", "&6Changed &a%PROPERTY% &6to &a%VALUE%&6.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.CHANGED_CONFIG_REMOVED, langConfig.getString("message.config.removed", "&6Removed &a%VALUE% &6from &a%PROPERTY%&6."))); messages.add(new LocalizedMessage(Message.CHANGED_CONFIG_REMOVED, langConfig.getString("message.config.removed", "&6Removed &a%VALUE% &6from &a%PROPERTY%&6.")));
messages.add(new LocalizedMessage(LocalizedMessage.Message.CHANGED_CONFIG_ADDED, langConfig.getString("message.config.added", "&6Added &a%VALUE% &6to &a%PROPERTY%&6."))); messages.add(new LocalizedMessage(Message.CHANGED_CONFIG_ADDED, langConfig.getString("message.config.added", "&6Added &a%VALUE% &6to &a%PROPERTY%&6.")));
} }
/** /**
@ -1124,10 +1125,10 @@ public class LanguageUtils {
if (Utils.getMajorVersion() < 9) { if (Utils.getMajorVersion() < 9) {
potionType = Potion.fromItemStack(stack).getType(); potionType = Potion.fromItemStack(stack).getType();
upgradeString = (Potion.fromItemStack(stack).getLevel() == 2 && plugin.getShopChestConfig().append_potion_level_to_item_name ? " II" : ""); upgradeString = (Potion.fromItemStack(stack).getLevel() == 2 && Config.appendPotionLevelToItemName ? " II" : "");
} else { } else {
potionType = meta.getBasePotionData().getType(); potionType = meta.getBasePotionData().getType();
upgradeString = (meta.getBasePotionData().isUpgraded() && plugin.getShopChestConfig().append_potion_level_to_item_name ? " II" : ""); upgradeString = (meta.getBasePotionData().isUpgraded() && Config.appendPotionLevelToItemName ? " II" : "");
} }
for (PotionName potionName : potionNames) { for (PotionName potionName : potionNames) {
@ -1302,22 +1303,22 @@ public class LanguageUtils {
/** /**
* @param message Message which should be translated * @param message Message which should be translated
* @param replacedPlaceholders Placeholders which might be required to be replaced in the message * @param replacements Replacements of placeholders which might be required to be replaced in the message
* @return Localized Message * @return Localized Message
*/ */
public static String getMessage(LocalizedMessage.Message message, LocalizedMessage.ReplacedPlaceholder... replacedPlaceholders) { public static String getMessage(Message message, Replacement... replacements) {
String finalMessage = ChatColor.RED + "An error occurred: Message not found: " + message.toString(); String finalMessage = ChatColor.RED + "An error occurred: Message not found: " + message.toString();
for (LocalizedMessage localizedMessage : messages) { for (LocalizedMessage localizedMessage : messages) {
if (localizedMessage.getMessage() == message) { if (localizedMessage.getMessage() == message) {
finalMessage = localizedMessage.getLocalizedString(); finalMessage = localizedMessage.getLocalizedString();
for (LocalizedMessage.ReplacedPlaceholder replacedPlaceholder : replacedPlaceholders) { for (Replacement replacement : replacements) {
Placeholder placeholder = replacedPlaceholder.getPlaceholder(); Placeholder placeholder = replacement.getPlaceholder();
String toReplace = replacedPlaceholder.getReplace(); String toReplace = replacement.getReplacement();
if (placeholder == Placeholder.BUY_PRICE || placeholder == Placeholder.SELL_PRICE || placeholder == Placeholder.MIN_PRICE || placeholder == Placeholder.CREATION_PRICE || placeholder == Placeholder.REVENUE) { if (placeholder == Placeholder.BUY_PRICE || placeholder == Placeholder.SELL_PRICE || placeholder == Placeholder.MIN_PRICE || placeholder == Placeholder.CREATION_PRICE || placeholder == Placeholder.REVENUE) {
if (!toReplace.equals(getMessage(LocalizedMessage.Message.SHOP_INFO_DISABLED))) { if (!toReplace.equals(getMessage(Message.SHOP_INFO_DISABLED))) {
double price = Double.parseDouble(toReplace); double price = Double.parseDouble(toReplace);
toReplace = plugin.getEconomy().format(price); toReplace = plugin.getEconomy().format(price);
} }

View File

@ -1,6 +1,5 @@
package de.epiceric.shopchest.language; package de.epiceric.shopchest.language;
import de.epiceric.shopchest.config.Placeholder;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
public class LocalizedMessage { public class LocalizedMessage {
@ -27,129 +26,4 @@ public class LocalizedMessage {
return localizedString; return localizedString;
} }
public enum Message {
SHOP_CREATED,
ADMIN_SHOP_CREATED,
CHEST_ALREADY_SHOP,
CHEST_BLOCKED,
DOUBLE_CHEST_BLOCKED,
SHOP_REMOVED,
ALL_SHOPS_REMOVED,
CHEST_NO_SHOP,
SHOP_CREATE_NOT_ENOUGH_MONEY,
SHOP_INFO_VENDOR,
SHOP_INFO_PRODUCT,
SHOP_INFO_STOCK,
SHOP_INFO_ENCHANTMENTS,
SHOP_INFO_POTION_EFFECT,
SHOP_INFO_MUSIC_TITLE,
SHOP_INFO_BOOK_GENERATION,
SHOP_INFO_NONE,
SHOP_INFO_PRICE,
SHOP_INFO_DISABLED,
SHOP_INFO_NORMAL,
SHOP_INFO_ADMIN,
SHOP_INFO_EXTENDED,
BUY_SELL_DISABLED,
BUY_SUCCESS,
BUY_SUCCESS_ADMIN,
SELL_SUCCESS,
SELL_SUCCESS_ADMIN,
SOMEONE_BOUGHT,
SOMEONE_SOLD,
REVENUE_WHILE_OFFLINE,
NOT_ENOUGH_INVENTORY_SPACE,
CHEST_NOT_ENOUGH_INVENTORY_SPACE,
NOT_ENOUGH_MONEY,
NOT_ENOUGH_ITEMS,
VENDOR_NOT_ENOUGH_MONEY,
OUT_OF_STOCK,
VENDOR_OUT_OF_STOCK,
ERROR_OCCURRED,
AMOUNT_PRICE_NOT_NUMBER,
AMOUNT_IS_ZERO,
PRICES_CONTAIN_DECIMALS,
NO_ITEM_IN_HAND,
CLICK_CHEST_CREATE,
CLICK_CHEST_REMOVE,
CLICK_CHEST_INFO,
CLICK_CHEST_OPEN,
CLICK_TO_CONFIRM,
OPENED_SHOP,
CANNOT_BREAK_SHOP,
CANNOT_SELL_BROKEN_ITEM,
BUY_PRICE_TOO_LOW,
SELL_PRICE_TOO_LOW,
BUY_PRICE_TOO_HIGH,
SELL_PRICE_TOO_HIGH,
BUYING_DISABLED,
SELLING_DISABLED,
RELOADED_SHOPS,
SHOP_LIMIT_REACHED,
OCCUPIED_SHOP_SLOTS,
CANNOT_SELL_ITEM,
USE_IN_CREATIVE,
UPDATE_AVAILABLE,
UPDATE_CLICK_TO_DOWNLOAD,
UPDATE_NO_UPDATE,
UPDATE_CHECKING,
UPDATE_ERROR,
NO_PERMISSION_CREATE,
NO_PERMISSION_CREATE_ADMIN,
NO_PERMISSION_CREATE_PROTECTED,
NO_PERMISSION_OPEN_OTHERS,
NO_PERMISSION_BUY,
NO_PERMISSION_SELL,
NO_PERMISSION_BUY_HERE,
NO_PERMISSION_SELL_HERE,
NO_PERMISSION_REMOVE_OTHERS,
NO_PERMISSION_REMOVE_ADMIN,
NO_PERMISSION_RELOAD,
NO_PERMISSION_UPDATE,
NO_PERMISSION_CONFIG,
NO_PERMISSION_EXTEND_OTHERS,
NO_PERMISSION_EXTEND_PROTECTED,
COMMAND_DESC_HEADER,
COMMAND_DESC_FOOTER,
COMMAND_DESC_CREATE,
COMMAND_DESC_CREATE_ADMIN,
COMMAND_DESC_REMOVE,
COMMAND_DESC_INFO,
COMMAND_DESC_REMOVEALL,
COMMAND_DESC_RELOAD,
COMMAND_DESC_UPDATE,
COMMAND_DESC_LIMITS,
COMMAND_DESC_OPEN,
COMMAND_DESC_CONFIG,
CHANGED_CONFIG_SET,
CHANGED_CONFIG_REMOVED,
CHANGED_CONFIG_ADDED
}
public static class ReplacedPlaceholder {
private Placeholder placeholder;
private String replace;
public ReplacedPlaceholder(Placeholder placeholder, String replace) {
this.placeholder = placeholder;
this.replace = replace;
}
/**
* @return String which will replace the placeholder
*/
public String getReplace() {
return replace;
}
/**
* @return Placeholder that will be replaced
*/
public Placeholder getPlaceholder() {
return placeholder;
}
}
} }

View File

@ -0,0 +1,100 @@
package de.epiceric.shopchest.language;
public enum Message {
SHOP_CREATED,
ADMIN_SHOP_CREATED,
CHEST_ALREADY_SHOP,
CHEST_BLOCKED,
DOUBLE_CHEST_BLOCKED,
SHOP_REMOVED,
ALL_SHOPS_REMOVED,
CHEST_NO_SHOP,
SHOP_CREATE_NOT_ENOUGH_MONEY,
SHOP_INFO_VENDOR,
SHOP_INFO_PRODUCT,
SHOP_INFO_STOCK,
SHOP_INFO_ENCHANTMENTS,
SHOP_INFO_POTION_EFFECT,
SHOP_INFO_MUSIC_TITLE,
SHOP_INFO_BOOK_GENERATION,
SHOP_INFO_NONE,
SHOP_INFO_PRICE,
SHOP_INFO_DISABLED,
SHOP_INFO_NORMAL,
SHOP_INFO_ADMIN,
SHOP_INFO_EXTENDED,
BUY_SELL_DISABLED,
BUY_SUCCESS,
BUY_SUCCESS_ADMIN,
SELL_SUCCESS,
SELL_SUCCESS_ADMIN,
SOMEONE_BOUGHT,
SOMEONE_SOLD,
REVENUE_WHILE_OFFLINE,
NOT_ENOUGH_INVENTORY_SPACE,
CHEST_NOT_ENOUGH_INVENTORY_SPACE,
NOT_ENOUGH_MONEY,
NOT_ENOUGH_ITEMS,
VENDOR_NOT_ENOUGH_MONEY,
OUT_OF_STOCK,
VENDOR_OUT_OF_STOCK,
ERROR_OCCURRED,
AMOUNT_PRICE_NOT_NUMBER,
AMOUNT_IS_ZERO,
PRICES_CONTAIN_DECIMALS,
NO_ITEM_IN_HAND,
CLICK_CHEST_CREATE,
CLICK_CHEST_REMOVE,
CLICK_CHEST_INFO,
CLICK_CHEST_OPEN,
CLICK_TO_CONFIRM,
OPENED_SHOP,
CANNOT_BREAK_SHOP,
CANNOT_SELL_BROKEN_ITEM,
BUY_PRICE_TOO_LOW,
SELL_PRICE_TOO_LOW,
BUY_PRICE_TOO_HIGH,
SELL_PRICE_TOO_HIGH,
BUYING_DISABLED,
SELLING_DISABLED,
RELOADED_SHOPS,
SHOP_LIMIT_REACHED,
OCCUPIED_SHOP_SLOTS,
CANNOT_SELL_ITEM,
USE_IN_CREATIVE,
UPDATE_AVAILABLE,
UPDATE_CLICK_TO_DOWNLOAD,
UPDATE_NO_UPDATE,
UPDATE_CHECKING,
UPDATE_ERROR,
NO_PERMISSION_CREATE,
NO_PERMISSION_CREATE_ADMIN,
NO_PERMISSION_CREATE_PROTECTED,
NO_PERMISSION_OPEN_OTHERS,
NO_PERMISSION_BUY,
NO_PERMISSION_SELL,
NO_PERMISSION_BUY_HERE,
NO_PERMISSION_SELL_HERE,
NO_PERMISSION_REMOVE_OTHERS,
NO_PERMISSION_REMOVE_ADMIN,
NO_PERMISSION_RELOAD,
NO_PERMISSION_UPDATE,
NO_PERMISSION_CONFIG,
NO_PERMISSION_EXTEND_OTHERS,
NO_PERMISSION_EXTEND_PROTECTED,
COMMAND_DESC_HEADER,
COMMAND_DESC_FOOTER,
COMMAND_DESC_CREATE,
COMMAND_DESC_CREATE_ADMIN,
COMMAND_DESC_REMOVE,
COMMAND_DESC_INFO,
COMMAND_DESC_REMOVEALL,
COMMAND_DESC_RELOAD,
COMMAND_DESC_UPDATE,
COMMAND_DESC_LIMITS,
COMMAND_DESC_OPEN,
COMMAND_DESC_CONFIG,
CHANGED_CONFIG_SET,
CHANGED_CONFIG_REMOVED,
CHANGED_CONFIG_ADDED
}

View File

@ -0,0 +1,29 @@
package de.epiceric.shopchest.language;
import de.epiceric.shopchest.config.Placeholder;
public class Replacement {
private Placeholder placeholder;
private String replacement;
public Replacement(Placeholder placeholder, String replacement) {
this.placeholder = placeholder;
this.replacement = replacement;
}
/**
* @return String which will replace the placeholder
*/
public String getReplacement() {
return replacement;
}
/**
* @return Placeholder that will be replaced
*/
public Placeholder getPlaceholder() {
return placeholder;
}
}

View File

@ -16,37 +16,35 @@ import org.bukkit.event.Listener;
public class AreaShopListener implements Listener { public class AreaShopListener implements Listener {
private ShopChest plugin; private ShopChest plugin;
private Config config;
public AreaShopListener(ShopChest plugin) { public AreaShopListener(ShopChest plugin) {
this.plugin = plugin; this.plugin = plugin;
this.config = plugin.getShopChestConfig();
} }
@EventHandler @EventHandler
public void onRegionDeleted(DeletedRegionEvent e) { public void onRegionDeleted(DeletedRegionEvent e) {
if (config.enable_areashop_integration && config.areashop_remove_shop_events.contains("DELETE")) { if (Config.enableAreaShopIntegration && Config.areashopRemoveShopEvents.contains("DELETE")) {
removeShopsInRegion(e.getRegion()); removeShopsInRegion(e.getRegion());
} }
} }
@EventHandler @EventHandler
public void onRegionUnrented(UnrentedRegionEvent e) { public void onRegionUnrented(UnrentedRegionEvent e) {
if (config.enable_areashop_integration && config.areashop_remove_shop_events.contains("UNRENT")) { if (Config.enableAreaShopIntegration && Config.areashopRemoveShopEvents.contains("UNRENT")) {
removeShopsInRegion(e.getRegion()); removeShopsInRegion(e.getRegion());
} }
} }
@EventHandler @EventHandler
public void onRegionResold(ResoldRegionEvent e) { public void onRegionResold(ResoldRegionEvent e) {
if (config.enable_areashop_integration && config.areashop_remove_shop_events.contains("RESELL")) { if (Config.enableAreaShopIntegration && Config.areashopRemoveShopEvents.contains("RESELL")) {
removeShopsInRegion(e.getRegion()); removeShopsInRegion(e.getRegion());
} }
} }
@EventHandler @EventHandler
public void onRegionSold(SoldRegionEvent e) { public void onRegionSold(SoldRegionEvent e) {
if (config.enable_areashop_integration && config.areashop_remove_shop_events.contains("SELL")) { if (Config.enableAreaShopIntegration && Config.areashopRemoveShopEvents.contains("SELL")) {
removeShopsInRegion(e.getRegion()); removeShopsInRegion(e.getRegion());
} }
} }

View File

@ -1,6 +1,7 @@
package de.epiceric.shopchest.listeners; package de.epiceric.shopchest.listeners;
import de.epiceric.shopchest.ShopChest; import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -19,7 +20,7 @@ public class BlockExplodeListener implements Listener {
@EventHandler @EventHandler
public void onBlockExplode(BlockExplodeEvent e) { public void onBlockExplode(BlockExplodeEvent e) {
if (plugin.getShopChestConfig().explosion_protection) { if (Config.explosionProtection) {
ArrayList<Block> bl = new ArrayList<>(e.blockList()); ArrayList<Block> bl = new ArrayList<>(e.blockList());
for (Block b : bl) { for (Block b : bl) {
if (b.getType().equals(Material.CHEST) || b.getType().equals(Material.TRAPPED_CHEST)) { if (b.getType().equals(Material.CHEST) || b.getType().equals(Material.TRAPPED_CHEST)) {

View File

@ -14,7 +14,7 @@ import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.external.PlotSquaredShopFlag; import de.epiceric.shopchest.external.PlotSquaredShopFlag;
import de.epiceric.shopchest.external.WorldGuardShopFlag; import de.epiceric.shopchest.external.WorldGuardShopFlag;
import de.epiceric.shopchest.language.LanguageUtils; import de.epiceric.shopchest.language.LanguageUtils;
import de.epiceric.shopchest.language.LocalizedMessage; import de.epiceric.shopchest.language.Message;
import de.epiceric.shopchest.nms.Hologram; import de.epiceric.shopchest.nms.Hologram;
import de.epiceric.shopchest.shop.Shop; import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.utils.Callback; import de.epiceric.shopchest.utils.Callback;
@ -49,13 +49,11 @@ public class ChestProtectListener implements Listener {
private ShopChest plugin; private ShopChest plugin;
private ShopUtils shopUtils; private ShopUtils shopUtils;
private Config config;
private WorldGuardPlugin worldGuard; private WorldGuardPlugin worldGuard;
public ChestProtectListener(ShopChest plugin, WorldGuardPlugin worldGuard) { public ChestProtectListener(ShopChest plugin, WorldGuardPlugin worldGuard) {
this.plugin = plugin; this.plugin = plugin;
this.shopUtils = plugin.getShopUtils(); this.shopUtils = plugin.getShopUtils();
this.config = plugin.getShopChestConfig();
this.worldGuard = worldGuard; this.worldGuard = worldGuard;
} }
@ -78,7 +76,7 @@ public class ChestProtectListener implements Listener {
} else { } else {
shopUtils.removeShop(shop, true); shopUtils.removeShop(shop, true);
plugin.debug(String.format("%s broke %s's shop (#%d)", p.getName(), shop.getVendor().getName(), shop.getID())); plugin.debug(String.format("%s broke %s's shop (#%d)", p.getName(), shop.getVendor().getName(), shop.getID()));
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_REMOVED)); p.sendMessage(LanguageUtils.getMessage(Message.SHOP_REMOVED));
} }
} }
@ -111,13 +109,13 @@ public class ChestProtectListener implements Listener {
} }
e.setCancelled(true); e.setCancelled(true);
e.getPlayer().sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CANNOT_BREAK_SHOP)); e.getPlayer().sendMessage(LanguageUtils.getMessage(Message.CANNOT_BREAK_SHOP));
} }
} }
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onEntityExplode(EntityExplodeEvent e) { public void onEntityExplode(EntityExplodeEvent e) {
if (config.explosion_protection) { if (Config.explosionProtection) {
ArrayList<Block> bl = new ArrayList<>(e.blockList()); ArrayList<Block> bl = new ArrayList<>(e.blockList());
for (Block b : bl) { for (Block b : bl) {
if (b.getType().equals(Material.CHEST) || b.getType().equals(Material.TRAPPED_CHEST)) { if (b.getType().equals(Material.CHEST) || b.getType().equals(Material.TRAPPED_CHEST)) {
@ -156,13 +154,13 @@ public class ChestProtectListener implements Listener {
boolean externalPluginsAllowed = true; boolean externalPluginsAllowed = true;
if (plugin.hasWorldGuard() && config.enable_worldguard_integration) { if (plugin.hasWorldGuard() && Config.enableWorldGuardIntegration) {
RegionContainer container = worldGuard.getRegionContainer(); RegionContainer container = worldGuard.getRegionContainer();
RegionQuery query = container.createQuery(); RegionQuery query = container.createQuery();
externalPluginsAllowed = query.testState(b.getLocation(), p, WorldGuardShopFlag.CREATE_SHOP); externalPluginsAllowed = query.testState(b.getLocation(), p, WorldGuardShopFlag.CREATE_SHOP);
} }
if (externalPluginsAllowed && plugin.hasTowny() && config.enable_towny_integration) { if (externalPluginsAllowed && plugin.hasTowny() && Config.enableTownyIntegration) {
TownBlock townBlock = TownyUniverse.getTownBlock(b.getLocation()); TownBlock townBlock = TownyUniverse.getTownBlock(b.getLocation());
if (townBlock != null) { if (townBlock != null) {
try { try {
@ -170,11 +168,11 @@ public class ChestProtectListener implements Listener {
for (Resident resident : town.getResidents()) { for (Resident resident : town.getResidents()) {
if (resident.getName().equals(p.getName())) { if (resident.getName().equals(p.getName())) {
if (resident.isMayor()) { if (resident.isMayor()) {
externalPluginsAllowed = (config.towny_shop_plots_mayor.contains(townBlock.getType().name())); externalPluginsAllowed = (Config.townyShopPlotsMayor.contains(townBlock.getType().name()));
} else if (resident.isKing()) { } else if (resident.isKing()) {
externalPluginsAllowed = (config.towny_shop_plots_king.contains(townBlock.getType().name())); externalPluginsAllowed = (Config.townyShopPlotsKing.contains(townBlock.getType().name()));
} else { } else {
externalPluginsAllowed = (config.towny_shop_plots_residents.contains(townBlock.getType().name())); externalPluginsAllowed = (Config.townyShopPlotsResidents.contains(townBlock.getType().name()));
} }
break; break;
} }
@ -185,21 +183,21 @@ public class ChestProtectListener implements Listener {
} }
} }
if (externalPluginsAllowed && plugin.hasPlotSquared() && config.enable_plotsquared_integration) { if (externalPluginsAllowed && plugin.hasPlotSquared() && Config.enablePlotsquaredIntegration) {
com.intellectualcrafters.plot.object.Location loc = com.intellectualcrafters.plot.object.Location loc =
new com.intellectualcrafters.plot.object.Location(b.getWorld().getName(), b.getX(), b.getY(), b.getZ()); new com.intellectualcrafters.plot.object.Location(b.getWorld().getName(), b.getX(), b.getY(), b.getZ());
externalPluginsAllowed = Utils.isFlagAllowedOnPlot(loc.getOwnedPlot(), PlotSquaredShopFlag.CREATE_SHOP, p); externalPluginsAllowed = Utils.isFlagAllowedOnPlot(loc.getOwnedPlot(), PlotSquaredShopFlag.CREATE_SHOP, p);
} }
if (externalPluginsAllowed && plugin.hasUSkyBlock() && config.enable_uskyblock_integration) { if (externalPluginsAllowed && plugin.hasUSkyBlock() && Config.enableUSkyblockIntegration) {
IslandInfo islandInfo = plugin.getUSkyBlock().getIslandInfo(b.getLocation()); IslandInfo islandInfo = plugin.getUSkyBlock().getIslandInfo(b.getLocation());
if (islandInfo != null) { if (islandInfo != null) {
externalPluginsAllowed = islandInfo.getMembers().contains(p.getName()) || islandInfo.getLeader().equals(p.getName()); externalPluginsAllowed = islandInfo.getMembers().contains(p.getName()) || islandInfo.getLeader().equals(p.getName());
} }
} }
if (externalPluginsAllowed && plugin.hasASkyBlock() && config.enable_askyblock_integration) { if (externalPluginsAllowed && plugin.hasASkyBlock() && Config.enableASkyblockIntegration) {
Island island = ASkyBlockAPI.getInstance().getIslandAt(b.getLocation()); Island island = ASkyBlockAPI.getInstance().getIslandAt(b.getLocation());
if (island != null) { if (island != null) {
if (island.getOwner() == null) { if (island.getOwner() == null) {
@ -210,13 +208,13 @@ public class ChestProtectListener implements Listener {
} }
} }
if (externalPluginsAllowed && plugin.hasIslandWorld() && config.enable_islandworld_integration && IslandWorldApi.isInitialized()) { if (externalPluginsAllowed && plugin.hasIslandWorld() && Config.enableIslandWorldIntegration && IslandWorldApi.isInitialized()) {
if (b.getWorld().getName().equals(IslandWorldApi.getIslandWorld().getName())) { if (b.getWorld().getName().equals(IslandWorldApi.getIslandWorld().getName())) {
externalPluginsAllowed = IslandWorldApi.canBuildOnLocation(p, b.getLocation(), true); externalPluginsAllowed = IslandWorldApi.canBuildOnLocation(p, b.getLocation(), true);
} }
} }
if (externalPluginsAllowed && plugin.hasGriefPrevention() && config.enable_griefprevention_integration) { if (externalPluginsAllowed && plugin.hasGriefPrevention() && Config.enableGriefPreventionIntegration) {
Claim claim = plugin.getGriefPrevention().dataStore.getClaimAt(b.getLocation(), false, null); Claim claim = plugin.getGriefPrevention().dataStore.getClaimAt(b.getLocation(), false, null);
if (claim != null) { if (claim != null) {
externalPluginsAllowed = claim.allowContainers(p) == null; externalPluginsAllowed = claim.allowContainers(p) == null;
@ -238,15 +236,15 @@ public class ChestProtectListener implements Listener {
}); });
} else { } else {
e.setCancelled(true); e.setCancelled(true);
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CHEST_BLOCKED)); p.sendMessage(LanguageUtils.getMessage(Message.CHEST_BLOCKED));
} }
} else { } else {
e.setCancelled(true); e.setCancelled(true);
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_EXTEND_OTHERS)); p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_EXTEND_OTHERS));
} }
} else { } else {
e.setCancelled(true); e.setCancelled(true);
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_EXTEND_PROTECTED)); p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_EXTEND_PROTECTED));
} }
} }
@ -267,7 +265,7 @@ public class ChestProtectListener implements Listener {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onItemMove(InventoryMoveItemEvent e) { public void onItemMove(InventoryMoveItemEvent e) {
if (config.hopper_protection) { if (Config.hopperProtection) {
if ((e.getSource().getType().equals(InventoryType.CHEST)) && (!e.getInitiator().getType().equals(InventoryType.PLAYER))) { if ((e.getSource().getType().equals(InventoryType.CHEST)) && (!e.getInitiator().getType().equals(InventoryType.PLAYER))) {
if (e.getSource().getHolder() instanceof DoubleChest) { if (e.getSource().getHolder() instanceof DoubleChest) {

View File

@ -1,18 +1,20 @@
package de.epiceric.shopchest.listeners; package de.epiceric.shopchest.listeners;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Placeholder;
import de.epiceric.shopchest.language.LanguageUtils;
import de.epiceric.shopchest.language.LocalizedMessage;
import de.epiceric.shopchest.nms.JsonBuilder;
import de.epiceric.shopchest.utils.Callback;
import de.epiceric.shopchest.utils.Permissions;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Placeholder;
import de.epiceric.shopchest.language.LanguageUtils;
import de.epiceric.shopchest.language.Message;
import de.epiceric.shopchest.language.Replacement;
import de.epiceric.shopchest.nms.JsonBuilder;
import de.epiceric.shopchest.utils.Callback;
import de.epiceric.shopchest.utils.Permissions;
public class NotifyPlayerOnJoinListener implements Listener { public class NotifyPlayerOnJoinListener implements Listener {
private ShopChest plugin; private ShopChest plugin;
@ -27,7 +29,7 @@ public class NotifyPlayerOnJoinListener implements Listener {
if (plugin.isUpdateNeeded()) { if (plugin.isUpdateNeeded()) {
if (p.hasPermission(Permissions.UPDATE_NOTIFICATION)) { if (p.hasPermission(Permissions.UPDATE_NOTIFICATION)) {
JsonBuilder jb = new JsonBuilder(plugin, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedPlaceholder(Placeholder.VERSION, plugin.getLatestVersion())), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), plugin.getDownloadLink()); JsonBuilder jb = new JsonBuilder(plugin, LanguageUtils.getMessage(Message.UPDATE_AVAILABLE, new Replacement(Placeholder.VERSION, plugin.getLatestVersion())), LanguageUtils.getMessage(Message.UPDATE_CLICK_TO_DOWNLOAD), plugin.getDownloadLink());
jb.sendJson(p); jb.sendJson(p);
} }
} }
@ -36,8 +38,8 @@ public class NotifyPlayerOnJoinListener implements Listener {
@Override @Override
public void onResult(Long result) { public void onResult(Long result) {
if (result < 0) { if (result < 0) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, p.sendMessage(LanguageUtils.getMessage(Message.ERROR_OCCURRED,
new LocalizedMessage.ReplacedPlaceholder(Placeholder.ERROR, "Could not get last time you logged out"))); new Replacement(Placeholder.ERROR, "Could not get last time you logged out")));
return; return;
} }
@ -45,8 +47,8 @@ public class NotifyPlayerOnJoinListener implements Listener {
@Override @Override
public void onResult(Double result) { public void onResult(Double result) {
if (result != 0) { if (result != 0) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.REVENUE_WHILE_OFFLINE, p.sendMessage(LanguageUtils.getMessage(Message.REVENUE_WHILE_OFFLINE,
new LocalizedMessage.ReplacedPlaceholder(Placeholder.REVENUE, String.valueOf(result)))); new Replacement(Placeholder.REVENUE, String.valueOf(result))));
} }
} }
}); });

View File

@ -23,7 +23,8 @@ import de.epiceric.shopchest.event.ShopRemoveEvent;
import de.epiceric.shopchest.external.PlotSquaredShopFlag; import de.epiceric.shopchest.external.PlotSquaredShopFlag;
import de.epiceric.shopchest.external.WorldGuardShopFlag; import de.epiceric.shopchest.external.WorldGuardShopFlag;
import de.epiceric.shopchest.language.LanguageUtils; import de.epiceric.shopchest.language.LanguageUtils;
import de.epiceric.shopchest.language.LocalizedMessage; import de.epiceric.shopchest.language.Message;
import de.epiceric.shopchest.language.Replacement;
import de.epiceric.shopchest.nms.CustomBookMeta; import de.epiceric.shopchest.nms.CustomBookMeta;
import de.epiceric.shopchest.nms.Hologram; import de.epiceric.shopchest.nms.Hologram;
import de.epiceric.shopchest.shop.Shop; import de.epiceric.shopchest.shop.Shop;
@ -81,7 +82,6 @@ public class ShopInteractListener implements Listener {
private Economy econ; private Economy econ;
private Database database; private Database database;
private ShopUtils shopUtils; private ShopUtils shopUtils;
private Config config;
private WorldGuardPlugin worldGuard; private WorldGuardPlugin worldGuard;
public ShopInteractListener(ShopChest plugin) { public ShopInteractListener(ShopChest plugin) {
@ -89,7 +89,6 @@ public class ShopInteractListener implements Listener {
this.econ = plugin.getEconomy(); this.econ = plugin.getEconomy();
this.database = plugin.getShopDatabase(); this.database = plugin.getShopDatabase();
this.shopUtils = plugin.getShopUtils(); this.shopUtils = plugin.getShopUtils();
this.config = plugin.getShopChestConfig();
this.worldGuard = plugin.getWorldGuard(); this.worldGuard = plugin.getWorldGuard();
} }
@ -136,7 +135,7 @@ public class ShopInteractListener implements Listener {
Player p = e.getPlayer(); Player p = e.getPlayer();
Block b = e.getClickedBlock(); Block b = e.getClickedBlock();
if (config.enable_authme_integration && plugin.hasAuthMe() && !AuthMe.getApi().isAuthenticated(p)) return; if (Config.enableAuthMeIntegration && plugin.hasAuthMe() && !AuthMe.getApi().isAuthenticated(p)) return;
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) { if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (b.getType().equals(Material.CHEST) || b.getType().equals(Material.TRAPPED_CHEST)) { if (b.getType().equals(Material.CHEST) || b.getType().equals(Material.TRAPPED_CHEST)) {
@ -158,7 +157,7 @@ public class ShopInteractListener implements Listener {
String denyReason = "Event Cancelled"; String denyReason = "Event Cancelled";
if (plugin.hasWorldGuard() && config.enable_worldguard_integration) { if (plugin.hasWorldGuard() && Config.enableWorldGuardIntegration) {
plugin.debug("Checking if WorldGuard allows shop creation..."); plugin.debug("Checking if WorldGuard allows shop creation...");
RegionContainer container = worldGuard.getRegionContainer(); RegionContainer container = worldGuard.getRegionContainer();
RegionQuery query = container.createQuery(); RegionQuery query = container.createQuery();
@ -172,7 +171,7 @@ public class ShopInteractListener implements Listener {
if (!externalPluginsAllowed) denyReason = "WorldGuard"; if (!externalPluginsAllowed) denyReason = "WorldGuard";
} }
if (externalPluginsAllowed && plugin.hasTowny() && config.enable_towny_integration) { if (externalPluginsAllowed && plugin.hasTowny() && Config.enableTownyIntegration) {
plugin.debug("Checking if Towny allows shop creation..."); plugin.debug("Checking if Towny allows shop creation...");
for (Location loc : chestLocations) { for (Location loc : chestLocations) {
if (loc != null) { if (loc != null) {
@ -187,13 +186,13 @@ public class ShopInteractListener implements Listener {
residentFound = true; residentFound = true;
if (resident.isMayor()) { if (resident.isMayor()) {
plugin.debug(p.getName() + " is mayor of town"); plugin.debug(p.getName() + " is mayor of town");
externalPluginsAllowed &= (config.towny_shop_plots_mayor.contains(townBlock.getType().name())); externalPluginsAllowed &= (Config.townyShopPlotsMayor.contains(townBlock.getType().name()));
} else if (resident.isKing()) { } else if (resident.isKing()) {
plugin.debug(p.getName() + " is king of town"); plugin.debug(p.getName() + " is king of town");
externalPluginsAllowed &= (config.towny_shop_plots_king.contains(townBlock.getType().name())); externalPluginsAllowed &= (Config.townyShopPlotsKing.contains(townBlock.getType().name()));
} else { } else {
plugin.debug(p.getName() + " is resident in town"); plugin.debug(p.getName() + " is resident in town");
externalPluginsAllowed &= (config.towny_shop_plots_residents.contains(townBlock.getType().name())); externalPluginsAllowed &= (Config.townyShopPlotsResidents.contains(townBlock.getType().name()));
} }
break; break;
} }
@ -212,7 +211,7 @@ public class ShopInteractListener implements Listener {
if (!externalPluginsAllowed) denyReason = "Towny"; if (!externalPluginsAllowed) denyReason = "Towny";
} }
if (externalPluginsAllowed && plugin.hasPlotSquared() && config.enable_plotsquared_integration) { if (externalPluginsAllowed && plugin.hasPlotSquared() && Config.enablePlotsquaredIntegration) {
plugin.debug("Checking if PlotSquared allows shop creation..."); plugin.debug("Checking if PlotSquared allows shop creation...");
for (Location loc : chestLocations) { for (Location loc : chestLocations) {
if (loc != null) { if (loc != null) {
@ -227,7 +226,7 @@ public class ShopInteractListener implements Listener {
if (!externalPluginsAllowed) denyReason = "PlotSquared"; if (!externalPluginsAllowed) denyReason = "PlotSquared";
} }
if (externalPluginsAllowed && plugin.hasUSkyBlock() && config.enable_uskyblock_integration) { if (externalPluginsAllowed && plugin.hasUSkyBlock() && Config.enableUSkyblockIntegration) {
plugin.debug("Checking if uSkyBlock allows shop creation..."); plugin.debug("Checking if uSkyBlock allows shop creation...");
for (Location loc : chestLocations) { for (Location loc : chestLocations) {
if (loc != null) { if (loc != null) {
@ -242,7 +241,7 @@ public class ShopInteractListener implements Listener {
if (!externalPluginsAllowed) denyReason = "uSkyBlock"; if (!externalPluginsAllowed) denyReason = "uSkyBlock";
} }
if (externalPluginsAllowed && plugin.hasASkyBlock() && config.enable_askyblock_integration) { if (externalPluginsAllowed && plugin.hasASkyBlock() && Config.enableASkyblockIntegration) {
plugin.debug("Checking if ASkyBlock allows shop creation..."); plugin.debug("Checking if ASkyBlock allows shop creation...");
for (Location loc : chestLocations) { for (Location loc : chestLocations) {
if (loc != null) { if (loc != null) {
@ -262,7 +261,7 @@ public class ShopInteractListener implements Listener {
if (!externalPluginsAllowed) denyReason = "ASkyBlock"; if (!externalPluginsAllowed) denyReason = "ASkyBlock";
} }
if (externalPluginsAllowed && plugin.hasIslandWorld() && config.enable_islandworld_integration && IslandWorldApi.isInitialized()) { if (externalPluginsAllowed && plugin.hasIslandWorld() && Config.enableIslandWorldIntegration && IslandWorldApi.isInitialized()) {
plugin.debug("Checking if IslandWorld allows shop creation..."); plugin.debug("Checking if IslandWorld allows shop creation...");
for (Location loc : chestLocations) { for (Location loc : chestLocations) {
if (loc != null) { if (loc != null) {
@ -276,7 +275,7 @@ public class ShopInteractListener implements Listener {
if (!externalPluginsAllowed) denyReason = "IslandWorld"; if (!externalPluginsAllowed) denyReason = "IslandWorld";
} }
if (externalPluginsAllowed && plugin.hasGriefPrevention() && config.enable_griefprevention_integration) { if (externalPluginsAllowed && plugin.hasGriefPrevention() && Config.enableGriefPreventionIntegration) {
plugin.debug("Checking if GriefPrevention allows shop creation..."); plugin.debug("Checking if GriefPrevention allows shop creation...");
String gpDenyReason = null; String gpDenyReason = null;
for (Location loc : chestLocations) { for (Location loc : chestLocations) {
@ -294,7 +293,7 @@ public class ShopInteractListener implements Listener {
} }
if ((e.isCancelled() || !externalPluginsAllowed) && !p.hasPermission(Permissions.CREATE_PROTECTED)) { if ((e.isCancelled() || !externalPluginsAllowed) && !p.hasPermission(Permissions.CREATE_PROTECTED)) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_CREATE_PROTECTED)); p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_CREATE_PROTECTED));
ClickType.removePlayerClickType(p); ClickType.removePlayerClickType(p);
plugin.debug(p.getName() + " is not allowed to create a shop on the selected chest because " + denyReason); plugin.debug(p.getName() + " is not allowed to create a shop on the selected chest because " + denyReason);
e.setCancelled(true); e.setCancelled(true);
@ -312,12 +311,12 @@ public class ShopInteractListener implements Listener {
create(p, b.getLocation(), product, buyPrice, sellPrice, shopType); create(p, b.getLocation(), product, buyPrice, sellPrice, shopType);
} else { } else {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CHEST_BLOCKED)); p.sendMessage(LanguageUtils.getMessage(Message.CHEST_BLOCKED));
plugin.debug("Chest is blocked"); plugin.debug("Chest is blocked");
} }
} else { } else {
e.setCancelled(true); e.setCancelled(true);
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CHEST_ALREADY_SHOP)); p.sendMessage(LanguageUtils.getMessage(Message.CHEST_ALREADY_SHOP));
plugin.debug("Chest is already a shop"); plugin.debug("Chest is already a shop");
} }
@ -334,7 +333,7 @@ public class ShopInteractListener implements Listener {
private void handleInteractEvent(PlayerInteractEvent e) { private void handleInteractEvent(PlayerInteractEvent e) {
Block b = e.getClickedBlock(); Block b = e.getClickedBlock();
Player p = e.getPlayer(); Player p = e.getPlayer();
boolean inverted = config.invert_mouse_buttons; boolean inverted = Config.invertMouseButtons;
if (Utils.getMajorVersion() >= 9) { if (Utils.getMajorVersion() >= 9) {
if (e.getHand() == EquipmentSlot.OFF_HAND) return; if (e.getHand() == EquipmentSlot.OFF_HAND) return;
@ -362,14 +361,14 @@ public class ShopInteractListener implements Listener {
if (p.hasPermission(Permissions.REMOVE_ADMIN)) { if (p.hasPermission(Permissions.REMOVE_ADMIN)) {
remove(p, shop); remove(p, shop);
} else { } else {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_REMOVE_ADMIN)); p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_REMOVE_ADMIN));
plugin.debug(p.getName() + " is not permitted to remove an admin shop"); plugin.debug(p.getName() + " is not permitted to remove an admin shop");
} }
} else { } else {
if (shop.getVendor().getUniqueId().equals(p.getUniqueId()) || p.hasPermission(Permissions.REMOVE_OTHER)) { if (shop.getVendor().getUniqueId().equals(p.getUniqueId()) || p.hasPermission(Permissions.REMOVE_OTHER)) {
remove(p, shop); remove(p, shop);
} else { } else {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_REMOVE_OTHERS)); p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_REMOVE_OTHERS));
plugin.debug(p.getName() + " is not permitted to remove another player's shop"); plugin.debug(p.getName() + " is not permitted to remove another player's shop");
} }
} }
@ -383,7 +382,7 @@ public class ShopInteractListener implements Listener {
if (p.getUniqueId().equals(shop.getVendor().getUniqueId()) || p.hasPermission(Permissions.OPEN_OTHER)) { if (p.getUniqueId().equals(shop.getVendor().getUniqueId()) || p.hasPermission(Permissions.OPEN_OTHER)) {
open(p, shop, true); open(p, shop, true);
} else { } else {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_OPEN_OTHERS)); p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_OPEN_OTHERS));
plugin.debug(p.getName() + " is not permitted to open another player's shop"); plugin.debug(p.getName() + " is not permitted to open another player's shop");
} }
@ -391,7 +390,7 @@ public class ShopInteractListener implements Listener {
break; break;
} }
} else { } else {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CHEST_NO_SHOP)); p.sendMessage(LanguageUtils.getMessage(Message.CHEST_NO_SHOP));
plugin.debug("Chest is not a shop"); plugin.debug("Chest is not a shop");
} }
} }
@ -405,7 +404,7 @@ public class ShopInteractListener implements Listener {
return; return;
} }
ItemStack infoItem = config.shop_info_item; ItemStack infoItem = Config.shopInfoItem;
if (infoItem != null) { if (infoItem != null) {
if (e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_BLOCK) { if (e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_BLOCK) {
ItemStack item = Utils.getItemInMainHand(p); ItemStack item = Utils.getItemInMainHand(p);
@ -432,7 +431,7 @@ public class ShopInteractListener implements Listener {
if (p.getGameMode() == GameMode.CREATIVE) { if (p.getGameMode() == GameMode.CREATIVE) {
e.setCancelled(true); e.setCancelled(true);
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.USE_IN_CREATIVE)); p.sendMessage(LanguageUtils.getMessage(Message.USE_IN_CREATIVE));
return; return;
} }
@ -446,7 +445,7 @@ public class ShopInteractListener implements Listener {
if (p.hasPermission(Permissions.BUY)) { if (p.hasPermission(Permissions.BUY)) {
boolean externalPluginsAllowed = true; boolean externalPluginsAllowed = true;
if (plugin.hasPlotSquared() && config.enable_plotsquared_integration) { if (plugin.hasPlotSquared() && Config.enablePlotsquaredIntegration) {
com.intellectualcrafters.plot.object.Location plotLocation = com.intellectualcrafters.plot.object.Location plotLocation =
new com.intellectualcrafters.plot.object.Location(b.getWorld().getName(), b.getX(), b.getY(), b.getZ()); new com.intellectualcrafters.plot.object.Location(b.getWorld().getName(), b.getX(), b.getY(), b.getZ());
@ -456,7 +455,7 @@ public class ShopInteractListener implements Listener {
externalPluginsAllowed = Utils.isFlagAllowedOnPlot(plot, flag, p); externalPluginsAllowed = Utils.isFlagAllowedOnPlot(plot, flag, p);
} }
if (externalPluginsAllowed && plugin.hasWorldGuard() && config.enable_worldguard_integration) { if (externalPluginsAllowed && plugin.hasWorldGuard() && Config.enableWorldGuardIntegration) {
StateFlag flag = (shop.getShopType() == ShopType.ADMIN ? WorldGuardShopFlag.USE_ADMIN_SHOP : WorldGuardShopFlag.USE_SHOP); StateFlag flag = (shop.getShopType() == ShopType.ADMIN ? WorldGuardShopFlag.USE_ADMIN_SHOP : WorldGuardShopFlag.USE_SHOP);
RegionContainer container = worldGuard.getRegionContainer(); RegionContainer container = worldGuard.getRegionContainer();
RegionQuery query = container.createQuery(); RegionQuery query = container.createQuery();
@ -465,9 +464,9 @@ public class ShopInteractListener implements Listener {
if (shop.getShopType() == ShopType.ADMIN) { if (shop.getShopType() == ShopType.ADMIN) {
if (externalPluginsAllowed || p.hasPermission(Permissions.BYPASS_EXTERNAL_PLUGIN)) { if (externalPluginsAllowed || p.hasPermission(Permissions.BYPASS_EXTERNAL_PLUGIN)) {
if (confirmed || !config.confirm_shopping) { if (confirmed || !Config.confirmShopping) {
buy(p, shop, p.isSneaking()); buy(p, shop, p.isSneaking());
if (config.confirm_shopping) { if (Config.confirmShopping) {
Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>(); Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>();
ids.remove(shop.getID()); ids.remove(shop.getID());
if (ids.isEmpty()) needsConfirmation.remove(p.getUniqueId()); if (ids.isEmpty()) needsConfirmation.remove(p.getUniqueId());
@ -475,14 +474,14 @@ public class ShopInteractListener implements Listener {
} }
} else { } else {
plugin.debug("Needs confirmation"); plugin.debug("Needs confirmation");
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CLICK_TO_CONFIRM)); p.sendMessage(LanguageUtils.getMessage(Message.CLICK_TO_CONFIRM));
Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>(); Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>();
ids.add(shop.getID()); ids.add(shop.getID());
needsConfirmation.put(p.getUniqueId(), ids); needsConfirmation.put(p.getUniqueId(), ids);
} }
} else { } else {
plugin.debug(p.getName() + " doesn't have external plugin's permission"); plugin.debug(p.getName() + " doesn't have external plugin's permission");
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_BUY_HERE)); p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_BUY_HERE));
} }
} else { } else {
if (externalPluginsAllowed || p.hasPermission(Permissions.BYPASS_EXTERNAL_PLUGIN)) { if (externalPluginsAllowed || p.hasPermission(Permissions.BYPASS_EXTERNAL_PLUGIN)) {
@ -490,9 +489,9 @@ public class ShopInteractListener implements Listener {
int amount = (p.isSneaking() ? shop.getProduct().getMaxStackSize() : shop.getProduct().getAmount()); int amount = (p.isSneaking() ? shop.getProduct().getMaxStackSize() : shop.getProduct().getAmount());
if (Utils.getAmount(c.getInventory(), shop.getProduct()) >= amount) { if (Utils.getAmount(c.getInventory(), shop.getProduct()) >= amount) {
if (confirmed || !config.confirm_shopping) { if (confirmed || !Config.confirmShopping) {
buy(p, shop, p.isSneaking()); buy(p, shop, p.isSneaking());
if (config.confirm_shopping) { if (Config.confirmShopping) {
Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>(); Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>();
ids.remove(shop.getID()); ids.remove(shop.getID());
if (ids.isEmpty()) needsConfirmation.remove(p.getUniqueId()); if (ids.isEmpty()) needsConfirmation.remove(p.getUniqueId());
@ -500,16 +499,16 @@ public class ShopInteractListener implements Listener {
} }
} else { } else {
plugin.debug("Needs confirmation"); plugin.debug("Needs confirmation");
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CLICK_TO_CONFIRM)); p.sendMessage(LanguageUtils.getMessage(Message.CLICK_TO_CONFIRM));
Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>(); Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>();
ids.add(shop.getID()); ids.add(shop.getID());
needsConfirmation.put(p.getUniqueId(), ids); needsConfirmation.put(p.getUniqueId(), ids);
} }
} else { } else {
if (config.auto_calculate_item_amount && Utils.getAmount(c.getInventory(), shop.getProduct()) > 0) { if (Config.autoCalculateItemAmount && Utils.getAmount(c.getInventory(), shop.getProduct()) > 0) {
if (confirmed || !config.confirm_shopping) { if (confirmed || !Config.confirmShopping) {
buy(p, shop, p.isSneaking()); buy(p, shop, p.isSneaking());
if (config.confirm_shopping) { if (Config.confirmShopping) {
Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>(); Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>();
ids.remove(shop.getID()); ids.remove(shop.getID());
if (ids.isEmpty()) needsConfirmation.remove(p.getUniqueId()); if (ids.isEmpty()) needsConfirmation.remove(p.getUniqueId());
@ -517,32 +516,32 @@ public class ShopInteractListener implements Listener {
} }
} else { } else {
plugin.debug("Needs confirmation"); plugin.debug("Needs confirmation");
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CLICK_TO_CONFIRM)); p.sendMessage(LanguageUtils.getMessage(Message.CLICK_TO_CONFIRM));
Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>(); Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>();
ids.add(shop.getID()); ids.add(shop.getID());
needsConfirmation.put(p.getUniqueId(), ids); needsConfirmation.put(p.getUniqueId(), ids);
} }
} else { } else {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.OUT_OF_STOCK)); p.sendMessage(LanguageUtils.getMessage(Message.OUT_OF_STOCK));
if (shop.getVendor().isOnline() && config.enable_vendor_messages) { if (shop.getVendor().isOnline() && Config.enableVendorMessages) {
shop.getVendor().getPlayer().sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.VENDOR_OUT_OF_STOCK, shop.getVendor().getPlayer().sendMessage(LanguageUtils.getMessage(Message.VENDOR_OUT_OF_STOCK,
new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(shop.getProduct().getAmount())), new Replacement(Placeholder.AMOUNT, String.valueOf(shop.getProduct().getAmount())),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(shop.getProduct())))); new Replacement(Placeholder.ITEM_NAME, LanguageUtils.getItemName(shop.getProduct()))));
} }
plugin.debug("Shop is out of stock"); plugin.debug("Shop is out of stock");
} }
} }
} else { } else {
plugin.debug(p.getName() + " doesn't have external plugin's permission"); plugin.debug(p.getName() + " doesn't have external plugin's permission");
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_BUY_HERE)); p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_BUY_HERE));
} }
} }
} else { } else {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_BUY)); p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_BUY));
plugin.debug(p.getName() + " is not permitted to buy"); plugin.debug(p.getName() + " is not permitted to buy");
} }
} else { } else {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUYING_DISABLED)); p.sendMessage(LanguageUtils.getMessage(Message.BUYING_DISABLED));
plugin.debug("Buying is disabled"); plugin.debug("Buying is disabled");
} }
} }
@ -557,7 +556,7 @@ public class ShopInteractListener implements Listener {
if (p.hasPermission(Permissions.SELL)) { if (p.hasPermission(Permissions.SELL)) {
boolean externalPluginsAllowed = true; boolean externalPluginsAllowed = true;
if (plugin.hasPlotSquared() && config.enable_plotsquared_integration) { if (plugin.hasPlotSquared() && Config.enablePlotsquaredIntegration) {
com.intellectualcrafters.plot.object.Location plotLocation = com.intellectualcrafters.plot.object.Location plotLocation =
new com.intellectualcrafters.plot.object.Location(b.getWorld().getName(), b.getX(), b.getY(), b.getZ()); new com.intellectualcrafters.plot.object.Location(b.getWorld().getName(), b.getX(), b.getY(), b.getZ());
@ -567,7 +566,7 @@ public class ShopInteractListener implements Listener {
externalPluginsAllowed = Utils.isFlagAllowedOnPlot(plot, flag, p); externalPluginsAllowed = Utils.isFlagAllowedOnPlot(plot, flag, p);
} }
if (externalPluginsAllowed && plugin.hasWorldGuard() && config.enable_worldguard_integration) { if (externalPluginsAllowed && plugin.hasWorldGuard() && Config.enableWorldGuardIntegration) {
RegionContainer container = worldGuard.getRegionContainer(); RegionContainer container = worldGuard.getRegionContainer();
RegionQuery query = container.createQuery(); RegionQuery query = container.createQuery();
@ -580,9 +579,9 @@ public class ShopInteractListener implements Listener {
int amount = stack ? shop.getProduct().getMaxStackSize() : shop.getProduct().getAmount(); int amount = stack ? shop.getProduct().getMaxStackSize() : shop.getProduct().getAmount();
if (Utils.getAmount(p.getInventory(), shop.getProduct()) >= amount) { if (Utils.getAmount(p.getInventory(), shop.getProduct()) >= amount) {
if (confirmed || !config.confirm_shopping) { if (confirmed || !Config.confirmShopping) {
sell(p, shop, stack); sell(p, shop, stack);
if (config.confirm_shopping) { if (Config.confirmShopping) {
Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>(); Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>();
ids.remove(shop.getID()); ids.remove(shop.getID());
if (ids.isEmpty()) needsConfirmation.remove(p.getUniqueId()); if (ids.isEmpty()) needsConfirmation.remove(p.getUniqueId());
@ -590,16 +589,16 @@ public class ShopInteractListener implements Listener {
} }
} else { } else {
plugin.debug("Needs confirmation"); plugin.debug("Needs confirmation");
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CLICK_TO_CONFIRM)); p.sendMessage(LanguageUtils.getMessage(Message.CLICK_TO_CONFIRM));
Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>(); Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>();
ids.add(shop.getID()); ids.add(shop.getID());
needsConfirmation.put(p.getUniqueId(), ids); needsConfirmation.put(p.getUniqueId(), ids);
} }
} else { } else {
if (config.auto_calculate_item_amount && Utils.getAmount(p.getInventory(), shop.getProduct()) > 0) { if (Config.autoCalculateItemAmount && Utils.getAmount(p.getInventory(), shop.getProduct()) > 0) {
if (confirmed || !config.confirm_shopping) { if (confirmed || !Config.confirmShopping) {
sell(p, shop, stack); sell(p, shop, stack);
if (config.confirm_shopping) { if (Config.confirmShopping) {
Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>(); Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>();
ids.remove(shop.getID()); ids.remove(shop.getID());
if (ids.isEmpty()) needsConfirmation.remove(p.getUniqueId()); if (ids.isEmpty()) needsConfirmation.remove(p.getUniqueId());
@ -607,26 +606,26 @@ public class ShopInteractListener implements Listener {
} }
} else { } else {
plugin.debug("Needs confirmation"); plugin.debug("Needs confirmation");
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CLICK_TO_CONFIRM)); p.sendMessage(LanguageUtils.getMessage(Message.CLICK_TO_CONFIRM));
Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>(); Set<Integer> ids = needsConfirmation.containsKey(p.getUniqueId()) ? needsConfirmation.get(p.getUniqueId()) : new HashSet<Integer>();
ids.add(shop.getID()); ids.add(shop.getID());
needsConfirmation.put(p.getUniqueId(), ids); needsConfirmation.put(p.getUniqueId(), ids);
} }
} else { } else {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NOT_ENOUGH_ITEMS)); p.sendMessage(LanguageUtils.getMessage(Message.NOT_ENOUGH_ITEMS));
plugin.debug(p.getName() + " doesn't have enough items"); plugin.debug(p.getName() + " doesn't have enough items");
} }
} }
} else { } else {
plugin.debug(p.getName() + " doesn't have external plugin's permission"); plugin.debug(p.getName() + " doesn't have external plugin's permission");
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_SELL_HERE)); p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_SELL_HERE));
} }
} else { } else {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_SELL)); p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_SELL));
plugin.debug(p.getName() + " is not permitted to sell"); plugin.debug(p.getName() + " is not permitted to sell");
} }
} else { } else {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SELLING_DISABLED)); p.sendMessage(LanguageUtils.getMessage(Message.SELLING_DISABLED));
plugin.debug("Selling is disabled"); plugin.debug("Selling is disabled");
} }
} else { } else {
@ -642,17 +641,17 @@ public class ShopInteractListener implements Listener {
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent e) { public void onPlayerInteract(PlayerInteractEvent e) {
if (config.enable_authme_integration && plugin.hasAuthMe() && !AuthMe.getApi().isAuthenticated(e.getPlayer())) return; if (Config.enableAuthMeIntegration && plugin.hasAuthMe() && !AuthMe.getApi().isAuthenticated(e.getPlayer())) return;
handleInteractEvent(e); handleInteractEvent(e);
} }
@EventHandler @EventHandler
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent e) { public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent e) {
if (!plugin.getShopChestConfig().enable_hologram_interaction) return; if (!Config.enableHologramInteraction) return;
Entity entity = e.getRightClicked(); Entity entity = e.getRightClicked();
Player p = e.getPlayer(); Player p = e.getPlayer();
if (config.enable_authme_integration && plugin.hasAuthMe() && !AuthMe.getApi().isAuthenticated(p)) return; if (Config.enableAuthMeIntegration && plugin.hasAuthMe() && !AuthMe.getApi().isAuthenticated(p)) return;
if (Utils.getMajorVersion() == 8 || e.getHand() == EquipmentSlot.HAND) { if (Utils.getMajorVersion() == 8 || e.getHand() == EquipmentSlot.HAND) {
if (entity instanceof ArmorStand) { if (entity instanceof ArmorStand) {
@ -680,14 +679,14 @@ public class ShopInteractListener implements Listener {
@EventHandler @EventHandler
public void onPlayerDamageEntity(EntityDamageByEntityEvent e) { public void onPlayerDamageEntity(EntityDamageByEntityEvent e) {
if (!plugin.getShopChestConfig().enable_hologram_interaction) return; if (!Config.enableHologramInteraction) return;
Entity entity = e.getEntity(); Entity entity = e.getEntity();
Entity damager = e.getDamager(); Entity damager = e.getDamager();
if (!(damager instanceof Player)) return; if (!(damager instanceof Player)) return;
Player p = (Player) damager; Player p = (Player) damager;
if (config.enable_authme_integration && plugin.hasAuthMe() && !AuthMe.getApi().isAuthenticated(p)) return; if (Config.enableAuthMeIntegration && plugin.hasAuthMe() && !AuthMe.getApi().isAuthenticated(p)) return;
if (entity instanceof ArmorStand) { if (entity instanceof ArmorStand) {
ArmorStand armorStand = (ArmorStand) entity; ArmorStand armorStand = (ArmorStand) entity;
@ -726,12 +725,12 @@ public class ShopInteractListener implements Listener {
plugin.debug(executor.getName() + " is creating new shop..."); plugin.debug(executor.getName() + " is creating new shop...");
if (!executor.hasPermission(Permissions.CREATE)) { if (!executor.hasPermission(Permissions.CREATE)) {
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_CREATE)); executor.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_CREATE));
plugin.debug(executor.getName() + " is not permitted to create the shop"); plugin.debug(executor.getName() + " is not permitted to create the shop");
return; return;
} }
double creationPrice = (shopType == ShopType.NORMAL) ? config.shop_creation_price_normal : config.shop_creation_price_admin; double creationPrice = (shopType == ShopType.NORMAL) ? Config.shopCreationPriceNormal : Config.shopCreationPriceAdmin;
Shop shop = new Shop(plugin, executor, product, location, buyPrice, sellPrice, shopType); Shop shop = new Shop(plugin, executor, product, location, buyPrice, sellPrice, shopType);
ShopCreateEvent event = new ShopCreateEvent(executor, shop, creationPrice); ShopCreateEvent event = new ShopCreateEvent(executor, shop, creationPrice);
@ -745,8 +744,8 @@ public class ShopInteractListener implements Listener {
EconomyResponse r = plugin.getEconomy().withdrawPlayer(executor, location.getWorld().getName(), creationPrice); EconomyResponse r = plugin.getEconomy().withdrawPlayer(executor, location.getWorld().getName(), creationPrice);
if (!r.transactionSuccess()) { if (!r.transactionSuccess()) {
plugin.debug("Economy transaction failed: " + r.errorMessage); plugin.debug("Economy transaction failed: " + r.errorMessage);
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, executor.sendMessage(LanguageUtils.getMessage(Message.ERROR_OCCURRED,
new LocalizedMessage.ReplacedPlaceholder(Placeholder.ERROR, r.errorMessage))); new Replacement(Placeholder.ERROR, r.errorMessage)));
return; return;
} }
@ -755,13 +754,13 @@ public class ShopInteractListener implements Listener {
plugin.debug("Shop created"); plugin.debug("Shop created");
shopUtils.addShop(shop, true); shopUtils.addShop(shop, true);
LocalizedMessage.ReplacedPlaceholder placeholder = new LocalizedMessage.ReplacedPlaceholder( Replacement placeholder = new Replacement(
Placeholder.CREATION_PRICE, String.valueOf(creationPrice)); Placeholder.CREATION_PRICE, String.valueOf(creationPrice));
if (shopType == ShopType.ADMIN) { if (shopType == ShopType.ADMIN) {
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ADMIN_SHOP_CREATED, placeholder)); executor.sendMessage(LanguageUtils.getMessage(Message.ADMIN_SHOP_CREATED, placeholder));
} else { } else {
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_CREATED, placeholder)); executor.sendMessage(LanguageUtils.getMessage(Message.SHOP_CREATED, placeholder));
} }
// next update will display the new shop // next update will display the new shop
@ -786,14 +785,14 @@ public class ShopInteractListener implements Listener {
shopUtils.removeShop(shop, true); shopUtils.removeShop(shop, true);
plugin.debug("Removed shop (#" + shop.getID() + ")"); plugin.debug("Removed shop (#" + shop.getID() + ")");
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_REMOVED)); executor.sendMessage(LanguageUtils.getMessage(Message.SHOP_REMOVED));
} }
/** /**
* Open a shop * Open a shop
* @param executor Player, who executed the command and will receive the message * @param executor Player, who executed the command and will receive the message
* @param shop Shop to be opened * @param shop Shop to be opened
* @param message Whether the player should receive the {@link LocalizedMessage.Message#OPENED_SHOP} message * @param message Whether the player should receive the {@link Message#OPENED_SHOP} message
*/ */
private void open(Player executor, Shop shop, boolean message) { private void open(Player executor, Shop shop, boolean message) {
plugin.debug(executor.getName() + " is opening " + shop.getVendor().getName() + "'s shop (#" + shop.getID() + ")"); plugin.debug(executor.getName() + " is opening " + shop.getVendor().getName() + "'s shop (#" + shop.getID() + ")");
@ -806,8 +805,8 @@ public class ShopInteractListener implements Listener {
executor.openInventory(shop.getInventoryHolder().getInventory()); executor.openInventory(shop.getInventoryHolder().getInventory());
plugin.debug("Opened shop (#" + shop.getID() + ")"); plugin.debug("Opened shop (#" + shop.getID() + ")");
if (message) executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.OPENED_SHOP, if (message) executor.sendMessage(LanguageUtils.getMessage(Message.OPENED_SHOP,
new LocalizedMessage.ReplacedPlaceholder(Placeholder.VENDOR, shop.getVendor().getName()))); new Replacement(Placeholder.VENDOR, shop.getVendor().getName())));
} }
/** /**
@ -833,39 +832,39 @@ public class ShopInteractListener implements Listener {
String vendorName = (shop.getVendor().getName() == null ? String vendorName = (shop.getVendor().getName() == null ?
shop.getVendor().getUniqueId().toString() : shop.getVendor().getName()); shop.getVendor().getUniqueId().toString() : shop.getVendor().getName());
String vendorString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_VENDOR, String vendorString = LanguageUtils.getMessage(Message.SHOP_INFO_VENDOR,
new LocalizedMessage.ReplacedPlaceholder(Placeholder.VENDOR, vendorName)); new Replacement(Placeholder.VENDOR, vendorName));
String productString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_PRODUCT, String productString = LanguageUtils.getMessage(Message.SHOP_INFO_PRODUCT,
new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(shop.getProduct().getAmount())), new Replacement(Placeholder.AMOUNT, String.valueOf(shop.getProduct().getAmount())),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(shop.getProduct()))); new Replacement(Placeholder.ITEM_NAME, LanguageUtils.getItemName(shop.getProduct())));
String enchantmentString = ""; String enchantmentString = "";
String potionEffectString = ""; String potionEffectString = "";
String bookGenerationString = ""; String bookGenerationString = "";
String musicDiscTitleString = ""; String musicDiscTitleString = "";
String disabled = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_DISABLED); String disabled = LanguageUtils.getMessage(Message.SHOP_INFO_DISABLED);
String priceString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_PRICE, String priceString = LanguageUtils.getMessage(Message.SHOP_INFO_PRICE,
new LocalizedMessage.ReplacedPlaceholder(Placeholder.BUY_PRICE, (shop.getBuyPrice() > 0 ? String.valueOf(shop.getBuyPrice()) : disabled)), new Replacement(Placeholder.BUY_PRICE, (shop.getBuyPrice() > 0 ? String.valueOf(shop.getBuyPrice()) : disabled)),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.SELL_PRICE, (shop.getSellPrice() > 0 ? String.valueOf(shop.getSellPrice()) : disabled))); new Replacement(Placeholder.SELL_PRICE, (shop.getSellPrice() > 0 ? String.valueOf(shop.getSellPrice()) : disabled)));
String shopType = LanguageUtils.getMessage(shop.getShopType() == ShopType.NORMAL ? String shopType = LanguageUtils.getMessage(shop.getShopType() == ShopType.NORMAL ?
LocalizedMessage.Message.SHOP_INFO_NORMAL : LocalizedMessage.Message.SHOP_INFO_ADMIN); Message.SHOP_INFO_NORMAL : Message.SHOP_INFO_ADMIN);
String stock = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_STOCK, String stock = LanguageUtils.getMessage(Message.SHOP_INFO_STOCK,
new LocalizedMessage.ReplacedPlaceholder(Placeholder.STOCK, String.valueOf(amount))); new Replacement(Placeholder.STOCK, String.valueOf(amount)));
String potionEffectName = LanguageUtils.getPotionEffectName(shop.getProduct()); String potionEffectName = LanguageUtils.getPotionEffectName(shop.getProduct());
if (potionEffectName.length() > 0) { if (potionEffectName.length() > 0) {
boolean potionExtended = ItemUtils.isExtendedPotion(shop.getProduct()); boolean potionExtended = ItemUtils.isExtendedPotion(shop.getProduct());
String extended = potionExtended ? LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_EXTENDED) : ""; String extended = potionExtended ? LanguageUtils.getMessage(Message.SHOP_INFO_EXTENDED) : "";
potionEffectString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_POTION_EFFECT, potionEffectString = LanguageUtils.getMessage(Message.SHOP_INFO_POTION_EFFECT,
new LocalizedMessage.ReplacedPlaceholder(Placeholder.POTION_EFFECT, potionEffectName), new Replacement(Placeholder.POTION_EFFECT, potionEffectName),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.EXTENDED, extended)); new Replacement(Placeholder.EXTENDED, extended));
} }
if (type == Material.WRITTEN_BOOK) { if (type == Material.WRITTEN_BOOK) {
@ -883,22 +882,22 @@ public class ShopInteractListener implements Listener {
} }
} }
bookGenerationString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_BOOK_GENERATION, bookGenerationString = LanguageUtils.getMessage(Message.SHOP_INFO_BOOK_GENERATION,
new LocalizedMessage.ReplacedPlaceholder(Placeholder.GENERATION, LanguageUtils.getBookGenerationName(generation))); new Replacement(Placeholder.GENERATION, LanguageUtils.getBookGenerationName(generation)));
} }
String musicDiscName = LanguageUtils.getMusicDiscName(type); String musicDiscName = LanguageUtils.getMusicDiscName(type);
if (musicDiscName.length() > 0) { if (musicDiscName.length() > 0) {
musicDiscTitleString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_MUSIC_TITLE, musicDiscTitleString = LanguageUtils.getMessage(Message.SHOP_INFO_MUSIC_TITLE,
new LocalizedMessage.ReplacedPlaceholder(Placeholder.MUSIC_TITLE, musicDiscName)); new Replacement(Placeholder.MUSIC_TITLE, musicDiscName));
} }
Map<Enchantment, Integer> enchantmentMap = ItemUtils.getEnchantments(shop.getProduct()); Map<Enchantment, Integer> enchantmentMap = ItemUtils.getEnchantments(shop.getProduct());
String enchantmentList = LanguageUtils.getEnchantmentString(enchantmentMap); String enchantmentList = LanguageUtils.getEnchantmentString(enchantmentMap);
if (enchantmentList.length() > 0) { if (enchantmentList.length() > 0) {
enchantmentString = LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_INFO_ENCHANTMENTS, enchantmentString = LanguageUtils.getMessage(Message.SHOP_INFO_ENCHANTMENTS,
new LocalizedMessage.ReplacedPlaceholder(Placeholder.ENCHANTMENT, enchantmentList)); new Replacement(Placeholder.ENCHANTMENT, enchantmentList));
} }
executor.sendMessage(" "); executor.sendMessage(" ");
@ -931,12 +930,12 @@ public class ShopInteractListener implements Listener {
double price = shop.getBuyPrice(); double price = shop.getBuyPrice();
if (stack) price = (price / shop.getProduct().getAmount()) * amount; if (stack) price = (price / shop.getProduct().getAmount()) * amount;
if (econ.getBalance(executor, worldName) >= price || config.auto_calculate_item_amount) { if (econ.getBalance(executor, worldName) >= price || Config.autoCalculateItemAmount) {
int amountForMoney = (int) (amount / price * econ.getBalance(executor, worldName)); int amountForMoney = (int) (amount / price * econ.getBalance(executor, worldName));
if (amountForMoney == 0 && config.auto_calculate_item_amount) { if (amountForMoney == 0 && Config.autoCalculateItemAmount) {
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NOT_ENOUGH_MONEY)); executor.sendMessage(LanguageUtils.getMessage(Message.NOT_ENOUGH_MONEY));
return; return;
} }
@ -948,7 +947,7 @@ public class ShopInteractListener implements Listener {
int amountForChestItems = Utils.getAmount(c.getInventory(), shop.getProduct()); int amountForChestItems = Utils.getAmount(c.getInventory(), shop.getProduct());
if (amountForChestItems == 0 && shop.getShopType() != ShopType.ADMIN) { if (amountForChestItems == 0 && shop.getShopType() != ShopType.ADMIN) {
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.OUT_OF_STOCK)); executor.sendMessage(LanguageUtils.getMessage(Message.OUT_OF_STOCK));
return; return;
} }
@ -960,13 +959,13 @@ public class ShopInteractListener implements Listener {
int freeSpace = Utils.getFreeSpaceForItem(inventory, product); int freeSpace = Utils.getFreeSpaceForItem(inventory, product);
if (freeSpace == 0) { if (freeSpace == 0) {
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NOT_ENOUGH_INVENTORY_SPACE)); executor.sendMessage(LanguageUtils.getMessage(Message.NOT_ENOUGH_INVENTORY_SPACE));
return; return;
} }
int newAmount = amount; int newAmount = amount;
if (config.auto_calculate_item_amount) { if (Config.autoCalculateItemAmount) {
if (shop.getShopType() == ShopType.ADMIN) if (shop.getShopType() == ShopType.ADMIN)
newAmount = Math.min(amountForMoney, freeSpace); newAmount = Math.min(amountForMoney, freeSpace);
else else
@ -1016,21 +1015,21 @@ public class ShopInteractListener implements Listener {
}.runTaskLater(plugin, 1L); }.runTaskLater(plugin, 1L);
String vendorName = (shop.getVendor().getName() == null ? shop.getVendor().getUniqueId().toString() : shop.getVendor().getName()); String vendorName = (shop.getVendor().getName() == null ? shop.getVendor().getUniqueId().toString() : shop.getVendor().getName());
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_SUCCESS, new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(newAmount)), executor.sendMessage(LanguageUtils.getMessage(Message.BUY_SUCCESS, new Replacement(Placeholder.AMOUNT, String.valueOf(newAmount)),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedPlaceholder(Placeholder.BUY_PRICE, String.valueOf(newPrice)), new Replacement(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new Replacement(Placeholder.BUY_PRICE, String.valueOf(newPrice)),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.VENDOR, vendorName))); new Replacement(Placeholder.VENDOR, vendorName)));
plugin.debug(executor.getName() + " successfully bought (#" + shop.getID() + ")"); plugin.debug(executor.getName() + " successfully bought (#" + shop.getID() + ")");
if (shop.getVendor().isOnline() && config.enable_vendor_messages) { if (shop.getVendor().isOnline() && Config.enableVendorMessages) {
shop.getVendor().getPlayer().sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SOMEONE_BOUGHT, new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(newAmount)), shop.getVendor().getPlayer().sendMessage(LanguageUtils.getMessage(Message.SOMEONE_BOUGHT, new Replacement(Placeholder.AMOUNT, String.valueOf(newAmount)),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedPlaceholder(Placeholder.BUY_PRICE, String.valueOf(newPrice)), new Replacement(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new Replacement(Placeholder.BUY_PRICE, String.valueOf(newPrice)),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.PLAYER, executor.getName()))); new Replacement(Placeholder.PLAYER, executor.getName())));
} }
} else { } else {
plugin.debug("Economy transaction failed (r2): " + r2.errorMessage + " (#" + shop.getID() + ")"); plugin.debug("Economy transaction failed (r2): " + r2.errorMessage + " (#" + shop.getID() + ")");
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.ERROR, r2.errorMessage))); executor.sendMessage(LanguageUtils.getMessage(Message.ERROR_OCCURRED, new Replacement(Placeholder.ERROR, r2.errorMessage)));
econ.withdrawPlayer(shop.getVendor(), worldName, newPrice); econ.withdrawPlayer(shop.getVendor(), worldName, newPrice);
econ.depositPlayer(executor, worldName, newPrice); econ.depositPlayer(executor, worldName, newPrice);
} }
@ -1058,21 +1057,21 @@ public class ShopInteractListener implements Listener {
} }
}.runTaskLater(plugin, 1L); }.runTaskLater(plugin, 1L);
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_SUCCESS_ADMIN, new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(newAmount)), executor.sendMessage(LanguageUtils.getMessage(Message.BUY_SUCCESS_ADMIN, new Replacement(Placeholder.AMOUNT, String.valueOf(newAmount)),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedPlaceholder(Placeholder.BUY_PRICE, String.valueOf(newPrice)))); new Replacement(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new Replacement(Placeholder.BUY_PRICE, String.valueOf(newPrice))));
plugin.debug(executor.getName() + " successfully bought (#" + shop.getID() + ")"); plugin.debug(executor.getName() + " successfully bought (#" + shop.getID() + ")");
} }
} else { } else {
plugin.debug("Economy transaction failed (r): " + r.errorMessage + " (#" + shop.getID() + ")"); plugin.debug("Economy transaction failed (r): " + r.errorMessage + " (#" + shop.getID() + ")");
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.ERROR, r.errorMessage))); executor.sendMessage(LanguageUtils.getMessage(Message.ERROR_OCCURRED, new Replacement(Placeholder.ERROR, r.errorMessage)));
econ.depositPlayer(executor, worldName, newPrice); econ.depositPlayer(executor, worldName, newPrice);
} }
} else { } else {
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NOT_ENOUGH_INVENTORY_SPACE)); executor.sendMessage(LanguageUtils.getMessage(Message.NOT_ENOUGH_INVENTORY_SPACE));
} }
} else { } else {
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NOT_ENOUGH_MONEY)); executor.sendMessage(LanguageUtils.getMessage(Message.NOT_ENOUGH_MONEY));
} }
} }
@ -1092,13 +1091,13 @@ public class ShopInteractListener implements Listener {
String worldName = shop.getLocation().getWorld().getName(); String worldName = shop.getLocation().getWorld().getName();
if (econ.getBalance(shop.getVendor(), worldName) >= price || shop.getShopType() == ShopType.ADMIN || config.auto_calculate_item_amount) { if (econ.getBalance(shop.getVendor(), worldName) >= price || shop.getShopType() == ShopType.ADMIN || Config.autoCalculateItemAmount) {
int amountForMoney = (int) (amount / price * econ.getBalance(shop.getVendor(), worldName)); int amountForMoney = (int) (amount / price * econ.getBalance(shop.getVendor(), worldName));
plugin.debug("Vendor has enough money for " + amountForMoney + " item(s) (#" + shop.getID() + ")"); plugin.debug("Vendor has enough money for " + amountForMoney + " item(s) (#" + shop.getID() + ")");
if (amountForMoney == 0 && config.auto_calculate_item_amount && shop.getShopType() != ShopType.ADMIN) { if (amountForMoney == 0 && Config.autoCalculateItemAmount && shop.getShopType() != ShopType.ADMIN) {
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.VENDOR_NOT_ENOUGH_MONEY)); executor.sendMessage(LanguageUtils.getMessage(Message.VENDOR_NOT_ENOUGH_MONEY));
return; return;
} }
@ -1108,7 +1107,7 @@ public class ShopInteractListener implements Listener {
int amountForItemCount = Utils.getAmount(executor.getInventory(), shop.getProduct()); int amountForItemCount = Utils.getAmount(executor.getInventory(), shop.getProduct());
if (amountForItemCount == 0) { if (amountForItemCount == 0) {
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NOT_ENOUGH_ITEMS)); executor.sendMessage(LanguageUtils.getMessage(Message.NOT_ENOUGH_ITEMS));
return; return;
} }
@ -1120,13 +1119,13 @@ public class ShopInteractListener implements Listener {
int freeSpace = Utils.getFreeSpaceForItem(inventory, product); int freeSpace = Utils.getFreeSpaceForItem(inventory, product);
if (freeSpace == 0 && shop.getShopType() != ShopType.ADMIN) { if (freeSpace == 0 && shop.getShopType() != ShopType.ADMIN) {
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CHEST_NOT_ENOUGH_INVENTORY_SPACE)); executor.sendMessage(LanguageUtils.getMessage(Message.CHEST_NOT_ENOUGH_INVENTORY_SPACE));
return; return;
} }
int newAmount = amount; int newAmount = amount;
if (config.auto_calculate_item_amount) { if (Config.autoCalculateItemAmount) {
if (shop.getShopType() == ShopType.ADMIN) if (shop.getShopType() == ShopType.ADMIN)
newAmount = amountForItemCount; newAmount = amountForItemCount;
else else
@ -1176,21 +1175,21 @@ public class ShopInteractListener implements Listener {
}.runTaskLater(plugin, 1L); }.runTaskLater(plugin, 1L);
String vendorName = (shop.getVendor().getName() == null ? shop.getVendor().getUniqueId().toString() : shop.getVendor().getName()); String vendorName = (shop.getVendor().getName() == null ? shop.getVendor().getUniqueId().toString() : shop.getVendor().getName());
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SELL_SUCCESS, new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(newAmount)), executor.sendMessage(LanguageUtils.getMessage(Message.SELL_SUCCESS, new Replacement(Placeholder.AMOUNT, String.valueOf(newAmount)),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedPlaceholder(Placeholder.SELL_PRICE, String.valueOf(newPrice)), new Replacement(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new Replacement(Placeholder.SELL_PRICE, String.valueOf(newPrice)),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.VENDOR, vendorName))); new Replacement(Placeholder.VENDOR, vendorName)));
plugin.debug(executor.getName() + " successfully sold (#" + shop.getID() + ")"); plugin.debug(executor.getName() + " successfully sold (#" + shop.getID() + ")");
if (shop.getVendor().isOnline() && config.enable_vendor_messages) { if (shop.getVendor().isOnline() && Config.enableVendorMessages) {
shop.getVendor().getPlayer().sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SOMEONE_SOLD, new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(newAmount)), shop.getVendor().getPlayer().sendMessage(LanguageUtils.getMessage(Message.SOMEONE_SOLD, new Replacement(Placeholder.AMOUNT, String.valueOf(newAmount)),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedPlaceholder(Placeholder.SELL_PRICE, String.valueOf(newPrice)), new Replacement(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new Replacement(Placeholder.SELL_PRICE, String.valueOf(newPrice)),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.PLAYER, executor.getName()))); new Replacement(Placeholder.PLAYER, executor.getName())));
} }
} else { } else {
plugin.debug("Economy transaction failed (r2): " + r2.errorMessage + " (#" + shop.getID() + ")"); plugin.debug("Economy transaction failed (r2): " + r2.errorMessage + " (#" + shop.getID() + ")");
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.ERROR, r2.errorMessage))); executor.sendMessage(LanguageUtils.getMessage(Message.ERROR_OCCURRED, new Replacement(Placeholder.ERROR, r2.errorMessage)));
econ.withdrawPlayer(executor, worldName, newPrice); econ.withdrawPlayer(executor, worldName, newPrice);
econ.depositPlayer(shop.getVendor(), worldName, newPrice); econ.depositPlayer(shop.getVendor(), worldName, newPrice);
} }
@ -1219,24 +1218,24 @@ public class ShopInteractListener implements Listener {
} }
}.runTaskLater(plugin, 1L); }.runTaskLater(plugin, 1L);
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SELL_SUCCESS_ADMIN, new LocalizedMessage.ReplacedPlaceholder(Placeholder.AMOUNT, String.valueOf(newAmount)), executor.sendMessage(LanguageUtils.getMessage(Message.SELL_SUCCESS_ADMIN, new Replacement(Placeholder.AMOUNT, String.valueOf(newAmount)),
new LocalizedMessage.ReplacedPlaceholder(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new LocalizedMessage.ReplacedPlaceholder(Placeholder.SELL_PRICE, String.valueOf(newPrice)))); new Replacement(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new Replacement(Placeholder.SELL_PRICE, String.valueOf(newPrice))));
plugin.debug(executor.getName() + " successfully sold (#" + shop.getID() + ")"); plugin.debug(executor.getName() + " successfully sold (#" + shop.getID() + ")");
} }
} else { } else {
plugin.debug("Economy transaction failed (r): " + r.errorMessage + " (#" + shop.getID() + ")"); plugin.debug("Economy transaction failed (r): " + r.errorMessage + " (#" + shop.getID() + ")");
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedPlaceholder(Placeholder.ERROR, r.errorMessage))); executor.sendMessage(LanguageUtils.getMessage(Message.ERROR_OCCURRED, new Replacement(Placeholder.ERROR, r.errorMessage)));
econ.withdrawPlayer(executor, worldName, newPrice); econ.withdrawPlayer(executor, worldName, newPrice);
} }
} else { } else {
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.CHEST_NOT_ENOUGH_INVENTORY_SPACE)); executor.sendMessage(LanguageUtils.getMessage(Message.CHEST_NOT_ENOUGH_INVENTORY_SPACE));
} }
} else { } else {
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.VENDOR_NOT_ENOUGH_MONEY)); executor.sendMessage(LanguageUtils.getMessage(Message.VENDOR_NOT_ENOUGH_MONEY));
} }
} }

View File

@ -14,16 +14,13 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.*; import org.bukkit.event.block.*;
import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.event.world.StructureGrowEvent;
public class ShopItemListener implements Listener { public class ShopItemListener implements Listener {
private ShopUtils shopUtils; private ShopUtils shopUtils;
private ShopChest plugin;
public ShopItemListener(ShopChest plugin) { public ShopItemListener(ShopChest plugin) {
this.plugin = plugin;
this.shopUtils = plugin.getShopUtils(); this.shopUtils = plugin.getShopUtils();
} }

View File

@ -9,6 +9,7 @@ import com.sk89q.worldguard.bukkit.event.entity.DamageEntityEvent;
import com.sk89q.worldguard.bukkit.event.entity.UseEntityEvent; import com.sk89q.worldguard.bukkit.event.entity.UseEntityEvent;
import com.sk89q.worldguard.protection.flags.StateFlag; import com.sk89q.worldguard.protection.flags.StateFlag;
import de.epiceric.shopchest.ShopChest; import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.nms.Hologram; import de.epiceric.shopchest.nms.Hologram;
import de.epiceric.shopchest.shop.Shop; import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.utils.ClickType; import de.epiceric.shopchest.utils.ClickType;
@ -78,7 +79,7 @@ public class WorldGuardListener implements Listener {
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW)
public void onUseEntity(UseEntityEvent event) { public void onUseEntity(UseEntityEvent event) {
if (plugin.getShopChestConfig().enable_worldguard_integration) { if (Config.enableWorldGuardIntegration) {
Player player = event.getCause().getFirstPlayer(); Player player = event.getCause().getFirstPlayer();
if (player == null) return; if (player == null) return;
@ -107,7 +108,7 @@ public class WorldGuardListener implements Listener {
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW)
public void onDamageEntity(DamageEntityEvent event) { public void onDamageEntity(DamageEntityEvent event) {
if (plugin.getShopChestConfig().enable_worldguard_integration) { if (Config.enableWorldGuardIntegration) {
Player player = event.getCause().getFirstPlayer(); Player player = event.getCause().getFirstPlayer();
if (player == null) return; if (player == null) return;
@ -136,7 +137,7 @@ public class WorldGuardListener implements Listener {
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW)
public void onUseBlock(UseBlockEvent event) { public void onUseBlock(UseBlockEvent event) {
if (plugin.getShopChestConfig().enable_worldguard_integration) { if (Config.enableWorldGuardIntegration) {
Player player = event.getCause().getFirstPlayer(); Player player = event.getCause().getFirstPlayer();
if (player == null) return; if (player == null) return;

View File

@ -42,23 +42,21 @@ public class Hologram {
private final List<ArmorStandWrapper> wrappers = new ArrayList<>(); private final List<ArmorStandWrapper> wrappers = new ArrayList<>();
private final Location location; private final Location location;
private final ShopChest plugin; private final ShopChest plugin;
private final Config config;
private boolean exists; private boolean exists;
private ArmorStandWrapper interactArmorStandWrapper; private ArmorStandWrapper interactArmorStandWrapper;
public Hologram(ShopChest plugin, String[] lines, Location location) { public Hologram(ShopChest plugin, String[] lines, Location location) {
this.plugin = plugin; this.plugin = plugin;
this.config = plugin.getShopChestConfig();
this.location = location; this.location = location;
for (int i = 0; i < lines.length; i++) { for (int i = 0; i < lines.length; i++) {
addLine(i, lines[i]); addLine(i, lines[i]);
} }
if (plugin.getShopChestConfig().enable_hologram_interaction) { if (Config.enableHologramInteraction) {
double y = 0.6; double y = 0.6;
if (config.hologram_fixed_bottom) y = 0.85; if (Config.hologramFixedBottom) y = 0.85;
Location loc = getLocation().add(0, y, 0); Location loc = getLocation().add(0, y, 0);
interactArmorStandWrapper = new ArmorStandWrapper(plugin, loc, null, true); interactArmorStandWrapper = new ArmorStandWrapper(plugin, loc, null, true);
@ -215,7 +213,7 @@ public class Hologram {
text = ChatColor.translateAlternateColorCodes('&', text); text = ChatColor.translateAlternateColorCodes('&', text);
if (config.hologram_fixed_bottom) { if (Config.hologramFixedBottom) {
for (int i = 0; i < line; i++) { for (int i = 0; i < line; i++) {
ArmorStandWrapper wrapper = wrappers.get(i); ArmorStandWrapper wrapper = wrappers.get(i);
wrapper.setLocation(wrapper.getLocation().add(0, 0.25, 0)); wrapper.setLocation(wrapper.getLocation().add(0, 0.25, 0));
@ -229,7 +227,7 @@ public class Hologram {
Location loc = getLocation(); Location loc = getLocation();
if (!config.hologram_fixed_bottom) { if (!Config.hologramFixedBottom) {
loc.subtract(0, line * 0.25, 0); loc.subtract(0, line * 0.25, 0);
} }
@ -274,7 +272,7 @@ public class Hologram {
*/ */
public void removeLine(int line) { public void removeLine(int line) {
if (line < wrappers.size()) { if (line < wrappers.size()) {
if (config.hologram_fixed_bottom) { if (Config.hologramFixedBottom) {
for (int i = 0; i < line; i++) { for (int i = 0; i < line; i++) {
ArmorStandWrapper wrapper = wrappers.get(i); ArmorStandWrapper wrapper = wrappers.get(i);
wrapper.setLocation(wrapper.getLocation().subtract(0, 0.25, 0)); wrapper.setLocation(wrapper.getLocation().subtract(0, 0.25, 0));

View File

@ -37,7 +37,6 @@ public class Shop {
private final double buyPrice; private final double buyPrice;
private final double sellPrice; private final double sellPrice;
private final ShopType shopType; private final ShopType shopType;
private final Config config;
private boolean created; private boolean created;
private int id; private int id;
@ -53,7 +52,6 @@ public class Shop {
this.buyPrice = buyPrice; this.buyPrice = buyPrice;
this.sellPrice = sellPrice; this.sellPrice = sellPrice;
this.shopType = shopType; this.shopType = shopType;
this.config = plugin.getShopChestConfig();
} }
public Shop(ShopChest plugin, OfflinePlayer vendor, ItemStack product, Location location, double buyPrice, double sellPrice, ShopType shopType) { public Shop(ShopChest plugin, OfflinePlayer vendor, ItemStack product, Location location, double buyPrice, double sellPrice, ShopType shopType) {
@ -96,14 +94,14 @@ public class Shop {
Block b = location.getBlock(); Block b = location.getBlock();
if (b.getType() != Material.CHEST && b.getType() != Material.TRAPPED_CHEST) { if (b.getType() != Material.CHEST && b.getType() != Material.TRAPPED_CHEST) {
ChestNotFoundException ex = new ChestNotFoundException(String.format("No Chest found in world '%s' at location: %d; %d; %d", b.getWorld().getName(), b.getX(), b.getY(), b.getZ())); ChestNotFoundException ex = new ChestNotFoundException(String.format("No Chest found in world '%s' at location: %d; %d; %d", b.getWorld().getName(), b.getX(), b.getY(), b.getZ()));
plugin.getShopUtils().removeShop(this, config.remove_shop_on_error); plugin.getShopUtils().removeShop(this, Config.removeShopOnError);
if (showConsoleMessages) plugin.getLogger().severe(ex.getMessage()); if (showConsoleMessages) plugin.getLogger().severe(ex.getMessage());
plugin.debug("Failed to create shop (#" + id + ")"); plugin.debug("Failed to create shop (#" + id + ")");
plugin.debug(ex); plugin.debug(ex);
return false; return false;
} else if ((b.getRelative(BlockFace.UP).getType() != Material.AIR) && config.show_shop_items) { } else if ((b.getRelative(BlockFace.UP).getType() != Material.AIR) && Config.showShopItems) {
NotEnoughSpaceException ex = new NotEnoughSpaceException(String.format("No space above chest in world '%s' at location: %d; %d; %d", b.getWorld().getName(), b.getX(), b.getY(), b.getZ())); NotEnoughSpaceException ex = new NotEnoughSpaceException(String.format("No space above chest in world '%s' at location: %d; %d; %d", b.getWorld().getName(), b.getX(), b.getY(), b.getZ()));
plugin.getShopUtils().removeShop(this, config.remove_shop_on_error); plugin.getShopUtils().removeShop(this, Config.removeShopOnError);
if (showConsoleMessages) plugin.getLogger().severe(ex.getMessage()); if (showConsoleMessages) plugin.getLogger().severe(ex.getMessage());
plugin.debug("Failed to create shop (#" + id + ")"); plugin.debug("Failed to create shop (#" + id + ")");
plugin.debug(ex); plugin.debug(ex);
@ -142,7 +140,7 @@ public class Shop {
* <b>Call this after {@link #createHologram()}, because it depends on the hologram's location</b> * <b>Call this after {@link #createHologram()}, because it depends on the hologram's location</b>
*/ */
private void createItem() { private void createItem() {
if (config.show_shop_items) { if (Config.showShopItems) {
plugin.debug("Creating item (#" + id + ")"); plugin.debug("Creating item (#" + id + ")");
Location itemLocation; Location itemLocation;
@ -283,7 +281,7 @@ public class Shop {
double subtractY = 0.6; double subtractY = 0.6;
if (config.hologram_fixed_bottom) subtractY = 0.85; if (Config.hologramFixedBottom) subtractY = 0.85;
if (doubleChest) { if (doubleChest) {
Chest r = chests[0]; Chest r = chests[0];
@ -310,7 +308,7 @@ public class Shop {
holoLocation = new Location(w, x + 0.5, y - subtractY, z + 0.5); holoLocation = new Location(w, x + 0.5, y - subtractY, z + 0.5);
} }
holoLocation.add(0, config.hologram_lift, 0); holoLocation.add(0, Config.hologramLift, 0);
return holoLocation; return holoLocation;
} }

View File

@ -44,13 +44,13 @@ public class ShopItem {
Class<?> craftWorldClass = Utils.getCraftClass("CraftWorld"); Class<?> craftWorldClass = Utils.getCraftClass("CraftWorld");
Class<?> nmsWorldClass = Utils.getNMSClass("World"); Class<?> nmsWorldClass = Utils.getNMSClass("World");
Class[] requiredClasses = new Class[] { Class<?>[] requiredClasses = new Class[] {
nmsWorldClass, craftWorldClass, nmsItemStackClass, craftItemStackClass, entityItemClass, nmsWorldClass, craftWorldClass, nmsItemStackClass, craftItemStackClass, entityItemClass,
packetPlayOutSpawnEntityClass, packetPlayOutEntityMetadataClass, dataWatcherClass, packetPlayOutSpawnEntityClass, packetPlayOutEntityMetadataClass, dataWatcherClass,
packetPlayOutEntityDestroyClass, entityClass, packetPlayOutEntityVelocityClass, packetPlayOutEntityDestroyClass, entityClass, packetPlayOutEntityVelocityClass,
}; };
for (Class c : requiredClasses) { for (Class<?> c : requiredClasses) {
if (c == null) { if (c == null) {
plugin.debug("Failed to create shop item: Could not find all required classes"); plugin.debug("Failed to create shop item: Could not find all required classes");
entityItem = null; entityItem = null;

View File

@ -1,6 +1,7 @@
package de.epiceric.shopchest.sql; package de.epiceric.shopchest.sql;
import de.epiceric.shopchest.ShopChest; import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.event.ShopBuySellEvent; import de.epiceric.shopchest.event.ShopBuySellEvent;
import de.epiceric.shopchest.exceptions.WorldNotFoundException; import de.epiceric.shopchest.exceptions.WorldNotFoundException;
import de.epiceric.shopchest.language.LanguageUtils; import de.epiceric.shopchest.language.LanguageUtils;
@ -385,7 +386,7 @@ public abstract class Database {
* @param callback Callback that - if succeeded - returns {@code null} * @param callback Callback that - if succeeded - returns {@code null}
*/ */
public void logEconomy(final Player executor, final ItemStack product, final OfflinePlayer vendor, final ShopType shopType, final Location location, final double price, final ShopBuySellEvent.Type type, final Callback<Void> callback) { public void logEconomy(final Player executor, final ItemStack product, final OfflinePlayer vendor, final ShopType shopType, final Location location, final double price, final ShopBuySellEvent.Type type, final Callback<Void> callback) {
if (plugin.getShopChestConfig().enable_ecomomy_log) { if (Config.enableEcomomyLog) {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {

View File

@ -1,6 +1,7 @@
package de.epiceric.shopchest.sql; package de.epiceric.shopchest.sql;
import de.epiceric.shopchest.ShopChest; import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import java.sql.Connection; import java.sql.Connection;
@ -23,10 +24,10 @@ public class MySQL extends Database {
Class.forName("com.mysql.jdbc.Driver"); Class.forName("com.mysql.jdbc.Driver");
String connectUrl = "jdbc:mysql://" + plugin.getShopChestConfig().database_mysql_host + ":" + plugin.getShopChestConfig().database_mysql_port + "/" + plugin.getShopChestConfig().database_mysql_database + "?autoReconnect=true&useSSL=false"; String connectUrl = "jdbc:mysql://" + Config.databaseMySqlHost + ":" + Config.databaseMySqlPort + "/" + Config.databaseMySqlDatabase + "?autoReconnect=true&useSSL=false";
plugin.debug("Connecting to MySQL Server \"" + connectUrl + "\" as user \"" + plugin.getShopChestConfig().database_mysql_username + "\""); plugin.debug("Connecting to MySQL Server \"" + connectUrl + "\" as user \"" + Config.databaseMySqlUsername + "\"");
connection = DriverManager.getConnection(connectUrl, plugin.getShopChestConfig().database_mysql_username, plugin.getShopChestConfig().database_mysql_password); connection = DriverManager.getConnection(connectUrl, Config.databaseMySqlUsername, Config.databaseMySqlPassword);
return connection; return connection;
} catch (Exception ex) { } catch (Exception ex) {

View File

@ -7,7 +7,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;

View File

@ -1,6 +1,7 @@
package de.epiceric.shopchest.utils; package de.epiceric.shopchest.utils;
import de.epiceric.shopchest.ShopChest; import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
@ -44,7 +45,7 @@ public class ShopUpdater {
*/ */
public void start() { public void start() {
if (!isRunning()) { if (!isRunning()) {
long interval = plugin.getShopChestConfig().update_quality.getInterval(); long interval = Config.updateQuality.getInterval();
running = Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, new ShopUpdaterTask(), interval, interval); running = Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, new ShopUpdaterTask(), interval, interval);
} }
} }

View File

@ -192,20 +192,20 @@ public class ShopUtils {
} }
if (limit < -1) limit = -1; if (limit < -1) limit = -1;
return (useDefault ? plugin.getShopChestConfig().default_limit : limit); return (useDefault ?Config.defaultLimit : limit);
} }
/** /**
* Get the amount of shops of a player * Get the amount of shops of a player
* @param p Player, whose shops should be counted * @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) * @return The amount of a shops a player has (if {@link Config#excludeAdminShops} is true, admin shops won't be counted)
*/ */
public int getShopAmount(OfflinePlayer p) { public int getShopAmount(OfflinePlayer p) {
float shopCount = 0; float shopCount = 0;
for (Shop shop : getShops()) { for (Shop shop : getShops()) {
if (shop.getVendor().equals(p)) { if (shop.getVendor().equals(p)) {
if (shop.getShopType() != Shop.ShopType.ADMIN || !plugin.getShopChestConfig().exclude_admin_shops) { if (shop.getShopType() != Shop.ShopType.ADMIN || !Config.excludeAdminShops) {
shopCount++; shopCount++;
InventoryHolder ih = shop.getInventoryHolder(); InventoryHolder ih = shop.getInventoryHolder();
@ -288,7 +288,7 @@ public class ShopUtils {
return; return;
} }
if (plugin.getShopChestConfig().only_show_shops_in_sight) { if (Config.onlyShowShopsInSight) {
updateVisibleShops(player); updateVisibleShops(player);
} else { } else {
updateNearestShops(player); updateNearestShops(player);
@ -308,12 +308,12 @@ public class ShopUtils {
private static final double TARGET_THRESHOLD = 1; private static final double TARGET_THRESHOLD = 1;
private void updateVisibleShops(Player player) { private void updateVisibleShops(Player player) {
double itemDistSquared = Math.pow(plugin.getShopChestConfig().maximal_item_distance, 2); double itemDistSquared = Math.pow(Config.maximalItemDistance, 2);
double hologramDistSquared = Math.pow(plugin.getShopChestConfig().maximal_distance, 2); double hologramDistSquared = Math.pow(Config.maximalDistance, 2);
boolean firstShopInSight = plugin.getShopChestConfig().only_show_first_shop_in_sight; boolean firstShopInSight =Config.onlyShowFirstShopInSight;
// used if only_show_first_shop_in_sight // used if onlyShowFirstShopInSight
List<Shop> otherShopsInSight = firstShopInSight ? new ArrayList<Shop>() : null; List<Shop> otherShopsInSight = firstShopInSight ? new ArrayList<Shop>() : null;
double nearestDistance = 0; double nearestDistance = 0;
Shop nearestShop = null; Shop nearestShop = null;
@ -403,8 +403,8 @@ public class ShopUtils {
} }
private void updateNearestShops(Player p) { private void updateNearestShops(Player p) {
double holoDistSqr = Math.pow(plugin.getShopChestConfig().maximal_distance, 2); double holoDistSqr = Math.pow(Config.maximalDistance, 2);
double itemDistSqr = Math.pow(plugin.getShopChestConfig().maximal_item_distance, 2); double itemDistSqr = Math.pow(Config.maximalItemDistance, 2);
for (Shop shop : getShops()) { for (Shop shop : getShops()) {
if (p.getLocation().getWorld().getName().equals(shop.getLocation().getWorld().getName())) { if (p.getLocation().getWorld().getName().equals(shop.getLocation().getWorld().getName())) {