fixed logical error in playerlistener

This commit is contained in:
Redecouverte 2011-02-26 01:08:18 +01:00
parent 9d813290c6
commit 7bedf6bb15
2 changed files with 33 additions and 39 deletions

View File

@ -15,8 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.sk89q.worldguard.bukkit; package com.sk89q.worldguard.bukkit;
import com.nijikokun.bukkit.iConomy.iConomy; import com.nijikokun.bukkit.iConomy.iConomy;
@ -41,11 +40,11 @@
* Handles all events thrown in relation to a Player * Handles all events thrown in relation to a Player
*/ */
public class WorldGuardPlayerListener extends PlayerListener { public class WorldGuardPlayerListener extends PlayerListener {
/** /**
* Plugin. * Plugin.
*/ */
private WorldGuardPlugin plugin; private WorldGuardPlugin plugin;
private boolean checkediConomy = false; private boolean checkediConomy = false;
/** /**
@ -109,8 +108,7 @@ public void onPlayerQuit(PlayerEvent event) {
@Override @Override
public void onPlayerItem(PlayerItemEvent event) { public void onPlayerItem(PlayerItemEvent event) {
if(event.isCancelled()) if (event.isCancelled()) {
{
return; return;
} }
@ -124,7 +122,7 @@ public void onPlayerItem(PlayerItemEvent event) {
if (!wcfg.itemDurability) { if (!wcfg.itemDurability) {
// Hoes // Hoes
if (item.getTypeId() >= 290 && item.getTypeId() <= 294) { if (item.getTypeId() >= 290 && item.getTypeId() <= 294) {
item.setDurability((byte)-1); item.setDurability((byte) -1);
player.setItemInHand(item); player.setItemInHand(item);
} }
} }
@ -154,8 +152,7 @@ public void onPlayerItem(PlayerItemEvent event) {
Vector pt = toVector(block.getRelative(event.getBlockFace())); Vector pt = toVector(block.getRelative(event.getBlockFace()));
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName()); RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
if (!mgr.getApplicableRegions(pt) if (!mgr.getApplicableRegions(pt).allowsFlag(AreaFlags.FLAG_LIGHTER)) {
.allowsFlag(AreaFlags.FLAG_LIGHTER)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -185,7 +182,7 @@ public void onPlayerLogin(PlayerLoginEvent event) {
} }
if (!checkediConomy) { if (!checkediConomy) {
iConomy iconomy = (iConomy)plugin.getServer().getPluginManager().getPlugin("iConomy"); iConomy iconomy = (iConomy) plugin.getServer().getPluginManager().getPlugin("iConomy");
if (iconomy != null) { if (iconomy != null) {
plugin.getWgConfiguration().setiConomy(iconomy); plugin.getWgConfiguration().setiConomy(iconomy);
} }
@ -213,9 +210,7 @@ public void onPlayerDropItem(PlayerDropItemEvent event) {
Item ci = event.getItemDrop(); Item ci = event.getItemDrop();
if (!wcfg.getBlacklist().check( if (!wcfg.getBlacklist().check(
new ItemDropBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, event new ItemDropBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, event.getPlayer()), toVector(ci.getLocation()), ci.getItemStack().getTypeId()), false, false)) {
.getPlayer()), toVector(ci.getLocation()), ci
.getItemStack().getTypeId()), false, false)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -242,9 +237,7 @@ public void onPlayerPickupItem(PlayerPickupItemEvent event) {
Item ci = event.getItem(); Item ci = event.getItem();
if (!wcfg.getBlacklist().check( if (!wcfg.getBlacklist().check(
new ItemAcquireBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, event new ItemAcquireBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, event.getPlayer()), toVector(ci.getLocation()), ci.getItemStack().getTypeId()), false, false)) {
.getPlayer()), toVector(ci.getLocation()), ci
.getItemStack().getTypeId()), false, false)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -267,14 +260,17 @@ public void onPlayerRespawn(PlayerRespawnEvent event) {
String spawnconfig = regions.getAreaFlag("spawn", "settings", true, null); String spawnconfig = regions.getAreaFlag("spawn", "settings", true, null);
Location spawn = regions.getLocationAreaFlag("spawn", player.getServer(), true, null); Location spawn = regions.getLocationAreaFlag("spawn", player.getServer(), true, null);
if(spawnconfig.equals("owner") && regions.isOwner(localPlayer)){ if (spawnconfig.equals("owner")) {
if (regions.isOwner(localPlayer)) {
player.teleportTo(spawn); player.teleportTo(spawn);
} else if (spawnconfig.equals("member") && regions.isMember(localPlayer)) { }
} else if (spawnconfig.equals("member")) {
if (regions.isMember(localPlayer)) {
player.teleportTo(spawn); player.teleportTo(spawn);
}
} else { } else {
player.teleportTo(spawn); player.teleportTo(spawn);
} }
} }
} }

View File

@ -157,8 +157,6 @@ public ApplicableRegionSet getApplicableRegions(Vector pt) {
} }
} }
// this allows parents not to overlap with their childs
return new ApplicableRegionSet(pt, appRegions, global); return new ApplicableRegionSet(pt, appRegions, global);
} }