Replaced all usage of CreatureType by EntityType.

This commit is contained in:
TomyLobo 2012-03-02 20:13:45 +01:00
parent 37d52f3688
commit 8c8c162a54
4 changed files with 13 additions and 65 deletions

View File

@ -32,7 +32,7 @@
import com.sk89q.util.yaml.YAMLFormat;
import com.sk89q.util.yaml.YAMLProcessor;
import org.bukkit.block.Block;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import com.sk89q.worldguard.blacklist.Blacklist;
@ -112,7 +112,7 @@ public class WorldConfiguration {
public boolean useRegions;
public boolean highFreqFlags;
public int regionWand = 287;
public Set<CreatureType> blockCreatureSpawn;
public Set<EntityType> blockCreatureSpawn;
// public boolean useiConomy;
// public boolean buyOnClaim;
// public double buyOnClaimPrice;
@ -375,12 +375,14 @@ private void loadConfiguration() {
// buyOnClaim = getBoolean("iconomy.buy-on-claim", false);
// buyOnClaimPrice = getDouble("iconomy.buy-on-claim-price", 1.0);
blockCreatureSpawn = new HashSet<CreatureType>();
blockCreatureSpawn = new HashSet<EntityType>();
for (String creatureName : getStringList("mobs.block-creature-spawn", null)) {
CreatureType creature = CreatureType.fromName(creatureName);
EntityType creature = EntityType.fromName(creatureName);
if (creature == null) {
plugin.getLogger().warning("Unknown mob type '" + creatureName + "'");
} else if (!creature.isAlive()) {
plugin.getLogger().warning("Entity type '" + creatureName + "' is not a creature");
} else {
blockCreatureSpawn.add(creature);
}

View File

@ -29,11 +29,11 @@
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Creature;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Enderman;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Painting;
@ -628,9 +628,9 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
}
WorldConfiguration wcfg = cfg.get(event.getEntity().getWorld());
CreatureType creaType = event.getCreatureType();
EntityType entityType = event.getEntityType();
if (wcfg.blockCreatureSpawn.contains(creaType)) {
if (wcfg.blockCreatureSpawn.contains(entityType)) {
event.setCancelled(true);
return;
}
@ -649,8 +649,8 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
return;
}
Set<CreatureType> creatureTypes = set.getFlag(DefaultFlag.DENY_SPAWN);
if (creatureTypes != null && creatureTypes.contains(creaType)) {
Set<EntityType> entityTypes = set.getFlag(DefaultFlag.DENY_SPAWN);
if (entityTypes != null && entityTypes.contains(entityType)) {
event.setCancelled(true);
return;
}

View File

@ -1,54 +0,0 @@
// $Id$
/*
* WorldGuard
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.protection.flags;
import org.bukkit.entity.CreatureType;
/**
* Represents a creature type.
*
* @author sk89q
*/
public class CreatureTypeFlag extends EnumFlag<CreatureType> {
public CreatureTypeFlag(String name, RegionGroup defaultGroup) {
super(name, CreatureType.class, defaultGroup);
}
public CreatureTypeFlag(String name) {
super(name, CreatureType.class);
}
@Override
public CreatureType detectValue(String input) {
CreatureType lowMatch = null;
for (CreatureType type : CreatureType.values()) {
if (type.name().equalsIgnoreCase(input.trim())) {
return type;
}
if (type.name().toLowerCase().startsWith(input.toLowerCase().trim())) {
lowMatch = type;
}
}
return lowMatch;
}
}

View File

@ -19,7 +19,7 @@
package com.sk89q.worldguard.protection.flags;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.EntityType;
/**
*
@ -64,7 +64,7 @@ public final class DefaultFlag {
public static final StringFlag FAREWELL_MESSAGE = new StringFlag("farewell", RegionGroup.ALL);
public static final BooleanFlag NOTIFY_ENTER = new BooleanFlag("notify-enter", RegionGroup.ALL);
public static final BooleanFlag NOTIFY_LEAVE = new BooleanFlag("notify-leave", RegionGroup.ALL);
public static final SetFlag<CreatureType> DENY_SPAWN = new SetFlag<CreatureType>("deny-spawn", RegionGroup.ALL, new CreatureTypeFlag(null));
public static final SetFlag<EntityType> DENY_SPAWN = new SetFlag<EntityType>("deny-spawn", RegionGroup.ALL, new EntityTypeFlag(null));
public static final IntegerFlag HEAL_DELAY = new IntegerFlag("heal-delay", RegionGroup.ALL);
public static final IntegerFlag HEAL_AMOUNT = new IntegerFlag("heal-amount", RegionGroup.ALL);
public static final IntegerFlag MIN_HEAL = new IntegerFlag("heal-min-health", RegionGroup.ALL);