- Changed how configuration works, so it works with plugin folder in different place

- Added support for Deadbolt
- By default, left clicking your own sign doesn't do anything
- Restricted signs now check if you've got permission ChestShop.group.groupName
- Added support for stacking unstackable things
- Updated Register
- Changed how plugins are loaded.
This commit is contained in:
Acrobot 2011-09-06 19:01:57 +02:00
parent e47632793a
commit a84c68d49d
33 changed files with 513 additions and 442 deletions

View File

@ -3,6 +3,7 @@ package com.Acrobot.ChestShop;
import com.Acrobot.ChestShop.Commands.ItemInfo;
import com.Acrobot.ChestShop.Commands.Version;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.ConfigObject;
import com.Acrobot.ChestShop.Config.Property;
import com.Acrobot.ChestShop.DB.Generator;
import com.Acrobot.ChestShop.DB.Queue;
@ -14,6 +15,7 @@ import com.avaje.ebean.EbeanServer;
import com.lennardf1989.bukkitex.Database;
import org.bukkit.Server;
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;
@ -30,57 +32,34 @@ import java.util.List;
*/
public class ChestShop extends JavaPlugin {
public static final File folder = new File("plugins/ChestShop");
public static File folder = new File("plugins/ChestShop");
public static final String chatPrefix = "[ChestShop] ";
private static EbeanServer DB;
private static PluginDescriptionFile description;
private static Server server;
public static PluginManager pm;
public void onEnable() {
PluginManager pm = getServer().getPluginManager();
pm = getServer().getPluginManager();
folder = getDataFolder();
//Set up our config file!
Config.setUp();
Config.setup(new ConfigObject());
//Register our events
blockBreak blockBreak = new blockBreak();
registerEvents();
description = this.getDescription(); //Description of the plugin
server = getServer(); //Setting out server variable
pm.registerEvent(Event.Type.BLOCK_BREAK, blockBreak, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_PLACE, new blockPlace(), Event.Priority.Normal, this);
pm.registerEvent(Event.Type.SIGN_CHANGE, new signChange(), Event.Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_INTERACT, new playerInteract(), Event.Priority.Highest, this);
pm.registerEvent(Event.Type.PLUGIN_ENABLE, new pluginEnable(), Event.Priority.Monitor, this);
pm.registerEvent(Event.Type.PLUGIN_DISABLE, new pluginDisable(), Event.Priority.Monitor, this);
if(Config.getBoolean(Property.USE_BUILT_IN_PROTECTION)){
pm.registerEvent(Event.Type.BLOCK_PISTON_EXTEND, blockBreak, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_PISTON_RETRACT, blockBreak, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_EXPLODE, new entityExplode(), Event.Priority.Normal, this);
}
if (Config.getBoolean(Property.LOG_TO_DATABASE) || Config.getBoolean(Property.GENERATE_STATISTICS_PAGE)) { //Now set up our database for storing transactions!
setupDB();
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Queue(), 200L, 200L);
if (Config.getBoolean(Property.GENERATE_STATISTICS_PAGE)) {
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Generator(), 300L, (long) Config.getDouble(Property.STATISTICS_PAGE_GENERATION_INTERVAL) * 20L);
}
}
//Now set up our logging to file!
if (Config.getBoolean(Property.LOG_TO_FILE)) {
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new FileWriterQueue(), 201L, 201L);
}
//And now for the chest masking
if (Config.getBoolean(Property.MASK_CHESTS_AS_OTHER_BLOCKS)) {
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new MaskChest(), 40L, 40L);
}
pluginEnable.initializePlugins();
if (Config.getBoolean(Property.LOG_TO_DATABASE) || Config.getBoolean(Property.GENERATE_STATISTICS_PAGE)) setupDB();
if (Config.getBoolean(Property.GENERATE_STATISTICS_PAGE)) scheduleTask(new Generator(), 300L, (long) Config.getDouble(Property.STATISTICS_PAGE_GENERATION_INTERVAL) * 20L);
if (Config.getBoolean(Property.LOG_TO_FILE)) scheduleTask(new FileWriterQueue(), 201L, 201L);
if (Config.getBoolean(Property.MASK_CHESTS_AS_OTHER_BLOCKS)) scheduleTask(new MaskChest(), 40L, 40L);
//Register our commands!
getCommand("iteminfo").setExecutor(new ItemInfo());
@ -93,6 +72,33 @@ public class ChestShop extends JavaPlugin {
System.out.println('[' + getPluginName() + "] version " + getVersion() + " shutting down!");
}
////////////////// REGISTER EVENTS & SCHEDULER ///////////////////////////
private void registerEvents() {
blockBreak blockBreak = new blockBreak();
registerEvent(Event.Type.BLOCK_BREAK, blockBreak);
registerEvent(Event.Type.BLOCK_PLACE, new blockPlace());
registerEvent(Event.Type.SIGN_CHANGE, new signChange());
registerEvent(Event.Type.PLAYER_INTERACT, new playerInteract(), Event.Priority.Highest);
registerEvent(Event.Type.PLUGIN_ENABLE, new pluginEnable());
registerEvent(Event.Type.PLUGIN_DISABLE, new pluginDisable());
if (!Config.getBoolean(Property.USE_BUILT_IN_PROTECTION)) return;
registerEvent(Event.Type.BLOCK_PISTON_EXTEND, blockBreak);
registerEvent(Event.Type.BLOCK_PISTON_RETRACT, blockBreak);
registerEvent(Event.Type.ENTITY_EXPLODE, new entityExplode());
}
private void registerEvent(Event.Type type, Listener listener) {
registerEvent(type, listener, Event.Priority.Normal);
}
private void registerEvent(Event.Type type, Listener listener, Event.Priority priority) {
pm.registerEvent(type, listener, priority, this);
}
private void scheduleTask(Runnable runnable, long startTime, long repetetionTime) {
server.getScheduler().scheduleAsyncRepeatingTask(this, runnable, startTime, repetetionTime);
}
///////////////////// DATABASE STUFF ////////////////////////////////
private static Configuration getBukkitConfig() {
Configuration config = new Configuration(new File("bukkit.yml"));
@ -124,6 +130,7 @@ public class ChestShop extends JavaPlugin {
);
DB = database.getDatabase();
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Queue(), 200L, 200L);
}
@Override
@ -147,4 +154,8 @@ public class ChestShop extends JavaPlugin {
public static EbeanServer getDB() {
return DB;
}
public static ArrayList getDependencies() {
return (ArrayList) description.getSoftDepend();
}
}

View File

@ -24,7 +24,7 @@ public class ItemInfo implements CommandExecutor {
item = Items.getItemStack(args[0]);
}
if(item == null || item.getType() == Material.AIR) return false;
if (item == null || item.getType() == Material.AIR) return false;
sender.sendMessage(Config.getLocal(Language.iteminfo));
sender.sendMessage(item.getTypeId() + (item.getDurability() != 0 ? " : " + item.getDurability() : "") + " - " + ChatColor.GRAY + item.getType().name());

View File

@ -1,66 +1,23 @@
package com.Acrobot.ChestShop.Config;
import com.Acrobot.ChestShop.ChestShop;
import com.Acrobot.ChestShop.Utils.uLongName;
import org.bukkit.util.config.Configuration;
import java.io.File;
import java.io.FileWriter;
import com.LRFLEW.register.payment.forChestShop.Methods;
/**
* @author Acrobot
*/
public class Config {
private static final File configFile = new File(ChestShop.folder, "config.yml");
private static final File langFile = new File(ChestShop.folder, "local.yml");
private static final Configuration config = new Configuration(configFile);
private static final Configuration language = new Configuration(langFile);
private static ConfigObject config;
public static void setUp() {
if(!ChestShop.folder.exists()) ChestShop.folder.mkdir();
reloadConfig();
config.load();
reloadLanguage();
language.load();
uLongName.config.load();
}
private static void reloadConfig(){
config.load();
for (Property def : Property.values()) {
if (config.getProperty(def.name()) == null) {
writeToFile('\n' + def.name() + ": " + def.getValue() + "\n#" + def.getComment(), configFile);
}
}
}
private static void reloadLanguage(){
language.load();
for (Language def : Language.values()) {
if (language.getProperty(def.name()) == null) {
writeToFile('\n' + def.name() + ": \"" + def.toString() + '\"', langFile);
}
}
}
private static void writeToFile(String string, File file) {
try {
FileWriter fw = new FileWriter(file, true);
fw.write(string + '\n');
fw.close();
} catch (Exception e) {
System.out.println("Couldn't write to file - " + file.getName());
}
public static void setup(ConfigObject cfg) {
config = cfg;
Methods.preferred = Config.getString(Property.PREFERRED_ECONOMY_PLUGIN);
}
public static boolean getBoolean(Property value) {
return (Boolean) getValue(value.name());
}
public static float getFloat(Property value){
public static float getFloat(Property value) {
return new Float(getValue(value.name()).toString());
}
@ -73,7 +30,7 @@ public class Config {
}
public static double getDouble(Property value) {
return config.getDouble(value.name(), -1);
return Double.parseDouble(getValue(value.name()).toString());
}
private static String getColored(String msg) {
@ -81,16 +38,10 @@ public class Config {
}
public static String getLocal(Language lang) {
return getColored(language.getString(Language.prefix.name()) + language.getString(lang.name()));
return getColored(config.getLanguageConfig().getString(Language.prefix.name()) + config.getLanguageConfig().getString(lang.name()));
}
private static Object getValue(String node) {
return config.getProperty(node);
}
public static String getPreferred() {
config.load();
return getString(Property.PREFERRED_ECONOMY_PLUGIN);
}
}

View File

@ -0,0 +1,67 @@
package com.Acrobot.ChestShop.Config;
import com.Acrobot.ChestShop.ChestShop;
import com.Acrobot.ChestShop.Utils.uLongName;
import org.bukkit.util.config.Configuration;
import java.io.File;
import java.io.FileWriter;
/**
* @author Acrobot
*/
public class ConfigObject {
private final File configFile = new File(ChestShop.folder, "config.yml");
private final File langFile = new File(ChestShop.folder, "local.yml");
private final Configuration config = new Configuration(configFile);
private final Configuration language = new Configuration(langFile);
public ConfigObject() {
if (!ChestShop.folder.exists()) ChestShop.folder.mkdir();
reloadConfig();
config.load();
reloadLanguage();
language.load();
uLongName.config = new Configuration(new File(ChestShop.folder, "longName.storage"));
uLongName.config.load();
}
private void reloadConfig() {
config.load();
for (Property def : Property.values()) {
if (config.getProperty(def.name()) == null) {
writeToFile('\n' + def.name() + ": " + def.getValue() + "\n#" + def.getComment(), configFile);
}
}
}
private void reloadLanguage() {
language.load();
for (Language def : Language.values()) {
if (language.getProperty(def.name()) == null) {
writeToFile('\n' + def.name() + ": \"" + def.toString() + '\"', langFile);
}
}
}
private static void writeToFile(String string, File file) {
try {
FileWriter fw = new FileWriter(file, true);
fw.write(string);
fw.close();
} catch (Exception e) {
System.out.println("Couldn't write to file - " + file.getName());
}
}
public Configuration getLanguageConfig() {
return language;
}
public Object getProperty(String property) {
return config.getProperty(property);
}
}

View File

@ -3,7 +3,7 @@ package com.Acrobot.ChestShop.Config;
/**
* @author Acrobot
*/
public enum Language{
public enum Language {
prefix("&a[Shop] &f"),
iteminfo("&aItem Information:&f"),

View File

@ -6,7 +6,8 @@ package com.Acrobot.ChestShop.Config;
public enum Property {
PREFERRED_ECONOMY_PLUGIN("", "Preferred economy plugin (iConomy, BOSEconomy, Essentials). If you do not want to specify this, leave it blank."),
REVERSE_BUTTONS(false, "If true, people will buy with left-click and sell with right-click."),
//ALLOW_LEFT_CLICK_DESTROYING(false, "If true, if you left-click your own shop sign you won't open chest's inventory, but instead you will start destroying the sign."),
ALLOW_LEFT_CLICK_DESTROYING(true, "If true, if you left-click your own shop sign you won't open chest's inventory, but instead you will start destroying the sign."),
STACK_UNSTACKABLES(false, "If true, ALL things (including food, etc.) will stack up to 64"),
SERVER_ECONOMY_ACCOUNT("", "Economy account's name you want Admin Shops to be assigned to"),
ADMIN_SHOP_NAME("Admin Shop", "First line of your admin shop should look like this"),
SHOP_CREATION_PRICE(0, "Amount of money player must pay to create a shop"),

View File

@ -1,11 +1,11 @@
package com.Acrobot.ChestShop;
import com.Acrobot.ChestShop.Utils.uLongName;
import com.nijikokun.register.payment.forChestShop.Method;
import com.LRFLEW.register.payment.forChestShop.Method;
/**
* @author Acrobot
* Economy management
* Economy management
*/
public class Economy {
public static Method economy;

View File

@ -52,10 +52,10 @@ public class Items {
return item == null ? null : new ItemStack(item, 1, Short.parseShort(word[1]));
}
private static ItemStack getItemStackWithDataValueFromWord(String itemName){
private static ItemStack getItemStackWithDataValueFromWord(String itemName) {
int indexOfChar = itemName.indexOf(' ');
if(indexOfChar == -1) return null;
if (indexOfChar == -1) return null;
Material item = getMaterial(itemName.substring(indexOfChar));
return item == null ? null : new ItemStack(item, 1, DataValue.get(itemName.substring(0, indexOfChar), item));
}

View File

@ -32,15 +32,15 @@ public class blockBreak extends BlockListener {
if (cancellingBlockBreak(event.getBlock(), event.getPlayer())) event.setCancelled(true);
}
private static boolean isCorrectSign(Sign sign, Block block){
private static boolean isCorrectSign(Sign sign, Block block) {
return sign.getBlock() == block || getAttachedFace(sign) == block;
}
private static Block getAttachedFace(Sign sign){
private static Block getAttachedFace(Sign sign) {
return sign.getBlock().getRelative(((org.bukkit.material.Sign) sign.getData()).getAttachedFace());
}
private static boolean playerIsNotOwner(Player player, Sign sign){
private static boolean playerIsNotOwner(Player player, Sign sign) {
return player == null || !uLongName.stripName(player.getName()).equals(sign.getLine(0));
}

View File

@ -7,11 +7,11 @@ import org.bukkit.event.entity.EntityListener;
/**
* @author Acrobot
*/
public class entityExplode extends EntityListener{
public void onEntityExplode(EntityExplodeEvent event){
public class entityExplode extends EntityListener {
public void onEntityExplode(EntityExplodeEvent event) {
if (event.isCancelled() || event.blockList() == null) return;
for(Block block : event.blockList()){
if(blockBreak.cancellingBlockBreak(block, null)){
for (Block block : event.blockList()) {
if (blockBreak.cancellingBlockBreak(block, null)) {
event.setCancelled(true);
return;
}

View File

@ -57,9 +57,9 @@ public class playerInteract extends PlayerListener {
lastTransactionTime.put(player, System.currentTimeMillis());
event.setCancelled(true);
if (action == Action.RIGHT_CLICK_BLOCK) event.setCancelled(true);
if (uLongName.stripName(player.getName()).equals(sign.getLine(0))) {
if (uLongName.stripName(player.getName()).equals(sign.getLine(0)) && (action != Action.LEFT_CLICK_BLOCK || !Config.getBoolean(Property.ALLOW_LEFT_CLICK_DESTROYING))) {
showChestGUI(player, block);
return;
}

View File

@ -1,6 +1,7 @@
package com.Acrobot.ChestShop.Listeners;
import com.Acrobot.ChestShop.Economy;
import com.LRFLEW.register.payment.forChestShop.Methods;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.ServerListener;
@ -9,13 +10,9 @@ import org.bukkit.event.server.ServerListener;
*/
public class pluginDisable extends ServerListener {
public void onPluginDisable(PluginDisableEvent event) {
if (Economy.economy != null && pluginEnable.methods.hasMethod()) {
boolean check = pluginEnable.methods.checkDisabled(event.getPlugin());
if (check) {
Economy.economy = null;
System.out.println("[ChestShop] Economy plugin disabled!");
}
if (Economy.economy != null && Methods.hasMethod() && Methods.checkDisabled(event.getPlugin())) {
Economy.economy = null;
System.out.println("[ChestShop] Economy plugin disabled!");
}
}
}

View File

@ -1,17 +1,17 @@
package com.Acrobot.ChestShop.Listeners;
import com.Acrobot.ChestShop.ChestShop;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Economy;
import com.Acrobot.ChestShop.Items.Odd;
import com.Acrobot.ChestShop.Permission;
import com.Acrobot.ChestShop.Protection.Plugins.DeadboltPlugin;
import com.Acrobot.ChestShop.Protection.Plugins.LWCplugin;
import com.Acrobot.ChestShop.Protection.Plugins.LockettePlugin;
import com.Acrobot.ChestShop.Protection.Plugins.OldLockettePlugin;
import com.Acrobot.ChestShop.Protection.Security;
import com.LRFLEW.register.payment.forChestShop.Methods;
import com.daemitus.deadbolt.Deadbolt;
import com.griefcraft.lwc.LWCPlugin;
import com.nijikokun.bukkit.Permissions.Permissions;
import com.nijikokun.register.payment.forChestShop.Methods;
import info.somethingodd.bukkit.OddItem.OddItem;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
@ -19,47 +19,26 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.yi.acru.bukkit.Lockette.Lockette;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
/**
* @author Acrobot
*/
public class pluginEnable extends ServerListener {
public static final Methods methods = new Methods(Config.getPreferred());
private static final List<String> pluginsToLoad = new LinkedList<String>(Arrays.asList(
"Permissions",
"LWC",
"Lockette",
"OddItem"
));
public void onPluginEnable(PluginEnableEvent event) {
LinkedList<String> toRemove = new LinkedList();
//Economy plugins
if (!methods.hasMethod()) {
if (methods.setMethod(event.getPlugin())) {
Economy.economy = methods.getMethod();
System.out.println(ChestShop.chatPrefix + Economy.economy.getName() + ' ' + Economy.economy.getVersion() + " loaded.");
}
if (!Methods.hasMethod() && Methods.setMethod(ChestShop.pm)) {
Economy.economy = Methods.getMethod();
System.out.println(ChestShop.chatPrefix + Economy.economy.getName() + ' ' + Economy.economy.getVersion() + " loaded.");
}
}
for (String pluginName : pluginsToLoad) {
Plugin plugin = ChestShop.getBukkitServer().getPluginManager().getPlugin(pluginName);
if (plugin == null) continue;
initializePlugin(pluginName, plugin);
toRemove.add(pluginName);
public static void initializePlugins() {
for (Object plugin : ChestShop.getDependencies()) {
Plugin pl = ChestShop.pm.getPlugin((String) plugin);
if (pl != null) initializePlugin((String) plugin, pl);
}
for (String pluginName : toRemove) pluginsToLoad.remove(pluginName);
}
private static void initializePlugin(String name, Plugin plugin) { //Really messy, right? But it's short and fast :)
PluginDescriptionFile description = plugin.getDescription();
if (name.equals("Permissions")) {
if (Permission.permissions != null) return;
Permission.permissions = ((Permissions) plugin).getHandler();
@ -68,18 +47,18 @@ public class pluginEnable extends ServerListener {
LWCplugin.setLWC(((LWCPlugin) plugin).getLWC());
Security.protection = new LWCplugin();
} else if (name.equals("Lockette")) {
if (OldLockettePlugin.lockette != null || LockettePlugin.lockette != null) return;
if (plugin.getClass().getName().equals("com.daemitus.lockette.Lockette")) {
LockettePlugin.lockette = (com.daemitus.lockette.Lockette) plugin;
Security.protection = new LockettePlugin();
} else {
OldLockettePlugin.lockette = (Lockette) plugin;
Security.protection = new OldLockettePlugin();
}
if (LockettePlugin.lockette != null) return;
LockettePlugin.lockette = (Lockette) plugin;
Security.protection = new LockettePlugin();
} else if (name.equals("Deadbolt")) {
if (DeadboltPlugin.deadbolt != null) return;
DeadboltPlugin.deadbolt = (Deadbolt) plugin;
Security.protection = new DeadboltPlugin();
} else if (name.equals("OddItem")) {
if (Odd.oddItem != null) return;
Odd.oddItem = (OddItem) plugin;
}
PluginDescriptionFile description = plugin.getDescription();
System.out.println(ChestShop.chatPrefix + description.getName() + " version " + description.getVersion() + " loaded.");
}
}

View File

@ -27,7 +27,7 @@ public class Logging {
}
public static void log(String string) {
if (Config.getBoolean(Property.LOG_TO_CONSOLE)) logger.log(Level.INFO,"[ChestShop] " + string);
if (Config.getBoolean(Property.LOG_TO_CONSOLE)) logger.log(Level.INFO, "[ChestShop] " + string);
if (Config.getBoolean(Property.LOG_TO_FILE)) FileWriterQueue.addToQueue(getDateAndTime() + ' ' + string);
}
@ -36,7 +36,7 @@ public class Logging {
if (Config.getBoolean(Property.LOG_TO_DATABASE) || Config.getBoolean(Property.GENERATE_STATISTICS_PAGE)) logToDatabase(isBuying, shop, player);
}
private static void logToDatabase(boolean isBuying, Shop shop, Player player){
private static void logToDatabase(boolean isBuying, Shop shop, Player player) {
Transaction transaction = new Transaction();
transaction.setAmount(shop.stockAmount);

View File

@ -1,23 +1,23 @@
package com.Acrobot.ChestShop.Protection.Plugins;
import com.Acrobot.ChestShop.Protection.Protection;
import com.daemitus.deadbolt.Deadbolt;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.yi.acru.bukkit.Lockette.Lockette;
/**
* @author Acrobot
*/
public class OldLockettePlugin implements Protection {
public static Lockette lockette;
public class DeadboltPlugin implements Protection {
public static Deadbolt deadbolt;
public boolean isProtected(Block block) {
return Lockette.isProtected(block);
return Deadbolt.isProtected(block);
}
public boolean canAccess(Player player, Block block) {
int length = (player.getName().length() > 15? 15 : player.getName().length());
return player.getName().substring(0, length).equals(Lockette.getProtectedOwner(block));
int length = (player.getName().length() > 15 ? 15 : player.getName().length());
return Deadbolt.getAllNames(block).contains(player.getName().substring(0, length));
}
public boolean protect(String name, Block block) {

View File

@ -24,7 +24,7 @@ public class Default implements Protection {
String playerName = player.getName();
Sign sign = uBlock.findSign(block);
if(sign != null) return uLongName.stripName(playerName).equals(sign.getLine(0));
if (sign != null) return uLongName.stripName(playerName).equals(sign.getLine(0));
Chest neighborChest = uBlock.findNeighbor(block);
Sign neighborSign = (neighborChest != null ? uBlock.findSign(neighborChest.getBlock()) : null);

View File

@ -5,7 +5,6 @@ import com.Acrobot.ChestShop.Protection.Protection;
import com.griefcraft.lwc.LWC;
import com.griefcraft.model.ProtectionTypes;
import com.griefcraft.modules.limits.LimitsModule;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;

View File

@ -1,9 +1,9 @@
package com.Acrobot.ChestShop.Protection.Plugins;
import com.Acrobot.ChestShop.Protection.Protection;
import com.daemitus.lockette.Lockette;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.yi.acru.bukkit.Lockette.Lockette;
/**
* @author Acrobot
@ -16,8 +16,8 @@ public class LockettePlugin implements Protection {
}
public boolean canAccess(Player player, Block block) {
int length = (player.getName().length() > 15? 15 : player.getName().length());
return player.getName().substring(0, length).equals(Lockette.getOwnerName(block));
int length = (player.getName().length() > 15 ? 15 : player.getName().length());
return player.getName().substring(0, length).equals(Lockette.getProtectedOwner(block));
}
public boolean protect(String name, Block block) {

View File

@ -34,7 +34,8 @@ public class restrictedSign {
sign = (Sign) blockUp.getState();
for (int i = 1; i <= 3; i++) {
if(Permission.permissions.inGroup(world, playerName, sign.getLine(i))) return true;
if (Permission.permissions != null && Permission.permissions.inGroup(world, playerName, sign.getLine(i))) return true;
if (player.hasPermission("ChestShop.group." + sign.getLine(i))) return true;
}
return false;
}

View File

@ -1,5 +1,7 @@
package com.Acrobot.ChestShop.Utils;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Property;
import org.bukkit.Material;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@ -45,13 +47,29 @@ public class uInventory {
public static int add(Inventory inv, ItemStack item, int amount) {
amount = (amount > 0 ? amount : 1);
ItemStack itemToAdd = new ItemStack(item.getType(), amount, item.getDurability());
HashMap<Integer, ItemStack> items = inv.addItem(itemToAdd);
if (Config.getBoolean(Property.STACK_UNSTACKABLES)) return addAndStackTo64(inv, item, amount);
HashMap<Integer, ItemStack> items = inv.addItem(new ItemStack(item.getType(), amount, item.getDurability()));
amount = 0;
for(ItemStack toAdd : items.values()){
amount += toAdd.getAmount();
for (ItemStack toAdd : items.values()) amount += toAdd.getAmount();
return amount;
}
public static int addAndStackTo64(Inventory inv, ItemStack item, int amount) {
Material type = item.getType();
for (int slot = 0; slot < inv.getSize(); slot++) {
if (amount <= 0) return 0;
ItemStack curItem = inv.getItem(slot);
if (curItem == null || curItem.getType() == Material.AIR) {
item.setAmount((amount > 64 ? 64 : amount));
amount -= item.getAmount();
inv.setItem(slot, item);
} else if (curItem.getType() == type && curItem.getDurability() == item.getDurability() && curItem.getAmount() != 64) {
int toFill = (64 - curItem.getAmount());
item.setAmount((amount > toFill ? 64 : curItem.getAmount() + amount));
amount -= item.getAmount();
inv.setItem(slot, item);
}
}
return amount;
}
@ -68,7 +86,7 @@ public class uInventory {
public static int fits(Inventory inv, ItemStack item, int amount, short durability) {
Material itemMaterial = item.getType();
int maxStackSize = itemMaterial.getMaxStackSize();
int maxStackSize = (Config.getBoolean(Property.STACK_UNSTACKABLES) ? 64 : itemMaterial.getMaxStackSize());
int amountLeft = amount;
for (ItemStack currentItem : inv.getContents()) {

View File

@ -9,7 +9,7 @@ import java.io.File;
* @author Acrobot
*/
public class uLongName {
public static final Configuration config = new Configuration(new File(ChestShop.folder, "longName.storage"));
public static Configuration config = new Configuration(new File(ChestShop.folder, "longName.storage"));
public static String getName(final String shortName) {
return config.getString(shortName, shortName);

View File

@ -38,12 +38,12 @@ public class uSign {
}
}
public static boolean isValidPreparedSign(String[] lines){
try{
public static boolean isValidPreparedSign(String[] lines) {
try {
boolean toReturn = true;
for(int i = 0; i < 4 && toReturn; i++) toReturn = patterns[i].matcher(lines[i]).matches();
for (int i = 0; i < 4 && toReturn; i++) toReturn = patterns[i].matcher(lines[i]).matches();
return toReturn && lines[2].split(":").length <= 2;
} catch (Exception e){
} catch (Exception e) {
return false;
}
}
@ -56,13 +56,13 @@ public class uSign {
return price(text, false);
}
private static float price(String text, boolean buy){
private static float price(String text, boolean buy) {
String toContain = buy ? "b" : "s";
text = text.replace(" ", "").toLowerCase();
String[] split = text.split(":");
int part = (text.contains(toContain) ? (split[0].contains(toContain) ? 0 : 1) : -1);
if(part == -1 || (part == 1 && split.length != 2)) return -1;
if (part == -1 || (part == 1 && split.length != 2)) return -1;
split[part] = split[part].replace(toContain, "");

View File

@ -1,4 +1,4 @@
package com.nijikokun.register.payment.forChestShop;
package com.LRFLEW.register.payment.forChestShop;
import org.bukkit.plugin.Plugin;
@ -39,6 +39,13 @@ public interface Method {
*/
public String getVersion();
/**
* Returns the amount of decimal places that get stored
* NOTE: it will return -1 if there is no rounding
*
* @return <code>int</code> for each decimal place
*/
public int fractionalDigits();
/**
* Formats amounts into this payment methods style of currency display.

View File

@ -0,0 +1,205 @@
package com.LRFLEW.register.payment.forChestShop;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import java.util.HashSet;
import java.util.Set;
/**
* The <code>Methods</code> initializes Methods that utilize the Method interface
* based on a "first come, first served" basis.
* <p/>
* Allowing you to check whether a payment method exists or not.
* <p/>
* Methods also allows you to set a preferred method of payment before it captures
* payment plugins in the initialization process.
* <p/>
* in server.properties:
* <blockquote><pre>
* economy=iConomy
* </pre></blockquote>
*
* @author: Nijikokun <nijikokun@shortmail.com> (@nijikokun)
* @copyright: Copyright (C) 2011
* @license: AOL license <http://aol.nexua.org>
*/
public class Methods {
private static String version = null;
private static boolean self = false;
private static Method Method = null;
public static String preferred = "";
private static Set<Method> Methods = new HashSet<Method>();
private static Set<String> Dependencies = new HashSet<String>();
private static Set<Method> Attachables = new HashSet<Method>();
static { _init(); }
/**
* Implement all methods along with their respective name & class.
*/
private static void _init() {
addMethod("iConomy", new com.LRFLEW.register.payment.forChestShop.methods.iCo6());
addMethod("iConomy", new com.LRFLEW.register.payment.forChestShop.methods.iCo5());
addMethod("iConomy", new com.LRFLEW.register.payment.forChestShop.methods.iCo4());
addMethod("BOSEconomy", new com.LRFLEW.register.payment.forChestShop.methods.BOSE6());
addMethod("BOSEconomy", new com.LRFLEW.register.payment.forChestShop.methods.BOSE7());
addMethod("Essentials", new com.LRFLEW.register.payment.forChestShop.methods.EE17());
addMethod("Currency", new com.LRFLEW.register.payment.forChestShop.methods.MCUR());
Dependencies.add("MultiCurrency");
}
/**
* Used by the plugin to setup version
*
* @param v version
*/
public static void setVersion(String v) {
version = v;
}
/**
* Use to reset methods during disable
*/
public static void reset() {
version = null;
self = false;
Method = null;
preferred = "";
Attachables.clear();
}
/**
* Use to get version of Register plugin
*
* @return version
*/
public static String getVersion() {
return version;
}
/**
* Returns an array of payment method names that have been loaded
* through the <code>_init</code> method.
*
* @return <code>Set<String></code> - Array of payment methods that are loaded.
*/
public static Set<String> getDependencies() {
return Dependencies;
}
/**
* Interprets Plugin class data to verify whether it is compatible with an existing payment
* method to use for payments and other various economic activity.
*
* @param plugin Plugin data from bukkit, Internal Class file.
* @return Method <em>or</em> Null
*/
public static Method createMethod(Plugin plugin) {
for (Method method : Methods) {
if (method.isCompatible(plugin)) {
method.setPlugin(plugin);
return method;
}
}
return null;
}
private static void addMethod(String name, Method method) {
Dependencies.add(name);
Methods.add(method);
}
/**
* Verifies if Register has set a payment method for usage yet.
*
* @return <code>boolean</code>
* @see #checkDisabled(org.bukkit.plugin.Plugin)
*/
public static boolean hasMethod() {
return (Method != null);
}
/**
* Checks Plugin Class against a multitude of checks to verify it's usability
* as a payment method.
*
* @return <code>boolean</code> True on success, False on failure.
*/
public static boolean setMethod(PluginManager manager) {
if (hasMethod()) return true;
if (self) { self = false; return false; }
int count = 0;
boolean match = false;
Plugin plugin;
for (String name : Dependencies) {
if (hasMethod()) break;
plugin = manager.getPlugin(name);
if (plugin == null) continue;
Method current = createMethod(plugin);
if (current == null) continue;
if (preferred.isEmpty())
Method = current;
else {
Attachables.add(current);
}
}
if (!preferred.isEmpty()) {
do {
if (hasMethod()) {
match = true;
} else {
for (Method attached : Attachables) {
if (attached == null) continue;
if (hasMethod()) {
match = true;
break;
}
if (preferred.isEmpty()) Method = attached;
if (count == 0) {
if (preferred.equalsIgnoreCase(attached.getName()))
Method = attached;
} else {
Method = attached;
}
}
count++;
}
} while (!match);
}
return hasMethod();
}
/**
* Grab the existing and initialized (hopefully) Method Class.
*
* @return <code>Method</code> <em>or</em> <code>Null</code>
*/
public static Method getMethod() {
return Method;
}
/**
* Verify is a plugin is disabled, only does this if we there is an existing payment
* method initialized in Register.
*
* @param method Plugin data from bukkit, Internal Class file.
* @return <code>boolean</code>
*/
public static boolean checkDisabled(Plugin method) {
if (!hasMethod()) return true;
if (Method.isCompatible(method)) Method = null;
return (Method == null);
}
}

View File

@ -1,6 +1,7 @@
package com.nijikokun.register.payment.forChestShop.methods;
package com.LRFLEW.register.payment.forChestShop.methods;
import com.LRFLEW.register.payment.forChestShop.Method;
import com.nijikokun.register.payment.forChestShop.Method;
import cosine.boseconomy.BOSEconomy;
import org.bukkit.plugin.Plugin;
@ -11,7 +12,7 @@ import org.bukkit.plugin.Plugin;
* @copyright (c) 2011
* @license AOL license <http://aol.nexua.org>
*/
@SuppressWarnings({"deprecation"})
@SuppressWarnings("deprecation")
public class BOSE6 implements Method {
private BOSEconomy BOSEconomy;
@ -27,6 +28,10 @@ public class BOSE6 implements Method {
return "0.6.2";
}
public int fractionalDigits() {
return 0;
}
public String format(double amount) {
String currency = this.BOSEconomy.getMoneyNamePlural();
if(amount == 1) currency = this.BOSEconomy.getMoneyName();
@ -76,7 +81,7 @@ public class BOSE6 implements Method {
this.BOSEconomy = bOSEconomy;
}
public double balance() {
public double balance() {
return (double) this.BOSEconomy.getPlayerMoney(this.name);
}

View File

@ -1,6 +1,7 @@
package com.nijikokun.register.payment.forChestShop.methods;
package com.LRFLEW.register.payment.forChestShop.methods;
import com.LRFLEW.register.payment.forChestShop.Method;
import com.nijikokun.register.payment.forChestShop.Method;
import cosine.boseconomy.BOSEconomy;
import org.bukkit.plugin.Plugin;
@ -27,6 +28,10 @@ public class BOSE7 implements Method {
return "0.7.0";
}
public int fractionalDigits() {
return this.BOSEconomy.getFractionalDigits();
}
public String format(double amount) {
String currency = this.BOSEconomy.getMoneyNamePlural();
if(amount == 1) currency = this.BOSEconomy.getMoneyName();
@ -68,8 +73,8 @@ public class BOSE7 implements Method {
}
public static class BOSEAccount implements MethodAccount {
private final String name;
private final BOSEconomy BOSEconomy;
private String name;
private BOSEconomy BOSEconomy;
public BOSEAccount(String name, BOSEconomy bOSEconomy) {
this.name = name;
@ -125,8 +130,8 @@ public class BOSE7 implements Method {
}
public static class BOSEBankAccount implements MethodBankAccount {
private final String bank;
private final BOSEconomy BOSEconomy;
private String bank;
private BOSEconomy BOSEconomy;
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) {
this.bank = bank;

View File

@ -1,11 +1,11 @@
package com.nijikokun.register.payment.forChestShop.methods;
package com.LRFLEW.register.payment.forChestShop.methods;
import com.LRFLEW.register.payment.forChestShop.Method;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.api.Economy;
import com.earth2me.essentials.api.NoLoanPermittedException;
import com.earth2me.essentials.api.UserDoesNotExistException;
import com.nijikokun.register.payment.forChestShop.Method;
import org.bukkit.plugin.Plugin;
@ -34,6 +34,10 @@ public class EE17 implements Method {
return "2.2";
}
public int fractionalDigits() {
return -1;
}
public String format(double amount) {
return Economy.format(amount);
}
@ -75,7 +79,7 @@ public class EE17 implements Method {
}
public static class EEcoAccount implements MethodAccount {
private final String name;
private String name;
public EEcoAccount(String name) {
this.name = name;

View File

@ -1,6 +1,6 @@
package com.nijikokun.register.payment.forChestShop.methods;
package com.LRFLEW.register.payment.forChestShop.methods;
import com.nijikokun.register.payment.forChestShop.Method;
import com.LRFLEW.register.payment.forChestShop.Method;
import me.ashtheking.currency.Currency;
import me.ashtheking.currency.CurrencyList;
@ -22,13 +22,17 @@ public class MCUR implements Method {
}
public String getName() {
return "Currency";
return "MultiCurrency";
}
public String getVersion() {
return "0.09";
}
public int fractionalDigits() {
return -1;
}
public String format(double amount) {
return amount + " Currency";
}
@ -58,7 +62,9 @@ public class MCUR implements Method {
}
public boolean isCompatible(Plugin plugin) {
return plugin.getDescription().getName().equalsIgnoreCase(getName()) && plugin instanceof Currency;
return (plugin.getDescription().getName().equalsIgnoreCase("Currency")
|| plugin.getDescription().getName().equalsIgnoreCase("MultiCurrency"))
&& plugin instanceof Currency;
}
public void setPlugin(Plugin plugin) {
@ -66,7 +72,7 @@ public class MCUR implements Method {
}
public static class MCurrencyAccount implements MethodAccount{
private final String name;
private String name;
public MCurrencyAccount(String name) {
this.name = name;

View File

@ -1,9 +1,9 @@
package com.nijikokun.register.payment.forChestShop.methods;
package com.LRFLEW.register.payment.forChestShop.methods;
import com.LRFLEW.register.payment.forChestShop.Method;
import com.nijiko.coelho.iConomy.iConomy;
import com.nijiko.coelho.iConomy.system.Account;
import com.nijikokun.register.payment.forChestShop.Method;
import org.bukkit.plugin.Plugin;
@ -29,8 +29,12 @@ public class iCo4 implements Method {
return "4";
}
public String format(double amount) {
return iConomy.getBank().format(amount);
public int fractionalDigits() {
return 2;
}
public String format(double amount) {
return com.nijiko.coelho.iConomy.iConomy.getBank().format(amount);
}
public boolean hasBanks() {
@ -42,7 +46,7 @@ public class iCo4 implements Method {
}
public boolean hasAccount(String name) {
return iConomy.getBank().hasAccount(name);
return com.nijiko.coelho.iConomy.iConomy.getBank().hasAccount(name);
}
public boolean hasBankAccount(String bank, String name) {
@ -50,7 +54,7 @@ public class iCo4 implements Method {
}
public MethodAccount getAccount(String name) {
return new iCoAccount(iConomy.getBank().getAccount(name));
return new iCoAccount(com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(name));
}
public MethodBankAccount getBankAccount(String bank, String name) {
@ -58,7 +62,9 @@ public class iCo4 implements Method {
}
public boolean isCompatible(Plugin plugin) {
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && !plugin.getClass().getName().equals("com.iConomy.iConomy") && plugin.getDescription().getVersion().length() > 0 && plugin.getDescription().getVersion().charAt(0) == '4' && plugin instanceof iConomy;
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
&& plugin.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy")
&& plugin instanceof iConomy;
}
public void setPlugin(Plugin plugin) {

View File

@ -1,12 +1,12 @@
package com.nijikokun.register.payment.forChestShop.methods;
package com.LRFLEW.register.payment.forChestShop.methods;
import com.LRFLEW.register.payment.forChestShop.Method;
import com.iConomy.iConomy;
import com.iConomy.system.Account;
import com.iConomy.system.BankAccount;
import com.iConomy.system.Holdings;
import com.iConomy.util.Constants;
import com.nijikokun.register.payment.forChestShop.Method;
import org.bukkit.plugin.Plugin;
@ -32,8 +32,12 @@ public class iCo5 implements Method {
return "5";
}
public String format(double amount) {
return iConomy.format(amount);
public int fractionalDigits() {
return 2;
}
public String format(double amount) {
return com.iConomy.iConomy.format(amount);
}
public boolean hasBanks() {
@ -41,27 +45,29 @@ public class iCo5 implements Method {
}
public boolean hasBank(String bank) {
return (hasBanks()) && this.iConomy.Banks.exists(bank);
return (hasBanks()) && com.iConomy.iConomy.Banks.exists(bank);
}
public boolean hasAccount(String name) {
return this.iConomy.hasAccount(name);
return com.iConomy.iConomy.hasAccount(name);
}
public boolean hasBankAccount(String bank, String name) {
return (hasBank(bank)) && this.iConomy.getBank(bank).hasAccount(name);
return (hasBank(bank)) && com.iConomy.iConomy.getBank(bank).hasAccount(name);
}
public MethodAccount getAccount(String name) {
return new iCoAccount(this.iConomy.getAccount(name));
return new iCoAccount(com.iConomy.iConomy.getAccount(name));
}
public MethodBankAccount getBankAccount(String bank, String name) {
return new iCoBankAccount(this.iConomy.getBank(bank).getAccount(name));
return new iCoBankAccount(com.iConomy.iConomy.getBank(bank).getAccount(name));
}
public boolean isCompatible(Plugin plugin) {
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.iConomy.iConomy") && plugin instanceof iConomy;
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
&& plugin.getClass().getName().equals("com.iConomy.iConomy")
&& plugin instanceof iConomy;
}
public void setPlugin(Plugin plugin) {

View File

@ -1,11 +1,11 @@
package com.nijikokun.register.payment.forChestShop.methods;
package com.LRFLEW.register.payment.forChestShop.methods;
import com.LRFLEW.register.payment.forChestShop.Method;
import com.iCo6.iConomy;
import com.iCo6.system.Account;
import com.iCo6.system.Accounts;
import com.iCo6.system.Holdings;
import com.nijikokun.register.payment.forChestShop.Method;
import org.bukkit.plugin.Plugin;
@ -31,8 +31,12 @@ public class iCo6 implements Method {
return "6";
}
public String format(double amount) {
return iConomy.format(amount);
public int fractionalDigits() {
return 2;
}
public String format(double amount) {
return com.iCo6.iConomy.format(amount);
}
public boolean hasBanks() {
@ -60,10 +64,9 @@ public class iCo6 implements Method {
}
public boolean isCompatible(Plugin plugin) {
try { Class.forName("com.iCo6.IO.InventoryDB"); }
catch(Exception e) {return false;}
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.iCo6.iConomy") && plugin instanceof iConomy;
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
&& plugin.getClass().getName().equals("com.iCo6.iConomy")
&& plugin instanceof iConomy;
}
public void setPlugin(Plugin plugin) {
@ -71,8 +74,8 @@ public class iCo6 implements Method {
}
public static class iCoAccount implements MethodAccount {
private final Account account;
private final Holdings holdings;
private Account account;
private Holdings holdings;
public iCoAccount(Account account) {
this.account = account;

View File

@ -1,203 +0,0 @@
package com.nijikokun.register.payment.forChestShop;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import java.util.HashSet;
import java.util.Set;
/**
* The <code>Methods</code> initializes Methods that utilize the Method interface
* based on a "first come, first served" basis.
*
* Allowing you to check whether a payment method exists or not.
*
* <blockquote><pre>
* Methods methods = new Methods();
* </pre></blockquote>
*
* Methods also allows you to set a preferred method of payment before it captures
* payment plugins in the initialization process.
*
* <blockquote><pre>
* Methods methods = new Methods("iConomy");
* </pre></blockquote>
*
* @author: Nijikokun <nijikokun@shortmail.com> (@nijikokun)
* @copyright: Copyright (C) 2011
* @license: AOL license <http://aol.nexua.org>
*/
public class Methods {
private boolean self = false;
private Method Method = null;
private String preferred = "";
private final Set<Method> Methods = new HashSet<Method>();
private final Set<String> Dependencies = new HashSet<String>();
private final Set<Method> Attachables = new HashSet<Method>();
/**
* Initialize Method class
*/
public Methods() {
this._init();
}
/**
* Initializes <code>Methods</code> class utilizing a "preferred" payment method check before
* returning the first method that was initialized.
*
* @param preferred Payment method that is most preferred for this setup.
*/
public Methods(String preferred) {
this._init();
if(this.Dependencies.contains(preferred)) {
this.preferred = preferred;
}
}
/**
* Implement all methods along with their respective name & class.
*
* @see #Methods()
* @see #Methods(java.lang.String)
*/
private void _init() {
this.addMethod("iConomy", new com.nijikokun.register.payment.forChestShop.methods.iCo6());
this.addMethod("iConomy", new com.nijikokun.register.payment.forChestShop.methods.iCo5());
this.addMethod("iConomy", new com.nijikokun.register.payment.forChestShop.methods.iCo4());
this.addMethod("BOSEconomy", new com.nijikokun.register.payment.forChestShop.methods.BOSE6());
this.addMethod("BOSEconomy", new com.nijikokun.register.payment.forChestShop.methods.BOSE7());
this.addMethod("Essentials", new com.nijikokun.register.payment.forChestShop.methods.EE17());
this.addMethod("MultiCurrency", new com.nijikokun.register.payment.forChestShop.methods.MCUR());
}
/**
* Returns an array of payment method names that have been loaded
* through the <code>_init</code> method.
*
* @return <code>Set<String></code> - Array of payment methods that are loaded.
* @see #setMethod(org.bukkit.plugin.Plugin)
*/
public Set<String> getDependencies() {
return Dependencies;
}
/**
* Interprets Plugin class data to verify whether it is compatible with an existing payment
* method to use for payments and other various economic activity.
*
* @param plugin Plugin data from bukkit, Internal Class file.
* @return Method <em>or</em> Null
*/
public Method createMethod(Plugin plugin) {
for (Method method: Methods) {
if (method.isCompatible(plugin)) {
method.setPlugin(plugin);
return method;
}
}
return null;
}
private void addMethod(String name, Method method) {
Dependencies.add(name);
Methods.add(method);
}
/**
* Verifies if Register has set a payment method for usage yet.
*
* @return <code>boolean</code>
* @see #setMethod(org.bukkit.plugin.Plugin)
* @see #checkDisabled(org.bukkit.plugin.Plugin)
*/
public boolean hasMethod() {
return (Method != null);
}
/**
* Checks Plugin Class against a multitude of checks to verify it's usability
* as a payment method.
*
* @param method Plugin data from bukkit, Internal Class file.
* @return <code>boolean</code> True on success, False on failure.
*/
public boolean setMethod(Plugin method) {
if(hasMethod()) return true;
if(self) { self = false; return false; }
int count = 0;
boolean match = false;
Plugin plugin;
PluginManager manager = method.getServer().getPluginManager();
for(String name: this.Dependencies) {
if(hasMethod()) break;
if(method.getDescription().getName().equals(name)) plugin = method; else plugin = manager.getPlugin(name);
if(plugin == null) continue;
Method current = this.createMethod(plugin);
if(current == null) continue;
if(this.preferred.isEmpty())
this.Method = current;
else {
this.Attachables.add(current);
}
}
if(!this.preferred.isEmpty()) {
do {
if(hasMethod()) {
match = true;
} else {
for(Method attached: this.Attachables) {
if(attached == null) continue;
if(hasMethod()) {
match = true;
break;
}
if(this.preferred.isEmpty()) this.Method = attached;
if(count == 0) {
if(this.preferred.equalsIgnoreCase(attached.getName()))
this.Method = attached;
} else {
this.Method = attached;
}
}
count++;
}
} while(!match);
}
return hasMethod();
}
/**
* Grab the existing and initialized (hopefully) Method Class.
*
* @return <code>Method</code> <em>or</em> <code>Null</code>
*/
public Method getMethod() {
return Method;
}
/**
* Verify is a plugin is disabled, only does this if we there is an existing payment
* method initialized in Register.
*
* @param method Plugin data from bukkit, Internal Class file.
* @return <code>boolean</code>
*/
public boolean checkDisabled(Plugin method) {
if(!hasMethod()) return true;
if (Method.isCompatible(method)) Method = null;
return (Method == null);
}
}

View File

@ -2,12 +2,15 @@ name: ChestShop
main: com.Acrobot.ChestShop.ChestShop
version: 3.04
version: 3.1
author: Acrobot
description: >
A chest shop for economy plugins.
softdepend: [Permissions, LWC, Lockette, Deadbolt, OddItem]
commands:
iteminfo:
aliases: [iinfo]