blob: e92b29a9312878bca935e56fc195891d1396df8d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Mob;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner;
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();
//TODO: user.sendMessage("§7Mobs: Zombie PigZombie Skeleton Slime Chicken Pig Monster Spider Creeper Ghast Squid Giant Cow Sheep Wolf");
}
final Location target = Util.getTarget(user);
if (target == null || target.getBlock().getType() != Material.MOB_SPAWNER)
{
throw new Exception(_("mobSpawnTarget"));
}
try
{
String name = args[0];
Mob mob = null;
mob = Mob.fromName(name);
if (mob == null)
{
user.sendMessage(_("invalidMob"));
return;
}
((CreatureSpawner)target.getBlock().getState()).setCreatureType(mob.getType());
user.sendMessage(_("setSpawner", mob.name));
}
catch (Throwable ex)
{
throw new Exception(_("mobSpawnError"), ex);
}
}
}
|