Skip to content

Commit

Permalink
Implements WORLDGUARD-2315 Enderdragon portal blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkArc committed Nov 24, 2012
1 parent 2e7ecc5 commit 0b3c40d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
37 changes: 15 additions & 22 deletions src/main/java/com/sk89q/worldguard/bukkit/ConfigurationManager.java
Expand Up @@ -18,6 +18,15 @@
*/
package com.sk89q.worldguard.bukkit;

import com.sk89q.commandbook.CommandBook;
import com.sk89q.commandbook.GodComponent;
import com.sk89q.util.yaml.YAMLFormat;
import com.sk89q.util.yaml.YAMLProcessor;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.blacklist.Blacklist;
import org.bukkit.World;
import org.bukkit.entity.Player;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
Expand All @@ -27,16 +36,6 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import com.sk89q.commandbook.CommandBook;
import com.sk89q.commandbook.GodComponent;
import com.sk89q.util.yaml.YAMLFormat;
import com.sk89q.util.yaml.YAMLProcessor;
import org.bukkit.World;
import org.bukkit.entity.Player;

import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.blacklist.Blacklist;

/**
* Represents the global configuration and also delegates configuration
* for individual worlds.
Expand Down Expand Up @@ -140,20 +139,14 @@ public void load() {
}

config.removeProperty("suppress-tick-sync-warnings");
useRegionsScheduler = config.getBoolean(
"regions.use-scheduler", true);
useRegionsCreatureSpawnEvent = config.getBoolean(
"regions.use-creature-spawn-event", true);
autoGodMode = config.getBoolean(
"auto-invincible", config.getBoolean("auto-invincible-permission", false));
useRegionsScheduler = config.getBoolean("regions.use-scheduler", true);
useRegionsCreatureSpawnEvent = config.getBoolean("regions.use-creature-spawn-event", true);
autoGodMode = config.getBoolean("auto-invincible", config.getBoolean("auto-invincible-permission", false));
config.removeProperty("auto-invincible-permission");
usePlayerMove = config.getBoolean(
"use-player-move-event", true);
usePlayerMove = config.getBoolean("use-player-move-event", true);

deopOnJoin = config.getBoolean(
"security.deop-everyone-on-join", false);
blockInGameOp = config.getBoolean(
"security.block-in-game-op-command", false);
deopOnJoin = config.getBoolean("security.deop-everyone-on-join", false);
blockInGameOp = config.getBoolean("security.block-in-game-op-command", false);

hostKeys = new HashMap<String, String>();
Object hostKeysRaw = config.getProperty("host-keys");
Expand Down
Expand Up @@ -98,6 +98,7 @@ public class WorldConfiguration {
public boolean blockWitherSkullExplosions;
public boolean blockWitherSkullBlockDamage;
public boolean blockEnderDragonBlockDamage;
public boolean blockEnderDragonPortalCreation;
public boolean blockFireballExplosions;
public boolean blockFireballBlockDamage;
public boolean blockEntityPaintingDestroy;
Expand Down Expand Up @@ -334,6 +335,7 @@ private void loadConfiguration() {
blockWitherSkullExplosions = getBoolean("mobs.block-wither-skull-explosions", false);
blockWitherSkullBlockDamage = getBoolean("mobs.block-wither-skull-block-damage", false);
blockEnderDragonBlockDamage = getBoolean("mobs.block-enderdragon-block-damage", false);
blockEnderDragonPortalCreation = getBoolean("mobs.block-enderdragon-portal-creation", false);
blockFireballExplosions = getBoolean("mobs.block-fireball-explosions", false);
blockFireballBlockDamage = getBoolean("mobs.block-fireball-block-damage", false);
antiWolfDumbness = getBoolean("mobs.anti-wolf-dumbness", false);
Expand Down
Expand Up @@ -27,10 +27,7 @@
import com.sk89q.worldguard.protection.events.DisallowedPVPEvent;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.managers.RegionManager;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
Expand Down Expand Up @@ -688,6 +685,18 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
}
}

@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onCreatePortal(EntityCreatePortalEvent event) {
ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(event.getEntity().getWorld());

switch (event.getEntityType()) {
case ENDER_DRAGON:
if (wcfg.blockEnderDragonBlockDamage) event.setCancelled(true);
break;
}
}

@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPigZap(PigZapEvent event) {
ConfigurationManager cfg = plugin.getGlobalStateManager();
Expand Down

0 comments on commit 0b3c40d

Please sign in to comment.