Switched from ugly statics to objects

This commit is contained in:
Acrobot 2012-04-19 15:50:53 +02:00
parent fc475ff543
commit e4e7329063
4 changed files with 22 additions and 9 deletions

View File

@ -6,7 +6,11 @@ import com.nijikokun.register.payment.forChestShop.Method;
* @author Acrobot * @author Acrobot
*/ */
public class Register implements EcoPlugin { public class Register implements EcoPlugin {
public static Method eco; public Method eco;
public Register(Method eco) {
this.eco = eco;
}
public boolean hasAccount(String player) { public boolean hasAccount(String player) {
return eco.hasAccount(player); return eco.hasAccount(player);

View File

@ -11,12 +11,12 @@ import org.bukkit.entity.Player;
* @author Acrobot * @author Acrobot
*/ */
public class LWCplugin implements Protection { public class LWCplugin implements Protection {
public static LWC lwc; public LWC lwc;
private static LimitsModule limitsModule; private LimitsModule limitsModule;
public static void setLWC(LWC LWC) { public LWCplugin(LWC lwc) {
lwc = LWC; this.lwc = lwc;
limitsModule = new LimitsModule(); limitsModule = new LimitsModule();
} }

View File

@ -1,6 +1,7 @@
package com.Acrobot.ChestShop.Protection.Plugins; package com.Acrobot.ChestShop.Protection.Plugins;
import com.Acrobot.ChestShop.Protection.Protection; import com.Acrobot.ChestShop.Protection.Protection;
import com.Acrobot.ChestShop.Utils.uLongName;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.yi.acru.bukkit.Lockette.Lockette; import org.yi.acru.bukkit.Lockette.Lockette;
@ -9,7 +10,11 @@ import org.yi.acru.bukkit.Lockette.Lockette;
* @author Acrobot * @author Acrobot
*/ */
public class LockettePlugin implements Protection { public class LockettePlugin implements Protection {
public static Lockette lockette; public Lockette lockette;
public LockettePlugin(Lockette lockette) {
this.lockette = lockette;
}
public boolean isProtected(Block block) { public boolean isProtected(Block block) {
return Lockette.isProtected(block); return Lockette.isProtected(block);
@ -17,9 +22,9 @@ public class LockettePlugin implements Protection {
public boolean canAccess(Player player, Block block) { public boolean canAccess(Player player, Block block) {
String pName = player.getName(); String pName = player.getName();
int length = (pName.length() > 15 ? 15 : pName.length());
String owner = Lockette.getProtectedOwner(block); String owner = Lockette.getProtectedOwner(block);
return owner == null || pName.substring(0, length).equals(owner); return owner == null || owner.equals(uLongName.stripName(pName));
} }
public boolean protect(String name, Block block) { public boolean protect(String name, Block block) {

View File

@ -9,7 +9,11 @@ import org.bukkit.entity.Player;
* @author Acrobot * @author Acrobot
*/ */
public class SCLplugin implements Protection { public class SCLplugin implements Protection {
public static SCL scl; public SCL scl;
public SCLplugin(SCL scl) {
this.scl = scl;
}
public boolean isProtected(Block block) { public boolean isProtected(Block block) {
return scl.chests.isLocked(block); return scl.chests.isLocked(block);