mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-19 06:58:17 +00:00
45 lines
1.1 KiB
Java
45 lines
1.1 KiB
Java
package com.earth2me.essentials.commands;
|
|
|
|
import com.earth2me.essentials.User;
|
|
import com.earth2me.essentials.Util;
|
|
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;
|
|
|
|
|
|
public class Commandspawner extends EssentialsCommand
|
|
{
|
|
public Commandspawner()
|
|
{
|
|
super("spawner");
|
|
}
|
|
|
|
@Override
|
|
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
|
{
|
|
if (args.length < 1 || args[0].length() < 2)
|
|
{
|
|
throw new NotEnoughArgumentsException();
|
|
}
|
|
|
|
final Block target = user.getTarget().getTargetBlock();
|
|
if (target.getType() != Material.MOB_SPAWNER)
|
|
{
|
|
throw new Exception(Util.i18n("mobSpawnTarget"));
|
|
}
|
|
|
|
charge(user);
|
|
try
|
|
{
|
|
final String name = args[0].substring(0, 1).toUpperCase() + args[0].substring(1).toLowerCase();
|
|
new CraftCreatureSpawner(target).setCreatureType(CreatureType.fromName(name));
|
|
}
|
|
catch (Throwable ex)
|
|
{
|
|
throw new Exception(Util.i18n("mobSpawnError"), ex);
|
|
}
|
|
}
|
|
}
|