summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2011-08-19 12:06:35 +0100
committerKHobbits <rob@khobbits.co.uk>2011-08-19 12:06:35 +0100
commita2f727bebcccfed44e604fbc09327c408b50919d (patch)
tree3577549dd17779ecb616883d912e1c4b45368daf
parent2b48045a8fddbe6b09fbfbcd100de729b89e226a (diff)
downloadEssentials-a2f727bebcccfed44e604fbc09327c408b50919d.tar
Essentials-a2f727bebcccfed44e604fbc09327c408b50919d.tar.gz
Essentials-a2f727bebcccfed44e604fbc09327c408b50919d.tar.lz
Essentials-a2f727bebcccfed44e604fbc09327c408b50919d.tar.xz
Essentials-a2f727bebcccfed44e604fbc09327c408b50919d.zip
Success message on /spawner
Switch to use mob class.
-rw-r--r--Essentials/src/com/earth2me/essentials/Mob.java3
-rw-r--r--Essentials/src/com/earth2me/essentials/Util.java5
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandspawner.java19
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java17
-rw-r--r--Essentials/src/messages.properties1
-rw-r--r--Essentials/src/messages_da.properties1
-rw-r--r--Essentials/src/messages_de.properties1
-rw-r--r--Essentials/src/messages_en.properties1
-rw-r--r--Essentials/src/messages_fr.properties1
-rw-r--r--Essentials/src/messages_nl.properties1
10 files changed, 34 insertions, 16 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Mob.java b/Essentials/src/com/earth2me/essentials/Mob.java
index f5e1aea3d..5ada086d9 100644
--- a/Essentials/src/com/earth2me/essentials/Mob.java
+++ b/Essentials/src/com/earth2me/essentials/Mob.java
@@ -86,6 +86,9 @@ public enum Mob
final protected String type;
}
+ public CreatureType getType () {
+ return bukkitType;
+ }
public static class MobException extends Exception
{
diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java
index 614e9b2b9..82231cb06 100644
--- a/Essentials/src/com/earth2me/essentials/Util.java
+++ b/Essentials/src/com/earth2me/essentials/Util.java
@@ -483,4 +483,9 @@ public class Util
}
return buf.toString();
}
+
+ public static String capitalCase(String s)
+ {
+ return s.toUpperCase().charAt(0) + s.toLowerCase().substring(1);
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java
index ae92670ca..15f5910af 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java
@@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
+import com.earth2me.essentials.Mob;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Material;
@@ -22,6 +23,7 @@ public class Commandspawner extends EssentialsCommand
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 Block target = user.getTarget().getTargetBlock();
@@ -33,11 +35,18 @@ public class Commandspawner extends EssentialsCommand
charge(user);
try
{
- String name = args[0].substring(0, 1).toUpperCase() + args[0].substring(1).toLowerCase();
- if (name.equalsIgnoreCase("Pigzombie")) {
- name = "PigZombie";
- }
- new CraftCreatureSpawner(target).setCreatureType(CreatureType.fromName(name));
+ String name = args[0];
+ name = name.equalsIgnoreCase("PigZombie") ? "PigZombie" : Util.capitalCase(name);
+
+ Mob mob = null;
+ mob = Mob.fromName(name);
+ if (mob == null)
+ {
+ user.sendMessage(Util.i18n("invalidMob"));
+ return;
+ }
+ new CraftCreatureSpawner(target).setCreatureType(mob.getType());
+ user.sendMessage(Util.format("setSpawner", mob.name));
}
catch (Throwable ex)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
index 86d2beac4..188edab27 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
@@ -40,7 +40,7 @@ public class Commandspawnmob extends EssentialsCommand
String[] mountparts = args[0].split(",");
String[] parts = mountparts[0].split(":");
String mobType = parts[0];
- mobType = mobType.equalsIgnoreCase("PigZombie") ? "PigZombie" : capitalCase(mobType);
+ mobType = mobType.equalsIgnoreCase("PigZombie") ? "PigZombie" : Util.capitalCase(mobType);
String mobData = null;
if (parts.length == 2)
{
@@ -52,7 +52,7 @@ public class Commandspawnmob extends EssentialsCommand
{
parts = mountparts[1].split(":");
mountType = parts[0];
- mountType = mountType.equalsIgnoreCase("PigZombie") ? "PigZombie" : capitalCase(mountType);
+ mountType = mountType.equalsIgnoreCase("PigZombie") ? "PigZombie" : Util.capitalCase(mountType);
if (parts.length == 2)
{
mountData = parts[1];
@@ -186,11 +186,6 @@ public class Commandspawnmob extends EssentialsCommand
}
}
- private String capitalCase(String s)
- {
- return s.toUpperCase().charAt(0) + s.toLowerCase().substring(1);
- }
-
private void changeMobData(String type, Entity spawned, String data, User user) throws Exception
{
if ("Slime".equalsIgnoreCase(type))
@@ -210,11 +205,11 @@ public class Commandspawnmob extends EssentialsCommand
{
if (data.equalsIgnoreCase("random"))
{
- Random rand = new Random();
- ((CraftSheep)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
+ Random rand = new Random();
+ ((CraftSheep)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
}
- else
- {
+ else
+ {
((CraftSheep)spawned).setColor(DyeColor.valueOf(data.toUpperCase()));
}
}
diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties
index 9bbcd7a87..912b14c67 100644
--- a/Essentials/src/messages.properties
+++ b/Essentials/src/messages.properties
@@ -240,6 +240,7 @@ seconds = seconds
seenOffline = Player {0} is offline since {1}
seenOnline = Player {0} is online since {1}
serverFull = Server is full
+setSpawner = Changed spawner type to {0}
sheepMalformedColor = Malformed color.
shoutFormat = \u00a77[Shout]\u00a7f {0}
similarWarpExist = A warp with a similar name already exists.
diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties
index de0c930bc..37f5449ec 100644
--- a/Essentials/src/messages_da.properties
+++ b/Essentials/src/messages_da.properties
@@ -240,6 +240,7 @@ seconds = sekunder
seenOffline = Spiller {0} er offline siden {1}
seenOnline = Spiller {0} er online siden {1}
serverFull = Server er fuld
+setSpawner = Changed spawner type to {0}
sheepMalformedColor = Misdannet farve.
shoutFormat = \u00a77[R\u00e5b]\u00a7f {0}
similarWarpExist = En warp med lignende tekst eksisterer allerede.
diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties
index 3da16d3f9..c9b6e2705 100644
--- a/Essentials/src/messages_de.properties
+++ b/Essentials/src/messages_de.properties
@@ -238,6 +238,7 @@ seconds = Sekunden
seenOffline = Spieler {0} ist offline seit {1}
seenOnline = Spieler {0} ist online seit {1}
serverFull = Server ist voll
+setSpawner = Changed spawner type to {0}
sheepMalformedColor = Ung\u00fcltige Farbe.
shoutFormat = \u00a77[Schrei]\u00a7f {0}
similarWarpExist = Ein Warp-Punkt mit einem \u00e4hnlichen Namen existiert bereits.
diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties
index 84a843dc7..244340750 100644
--- a/Essentials/src/messages_en.properties
+++ b/Essentials/src/messages_en.properties
@@ -240,6 +240,7 @@ seconds = seconds
seenOffline = Player {0} is offline since {1}
seenOnline = Player {0} is online since {1}
serverFull = Server is full
+setSpawner = Changed spawner type to {0}
sheepMalformedColor = Malformed color.
shoutFormat = \u00a77[Shout]\u00a7f {0}
similarWarpExist = A warp with a similar name already exists.
diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties
index a4c007a1a..af74e9fff 100644
--- a/Essentials/src/messages_fr.properties
+++ b/Essentials/src/messages_fr.properties
@@ -238,6 +238,7 @@ seconds = secondes
seenOffline = Le joueur {0} est hors ligne depuis {1}
seenOnline = Le joueur {0} est en ligne depuis {1}
serverFull = Le serveur est plein.
+setSpawner = Changed spawner type to {0}
sheepMalformedColor = Couleur mal form\u00e9e.
shoutFormat = \u00a77[Crie]\u00a7f {0}
similarWarpExist = Un warp avec un nom similaire existe d\u00e9j\u00e0.
diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties
index 375d9248f..8d0c2ac77 100644
--- a/Essentials/src/messages_nl.properties
+++ b/Essentials/src/messages_nl.properties
@@ -239,6 +239,7 @@ seconds = seconde
seenOffline = Speler {0} is offline vanaf {1}
seenOnline = Speler {0} is online vanaf {1}
serverFull = Server is vol
+setSpawner = Changed spawner type to {0}
sheepMalformedColor = Misvoormde kleur.
shoutFormat = \u00a77[Shout]\u00a7f {0}
similarWarpExist = Er bestaat al een warp met dezelfde naam.