mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-30 22:44:07 +01:00
fixed logical error in playerlistener
This commit is contained in:
parent
9d813290c6
commit
7bedf6bb15
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,8 +141,8 @@ public void onPlayerItem(PlayerItemEvent event) {
|
|||||||
if (wcfg.getBlacklist() != null && item != null && block != null) {
|
if (wcfg.getBlacklist() != null && item != null && block != null) {
|
||||||
if (!wcfg.getBlacklist().check(
|
if (!wcfg.getBlacklist().check(
|
||||||
new ItemUseBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, player),
|
new ItemUseBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, player),
|
||||||
toVector(block.getRelative(event.getBlockFace())),
|
toVector(block.getRelative(event.getBlockFace())),
|
||||||
item.getTypeId()), false, false)) {
|
item.getTypeId()), false, false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
@ -259,22 +252,25 @@ public void onPlayerRespawn(PlayerRespawnEvent event) {
|
|||||||
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
|
||||||
ApplicableRegionSet regions = plugin.getGlobalRegionManager().getRegionManager(
|
ApplicableRegionSet regions = plugin.getGlobalRegionManager().getRegionManager(
|
||||||
player.getWorld().getName()).getApplicableRegions(
|
player.getWorld().getName()).getApplicableRegions(
|
||||||
BukkitUtil.toVector(location));
|
BukkitUtil.toVector(location));
|
||||||
|
|
||||||
BukkitPlayer localPlayer = BukkitPlayer.wrapPlayer(cfg, player);
|
BukkitPlayer localPlayer = BukkitPlayer.wrapPlayer(cfg, player);
|
||||||
|
|
||||||
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")) {
|
||||||
player.teleportTo(spawn);
|
if (regions.isOwner(localPlayer)) {
|
||||||
} else if (spawnconfig.equals("member") && regions.isMember(localPlayer)) {
|
player.teleportTo(spawn);
|
||||||
player.teleportTo(spawn);
|
}
|
||||||
|
} else if (spawnconfig.equals("member")) {
|
||||||
|
if (regions.isMember(localPlayer)) {
|
||||||
|
player.teleportTo(spawn);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
player.teleportTo(spawn);
|
player.teleportTo(spawn);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user