Configured all classes to use the newest config

This commit is contained in:
Acrobot 2012-11-23 21:04:13 +01:00
parent 0d22ddc4a4
commit cb44575270
27 changed files with 170 additions and 221 deletions

View File

@ -1,9 +1,10 @@
package com.Acrobot.ChestShop;
import com.Acrobot.Breeze.Configuration.Configuration;
import com.Acrobot.ChestShop.Commands.ItemInfo;
import com.Acrobot.ChestShop.Commands.Version;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Property;
import com.Acrobot.ChestShop.Configuration.Messages;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.DB.Generator;
import com.Acrobot.ChestShop.DB.Queue;
import com.Acrobot.ChestShop.DB.Transaction;
@ -21,15 +22,16 @@ import com.Acrobot.ChestShop.Listeners.PreTransaction.*;
import com.Acrobot.ChestShop.Listeners.ShopRefundListener;
import com.Acrobot.ChestShop.Logging.FileFormatter;
import com.Acrobot.ChestShop.Signs.RestrictedSign;
import com.Acrobot.ChestShop.Utils.uName;
import com.avaje.ebean.EbeanServer;
import com.lennardf1989.bukkitex.Database;
import com.nijikokun.register.payment.forChestShop.Methods;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.Event;
import org.bukkit.event.Listener;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
@ -39,9 +41,6 @@ import java.util.List;
import java.util.logging.FileHandler;
import java.util.logging.Logger;
import static com.Acrobot.ChestShop.Config.Property.ALLOW_PARTIAL_TRANSACTIONS;
import static com.Acrobot.ChestShop.Config.Property.SHOP_INTERACTION_INTERVAL;
/**
* Main file of the plugin
*
@ -50,11 +49,10 @@ import static com.Acrobot.ChestShop.Config.Property.SHOP_INTERACTION_INTERVAL;
public class ChestShop extends JavaPlugin {
public static File dataFolder = new File("plugins/ChestShop");
private static EbeanServer DB;
private static EbeanServer database;
private static PluginDescriptionFile description;
private static Server server;
private static Logger logger;
private static PluginManager pluginManager;
private static ChestShop plugin;
private FileHandler handler;
@ -62,25 +60,31 @@ public class ChestShop extends JavaPlugin {
public void onEnable() {
plugin = this;
logger = getLogger();
pluginManager = getServer().getPluginManager();
dataFolder = getDataFolder();
description = getDescription();
server = getServer();
Config.setup();
Configuration.pairFileAndClass(loadFile("config.yml"), Properties.class);
Configuration.pairFileAndClass(loadFile("local.yml"), Messages.class);
uName.file = loadFile("longName.storage");
uName.load();
Methods.setPreferred(Properties.PREFERRED_ECONOMY_PLUGIN);
Dependencies.load();
registerEvents();
if (Config.getBoolean(Property.LOG_TO_DATABASE) || Config.getBoolean(Property.GENERATE_STATISTICS_PAGE)) {
if (Properties.LOG_TO_DATABASE || Properties.GENERATE_STATISTICS_PAGE) {
setupDB();
}
if (Config.getBoolean(Property.GENERATE_STATISTICS_PAGE)) {
File htmlFolder = new File(Config.getString(Property.STATISTICS_PAGE_PATH));
scheduleTask(new Generator(htmlFolder), 300L, (long) Config.getDouble(Property.STATISTICS_PAGE_GENERATION_INTERVAL) * 20L);
if (Properties.GENERATE_STATISTICS_PAGE) {
File htmlFolder = new File(Properties.STATISTICS_PAGE_PATH);
scheduleTask(new Generator(htmlFolder), 300L, Properties.STATISTICS_PAGE_GENERATION_INTERVAL * 20L);
}
if (Config.getBoolean(Property.LOG_TO_FILE)) {
File log = loadFile(new File(ChestShop.getFolder(), "ChestShop.log"));
if (Properties.LOG_TO_FILE) {
File log = loadFile("ChestShop.log");
FileHandler handler = loadHandler(log.getAbsolutePath());
handler.setFormatter(new FileFormatter());
@ -88,18 +92,22 @@ public class ChestShop extends JavaPlugin {
this.handler = handler;
logger.addHandler(handler);
}
if (!Config.getBoolean(Property.LOG_TO_CONSOLE)) {
if (!Properties.LOG_TO_CONSOLE) {
logger.setUseParentHandlers(false);
}
//Register our commands!
getCommand("iteminfo").setExecutor(new ItemInfo());
getCommand("csVersion").setExecutor(new Version());
//Start the statistics pinger
startStatistics();
}
public static File loadFile(String string) {
File file = new File(dataFolder, string);
return loadFile(file);
}
private static File loadFile(File file) {
if (!file.exists()) {
try {
@ -161,13 +169,13 @@ public class ChestShop extends JavaPlugin {
registerEvent(new ShopValidator());
registerEvent(new StockFittingChecker());
registerEvent(new ErrorMessageSender());
registerEvent(new SpamClickProtector(Config.getInteger(SHOP_INTERACTION_INTERVAL)));
registerEvent(new SpamClickProtector());
registerEvent(new RestrictedSign());
registerEvent(new DiscountModule());
registerEvent(new ShopRefundListener());
if (Config.getBoolean(ALLOW_PARTIAL_TRANSACTIONS)) {
if (Properties.ALLOW_PARTIAL_TRANSACTIONS) {
registerEvent(new PartialTransactionModule());
} else {
registerEvent(new AmountAndPriceChecker());
@ -193,14 +201,10 @@ public class ChestShop extends JavaPlugin {
}
///////////////////// DATABASE STUFF ////////////////////////////////
private static YamlConfiguration getBukkitConfig() {
return YamlConfiguration.loadConfiguration(new File("bukkit.yml"));
}
private static Database database;
private void setupDB() {
database = new Database(this) {
Database DB;
DB = new Database(this) {
protected java.util.List<Class<?>> getDatabaseClasses() {
List<Class<?>> list = new ArrayList<Class<?>>();
list.add(Transaction.class);
@ -208,9 +212,9 @@ public class ChestShop extends JavaPlugin {
}
};
YamlConfiguration config = getBukkitConfig();
FileConfiguration config = getConfig();
database.initializeDatabase(
DB.initializeDatabase(
config.getString("database.driver"),
config.getString("database.url"),
config.getString("database.username"),
@ -218,13 +222,13 @@ public class ChestShop extends JavaPlugin {
config.getString("database.isolation")
);
DB = database.getDatabase();
database = DB.getDatabase();
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Queue(), 200L, 200L);
}
@Override
public EbeanServer getDatabase() {
return database.getDatabase();
return database;
}
///////////////////////////////////////////////////////////////////////////////
@ -249,7 +253,7 @@ public class ChestShop extends JavaPlugin {
}
public static EbeanServer getDB() {
return DB;
return database;
}
public static List<String> getDependencies() {
@ -261,10 +265,6 @@ public class ChestShop extends JavaPlugin {
}
public static void callEvent(Event event) {
pluginManager.callEvent(event);
}
public static void scheduleRepeating(Runnable runnable, int delay) {
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, runnable, 0, delay);
Bukkit.getPluginManager().callEvent(event);
}
}

View File

@ -1,10 +1,9 @@
package com.Acrobot.ChestShop.Commands;
import com.Acrobot.Breeze.Utils.MaterialUtil;
import com.Acrobot.Breeze.Utils.MessageUtil;
import com.Acrobot.Breeze.Utils.StringUtil;
import com.Acrobot.ChestShop.ChestShop;
import com.Acrobot.ChestShop.Config.Language;
import com.Acrobot.ChestShop.Configuration.Messages;
import com.Acrobot.ChestShop.Events.ItemInfoEvent;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@ -13,6 +12,8 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.HumanEntity;
import org.bukkit.inventory.ItemStack;
import static com.Acrobot.ChestShop.Configuration.Messages.iteminfo;
/**
* @author Acrobot
*/
@ -37,7 +38,7 @@ public class ItemInfo implements CommandExecutor {
String durability = getDurability(item);
String enchantment = getEnchantment(item);
MessageUtil.sendMessage(sender, Language.iteminfo);
sender.sendMessage(Messages.prefix(iteminfo));
sender.sendMessage(getNameAndID(item) + durability + enchantment + ChatColor.WHITE);
ItemInfoEvent event = new ItemInfoEvent(sender, item);

View File

@ -1,8 +1,7 @@
package com.Acrobot.ChestShop.DB;
import com.Acrobot.ChestShop.ChestShop;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Property;
import com.Acrobot.ChestShop.Configuration.Properties;
import javax.persistence.OptimisticLockException;
import java.util.List;
@ -19,7 +18,7 @@ public class Queue implements Runnable {
}
public synchronized void run() {
if (Config.getInteger(Property.RECORD_TIME_TO_LIVE) != -1)
if (Properties.RECORD_TIME_TO_LIVE != -1)
deleteOld();
ChestShop.getDB().save(queue);
@ -40,7 +39,7 @@ public class Queue implements Runnable {
.getDB()
.find(Transaction.class)
.where()
.lt("sec", (System.currentTimeMillis() / 1000L) - Config.getInteger(Property.RECORD_TIME_TO_LIVE))
.lt("sec", (System.currentTimeMillis() / 1000L) - Properties.RECORD_TIME_TO_LIVE)
.findList();
}
}

View File

@ -1,7 +1,7 @@
package com.Acrobot.ChestShop;
import com.Acrobot.Breeze.Utils.MaterialUtil;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Economy.Economy;
import com.Acrobot.ChestShop.Economy.NoProvider;
import com.Acrobot.ChestShop.Economy.Register;
@ -16,8 +16,6 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
import static com.Acrobot.ChestShop.Config.Property.*;
/**
* @author Acrobot
*/
@ -84,7 +82,7 @@ public class Dependencies {
case Towny:
Towny towny = Towny.getTowny();
if (towny == null || !Config.getBoolean(TOWNY_INTEGRATION)) {
if (towny == null || !Properties.TOWNY_INTEGRATION) {
return;
}
@ -93,17 +91,17 @@ public class Dependencies {
break;
case WorldGuard:
WorldGuardPlugin worldGuard = (WorldGuardPlugin) plugin;
boolean inUse = Config.getBoolean(WORLDGUARD_USE_PROTECTION) || Config.getBoolean(WORLDGUARD_INTEGRATION);
boolean inUse = Properties.WORLDGUARD_USE_PROTECTION || Properties.WORLDGUARD_INTEGRATION;
if (!inUse) {
return;
}
if (Config.getBoolean(WORLDGUARD_USE_PROTECTION)) {
if (Properties.WORLDGUARD_USE_PROTECTION) {
ChestShop.registerListener(new WorldGuardProtection(worldGuard));
}
if (Config.getBoolean(WORLDGUARD_INTEGRATION)) {
if (Properties.WORLDGUARD_INTEGRATION) {
listener = new WorldGuardBuilding(worldGuard);
}

View File

@ -1,8 +1,7 @@
package com.Acrobot.ChestShop.Economy;
import com.Acrobot.Breeze.Utils.NumberUtil;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Property;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Signs.ChestShopSign;
import com.Acrobot.ChestShop.Utils.uName;
import org.bukkit.inventory.Inventory;
@ -25,7 +24,7 @@ public class Economy {
}
public static String getServerAccountName() {
return Config.getString(Property.SERVER_ECONOMY_ACCOUNT);
return Properties.SERVER_ECONOMY_ACCOUNT;
}
public static boolean isServerAccount(String acc) {
@ -37,7 +36,7 @@ public class Economy {
name = getServerAccountName();
}
Property taxAmount = isServerAccount(name) ? Property.SERVER_TAX_AMOUNT : Property.TAX_AMOUNT;
float taxAmount = isServerAccount(name) ? Properties.SERVER_TAX_AMOUNT : Properties.TAX_AMOUNT;
double tax = getTax(taxAmount, amount);
if (tax != 0) {
@ -50,8 +49,8 @@ public class Economy {
economy.add(uName.getName(name), amount);
}
public static double getTax(Property tax, double price) {
return NumberUtil.roundDown((Config.getFloat(tax) / 100F) * price);
public static double getTax(float tax, double price) {
return NumberUtil.roundDown((tax / 100F) * price);
}
public static void subtract(String name, double amount) {

View File

@ -1,8 +1,7 @@
package com.Acrobot.ChestShop.Listeners.Block;
import com.Acrobot.Breeze.Utils.BlockUtil;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Language;
import com.Acrobot.ChestShop.Configuration.Messages;
import com.Acrobot.ChestShop.Permission;
import com.Acrobot.ChestShop.Security;
import com.Acrobot.ChestShop.Signs.ChestShopSign;
@ -43,7 +42,7 @@ public class BlockPlace implements Listener {
}
if (!Security.canAccess(player, placed)) {
event.getPlayer().sendMessage(Config.getLocal(Language.ACCESS_DENIED));
event.getPlayer().sendMessage(Messages.prefix(Messages.ACCESS_DENIED));
event.setCancelled(true);
}
@ -54,7 +53,7 @@ public class BlockPlace implements Listener {
}
if (!Security.canAccess(event.getPlayer(), neighbor.getBlock())) {
event.getPlayer().sendMessage(Config.getLocal(Language.ACCESS_DENIED));
event.getPlayer().sendMessage(Messages.prefix(Messages.ACCESS_DENIED));
event.setCancelled(true);
}

View File

@ -1,7 +1,6 @@
package com.Acrobot.ChestShop.Listeners.Block.Break;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Property;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Listeners.Player.PlayerInteract;
import com.Acrobot.ChestShop.Plugins.ChestShop;
import com.Acrobot.ChestShop.Signs.ChestShopSign;
@ -12,7 +11,6 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import static com.Acrobot.ChestShop.Config.Property.USE_BUILT_IN_PROTECTION;
import static org.bukkit.Material.CHEST;
/**
@ -28,7 +26,7 @@ public class ChestBreak implements Listener {
@EventHandler(ignoreCancelled = true)
public static void onExplosion(EntityExplodeEvent event) {
if (event.blockList() == null || !Config.getBoolean(Property.USE_BUILT_IN_PROTECTION)) {
if (event.blockList() == null || !Properties.USE_BUILT_IN_PROTECTION) {
return;
}
@ -41,7 +39,7 @@ public class ChestBreak implements Listener {
}
private static boolean canChestBeBroken(Block chest, Player breaker) {
if (chest.getType() != CHEST || !Config.getBoolean(USE_BUILT_IN_PROTECTION) || ChestShopSign.isShopChest(chest)) {
if (chest.getType() != CHEST || !Properties.USE_BUILT_IN_PROTECTION || ChestShopSign.isShopChest(chest)) {
return true;
}

View File

@ -1,8 +1,7 @@
package com.Acrobot.ChestShop.Listeners.Block.Break;
import com.Acrobot.Breeze.Utils.BlockUtil;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Property;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Events.ShopDestroyedEvent;
import com.Acrobot.ChestShop.Permission;
import com.Acrobot.ChestShop.Signs.ChestShopSign;
@ -33,7 +32,6 @@ import java.util.List;
import static com.Acrobot.Breeze.Utils.BlockUtil.getAttachedFace;
import static com.Acrobot.Breeze.Utils.BlockUtil.isSign;
import static com.Acrobot.ChestShop.Config.Property.TURN_OFF_SIGN_PROTECTION;
import static com.Acrobot.ChestShop.Permission.ADMIN;
import static com.Acrobot.ChestShop.Permission.MOD;
import static com.Acrobot.ChestShop.Signs.ChestShopSign.NAME_LINE;
@ -70,7 +68,7 @@ public class SignBreak implements Listener {
@EventHandler(ignoreCancelled = true)
public static void onExplosion(EntityExplodeEvent event) {
if (event.blockList() == null || !Config.getBoolean(Property.USE_BUILT_IN_PROTECTION)) {
if (event.blockList() == null || !Properties.USE_BUILT_IN_PROTECTION) {
return;
}
@ -95,7 +93,7 @@ public class SignBreak implements Listener {
continue;
}
if (Config.getBoolean(TURN_OFF_SIGN_PROTECTION) || canDestroyShop(breaker, sign.getLine(NAME_LINE))) {
if (Properties.TURN_OFF_SIGN_PROTECTION || canDestroyShop(breaker, sign.getLine(NAME_LINE))) {
brokenBlocks.add(sign);
} else {
canBeBroken = false;

View File

@ -5,10 +5,9 @@ import com.Acrobot.Breeze.Utils.MaterialUtil;
import com.Acrobot.Breeze.Utils.PriceUtil;
import com.Acrobot.Breeze.Utils.StringUtil;
import com.Acrobot.ChestShop.ChestShop;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Language;
import com.Acrobot.ChestShop.Config.MaxPrice;
import com.Acrobot.ChestShop.Config.Property;
import com.Acrobot.ChestShop.Configuration.MaxPrice;
import com.Acrobot.ChestShop.Configuration.Messages;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Economy.Economy;
import com.Acrobot.ChestShop.Events.Protection.BuildPermissionEvent;
import com.Acrobot.ChestShop.Events.ShopCreatedEvent;
@ -29,9 +28,7 @@ import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.inventory.ItemStack;
import static com.Acrobot.Breeze.Utils.PriceUtil.NO_PRICE;
import static com.Acrobot.ChestShop.Config.Language.*;
import static com.Acrobot.ChestShop.Config.Property.SHOP_CREATION_PRICE;
import static com.Acrobot.ChestShop.Config.Property.STICK_SIGNS_TO_CHESTS;
import static com.Acrobot.ChestShop.Configuration.Messages.*;
import static com.Acrobot.ChestShop.Signs.ChestShopSign.*;
/**
@ -116,7 +113,7 @@ public class SignChange implements Listener {
return;
}
float shopCreationPrice = Config.getFloat(SHOP_CREATION_PRICE);
double shopCreationPrice = Properties.SHOP_CREATION_PRICE;
if (shopCreationPrice != 0 && !ChestShopSign.isAdminShop(line[NAME_LINE]) && !Permission.has(player, Permission.NOFEE)) {
if (!Economy.hasEnough(player.getName(), shopCreationPrice)) {
sendMessageAndExit(NOT_ENOUGH_MONEY, event);
@ -125,12 +122,12 @@ public class SignChange implements Listener {
Economy.subtract(player.getName(), shopCreationPrice);
player.sendMessage(Config.getLocal(SHOP_CREATED) + " - " + Economy.formatBalance(shopCreationPrice));
player.sendMessage(Messages.prefix(Messages.SHOP_CREATED + " - " + Economy.formatBalance(shopCreationPrice)));
} else {
player.sendMessage(Config.getLocal(SHOP_CREATED));
player.sendMessage(Messages.prefix(Messages.SHOP_CREATED));
}
if (!isAdminShop(line[NAME_LINE]) && Config.getBoolean(STICK_SIGNS_TO_CHESTS)) {
if (!isAdminShop(line[NAME_LINE]) && Properties.STICK_SIGNS_TO_CHESTS) {
stickSign(signBlock, event);
}
@ -172,7 +169,7 @@ public class SignChange implements Listener {
}
private static boolean canCreateShop(Player player, Material mat, double buyPrice, double sellPrice) {
if (Config.getBoolean(Property.BLOCK_SHOPS_WITH_SELL_PRICE_HIGHER_THAN_BUY_PRICE)) {
if (Properties.BLOCK_SHOPS_WITH_SELL_PRICE_HIGHER_THAN_BUY_PRICE) {
if (buyPrice != NO_PRICE && sellPrice != NO_PRICE && sellPrice > buyPrice) {
return false;
}
@ -230,8 +227,8 @@ public class SignChange implements Listener {
formatted = MaterialUtil.getName(item, false);
data = (split.length == 2 ? split[1] : "");
if (formatted.length() > (15 - data.length())) {
formatted = formatted.substring(0, (15 - data.length()));
if (formatted.length() > (15 - 1 - data.length())) {
formatted = formatted.substring(0, (15 - 1 - data.length()));
}
formattedItem = MaterialUtil.getItem(formatted);
@ -252,8 +249,8 @@ public class SignChange implements Listener {
return !name.isEmpty() && (uName.canUseName(player, name) || Permission.has(player, Permission.ADMIN));
}
private static void sendMessageAndExit(Language message, SignChangeEvent event) {
event.getPlayer().sendMessage(Config.getLocal(message));
private static void sendMessageAndExit(String message, SignChangeEvent event) {
event.getPlayer().sendMessage(message);
dropSign(event);
}

View File

@ -4,8 +4,8 @@ import com.Acrobot.Breeze.Utils.BlockUtil;
import com.Acrobot.Breeze.Utils.InventoryUtil;
import com.Acrobot.Breeze.Utils.MaterialUtil;
import com.Acrobot.Breeze.Utils.PriceUtil;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Language;
import com.Acrobot.ChestShop.Configuration.Messages;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Containers.AdminInventory;
import com.Acrobot.ChestShop.Events.PreTransactionEvent;
import com.Acrobot.ChestShop.Events.TransactionEvent;
@ -30,8 +30,6 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import static com.Acrobot.ChestShop.Config.Language.ACCESS_DENIED;
import static com.Acrobot.ChestShop.Config.Property.*;
import static com.Acrobot.ChestShop.Events.TransactionEvent.TransactionType;
import static com.Acrobot.ChestShop.Events.TransactionEvent.TransactionType.BUY;
import static com.Acrobot.ChestShop.Events.TransactionEvent.TransactionType.SELL;
@ -54,13 +52,13 @@ public class PlayerInteract implements Listener {
Action action = event.getAction();
Player player = event.getPlayer();
if (Config.getBoolean(USE_BUILT_IN_PROTECTION) && clickedBlock.getType() == Material.CHEST) {
if (Config.getBoolean(TURN_OFF_DEFAULT_PROTECTION_WHEN_PROTECTED_EXTERNALLY)) {
if (Properties.USE_BUILT_IN_PROTECTION && clickedBlock.getType() == Material.CHEST) {
if (Properties.TURN_OFF_DEFAULT_PROTECTION_WHEN_PROTECTED_EXTERNALLY) {
return;
}
if (!canOpenOtherShops(player) && !ChestShop.canAccess(player, clickedBlock)) {
player.sendMessage(Config.getLocal(ACCESS_DENIED));
player.sendMessage(Messages.prefix(Messages.ACCESS_DENIED));
event.setCancelled(true);
}
@ -78,11 +76,11 @@ public class PlayerInteract implements Listener {
}
if (ChestShopSign.canAccess(player, sign)) {
if (!Config.getBoolean(ALLOW_SIGN_CHEST_OPEN)) {
if (!Properties.ALLOW_SIGN_CHEST_OPEN) {
return;
}
if (action != LEFT_CLICK_BLOCK || !Config.getBoolean(ALLOW_LEFT_CLICK_DESTROYING)) {
if (action != LEFT_CLICK_BLOCK || !Properties.ALLOW_LEFT_CLICK_DESTROYING) {
showChestGUI(player, clickedBlock);
}
return;
@ -105,7 +103,7 @@ public class PlayerInteract implements Listener {
String priceLine = sign.getLine(PRICE_LINE);
Action buy = Config.getBoolean(REVERSE_BUTTONS) ? LEFT_CLICK_BLOCK : RIGHT_CLICK_BLOCK;
Action buy = Properties.REVERSE_BUTTONS ? LEFT_CLICK_BLOCK : RIGHT_CLICK_BLOCK;
double price = (action == buy ? PriceUtil.getBuyPrice(priceLine) : PriceUtil.getSellPrice(priceLine));
Chest chest = uBlock.findConnectedChest(sign);
@ -119,7 +117,7 @@ public class PlayerInteract implements Listener {
amount = 1;
}
if (Config.getBoolean(SHIFT_SELLS_EVERYTHING) && player.isSneaking() && price != PriceUtil.NO_PRICE) {
if (Properties.SHIFT_SELLS_EVERYTHING && player.isSneaking() && price != PriceUtil.NO_PRICE) {
int newAmount = getItemAmount(item, ownerInventory, player, action);
if (newAmount > 0) {
price = (price / amount) * newAmount;
@ -136,7 +134,7 @@ public class PlayerInteract implements Listener {
}
private static int getItemAmount(ItemStack item, Inventory inventory, Player player, Action action) {
Action buy = Config.getBoolean(REVERSE_BUTTONS) ? LEFT_CLICK_BLOCK : RIGHT_CLICK_BLOCK;
Action buy = Properties.REVERSE_BUTTONS ? LEFT_CLICK_BLOCK : RIGHT_CLICK_BLOCK;
if (action == buy) {
return InventoryUtil.getAmount(item, inventory);
@ -153,7 +151,7 @@ public class PlayerInteract implements Listener {
Chest chest = uBlock.findConnectedChest(block);
if (chest == null) {
player.sendMessage(Config.getLocal(Language.NO_CHEST_DETECTED));
player.sendMessage(Messages.prefix(Messages.NO_CHEST_DETECTED));
return;
}

View File

@ -1,7 +1,7 @@
package com.Acrobot.ChestShop.Listeners.PostTransaction;
import com.Acrobot.Breeze.Utils.InventoryUtil;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Events.TransactionEvent;
import com.Acrobot.ChestShop.Signs.ChestShopSign;
import com.Acrobot.ChestShop.Utils.uBlock;
@ -14,9 +14,6 @@ import org.bukkit.event.Listener;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import static com.Acrobot.ChestShop.Config.Property.REMOVE_EMPTY_CHESTS;
import static com.Acrobot.ChestShop.Config.Property.REMOVE_EMPTY_SHOPS;
/**
* @author Acrobot
*/
@ -36,7 +33,7 @@ public class EmptyShopDeleter implements Listener {
sign.getBlock().setType(Material.AIR);
if (Config.getBoolean(REMOVE_EMPTY_CHESTS) && !ChestShopSign.isAdminShop(ownerInventory) && InventoryUtil.isEmpty(ownerInventory)) {
if (Properties.REMOVE_EMPTY_CHESTS && !ChestShopSign.isAdminShop(ownerInventory) && InventoryUtil.isEmpty(ownerInventory)) {
Chest connectedChest = uBlock.findConnectedChest(sign);
connectedChest.getBlock().setType(Material.AIR);
} else {
@ -45,6 +42,6 @@ public class EmptyShopDeleter implements Listener {
}
private static boolean shopShouldBeRemoved(Inventory inventory, ItemStack[] stock) {
return Config.getBoolean(REMOVE_EMPTY_SHOPS) && !ChestShopSign.isAdminShop(inventory) && !InventoryUtil.hasItems(stock, inventory);
return Properties.REMOVE_EMPTY_SHOPS && !ChestShopSign.isAdminShop(inventory) && !InventoryUtil.hasItems(stock, inventory);
}
}

View File

@ -1,7 +1,7 @@
package com.Acrobot.ChestShop.Listeners.PostTransaction;
import com.Acrobot.ChestShop.ChestShop;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.DB.Queue;
import com.Acrobot.ChestShop.DB.Transaction;
import com.Acrobot.ChestShop.Events.TransactionEvent;
@ -11,8 +11,6 @@ import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import static com.Acrobot.Breeze.Utils.MaterialUtil.getSignName;
import static com.Acrobot.ChestShop.Config.Property.GENERATE_STATISTICS_PAGE;
import static com.Acrobot.ChestShop.Config.Property.LOG_TO_DATABASE;
import static com.Acrobot.ChestShop.Events.TransactionEvent.TransactionType.BUY;
/**
@ -44,7 +42,7 @@ public class TransactionLogger implements Listener {
@EventHandler
public static void onTransactionLogToDB(TransactionEvent event) {
if (!Config.getBoolean(LOG_TO_DATABASE) && !Config.getBoolean(GENERATE_STATISTICS_PAGE)) {
if (!Properties.LOG_TO_DATABASE && !Properties.GENERATE_STATISTICS_PAGE) {
return;
}

View File

@ -1,10 +1,12 @@
package com.Acrobot.ChestShop.Listeners.PostTransaction;
import com.Acrobot.Breeze.Utils.InventoryUtil;
import com.Acrobot.Breeze.Utils.MaterialUtil;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Language;
import com.Acrobot.ChestShop.Configuration.Messages;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Economy.Economy;
import com.Acrobot.ChestShop.Events.TransactionEvent;
import com.google.common.base.Joiner;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -12,13 +14,6 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import java.util.LinkedList;
import java.util.List;
import static com.Acrobot.ChestShop.Config.Language.*;
import static com.Acrobot.ChestShop.Config.Property.SHOW_TRANSACTION_INFORMATION_CLIENT;
import static com.Acrobot.ChestShop.Config.Property.SHOW_TRANSACTION_INFORMATION_OWNER;
/**
* @author Acrobot
*/
@ -40,15 +35,15 @@ public class TransactionMessageSender implements Listener {
String price = Economy.formatBalance(event.getPrice());
if (Config.getBoolean(SHOW_TRANSACTION_INFORMATION_CLIENT)) {
String message = formatMessage(YOU_BOUGHT_FROM_SHOP, itemName, price);
if (Properties.SHOW_TRANSACTION_INFORMATION_CLIENT) {
String message = formatMessage(Messages.YOU_BOUGHT_FROM_SHOP, itemName, price);
message = message.replace("%owner", owner);
player.sendMessage(message);
}
if (Config.getBoolean(SHOW_TRANSACTION_INFORMATION_OWNER)) {
String message = formatMessage(SOMEBODY_BOUGHT_FROM_YOUR_SHOP, itemName, price);
if (Properties.SHOW_TRANSACTION_INFORMATION_OWNER) {
String message = formatMessage(Messages.SOMEBODY_BOUGHT_FROM_YOUR_SHOP, itemName, price);
message = message.replace("%buyer", player.getName());
sendMessageToOwner(message, event);
@ -63,15 +58,15 @@ public class TransactionMessageSender implements Listener {
String price = Economy.formatBalance(event.getPrice());
if (Config.getBoolean(SHOW_TRANSACTION_INFORMATION_CLIENT)) {
String message = formatMessage(YOU_SOLD_TO_SHOP, itemName, price);
if (Properties.SHOW_TRANSACTION_INFORMATION_CLIENT) {
String message = formatMessage(Messages.YOU_SOLD_TO_SHOP, itemName, price);
message = message.replace("%buyer", owner);
player.sendMessage(message);
}
if (Config.getBoolean(SHOW_TRANSACTION_INFORMATION_OWNER)) {
String message = formatMessage(SOMEBODY_SOLD_TO_YOUR_SHOP, itemName, price);
if (Properties.SHOW_TRANSACTION_INFORMATION_OWNER) {
String message = formatMessage(Messages.SOMEBODY_SOLD_TO_YOUR_SHOP, itemName, price);
message = message.replace("%seller", player.getName());
sendMessageToOwner(message, event);
@ -79,28 +74,13 @@ public class TransactionMessageSender implements Listener {
}
private static String parseItemInformation(ItemStack[] items) {
List<ItemStack> stock = new LinkedList<ItemStack>();
for (ItemStack item : items) {
boolean added = false;
for (ItemStack iStack : stock) {
if (MaterialUtil.equals(item, iStack)) {
iStack.setAmount(iStack.getAmount() + item.getAmount());
added = true;
break;
}
}
if (!added) {
stock.add(item);
}
}
ItemStack[] stock = InventoryUtil.mergeSimilarStacks(items);
StringBuilder message = new StringBuilder(15);
Joiner joiner = Joiner.on(' ');
for (ItemStack item : stock) {
message.append(item.getAmount()).append(' ').append(item.getType().name());
joiner.appendTo(message, item.getAmount(), MaterialUtil.getSignName(item));
}
return message.toString();
@ -116,8 +96,8 @@ public class TransactionMessageSender implements Listener {
}
}
private static String formatMessage(Language message, String item, String price) {
return Config.getLocal(message)
private static String formatMessage(String message, String item, String price) {
return Messages.prefix(message)
.replace("%item", item)
.replace("%price", price);
}

View File

@ -1,13 +1,12 @@
package com.Acrobot.ChestShop.Listeners.PreTransaction;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Events.PreTransactionEvent;
import org.bukkit.GameMode;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import static com.Acrobot.ChestShop.Config.Property.IGNORE_CREATIVE_MODE;
import static com.Acrobot.ChestShop.Events.PreTransactionEvent.TransactionOutcome.CREATIVE_MODE_PROTECTION;
/**
@ -20,7 +19,7 @@ public class CreativeModeIgnorer implements Listener {
return;
}
if (Config.getBoolean(IGNORE_CREATIVE_MODE) && event.getClient().getGameMode() == GameMode.CREATIVE) {
if (Properties.IGNORE_CREATIVE_MODE && event.getClient().getGameMode() == GameMode.CREATIVE) {
event.setCancelled(CREATIVE_MODE_PROTECTION);
}
}

View File

@ -2,15 +2,15 @@ package com.Acrobot.ChestShop.Listeners.PreTransaction;
import com.Acrobot.Breeze.Utils.PriceUtil;
import com.Acrobot.ChestShop.ChestShop;
import com.Acrobot.ChestShop.Config.BreezeConfiguration;
import com.Acrobot.ChestShop.Containers.AdminInventory;
import com.Acrobot.ChestShop.Events.PreTransactionEvent;
import com.Acrobot.ChestShop.Permission;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
@ -22,11 +22,11 @@ import static com.Acrobot.ChestShop.Signs.ChestShopSign.PRICE_LINE;
* @author Acrobot
*/
public class DiscountModule implements Listener {
private BreezeConfiguration config;
private YamlConfiguration config;
private Set<String> groupList = new HashSet<String>();
public DiscountModule() {
config = BreezeConfiguration.loadConfiguration(new File(ChestShop.getFolder(), "discounts.yml"));
config = YamlConfiguration.loadConfiguration(ChestShop.loadFile("discounts.yml"));
config.options().header("This file is for discount management. You are able to do that:\n" +
"group1: 75\n" +
@ -34,7 +34,11 @@ public class DiscountModule implements Listener {
"For example, if the price is 100 dollars, the player pays only 75 dollars.\n" +
"(Only works in buy-only Admin Shops!)");
config.reload();
try {
config.save(ChestShop.loadFile("discounts.yml"));
} catch (IOException e) {
e.printStackTrace();
}
groupList = config.getKeys(false);
}

View File

@ -1,9 +1,8 @@
package com.Acrobot.ChestShop.Listeners.PreTransaction;
import com.Acrobot.Breeze.Utils.MaterialUtil;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Language;
import com.Acrobot.ChestShop.Config.Property;
import com.Acrobot.ChestShop.Configuration.Messages;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Events.PreTransactionEvent;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
@ -15,6 +14,8 @@ import org.bukkit.inventory.ItemStack;
import java.util.LinkedList;
import java.util.List;
import static com.Acrobot.ChestShop.Configuration.Messages.NOT_ENOUGH_STOCK_IN_YOUR_SHOP;
/**
* @author Acrobot
*/
@ -25,48 +26,48 @@ public class ErrorMessageSender implements Listener {
return;
}
Language message = null;
String message = null;
switch (event.getTransactionOutcome()) {
case SHOP_DOES_NOT_BUY_THIS_ITEM:
message = Language.NO_BUYING_HERE;
message = Messages.NO_BUYING_HERE;
break;
case SHOP_DOES_NOT_SELL_THIS_ITEM:
message = Language.NO_SELLING_HERE;
message = Messages.NO_SELLING_HERE;
break;
case CLIENT_DOES_NOT_HAVE_PERMISSION:
message = Language.NO_PERMISSION;
message = Messages.NO_PERMISSION;
break;
case CLIENT_DOES_NOT_HAVE_ENOUGH_MONEY:
message = Language.NOT_ENOUGH_MONEY;
message = Messages.NOT_ENOUGH_MONEY;
break;
case SHOP_DOES_NOT_HAVE_ENOUGH_MONEY:
message = Language.NOT_ENOUGH_MONEY_SHOP;
message = Messages.NOT_ENOUGH_MONEY_SHOP;
break;
case NOT_ENOUGH_SPACE_IN_CHEST:
message = Language.NOT_ENOUGH_SPACE_IN_CHEST;
message = Messages.NOT_ENOUGH_SPACE_IN_CHEST;
break;
case NOT_ENOUGH_SPACE_IN_INVENTORY:
message = Language.NOT_ENOUGH_SPACE_IN_INVENTORY;
message = Messages.NOT_ENOUGH_SPACE_IN_INVENTORY;
break;
case NOT_ENOUGH_STOCK_IN_INVENTORY:
message = Language.NOT_ENOUGH_ITEMS_TO_SELL;
message = Messages.NOT_ENOUGH_ITEMS_TO_SELL;
break;
case NOT_ENOUGH_STOCK_IN_CHEST:
String messageOutOfStock = Config.getLocal(Language.NOT_ENOUGH_STOCK_IN_YOUR_SHOP).replace("%material", getItemNames(event.getStock()));
String messageOutOfStock = Messages.prefix(NOT_ENOUGH_STOCK_IN_YOUR_SHOP).replace("%material", getItemNames(event.getStock()));
sendMessageToOwner(event.getOwner(), messageOutOfStock);
message = Language.NOT_ENOUGH_STOCK;
message = Messages.NOT_ENOUGH_STOCK;
break;
case SHOP_IS_RESTRICTED:
message = Language.ACCESS_DENIED;
message = Messages.ACCESS_DENIED;
break;
case INVALID_SHOP:
message = Language.INVALID_SHOP_DETECTED;
message = Messages.INVALID_SHOP_DETECTED;
break;
}
if (message != null) {
event.getClient().sendMessage(Config.getLocal(message));
event.getClient().sendMessage(Messages.prefix(message));
}
}
@ -98,7 +99,7 @@ public class ErrorMessageSender implements Listener {
}
private static void sendMessageToOwner(OfflinePlayer owner, String message) {
if (owner.isOnline() && Config.getBoolean(Property.SHOW_MESSAGE_OUT_OF_STOCK)) {
if (owner.isOnline() && Properties.SHOW_MESSAGE_OUT_OF_STOCK) {
Player player = (Player) owner;
player.sendMessage(message);
}

View File

@ -1,5 +1,6 @@
package com.Acrobot.ChestShop.Listeners.PreTransaction;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Events.PreTransactionEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -16,11 +17,6 @@ import static com.Acrobot.ChestShop.Events.PreTransactionEvent.TransactionOutcom
*/
public class SpamClickProtector implements Listener {
private final Map<Player, Long> TIME_OF_LATEST_CLICK = new WeakHashMap<Player, Long>();
private final int interval;
public SpamClickProtector(int interval) {
this.interval = interval;
}
@EventHandler(priority = EventPriority.LOWEST)
public void onClick(PreTransactionEvent event) {
@ -30,7 +26,7 @@ public class SpamClickProtector implements Listener {
Player clicker = event.getClient();
if (TIME_OF_LATEST_CLICK.containsKey(clicker) && (System.currentTimeMillis() - TIME_OF_LATEST_CLICK.get(clicker)) < interval) {
if (TIME_OF_LATEST_CLICK.containsKey(clicker) && (System.currentTimeMillis() - TIME_OF_LATEST_CLICK.get(clicker)) < Properties.SHOP_INTERACTION_INTERVAL) {
event.setCancelled(SPAM_CLICKING_PROTECTION);
return;
}

View File

@ -1,7 +1,7 @@
package com.Acrobot.ChestShop.Listeners;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Language;
import com.Acrobot.ChestShop.Configuration.Messages;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Economy.Economy;
import com.Acrobot.ChestShop.Events.ShopDestroyedEvent;
import com.Acrobot.ChestShop.Permission;
@ -10,7 +10,6 @@ import com.Acrobot.ChestShop.Utils.uName;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import static com.Acrobot.ChestShop.Config.Property.SHOP_REFUND_PRICE;
import static com.Acrobot.ChestShop.Permission.NOFEE;
/**
@ -19,7 +18,7 @@ import static com.Acrobot.ChestShop.Permission.NOFEE;
public class ShopRefundListener implements Listener {
@EventHandler
public static void onShopDestroy(ShopDestroyedEvent event) {
float refundPrice = Config.getFloat(SHOP_REFUND_PRICE);
double refundPrice = Properties.SHOP_REFUND_PRICE;
if (event.getDestroyer() == null || Permission.has(event.getDestroyer(), NOFEE) || refundPrice == 0) {
return;
@ -28,6 +27,6 @@ public class ShopRefundListener implements Listener {
String ownerName = uName.getName(event.getSign().getLine(ChestShopSign.NAME_LINE));
Economy.add(ownerName, refundPrice);
event.getDestroyer().sendMessage(Config.getLocal(Language.SHOP_REFUNDED).replace("%amount", Economy.formatBalance(refundPrice)));
event.getDestroyer().sendMessage(Messages.prefix(Messages.SHOP_REFUNDED).replace("%amount", Economy.formatBalance(refundPrice)));
}
}

View File

@ -1,7 +1,6 @@
package com.Acrobot.ChestShop.Plugins;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Property;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Events.ShopCreatedEvent;
import com.herocraftonline.heroes.characters.Hero;
import com.herocraftonline.heroes.characters.classes.HeroClass;
@ -21,7 +20,7 @@ public class Heroes implements Listener {
@EventHandler
public void shopCreated(ShopCreatedEvent event) {
double heroExp = Config.getDouble(Property.HEROES_EXP);
double heroExp = Properties.HEROES_EXP;
if (heroExp == 0) {
return;

View File

@ -1,6 +1,7 @@
package com.Acrobot.ChestShop.Plugins;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Configuration.Messages;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Events.Protection.ProtectBlockEvent;
import com.Acrobot.ChestShop.Events.Protection.ProtectionCheckEvent;
import com.Acrobot.ChestShop.Events.ShopCreatedEvent;
@ -17,11 +18,6 @@ import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import static com.Acrobot.ChestShop.Config.Language.NOT_ENOUGH_PROTECTIONS;
import static com.Acrobot.ChestShop.Config.Language.PROTECTED_SHOP;
import static com.Acrobot.ChestShop.Config.Property.PROTECT_CHEST_WITH_LWC;
import static com.Acrobot.ChestShop.Config.Property.PROTECT_SIGN_WITH_LWC;
/**
* @author Acrobot
*/
@ -40,14 +36,14 @@ public class LightweightChestProtection implements Listener {
Sign sign = event.getSign();
Chest connectedChest = event.getChest();
if (Config.getBoolean(PROTECT_SIGN_WITH_LWC)) {
if (Properties.PROTECT_SIGN_WITH_LWC) {
if (!Security.protect(player.getName(), sign.getBlock())) {
player.sendMessage(Config.getLocal(NOT_ENOUGH_PROTECTIONS));
player.sendMessage(Messages.prefix(Messages.NOT_ENOUGH_PROTECTIONS));
}
}
if (Config.getBoolean(PROTECT_CHEST_WITH_LWC) && connectedChest != null && Security.protect(player.getName(), connectedChest.getBlock())) {
player.sendMessage(Config.getLocal(PROTECTED_SHOP));
if (Properties.PROTECT_CHEST_WITH_LWC && connectedChest != null && Security.protect(player.getName(), connectedChest.getBlock())) {
player.sendMessage(Messages.prefix(Messages.PROTECTED_SHOP));
}
}

View File

@ -1,7 +1,6 @@
package com.Acrobot.ChestShop.Plugins;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Property;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Events.Protection.BuildPermissionEvent;
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
import com.palmergames.bukkit.towny.object.TownBlockOwner;
@ -28,7 +27,7 @@ public class Towny implements Listener {
boolean allow;
if (Config.getBoolean(Property.TOWNY_SHOPS_FOR_OWNERS_ONLY)) {
if (Properties.TOWNY_SHOPS_FOR_OWNERS_ONLY) {
allow = isPlotOwner(event.getPlayer(), chest, sign);
} else {
allow = isResident(event.getPlayer(), chest, sign);
@ -103,7 +102,7 @@ public class Towny implements Listener {
}
public static Towny getTowny() {
if (!Config.getBoolean(Property.TOWNY_INTEGRATION)) {
if (!Properties.TOWNY_INTEGRATION) {
return null;
}

View File

@ -1,8 +1,7 @@
package com.Acrobot.ChestShop.Plugins;
import com.Acrobot.ChestShop.ChestShop;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Property;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Events.Protection.BuildPermissionEvent;
import com.sk89q.worldedit.bukkit.BukkitUtil;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
@ -30,7 +29,7 @@ public class WorldGuardBuilding implements Listener {
public WorldGuardBuilding(WorldGuardPlugin plugin) {
this.worldGuard = plugin;
if (Config.getBoolean(Property.WORLDGUARD_USE_FLAG)) {
if (Properties.WORLDGUARD_USE_FLAG) {
ChestShopFlag.injectHax();
}
}
@ -39,7 +38,7 @@ public class WorldGuardBuilding implements Listener {
public void canBuild(BuildPermissionEvent event) {
ApplicableRegionSet regions = getApplicableRegions(event.getSign().getBlock().getLocation());
if (Config.getBoolean(Property.WORLDGUARD_USE_FLAG)) {
if (Properties.WORLDGUARD_USE_FLAG) {
event.allow(ChestShopFlag.setAllowsFlag(regions));
} else {
event.allow(regions.size() != 0);

View File

@ -1,8 +1,7 @@
package com.Acrobot.ChestShop;
import com.Acrobot.Breeze.Utils.BlockUtil;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Property;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Events.Protection.ProtectBlockEvent;
import com.Acrobot.ChestShop.Events.Protection.ProtectionCheckEvent;
import com.Acrobot.ChestShop.Signs.ChestShopSign;
@ -61,7 +60,7 @@ public class Security {
private static boolean anotherShopFound(Block baseBlock, Block signBlock, Player p) {
String shortName = uName.stripName(p.getName());
if (Config.getBoolean(Property.ALLOW_MULTIPLE_SHOPS_AT_ONE_BLOCK)) return false;
if (Properties.ALLOW_MULTIPLE_SHOPS_AT_ONE_BLOCK) return false;
for (BlockFace bf : SIGN_CONNECTION_FACES) {
Block block = baseBlock.getRelative(bf);

View File

@ -1,7 +1,7 @@
package com.Acrobot.ChestShop.Signs;
import com.Acrobot.Breeze.Utils.BlockUtil;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Containers.AdminInventory;
import com.Acrobot.ChestShop.Utils.uBlock;
import com.Acrobot.ChestShop.Utils.uName;
@ -14,8 +14,6 @@ import org.bukkit.inventory.Inventory;
import java.util.regex.Pattern;
import static com.Acrobot.ChestShop.Config.Property.ADMIN_SHOP_NAME;
/**
* @author Acrobot
*/
@ -37,7 +35,7 @@ public class ChestShopSign {
}
public static boolean isAdminShop(String owner) {
return owner.replace(" ", "").equalsIgnoreCase(Config.getString(ADMIN_SHOP_NAME).replace(" ", ""));
return owner.replace(" ", "").equalsIgnoreCase(Properties.ADMIN_SHOP_NAME.replace(" ", ""));
}
public static boolean isAdminShop(Sign sign) {

View File

@ -1,7 +1,7 @@
package com.Acrobot.ChestShop.Signs;
import com.Acrobot.Breeze.Utils.BlockUtil;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Configuration.Messages;
import com.Acrobot.ChestShop.Events.PreTransactionEvent;
import com.Acrobot.ChestShop.Permission;
import org.bukkit.Location;
@ -15,8 +15,6 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.SignChangeEvent;
import static com.Acrobot.ChestShop.Config.Language.ACCESS_DENIED;
import static com.Acrobot.ChestShop.Config.Language.RESTRICTED_SIGN_CREATED;
import static com.Acrobot.ChestShop.Events.PreTransactionEvent.TransactionOutcome.SHOP_IS_RESTRICTED;
import static com.Acrobot.ChestShop.Permission.ADMIN;
@ -47,7 +45,7 @@ public class RestrictedSign implements Listener {
if (isRestricted(lines)) {
if (!hasPermission(player, lines)) {
player.sendMessage(Config.getLocal(ACCESS_DENIED));
player.sendMessage(Messages.prefix(Messages.ACCESS_DENIED));
dropSignAndCancelEvent(event);
return;
}
@ -64,7 +62,7 @@ public class RestrictedSign implements Listener {
dropSignAndCancelEvent(event);
}
player.sendMessage(Config.getLocal(RESTRICTED_SIGN_CREATED));
player.sendMessage(Messages.prefix(Messages.RESTRICTED_SIGN_CREATED));
}
}

View File

@ -58,7 +58,7 @@ public class Methods {
}
private static Method getPreferredMethod() {
if (preferredPlugin.isEmpty()) {
if (preferredPlugin == null || preferredPlugin.isEmpty()) {
return null;
}

View File

@ -2,7 +2,7 @@ name: ChestShop
main: com.Acrobot.ChestShop.ChestShop
version: 3.50t0026
version: 3.50t0030
#for CButD
dev-url: http://dev.bukkit.org/server-mods/chestshop/