From b8f9ceafbb5c702badf435a7a3f4d1ba3aecb051 Mon Sep 17 00:00:00 2001 From: Dark Arc Date: Wed, 7 Nov 2012 14:20:15 -0500 Subject: [PATCH] Resolves comma issue relating to flag listing This stops commas from being added when a player types in an invalid flag and the player does not have permission to use one or more of the flag that are listed. --- .../worldguard/bukkit/FlagStateManager.java | 23 ++++++++----------- .../bukkit/commands/RegionCommands.java | 10 ++++---- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/sk89q/worldguard/bukkit/FlagStateManager.java b/src/main/java/com/sk89q/worldguard/bukkit/FlagStateManager.java index ae91ecd9..2fa2c4ce 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/FlagStateManager.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/FlagStateManager.java @@ -19,19 +19,18 @@ package com.sk89q.worldguard.bukkit; -import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector; - -import java.util.HashMap; -import java.util.Map; - -import org.bukkit.GameMode; -import org.bukkit.World; -import org.bukkit.entity.Player; - import com.sk89q.worldedit.Vector; import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.flags.DefaultFlag; import com.sk89q.worldguard.protection.managers.RegionManager; +import org.bukkit.GameMode; +import org.bukkit.World; +import org.bukkit.entity.Player; + +import java.util.HashMap; +import java.util.Map; + +import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector; /** * This processes per-player state information and is also meant to be used @@ -83,10 +82,8 @@ public void run() { } Vector playerLocation = toVector(player.getLocation()); - RegionManager regionManager = plugin.getGlobalRegionManager() - .get(player.getWorld()); - ApplicableRegionSet applicable = regionManager - .getApplicableRegions(playerLocation); + RegionManager regionManager = plugin.getGlobalRegionManager().get(player.getWorld()); + ApplicableRegionSet applicable = regionManager.getApplicableRegions(playerLocation); if (!RegionQueryUtil.isInvincible(plugin, player, applicable) && !plugin.getGlobalStateManager().hasGodMode(player) diff --git a/src/main/java/com/sk89q/worldguard/bukkit/commands/RegionCommands.java b/src/main/java/com/sk89q/worldguard/bukkit/commands/RegionCommands.java index dce514d9..9d00e25e 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/commands/RegionCommands.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/commands/RegionCommands.java @@ -708,9 +708,6 @@ public void flag(CommandContext args, CommandSender sender) throws CommandExcept // Need to build a list for (Flag flag : DefaultFlag.getFlags()) { - if (list.length() > 0) { - list.append(", "); - } // @TODO deprecate inconsistant "owner" permission if (region.isOwner(localPlayer)) { @@ -730,8 +727,11 @@ public void flag(CommandContext args, CommandSender sender) throws CommandExcept + flag.getName() + "." + id.toLowerCase())) { continue; } - } - + } + + if (list.length() > 0) { + list.append(", "); + } list.append(flag.getName()); }