Skip to content

Commit

Permalink
Various fixes, readded /zclaim and added protectedblocks list for dyn…
Browse files Browse the repository at this point in the history
…amite.
  • Loading branch information
Meaglin committed May 21, 2012
1 parent a1cd392 commit ba7218b
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 8 deletions.
8 changes: 5 additions & 3 deletions src/com/zones/command/AdminCommands.java
Expand Up @@ -59,9 +59,11 @@ private void addAdmin(Player owner, ZoneNormal zone, String username) {
)
public void removeAdmin(Player player, String[] params) {
ZoneNormal zone = (ZoneNormal)getSelectedZone(player);
if(zone instanceof ZoneInherit && !((ZoneInherit)zone).isInheritAdmin(player) ) {
player.sendMessage(ChatColor.RED + "You're not allowed to remove admins in this zone.");
return;
if(zone instanceof ZoneInherit) {
if(!((ZoneInherit)zone).isInheritAdmin(player)) {
player.sendMessage(ChatColor.RED + "You're not allowed to remove admins in this zone.");
return;
}
} else if(!canUseCommand(player,"zones.admin")) {
player.sendMessage(ChatColor.RED + "You're not allowed to remove admins from zones.");
return;
Expand Down
16 changes: 16 additions & 0 deletions src/com/zones/command/MiscCommands.java
Expand Up @@ -10,6 +10,7 @@
import com.zones.ZonesConfig;
import com.zones.model.WorldConfig;
import com.zones.model.ZoneBase;
import com.zones.model.types.ZonePlot;

public class MiscCommands extends CommandsBase {

Expand Down Expand Up @@ -128,4 +129,19 @@ public void test(Player player, String[] params) {
// player.sendMessage(file.substring(0, file.length() > 100 ? 100 : file.length()));
ZonesConfig.setDatabaseVersion(new File(getPlugin().getDataFolder(), ZonesConfig.ZONES_CONFIG_FILE), Integer.parseInt(params[0]));
}

@Command(
name = "zclaim",
description = "Claim the zone you're currently standing in.",
requiresPlayer = true,
requiredPermission = "zones.claim"
)
public void run(Player player, String[] vars) {
ZoneBase zone = getPlugin().getWorldManager(player).getActiveZone(player);
if(!(zone instanceof ZonePlot)) {
zone.sendMarkupMessage(ChatColor.RED + "You cannot claim {zname} since it's not a claimable zone.", player);
return;
}
((ZonePlot)zone).claim(player);
}
}
6 changes: 6 additions & 0 deletions src/com/zones/config/world.properties
Expand Up @@ -51,6 +51,12 @@ CreeperExplosionRange = 3
# Default: true
ExplosionDamageEntities = true

# Protect certain blocks from being destroyed by explosions.
# Default: false
DynamiteProtectedBlocksEnabled = false
# List of protected blocks id's
DynamiteProtectedBlocks =

# Allow usage of the lighter in this world, player with the following permission can always use a lighter:
# zones.override.lighter
# Default: true
Expand Down
20 changes: 17 additions & 3 deletions src/com/zones/listeners/ZonesEntityListener.java
@@ -1,5 +1,7 @@
package com.zones.listeners;

import java.util.Iterator;

import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Creeper;
Expand Down Expand Up @@ -117,17 +119,29 @@ public void onEntityExplode(EntityExplodeEvent event) {
if(event.getEntity() instanceof Creeper) {
if(!wm.getConfig().ALLOW_CREEPER_TRIGGER) {
event.setCancelled(true);
return;
}
} else {
if(!wm.getConfig().DYNAMITE_ENABLED) {
event.setCancelled(true);
return;
}
}
} else {
if (!((BlockResolver)zone.getResolver(AccessResolver.DYNAMITE)).isAllowed(zone, event.getLocation().getBlock()))
if (!((BlockResolver)zone.getResolver(AccessResolver.DYNAMITE)).isAllowed(zone, event.getLocation().getBlock())) {
event.setCancelled(true);
return;
}
}

if(wm.getConfig().EXPLOSION_PROTECTED_BLOCKS_ENABLED && wm.getConfig().EXPLOSION_PROTECTED_BLOCKS.size() != 0) {
Iterator<Block> it = event.blockList().iterator();
while(it.hasNext()) {
Block b = it.next();
if(wm.getConfig().EXPLOSION_PROTECTED_BLOCKS.contains(b.getTypeId())) {
it.remove();
}
}
}
}

@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
Expand Down Expand Up @@ -201,7 +215,7 @@ public void onExplosionPrime(ExplosionPrimeEvent event) {
if(event.getEntity() instanceof Creeper) {
event.setRadius(wm.getConfig().CREEPER_EXPLOSION_RANGE);
} else if (event.getEntity() instanceof TNTPrimed ) {
event.setRadius(wm.getConfig().TNT_RANGE);
event.setRadius(wm.getConfig().DYNAMITE_RANGE);
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/com/zones/listeners/ZonesPlayerListener.java
Expand Up @@ -9,6 +9,7 @@
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.StorageMinecart;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
Expand All @@ -33,7 +34,9 @@
import com.zones.accessresolver.interfaces.PlayerHitEntityResolver;
import com.zones.accessresolver.interfaces.PlayerLocationResolver;
import com.zones.model.ZoneBase;
import com.zones.model.ZonesAccess.Rights;
import com.zones.model.settings.ZoneVar;
import com.zones.model.types.ZoneNormal;
import com.zones.selection.ZoneSelection;
import com.zones.selection.ZoneSelection.Confirm;

Expand Down Expand Up @@ -420,6 +423,13 @@ public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
event.setCancelled(true);
return;
}
} else if (target instanceof StorageMinecart) {
ZoneBase zone = plugin.getWorldManager(target.getWorld()).getActiveZone(target.getLocation());
if(zone != null && zone instanceof ZoneNormal && !((ZoneNormal)zone).canModify(player, Rights.MODIFY)){
zone.sendMarkupMessage(ZonesConfig.PLAYER_CANT_MODIFY_BLOCKS_IN_ZONE, player);
event.setCancelled(true);
return;
}
}
}
}
10 changes: 8 additions & 2 deletions src/com/zones/model/WorldConfig.java
Expand Up @@ -46,8 +46,11 @@ public class WorldConfig {
public boolean BORDER_OVERRIDE_ENABLED;

public boolean DYNAMITE_ENABLED;
public int TNT_RANGE;
public int DYNAMITE_RANGE;
public boolean EXPLOSION_DAMAGE_ENTITIES;
public boolean EXPLOSION_PROTECTED_BLOCKS_ENABLED;
public List<Integer> EXPLOSION_PROTECTED_BLOCKS;


public boolean ALLOW_CREEPER_TRIGGER;
public int CREEPER_EXPLOSION_RANGE;
Expand Down Expand Up @@ -193,13 +196,16 @@ public void load() {
BORDER_OVERRIDE_ENABLED = p.getBool("BorderOverrideEnabled", true);

DYNAMITE_ENABLED = p.getBool("AllowTntTrigger", true);
TNT_RANGE = p.getInt("TntRange", 4);
DYNAMITE_RANGE = p.getInt("TntRange", 4);

ALLOW_CREEPER_TRIGGER = p.getBool("AllowCreeperTrigger", true);
CREEPER_EXPLOSION_RANGE = p.getInt("CreeperExplosionRange", 3);

EXPLOSION_DAMAGE_ENTITIES = p.getBool("ExplosionDamageEntities", true);

EXPLOSION_PROTECTED_BLOCKS_ENABLED = p.getBool("ExplosionProtectedBlocksEnabled", false);
EXPLOSION_PROTECTED_BLOCKS = p.getIntList("ExplosionProtectedBlocks", "");

LIGHTER_ALLOWED = p.getBool("LighterAllowed", true);
FIRE_ENABLED = p.getBool("FireEnabled", true);
LAVA_FIRE_ENABLED = p.getBool("LavaFireEnabled", true);
Expand Down

0 comments on commit ba7218b

Please sign in to comment.