mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-11-27 04:25:14 +01:00
Wow, that is ugly now :/
- Added WorldGuard support - Fixed protection - Added shop refund price - Updated Register
This commit is contained in:
parent
9a6b9d0c38
commit
637e08e985
@ -1,6 +1,6 @@
|
||||
package com.Acrobot.ChestShop.Config;
|
||||
|
||||
import com.nijikokun.register.forChestShop.payment.Methods;
|
||||
import com.nijikokun.register.payment.forChestShop.Methods;
|
||||
|
||||
/**
|
||||
* @author Acrobot
|
||||
|
@ -26,7 +26,9 @@ 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?"),
|
||||
TAX_AMOUNT(0, "Percent of the price that should go to the server's account. (100 = 100 percent)");
|
||||
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?");
|
||||
|
||||
|
||||
private final Object value;
|
||||
|
@ -3,7 +3,7 @@ package com.Acrobot.ChestShop;
|
||||
import com.Acrobot.ChestShop.Config.Config;
|
||||
import com.Acrobot.ChestShop.Config.Property;
|
||||
import com.Acrobot.ChestShop.Utils.uLongName;
|
||||
import com.nijikokun.register.forChestShop.payment.Method;
|
||||
import com.nijikokun.register.payment.forChestShop.Method;
|
||||
|
||||
/**
|
||||
* @author Acrobot
|
||||
|
@ -1,9 +1,13 @@
|
||||
package com.Acrobot.ChestShop.Listeners;
|
||||
|
||||
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.Utils.uBlock;
|
||||
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,6 +18,9 @@ import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.material.PistonBaseMaterial;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Acrobot
|
||||
*/
|
||||
@ -26,6 +33,7 @@ public class blockBreak extends BlockListener {
|
||||
if (isCorrectSign(sign, block)) return true;
|
||||
|
||||
sign = uBlock.findSign(block);
|
||||
if (Config.getFloat(Property.SHOP_REFUND_PRICE) != 0F && isCorrectSign(sign, block) && !playerIsNotOwner(player, sign)) Economy.add(uLongName.getName(sign.getLine(0)), Config.getFloat(Property.SHOP_REFUND_PRICE));
|
||||
return isCorrectSign(sign, block) && playerIsNotOwner(player, sign);
|
||||
}
|
||||
|
||||
@ -34,10 +42,10 @@ public class blockBreak extends BlockListener {
|
||||
}
|
||||
|
||||
private static boolean isCorrectSign(Sign sign, Block block) {
|
||||
return sign != null && (sign.getBlock() == block || getAttachedFace(sign) == block);
|
||||
return sign != null && (sign.getBlock().equals(block) || getAttachedFace(sign).equals(block));
|
||||
}
|
||||
|
||||
private static Block getAttachedFace(Sign sign) {
|
||||
public static Block getAttachedFace(Sign sign) {
|
||||
return sign.getBlock().getRelative(((org.bukkit.material.Sign) sign.getData()).getAttachedFace());
|
||||
}
|
||||
|
||||
@ -46,7 +54,7 @@ public class blockBreak extends BlockListener {
|
||||
}
|
||||
|
||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||
for (Block b : event.getBlocks()) {
|
||||
for (Block b : getExtendBlocks(event)) {
|
||||
if (cancellingBlockBreak(b, null)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -72,4 +80,18 @@ public class blockBreak extends BlockListener {
|
||||
BlockFace pistonDirection = getPistonDirection(event.getBlock());
|
||||
return pistonDirection != null ? event.getBlock().getRelative((pistonDirection), 2).getLocation().getBlock() : null;
|
||||
}
|
||||
|
||||
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++){
|
||||
Block block = piston.getRelative(pistonDirection, b);
|
||||
Material blockType = block.getType();
|
||||
if (blockType == Material.AIR) break;
|
||||
list.add(block);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ public class playerInteract extends PlayerListener {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (restrictedSign.isRestrictedShop(sign) && !restrictedSign.canAccess(sign, player)) {
|
||||
player.sendMessage(Config.getLocal(Language.ACCESS_DENIED));
|
||||
return;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.Acrobot.ChestShop.Listeners;
|
||||
|
||||
import com.Acrobot.ChestShop.Economy;
|
||||
import com.nijikokun.register.forChestShop.payment.Methods;
|
||||
import com.nijikokun.register.payment.forChestShop.Methods;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
|
||||
|
@ -10,11 +10,13 @@ import com.Acrobot.ChestShop.Protection.Plugins.LockettePlugin;
|
||||
import com.Acrobot.ChestShop.Protection.Security;
|
||||
import com.Acrobot.ChestShop.Utils.uNumber;
|
||||
import com.Acrobot.ChestShop.Utils.uSign;
|
||||
import com.Acrobot.ChestShop.Utils.uWorldGuard;
|
||||
import com.daemitus.deadbolt.Deadbolt;
|
||||
import com.griefcraft.lwc.LWCPlugin;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
import com.nijikokun.register.forChestShop.payment.Methods;
|
||||
import com.nijikokun.register.payment.forChestShop.Methods;
|
||||
import com.palmergames.bukkit.towny.Towny;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -67,6 +69,9 @@ public class pluginEnable extends ServerListener {
|
||||
for (int i = 0; i < 4; i++) if (split.length >= i + 1 && uNumber.isInteger(split[i])) versionNumber += (Math.pow(10, (3 - i) << 1) * Integer.parseInt(split[i])); //EPIC CODE RIGHT HERE
|
||||
if (versionNumber < 760047) { System.out.println(generateOutdatedVersion(name, plugin.getDescription().getVersion(), "0.76.0.47")); return; }
|
||||
uSign.towny = (Towny) plugin;
|
||||
} else if (name.equals("WorldGuard")) {
|
||||
if (uWorldGuard.worldGuard != null) return;
|
||||
uWorldGuard.worldGuard = (WorldGuardPlugin) plugin;
|
||||
}
|
||||
PluginDescriptionFile description = plugin.getDescription();
|
||||
System.out.println(ChestShop.chatPrefix + description.getName() + " version " + description.getVersion() + " loaded.");
|
||||
|
@ -82,7 +82,7 @@ public class signChange extends BlockListener {
|
||||
dropSign(event);
|
||||
return;
|
||||
} else if (!playerIsAdmin) {
|
||||
if (!Security.canPlaceSign(player, signBlock)) {
|
||||
if (!Security.canPlaceSign(player, (Sign) signBlock.getState())) {
|
||||
player.sendMessage(Config.getLocal(Language.ANOTHER_SHOP_DETECTED));
|
||||
dropSign(event);
|
||||
return;
|
||||
@ -90,7 +90,7 @@ public class signChange extends BlockListener {
|
||||
|
||||
Block chestBlock = chest.getBlock();
|
||||
|
||||
if (uSign.towny != null && !uTowny.canBuild(player, signBlock.getLocation(), chestBlock.getLocation())) {
|
||||
if (!uWorldGuard.isNotOutsideWGplot(signBlock.getLocation()) || (uSign.towny != null && !uTowny.canBuild(player, signBlock.getLocation(), chestBlock.getLocation()))) {
|
||||
player.sendMessage(Config.getLocal(Language.TOWNY_CANNOT_CREATE_SHOP_HERE));
|
||||
dropSign(event);
|
||||
return;
|
||||
@ -150,6 +150,7 @@ public class signChange extends BlockListener {
|
||||
if (uNumber.isFloat(split[0])) thirdLine = "B " + thirdLine;
|
||||
if (split.length == 2 && uNumber.isFloat(split[1])) thirdLine = thirdLine + " S";
|
||||
if (thirdLine.length() > 15) thirdLine = thirdLine.replace(" ", "");
|
||||
thirdLine = thirdLine.toUpperCase();
|
||||
|
||||
return (thirdLine.length() > 15 ? null : thirdLine);
|
||||
}
|
||||
@ -163,8 +164,9 @@ public class signChange extends BlockListener {
|
||||
if (materialLine.length() > maxLength) materialLine = materialLine.substring(0, maxLength);
|
||||
materialLine = materialLine + ':' + split[1];
|
||||
}
|
||||
return materialLine;
|
||||
fourthLine = materialLine;
|
||||
}
|
||||
fourthLine = fourthLine.replace("_", " ");
|
||||
return fourthLine;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class MaskChest implements Runnable {
|
||||
Block block = world.getBlockAt(x + pX, y + pY, z + pZ);
|
||||
|
||||
if (block.getType() == Material.CHEST) {
|
||||
if (uBlock.findSign(block) != null) {
|
||||
if (uBlock.findSign2(block) != null) {
|
||||
Chest neighbor = uBlock.findNeighbor(block);
|
||||
Material nMat = returnNearestMat(block);
|
||||
if (neighbor != null) {
|
||||
|
@ -14,20 +14,20 @@ import org.bukkit.entity.Player;
|
||||
public class Default implements Protection {
|
||||
public boolean isProtected(Block block) {
|
||||
if (!(block.getState() instanceof Chest)) return false;
|
||||
if (uBlock.findSign(block) != null) return true;
|
||||
if (uBlock.findSign2(block) != null) return true;
|
||||
|
||||
Chest neighbor = uBlock.findNeighbor(block);
|
||||
return neighbor != null && uBlock.findSign(neighbor.getBlock()) != null;
|
||||
return neighbor != null && uBlock.findSign2(neighbor.getBlock()) != null;
|
||||
}
|
||||
|
||||
public boolean canAccess(Player player, Block block) {
|
||||
String playerName = player.getName();
|
||||
|
||||
Sign sign = uBlock.findSign(block);
|
||||
Sign sign = uBlock.findSign2(block);
|
||||
if (sign != null) return uLongName.stripName(playerName).equals(sign.getLine(0));
|
||||
|
||||
Chest neighborChest = uBlock.findNeighbor(block);
|
||||
Sign neighborSign = (neighborChest != null ? uBlock.findSign(neighborChest.getBlock()) : null);
|
||||
Sign neighborSign = (neighborChest != null ? uBlock.findSign2(neighborChest.getBlock()) : null);
|
||||
|
||||
return neighborSign != null && uLongName.stripName(playerName).equals(neighborSign.getLine(0));
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package com.Acrobot.ChestShop.Protection;
|
||||
|
||||
import com.Acrobot.ChestShop.Listeners.blockBreak;
|
||||
import com.Acrobot.ChestShop.Protection.Plugins.Default;
|
||||
import com.Acrobot.ChestShop.Utils.uBlock;
|
||||
import com.Acrobot.ChestShop.Utils.uLongName;
|
||||
import com.Acrobot.ChestShop.Utils.uSign;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -11,6 +13,7 @@ import org.bukkit.entity.Player;
|
||||
* @author Acrobot
|
||||
*/
|
||||
public class Security {
|
||||
private static BlockFace[] faces = {BlockFace.UP, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH};
|
||||
public static Protection protection = new Default();
|
||||
|
||||
public static boolean protect(String name, Block block) {
|
||||
@ -25,10 +28,16 @@ public class Security {
|
||||
return protection.isProtected(block);
|
||||
}
|
||||
|
||||
public static boolean canPlaceSign(Player p, Block block) {
|
||||
Sign sign = uBlock.findSign(uBlock.findChest(block).getBlock());
|
||||
if (sign == null) sign = uBlock.findSign(block);
|
||||
public static boolean canPlaceSign(Player p, Sign sign) {
|
||||
Block block = blockBreak.getAttachedFace(sign);
|
||||
return !thereIsAnotherSignByPlayer(block, sign.getBlock(), uLongName.stripName(p.getName()));
|
||||
}
|
||||
|
||||
return (sign == null || sign.getLine(0).equals(uLongName.stripName(p.getName())));
|
||||
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;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.Acrobot.ChestShop.Utils;
|
||||
|
||||
import com.Acrobot.ChestShop.Listeners.blockBreak;
|
||||
import com.Acrobot.ChestShop.Signs.restrictedSign;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -29,6 +30,18 @@ public class uBlock {
|
||||
}
|
||||
|
||||
public static Sign findSign(Block block) {
|
||||
for (BlockFace bf : shopFaces) {
|
||||
Block faceBlock = block.getRelative(bf);
|
||||
if (uSign.isSign(faceBlock)) {
|
||||
Sign sign = (Sign) faceBlock.getState();
|
||||
if (uSign.isValid(sign) && (faceBlock.equals(block) || blockBreak.getAttachedFace(sign).equals(block))) return sign;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//Well, I need to re-write this plugin... I hate to code like that - sorry!
|
||||
public static Sign findSign2(Block block){
|
||||
for (BlockFace bf : shopFaces) {
|
||||
Block faceBlock = block.getRelative(bf);
|
||||
if (uSign.isSign(faceBlock)) {
|
||||
@ -44,7 +57,7 @@ public class uBlock {
|
||||
Block faceBlock = block.getRelative(bf);
|
||||
if (uSign.isSign(faceBlock)) {
|
||||
Sign sign = (Sign) faceBlock.getState();
|
||||
if (restrictedSign.isRestricted(sign)) return sign;
|
||||
if (restrictedSign.isRestricted(sign) && (faceBlock.equals(block) || blockBreak.getAttachedFace(sign).equals(block))) return sign;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -12,8 +12,6 @@ import org.bukkit.entity.Player;
|
||||
* @author Acrobot
|
||||
*/
|
||||
public class uTowny {
|
||||
|
||||
|
||||
public static boolean isInsideShopPlot(Location chestlocation, Location signLocation) {
|
||||
return uSign.towny.getTownyUniverse().getTownBlock(chestlocation).getType() == TownBlockType.COMMERCIAL && uSign.towny.getTownyUniverse().getTownBlock(signLocation).getType() == TownBlockType.COMMERCIAL;
|
||||
}
|
||||
@ -27,7 +25,6 @@ public class uTowny {
|
||||
}
|
||||
|
||||
public static boolean canBuild(Player player, Location chestLocation, Location signLocation) {
|
||||
System.out.println(isNotInTheWilderness(chestLocation, signLocation));
|
||||
return uSign.towny == null || !Config.getBoolean(Property.TOWNY_INTEGRATION) || (isNotInTheWilderness(chestLocation, signLocation) && isInsideShopPlot(chestLocation, signLocation) && isPlotOwner(player, chestLocation, signLocation));
|
||||
}
|
||||
|
||||
|
18
com/Acrobot/ChestShop/Utils/uWorldGuard.java
Normal file
18
com/Acrobot/ChestShop/Utils/uWorldGuard.java
Normal file
@ -0,0 +1,18 @@
|
||||
package com.Acrobot.ChestShop.Utils;
|
||||
|
||||
import com.Acrobot.ChestShop.Config.Config;
|
||||
import com.Acrobot.ChestShop.Config.Property;
|
||||
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import org.bukkit.Location;
|
||||
|
||||
/**
|
||||
* @author Acrobot
|
||||
*/
|
||||
public class uWorldGuard {
|
||||
public static WorldGuardPlugin worldGuard;
|
||||
|
||||
public static boolean isNotOutsideWGplot(Location l2) {
|
||||
return worldGuard == null || !Config.getBoolean(Property.WORLDGUARD_INTEGRATION) || worldGuard.getGlobalRegionManager().get(l2.getWorld()).getApplicableRegions(BukkitUtil.toVector(l2)).size() != 0;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.nijikokun.register.forChestShop.payment;
|
||||
package com.nijikokun.register.payment.forChestShop;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
@ -103,7 +103,7 @@ public interface Method {
|
||||
* @param balance Initial account balance
|
||||
* @return <code>boolean</code>
|
||||
*/
|
||||
public boolean createAccount(String name, Double balance);
|
||||
public boolean createAccount(String name, double balance);
|
||||
|
||||
/**
|
||||
* Returns a <code>MethodAccount</code> class for an account <code>name</code>.
|
@ -1,20 +1,20 @@
|
||||
package com.nijikokun.register.forChestShop.payment;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
package com.nijikokun.register.payment.forChestShop;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* The <code>Methods</code> initializes Methods that utilize the Method interface
|
||||
* based on a "first come, first served" basis.
|
||||
*
|
||||
* <p/>
|
||||
* Allowing you to check whether a payment method exists or not.
|
||||
*
|
||||
* <p/>
|
||||
* Methods also allows you to set a preferred method of payment before it captures
|
||||
* payment plugins in the initialization process.
|
||||
*
|
||||
* <p/>
|
||||
* in <code>bukkit.yml</code>:
|
||||
* <blockquote><pre>
|
||||
* economy:
|
||||
@ -42,13 +42,14 @@ public class Methods {
|
||||
* Implement all methods along with their respective name & class.
|
||||
*/
|
||||
private static void _init() {
|
||||
addMethod("iConomy", new com.nijikokun.register.forChestShop.payment.methods.iCo6());
|
||||
addMethod("iConomy", new com.nijikokun.register.forChestShop.payment.methods.iCo5());
|
||||
addMethod("iConomy", new com.nijikokun.register.forChestShop.payment.methods.iCo4());
|
||||
addMethod("BOSEconomy", new com.nijikokun.register.forChestShop.payment.methods.BOSE6());
|
||||
addMethod("BOSEconomy", new com.nijikokun.register.forChestShop.payment.methods.BOSE7());
|
||||
addMethod("Essentials", new com.nijikokun.register.forChestShop.payment.methods.EE17());
|
||||
addMethod("Currency", new com.nijikokun.register.forChestShop.payment.methods.MCUR());
|
||||
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());
|
||||
addMethod("BOSEconomy", new com.nijikokun.register.payment.forChestShop.methods.BOSE6());
|
||||
addMethod("BOSEconomy", new com.nijikokun.register.payment.forChestShop.methods.BOSE7());
|
||||
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");
|
||||
}
|
||||
|
||||
@ -74,6 +75,7 @@ public class Methods {
|
||||
|
||||
/**
|
||||
* Use to get version of Register plugin
|
||||
*
|
||||
* @return version
|
||||
*/
|
||||
public static String getVersion() {
|
||||
@ -85,7 +87,7 @@ public class Methods {
|
||||
* through the <code>_init</code> method.
|
||||
*
|
||||
* @return <code>Set<String></code> - Array of payment methods that are loaded.
|
||||
* @see #setMethod(org.bukkit.plugin.Plugin)
|
||||
* @see #setMethod(org.bukkit.plugin.PluginManager)
|
||||
*/
|
||||
public static Set<String> getDependencies() {
|
||||
return Dependencies;
|
||||
@ -117,7 +119,7 @@ public class Methods {
|
||||
* Verifies if Register has set a payment method for usage yet.
|
||||
*
|
||||
* @return <code>boolean</code>
|
||||
* @see #setMethod(org.bukkit.plugin.Plugin)
|
||||
* @see #setMethod(org.bukkit.plugin.PluginManager)
|
||||
* @see #checkDisabled(org.bukkit.plugin.Plugin)
|
||||
*/
|
||||
public static boolean hasMethod() {
|
||||
@ -128,7 +130,7 @@ public class Methods {
|
||||
* Checks Plugin Class against a multitude of checks to verify it's usability
|
||||
* as a payment method.
|
||||
*
|
||||
* @param <code>PluginManager</code> the plugin manager for the server
|
||||
* @param manager the plugin manager for the server
|
||||
* @return <code>boolean</code> True on success, False on failure.
|
||||
*/
|
||||
public static boolean setMethod(PluginManager manager) {
|
||||
@ -168,8 +170,7 @@ public class Methods {
|
||||
match = true;
|
||||
else {
|
||||
for (Method attached : Attachables) {
|
||||
if (attached == null)
|
||||
continue;
|
||||
if (attached == null) continue;
|
||||
|
||||
if (hasMethod()) {
|
||||
match = true; break;
|
||||
@ -178,13 +179,12 @@ public class Methods {
|
||||
if (preferred.isEmpty())
|
||||
Method = attached;
|
||||
|
||||
if (count == 0)
|
||||
if (preferred.equalsIgnoreCase(attached.getName()))
|
||||
Method = attached;
|
||||
|
||||
else
|
||||
if (count == 0) {
|
||||
if (preferred.equalsIgnoreCase(attached.getName())) Method = attached;
|
||||
} else {
|
||||
Method = attached;
|
||||
}
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
@ -197,6 +197,7 @@ public class Methods {
|
||||
/**
|
||||
* Sets the preferred economy
|
||||
*
|
||||
* @param check The plugin name to check
|
||||
* @return <code>boolean</code>
|
||||
*/
|
||||
public static boolean setPreferred(String check) {
|
@ -1,6 +1,6 @@
|
||||
package com.nijikokun.register.forChestShop.payment.methods;
|
||||
package com.nijikokun.register.payment.forChestShop.methods;
|
||||
|
||||
import com.nijikokun.register.forChestShop.payment.Method;
|
||||
import com.nijikokun.register.payment.forChestShop.Method;
|
||||
|
||||
import cosine.boseconomy.BOSEconomy;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -66,7 +66,7 @@ public class BOSE6 implements Method {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean createAccount(String name, Double balance) {
|
||||
public boolean createAccount(String name, double balance) {
|
||||
if(hasAccount(name))
|
||||
return false;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.nijikokun.register.forChestShop.payment.methods;
|
||||
package com.nijikokun.register.payment.forChestShop.methods;
|
||||
|
||||
import com.nijikokun.register.forChestShop.payment.Method;
|
||||
import com.nijikokun.register.payment.forChestShop.Method;
|
||||
|
||||
import cosine.boseconomy.BOSEconomy;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -65,7 +65,7 @@ public class BOSE7 implements Method {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean createAccount(String name, Double balance) {
|
||||
public boolean createAccount(String name, double balance) {
|
||||
if(hasAccount(name))
|
||||
return false;
|
||||
|
137
com/nijikokun/register/payment/forChestShop/methods/ECO3.java
Normal file
137
com/nijikokun/register/payment/forChestShop/methods/ECO3.java
Normal file
@ -0,0 +1,137 @@
|
||||
package com.nijikokun.register.payment.forChestShop.methods;
|
||||
|
||||
import com.nijikokun.register.payment.forChestShop.Method;
|
||||
import me.ic3d.eco.ECO;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* 3co implementation of Method.
|
||||
*
|
||||
* @copyright (c) 2011
|
||||
* @license AOL license <http://aol.nexua.org>
|
||||
*/
|
||||
public class ECO3 implements Method {
|
||||
private ECO eco;
|
||||
|
||||
public Object getPlugin() {
|
||||
return this.eco;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "3co";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "2.0";
|
||||
}
|
||||
|
||||
public int fractionalDigits() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
return (int) Math.ceil(amount) + " " + (amount == 1 ? eco.singularCurrency : eco.pluralCurrency);
|
||||
}
|
||||
|
||||
public boolean hasBanks() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return eco.hasAccount(name);
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean createAccount(String name) {
|
||||
if (hasAccount(name)) return false;
|
||||
eco.createAccount(name, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean createAccount(String name, double balance) {
|
||||
if (hasAccount(name)) return false;
|
||||
eco.createAccount(name, (int) balance);
|
||||
return true;
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
if (!hasAccount(name)) createAccount(name); //Still somehow fails - it's 3co's issue
|
||||
return new ECO3Account(name);
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
return plugin.getDescription().getName().equals("3co") && plugin.getClass().getName().equals("me.ic3d.eco.ECO") && plugin instanceof ECO;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
this.eco = (ECO) plugin;
|
||||
}
|
||||
|
||||
public class ECO3Account implements MethodAccount {
|
||||
private String name;
|
||||
|
||||
public ECO3Account(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return eco.getMoney(name);
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
eco.setMoney(name, (int) Math.ceil(amount));
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
set(balance() + amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
set(balance() - amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
set(balance() * amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
set(balance() / amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return eco.hasEnough(name, (int) Math.ceil(amount));
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return balance() > amount;
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return balance() < amount;
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return balance() < 0;
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.nijikokun.register.forChestShop.payment.methods;
|
||||
package com.nijikokun.register.payment.forChestShop.methods;
|
||||
|
||||
import com.nijikokun.register.forChestShop.payment.Method;
|
||||
import com.nijikokun.register.payment.forChestShop.Method;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.api.Economy;
|
||||
|
||||
@ -63,7 +63,7 @@ public class EE17 implements Method {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean createAccount(String name, Double balance) {
|
||||
public boolean createAccount(String name, double balance) {
|
||||
if(hasAccount(name))
|
||||
return false;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.nijikokun.register.forChestShop.payment.methods;
|
||||
package com.nijikokun.register.payment.forChestShop.methods;
|
||||
|
||||
import com.nijikokun.register.forChestShop.payment.Method;
|
||||
import com.nijikokun.register.payment.forChestShop.Method;
|
||||
|
||||
import me.ashtheking.currency.Currency;
|
||||
import me.ashtheking.currency.CurrencyList;
|
||||
@ -58,7 +58,7 @@ public class MCUR implements Method {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean createAccount(String name, Double balance) {
|
||||
public boolean createAccount(String name, double balance) {
|
||||
CurrencyList.setValue((String) CurrencyList.maxCurrency(name)[0], name, balance);
|
||||
return true;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.nijikokun.register.forChestShop.payment.methods;
|
||||
package com.nijikokun.register.payment.forChestShop.methods;
|
||||
|
||||
import com.nijikokun.register.forChestShop.payment.Method;
|
||||
import com.nijikokun.register.payment.forChestShop.Method;
|
||||
import com.nijiko.coelho.iConomy.iConomy;
|
||||
import com.nijiko.coelho.iConomy.system.Account;
|
||||
|
||||
@ -66,7 +66,7 @@ public class iCo4 implements Method {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean createAccount(String name, Double balance) {
|
||||
public boolean createAccount(String name, double balance) {
|
||||
if(hasAccount(name))
|
||||
return false;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.nijikokun.register.forChestShop.payment.methods;
|
||||
package com.nijikokun.register.payment.forChestShop.methods;
|
||||
|
||||
import com.nijikokun.register.forChestShop.payment.Method;
|
||||
import com.nijikokun.register.payment.forChestShop.Method;
|
||||
import com.iConomy.iConomy;
|
||||
import com.iConomy.system.Account;
|
||||
import com.iConomy.system.BankAccount;
|
||||
@ -63,7 +63,7 @@ public class iCo5 implements Method {
|
||||
return com.iConomy.iConomy.Accounts.create(name);
|
||||
}
|
||||
|
||||
public boolean createAccount(String name, Double balance) {
|
||||
public boolean createAccount(String name, double balance) {
|
||||
if(hasAccount(name))
|
||||
return false;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.nijikokun.register.forChestShop.payment.methods;
|
||||
package com.nijikokun.register.payment.forChestShop.methods;
|
||||
|
||||
import com.nijikokun.register.forChestShop.payment.Method;
|
||||
import com.nijikokun.register.payment.forChestShop.Method;
|
||||
import com.iCo6.iConomy;
|
||||
import com.iCo6.system.Account;
|
||||
import com.iCo6.system.Accounts;
|
||||
@ -62,7 +62,7 @@ public class iCo6 implements Method {
|
||||
return (new Accounts()).create(name);
|
||||
}
|
||||
|
||||
public boolean createAccount(String name, Double balance) {
|
||||
public boolean createAccount(String name, double balance) {
|
||||
if(hasAccount(name))
|
||||
return false;
|
||||
|
@ -2,7 +2,7 @@ name: ChestShop
|
||||
|
||||
main: com.Acrobot.ChestShop.ChestShop
|
||||
|
||||
version: 3.22
|
||||
version: 3.23
|
||||
|
||||
|
||||
author: Acrobot
|
||||
@ -10,7 +10,7 @@ description: >
|
||||
A chest shop for economy plugins.
|
||||
|
||||
|
||||
softdepend: [Permissions, LWC, Lockette, Deadbolt, OddItem, Towny]
|
||||
softdepend: [Permissions, LWC, Lockette, Deadbolt, OddItem, Towny, WorldGuard]
|
||||
commands:
|
||||
iteminfo:
|
||||
aliases: [iinfo]
|
||||
|
Loading…
Reference in New Issue
Block a user