1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-06 22:56:41 +02:00

Fix /spawner command

The name had to be first letter uppercase, the rest lowercase
This commit is contained in:
snowleo
2011-06-27 11:57:03 +02:00
parent 3dc0659f66
commit 40e106db13

View File

@@ -6,6 +6,7 @@ import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.block.CraftCreatureSpawner;
import org.bukkit.entity.CreatureType;
@@ -19,12 +20,12 @@ public class Commandspawner extends EssentialsCommand
@Override
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
if (args.length < 1)
if (args.length < 1 || args[0].length() < 2)
{
throw new NotEnoughArgumentsException();
}
Block target = user.getTarget().getTargetBlock();
final Block target = user.getTarget().getTargetBlock();
if (target.getType() != Material.MOB_SPAWNER)
{
throw new Exception(Util.i18n("mobSpawnTarget"));
@@ -33,7 +34,8 @@ public class Commandspawner extends EssentialsCommand
charge(user);
try
{
((CreatureSpawner)target).setCreatureType(CreatureType.fromName(args[0]));
final String name = args[0].substring(0, 1).toUpperCase() + args[0].substring(1).toLowerCase();
new CraftCreatureSpawner(target).setCreatureType(CreatureType.fromName(name));
}
catch (Throwable ex)
{