Added mob type enum and subsequently removed case sensitivity from //set with mobspawners.

Dieser Commit ist enthalten in:
md-5 2011-09-06 18:06:17 +10:00 committet von Wizjany
Ursprung 1c4c621500
Commit 46ba1c7f5b
3 geänderte Dateien mit 63 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -377,17 +377,18 @@ public class WorldEdit {
} else if (blockType == BlockType.MOB_SPAWNER) {
if (args0.length > 1) {
String mobName = args0[1];
if (mobName.length() > 1) {
mobName = mobName.substring(0, 1).toUpperCase()
+ mobName.substring(1);
for (MobType mobType : MobType.values()){
if (mobType.getName().toLowerCase().equals(mobName.toLowerCase())){
mobName = mobType.getName();
break;
}
}
if (!server.isValidMobType(mobName)) {
throw new InvalidItemException(arg, "Unknown mob type '" + mobName + "'");
}
return new MobSpawnerBlock(data, args0[1]);
return new MobSpawnerBlock(data, mobName);
} else {
return new MobSpawnerBlock(data, "Pig");
return new MobSpawnerBlock(data, MobType.PIG.getName());
}
// Allow setting note

Datei anzeigen

@ -25,7 +25,7 @@ import java.util.Map;
import java.util.HashMap;
/**
* Represents chests.
* Represents mob spawners.
*
* @author sk89q
*/
@ -45,7 +45,7 @@ public class MobSpawnerBlock extends BaseBlock implements TileEntityBlock {
*/
public MobSpawnerBlock() {
super(BlockID.MOB_SPAWNER);
this.mobType = "Pig";
this.mobType = MobType.PIG.getName();
}
/**

Datei anzeigen

@ -0,0 +1,54 @@
// $Id$
/*
* WorldEdit
* 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.worldedit.blocks;
/**
* Represents the possible types of mobs.
*/
public enum MobType {
CAVE_SPIDER("CaveSpider"),
CHICKEN("Chicken"),
COW("Cow"),
CREEPER("Creeper"),
ENDERMAN("Enderman"),
GHAST("Ghast"),
GIANT("Giant"),
MONSTER("Monster"),
PIG("Pig"),
PIG_ZOMBIE("PigZombie"),
SHEEP("Sheep"),
SILVERFISH("Silverfish"),
SKELETON("Skeleton"),
SLIME("Slime"),
SPIDER("Spider"),
SQUID("Squid"),
ZOMBIE("Zombie"),
WOLF("Wolf");
private String name;
private MobType(String name) {
this.name = name;
}
public String getName() {
return name;
}
}