- Fancy sign formatting :D

- Fixed LWC, Lockette and Default protections
- Added restricted signs (Changed how they work)
- Added an option to use another name
- Fixed a bug where default protection was initialized too many times
- Disallowed players to place another chest near a shop chest
- Speeded up and fixed enchantment and durability in itemstacks
- Changed /iteminfo a bit
- Added /chestshop reload
- Added many default permission kits
- Fixed dye colors
- Added an option to allow towny residents place shops in their town
This commit is contained in:
Acrobot 2012-01-09 22:39:38 +01:00
parent 505dfb3449
commit dc4d9961c1
25 changed files with 631 additions and 102 deletions

View File

@ -1,6 +1,8 @@
package com.Acrobot.ChestShop.Commands;
import com.Acrobot.ChestShop.ChestShop;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.ConfigObject;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -11,6 +13,11 @@ import org.bukkit.command.CommandSender;
*/
public class Version implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length > 0 && args[0].equals("reload")){
Config.config = new ConfigObject();
sender.sendMessage(ChatColor.DARK_GREEN + "The config was reloaded.");
return true;
}
sender.sendMessage(ChatColor.GRAY + ChestShop.getPluginName() + "'s version is: " + ChatColor.GREEN + ChestShop.getVersion());
return true;
}

View File

@ -6,7 +6,7 @@ import com.nijikokun.register.payment.forChestShop.Methods;
* @author Acrobot
*/
public class Config {
private static ConfigObject config;
public static ConfigObject config;
public static void setup(ConfigObject cfg) {
config = cfg;

View File

@ -27,6 +27,7 @@ public enum Property {
SHOW_TRANSACTION_INFORMATION_CLIENT(true, "Do you want to show \"You bought/sold... \" messages?"),
SHOW_TRANSACTION_INFORMATION_OWNER(true, "Do you want to show \"Somebody bought/sold... \" messages?"),
TOWNY_INTEGRATION(false, "Do you want to only let people build inside shop plots?"),
TOWNY_SHOPS_FOR_OWNERS_ONLY(true, "If true, only plot owners are able to build inside a shop plot. If false, every town's resident is able to build there."),
WORLDGUARD_INTEGRATION(false, "Do you want to only let people build inside plots?"),
TAX_AMOUNT(0, "Percent of the price that should go to the server's account. (100 = 100 percent)"),
SHOP_REFUND_PRICE(0, "How much money do you get back when destroying a sign?"),

View File

@ -6,6 +6,7 @@ import com.Acrobot.ChestShop.Config.Property;
import javax.persistence.OptimisticLockException;
import java.util.ArrayList;
import java.util.List;
/**
* @author Acrobot
@ -18,10 +19,27 @@ public class Queue implements Runnable {
}
public void run() {
ChestShop.getDB().delete(ChestShop.getDB().find(Transaction.class).where().lt("sec", System.currentTimeMillis() / 1000 - Config.getInteger(Property.RECORD_TIME_TO_LIVE)).findList());
deleteOld();
ArrayList<Transaction> queueCopy = queue;
try { ChestShop.getDB().save(queueCopy); } catch (OptimisticLockException ignored) {}
ChestShop.getDB().save(queue);
queue.clear();
}
public static boolean deleteOld() {
try {
ChestShop.getDB().delete(getOld());
return true;
} catch (OptimisticLockException ex) {
return false;
}
}
public static List getOld() throws OptimisticLockException {
return ChestShop
.getDB()
.find(Transaction.class)
.where()
.lt("sec", System.currentTimeMillis() / 1000 - Config.getInteger(Property.RECORD_TIME_TO_LIVE))
.findList();
}
}

View File

@ -31,7 +31,8 @@ public class DataValue {
materialData = new Wool(DyeColor.valueOf(type));
break;
case INK_SACK:
materialData = new Wool(15 - DyeColor.valueOf(type).getData());
byte data = (byte) (15 - DyeColor.valueOf(type).getData());
materialData = new Wool(DyeColor.getByData(data));
break;
case COAL:
materialData = new Coal(CoalType.valueOf(type));

View File

@ -7,13 +7,18 @@ import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author Acrobot
* Manages ItemStack names and ID's
*/
public class Items {
private static final Pattern Durability = Pattern.compile(":(\\d)*");
private static final Pattern Enchant = Pattern.compile("-([0-9a-zA-Z])*");
public static Material getMaterial(String itemName) {
if (uNumber.isInteger(itemName)) return Material.getMaterial(Integer.parseInt(itemName));
@ -46,34 +51,53 @@ public class Items {
ItemStack toReturn = getFromOddItem(itemName);
if (toReturn != null) return toReturn;
String[] split = itemName.split(":|-");
String first = itemName.split(":|-")[0];
String[] space = split[0].split(" ");
Material material = getMaterial(split[0]);
String[] space = first.split(" ");
Material material = getMaterial(first);
for (int i = (space.length > 1 ? 1 : 0); i >= 0 && material == null; i--) material = getMaterial(space[i]);
if (material == null) return null;
toReturn = new ItemStack(material, 1);
toReturn = addEnchantments(toReturn, itemName);
toReturn = addDurability(toReturn, itemName);
for (int i = 1; i < split.length; i++){
split[i] = split[i].trim();
if (uNumber.isInteger(split[i])) toReturn.setDurability((short) Integer.parseInt(split[i]));
else {
try{ toReturn.addEnchantments(getEnchantment(split[i]));
} catch (Exception ignored){}
}
}
short data = getDataFromWord(space[0], material);
if (data != 0) toReturn.setDurability(data);
return toReturn;
}
private static ItemStack addDurability(ItemStack toReturn, String itemName) {
Matcher m = Durability.matcher(itemName);
if (!m.find()) return toReturn;
String data = m.group();
if (data == null || data.isEmpty()) return toReturn;
data = data.substring(1);
if (uNumber.isInteger(data)) toReturn.setDurability(Short.valueOf(data));
return toReturn;
}
private static Map<Enchantment, Integer> getEnchantment(String itemName){
return uEnchantment.decodeEnchantment(itemName);
}
private static Map<Enchantment, Integer> getEnchant(String original){
Matcher m = Enchant.matcher(original);
if (!m.find()) return new HashMap<Enchantment, Integer>();
String group = m.group().substring(1);
return getEnchantment(group);
}
private static ItemStack addEnchantments(ItemStack is, String itemname){
try{ is.addEnchantments(getEnchant(itemname));
} catch (Exception ignored) {}
return is;
}
private static ItemStack getFromOddItem(String itemName) {
return !Odd.isInitialized() ? null : Odd.returnItemStack(itemName.replace(":", ";"));

View File

@ -4,6 +4,7 @@ import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Property;
import com.Acrobot.ChestShop.Economy;
import com.Acrobot.ChestShop.Permission;
import com.Acrobot.ChestShop.Signs.restrictedSign;
import com.Acrobot.ChestShop.Utils.uBlock;
import com.Acrobot.ChestShop.Utils.uLongName;
import com.Acrobot.ChestShop.Utils.uSign;
@ -28,9 +29,10 @@ public class blockBreak extends BlockListener {
public static boolean cancellingBlockBreak(Block block, Player player) {
if (block == null) return false;
if (player != null && (Permission.has(player, Permission.ADMIN) || Permission.has(player, Permission.MOD))) return false;
if (uSign.isSign(block)) block.getState().update(); //Show the text immediately
if (restrictedSign(block)) return true; //If the block is a restricted sign (and the player is not an admin/mod)
if (restrictedSign(block)) return !restrictedSign.canDestroy(player, uBlock.findRestrictedSign(block));
Sign sign = uBlock.findSign(block, (player != null ? uLongName.stripName(player.getName()) : null));
if (!isCorrectSign(sign, block)) return false; //It's not a correct shop sign, so don't cancel it
@ -45,8 +47,7 @@ public class blockBreak extends BlockListener {
}
private static boolean restrictedSign(Block block) {
Sign s = uBlock.findRestrictedSign(block);
return isCorrectSign(s, block);
return uBlock.findRestrictedSign(block) != null;
}
public void onBlockBreak(BlockBreakEvent event) {
@ -62,7 +63,8 @@ public class blockBreak extends BlockListener {
}
private static boolean playerIsNotOwner(Player player, Sign sign) {
return player == null || (!uLongName.stripName(player.getName()).equals(sign.getLine(0)) && !Permission.has(player, Permission.OTHER_NAME + sign.getLine(0)));
return player == null || (!uLongName.stripName(player.getName()).equals(sign.getLine(0))
&& !Permission.otherName(player, sign.getLine(0)));
}
public void onBlockPistonExtend(BlockPistonExtendEvent event) {

View File

@ -1,7 +1,13 @@
package com.Acrobot.ChestShop.Listeners;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Language;
import com.Acrobot.ChestShop.Protection.Security;
import com.Acrobot.ChestShop.Utils.uBlock;
import com.Acrobot.ChestShop.Utils.uSign;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Chest;
import org.bukkit.block.Sign;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPlaceEvent;
@ -14,6 +20,19 @@ public class blockPlace extends BlockListener {
Block block = event.getBlockAgainst();
if (uSign.isSign(block) && uSign.isValid((Sign) block.getState())) {
event.setCancelled(true);
return;
}
Block placed = event.getBlockPlaced();
if (placed.getType() == Material.CHEST){
Chest neighbor = uBlock.findNeighbor(placed);
if (neighbor == null) return;
Block neighborBlock = neighbor.getBlock();
if (Security.isProtected(neighborBlock) && !Security.canAccess(event.getPlayer(), neighborBlock)){
event.getPlayer().sendMessage(Config.getLocal(Language.ACCESS_DENIED));
event.setCancelled(true);
}
}
}
}

View File

@ -8,7 +8,6 @@ import com.Acrobot.ChestShop.Protection.Plugins.Default;
import com.Acrobot.ChestShop.Shop.ShopManagement;
import com.Acrobot.ChestShop.Signs.restrictedSign;
import com.Acrobot.ChestShop.Utils.uBlock;
import com.Acrobot.ChestShop.Utils.uLongName;
import com.Acrobot.ChestShop.Utils.uSign;
import net.minecraft.server.IInventory;
import net.minecraft.server.InventoryLargeChest;
@ -64,12 +63,11 @@ public class playerInteract extends PlayerListener {
if (action == Action.RIGHT_CLICK_BLOCK) event.setCancelled(true);
if (uLongName.stripName(player.getName()).equals(sign.getLine(0))) {
if (uSign.canAccess(player, sign)) {
if (action != Action.LEFT_CLICK_BLOCK || !Config.getBoolean(Property.ALLOW_LEFT_CLICK_DESTROYING)) showChestGUI(player, block);
return;
}
if (restrictedSign.isRestrictedShop(sign) && !restrictedSign.canAccess(sign, player)) {
player.sendMessage(Config.getLocal(Language.ACCESS_DENIED));
return;

View File

@ -37,6 +37,7 @@ public class pluginEnable extends ServerListener {
}
public static void initializePlugins() {
Security.protections.add(new Default()); //Initialize basic protection
for (Object plugin : ChestShop.getDependencies()) {
Plugin pl = ChestShop.pm.getPlugin((String) plugin);
if (pl != null) initializePlugin((String) plugin, pl);
@ -44,7 +45,6 @@ public class pluginEnable extends ServerListener {
}
private static void initializePlugin(String name, Plugin plugin) { //Really messy, right? But it's short and fast :)
Security.protections.add(new Default()); //Initialize basic protection
if (name.equals("Permissions")) {
if (Permission.permissions != null) return;
Permission.permissions = ((Permissions) plugin).getHandler();

View File

@ -49,14 +49,15 @@ public class signChange extends BlockListener {
return;
}
} else {
if (restrictedSign.isRestricted(event.getLines())) {
if (!playerIsAdmin) {
if (restrictedSign.isRestricted(line)) {
if (!restrictedSign.hasPermission(player, line)) {
player.sendMessage(Config.getLocal(Language.ACCESS_DENIED));
dropSign(event);
return;
}
Block secondSign = signBlock.getRelative(BlockFace.DOWN);
if (!uSign.isSign(secondSign) || !uSign.isValid((Sign) secondSign.getState())) dropSign(event);
if (!playerIsAdmin && (!uSign.isSign(secondSign) || !uSign.isValid((Sign) secondSign.getState())
|| !uSign.canAccess(player, (Sign) secondSign))) dropSign(event);
}
return;
}
@ -94,8 +95,8 @@ public class signChange extends BlockListener {
dropSign(event);
return;
}
boolean canAccess = !Security.isProtected(chestBlock) || Security.canAccess(player, chestBlock);
boolean canAccess = !Security.isProtected(chestBlock) || Security.canAccess(player, chestBlock);
if (!canAccess) {
player.sendMessage(Config.getLocal(Language.CANNOT_ACCESS_THE_CHEST));
dropSign(event);
@ -104,6 +105,8 @@ public class signChange extends BlockListener {
}
}
float shopCreationPrice = Config.getFloat(Property.SHOP_CREATION_PRICE);
boolean paid = shopCreationPrice != 0 && !isAdminShop;
if (paid) {
@ -162,14 +165,14 @@ public class signChange extends BlockListener {
else toReturn.append(is.getTypeId());
if (index != -1 && index != 9999) toReturn.append(fourthLine.substring(index));
return toReturn.toString();
return uSign.capitalizeFirst(toReturn.toString(), ' ');
}
private static boolean formatFirstLine(String line1, Player player) {
return line1.isEmpty() ||
(!line1.equals(uLongName.stripName(player.getName()))
&& !Permission.has(player, Permission.ADMIN)
&& !Permission.has(player, Permission.OTHER_NAME + line1));
&& !Permission.otherName(player, line1));
}
private static void dropSign(SignChangeEvent event) {

View File

@ -14,7 +14,8 @@ public enum Permission {
SELL("ChestShop.shop.sell"),
ADMIN("ChestShop.admin"),
MOD("ChestShop.mod"),
OTHER_NAME("ChestShop.name.");
OTHER_NAME("ChestShop.name."),
GROUP("ChestShop.group.");
private final String permission;
@ -32,6 +33,16 @@ public enum Permission {
if (permissions != null) return permissions.has(player, node) || permissions.has(player, node.toLowerCase());
return player.hasPermission(node) || player.hasPermission(node.toLowerCase());
}
public static boolean otherName(Player p, String name){
String node = OTHER_NAME + name;
if (permissions != null) return permissions.has(p, node) || permissions.has(p, node.toLowerCase());
return hasPermissionSet(p, node) || hasPermissionSet(p, node.toLowerCase());
}
private static boolean hasPermissionSet(Player p, String perm){
return p.isPermissionSet(perm) && p.hasPermission(perm);
}
public String toString() {
return permission;

View File

@ -1,5 +1,6 @@
package com.Acrobot.ChestShop.Protection.Plugins;
import com.Acrobot.ChestShop.Permission;
import com.Acrobot.ChestShop.Protection.Protection;
import com.Acrobot.ChestShop.Utils.uBlock;
import com.Acrobot.ChestShop.Utils.uLongName;
@ -24,12 +25,16 @@ public class Default implements Protection {
String playerName = player.getName();
Sign sign = uBlock.findSign2(block);
if (sign != null) return uLongName.stripName(playerName).equals(sign.getLine(0));
if (sign != null) return uLongName.stripName(playerName).equals(sign.getLine(0))
|| Permission.otherName(player, sign.getLine(0));
Chest neighborChest = uBlock.findNeighbor(block);
Sign neighborSign = (neighborChest != null ? uBlock.findSign2(neighborChest.getBlock()) : null);
return neighborSign == null || uLongName.stripName(playerName).equals(neighborSign.getLine(0));
return neighborSign == null
|| uLongName.stripName(playerName).equals(neighborSign.getLine(0))
|| Permission.otherName(player, neighborSign.getLine(0));
}
public boolean protect(String name, Block block) {

View File

@ -26,7 +26,7 @@ public class LWCplugin implements Protection {
}
public boolean canAccess(Player player, Block block) {
return lwc.canAccessProtection(player, block);
return lwc.findProtection(block) == null || lwc.canAccessProtection(player, block);
}
public boolean protect(String name, Block block) {

View File

@ -16,8 +16,10 @@ 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.getProtectedOwner(block));
String pName = player.getName();
int length = (pName.length() > 15 ? 15 : pName.length());
String owner = Lockette.getProtectedOwner(block);
return owner == null || pName.substring(0, length).equals(owner);
}
public boolean protect(String name, Block block) {

View File

@ -30,19 +30,20 @@ public class Security {
}
public static boolean isProtected(Block block) {
boolean isProtected = false;
for (int i = 0; i < protections.size() && !isProtected; i++) isProtected = protections.get(i).isProtected(block);
return isProtected;
boolean isProt = false;
for (int i = 0; i < protections.size() && !isProt; i++) isProt = protections.get(i).isProtected(block);
return isProt;
}
public static boolean canPlaceSign(Player p, Sign sign) {
return !thereIsAnotherSignByPlayer(blockBreak.getAttachedFace(sign), sign.getBlock(), uLongName.stripName(p.getName()));
}
private static boolean thereIsAnotherSignByPlayer(Block baseBlock, Block signBlock, String shortName){
for (BlockFace bf : faces){
private static boolean thereIsAnotherSignByPlayer(Block baseBlock, Block signBlock, String shortName) {
for (BlockFace bf : faces) {
Block block = baseBlock.getRelative(bf);
if(uSign.isSign(block) && !block.equals(signBlock) && blockBreak.getAttachedFace((Sign) block.getState()).equals(baseBlock) && !((Sign) block.getState()).getLine(0).equals(shortName)) return true;
if (uSign.isSign(block) && !block.equals(signBlock) && blockBreak.getAttachedFace((Sign) block.getState()).equals(baseBlock) && !((Sign) block.getState()).getLine(0).equals(shortName))
return true;
}
return false;
}

View File

@ -26,16 +26,28 @@ public class restrictedSign {
public static boolean canAccess(Sign sign, Player player) {
Block blockUp = sign.getBlock().getRelative(BlockFace.UP);
if (Permission.permissions == null || !uSign.isSign(blockUp) || Permission.has(player, Permission.ADMIN)) return true;
return !uSign.isSign(blockUp) || hasPermission(player, ((Sign) blockUp.getState()).getLines());
String world = blockUp.getWorld().getName();
String playerName = player.getName();
}
sign = (Sign) blockUp.getState();
public static boolean canDestroy(Player p, Sign sign){
Sign shopSign = getAssociatedSign(sign);
return uSign.canAccess(p, shopSign);
}
public static Sign getAssociatedSign(Sign restricted){
Block down = restricted.getBlock().getRelative(BlockFace.DOWN);
return uSign.isSign(down) ? (Sign) down.getState() : null;
}
public static boolean hasPermission(Player p, String[] lines){
if (Permission.has(p, Permission.ADMIN)) return true;
String world = p.getWorld().getName();
String playerName = p.getName();
for (int i = 1; i <= 3; i++) {
if (Permission.permissions != null && Permission.permissions.inGroup(world, playerName, sign.getLine(i))) return true;
if (player.hasPermission("ChestShop.group." + sign.getLine(i))) return true;
if (Permission.permissions != null && Permission.permissions.inGroup(world, playerName, lines[i])) return true;
if (p.hasPermission(Permission.GROUP.toString() + lines[i])) return true;
}
return false;
}

View File

@ -51,7 +51,7 @@ public class uInventory {
amount = 0;
for (ItemStack toAdd : items.values()) amount += toAdd.getAmount();
return amount;*/ //TODO: Fix this in CraftBukkit's code
return amount;*/ //TODO: revert when Bukkit releases new RB
return addManually(inv, item, amount);
}
@ -101,6 +101,8 @@ public class uInventory {
public static int fits(Inventory inv, ItemStack item, int amount, short durability) {
int maxStackSize = (Config.getBoolean(Property.STACK_UNSTACKABLES) ? 64 : item.getType().getMaxStackSize());
if (item.getType() == Material.POTION) maxStackSize = 1; //TODO Bukkit, can you fix that?
int amountLeft = amount;
for (ItemStack currentItem : inv.getContents()) {

View File

@ -2,9 +2,11 @@ package com.Acrobot.ChestShop.Utils;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Property;
import com.Acrobot.ChestShop.Permission;
import com.palmergames.bukkit.towny.Towny;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import java.util.regex.Pattern;
@ -34,21 +36,21 @@ public class uSign {
}
public static boolean isValid(String[] line) {
try {
return isValidPreparedSign(line) && (line[2].contains("B") || line[2].contains("S"));
} catch (Exception e) {
return false;
}
return isValidPreparedSign(line) && (line[2].contains("B") || line[2].contains("S")) && !line[0].isEmpty();
}
public static boolean canAccess(Player p, Sign s) {
if (p == null) return false;
if (s == null) return true;
String line = s.getLine(0);
return uLongName.stripName(p.getName()).equals(line) || Permission.otherName(p, line);
}
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();
return toReturn && lines[2].split(":").length <= 2;
} catch (Exception e) {
return false;
}
boolean toReturn = true;
for (int i = 0; i < 4 && toReturn; i++) toReturn = patterns[i].matcher(lines[i]).matches();
return toReturn && lines[2].indexOf(':') == lines[2].lastIndexOf(':');
}
public static float buyPrice(String text) {
@ -83,11 +85,11 @@ public class uSign {
} else return 1;
}
public static String capitalizeFirst(String name){
public static String capitalizeFirst(String name) {
return capitalizeFirst(name, '_');
}
public static String capitalizeFirst(String name, char separator){
public static String capitalizeFirst(String name, char separator) {
name = name.toLowerCase();
String[] split = name.split(Character.toString(separator));
StringBuilder total = new StringBuilder(3);

View File

@ -17,7 +17,8 @@ public class uTowny {
}
public static boolean isPlotOwner(Player player, Location chestLocation, Location signLocation) {
return isBlockOwner(player, chestLocation) && isBlockOwner(player, signLocation);
if (Config.getBoolean(Property.TOWNY_SHOPS_FOR_OWNERS_ONLY)) return isBlockOwner(player, chestLocation) && isBlockOwner(player, signLocation);
return isResident(player, chestLocation) && isResident(player, signLocation);
}
public static boolean isNotInTheWilderness(Location chestLocation, Location signLocation) {
@ -29,8 +30,12 @@ public class uTowny {
}
private static boolean isBlockOwner(Player player, Location location) {
try {
return uSign.towny.getTownyUniverse().getTownBlock(location).isOwner(uSign.towny.getTownyUniverse().getResident(player.getName()));
try { return uSign.towny.getTownyUniverse().getTownBlock(location).isOwner(uSign.towny.getTownyUniverse().getResident(player.getName()));
} catch (NotRegisteredException ex) { return false; }
}
private static boolean isResident(Player p, Location l){
try { return uSign.towny.getTownyUniverse().getTownBlock(l).getTown().hasResident(p.getName());
} catch (NotRegisteredException ex) { return false; }
}
}

View File

@ -275,7 +275,7 @@ public abstract class Database {
currentTable = currentLine.split(" ", 4)[2];
foundTables.put(currentLine.split(" ", 3)[2], scriptLines.size() - 1);
}
else if(currentLine.length() > 0 && currentLine.charAt(0) == ';' && currentTable != null && !currentTable.isEmpty()) {
else if(!currentLine.isEmpty() && currentLine.charAt(0) == ';' && currentTable != null && !currentTable.isEmpty()) {
//Found the end of a table definition, so update the entry
int index = scriptLines.size() - 1;
foundTables.put(currentTable, index);

View File

@ -7,12 +7,12 @@ import java.util.HashSet;
import java.util.Set;
/**
* The <code>Methods</code> initializes Methods that utilize the Method interface
* 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
* methods also allows you to set a preferred method of payment before it captures
* payment plugins in the initialization process.
* <p/>
* in <code>bukkit.yml</code>:
@ -30,18 +30,18 @@ public class Methods {
private static boolean self = false;
private static Method Method = null;
private 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>();
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();
init();
}
/**
* Implement all methods along with their respective name & class.
*/
private static void _init() {
private static void init() {
addMethod("iConomy", new com.nijikokun.register.payment.forChestShop.methods.iCo6());
addMethod("iConomy", new com.nijikokun.register.payment.forChestShop.methods.iCo5());
addMethod("iConomy", new com.nijikokun.register.payment.forChestShop.methods.iCo4());
@ -50,7 +50,7 @@ public class Methods {
addMethod("Essentials", new com.nijikokun.register.payment.forChestShop.methods.EE17());
addMethod("Currency", new com.nijikokun.register.payment.forChestShop.methods.MCUR());
addMethod("3co", new com.nijikokun.register.payment.forChestShop.methods.ECO3());
Dependencies.add("MultiCurrency");
dependencies.add("MultiCurrency");
}
/**
@ -70,7 +70,7 @@ public class Methods {
self = false;
Method = null;
preferred = "";
Attachables.clear();
attachables.clear();
}
/**
@ -84,13 +84,13 @@ public class Methods {
/**
* Returns an array of payment method names that have been loaded
* through the <code>_init</code> method.
* through the <code>init</code> method.
*
* @return <code>Set<String></code> - Array of payment methods that are loaded.
* @see #setMethod(org.bukkit.plugin.PluginManager)
*/
public static Set<String> getDependencies() {
return Dependencies;
return dependencies;
}
/**
@ -101,18 +101,18 @@ public class Methods {
* @return Method <em>or</em> Null
*/
public static Method createMethod(Plugin plugin) {
for (Method method : Methods)
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);
dependencies.add(name);
methods.add(method);
}
/**
@ -144,9 +144,9 @@ public class Methods {
int count = 0;
boolean match = false;
Plugin plugin = null;
Plugin plugin;
for (String name : getDependencies()) {
for (String name : dependencies) {
if (hasMethod())
break;
@ -161,7 +161,7 @@ public class Methods {
if (preferred.isEmpty())
Method = current;
else
Attachables.add(current);
attachables.add(current);
}
if (!preferred.isEmpty()) {
@ -169,7 +169,7 @@ public class Methods {
if (hasMethod())
match = true;
else {
for (Method attached : Attachables) {
for (Method attached : attachables) {
if (attached == null) continue;
if (hasMethod()) {
@ -201,7 +201,7 @@ public class Methods {
* @return <code>boolean</code>
*/
public static boolean setPreferred(String check) {
if (getDependencies().contains(check)) {
if (dependencies.contains(check)) {
preferred = check;
return true;
}

View File

@ -57,10 +57,8 @@ public class iCo5 implements Method {
}
public boolean createAccount(String name) {
if(hasAccount(name))
return false;
return com.iConomy.iConomy.Accounts.create(name);
return !hasAccount(name) && iConomy.Accounts.create(name);
}
public boolean createAccount(String name, double balance) {

View File

@ -56,17 +56,13 @@ public class iCo6 implements Method {
}
public boolean createAccount(String name) {
if(hasAccount(name))
return false;
return (new Accounts()).create(name);
return !hasAccount(name) && (new Accounts()).create(name);
}
public boolean createAccount(String name, double balance) {
if(hasAccount(name))
return false;
return (new Accounts()).create(name, balance);
return !hasAccount(name) && (new Accounts()).create(name, balance);
}
public MethodAccount getAccount(String name) {

View File

@ -2,7 +2,7 @@ name: ChestShop
main: com.Acrobot.ChestShop.ChestShop
version: 3.31
version: 3.32
author: Acrobot
@ -21,6 +21,7 @@ commands:
/<command> §7log§f §2(what's the item ID of §7LOG§2?)
csVersion:
aliases: [chestshop]
description: Shows the ChestShop's version
usage: /<command>
@ -56,4 +57,425 @@ permissions:
ChestShop.mod:
description: Allows user only to view other store chests, he can't destroy them or create an Admin Shop
ChestShop.name.(some name):
description: Gives you the power to do create shops for (some name), for example your town.
description: Gives you the power to do create shops for (some name), for example your town.
ChestShop.shop.create.food:
description: Allows to create a shop that sells food
children:
ChestShop.shop.create.297: true #Bread
ChestShop.shop.create.354: true #Cake
ChestShop.shop.create.357: true #Cookie
ChestShop.shop.create.349: true #RawFish
ChestShop.shop.create.350: true #CookedFish
ChestShop.shop.create.365: true #RawChicken
ChestShop.shop.create.366: true #CookedChicken
ChestShop.shop.create.363: true #RawSteak
ChestShop.shop.create.364: true #CookedSteak
ChestShop.shop.create.319: true #RawPork
ChestShop.shop.create.320: true #CookedPork
ChestShop.shop.create.282: true #MushroomSoup
ChestShop.shop.create.360: true #Melon
ChestShop.shop.create.260: true #Apple
ChestShop.shop.create.322: true #GoldApple
ChestShop.shop.create.297: true #Bread
ChestShop.shop.create.335: true #Milk
ChestShop.shop.create.diamondgrade:
description: Allows to create a shop that sells diamond gear
children:
ChestShop.shop.create.310: true #DiamondHelm
ChestShop.shop.create.311: true #DiamondChestplate
ChestShop.shop.create.312: true #DiamondLeggings
ChestShop.shop.create.313: true #DiamondBoots
ChestShop.shop.create.276: true #DiamondSword
ChestShop.shop.create.277: true #DiamondShovel
ChestShop.shop.create.278: true #DiamondPick
ChestShop.shop.create.279: true #DiamondAxe
ChestShop.shop.create.293: true #DiamondHoe
ChestShop.shop.create.irongrade:
description: Allows to create a shop that sells iron gear
children:
ChestShop.shop.create.306: true #IronHelm
ChestShop.shop.create.307: true #IronChestplate
ChestShop.shop.create.308: true #IronLeggings
ChestShop.shop.create.309: true #IronBoots
ChestShop.shop.create.267: true #IronSword
ChestShop.shop.create.256: true #IronShovel
ChestShop.shop.create.257: true #IronPick
ChestShop.shop.create.258: true #IronAxe
ChestShop.shop.create.292: true #IronHoe
ChestShop.shop.create.goldgrade:
description: Allows to create a shop that sells gold gear
children:
ChestShop.shop.create.314: true #GoldHelm
ChestShop.shop.create.315: true #GoldChestplate
ChestShop.shop.create.316: true #GoldLeggings
ChestShop.shop.create.317: true #GoldBoots
ChestShop.shop.create.283: true #GoldSword
ChestShop.shop.create.284: true #GoldShovel
ChestShop.shop.create.285: true #GoldPick
ChestShop.shop.create.286: true #GoldAxe
ChestShop.shop.create.294: true #GoldHoe
ChestShop.shop.create.stonegrade:
description: Allows to create a shop that sells stone tools and chain armor
children:
ChestShop.shop.create.302: true #ChainHelm
ChestShop.shop.create.303: true #ChainChestplate
ChestShop.shop.create.304: true #ChainLeggings
ChestShop.shop.create.305: true #ChainBoots
ChestShop.shop.create.272: true #StoneSword
ChestShop.shop.create.273: true #StoneShovel
ChestShop.shop.create.274: true #StonePick
ChestShop.shop.create.275: true #StoneAxe
ChestShop.shop.create.291: true #StoneHoe
ChestShop.shop.create.woodgrade:
description: Allows to create a shop that sells wood tools and leather armor
children:
ChestShop.shop.create.298: true #LeatherHelm
ChestShop.shop.create.299: true #LeatherChestplate
ChestShop.shop.create.300: true #LeatherLeggings
ChestShop.shop.create.301: true #LeatherBoots
ChestShop.shop.create.268: true #WoodSword
ChestShop.shop.create.269: true #WoodShovel
ChestShop.shop.create.270: true #WoodPick
ChestShop.shop.create.271: true #WoodAxe
ChestShop.shop.create.290: true #WoodHoe
ChestShop.shop.create.diamondarmor:
description: Allows to create a shop that sells diamond armor
children:
ChestShop.shop.create.310: true #DiamondHelm
ChestShop.shop.create.311: true #DiamondChestplate
ChestShop.shop.create.312: true #DiamondLeggings
ChestShop.shop.create.313: true #DiamondBoots
ChestShop.shop.create.diamondtools:
description: Allows to create a shop that sells diamond tools
children:
ChestShop.shop.create.276: true #DiamondSword
ChestShop.shop.create.277: true #DiamondShovel
ChestShop.shop.create.278: true #DiamondPick
ChestShop.shop.create.279: true #DiamondAxe
ChestShop.shop.create.293: true #DiamondHoe
ChestShop.shop.create.goldarmor:
description: Allows to create a shop that sells gold armor
children:
ChestShop.shop.create.314: true #GoldHelm
ChestShop.shop.create.315: true #GoldChestplate
ChestShop.shop.create.316: true #GoldLeggings
ChestShop.shop.create.317: true #GoldBoots
ChestShop.shop.create.goldtools:
description: Allows to create a shop that sells gold tools
children:
ChestShop.shop.create.283: true #GoldSword
ChestShop.shop.create.284: true #GoldShovel
ChestShop.shop.create.285: true #GoldPick
ChestShop.shop.create.286: true #GoldAxe
ChestShop.shop.create.294: true #GoldHoe
ChestShop.shop.create.ironarmor:
description: Allows to create a shop that sells iron armor
children:
ChestShop.shop.create.306: true #IronHelm
ChestShop.shop.create.307: true #IronChestplate
ChestShop.shop.create.308: true #IronLeggings
ChestShop.shop.create.309: true #IronBoots
ChestShop.shop.create.irontools:
description: Allows to create a shop that sells iron tools
children:
ChestShop.shop.create.267: true #IronSword
ChestShop.shop.create.256: true #IronShovel
ChestShop.shop.create.257: true #IronPick
ChestShop.shop.create.258: true #IronAxe
ChestShop.shop.create.292: true #IronHoe
ChestShop.shop.create.chainarmor:
description: Allows to create a shop that sells chain armor
children:
ChestShop.shop.create.302: true #ChainHelm
ChestShop.shop.create.303: true #ChainChestplate
ChestShop.shop.create.304: true #ChainLeggings
ChestShop.shop.create.305: true #ChainBoots
ChestShop.shop.create.stonetools:
description: Allows to create a shop that sells stone tools
children:
ChestShop.shop.create.272: true #StoneSword
ChestShop.shop.create.273: true #StoneShovel
ChestShop.shop.create.274: true #StonePick
ChestShop.shop.create.275: true #StoneAxe
ChestShop.shop.create.291: true #StoneHoe
ChestShop.shop.create.leatherarmor:
description: Allows to create a shop that sells leather armor
children:
ChestShop.shop.create.298: true #LeatherHelm
ChestShop.shop.create.299: true #LeatherChestplate
ChestShop.shop.create.300: true #LeatherLeggings
ChestShop.shop.create.301: true #LeatherBoots
ChestShop.shop.create.woodtools:
description: Allows to create a shop that sells wood tools
children:
ChestShop.shop.create.268: true #WoodSword
ChestShop.shop.create.269: true #WoodShovel
ChestShop.shop.create.270: true #WoodPick
ChestShop.shop.create.271: true #WoodAxe
ChestShop.shop.create.290: true #WoodHoe
ChestShop.shop.create.bows:
description: Allows to create a shop that sells bows & arrows
children:
ChestShop.shop.create.261: true #Bow
ChestShop.shop.create.262: true #Arrow
ChestShop.shop.create.misctools:
description: Allows to create a shop that sells misc tools
children:
ChestShop.shop.create.259: true #Flint&Steel
ChestShop.shop.create.325: true #Bucket
ChestShop.shop.create.326: true #WaterBucket
ChestShop.shop.create.327: true #LavaBucket
ChestShop.shop.create.345: true #Compass
ChestShop.shop.create.346: true #FishingRod
ChestShop.shop.create.347: true #Clock
ChestShop.shop.create.358: true #Map
ChestShop.shop.create.359: true #Sheers
ChestShop.shop.create.ore:
description: Allows to create a shop that sells ores
children:
ChestShop.shop.create.16: true #CoalOre
ChestShop.shop.create.15: true #IronOre
ChestShop.shop.create.21: true #LapisOre
ChestShop.shop.create.14: true #GoldOre
ChestShop.shop.create.56: true #DiamondOre
ChestShop.shop.create.74: true #RedstoneOre
ChestShop.shop.create.ingots:
description: Allows to create a shop that sells ingots
children:
ChestShop.shop.create.265: true #IronIngot
ChestShop.shop.create.266: true #GoldIngot
ChestShop.shop.create.264: true #Diamond
ChestShop.shop.create.stairs:
description: Allows to create a shop that sells stairs
children:
ChestShop.shop.create.53: true #WoodStairs
ChestShop.shop.create.67: true #CobbleStairs
ChestShop.shop.create.108: true #BrickStairs
ChestShop.shop.create.109: true #StoneStairs
ChestShop.shop.create.114: true #NetherBrickStairs
ChestShop.shop.create.monsterdrops:
description: Allows to create a shop that sells mob drops
children:
ChestShop.shop.create.289: true #Sulphur
ChestShop.shop.create.288: true #Feather
ChestShop.shop.create.287: true #String
ChestShop.shop.create.341: true #Slimeball
ChestShop.shop.create.344: true #Egg
ChestShop.shop.create.352: true #Bone
ChestShop.shop.create.334: true #Leather
ChestShop.shop.create.367: true #RottenFlesh
ChestShop.shop.create.368: true #EnderPearl
ChestShop.shop.create.375: true #SpiderEye
ChestShop.shop.create.netherdrops:
description: Allows to create a shop that sells nether drops
children:
ChestShop.shop.create.369: true #BlazeRod
ChestShop.shop.create.370: true #GhastTear
ChestShop.shop.create.371: true #GoldNugget
ChestShop.shop.create.378: true #MagmaCream
ChestShop.shop.create.plants:
description: Allows to create a shop that sells plants
children:
ChestShop.shop.create.6: true #Sapling
ChestShop.shop.create.18: true #LeafBlock
ChestShop.shop.create.31: true #TallGrass
ChestShop.shop.create.32: true #DeadShrub
ChestShop.shop.create.37: true #YellowFlower
ChestShop.shop.create.38: true #RedFlower
ChestShop.shop.create.39: true #BrownMushroom
ChestShop.shop.create.40: true #RedMushroom
ChestShop.shop.create.81: true #Cactus
ChestShop.shop.create.86: true #Pumpkin
ChestShop.shop.create.103: true #MelonBlock
ChestShop.shop.create.106: true #Vines
ChestShop.shop.create.111: true #LillyPad
ChestShop.shop.create.295: true #Seeds
ChestShop.shop.create.296: true #Wheat
ChestShop.shop.create.338: true #Reeds
ChestShop.shop.create.361: true #PumpkinSeeds
ChestShop.shop.create.362: true #MelonSeeds
ChestShop.shop.create.redstone:
descriptions: Allows to create a shop that sells redstone items
children:
ChestShop.shop.create.69: true #Lever
ChestShop.shop.create.77: true #Button
ChestShop.shop.create.76: true #TorchOn
ChestShop.shop.create.331: true #RedstoneDust
ChestShop.shop.create.356: true #RedstoneRepeater
ChestShop.shop.create.23: true #Dispenser
ChestShop.shop.create.29: true #StickyPiston
ChestShop.shop.create.33: true #Piston
ChestShop.shop.create.27: true #PowerRail
ChestShop.shop.create.28: true #DetectorRail
ChestShop.shop.create.66: true #MinecartRail
ChestShop.shop.create.70: true #StonePlate
ChestShop.shop.create.72: true #WoodPlate
ChestShop.shop.create.netherblocks:
descriptions: Allows to create a shop that sells netherblocks
children:
ChestShop.shop.create.87: true #NetherRack
ChestShop.shop.create.88: true #SoulSand
ChestShop.shop.create.89: true #GlowStone
ChestShop.shop.create.112: true #NetherBrick
ChestShop.shop.create.113: true #NetherFence
ChestShop.shop.create.114: true #NetherStairs
ChestShop.shop.create.misc:
descriptions: Allows to create a shop that sells misc items
children:
ChestShop.shop.create.263: true #Coal
ChestShop.shop.create.280: true #Stick
ChestShop.shop.create.281: true #Bowl
ChestShop.shop.create.318: true #Flint
ChestShop.shop.create.321: true #Painting
ChestShop.shop.create.323: true #Sign
ChestShop.shop.create.329: true #Saddle
ChestShop.shop.create.332: true #Snowballs
ChestShop.shop.create.336: true #Bricks
ChestShop.shop.create.337: true #ClayBalls
ChestShop.shop.create.339: true #Paper
ChestShop.shop.create.340: true #Book
ChestShop.shop.create.348: true #GlowstoneDust
ChestShop.shop.create.353: true #Sugar
ChestShop.shop.create.355: true #Bed
ChestShop.shop.create.381: true #EnderEye
ChestShop.shop.create.steps:
description: Allows to create a shop that sells steps
children:
ChestShop.shop.create.44: true #Step
ChestShop.shop.create.brewing:
description: Allows to create a shop that sells brewing materials
children:
ChestShop.shop.create.335: true #Milk
ChestShop.shop.create.372: true #NetherWart
ChestShop.shop.create.373: true #WaterBottle
ChestShop.shop.create.374: true #Bottle
ChestShop.shop.create.376: true #FermentedSpiderEye
ChestShop.shop.create.377: true #BlazePowder
ChestShop.shop.create.382: true #GlisteringMelon
ChestShop.shop.create.basic:
description: Allows to create a shop that sells basic blocks
children:
ChestShop.shop.create.1: true #Stone
ChestShop.shop.create.2: true #Grass
ChestShop.shop.create.3: true #Dirt
ChestShop.shop.create.4: true #Cobble
ChestShop.shop.create.5: true #Planks
ChestShop.shop.create.12: true #Sand
ChestShop.shop.create.13: true #Gravel
ChestShop.shop.create.17: true #Log
ChestShop.shop.create.20: true #Glass
ChestShop.shop.create.22: true #LapisBlock
ChestShop.shop.create.24: true #SandStone
ChestShop.shop.create.41: true #GoldBlock
ChestShop.shop.create.42: true #IronBlock
ChestShop.shop.create.45: true #BrickBlock
ChestShop.shop.create.46: true #TNT
ChestShop.shop.create.47: true #BookShelf
ChestShop.shop.create.48: true #MossyCobble
ChestShop.shop.create.49: true #Obsidian
ChestShop.shop.create.50: true #Torch
ChestShop.shop.create.54: true #Chest
ChestShop.shop.create.57: true #DiamondBlock
ChestShop.shop.create.65: true #Ladder
ChestShop.shop.create.79: true #Ice
ChestShop.shop.create.80: true #Snow
ChestShop.shop.create.82: true #ClayBlock
ChestShop.shop.create.91: true #JackoLantern
ChestShop.shop.create.98: true #StoneBrick
ChestShop.shop.create.99: true #MushroomBlock1
ChestShop.shop.create.100: true #MushroomBlock2
ChestShop.shop.create.101: true #IronBar
ChestShop.shop.create.102: true #GlassPane
ChestShop.shop.create.110: true #Mycelium
ChestShop.shop.create.121: true #EndStone
ChestShop.shop.create.122: true #DragonEgg
ChestShop.shop.create.doors:
descriptions: Allows to create a shop that sells doors
children:
ChestShop.shop.create.324: true #WoodDoor
ChestShop.shop.create.330: true #IronDoor
ChestShop.shop.create.96: true #TrapDoor
ChestShop.shop.create.music:
description: Allows to create a shop that sells music items
children:
ChestShop.shop.create.25: true #Noteblock
ChestShop.shop.create.84: true #Jukebox
ChestShop.shop.create.2256: true #Disk13
ChestShop.shop.create.2257: true #Diskcat
ChestShop.shop.create.2258: true #Diskblocks
ChestShop.shop.create.2259: true #Diskchirp
ChestShop.shop.create.2260: true #Diskfar
ChestShop.shop.create.2261: true #Diskmall
ChestShop.shop.create.2262: true #Diskmellohi
ChestShop.shop.create.2263: true #Diskstal
ChestShop.shop.create.2264: true #Diskstrad
ChestShop.shop.create.2265: true #Diskward
ChestShop.shop.create.2266: true #Disk11
ChestShop.shop.create.vehicles:
description: Allows to create a shop that sells vehicles
children:
ChestShop.shop.create.328: true #Minecart
ChestShop.shop.create.333: true #Boat
ChestShop.shop.create.342: true #StorageCart
ChestShop.shop.create.343: true #PoweredCart
ChestShop.shop.create.wool:
description: Allows to create a shop that sells wool and dye
children:
ChestShop.shop.create.35: true #Wool
ChestShop.shop.create.351: true #Dyes
ChestShop.shop.create.fence:
description: Allows to create a shop that sells fence
children:
ChestShop.shop.create.85: true #Fence
ChestShop.shop.create.101: true #IronBar
ChestShop.shop.create.107: true #FenceGate
ChestShop.shop.create.113: true #NetherFence
ChestShop.shop.create.bench:
description: Allows to create a shop that sells crafting blocks
children:
ChestShop.shop.create.58: true #WorkBench
ChestShop.shop.create.61: true #Furnace
ChestShop.shop.create.116: true #EnchantingTable
ChestShop.shop.create.379: true #BrewingStand
ChestShop.shop.create.380: true #Cauldron
ChestShop.shop.create.unobtainables:
description: Allows to create a shop that sells unobtainable items
children:
ChestShop.shop.create.7: true #Bedrock
ChestShop.shop.create.8: true #Water
ChestShop.shop.create.9: true #StillWater
ChestShop.shop.create.10: true #Lava
ChestShop.shop.create.11: true #StillLava
ChestShop.shop.create.19: true #Sponge
ChestShop.shop.create.26: true #PlacedBed
ChestShop.shop.create.30: true #Cobweb
ChestShop.shop.create.34: true #PistonHead
ChestShop.shop.create.36: true #MovingPiston
ChestShop.shop.create.43: true #Doublestep
ChestShop.shop.create.51: true #Fire
ChestShop.shop.create.52: true #MobSpawner
ChestShop.shop.create.55: true #PlacedRedstone
ChestShop.shop.create.59: true #GrowingCrop
ChestShop.shop.create.60: true #TilledDirt
ChestShop.shop.create.62: true #LitFurnace
ChestShop.shop.create.63: true #SignPost
ChestShop.shop.create.64: true #PlacedDoor
ChestShop.shop.create.68: true #WallSign
ChestShop.shop.create.71: true #PlacedIronDoor
ChestShop.shop.create.73: true #GlowingRedstoneOre
ChestShop.shop.create.75: true #RedstoneTorchOff
ChestShop.shop.create.78: true #FallenSnow
ChestShop.shop.create.83: true #PlacedReeds
ChestShop.shop.create.90: true #Portal
ChestShop.shop.create.92: true #PlacedCake
ChestShop.shop.create.93: true #PlacedRepeaterOff
ChestShop.shop.create.94: true #PlacedRepeaterOn
ChestShop.shop.create.95: true #LockedChest
ChestShop.shop.create.97: true #MonsterEgg
ChestShop.shop.create.104: true #PumpkinStalk
ChestShop.shop.create.105: true #MelonStalk
ChestShop.shop.create.115: true #GrowingNetherwart
ChestShop.shop.create.117: true #BrewingBlock
ChestShop.shop.create.118: true #PlacedCauldron
ChestShop.shop.create.119: true #EndPortal
ChestShop.shop.create.120: true #EndPortalBlock