summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandspawner.java47
1 files changed, 22 insertions, 25 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java
index 1cd65a743..d2b50137d 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java
@@ -1,10 +1,7 @@
package com.earth2me.essentials.commands;
+import com.earth2me.essentials.*;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.Mob;
-import com.earth2me.essentials.Trade;
-import com.earth2me.essentials.User;
-import com.earth2me.essentials.Util;
import java.util.Locale;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -34,34 +31,34 @@ public class Commandspawner extends EssentialsCommand
throw new Exception(_("mobSpawnTarget"));
}
+ String name = args[0];
+
+ Mob mob = null;
+ mob = Mob.fromName(name);
+ if (mob == null)
+ {
+ throw new Exception(_("invalidMob"));
+ }
+ if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH)))
+ {
+ throw new Exception(_("disabledToSpawnMob"));
+ }
+ if (!user.isAuthorized("essentials.spawner." + mob.name.toLowerCase(Locale.ENGLISH)))
+ {
+ throw new Exception(_("noPermToSpawnMob"));
+ }
+ final Trade charge = new Trade("spawner-" + mob.name.toLowerCase(Locale.ENGLISH), ess);
+ charge.isAffordableFor(user);
try
{
- String name = args[0];
-
- Mob mob = null;
- mob = Mob.fromName(name);
- if (mob == null)
- {
- user.sendMessage(_("invalidMob"));
- return;
- }
- if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH)))
- {
- throw new Exception(_("unableToSpawnMob"));
- }
- if (!user.isAuthorized("essentials.spawner." + mob.name.toLowerCase(Locale.ENGLISH)))
- {
- throw new Exception(_("unableToSpawnMob"));
- }
- final Trade charge = new Trade("spawner-" + mob.name.toLowerCase(Locale.ENGLISH), ess);
- charge.isAffordableFor(user);
((CreatureSpawner)target.getBlock().getState()).setSpawnedType(mob.getType());
- charge.charge(user);
- user.sendMessage(_("setSpawner", mob.name));
}
catch (Throwable ex)
{
throw new Exception(_("mobSpawnError"), ex);
}
+ charge.charge(user);
+ user.sendMessage(_("setSpawner", mob.name));
+
}
}