mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-11-23 10:35:15 +01:00
- Fixed chests in 1.2.3
- Formatting - Warning about old Bukkit version - Renamed "TOWNY_CANNOT_CREATE_SHOP_HERE" to "CANNOT_CREATE_SHOP_HERE" to avoid confusion - Renamed "NOT_ENOUGH_LWC_PROTECTIONS" to "NOT_ENOUGH_PROTECTIONS" and changed its message - Fixed armour enchantments - Logging shop location - Fixed Heroes for the newest version - Removed redutant plugin object - Added dev-url for CraftBukkitUpToDate - Removed redutant plugins from softdepend - Fixed a bug when the player interacts with a shop with a sign in hand
This commit is contained in:
parent
73e3616238
commit
d6bdb0486a
@ -10,6 +10,7 @@ import org.bukkit.inventory.Inventory;
|
||||
|
||||
/**
|
||||
* Temporary class until this is fixed in Bukkit RB
|
||||
*
|
||||
* @author Acrobot
|
||||
*/
|
||||
public class bInventoryFix {
|
||||
@ -18,7 +19,7 @@ public class bInventoryFix {
|
||||
|
||||
TileEntityChest teChest = (TileEntityChest) ((CraftWorld) chest.getWorld()).getTileEntityAt(chest.getX(), chest.getY(), chest.getZ());
|
||||
CraftInventory ci = new CraftInventory(teChest);
|
||||
|
||||
|
||||
if (mchest.getNeighbor() != null) {
|
||||
Chest nb = mchest.getNeighbor();
|
||||
TileEntityChest neighbor = (TileEntityChest) ((CraftWorld) chest.getWorld()).getTileEntityAt(nb.getX(), nb.getY(), nb.getZ());
|
||||
|
@ -10,8 +10,11 @@ import com.Acrobot.ChestShop.DB.Queue;
|
||||
import com.Acrobot.ChestShop.DB.Transaction;
|
||||
import com.Acrobot.ChestShop.Listeners.*;
|
||||
import com.Acrobot.ChestShop.Logging.FileWriterQueue;
|
||||
import com.Acrobot.ChestShop.Shop.ShopManagement;
|
||||
import com.Acrobot.ChestShop.Utils.uNumber;
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
import com.lennardf1989.bukkitex.Database;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
@ -54,6 +57,7 @@ public class ChestShop extends JavaPlugin {
|
||||
pluginEnable.initializePlugins();
|
||||
|
||||
warnAboutSpawnProtection();
|
||||
warnAboutOldBukkit();
|
||||
|
||||
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);
|
||||
@ -75,7 +79,7 @@ public class ChestShop extends JavaPlugin {
|
||||
////////////////// REGISTER EVENTS, SCHEDULER & STATS ///////////////////////////
|
||||
private void registerEvents() {
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
|
||||
|
||||
pm.registerEvents(new blockBreak(), this);
|
||||
pm.registerEvents(new blockPlace(), this);
|
||||
pm.registerEvents(new signChange(), this);
|
||||
@ -87,21 +91,29 @@ public class ChestShop extends JavaPlugin {
|
||||
server.getScheduler().scheduleAsyncRepeatingTask(this, runnable, startTime, repetetionTime);
|
||||
}
|
||||
|
||||
private void startStatistics(){
|
||||
try{
|
||||
private void startStatistics() {
|
||||
try {
|
||||
new Metrics().beginMeasuringPlugin(this);
|
||||
} catch (Exception ex){
|
||||
} catch (Exception ex) {
|
||||
System.err.println(chatPrefix + "There was an error while submitting statistics.");
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////// WARN ABOUT SPAWN PROTECTION ///////////////////////////
|
||||
///////////////////// WARN ///////////////////////////
|
||||
private static void warnAboutSpawnProtection() {
|
||||
if (getBukkitConfig().getInt("settings.spawn-radius") > 0)
|
||||
System.err.println(ChestShop.chatPrefix + "WARNING! Your spawn-radius in bukkit.yml isn't set to 0! " +
|
||||
"You won't be able to sell to shops built near spawn!");
|
||||
}
|
||||
|
||||
private static void warnAboutOldBukkit() {
|
||||
String split[] = Bukkit.getBukkitVersion().split("-R");
|
||||
if (split[0].equals("1.1") && split.length > 1 && uNumber.isInteger(split[1]) && (Integer.parseInt(split[1])) < 7) {
|
||||
System.err.println(ChestShop.chatPrefix + "Your CraftBukkit version is outdated! Use at least 1.1-R7 or 1.2.3-R0!");
|
||||
ShopManagement.useOldChest = true;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////// DATABASE STUFF ////////////////////////////////
|
||||
private static YamlConfiguration getBukkitConfig() {
|
||||
return YamlConfiguration.loadConfiguration(new File("bukkit.yml"));
|
||||
|
@ -9,56 +9,34 @@ import org.bukkit.inventory.ItemStack;
|
||||
* @author Acrobot
|
||||
*/
|
||||
public class MinecraftChest implements ChestObject {
|
||||
private final Chest main;
|
||||
private final Chest neighbor;
|
||||
private final Chest chest;
|
||||
|
||||
public MinecraftChest(Chest chest) {
|
||||
this.main = chest;
|
||||
this.neighbor = getNeighbor();
|
||||
this.chest = chest;
|
||||
}
|
||||
|
||||
public ItemStack[] getContents() {
|
||||
ItemStack[] contents = new ItemStack[(neighbor != null ? 54 : 27)];
|
||||
ItemStack[] chest1 = main.getInventory().getContents();
|
||||
|
||||
System.arraycopy(chest1, 0, contents, 0, chest1.length);
|
||||
|
||||
if (neighbor != null) {
|
||||
ItemStack[] chest2 = neighbor.getInventory().getContents();
|
||||
System.arraycopy(chest2, 0, contents, chest1.length, chest2.length);
|
||||
}
|
||||
|
||||
return contents;
|
||||
return chest.getInventory().getContents();
|
||||
}
|
||||
|
||||
public void setSlot(int slot, ItemStack item) {
|
||||
if (slot < main.getInventory().getSize()) {
|
||||
main.getInventory().setItem(slot, item);
|
||||
} else {
|
||||
neighbor.getInventory().setItem(slot - main.getInventory().getSize(), item);
|
||||
}
|
||||
chest.getInventory().setItem(slot, item);
|
||||
}
|
||||
|
||||
public void clearSlot(int slot) {
|
||||
if (slot < main.getInventory().getSize()) {
|
||||
main.getInventory().setItem(slot, null);
|
||||
} else {
|
||||
neighbor.getInventory().setItem(slot - main.getInventory().getSize(), null);
|
||||
}
|
||||
chest.getInventory().setItem(slot, null);
|
||||
}
|
||||
|
||||
public void addItem(ItemStack item, int amount) {
|
||||
int left = addItem(item, amount, main);
|
||||
if (neighbor != null && left > 0) addItem(item, left, neighbor);
|
||||
uInventory.add(chest.getInventory(), item, amount);
|
||||
}
|
||||
|
||||
public void removeItem(ItemStack item, short durability, int amount) {
|
||||
int left = removeItem(item, durability, amount, main);
|
||||
if (neighbor != null && left > 0) removeItem(item, durability, left, neighbor);
|
||||
uInventory.remove(chest.getInventory(), item, amount, durability);
|
||||
}
|
||||
|
||||
public int amount(ItemStack item, short durability) {
|
||||
return amount(item, durability, main) + (neighbor != null ? amount(item, durability, neighbor) : 0);
|
||||
return uInventory.amount(chest.getInventory(), item, durability);
|
||||
}
|
||||
|
||||
public boolean hasEnough(ItemStack item, int amount, short durability) {
|
||||
@ -66,31 +44,14 @@ public class MinecraftChest implements ChestObject {
|
||||
}
|
||||
|
||||
public boolean fits(ItemStack item, int amount, short durability) {
|
||||
int firstChest = fits(item, amount, durability, main);
|
||||
return (firstChest > 0 && neighbor != null ? fits(item, firstChest, durability, neighbor) <= 0 : firstChest <= 0);
|
||||
return uInventory.fits(chest.getInventory(), item, amount, durability) <= 0;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return main.getInventory().getSize() + (neighbor != null ? neighbor.getInventory().getSize() : 0);
|
||||
return chest.getInventory().getSize();
|
||||
}
|
||||
|
||||
public Chest getNeighbor() {
|
||||
return uBlock.findNeighbor(main);
|
||||
return uBlock.findNeighbor(chest);
|
||||
}
|
||||
|
||||
private static int amount(ItemStack item, short durability, Chest chest) {
|
||||
return uInventory.amount(chest.getInventory(), item, durability);
|
||||
}
|
||||
|
||||
private static int fits(ItemStack item, int amount, short durability, Chest chest) {
|
||||
return uInventory.fits(chest.getInventory(), item, amount, durability);
|
||||
}
|
||||
|
||||
private static int addItem(ItemStack item, int amount, Chest chest) {
|
||||
return uInventory.add(chest.getInventory(), item, amount);
|
||||
}
|
||||
|
||||
private static int removeItem(ItemStack item, short durability, int amount, Chest chest) {
|
||||
return uInventory.remove(chest.getInventory(), item, amount, durability);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,42 +1,43 @@
|
||||
package com.Acrobot.ChestShop.Chests;
|
||||
|
||||
import com.Acrobot.ChestShop.Utils.uBlock;
|
||||
import com.Acrobot.ChestShop.BukkitFixes.bInventoryFix;
|
||||
import com.Acrobot.ChestShop.Utils.uInventory;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* @author Acrobot
|
||||
*/
|
||||
public class MinecraftChest_forNewBukkit implements ChestObject {
|
||||
private final Chest chest;
|
||||
public class OldMCchest implements ChestObject {
|
||||
private final Inventory inventory;
|
||||
|
||||
public MinecraftChest_forNewBukkit(Chest chest) {
|
||||
this.chest = chest;
|
||||
public OldMCchest(Chest chest) {
|
||||
this.inventory = bInventoryFix.getInventory(chest);
|
||||
}
|
||||
|
||||
public ItemStack[] getContents() {
|
||||
return chest.getInventory().getContents();
|
||||
return inventory.getContents();
|
||||
}
|
||||
|
||||
public void setSlot(int slot, ItemStack item) {
|
||||
chest.getInventory().setItem(slot, item);
|
||||
inventory.setItem(slot, item);
|
||||
}
|
||||
|
||||
public void clearSlot(int slot) {
|
||||
chest.getInventory().setItem(slot, null);
|
||||
inventory.clear(slot);
|
||||
}
|
||||
|
||||
public void addItem(ItemStack item, int amount) {
|
||||
uInventory.add(chest.getInventory(), item, amount);
|
||||
uInventory.add(inventory, item, amount);
|
||||
}
|
||||
|
||||
public void removeItem(ItemStack item, short durability, int amount) {
|
||||
uInventory.remove(chest.getInventory(), item, amount, durability);
|
||||
uInventory.remove(inventory, item, amount, durability);
|
||||
}
|
||||
|
||||
public int amount(ItemStack item, short durability) {
|
||||
return uInventory.amount(chest.getInventory(), item, durability);
|
||||
return uInventory.amount(inventory, item, durability);
|
||||
}
|
||||
|
||||
public boolean hasEnough(ItemStack item, int amount, short durability) {
|
||||
@ -44,14 +45,10 @@ public class MinecraftChest_forNewBukkit implements ChestObject {
|
||||
}
|
||||
|
||||
public boolean fits(ItemStack item, int amount, short durability) {
|
||||
return uInventory.fits(chest.getInventory(), item, amount, durability) <= 0;
|
||||
return uInventory.fits(inventory, item, amount, durability) <= 0;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return chest.getInventory().getSize();
|
||||
}
|
||||
|
||||
public Chest getNeighbor() {
|
||||
return uBlock.findNeighbor(chest);
|
||||
return inventory.getSize();
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ public class ItemInfo implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (item == null || item.getType() == Material.AIR) return false;
|
||||
|
||||
|
||||
String durability = (item.getDurability() != 0 ? ChatColor.DARK_GREEN + ":" + item.getDurability() : "");
|
||||
String ench = uEnchantment.getEnchantment(item);
|
||||
String enchantment = (ench != null ? ChatColor.DARK_AQUA + "-" + ench : "");
|
||||
@ -47,8 +47,8 @@ public class ItemInfo implements CommandExecutor {
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
private static String intToRoman(int integer){
|
||||
|
||||
private static String intToRoman(int integer) {
|
||||
if (integer == 1) return "I";
|
||||
if (integer == 2) return "II";
|
||||
if (integer == 3) return "III";
|
||||
@ -56,10 +56,9 @@ public class ItemInfo implements CommandExecutor {
|
||||
if (integer == 5) return "V";
|
||||
return Integer.toString(integer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static String joinArray(String[] array){
|
||||
|
||||
private static String joinArray(String[] array) {
|
||||
StringBuilder b = new StringBuilder(array.length);
|
||||
for (String s : array) b.append(s).append(' ');
|
||||
return b.toString();
|
||||
|
@ -13,7 +13,7 @@ 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")){
|
||||
if (args.length > 0 && args[0].equals("reload")) {
|
||||
Config.config = new ConfigObject();
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "The config was reloaded.");
|
||||
return true;
|
||||
|
@ -20,7 +20,7 @@ public class Config {
|
||||
public static float getFloat(Property value) {
|
||||
return new Float(getValue(value.name()).toString());
|
||||
}
|
||||
|
||||
|
||||
public static float getFloat(String value) {
|
||||
return new Float(getValue(value).toString());
|
||||
}
|
||||
@ -44,7 +44,7 @@ public class Config {
|
||||
public static String getLocal(Language lang) {
|
||||
return getColored(config.getLanguageConfig().getString(Language.prefix.name()) + config.getLanguageConfig().getString(lang.name()));
|
||||
}
|
||||
|
||||
|
||||
public static boolean exists(String value) {
|
||||
return getValue(value) != null;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class ConfigObject {
|
||||
public Object getProperty(String property) {
|
||||
return config.get(property);
|
||||
}
|
||||
|
||||
|
||||
public static void load(FileConfiguration config, File file) {
|
||||
try {
|
||||
config.load(file);
|
||||
@ -72,7 +72,7 @@ public class ConfigObject {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void save(FileConfiguration config, File file) {
|
||||
try {
|
||||
config.save(file);
|
||||
@ -80,7 +80,7 @@ public class ConfigObject {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void reloadConfig(FileConfiguration config, File file) {
|
||||
save(config, file);
|
||||
load(config, file);
|
||||
|
@ -39,9 +39,9 @@ public enum Language {
|
||||
|
||||
NO_PERMISSION("You don't have permissions to do that!"),
|
||||
INCORRECT_ITEM_ID("You have specified invalid item id!"),
|
||||
NOT_ENOUGH_LWC_PROTECTIONS("You have reached the LWC protections limit!"),
|
||||
NOT_ENOUGH_PROTECTIONS("You have reached the protection limit!"),
|
||||
|
||||
TOWNY_CANNOT_CREATE_SHOP_HERE("You can't create shop here!");
|
||||
CANNOT_CREATE_SHOP_HERE("You can't create shop here!");
|
||||
|
||||
|
||||
private final String text;
|
||||
|
@ -9,11 +9,11 @@ public class MaxPrice {
|
||||
public static boolean canCreate(float buyPrice, float sellPrice, Material mat) {
|
||||
float bPrice = maxBuyPrice(mat.getId());
|
||||
float sPrice = maxSellPrice(mat.getId());
|
||||
|
||||
|
||||
return (bPrice == -1 || buyPrice <= maxBuyPrice(mat.getId()))
|
||||
&& (sPrice == -1 || sellPrice <= maxSellPrice(mat.getId()));
|
||||
}
|
||||
|
||||
|
||||
public static float maxBuyPrice(int itemID) {
|
||||
return getPrice("buy", itemID);
|
||||
}
|
||||
|
@ -23,7 +23,8 @@ public class Transaction {
|
||||
private float price;
|
||||
private long sec;
|
||||
|
||||
public Transaction() {}
|
||||
public Transaction() {
|
||||
}
|
||||
|
||||
public float getAveragePricePerItem() {
|
||||
return price / amount;
|
||||
|
@ -5,9 +5,14 @@ package com.Acrobot.ChestShop.Economy;
|
||||
*/
|
||||
public interface EcoPlugin {
|
||||
public boolean hasAccount(String player);
|
||||
|
||||
public void add(String player, double amount);
|
||||
|
||||
public void subtract(String player, double amount);
|
||||
|
||||
public boolean hasEnough(String player, double amount);
|
||||
|
||||
public double balance(String player);
|
||||
|
||||
public String format(double amount);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class Economy {
|
||||
economy.add(uLongName.getName(name), amount);
|
||||
}
|
||||
|
||||
public static void addServer(String name, float amount){
|
||||
public static void addServer(String name, float amount) {
|
||||
String account = Config.getString(Property.SERVER_ECONOMY_ACCOUNT);
|
||||
if (!account.isEmpty()) {
|
||||
float tax = getTax(Property.SERVER_TAX_AMOUNT, amount);
|
||||
@ -36,7 +36,7 @@ public class Economy {
|
||||
economy.add(uLongName.getName(name), amount);
|
||||
}
|
||||
|
||||
public static float getTax(Property tax, float price){
|
||||
public static float getTax(Property tax, float price) {
|
||||
return (Config.getFloat(tax) / 100F) * price;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ package com.Acrobot.ChestShop.Economy;
|
||||
/**
|
||||
* @author Acrobot
|
||||
*/
|
||||
public class NoProvider implements EcoPlugin{
|
||||
public class NoProvider implements EcoPlugin {
|
||||
public boolean hasAccount(String player) {
|
||||
printError();
|
||||
return false;
|
||||
@ -31,7 +31,7 @@ public class NoProvider implements EcoPlugin{
|
||||
printError();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static void printError() {
|
||||
System.err.println("[ChestShop] You haven't got any economy plugin!");
|
||||
}
|
||||
|
@ -5,8 +5,9 @@ import com.nijikokun.register.payment.forChestShop.Method;
|
||||
/**
|
||||
* @author Acrobot
|
||||
*/
|
||||
public class Register implements EcoPlugin{
|
||||
public class Register implements EcoPlugin {
|
||||
public static Method eco;
|
||||
|
||||
public boolean hasAccount(String player) {
|
||||
return eco.hasAccount(player);
|
||||
}
|
||||
|
@ -38,15 +38,17 @@ public class DataValue {
|
||||
materialData = new Coal(CoalType.valueOf(type));
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) { return 0; }
|
||||
} catch (Exception e) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (materialData == null ? 0 : materialData.getData());
|
||||
}
|
||||
|
||||
public static String getName(ItemStack is){
|
||||
|
||||
public static String getName(ItemStack is) {
|
||||
short dur = is.getDurability();
|
||||
if (dur == 0) return null;
|
||||
|
||||
|
||||
Material material = is.getType();
|
||||
|
||||
String name = null;
|
||||
@ -71,7 +73,9 @@ public class DataValue {
|
||||
name = CoalType.getByData((byte) dur).name();
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) { return null; }
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
@ -37,16 +37,22 @@ public class Items {
|
||||
}
|
||||
return finalMaterial;
|
||||
}
|
||||
|
||||
public static String getName(ItemStack is){
|
||||
|
||||
public static String getName(ItemStack is) {
|
||||
return getName(is, true);
|
||||
}
|
||||
|
||||
public static String getName(ItemStack is, boolean showData){
|
||||
|
||||
public static String getName(ItemStack is, boolean showData) {
|
||||
String name = DataValue.getName(is);
|
||||
return uSign.capitalizeFirst((name != null && showData ? name + '_' : "") + is.getType());
|
||||
}
|
||||
|
||||
public static String getSignName(ItemStack is) {
|
||||
return is.getType().name()
|
||||
+ (is.getDurability() > 0 ? ':' + is.getDurability() : "")
|
||||
+ (!is.getEnchantments().isEmpty() ? '-' + uEnchantment.encodeEnchantment(is.getEnchantments()) : "");
|
||||
}
|
||||
|
||||
public static ItemStack getItemStack(String itemName) {
|
||||
ItemStack toReturn = getFromOddItem(itemName);
|
||||
if (toReturn != null) return toReturn;
|
||||
@ -65,11 +71,11 @@ public class Items {
|
||||
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);
|
||||
|
||||
|
||||
short data = getDataFromWord(space[0], material);
|
||||
if (data != 0) toReturn.setDurability(data);
|
||||
|
||||
@ -79,7 +85,7 @@ public class Items {
|
||||
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);
|
||||
@ -88,19 +94,19 @@ public class Items {
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
private static Map<Enchantment, Integer> getEnchantment(String itemName){
|
||||
private static Map<Enchantment, Integer> getEnchantment(String itemName) {
|
||||
return uEnchantment.decodeEnchantment(itemName);
|
||||
}
|
||||
|
||||
private static Map<Enchantment, Integer> getEnchant(String original){
|
||||
|
||||
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));
|
||||
|
||||
private static ItemStack addEnchantments(ItemStack is, String itemname) {
|
||||
try { is.addEnchantments(getEnchant(itemname));
|
||||
} catch (Exception ignored) {}
|
||||
return is;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class blockBreak implements Listener {
|
||||
if (!isCorrectSign(sign, block)) return false; //It's not a correct shop sign, so don't cancel it
|
||||
if (playerIsNotOwner(player, sign)) return !isAdmin(player); //If the player isn't the owner or an admin - cancel!
|
||||
|
||||
if (weShouldReturnMoney() && !Permission.has(player, Permission.NOFEE)){
|
||||
if (weShouldReturnMoney() && !Permission.has(player, Permission.NOFEE)) {
|
||||
float refundPrice = Config.getFloat(Property.SHOP_REFUND_PRICE);
|
||||
Economy.add(uLongName.getName(sign.getLine(0)), refundPrice); //Add some money
|
||||
player.sendMessage(Config.getLocal(Language.SHOP_REFUNDED).replace("%amount", Economy.formatBalance(refundPrice)));
|
||||
@ -47,7 +47,7 @@ public class blockBreak implements Listener {
|
||||
|
||||
return false; //Player is the owner, so we don't want to cancel this :)
|
||||
}
|
||||
|
||||
|
||||
private static boolean isAdmin(Player p) {
|
||||
return p != null && (Permission.has(p, Permission.ADMIN) || Permission.has(p, Permission.MOD));
|
||||
}
|
||||
@ -109,12 +109,12 @@ public class blockBreak implements Listener {
|
||||
return pistonDirection != null ? event.getBlock().getRelative((pistonDirection), 2).getLocation().getBlock() : null;
|
||||
}
|
||||
|
||||
private static List<Block> getExtendBlocks(BlockPistonExtendEvent event){
|
||||
private static List<Block> getExtendBlocks(BlockPistonExtendEvent event) {
|
||||
BlockFace pistonDirection = getPistonDirection(event.getBlock());
|
||||
if (pistonDirection == null) return new ArrayList<Block>();
|
||||
Block piston = event.getBlock();
|
||||
ArrayList<Block> list = new ArrayList<Block>();
|
||||
for (int b = 1; b < event.getLength() + 1; b++){
|
||||
for (int b = 1; b < event.getLength() + 1; b++) {
|
||||
Block block = piston.getRelative(pistonDirection, b);
|
||||
Material blockType = block.getType();
|
||||
if (blockType == Material.AIR) break;
|
||||
|
@ -26,12 +26,12 @@ public class blockPlace implements Listener {
|
||||
}
|
||||
|
||||
Block placed = event.getBlockPlaced();
|
||||
if (placed.getType() == Material.CHEST){
|
||||
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)){
|
||||
if (Security.isProtected(neighborBlock) && !Security.canAccess(event.getPlayer(), neighborBlock)) {
|
||||
event.getPlayer().sendMessage(Config.getLocal(Language.ACCESS_DENIED));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ public class playerInteract implements Listener {
|
||||
Block block = event.getClickedBlock();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (player.getItemInHand() != null && player.getItemInHand().getType() == Material.SIGN) return;
|
||||
if (Config.getBoolean(Property.USE_BUILT_IN_PROTECTION) && block.getType() == Material.CHEST) {
|
||||
Default protection = new Default();
|
||||
if (!hasAdminPermissions(player) && (protection.isProtected(block) && !protection.canAccess(player, block))) {
|
||||
@ -54,9 +53,10 @@ public class playerInteract implements Listener {
|
||||
if (!uSign.isSign(block)) return;
|
||||
Sign sign = (Sign) block.getState();
|
||||
|
||||
if (player.getItemInHand() != null && player.getItemInHand().getType() == Material.SIGN) return;
|
||||
if (!uSign.isValid(sign) || !enoughTimeHasPassed(player) || player.isSneaking()) return;
|
||||
|
||||
if (Config.getBoolean(Property.IGNORE_CREATIVE_MODE) && player.getGameMode() == GameMode.CREATIVE){
|
||||
if (Config.getBoolean(Property.IGNORE_CREATIVE_MODE) && player.getGameMode() == GameMode.CREATIVE) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import com.Acrobot.ChestShop.Protection.Security;
|
||||
import com.Acrobot.ChestShop.Utils.WorldGuard.uWorldGuard;
|
||||
import com.Acrobot.ChestShop.Utils.uHeroes;
|
||||
import com.Acrobot.ChestShop.Utils.uSign;
|
||||
import com.daemitus.deadbolt.Deadbolt;
|
||||
import com.griefcraft.lwc.LWCPlugin;
|
||||
import com.herocraftonline.heroes.Heroes;
|
||||
import com.nijikokun.register.payment.forChestShop.Method;
|
||||
@ -37,8 +36,8 @@ public class pluginEnable {
|
||||
}
|
||||
loadRegister();
|
||||
}
|
||||
|
||||
private static void loadRegister(){
|
||||
|
||||
private static void loadRegister() {
|
||||
if (com.Acrobot.ChestShop.Economy.Economy.economy == null) {
|
||||
Method m = Methods.load(ChestShop.pm);
|
||||
if (m == null) {
|
||||
@ -59,7 +58,6 @@ public class pluginEnable {
|
||||
LockettePlugin.lockette = (Lockette) plugin;
|
||||
Security.protections.add(new LockettePlugin());
|
||||
} else if (name.equals("Deadbolt")) {
|
||||
DeadboltPlugin.deadbolt = (Deadbolt) plugin;
|
||||
Security.protections.add(new DeadboltPlugin());
|
||||
} else if (name.equals("OddItem")) {
|
||||
Odd.isInitialized = true;
|
||||
@ -77,7 +75,7 @@ public class pluginEnable {
|
||||
com.Acrobot.ChestShop.Economy.Economy.economy = new Vault();
|
||||
System.out.println(ChestShop.chatPrefix + "Vault loaded using economy plugin " + Vault.economy.getName());
|
||||
return;
|
||||
} else if (name.equals("Heroes")){
|
||||
} else if (name.equals("Heroes")) {
|
||||
uHeroes.heroes = (Heroes) plugin;
|
||||
} else if (name.equals("SimpleChestLock")) {
|
||||
SCLplugin.scl = (SCL) plugin;
|
||||
@ -85,7 +83,7 @@ public class pluginEnable {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
PluginDescriptionFile description = plugin.getDescription();
|
||||
System.out.println(ChestShop.chatPrefix + description.getName() + " version " + description.getVersion() + " loaded.");
|
||||
}
|
||||
|
@ -80,8 +80,8 @@ public class signChange implements Listener {
|
||||
dropSign(event);
|
||||
return;
|
||||
} else if (!playerIsAdmin) {
|
||||
if (!Config.getBoolean(Property.ALLOW_MULTIPLE_SHOPS_AT_ONE_BLOCK) && !Security.canPlaceSign(player, (Sign) signBlock.getState())) {
|
||||
player.sendMessage(Config.getLocal(Language.ANOTHER_SHOP_DETECTED));
|
||||
if (!Security.canPlaceSign(player, (Sign) signBlock.getState())) {
|
||||
player.sendMessage(Config.getLocal(Language.CANNOT_CREATE_SHOP_HERE));
|
||||
dropSign(event);
|
||||
return;
|
||||
}
|
||||
@ -92,7 +92,7 @@ public class signChange implements Listener {
|
||||
boolean bothActive = uSign.towny != null && uWorldGuard.wg != null;
|
||||
|
||||
if (((!canBuildTowny || !canBuildWorldGuard) && !bothActive) || (bothActive && !canBuildTowny && !canBuildWorldGuard)) {
|
||||
player.sendMessage(Config.getLocal(Language.TOWNY_CANNOT_CREATE_SHOP_HERE));
|
||||
player.sendMessage(Config.getLocal(Language.CANNOT_CREATE_SHOP_HERE));
|
||||
dropSign(event);
|
||||
return;
|
||||
}
|
||||
@ -106,7 +106,7 @@ public class signChange implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
float buyPrice = uSign.buyPrice(thirdLine);
|
||||
float buyPrice = uSign.buyPrice(thirdLine);
|
||||
float sellPrice = uSign.sellPrice(thirdLine);
|
||||
|
||||
if (!playerIsAdmin && (!canCreateShop(player, mat.getId(), buyPrice != -1, sellPrice != -1) || !MaxPrice.canCreate(buyPrice, sellPrice, mat))) {
|
||||
@ -128,7 +128,7 @@ public class signChange implements Listener {
|
||||
}
|
||||
|
||||
if (Config.getBoolean(Property.PROTECT_SIGN_WITH_LWC)) {
|
||||
if (!Security.protect(player.getName(), signBlock)) player.sendMessage(Config.getLocal(Language.NOT_ENOUGH_LWC_PROTECTIONS));
|
||||
if (!Security.protect(player.getName(), signBlock)) player.sendMessage(Config.getLocal(Language.NOT_ENOUGH_PROTECTIONS));
|
||||
}
|
||||
if (Config.getBoolean(Property.PROTECT_CHEST_WITH_LWC) && chest != null && Security.protect(player.getName(), chest.getBlock())) {
|
||||
player.sendMessage(Config.getLocal(Language.PROTECTED_SHOP));
|
||||
@ -143,7 +143,7 @@ public class signChange implements Listener {
|
||||
private static boolean canCreateShop(Player player, int ID, boolean buy, boolean sell) {
|
||||
if (Permission.has(player, Permission.SHOP_CREATION_ID + Integer.toString(ID))) return true;
|
||||
|
||||
if (buy && !Permission.has(player, Permission.SHOP_CREATION_BUY)) return false;
|
||||
if (buy && !Permission.has(player, Permission.SHOP_CREATION_BUY)) return false;
|
||||
if (sell && !Permission.has(player, Permission.SHOP_CREATION_SELL)) return false;
|
||||
|
||||
return true;
|
||||
@ -180,8 +180,8 @@ public class signChange implements Listener {
|
||||
private static boolean formatFirstLine(String line1, Player player) {
|
||||
return line1.isEmpty() ||
|
||||
(!line1.equals(uLongName.stripName(player.getName()))
|
||||
&& !Permission.has(player, Permission.ADMIN)
|
||||
&& !Permission.otherName(player, line1));
|
||||
&& !Permission.has(player, Permission.ADMIN)
|
||||
&& !Permission.otherName(player, line1));
|
||||
}
|
||||
|
||||
private static void dropSign(SignChangeEvent event) {
|
||||
|
@ -4,7 +4,9 @@ import com.Acrobot.ChestShop.Config.Config;
|
||||
import com.Acrobot.ChestShop.Config.Property;
|
||||
import com.Acrobot.ChestShop.DB.Queue;
|
||||
import com.Acrobot.ChestShop.DB.Transaction;
|
||||
import com.Acrobot.ChestShop.Items.Items;
|
||||
import com.Acrobot.ChestShop.Shop.Shop;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -32,10 +34,20 @@ public class Logging {
|
||||
}
|
||||
|
||||
public static void logTransaction(boolean isBuying, Shop shop, Player player) {
|
||||
log(player.getName() + (isBuying ? " bought " : " sold ") + shop.stockAmount + ' ' + shop.stock.getType() + " for " + (isBuying ? shop.buyPrice + " from " : shop.sellPrice + " to ") + shop.owner);
|
||||
log(player.getName()
|
||||
+ (isBuying ? " bought " : " sold ")
|
||||
+ shop.stockAmount + ' '
|
||||
+ Items.getSignName(shop.stock) + " for "
|
||||
+ (isBuying ? shop.buyPrice + " from " : shop.sellPrice + " to ")
|
||||
+ shop.owner + " at "
|
||||
+ locationToString(shop.sign.getLocation()));
|
||||
if (Config.getBoolean(Property.LOG_TO_DATABASE) || Config.getBoolean(Property.GENERATE_STATISTICS_PAGE)) logToDatabase(isBuying, shop, player);
|
||||
}
|
||||
|
||||
private static String locationToString(Location loc) {
|
||||
return '[' + loc.getWorld().getName() + "] " + loc.getBlockX() + ", " + loc.getBlockY() + ", " + loc.getBlockZ();
|
||||
}
|
||||
|
||||
private static void logToDatabase(boolean isBuying, Shop shop, Player player) {
|
||||
Transaction transaction = new Transaction();
|
||||
|
||||
|
@ -33,24 +33,12 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.*;
|
||||
import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
public class Metrics {
|
||||
|
||||
@ -242,7 +230,7 @@ public class Metrics {
|
||||
|
||||
// Acquire a lock on the graphs, which lets us make the assumption we also lock everything
|
||||
// inside of the graph (e.g plotters)
|
||||
synchronized(graphs) {
|
||||
synchronized (graphs) {
|
||||
for (Graph graph : graphs) {
|
||||
// Because we have a lock on the graphs set already, it is reasonable to assume
|
||||
// that our lock transcends down to the individual plotters in the graphs also.
|
||||
@ -299,11 +287,8 @@ public class Metrics {
|
||||
// Is this the first update this hour?
|
||||
if (response.contains("OK This is your first update this hour")) {
|
||||
synchronized (graphs) {
|
||||
Iterator<Graph> iter = graphs.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
Graph graph = iter.next();
|
||||
|
||||
for (Graph graph : graphs) {
|
||||
for (Plotter plotter : graph.getPlotters()) {
|
||||
plotter.reset();
|
||||
}
|
||||
@ -368,7 +353,7 @@ public class Metrics {
|
||||
* Encode a key/value data pair to be used in a HTTP post request. This INCLUDES a & so the first
|
||||
* key/value pair MUST be included manually, e.g:
|
||||
* <p>
|
||||
* String httpData = encode("guid") + "=" + encode("1234") + encodeDataPair("authors") + "..";
|
||||
* String httpData = encode("guid") + "=" + encode("1234") + encodeDataPair("authors") + "..";
|
||||
* </p>
|
||||
*
|
||||
* @param key
|
||||
@ -474,6 +459,7 @@ public class Metrics {
|
||||
|
||||
/**
|
||||
* Gets an <b>unmodifiable</b> set of the plotter objects in the graph
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Set<Plotter> getPlotters() {
|
||||
|
@ -36,14 +36,14 @@ public enum Permission {
|
||||
public static boolean has(Player player, String node) {
|
||||
return player.hasPermission(node) || player.hasPermission(node.toLowerCase());
|
||||
}
|
||||
|
||||
public static boolean otherName(Player p, String name){
|
||||
|
||||
public static boolean otherName(Player p, String name) {
|
||||
if (has(p, Permission.ADMIN)) return false;
|
||||
String node = OTHER_NAME + name;
|
||||
return hasPermissionSet(p, node) || hasPermissionSet(p, node.toLowerCase());
|
||||
}
|
||||
|
||||
private static boolean hasPermissionSet(Player p, String perm){
|
||||
|
||||
private static boolean hasPermissionSet(Player p, String perm) {
|
||||
return p.isPermissionSet(perm) && p.hasPermission(perm);
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,6 @@ import org.bukkit.entity.Player;
|
||||
* @author Acrobot
|
||||
*/
|
||||
public class DeadboltPlugin implements Protection {
|
||||
public static Deadbolt deadbolt;
|
||||
|
||||
public boolean isProtected(Block block) {
|
||||
return Deadbolt.isProtected(block);
|
||||
}
|
||||
|
@ -26,13 +26,13 @@ public class Default implements Protection {
|
||||
|
||||
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
|
||||
return neighborSign == null
|
||||
|| uLongName.stripName(playerName).equals(neighborSign.getLine(0))
|
||||
|| Permission.otherName(player, neighborSign.getLine(0));
|
||||
}
|
||||
|
@ -1,8 +1,11 @@
|
||||
package com.Acrobot.ChestShop.Protection;
|
||||
|
||||
import com.Acrobot.ChestShop.Config.Config;
|
||||
import com.Acrobot.ChestShop.Config.Property;
|
||||
import com.Acrobot.ChestShop.Listeners.blockBreak;
|
||||
import com.Acrobot.ChestShop.Utils.uLongName;
|
||||
import com.Acrobot.ChestShop.Utils.uSign;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Sign;
|
||||
@ -14,7 +17,8 @@ import java.util.ArrayList;
|
||||
* @author Acrobot
|
||||
*/
|
||||
public class Security {
|
||||
private static BlockFace[] faces = {BlockFace.UP, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH};
|
||||
private static final BlockFace[] faces = {BlockFace.UP, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH};
|
||||
private static final BlockFace[] blockFaces = {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH};
|
||||
public static ArrayList<Protection> protections = new ArrayList<Protection>();
|
||||
|
||||
public static boolean protect(String name, Block block) {
|
||||
@ -36,13 +40,31 @@ public class Security {
|
||||
}
|
||||
|
||||
public static boolean canPlaceSign(Player p, Sign sign) {
|
||||
return !thereIsAnotherSignByPlayer(blockBreak.getAttachedFace(sign), sign.getBlock(), uLongName.stripName(p.getName()));
|
||||
return !anotherShopFound(blockBreak.getAttachedFace(sign), sign.getBlock(), p) && canBePlaced(p, sign.getBlock());
|
||||
}
|
||||
|
||||
private static boolean thereIsAnotherSignByPlayer(Block baseBlock, Block signBlock, String shortName) {
|
||||
private static boolean canBePlaced(Player p, Block signBlock) {
|
||||
for (BlockFace bf : blockFaces) {
|
||||
Block block = signBlock.getRelative(bf);
|
||||
|
||||
if (block.getType() != Material.CHEST) continue;
|
||||
if (isProtected(block) && !canAccess(p, block)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean anotherShopFound(Block baseBlock, Block signBlock, Player p) {
|
||||
String shortName = uLongName.stripName(p.getName());
|
||||
if (Config.getBoolean(Property.ALLOW_MULTIPLE_SHOPS_AT_ONE_BLOCK)) return false;
|
||||
|
||||
for (BlockFace bf : faces) {
|
||||
Block block = baseBlock.getRelative(bf);
|
||||
if (uSign.isSign(block) && uSign.isValid((Sign) block.getState()) && !block.equals(signBlock) && blockBreak.getAttachedFace((Sign) block.getState()).equals(baseBlock) && !((Sign) block.getState()).getLine(0).equals(shortName))
|
||||
|
||||
if (!uSign.isSign(block)) continue;
|
||||
|
||||
Sign s = (Sign) block.getState();
|
||||
if (uSign.isValid(s) && !block.equals(signBlock) && blockBreak.getAttachedFace(s).equals(baseBlock) && !s.getLine(0).equals(shortName))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -27,7 +27,7 @@ public class Shop {
|
||||
public float buyPrice;
|
||||
public float sellPrice;
|
||||
public final String owner;
|
||||
private final Sign sign;
|
||||
public final Sign sign;
|
||||
|
||||
public Shop(ChestObject chest, boolean buy, Sign sign, ItemStack... itemStacks) {
|
||||
this.stock = itemStacks[0];
|
||||
@ -204,8 +204,8 @@ public class Shop {
|
||||
private boolean hasEnoughStock() {
|
||||
return chest.hasEnough(stock, stockAmount, durability);
|
||||
}
|
||||
|
||||
private int stockAmount(ItemStack item, short durability){
|
||||
|
||||
private int stockAmount(ItemStack item, short durability) {
|
||||
return chest.amount(item, durability);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.Acrobot.ChestShop.Shop;
|
||||
|
||||
import com.Acrobot.ChestShop.Chests.ChestObject;
|
||||
import com.Acrobot.ChestShop.Chests.MinecraftChest;
|
||||
import com.Acrobot.ChestShop.Chests.OldMCchest;
|
||||
import com.Acrobot.ChestShop.Items.Items;
|
||||
import com.Acrobot.ChestShop.Utils.uBlock;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -13,6 +15,8 @@ import org.bukkit.inventory.ItemStack;
|
||||
* @author Acrobot
|
||||
*/
|
||||
public class ShopManagement {
|
||||
public static boolean useOldChest = false;
|
||||
|
||||
public static void buy(Sign sign, Player player) {
|
||||
Chest chestMc = uBlock.findChest(sign);
|
||||
ItemStack item = Items.getItemStack(sign.getLine(3));
|
||||
@ -20,7 +24,7 @@ public class ShopManagement {
|
||||
player.sendMessage(ChatColor.RED + "[Shop] The item is not recognised!");
|
||||
return;
|
||||
}
|
||||
Shop shop = new Shop(chestMc != null ? new MinecraftChest(chestMc) : null, true, sign, item);
|
||||
Shop shop = new Shop(chestMc != null ? getChest(chestMc) : null, true, sign, item);
|
||||
shop.buy(player);
|
||||
}
|
||||
|
||||
@ -31,7 +35,11 @@ public class ShopManagement {
|
||||
player.sendMessage(ChatColor.RED + "[Shop] The item is not recognised!");
|
||||
return;
|
||||
}
|
||||
Shop shop = new Shop(chestMc != null ? new MinecraftChest(chestMc) : null, false, sign, item);
|
||||
Shop shop = new Shop(chestMc != null ? getChest(chestMc) : null, false, sign, item);
|
||||
shop.sell(player);
|
||||
}
|
||||
|
||||
public static ChestObject getChest(Chest mc) {
|
||||
return (useOldChest ? new OldMCchest(mc) : new MinecraftChest(mc));
|
||||
}
|
||||
}
|
||||
|
@ -30,17 +30,17 @@ public class restrictedSign {
|
||||
|
||||
}
|
||||
|
||||
public static boolean canDestroy(Player p, Sign sign){
|
||||
public static boolean canDestroy(Player p, Sign sign) {
|
||||
Sign shopSign = getAssociatedSign(sign);
|
||||
return uSign.canAccess(p, shopSign);
|
||||
}
|
||||
|
||||
public static Sign getAssociatedSign(Sign restricted){
|
||||
|
||||
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){
|
||||
|
||||
public static boolean hasPermission(Player p, String[] lines) {
|
||||
if (Permission.has(p, Permission.ADMIN)) return true;
|
||||
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
|
@ -26,7 +26,7 @@ public class JavaWorkaround {
|
||||
elements.add(ChestShopFlag.flag);
|
||||
return elements;
|
||||
}
|
||||
|
||||
|
||||
public static void injectHax() {
|
||||
try {
|
||||
Field field = DefaultFlag.class.getDeclaredField("flagsList");
|
||||
|
@ -28,9 +28,9 @@ public class uBlock {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void blockUpdate(Block block){
|
||||
for (BlockFace bf : shopFaces){
|
||||
|
||||
public static void blockUpdate(Block block) {
|
||||
for (BlockFace bf : shopFaces) {
|
||||
block.getRelative(bf).getState().update(true);
|
||||
}
|
||||
}
|
||||
@ -54,7 +54,7 @@ public class uBlock {
|
||||
}
|
||||
|
||||
//Well, I need to re-write this plugin... I hate to code like that - sorry!
|
||||
public static Sign findSign2(Block block){
|
||||
public static Sign findSign2(Block block) {
|
||||
for (BlockFace bf : shopFaces) {
|
||||
Block faceBlock = block.getRelative(bf);
|
||||
if (uSign.isSign(faceBlock)) {
|
||||
|
@ -10,32 +10,39 @@ import java.util.Map;
|
||||
* @author Acrobot
|
||||
*/
|
||||
public class uEnchantment {
|
||||
public static String getEnchantment(ItemStack item){
|
||||
public static String getEnchantment(ItemStack item) {
|
||||
return encodeEnchantment(item.getEnchantments());
|
||||
}
|
||||
|
||||
public static String encodeEnchantment(Map<Enchantment, Integer> map){
|
||||
|
||||
public static String encodeEnchantment(Map<Enchantment, Integer> map) {
|
||||
int integer = 0;
|
||||
for (Map.Entry<Enchantment, Integer> entry : map.entrySet()){
|
||||
for (Map.Entry<Enchantment, Integer> entry : map.entrySet()) {
|
||||
integer = integer * 1000 + (entry.getKey().getId()) * 10 + entry.getValue();
|
||||
}
|
||||
return (integer != 0 ? Integer.toString(integer, 32) : null);
|
||||
|
||||
if (integer == 0) return null;
|
||||
|
||||
return Integer.toString(integer, 32);
|
||||
}
|
||||
|
||||
public static Map<Enchantment, Integer> decodeEnchantment(String base32){
|
||||
|
||||
public static Map<Enchantment, Integer> decodeEnchantment(String base32) {
|
||||
if (base32 == null) return new HashMap<Enchantment, Integer>();
|
||||
Map<Enchantment, Integer> map = new HashMap<Enchantment, Integer>();
|
||||
|
||||
String integer = String.valueOf(Integer.parseInt(base32, 32));
|
||||
if (integer.length() < 3) integer = '0' + integer;
|
||||
|
||||
for (int i = 0; i < (integer.length() / 3); i++){
|
||||
for (int i = 0; i < integer.length() / 3; i++) {
|
||||
String item = integer.substring(i * 3, i * 3 + 3);
|
||||
|
||||
Enchantment ench = Enchantment.getById(Integer.parseInt(item.substring(0, 2)));
|
||||
|
||||
if (ench == null) continue;
|
||||
int level = Integer.parseInt(item.substring(2));
|
||||
if (ench.getMaxLevel() < level || level < ench.getStartLevel()) continue;
|
||||
map.put(ench, level);
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ public class uHeroes {
|
||||
|
||||
public static void addHeroExp(Player p) {
|
||||
if (heroes != null) {
|
||||
Hero hero = heroes.getHeroManager().getHero(p);
|
||||
Hero hero = heroes.getCharacterManager().getHero(p);
|
||||
if (hero.hasParty()) {
|
||||
hero.getParty().gainExp(Config.getDouble(Property.HEROES_EXP), HeroClass.ExperienceType.EXTERNAL, p.getLocation());
|
||||
} else {
|
||||
|
@ -4,6 +4,7 @@ import com.Acrobot.ChestShop.Config.Config;
|
||||
import com.Acrobot.ChestShop.Config.Property;
|
||||
import com.palmergames.bukkit.towny.NotRegisteredException;
|
||||
import com.palmergames.bukkit.towny.object.TownBlockType;
|
||||
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -26,7 +27,7 @@ public class uTowny {
|
||||
return isInWilderness(chestLocation.getBlock()) || isInWilderness(signLocation.getBlock());
|
||||
}
|
||||
|
||||
private static boolean isInWilderness(Block block){
|
||||
private static boolean isInWilderness(Block block) {
|
||||
return uSign.towny.getTownyUniverse().isWilderness(block);
|
||||
}
|
||||
|
||||
@ -35,12 +36,18 @@ 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()));
|
||||
} catch (NotRegisteredException ex) { return false; }
|
||||
try {
|
||||
return uSign.towny.getTownyUniverse().getTownBlock(location).isOwner(TownyUniverse.getDataSource().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; }
|
||||
|
||||
private static boolean isResident(Player p, Location l) {
|
||||
try {
|
||||
return uSign.towny.getTownyUniverse().getTownBlock(l).getTown().hasResident(p.getName());
|
||||
} catch (NotRegisteredException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,11 @@
|
||||
package com.nijikokun.register.payment.forChestShop.methods;
|
||||
|
||||
import com.nijikokun.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;
|
||||
|
||||
/**
|
||||
@ -18,10 +16,10 @@ import org.bukkit.plugin.Plugin;
|
||||
* @license AOL license <http://aol.nexua.org>
|
||||
*/
|
||||
public class iCo5 implements Method {
|
||||
private iConomy iConomy;
|
||||
private iConomy iconomy;
|
||||
|
||||
public iConomy getPlugin() {
|
||||
return this.iConomy;
|
||||
return this.iconomy;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@ -31,9 +29,9 @@ public class iCo5 implements Method {
|
||||
public String getVersion() {
|
||||
return "5";
|
||||
}
|
||||
|
||||
|
||||
public int fractionalDigits() {
|
||||
return 2;
|
||||
return 2;
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
@ -62,10 +60,10 @@ public class iCo5 implements Method {
|
||||
}
|
||||
|
||||
public boolean createAccount(String name, double balance) {
|
||||
if(hasAccount(name))
|
||||
if (hasAccount(name))
|
||||
return false;
|
||||
|
||||
if(!com.iConomy.iConomy.Accounts.create(name))
|
||||
|
||||
if (!com.iConomy.iConomy.Accounts.create(name))
|
||||
return false;
|
||||
|
||||
getAccount(name).set(balance);
|
||||
@ -82,13 +80,13 @@ public class iCo5 implements Method {
|
||||
}
|
||||
|
||||
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) {
|
||||
iConomy = (iConomy)plugin;
|
||||
iconomy = (iConomy) plugin;
|
||||
}
|
||||
|
||||
public static class iCoAccount implements MethodAccount {
|
||||
@ -109,31 +107,31 @@ public class iCo5 implements Method {
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.set(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.add(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.subtract(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.multiply(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.divide(amount);
|
||||
return true;
|
||||
}
|
||||
@ -155,7 +153,7 @@ public class iCo5 implements Method {
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
if(this.account == null) return false;
|
||||
if (this.account == null) return false;
|
||||
this.account.remove();
|
||||
return true;
|
||||
}
|
||||
@ -187,31 +185,31 @@ public class iCo5 implements Method {
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.set(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.add(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.subtract(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.multiply(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
if (this.holdings == null) return false;
|
||||
this.holdings.divide(amount);
|
||||
return true;
|
||||
}
|
||||
@ -233,7 +231,7 @@ public class iCo5 implements Method {
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
if(this.account == null) return false;
|
||||
if (this.account == null) return false;
|
||||
this.account.remove();
|
||||
return true;
|
||||
}
|
||||
|
@ -2,7 +2,10 @@ name: ChestShop
|
||||
|
||||
main: com.Acrobot.ChestShop.ChestShop
|
||||
|
||||
version: 3.38
|
||||
version: 3.39
|
||||
|
||||
#for CButD
|
||||
dev-url: http://dev.bukkit.org/server-mods/chestshop/
|
||||
|
||||
|
||||
author: Acrobot
|
||||
@ -11,7 +14,7 @@ description: >
|
||||
|
||||
|
||||
softdepend: [LWC, Lockette, Deadbolt, OddItem, Towny, WorldGuard, Vault, Heroes,
|
||||
iConomy, BOSEconomy, Essentials, 3co, MultiCurrency, Currency, SimpleChestLock]
|
||||
iConomy, BOSEconomy, Essentials, SimpleChestLock]
|
||||
commands:
|
||||
iteminfo:
|
||||
aliases: [iinfo]
|
||||
|
Loading…
Reference in New Issue
Block a user