Permalink
Browse files

Fixed PvP-mode bugs, test better next time.

  • Loading branch information...
1 parent 2db5685 commit c4785b7d1f499d883e5cc06a5229a6713580c14d @jhaegg committed Nov 22, 2011
View
@@ -1,6 +1,6 @@
name: MDFPvP
main: se.shard.kaustic.mdfpvp.MDFPvP
-version: 1.0.0-RC4
+version: 1.0.0-RC5
author: Johan Haegg
database: true
description: >
@@ -271,20 +271,22 @@ public boolean canOpenChest(Player player, Block chest) {
PlayerData owner = getOwnerData(chest.getChunk());
// Disallow stealing if both players are not in PvP mode.
- if(owner == null)
+ if(owner == null) {
return true;
- else {
- if(owner.equals(player))
+ }
+ else if (deathChest == null) {
+ System.out.println(plugin.isPvPEnabled(player) + " " + plugin.isPvPEnabled(owner.getPlayerUUID()));
+ if(owner.equals(player) || owner.getTenants().contains(player)) {
return true;
-
- if(plugin.isPvPEnabled(player) && plugin.isPvPEnabled(owner.getPlayerUUID()) && deathChest == null)
+ }
+ else if(plugin.isPvPEnabled(player) && plugin.isPvPEnabled(owner.getPlayerUUID())) {
return true;
+ }
+ return false;
}
-
PlayerData playerData = getPlayerData(player);
-
// Long way around due to problems with Avaje.
- return playerData.getDeathChest().equals(deathChest);
+ return deathChest.equals(playerData.getDeathChest());
}
/**
@@ -23,10 +23,12 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
if(plugin.canChangePvP(player)) {
if(plugin.isPvPEnabled(player)) {
player.setPlayerListName(player.getName());
+ plugin.setPvPEnabled(player, false);
plugin.getServer().broadcastMessage(player.getName() + " left PvP mode.");
}
else {
player.setPlayerListName(ChatColor.GOLD + player.getName());
+ plugin.setPvPEnabled(player, true);
plugin.getServer().broadcastMessage(player.getName() + " entered PvP mode.");
}
return true;
@@ -56,8 +56,8 @@ public void onEntityDamage(EntityDamageEvent event) {
if(subevent.getDamager() instanceof Player)
damager = (Player)subevent.getDamager();
else if(subevent.getDamager() instanceof Projectile) {
- if(((Projectile)subevent).getShooter() instanceof Player)
- damager = (Player)((Projectile)subevent).getShooter();
+ if(((Projectile)subevent.getDamager()).getShooter() instanceof Player)
+ damager = (Player)((Projectile)subevent.getDamager()).getShooter();
}
}
}
@@ -129,7 +129,7 @@ public void setProtect(boolean protect) {
public boolean equals(Object obj) {
if(obj instanceof Claim) {
Claim claim = (Claim)obj;
- return claim.worldUUID.equals(this.worldUUID) && claim.chunkX == this.chunkX && claim.chunkZ == this.chunkZ;
+ return claim.getWorldUUID().equals(this.getWorldUUID()) && claim.getChunkX() == this.getChunkX() && claim.getChunkZ() == this.getChunkZ();
}
return false;
}
@@ -133,11 +133,11 @@ public void setOwner(PlayerData owner) {
public boolean equals(Object obj) {
if(obj instanceof Block) {
Block block = (Block)obj;
- return this.worldUUID.equals(block.getWorld().getUID()) && this.posX == block.getX() && this.posY == block.getY() && this.posZ == block.getZ();
+ return this.getWorldUUID().equals(block.getWorld().getUID()) && this.getPosX() == block.getX() && this.getPosY() == block.getY() && this.getPosZ() == block.getZ();
}
else if(obj instanceof DeathChest) {
DeathChest deathChest = (DeathChest)obj;
- return this.worldUUID.equals(deathChest.worldUUID) && this.posX == deathChest.posX && this.posY == deathChest.posY && this.posZ == deathChest.posZ;
+ return this.getWorldUUID().equals(deathChest.getWorldUUID()) && this.getPosX() == deathChest.getPosX() && this.getPosY() == deathChest.getPosY() && this.getPosZ() == deathChest.getPosZ();
}
return false;
}
@@ -272,11 +272,11 @@ public boolean equals(Object obj) {
if(obj == null) {
return false;
}
- else if(obj instanceof PlayerData) {
- return ((PlayerData)obj).playerUUID.equals(this.playerUUID);
+ else if(obj instanceof PlayerData) {
+ return ((PlayerData)obj).getPlayerUUID().equals(this.getPlayerUUID());
}
- else if(obj instanceof Player) {
- return ((Player)obj).getUniqueId().equals(this.playerUUID);
+ else if(obj instanceof Player) {
+ return ((Player)obj).getUniqueId().equals(this.getPlayerUUID());
}
return false;
}

0 comments on commit c4785b7

Please sign in to comment.