mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-09-24 20:42:46 +02: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 {
|
||||
|
@ -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);
|
||||
@ -95,13 +99,21 @@ public class ChestShop extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////// 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);
|
||||
}
|
||||
|
||||
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);
|
||||
return uBlock.findNeighbor(chest);
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
@ -58,7 +58,6 @@ public class ItemInfo implements CommandExecutor {
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static String joinArray(String[] array) {
|
||||
StringBuilder b = new StringBuilder(array.length);
|
||||
for (String s : array) b.append(s).append(' ');
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.nijikokun.register.payment.forChestShop.Method;
|
||||
*/
|
||||
public class Register implements EcoPlugin {
|
||||
public static Method eco;
|
||||
|
||||
public boolean hasAccount(String player) {
|
||||
return eco.hasAccount(player);
|
||||
}
|
||||
|
@ -38,7 +38,9 @@ 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());
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
@ -47,6 +47,12 @@ public class Items {
|
||||
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;
|
||||
|
@ -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,6 +53,7 @@ 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) {
|
||||
|
@ -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;
|
||||
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
@ -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));
|
||||
|
@ -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 {
|
||||
|
||||
@ -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();
|
||||
}
|
||||
@ -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() {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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];
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,10 @@ public class uEnchantment {
|
||||
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) {
|
||||
@ -27,15 +30,19 @@ public class uEnchantment {
|
||||
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;
|
||||
@ -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; }
|
||||
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() {
|
||||
@ -88,7 +86,7 @@ public class iCo5 implements Method {
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
iConomy = (iConomy)plugin;
|
||||
iconomy = (iConomy) plugin;
|
||||
}
|
||||
|
||||
public static class iCoAccount implements MethodAccount {
|
||||
|
@ -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