Fix entry and exit group flags not working, fix vehicle destroy flag not being allowed with canBuild

This commit is contained in:
zml2008 2012-03-03 16:26:11 -08:00
parent 8c8c162a54
commit 5ff2855eb0
2 changed files with 14 additions and 13 deletions

View File

@ -117,14 +117,14 @@ public void onPlayerMove(PlayerMoveEvent event) {
state = plugin.getFlagStateManager().getState(player); state = plugin.getFlagStateManager().getState(player);
} }
//LocalPlayer localPlayer = plugin.wrapPlayer(player); LocalPlayer localPlayer = plugin.wrapPlayer(player);
boolean hasBypass = plugin.getGlobalRegionManager().hasBypass(player, world); boolean hasBypass = plugin.getGlobalRegionManager().hasBypass(player, world);
RegionManager mgr = plugin.getGlobalRegionManager().get(world); RegionManager mgr = plugin.getGlobalRegionManager().get(world);
Vector pt = new Vector(event.getTo().getBlockX(), event.getTo().getBlockY(), event.getTo().getBlockZ()); Vector pt = new Vector(event.getTo().getBlockX(), event.getTo().getBlockY(), event.getTo().getBlockZ());
ApplicableRegionSet set = mgr.getApplicableRegions(pt); ApplicableRegionSet set = mgr.getApplicableRegions(pt);
boolean entryAllowed = set.allows(DefaultFlag.ENTRY);//, localPlayer); boolean entryAllowed = set.allows(DefaultFlag.ENTRY, localPlayer);
if (!hasBypass && !entryAllowed) { if (!hasBypass && !entryAllowed) {
player.sendMessage(ChatColor.DARK_RED + "You are not permitted to enter this area."); player.sendMessage(ChatColor.DARK_RED + "You are not permitted to enter this area.");
@ -139,10 +139,10 @@ public void onPlayerMove(PlayerMoveEvent event) {
// Have to set this state // Have to set this state
if (state.lastExitAllowed == null) { if (state.lastExitAllowed == null) {
state.lastExitAllowed = mgr.getApplicableRegions(toVector(event.getFrom())) state.lastExitAllowed = mgr.getApplicableRegions(toVector(event.getFrom()))
.allows(DefaultFlag.EXIT);//, localPlayer); .allows(DefaultFlag.EXIT, localPlayer);
} }
boolean exitAllowed = set.allows(DefaultFlag.EXIT);//, localPlayer); boolean exitAllowed = set.allows(DefaultFlag.EXIT, localPlayer);
if (!hasBypass && exitAllowed && !state.lastExitAllowed) { if (!hasBypass && exitAllowed && !state.lastExitAllowed) {
player.sendMessage(ChatColor.DARK_RED + "You are not permitted to leave this area."); player.sendMessage(ChatColor.DARK_RED + "You are not permitted to leave this area.");

View File

@ -63,6 +63,7 @@ public void onVehicleDestroy(VehicleDestroyEvent event) {
LocalPlayer localPlayer = plugin.wrapPlayer(player); LocalPlayer localPlayer = plugin.wrapPlayer(player);
if (!plugin.getGlobalRegionManager().hasBypass(player, world) if (!plugin.getGlobalRegionManager().hasBypass(player, world)
&& !set.canBuild(localPlayer)
&& !set.allows(DefaultFlag.DESTROY_VEHICLE, localPlayer)) { && !set.allows(DefaultFlag.DESTROY_VEHICLE, localPlayer)) {
player.sendMessage(ChatColor.DARK_RED + "You don't have permission to destroy vehicles here."); player.sendMessage(ChatColor.DARK_RED + "You don't have permission to destroy vehicles here.");
event.setCancelled(true); event.setCancelled(true);
@ -122,40 +123,40 @@ public void onVehicleMove(VehicleMoveEvent event) {
String farewell = set.getFlag(DefaultFlag.FAREWELL_MESSAGE, localPlayer); String farewell = set.getFlag(DefaultFlag.FAREWELL_MESSAGE, localPlayer);
Boolean notifyEnter = set.getFlag(DefaultFlag.NOTIFY_ENTER, localPlayer); Boolean notifyEnter = set.getFlag(DefaultFlag.NOTIFY_ENTER, localPlayer);
Boolean notifyLeave = set.getFlag(DefaultFlag.NOTIFY_LEAVE, localPlayer); Boolean notifyLeave = set.getFlag(DefaultFlag.NOTIFY_LEAVE, localPlayer);
if (state.lastFarewell != null && (farewell == null if (state.lastFarewell != null && (farewell == null
|| !state.lastFarewell.equals(farewell))) { || !state.lastFarewell.equals(farewell))) {
String replacedFarewell = plugin.replaceMacros( String replacedFarewell = plugin.replaceMacros(
player, BukkitUtil.replaceColorMacros(state.lastFarewell)); player, BukkitUtil.replaceColorMacros(state.lastFarewell));
player.sendMessage(ChatColor.AQUA + " ** " + replacedFarewell); player.sendMessage(ChatColor.AQUA + " ** " + replacedFarewell);
} }
if (greeting != null && (state.lastGreeting == null if (greeting != null && (state.lastGreeting == null
|| !state.lastGreeting.equals(greeting))) { || !state.lastGreeting.equals(greeting))) {
String replacedGreeting = plugin.replaceMacros( String replacedGreeting = plugin.replaceMacros(
player, BukkitUtil.replaceColorMacros(greeting)); player, BukkitUtil.replaceColorMacros(greeting));
player.sendMessage(ChatColor.AQUA + " ** " + replacedGreeting); player.sendMessage(ChatColor.AQUA + " ** " + replacedGreeting);
} }
if ((notifyLeave == null || !notifyLeave) if ((notifyLeave == null || !notifyLeave)
&& state.notifiedForLeave != null && state.notifiedForLeave) { && state.notifiedForLeave != null && state.notifiedForLeave) {
plugin.broadcastNotification(ChatColor.GRAY + "WG: " plugin.broadcastNotification(ChatColor.GRAY + "WG: "
+ ChatColor.LIGHT_PURPLE + player.getName() + ChatColor.LIGHT_PURPLE + player.getName()
+ ChatColor.GOLD + " left NOTIFY region"); + ChatColor.GOLD + " left NOTIFY region");
} }
if (notifyEnter != null && notifyEnter && (state.notifiedForEnter == null if (notifyEnter != null && notifyEnter && (state.notifiedForEnter == null
|| !state.notifiedForEnter)) { || !state.notifiedForEnter)) {
StringBuilder regionList = new StringBuilder(); StringBuilder regionList = new StringBuilder();
for (ProtectedRegion region : set) { for (ProtectedRegion region : set) {
if (regionList.length() != 0) { if (regionList.length() != 0) {
regionList.append(", "); regionList.append(", ");
} }
regionList.append(region.getId()); regionList.append(region.getId());
} }
plugin.broadcastNotification(ChatColor.GRAY + "WG: " plugin.broadcastNotification(ChatColor.GRAY + "WG: "
+ ChatColor.LIGHT_PURPLE + player.getName() + ChatColor.LIGHT_PURPLE + player.getName()
+ ChatColor.GOLD + " entered NOTIFY region: " + ChatColor.GOLD + " entered NOTIFY region: "
+ ChatColor.WHITE + ChatColor.WHITE