[Version 0.7.4.4]

- Changed the implementation of StargateAccessEvent.
 - Disable Permissions if version is 2.7.2 (Common version used between
bridges)
 - Fix long-standing bug with hasPermDeep check. Oops.
This commit is contained in:
Steven Scott 2012-01-27 22:43:24 -08:00
parent 64053cdc63
commit bf92401ea9
4 changed files with 66 additions and 92 deletions

4
README
View File

@ -198,6 +198,10 @@ createConflict=Gate conflicts with existing gate
============= =============
Changes Changes
============= =============
[Version 0.7.4.4]
- Changed the implementation of StargateAccessEvent.
- Disable Permissions if version is 2.7.2 (Common version used between bridges)
- Fix long-standing bug with hasPermDeep check. Oops.
[Version 0.7.4.3] [Version 0.7.4.3]
- Implement StargateAccessEvent, used for bypassing permission checks/denying access to gates. - Implement StargateAccessEvent, used for bypassing permission checks/denying access to gates.
[Version 0.7.4.2] [Version 0.7.4.2]

View File

@ -126,6 +126,10 @@ public class Stargate extends JavaPlugin {
// Check to see if iConomy/Permissions is loaded yet. // Check to see if iConomy/Permissions is loaded yet.
permissions = (Permissions)checkPlugin("Permissions"); permissions = (Permissions)checkPlugin("Permissions");
if (permissions != null && permissions.getDescription().getVersion().equals("2.7.2")) {
log.info("[Stargate] Permissions is 2.7.2, most likely a bridge, disabling.");
permissions = null;
}
if (iConomyHandler.setupeConomy(pm)) { if (iConomyHandler.setupeConomy(pm)) {
if (iConomyHandler.register != null) if (iConomyHandler.register != null)
log.info("[Stargate] Register v" + iConomyHandler.register.getDescription().getVersion() + " found"); log.info("[Stargate] Register v" + iConomyHandler.register.getDescription().getVersion() + " found");
@ -347,7 +351,7 @@ public class Stargate extends JavaPlugin {
return true; return true;
} }
if (permDebug) if (permDebug)
Stargate.debug("hasPermDeep::Permissions", perm + " => " + permissions.getHandler().has(player, perm)); Stargate.debug("hasPermDeep::SuperPerms", perm + " => " + player.hasPermission(perm));
return player.hasPermission(perm); return player.hasPermission(perm);
} }
} }
@ -391,10 +395,11 @@ public class Stargate extends JavaPlugin {
/* /*
* Call the StargateAccessPortal event, used for other plugins to bypass Permissions checks * Call the StargateAccessPortal event, used for other plugins to bypass Permissions checks
*/ */
public static StargateAccessEvent canAccessPortal(Player player, Portal portal) { public static boolean canAccessPortal(Player player, Portal portal, boolean deny) {
StargateAccessEvent event = new StargateAccessEvent(player, portal); StargateAccessEvent event = new StargateAccessEvent(player, portal, deny);
Stargate.server.getPluginManager().callEvent(event); Stargate.server.getPluginManager().callEvent(event);
return event; if (event.getDeny()) return false;
return true;
} }
/* /*
@ -611,28 +616,22 @@ public class Stargate extends JavaPlugin {
Portal dest = portal.getDestination(); Portal dest = portal.getDestination();
if (dest == null) return; if (dest == null) return;
// Check if we're bypassing the permission check boolean deny = false;
StargateAccessEvent access = canAccessPortal(player, portal); // Check if player has access to this network
if (access.getDeny()) { if (!canAccessNetwork(player, portal.getNetwork())) {
deny = true;
}
// Check if player has access to destination world
if (!canAccessWorld(player, dest.getWorld().getName())) {
deny = true;
}
if (!canAccessPortal(player, portal, deny)) {
Stargate.sendMessage(player, Stargate.getString("denyMsg")); Stargate.sendMessage(player, Stargate.getString("denyMsg"));
portal.close(false); portal.close(false);
return; return;
} }
if (!access.getBypassPerms()) {
// Check if player has access to this network
if (!canAccessNetwork(player, portal.getNetwork())) {
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
portal.close(false);
return;
}
// Check if player has access to destination world
if (!canAccessWorld(player, dest.getWorld().getName())) {
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
portal.close(false);
return;
}
}
int cost = Stargate.getUseCost(player, portal, dest); int cost = Stargate.getUseCost(player, portal, dest);
if (cost > 0) { if (cost > 0) {
@ -714,31 +713,23 @@ public class Stargate extends JavaPlugin {
Portal destination = portal.getDestination(); Portal destination = portal.getDestination();
if (destination == null) return; if (destination == null) return;
// Check if we're bypassing the perm check boolean deny = false;
StargateAccessEvent access = canAccessPortal(player, portal); // Check if player has access to this network
if (access.getDeny()) { if (!canAccessNetwork(player, portal.getNetwork())) {
deny = true;
}
// Check if player has access to destination world
if (!canAccessWorld(player, destination.getWorld().getName())) {
deny = true;
}
if (!canAccessPortal(player, portal, deny)) {
Stargate.sendMessage(player, Stargate.getString("denyMsg")); Stargate.sendMessage(player, Stargate.getString("denyMsg"));
portal.teleport(player, portal, event); portal.teleport(player, portal, event);
portal.close(false); portal.close(false);
return; return;
} }
if (!access.getBypassPerms()) {
// Check if player has access to this network
if (!canAccessNetwork(player, portal.getNetwork())) {
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
portal.teleport(player, portal, event);
portal.close(false);
return;
}
// Check if player has access to destination world
if (!canAccessWorld(player, destination.getWorld().getName())) {
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
portal.teleport(player, portal, event);
portal.close(false);
return;
}
}
int cost = Stargate.getUseCost(player, portal, destination); int cost = Stargate.getUseCost(player, portal, destination);
if (cost > 0) { if (cost > 0) {
@ -781,18 +772,15 @@ public class Stargate extends JavaPlugin {
event.setUseItemInHand(Result.DENY); event.setUseItemInHand(Result.DENY);
event.setUseInteractedBlock(Result.DENY); event.setUseInteractedBlock(Result.DENY);
// Check if we're bypassing the perm check boolean deny = false;
StargateAccessEvent access = canAccessPortal(player, portal); if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
if (access.getDeny()) { deny = true;
}
if (!Stargate.canAccessPortal(player, portal, deny)) {
Stargate.sendMessage(player, Stargate.getString("denyMsg")); Stargate.sendMessage(player, Stargate.getString("denyMsg"));
return; return;
} }
if (!access.getBypassPerms()) {
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
return;
}
}
if ((!portal.isOpen()) && (!portal.isFixed())) { if ((!portal.isOpen()) && (!portal.isFixed())) {
portal.cycleDestination(player); portal.cycleDestination(player);
@ -809,18 +797,15 @@ public class Stargate extends JavaPlugin {
event.setUseItemInHand(Result.DENY); event.setUseItemInHand(Result.DENY);
event.setUseInteractedBlock(Result.DENY); event.setUseInteractedBlock(Result.DENY);
// Check if we're bypassing the perm check boolean deny = false;
StargateAccessEvent access = canAccessPortal(player, portal); if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
if (access.getDeny()) { deny = true;
}
if (!Stargate.canAccessPortal(player, portal, deny)) {
Stargate.sendMessage(player, Stargate.getString("denyMsg")); Stargate.sendMessage(player, Stargate.getString("denyMsg"));
return; return;
} }
if (!access.getBypassPerms()) {
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
return;
}
}
onButtonPressed(player, portal); onButtonPressed(player, portal);
} }
return; return;
@ -839,18 +824,15 @@ public class Stargate extends JavaPlugin {
event.setCancelled(true); event.setCancelled(true);
} }
// Check if we're bypassing the perm check boolean deny = false;
StargateAccessEvent access = canAccessPortal(player, portal); if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
if (access.getDeny()) { deny = true;
}
if (!Stargate.canAccessPortal(player, portal, deny)) {
Stargate.sendMessage(player, Stargate.getString("denyMsg")); Stargate.sendMessage(player, Stargate.getString("denyMsg"));
return; return;
} }
if (!access.getBypassPerms()) {
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
return;
}
}
if ((!portal.isOpen()) && (!portal.isFixed())) { if ((!portal.isOpen()) && (!portal.isFixed())) {
portal.cycleDestination(player, -1); portal.cycleDestination(player, -1);
@ -868,18 +850,15 @@ public class Stargate extends JavaPlugin {
event.setCancelled(true); event.setCancelled(true);
} }
// Check if we're bypassing the perm check boolean deny = false;
StargateAccessEvent access = canAccessPortal(player, portal); if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
if (access.getDeny()) { deny = true;
}
if (!Stargate.canAccessPortal(player, portal, deny)) {
Stargate.sendMessage(player, Stargate.getString("denyMsg")); Stargate.sendMessage(player, Stargate.getString("denyMsg"));
return; return;
} }
if (!access.getBypassPerms()) {
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
return;
}
}
onButtonPressed(player, portal); onButtonPressed(player, portal);
} }
} }
@ -1097,7 +1076,8 @@ public class Stargate extends JavaPlugin {
log.info("[Stargate] Vault v" + iConomyHandler.vault.getDescription().getVersion() + " found"); log.info("[Stargate] Vault v" + iConomyHandler.vault.getDescription().getVersion() + " found");
} }
if (permissions == null) { if (permissions == null) {
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("Permissions")) { PluginDescriptionFile desc = event.getPlugin().getDescription();
if (desc.getName().equalsIgnoreCase("Permissions") && !desc.getVersion().equals("2.7.2")) {
permissions = (Permissions)checkPlugin(event.getPlugin()); permissions = (Permissions)checkPlugin(event.getPlugin());
} }
} }

View File

@ -10,23 +10,13 @@ public class StargateAccessEvent extends StargateEvent {
*/ */
private static final long serialVersionUID = -1009056668229801760L; private static final long serialVersionUID = -1009056668229801760L;
private Player player; private Player player;
private boolean bypassPerms;
private boolean deny; private boolean deny;
public StargateAccessEvent(Player player, Portal portal) { public StargateAccessEvent(Player player, Portal portal, boolean deny) {
super("StargateAccessEvent", portal); super("StargateAccessEvent", portal);
this.player = player; this.player = player;
this.bypassPerms = false; this.deny = deny;
this.deny = false;
}
public void setBypassPerms(boolean access) {
this.bypassPerms = access;
}
public boolean getBypassPerms() {
return this.bypassPerms;
} }
public boolean getDeny() { public boolean getDeny() {

View File

@ -1,6 +1,6 @@
name: Stargate name: Stargate
main: net.TheDgtl.Stargate.Stargate main: net.TheDgtl.Stargate.Stargate
version: 0.7.4.3 version: 0.7.4.4
description: Stargate mod for Bukkit description: Stargate mod for Bukkit
author: Drakia author: Drakia
website: http://www.thedgtl.net website: http://www.thedgtl.net