Skip to content

Commit

Permalink
- Fixed Permissions for shop creation
Browse files Browse the repository at this point in the history
- Added Moderator Permission (ChestShop.mod)
- Updated Register
  • Loading branch information
Acrobot committed Jul 1, 2011
1 parent 36f2584 commit e522b33
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 146 deletions.
6 changes: 3 additions & 3 deletions com/Acrobot/ChestShop/ChestShop.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ public void onEnable() {
pm.registerEvent(Event.Type.PLUGIN_ENABLE, pluginEnable, Event.Priority.Monitor, this);
pm.registerEvent(Event.Type.PLUGIN_DISABLE, pluginDisable, Event.Priority.Monitor, this);

desc = this.getDescription();
server = getServer();
mainWorldName = server.getWorlds().get(0).getName();
desc = this.getDescription(); //Description of the plugin
server = getServer(); //Setting out server variable
mainWorldName = server.getWorlds().get(0).getName(); //Set up our main world's name - currently not used

//Yep, set up our folder!
folder = getDataFolder();
Expand Down
2 changes: 1 addition & 1 deletion com/Acrobot/ChestShop/Listeners/playerInteract.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void onPlayerInteract(PlayerInteractEvent event) {

if (Config.getBoolean(Property.USE_BUILT_IN_PROTECTION) && block.getType() == Material.CHEST) {
Default defProtection = new Default();
if (!Permission.has(player, Permission.ADMIN) && (defProtection.isProtected(block) && !defProtection.canAccess(player, block))) {
if (!Permission.has(player, Permission.ADMIN) && !Permission.has(player, Permission.MOD) && (defProtection.isProtected(block) && !defProtection.canAccess(player, block))) {
player.sendMessage(Config.getLocal(Language.ACCESS_DENIED));
event.setCancelled(true);
return;
Expand Down
10 changes: 6 additions & 4 deletions com/Acrobot/ChestShop/Listeners/signChange.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import com.Acrobot.ChestShop.Protection.Default;
import com.Acrobot.ChestShop.Protection.Security;
import com.Acrobot.ChestShop.Restrictions.RestrictedSign;
import com.Acrobot.ChestShop.Utils.Numerical;
import com.Acrobot.ChestShop.Utils.BlockSearch;
import com.Acrobot.ChestShop.Utils.Numerical;
import com.Acrobot.ChestShop.Utils.SignUtil;
import org.bukkit.Material;
import org.bukkit.block.Block;
Expand Down Expand Up @@ -53,9 +53,11 @@ public void onSignChange(SignChangeEvent event) {
dropSign(event);
return;
}
if (!playerIsAdmin && !(Permission.has(player, Permission.SHOP_CREATION)
|| ((Permission.has(player, Permission.SHOP_CREATION + "." + mat.getId())
|| !Permission.has(player, Permission.EXCLUDE_ITEM + "." + mat.getId()))))) {
if (!(playerIsAdmin ||
Permission.has(player, Permission.SHOP_CREATION) ||
(Permission.has(player, Permission.SHOP_CREATION + "." + mat.getId()) &&
!Permission.has(player, Permission.EXCLUDE_ITEM + "." + mat.getId()))))
{

player.sendMessage(Config.getLocal(Language.YOU_CANNOT_CREATE_SHOP));
dropSign(event);
Expand Down
5 changes: 3 additions & 2 deletions com/Acrobot/ChestShop/Permission.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public enum Permission {
EXCLUDE_ITEM("ChestShop.shop.exclude"),
BUY("ChestShop.shop.buy"),
SELL("ChestShop.shop.sell"),
ADMIN("ChestShop.admin");
ADMIN("ChestShop.admin"),
MOD("ChestShop.mod");

private final String permission;

Expand All @@ -30,7 +31,7 @@ public static boolean has(Player player, String node) {
if (permissions != null) {
return permissions.has(player, node);
} else {
return !node.contains("exclude") && (!node.contains("admin") || player.isOp());
return !node.contains("exclude") && ((!node.contains("admin") && !node.contains("mod")) || player.isOp());
}
}

Expand Down
33 changes: 0 additions & 33 deletions com/nijikokun/register/payment/forChestShop/Method.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,29 @@
*/
public interface Method {
public Object getPlugin();

public String getName();

public String getVersion();

public String format(double amount);

public boolean hasBanks();

public boolean hasBank(String bank);

public boolean hasAccount(String name);

public boolean hasBankAccount(String bank, String name);

public MethodAccount getAccount(String name);

public MethodBankAccount getBankAccount(String bank, String name);

public boolean isCompatible(Plugin plugin);

public void setPlugin(Plugin plugin);

public interface MethodAccount {
public double balance();

public boolean set(double amount);

public boolean add(double amount);

public boolean subtract(double amount);

public boolean multiply(double amount);

public boolean divide(double amount);

public boolean hasEnough(double amount);

public boolean hasOver(double amount);

public boolean hasUnder(double amount);

public boolean isNegative();

public boolean remove();

@Override
Expand All @@ -64,29 +43,17 @@ public interface MethodAccount {

public interface MethodBankAccount {
public double balance();

public String getBankName();

public int getBankId();

public boolean set(double amount);

public boolean add(double amount);

public boolean subtract(double amount);

public boolean multiply(double amount);

public boolean divide(double amount);

public boolean hasEnough(double amount);

public boolean hasOver(double amount);

public boolean hasUnder(double amount);

public boolean isNegative();

public boolean remove();

@Override
Expand Down
59 changes: 25 additions & 34 deletions com/nijikokun/register/payment/forChestShop/Methods.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.nijikokun.register.payment.forChestShop;

import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;

import java.util.HashSet;
import java.util.Set;

import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;

/**
* Methods.java
* Controls the getting / setting of methods & the method of payment used.
Expand All @@ -28,13 +28,13 @@ public Methods() {

/**
* Allows you to set which economy plugin is most preferred.
*
*
* @param preferred
*/
public Methods(String preferred) {
this._init();

if (this.Dependencies.contains(preferred)) {
if(this.Dependencies.contains(preferred)) {
this.preferred = preferred;
}
}
Expand All @@ -51,7 +51,7 @@ public Set<String> getDependencies() {
}

public Method createMethod(Plugin plugin) {
for (Method method : Methods) {
for (Method method: Methods) {
if (method.isCompatible(plugin)) {
method.setPlugin(plugin);
return method;
Expand All @@ -71,55 +71,46 @@ public boolean hasMethod() {
}

public boolean setMethod(Plugin method) {
if (hasMethod()) return true;
if (self) {
self = false;
return false;
}
if(hasMethod()) return true;
if(self) { self = false; return false; }

int count = 0;
boolean match = false;
Plugin plugin;
Plugin plugin = null;
PluginManager manager = method.getServer().getPluginManager();

for (String name : this.Dependencies) {
if (hasMethod()) break;
if (method.getDescription().getName().equals(name)) plugin = method;
else plugin = manager.getPlugin(name);
if (plugin == null) continue;

if (!plugin.isEnabled()) {
this.self = true;
manager.enablePlugin(plugin);
}
for(String name: this.getDependencies()) {
if(hasMethod()) break;
if(method.getDescription().getName().equals(name)) plugin = method; else plugin = manager.getPlugin(name);
if(plugin == null) continue;

Method current = this.createMethod(plugin);
if (current == null) continue;
if(current == null) continue;

if (this.preferred.isEmpty())
if(this.preferred.isEmpty())
this.Method = current;
else {
this.Attachables.add(current);
}
}

if (!this.preferred.isEmpty()) {
if(!this.preferred.isEmpty()) {
do {
if (hasMethod()) {
if(hasMethod()) {
match = true;
} else {
for (Method attached : this.Attachables) {
if (attached == null) continue;
for(Method attached: this.Attachables) {
if(attached == null) continue;

if (hasMethod()) {
if(hasMethod()) {
match = true;
break;
}

if (this.preferred.isEmpty()) this.Method = attached;
if(this.preferred.isEmpty()) this.Method = attached;

if (count == 0) {
if (this.preferred.equalsIgnoreCase(attached.getName()))
if(count == 0) {
if(this.preferred.equalsIgnoreCase(attached.getName()))
this.Method = attached;
} else {
this.Method = attached;
Expand All @@ -128,7 +119,7 @@ public boolean setMethod(Plugin method) {

count++;
}
} while (!match);
} while(!match);
}

return hasMethod();
Expand All @@ -139,7 +130,7 @@ public Method getMethod() {
}

public boolean checkDisabled(Plugin method) {
if (!hasMethod()) return true;
if(!hasMethod()) return true;
if (Method.isCompatible(method)) Method = null;
return (Method == null);
}
Expand Down
Loading

0 comments on commit e522b33

Please sign in to comment.