summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIaccidentally <coryhuckaby@gmail.com>2013-01-17 14:59:01 -0800
committerIaccidentally <coryhuckaby@gmail.com>2013-01-17 14:59:01 -0800
commit855c0802f1a530976c7de40ae86ad52dda12ecc5 (patch)
treefed132817c0a9cf12f4e0c813f069cee2673fbe6
parentba6ab14b87b6036b64745f5d7cfc6645037b3ef4 (diff)
parentcb19a11c47343ec38b1abb4e5c36251973bac4b3 (diff)
downloadEssentials-855c0802f1a530976c7de40ae86ad52dda12ecc5.tar
Essentials-855c0802f1a530976c7de40ae86ad52dda12ecc5.tar.gz
Essentials-855c0802f1a530976c7de40ae86ad52dda12ecc5.tar.lz
Essentials-855c0802f1a530976c7de40ae86ad52dda12ecc5.tar.xz
Essentials-855c0802f1a530976c7de40ae86ad52dda12ecc5.zip
Merge pull request #263 from GunfighterJ/2.9
Added /firework command
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandfirework.java214
-rw-r--r--Essentials/src/messages.properties5
-rw-r--r--Essentials/src/messages_cs.properties6
-rw-r--r--Essentials/src/messages_da.properties5
-rw-r--r--Essentials/src/messages_de.properties5
-rw-r--r--Essentials/src/messages_en.properties5
-rw-r--r--Essentials/src/messages_es.properties5
-rw-r--r--Essentials/src/messages_fi.properties5
-rw-r--r--Essentials/src/messages_fr.properties5
-rw-r--r--Essentials/src/messages_it.properties5
-rw-r--r--Essentials/src/messages_nl.properties5
-rw-r--r--Essentials/src/messages_pl.properties5
-rw-r--r--Essentials/src/messages_pt.properties5
-rw-r--r--Essentials/src/messages_se.properties5
-rw-r--r--Essentials/src/plugin.yml6
15 files changed, 272 insertions, 14 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandfirework.java b/Essentials/src/com/earth2me/essentials/commands/Commandfirework.java
new file mode 100644
index 000000000..ddd1fc705
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandfirework.java
@@ -0,0 +1,214 @@
+package com.earth2me.essentials.commands;
+
+import com.earth2me.essentials.User;
+import static com.earth2me.essentials.I18n._;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+import org.bukkit.Color;
+import org.bukkit.DyeColor;
+import org.bukkit.FireworkEffect;
+import org.bukkit.Material;
+import org.bukkit.Server;
+import org.bukkit.entity.EntityType;
+import org.bukkit.entity.Firework;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.FireworkMeta;
+
+
+public class Commandfirework extends EssentialsCommand
+{
+ private final transient Pattern splitPattern = Pattern.compile("[:+',;.]");
+ private final static Map<String, DyeColor> colorMap = new HashMap<String, DyeColor>();
+ private final static Map<String, FireworkEffect.Type> fireworkShape = new HashMap<String, FireworkEffect.Type>();
+
+ static
+ {
+ for (DyeColor color : DyeColor.values())
+ {
+ colorMap.put(color.name(), color);
+ }
+ for (FireworkEffect.Type type : FireworkEffect.Type.values())
+ {
+ fireworkShape.put(type.name(), type);
+ }
+ }
+
+ public Commandfirework()
+ {
+ super("firework");
+ }
+
+ @Override
+ protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
+ {
+
+ if (args.length > 0)
+ {
+ ItemStack stack = user.getItemInHand();
+ if (stack.getType() == Material.FIREWORK)
+ {
+ FireworkEffect.Builder builder = FireworkEffect.builder();
+ FireworkMeta fmeta = (FireworkMeta)stack.getItemMeta();
+
+ if (args.length > 0)
+ {
+ if (args[0].equalsIgnoreCase("clear"))
+ {
+ fmeta.clearEffects();
+ stack.setItemMeta(fmeta);
+ }
+ else
+ {
+ List<Color> primaryColors = new ArrayList<Color>();
+ List<Color> fadeColors = new ArrayList<Color>();
+ FireworkEffect.Type finalEffect = null;
+
+ boolean valid = false;
+ boolean fire = false;
+ int amount = 1;
+ for (String arg : args)
+ {
+ final String[] split = splitPattern.split(arg, 2);
+ if (split[0].equalsIgnoreCase("color") || split[0].equalsIgnoreCase("colour") || split[0].equalsIgnoreCase("c"))
+ {
+ String[] colors = split[1].split(",");
+ for (String color : colors)
+ {
+ if (colorMap.containsKey(color.toUpperCase()))
+ {
+ valid = true;
+ primaryColors.add(colorMap.get(color.toUpperCase()).getFireworkColor());
+ }
+ else
+ {
+ user.sendMessage(_("invalidFireworkFormat", split[1], split[0]));
+ }
+ }
+ builder.withColor(primaryColors);
+ }
+ if (split[0].equalsIgnoreCase("shape") || split[0].equalsIgnoreCase("s") || split[0].equalsIgnoreCase("type") || split[0].equalsIgnoreCase("t"))
+ {
+ split[1] = (split[1].equalsIgnoreCase("large") ? "BALL_LARGE" : split[1]);
+ if (fireworkShape.containsKey(split[1].toUpperCase()))
+ {
+ finalEffect = fireworkShape.get(split[1].toUpperCase());
+ }
+ else
+ {
+ user.sendMessage(_("invalidFireworkFormat", split[1], split[0]));
+ }
+ if (finalEffect != null)
+ {
+ builder.with(finalEffect);
+ }
+ }
+ if (split[0].equalsIgnoreCase("fade") || split[0].equalsIgnoreCase("f"))
+ {
+ String[] colors = split[1].split(",");
+ for (String color : colors)
+ {
+ if (colorMap.containsKey(color.toUpperCase()))
+ {
+ fadeColors.add(colorMap.get(color.toUpperCase()).getFireworkColor());
+ }
+ else
+ {
+ user.sendMessage(_("invalidFireworkFormat", split[1], split[0]));
+ }
+ }
+ if (!fadeColors.isEmpty())
+ {
+ builder.withFade(fadeColors);
+ }
+ }
+ if (split[0].equalsIgnoreCase("effect") || split[0].equalsIgnoreCase("e"))
+ {
+ String[] effects = split[1].split(",");
+ for (String effect : effects)
+ {
+ if (effect.equalsIgnoreCase("twinkle"))
+ {
+ builder.flicker(true);
+ }
+ else if (effect.equalsIgnoreCase("trail"))
+ {
+ builder.trail(true);
+ }
+ else
+ {
+ user.sendMessage(_("invalidFireworkFormat", split[1], split[0]));
+ }
+ }
+ }
+ if (split[0].equalsIgnoreCase("power") || split[0].equalsIgnoreCase("p"))
+ {
+ try
+ {
+ fmeta.setPower(Integer.parseInt(split[1]));
+ }
+ catch (NumberFormatException e)
+ {
+ user.sendMessage(_("invalidFireworkFormat", split[1], split[0]));
+ }
+ }
+ if ((split[0].equalsIgnoreCase("fire") || split[0].equalsIgnoreCase("f")) && user.isAuthorized("essentials.firework.fire"))
+ {
+ fire = true;
+ try
+ {
+ amount = Integer.parseInt(split[1]);
+ int serverLimit = ess.getSettings().getSpawnMobLimit();
+ if(amount > serverLimit)
+ {
+ amount = serverLimit;
+ user.sendMessage(_("mobSpawnLimit"));
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ amount = 1;
+ }
+ }
+ }
+ if (valid)
+ {
+ if (fire)
+ {
+ for (int i = 0; i < amount; i++ )
+ {
+ Firework firework = (Firework)user.getWorld().spawnEntity(user.getLocation(), EntityType.FIREWORK);
+ FireworkMeta ffmeta = firework.getFireworkMeta();
+ ffmeta.addEffect(builder.build());
+ ffmeta.setPower(fmeta.getPower());
+ firework.setFireworkMeta(ffmeta);
+ }
+ }
+ else
+ {
+ final FireworkEffect effect = builder.build();
+ fmeta.addEffect(effect);
+ stack.setItemMeta(fmeta);
+ }
+ }
+ else
+ {
+ user.sendMessage(_("fireworkColor"));
+ }
+
+ }
+ }
+ }
+ else
+ {
+ user.sendMessage(_("holdFirework"));
+ }
+ }
+ else
+ {
+ throw new NotEnoughArgumentsException();
+ }
+ }
+}
diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties
index b5bdfc340..ceca9beb4 100644
--- a/Essentials/src/messages.properties
+++ b/Essentials/src/messages.properties
@@ -485,4 +485,7 @@ denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
-holdBook=\u00a74You are not holding a writable book \ No newline at end of file
+holdBook=\u00a74You are not holding a writable book
+fireworkColor=\u00a74You must apply a color to the firework to add an effect
+holdFirework=\u00a74You must be holding a firework to add effects
+invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
diff --git a/Essentials/src/messages_cs.properties b/Essentials/src/messages_cs.properties
index 56772abc7..5178598e8 100644
--- a/Essentials/src/messages_cs.properties
+++ b/Essentials/src/messages_cs.properties
@@ -488,4 +488,8 @@ denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
-holdBook=\u00a74You are not holding a writable book \ No newline at end of file
+holdBook=\u00a74You are not holding a writable book
+fireworkColor=\u00a74You must apply a color to the firework to add an effect
+holdFirework=\u00a74You must be holding a firework to add effects
+invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
+
diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties
index 3e13c65f5..106bea42a 100644
--- a/Essentials/src/messages_da.properties
+++ b/Essentials/src/messages_da.properties
@@ -485,4 +485,7 @@ denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
-holdBook=\u00a74You are not holding a writable book \ No newline at end of file
+holdBook=\u00a74You are not holding a writable book
+fireworkColor=\u00a74You must apply a color to the firework to add an effect
+holdFirework=\u00a74You must be holding a firework to add effects
+invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties
index 568b7f760..6f02ec613 100644
--- a/Essentials/src/messages_de.properties
+++ b/Essentials/src/messages_de.properties
@@ -485,4 +485,7 @@ denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
-holdBook=\u00a74You are not holding a writable book \ No newline at end of file
+holdBook=\u00a74You are not holding a writable book
+fireworkColor=\u00a74You must apply a color to the firework to add an effect
+holdFirework=\u00a74You must be holding a firework to add effects
+invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties
index b5bdfc340..ceca9beb4 100644
--- a/Essentials/src/messages_en.properties
+++ b/Essentials/src/messages_en.properties
@@ -485,4 +485,7 @@ denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
-holdBook=\u00a74You are not holding a writable book \ No newline at end of file
+holdBook=\u00a74You are not holding a writable book
+fireworkColor=\u00a74You must apply a color to the firework to add an effect
+holdFirework=\u00a74You must be holding a firework to add effects
+invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties
index 983bbb70b..25ae737ed 100644
--- a/Essentials/src/messages_es.properties
+++ b/Essentials/src/messages_es.properties
@@ -485,4 +485,7 @@ denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
-holdBook=\u00a74You are not holding a writable book \ No newline at end of file
+holdBook=\u00a74You are not holding a writable book
+fireworkColor=\u00a74You must apply a color to the firework to add an effect
+holdFirework=\u00a74You must be holding a firework to add effects
+invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
diff --git a/Essentials/src/messages_fi.properties b/Essentials/src/messages_fi.properties
index f64ad8cf2..6a18d49a1 100644
--- a/Essentials/src/messages_fi.properties
+++ b/Essentials/src/messages_fi.properties
@@ -485,4 +485,7 @@ denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
-holdBook=\u00a74You are not holding a writable book \ No newline at end of file
+holdBook=\u00a74You are not holding a writable book
+fireworkColor=\u00a74You must apply a color to the firework to add an effect
+holdFirework=\u00a74You must be holding a firework to add effects
+invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties
index 8d4116697..40deed6bd 100644
--- a/Essentials/src/messages_fr.properties
+++ b/Essentials/src/messages_fr.properties
@@ -485,4 +485,7 @@ denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
-holdBook=\u00a74You are not holding a writable book \ No newline at end of file
+holdBook=\u00a74You are not holding a writable book
+fireworkColor=\u00a74You must apply a color to the firework to add an effect
+holdFirework=\u00a74You must be holding a firework to add effects
+invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
diff --git a/Essentials/src/messages_it.properties b/Essentials/src/messages_it.properties
index 02ce6c483..addc32c3e 100644
--- a/Essentials/src/messages_it.properties
+++ b/Essentials/src/messages_it.properties
@@ -485,4 +485,7 @@ denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
-holdBook=\u00a74You are not holding a writable book \ No newline at end of file
+holdBook=\u00a74You are not holding a writable book
+fireworkColor=\u00a74You must apply a color to the firework to add an effect
+holdFirework=\u00a74You must be holding a firework to add effects
+invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties
index 81ae25e03..de37ddd68 100644
--- a/Essentials/src/messages_nl.properties
+++ b/Essentials/src/messages_nl.properties
@@ -485,4 +485,7 @@ denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
-holdBook=\u00a74You are not holding a writable book \ No newline at end of file
+holdBook=\u00a74You are not holding a writable book
+fireworkColor=\u00a74You must apply a color to the firework to add an effect
+holdFirework=\u00a74You must be holding a firework to add effects
+invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
diff --git a/Essentials/src/messages_pl.properties b/Essentials/src/messages_pl.properties
index 923e125f5..de9388897 100644
--- a/Essentials/src/messages_pl.properties
+++ b/Essentials/src/messages_pl.properties
@@ -485,4 +485,7 @@ denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
-holdBook=\u00a74You are not holding a writable book \ No newline at end of file
+holdBook=\u00a74You are not holding a writable book
+fireworkColor=\u00a74You must apply a color to the firework to add an effect
+holdFirework=\u00a74You must be holding a firework to add effects
+invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
diff --git a/Essentials/src/messages_pt.properties b/Essentials/src/messages_pt.properties
index f7ea1a220..028ea280f 100644
--- a/Essentials/src/messages_pt.properties
+++ b/Essentials/src/messages_pt.properties
@@ -485,4 +485,7 @@ denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
-holdBook=\u00a74You are not holding a writable book \ No newline at end of file
+holdBook=\u00a74You are not holding a writable book
+fireworkColor=\u00a74You must apply a color to the firework to add an effect
+holdFirework=\u00a74You must be holding a firework to add effects
+invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
diff --git a/Essentials/src/messages_se.properties b/Essentials/src/messages_se.properties
index a110218a3..d47289567 100644
--- a/Essentials/src/messages_se.properties
+++ b/Essentials/src/messages_se.properties
@@ -485,4 +485,7 @@ denyChangeAuthor=\u00a74You cannot change the author of this book
denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a7cThis book is now locked
-holdBook=\u00a74You are not holding a writable book \ No newline at end of file
+holdBook=\u00a74You are not holding a writable book
+fireworkColor=\u00a74You must apply a color to the firework to add an effect
+holdFirework=\u00a74You must be holding a firework to add effects
+invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml
index c7dd232e1..e830e77be 100644
--- a/Essentials/src/plugin.yml
+++ b/Essentials/src/plugin.yml
@@ -119,6 +119,10 @@ commands:
description: Throw a fireball.
usage: /<command> [small|skull]
aliases: [efireball,fireskull,efireskull,fireentity,efireentity]
+ firework:
+ description: Add or clears effects to a firework
+ usage: /<command> [clear|params]
+ aliases: [efirework]
gamemode:
description: Change player gamemode.
usage: /<command> <survival|creative|adventure> [player]
@@ -462,4 +466,4 @@ commands:
permissions:
essentials.*:
default: op
- description: Give players with op everything by default
+ description: Give players with op everything by default \ No newline at end of file