Merge branch 'master' into nimitz-v2

Conflicts:
	war/src/main/java/com/tommytony/war/Warzone.java
This commit is contained in:
cmastudios 2013-12-24 20:40:35 -06:00
commit 0af348f2cb
3 changed files with 34 additions and 2 deletions

View File

@ -1874,4 +1874,13 @@ public class Warzone {
stmt.close();
}
}
/**
* Check if a player has stolen from a warzone flag, bomb, or cake.
* @param suspect Player to check.
* @return true if suspect has stolen a structure.
*/
public boolean isThief(String suspect) {
return this.isFlagThief(suspect) || this.isBombThief(suspect) || this.isCakeThief(suspect);
}
}

View File

@ -147,8 +147,8 @@ public class WarBlockListener implements Listener {
}
// unbreakableZoneBlocks
if (zone != null && zone.getWarzoneConfig().getBoolean(WarzoneConfig.UNBREAKABLE)
|| (team != null && !team.getTeamConfig().resolveBoolean(TeamConfig.PLACEBLOCK))
if (zone != null && (zone.getWarzoneConfig().getBoolean(WarzoneConfig.UNBREAKABLE)
|| (team != null && !team.getTeamConfig().resolveBoolean(TeamConfig.PLACEBLOCK)))
&& (!isZoneMaker || (isZoneMaker && team != null))) {
// if the zone is unbreakable, no one but zone makers can break blocks (even then, zone makers in a team can't break blocks)
War.war.badMsg(player, "build.denied.zone.place");

View File

@ -17,6 +17,8 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.*;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
@ -413,6 +415,7 @@ public class WarPlayerListener implements Listener {
War.war.getWarHub().getLocation() : playerWarzone.getTeleport(), event, true);
return;
}
return;
}
}
@ -882,6 +885,26 @@ public class WarPlayerListener implements Listener {
}
}
@EventHandler
public void onInventoryClick(final InventoryClickEvent event) {
if (!(event.getWhoClicked() instanceof Player)) {
return;
}
Player player = (Player) event.getWhoClicked();
Warzone zone = Warzone.getZoneByPlayerName(player.getName());
if (zone == null) {
return;
}
// Prevent thieves from taking their bomb/wool/cake into a chest, etc.
if (zone.isThief(player.getName())
// Prevent player from grabbing their block helmet
|| event.getSlotType() == InventoryType.SlotType.ARMOR && event.getSlot() == 39
&& zone.getWarzoneConfig().getBoolean(WarzoneConfig.BLOCKHEADS)) {
event.setCancelled(true);
player.playSound(player.getLocation(), Sound.FIZZ, 10, 10);
}
}
public void purgeLatestPositions() {
this.latestLocations.clear();
}