[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:
parent
64053cdc63
commit
bf92401ea9
4
README
4
README
@ -198,6 +198,10 @@ createConflict=Gate conflicts with existing gate
|
||||
=============
|
||||
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]
|
||||
- Implement StargateAccessEvent, used for bypassing permission checks/denying access to gates.
|
||||
[Version 0.7.4.2]
|
||||
|
@ -126,6 +126,10 @@ public class Stargate extends JavaPlugin {
|
||||
|
||||
// Check to see if iConomy/Permissions is loaded yet.
|
||||
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.register != null)
|
||||
log.info("[Stargate] Register v" + iConomyHandler.register.getDescription().getVersion() + " found");
|
||||
@ -347,7 +351,7 @@ public class Stargate extends JavaPlugin {
|
||||
return true;
|
||||
}
|
||||
if (permDebug)
|
||||
Stargate.debug("hasPermDeep::Permissions", perm + " => " + permissions.getHandler().has(player, perm));
|
||||
Stargate.debug("hasPermDeep::SuperPerms", perm + " => " + 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
|
||||
*/
|
||||
public static StargateAccessEvent canAccessPortal(Player player, Portal portal) {
|
||||
StargateAccessEvent event = new StargateAccessEvent(player, portal);
|
||||
public static boolean canAccessPortal(Player player, Portal portal, boolean deny) {
|
||||
StargateAccessEvent event = new StargateAccessEvent(player, portal, deny);
|
||||
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();
|
||||
if (dest == null) return;
|
||||
// Check if we're bypassing the permission check
|
||||
StargateAccessEvent access = canAccessPortal(player, portal);
|
||||
if (access.getDeny()) {
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
portal.close(false);
|
||||
return;
|
||||
}
|
||||
if (!access.getBypassPerms()) {
|
||||
boolean deny = false;
|
||||
// Check if player has access to this network
|
||||
if (!canAccessNetwork(player, portal.getNetwork())) {
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
portal.close(false);
|
||||
return;
|
||||
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"));
|
||||
portal.close(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int cost = Stargate.getUseCost(player, portal, dest);
|
||||
if (cost > 0) {
|
||||
@ -714,31 +713,23 @@ public class Stargate extends JavaPlugin {
|
||||
Portal destination = portal.getDestination();
|
||||
if (destination == null) return;
|
||||
|
||||
// Check if we're bypassing the perm check
|
||||
StargateAccessEvent access = canAccessPortal(player, portal);
|
||||
if (access.getDeny()) {
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
portal.teleport(player, portal, event);
|
||||
portal.close(false);
|
||||
return;
|
||||
}
|
||||
if (!access.getBypassPerms()) {
|
||||
boolean deny = false;
|
||||
// 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;
|
||||
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"));
|
||||
portal.teleport(player, portal, event);
|
||||
portal.close(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int cost = Stargate.getUseCost(player, portal, destination);
|
||||
if (cost > 0) {
|
||||
@ -781,18 +772,15 @@ public class Stargate extends JavaPlugin {
|
||||
event.setUseItemInHand(Result.DENY);
|
||||
event.setUseInteractedBlock(Result.DENY);
|
||||
|
||||
// Check if we're bypassing the perm check
|
||||
StargateAccessEvent access = canAccessPortal(player, portal);
|
||||
if (access.getDeny()) {
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
return;
|
||||
}
|
||||
if (!access.getBypassPerms()) {
|
||||
boolean deny = false;
|
||||
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
|
||||
deny = true;
|
||||
}
|
||||
|
||||
if (!Stargate.canAccessPortal(player, portal, deny)) {
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((!portal.isOpen()) && (!portal.isFixed())) {
|
||||
portal.cycleDestination(player);
|
||||
@ -809,18 +797,15 @@ public class Stargate extends JavaPlugin {
|
||||
event.setUseItemInHand(Result.DENY);
|
||||
event.setUseInteractedBlock(Result.DENY);
|
||||
|
||||
// Check if we're bypassing the perm check
|
||||
StargateAccessEvent access = canAccessPortal(player, portal);
|
||||
if (access.getDeny()) {
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
return;
|
||||
}
|
||||
if (!access.getBypassPerms()) {
|
||||
boolean deny = false;
|
||||
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
|
||||
deny = true;
|
||||
}
|
||||
|
||||
if (!Stargate.canAccessPortal(player, portal, deny)) {
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
onButtonPressed(player, portal);
|
||||
}
|
||||
return;
|
||||
@ -839,18 +824,15 @@ public class Stargate extends JavaPlugin {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
// Check if we're bypassing the perm check
|
||||
StargateAccessEvent access = canAccessPortal(player, portal);
|
||||
if (access.getDeny()) {
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
return;
|
||||
}
|
||||
if (!access.getBypassPerms()) {
|
||||
boolean deny = false;
|
||||
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
|
||||
deny = true;
|
||||
}
|
||||
|
||||
if (!Stargate.canAccessPortal(player, portal, deny)) {
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((!portal.isOpen()) && (!portal.isFixed())) {
|
||||
portal.cycleDestination(player, -1);
|
||||
@ -868,18 +850,15 @@ public class Stargate extends JavaPlugin {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
// Check if we're bypassing the perm check
|
||||
StargateAccessEvent access = canAccessPortal(player, portal);
|
||||
if (access.getDeny()) {
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
return;
|
||||
}
|
||||
if (!access.getBypassPerms()) {
|
||||
boolean deny = false;
|
||||
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
|
||||
deny = true;
|
||||
}
|
||||
|
||||
if (!Stargate.canAccessPortal(player, portal, deny)) {
|
||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
onButtonPressed(player, portal);
|
||||
}
|
||||
}
|
||||
@ -1097,7 +1076,8 @@ public class Stargate extends JavaPlugin {
|
||||
log.info("[Stargate] Vault v" + iConomyHandler.vault.getDescription().getVersion() + " found");
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
@ -10,23 +10,13 @@ public class StargateAccessEvent extends StargateEvent {
|
||||
*/
|
||||
private static final long serialVersionUID = -1009056668229801760L;
|
||||
private Player player;
|
||||
private boolean bypassPerms;
|
||||
private boolean deny;
|
||||
|
||||
public StargateAccessEvent(Player player, Portal portal) {
|
||||
public StargateAccessEvent(Player player, Portal portal, boolean deny) {
|
||||
super("StargateAccessEvent", portal);
|
||||
|
||||
this.player = player;
|
||||
this.bypassPerms = false;
|
||||
this.deny = false;
|
||||
}
|
||||
|
||||
public void setBypassPerms(boolean access) {
|
||||
this.bypassPerms = access;
|
||||
}
|
||||
|
||||
public boolean getBypassPerms() {
|
||||
return this.bypassPerms;
|
||||
this.deny = deny;
|
||||
}
|
||||
|
||||
public boolean getDeny() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: Stargate
|
||||
main: net.TheDgtl.Stargate.Stargate
|
||||
version: 0.7.4.3
|
||||
version: 0.7.4.4
|
||||
description: Stargate mod for Bukkit
|
||||
author: Drakia
|
||||
website: http://www.thedgtl.net
|
||||
|
Loading…
Reference in New Issue
Block a user