Added stargate.create.gate permissions

This is really 0.6.5... Hopefully
This commit is contained in:
Steven Scott
2011-08-28 18:08:03 -07:00
parent 8e222ea87e
commit 394421dff8
4 changed files with 35 additions and 5 deletions

View File

@ -795,6 +795,15 @@ public class Portal {
}
}
// Check if the player can create this gate layout
String gateName = gate.getFilename();
gateName = gateName.substring(0, gateName.indexOf('.'));
if (!Stargate.canCreateGate(player, gateName)) {
Stargate.debug("createPortal", "Player does not have access to gate layout");
Stargate.sendMessage(player, Stargate.getString("createGateDeny"));
return null;
}
if (name.length() < 1 || name.length() > 11) {
Stargate.debug("createPortal", "Name length error");
Stargate.sendMessage(player, Stargate.getString("createNameLength"));

View File

@ -163,7 +163,6 @@ public class Stargate extends JavaPlugin {
iConomyHandler.createCost = config.getInt("createcost", iConomyHandler.createCost);
iConomyHandler.destroyCost = config.getInt("destroycost", iConomyHandler.destroyCost);
iConomyHandler.useCost = config.getInt("usecost", iConomyHandler.useCost);
iConomyHandler.inFundMsg = config.getString("not-enough-money-message", iConomyHandler.inFundMsg);
iConomyHandler.toOwner = config.getBoolean("toowner", iConomyHandler.toOwner);
iConomyHandler.chargeFreeDestination = config.getBoolean("chargefreedestination", iConomyHandler.chargeFreeDestination);
iConomyHandler.freeGatesGreen = config.getBoolean("freegatesgreen", iConomyHandler.freeGatesGreen);
@ -455,6 +454,24 @@ public class Stargate extends JavaPlugin {
return false;
}
/*
* Check if the player can create this gate layout
*/
public static boolean canCreateGate(Player player, String gate) {
// Check for general create
if (hasPerm(player, "stargate.create")) return true;
// Check for all gate create permissions
if (hasPerm(player, "stargate.create.gate")) {
// Do a deep check to see if the player lacks this specific gate node
if (!hasPermDeep(player, "stargate.create.gate." + gate)) return false;
return true;
}
// Check for this specific gate
if (hasPerm(player, "stargate.create.gate." + gate)) return true;
return false;
}
/*
* Check if the player can destroy this gate
*/

View File

@ -13,6 +13,7 @@ ecoInFunds=Insufficient Funds
createMsg=Gate Created
createNetDeny=You do not have access to that network
createGateDeny=You do not have access to that gate layout
createPersonal=Creating gate on personal network
createNameLength=Name too short or too long.
createExists=A gate by that name already exists