[Version 0.7.4.3]
- Implement StargateAccessEvent, used for bypassing permission checks/denying access to gates.
This commit is contained in:
parent
82894b2e52
commit
64053cdc63
2
README
2
README
@ -198,6 +198,8 @@ createConflict=Gate conflicts with existing gate
|
|||||||
=============
|
=============
|
||||||
Changes
|
Changes
|
||||||
=============
|
=============
|
||||||
|
[Version 0.7.4.3]
|
||||||
|
- Implement StargateAccessEvent, used for bypassing permission checks/denying access to gates.
|
||||||
[Version 0.7.4.2]
|
[Version 0.7.4.2]
|
||||||
- stargate.create.personal permission now also allows user to use personal gates
|
- stargate.create.personal permission now also allows user to use personal gates
|
||||||
[Version 0.7.4.1]
|
[Version 0.7.4.1]
|
||||||
|
@ -6,6 +6,8 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import net.TheDgtl.Stargate.event.StargateAccessEvent;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -386,6 +388,15 @@ public class Stargate extends JavaPlugin {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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);
|
||||||
|
Stargate.server.getPluginManager().callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return true if the portal is free for the player
|
* Return true if the portal is free for the player
|
||||||
*/
|
*/
|
||||||
@ -600,6 +611,14 @@ 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
|
||||||
|
StargateAccessEvent access = canAccessPortal(player, portal);
|
||||||
|
if (access.getDeny()) {
|
||||||
|
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||||
|
portal.close(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!access.getBypassPerms()) {
|
||||||
// Check if player has access to this network
|
// Check if player has access to this network
|
||||||
if (!canAccessNetwork(player, portal.getNetwork())) {
|
if (!canAccessNetwork(player, portal.getNetwork())) {
|
||||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||||
@ -613,6 +632,7 @@ public class Stargate extends JavaPlugin {
|
|||||||
portal.close(false);
|
portal.close(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int cost = Stargate.getUseCost(player, portal, dest);
|
int cost = Stargate.getUseCost(player, portal, dest);
|
||||||
if (cost > 0) {
|
if (cost > 0) {
|
||||||
@ -694,6 +714,15 @@ 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
|
||||||
|
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()) {
|
||||||
// Check if player has access to this network
|
// Check if player has access to this network
|
||||||
if (!canAccessNetwork(player, portal.getNetwork())) {
|
if (!canAccessNetwork(player, portal.getNetwork())) {
|
||||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||||
@ -709,6 +738,7 @@ public class Stargate extends JavaPlugin {
|
|||||||
portal.close(false);
|
portal.close(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int cost = Stargate.getUseCost(player, portal, destination);
|
int cost = Stargate.getUseCost(player, portal, destination);
|
||||||
if (cost > 0) {
|
if (cost > 0) {
|
||||||
@ -751,10 +781,18 @@ 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
|
||||||
|
StargateAccessEvent access = canAccessPortal(player, portal);
|
||||||
|
if (access.getDeny()) {
|
||||||
|
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!access.getBypassPerms()) {
|
||||||
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
|
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
|
||||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((!portal.isOpen()) && (!portal.isFixed())) {
|
if ((!portal.isOpen()) && (!portal.isFixed())) {
|
||||||
portal.cycleDestination(player);
|
portal.cycleDestination(player);
|
||||||
@ -771,10 +809,18 @@ 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
|
||||||
|
StargateAccessEvent access = canAccessPortal(player, portal);
|
||||||
|
if (access.getDeny()) {
|
||||||
|
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!access.getBypassPerms()) {
|
||||||
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
|
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
|
||||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
onButtonPressed(player, portal);
|
onButtonPressed(player, portal);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -793,10 +839,18 @@ public class Stargate extends JavaPlugin {
|
|||||||
event.setCancelled(true);
|
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()) {
|
||||||
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
|
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
|
||||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((!portal.isOpen()) && (!portal.isFixed())) {
|
if ((!portal.isOpen()) && (!portal.isFixed())) {
|
||||||
portal.cycleDestination(player, -1);
|
portal.cycleDestination(player, -1);
|
||||||
@ -814,10 +868,18 @@ public class Stargate extends JavaPlugin {
|
|||||||
event.setCancelled(true);
|
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()) {
|
||||||
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
|
if (!Stargate.canAccessNetwork(player, portal.getNetwork())) {
|
||||||
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
Stargate.sendMessage(player, Stargate.getString("denyMsg"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
onButtonPressed(player, portal);
|
onButtonPressed(player, portal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
44
src/net/TheDgtl/Stargate/event/StargateAccessEvent.java
Normal file
44
src/net/TheDgtl/Stargate/event/StargateAccessEvent.java
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package net.TheDgtl.Stargate.event;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import net.TheDgtl.Stargate.Portal;
|
||||||
|
|
||||||
|
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) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getDeny() {
|
||||||
|
return this.deny;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeny(boolean deny) {
|
||||||
|
this.deny = deny;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer() {
|
||||||
|
return this.player;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -29,6 +29,10 @@ public class StargateListener extends CustomEventListener implements Listener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onStargateAccess(StargateAccessEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCustomEvent(Event event) {
|
public void onCustomEvent(Event event) {
|
||||||
if (event instanceof StargateOpenEvent) {
|
if (event instanceof StargateOpenEvent) {
|
||||||
@ -41,6 +45,8 @@ public class StargateListener extends CustomEventListener implements Listener {
|
|||||||
onStargateDeactivate((StargateDeactivateEvent)event);
|
onStargateDeactivate((StargateDeactivateEvent)event);
|
||||||
} else if (event instanceof StargatePortalEvent) {
|
} else if (event instanceof StargatePortalEvent) {
|
||||||
onStargatePortal((StargatePortalEvent)event);
|
onStargatePortal((StargatePortalEvent)event);
|
||||||
|
} else if (event instanceof StargateAccessEvent) {
|
||||||
|
onStargateAccess((StargateAccessEvent)event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: Stargate
|
name: Stargate
|
||||||
main: net.TheDgtl.Stargate.Stargate
|
main: net.TheDgtl.Stargate.Stargate
|
||||||
version: 0.7.4.2
|
version: 0.7.4.3
|
||||||
description: Stargate mod for Bukkit
|
description: Stargate mod for Bukkit
|
||||||
author: Drakia
|
author: Drakia
|
||||||
website: http://www.thedgtl.net
|
website: http://www.thedgtl.net
|
||||||
|
Loading…
Reference in New Issue
Block a user