Revert /gc change.

Simplify firework syntax, and add help
Merge branch 'patch-26' of git://github.com/necrodoom/Essentials into 2.9
This commit is contained in:
KHobbits 2013-01-21 19:17:14 +00:00
parent 4663c89dd6
commit 51a55318d0
17 changed files with 141 additions and 122 deletions

View File

@ -137,6 +137,13 @@ public class MetaItemStack
meta.setTitle(title);
stack.setItemMeta(meta);
}
else if (split.length > 1 && split[0].equalsIgnoreCase("power") && stack.getType() == Material.FIREWORK)
{
final int power = Util.isInt(split[1]) ? Integer.parseInt(split[1]) : 0;
final FireworkMeta meta = (FireworkMeta)stack.getItemMeta();
meta.setPower(power > 3 ? 4 : power);
stack.setItemMeta(meta);
}
else if (stack.getType() == Material.FIREWORK) //WARNING - Meta for fireworks will be ignored after this point.
{
addFireworkMeta(user, false, string, ess);
@ -168,7 +175,7 @@ public class MetaItemStack
}
}
public void addFireworkMeta(final CommandSender user, final boolean allowShortName, final String string, final IEssentials ess)
public void addFireworkMeta(final CommandSender user, final boolean allowShortName, final String string, final IEssentials ess) throws Exception
{
if (stack.getType() == Material.FIREWORK)
{
@ -193,7 +200,9 @@ public class MetaItemStack
}
else
{
user.sendMessage(_("invalidFireworkFormat", split[1], split[0]));
user.sendMessage(_("fireworkSyntax"));
throw new Exception(_("invalidFireworkFormat", split[1], split[0]));
}
}
builder.withColor(primaryColors);
@ -208,7 +217,8 @@ public class MetaItemStack
}
else
{
user.sendMessage(_("invalidFireworkFormat", split[1], split[0]));
user.sendMessage(_("fireworkSyntax"));
throw new Exception(_("invalidFireworkFormat", split[1], split[0]));
}
if (finalEffect != null)
{
@ -227,7 +237,8 @@ public class MetaItemStack
}
else
{
user.sendMessage(_("invalidFireworkFormat", split[1], split[0]));
user.sendMessage(_("fireworkSyntax"));
throw new Exception(_("invalidFireworkFormat", split[1], split[0]));
}
}
if (!fadeColors.isEmpty())
@ -250,23 +261,11 @@ public class MetaItemStack
}
else
{
user.sendMessage(_("invalidFireworkFormat", split[1], split[0]));
user.sendMessage(_("fireworkSyntax"));
throw new Exception(_("invalidFireworkFormat", split[1], split[0]));
}
}
}
else if (split[0].equalsIgnoreCase("power") || (allowShortName && split[0].equalsIgnoreCase("p")))
{
try
{
int power = Integer.parseInt(split[1]);
fmeta.setPower(power > 3 ? 4 : power);
}
catch (NumberFormatException e)
{
user.sendMessage(_("invalidFireworkFormat", split[1], split[0]));
}
stack.setItemMeta(fmeta);
}
}
}

View File

@ -4,7 +4,6 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.MetaItemStack;
import com.earth2me.essentials.User;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import org.bukkit.DyeColor;
@ -42,8 +41,6 @@ public class Commandfirework extends EssentialsCommand
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (args.length > 0)
{
final ItemStack stack = user.getItemInHand();
if (stack.getType() == Material.FIREWORK)
@ -55,68 +52,68 @@ public class Commandfirework extends EssentialsCommand
FireworkMeta fmeta = (FireworkMeta)stack.getItemMeta();
fmeta.clearEffects();
stack.setItemMeta(fmeta);
user.sendMessage(_("fireworkEffectsCleared"));
}
else
else if (args.length > 1 && (args[0].equalsIgnoreCase("power") || (args[0].equalsIgnoreCase("p"))))
{
final MetaItemStack mStack = new MetaItemStack(stack);
boolean fire = false;
int amount = 1;
for (String arg : args)
{
final String[] split = splitPattern.split(arg, 2);
mStack.addFireworkMeta(user, true, arg, ess);
if (split.length > 1 && split[0].equalsIgnoreCase("fire") && user.isAuthorized("essentials.firework.fire"))
{
fire = true;
FireworkMeta fmeta = (FireworkMeta)stack.getItemMeta();
try
{
amount = Integer.parseInt(split[1]);
int serverLimit = ess.getSettings().getSpawnMobLimit();
int power = Integer.parseInt(args[1]);
fmeta.setPower(power > 3 ? 4 : power);
}
catch (NumberFormatException e)
{
throw new Exception(_("invalidFireworkFormat", args[1], args[0]));
}
stack.setItemMeta(fmeta);
}
else if ((args[0].equalsIgnoreCase("fire") || (args[0].equalsIgnoreCase("p")))
&& user.isAuthorized("essentials.firework.fire"))
{
int amount;
try
{
final int serverLimit = ess.getSettings().getSpawnMobLimit();
amount = Integer.parseInt(args[1]);
if (amount > serverLimit)
{
amount = serverLimit;
user.sendMessage(_("mobSpawnLimit"));
}
}
catch (NumberFormatException e)
catch (Exception e)
{
amount = 1;
}
}
}
if (fire)
{
for (int i = 0; i < amount; i++)
{
Firework firework = (Firework)user.getWorld().spawnEntity(user.getLocation(), EntityType.FIREWORK);
FireworkMeta fmeta = (FireworkMeta)mStack.getItemStack().getItemMeta();
if (mStack.isValidFirework())
{
FireworkEffect effect = mStack.getFireworkBuilder().build();
fmeta.addEffect(effect);
}
FireworkMeta fmeta = (FireworkMeta)stack.getItemMeta();
firework.setFireworkMeta(fmeta);
}
}
else if (!mStack.isValidFirework())
{
user.sendMessage(_("fireworkColor"));
}
else
{
final MetaItemStack mStack = new MetaItemStack(stack);
for (String arg : args)
{
final String[] split = splitPattern.split(arg, 2);
mStack.addFireworkMeta(user, true, arg, ess);
}
if (mStack.isValidFirework())
{
FireworkMeta fmeta = (FireworkMeta)mStack.getItemStack().getItemMeta();
FireworkEffect effect = mStack.getFireworkBuilder().build();
fmeta.addEffect(effect);
stack.setItemMeta(fmeta);
}
}
}
}
else
{
user.sendMessage(_("holdFirework"));
user.sendMessage(_("fireworkSyntax"));
throw new Exception(_("fireworkColor"));
}
}
}
else
@ -124,4 +121,9 @@ public class Commandfirework extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
}
else
{
throw new Exception(_("holdFirework"));
}
}
}

View File

@ -42,12 +42,6 @@ public class Commandgc extends EssentialsCommand
sender.sendMessage(_("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
List<World> worlds = server.getWorlds();
if (worlds.size() > 3 && args.length == 0)
{
sender.sendMessage(_("messageTruncated", commandLabel, "all"));
}
else
{
for (World w : worlds)
{
String worldType = "World";
@ -64,6 +58,4 @@ public class Commandgc extends EssentialsCommand
sender.sendMessage(_("gcWorld", worldType, w.getName(), w.getLoadedChunks().length, w.getEntities().size()));
}
}
}
}

View File

@ -486,7 +486,7 @@ denyChangeTitle=\u00a74You cannot change the title of this book
denyBookEdit=\u00a74You cannot unlock this book
bookLocked=\u00a76This book is now locked
holdBook=\u00a74You are not holding a writable book
fireworkColor=\u00a74Error: \u00a7cInvalid firework charge parameters inserted, must set a color first.
fireworkColor=\u00a7cInvalid firework charge parameters inserted, must set a color first.
holdFirework=\u00a74You must be holding a firework to add effects
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}
@ -494,3 +494,5 @@ resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76for all online playe
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond
fireworkEffectsCleared=\u00a76Removed all effects from held stack.
fireworkSyntax=\u00a76Firework parameters:\u00a7c color:<color> [fade:<color>] [shape:<shape>] [effect:<effect>]\n\u00a76To use multiple colors/effects, seperate values with commas: \u00a7cred,blue,pink\n\u00a76Shapes:\u00a7c star, ball, large, creeper, burst \u00a76Effects:\u00a7c trail, twinkle

View File

@ -497,3 +497,5 @@ resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online play
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond
fireworkEffectsCleared=\u00a76Removed all effects from held stack.
fireworkSyntax=\u00a76Firework parameters:\u00a7c color:<color> [fade:<color>] [shape:<shape>] [effect:<effect>]\n\u00a76To use multiple colors/effects, seperate values with commas: \u00a7cred,blue,pink\n\u00a76Shapes:\u00a7c star, ball, large, creeper, burst \u00a76Effects:\u00a7c trail, twinkle

View File

@ -494,3 +494,5 @@ resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online play
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond
fireworkEffectsCleared=\u00a76Removed all effects from held stack.
fireworkSyntax=\u00a76Firework parameters:\u00a7c color:<color> [fade:<color>] [shape:<shape>] [effect:<effect>]\n\u00a76To use multiple colors/effects, seperate values with commas: \u00a7cred,blue,pink\n\u00a76Shapes:\u00a7c star, ball, large, creeper, burst \u00a76Effects:\u00a7c trail, twinkle

View File

@ -494,3 +494,5 @@ resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online play
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond
fireworkEffectsCleared=\u00a76Removed all effects from held stack.
fireworkSyntax=\u00a76Firework parameters:\u00a7c color:<color> [fade:<color>] [shape:<shape>] [effect:<effect>]\n\u00a76To use multiple colors/effects, seperate values with commas: \u00a7cred,blue,pink\n\u00a76Shapes:\u00a7c star, ball, large, creeper, burst \u00a76Effects:\u00a7c trail, twinkle

View File

@ -494,3 +494,5 @@ resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76for all online playe
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond
fireworkEffectsCleared=\u00a76Removed all effects from held stack.
fireworkSyntax=\u00a76Firework parameters:\u00a7c color:<color> [fade:<color>] [shape:<shape>] [effect:<effect>]\n\u00a76To use multiple colors/effects, seperate values with commas: \u00a7cred,blue,pink\n\u00a76Shapes:\u00a7c star, ball, large, creeper, burst \u00a76Effects:\u00a7c trail, twinkle

View File

@ -494,3 +494,5 @@ resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online play
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond
fireworkEffectsCleared=\u00a76Removed all effects from held stack.
fireworkSyntax=\u00a76Firework parameters:\u00a7c color:<color> [fade:<color>] [shape:<shape>] [effect:<effect>]\n\u00a76To use multiple colors/effects, seperate values with commas: \u00a7cred,blue,pink\n\u00a76Shapes:\u00a7c star, ball, large, creeper, burst \u00a76Effects:\u00a7c trail, twinkle

View File

@ -494,3 +494,5 @@ resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online play
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond
fireworkEffectsCleared=\u00a76Removed all effects from held stack.
fireworkSyntax=\u00a76Firework parameters:\u00a7c color:<color> [fade:<color>] [shape:<shape>] [effect:<effect>]\n\u00a76To use multiple colors/effects, seperate values with commas: \u00a7cred,blue,pink\n\u00a76Shapes:\u00a7c star, ball, large, creeper, burst \u00a76Effects:\u00a7c trail, twinkle

View File

@ -494,3 +494,5 @@ resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online play
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond
fireworkEffectsCleared=\u00a76Removed all effects from held stack.
fireworkSyntax=\u00a76Firework parameters:\u00a7c color:<color> [fade:<color>] [shape:<shape>] [effect:<effect>]\n\u00a76To use multiple colors/effects, seperate values with commas: \u00a7cred,blue,pink\n\u00a76Shapes:\u00a7c star, ball, large, creeper, burst \u00a76Effects:\u00a7c trail, twinkle

View File

@ -494,3 +494,5 @@ resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online play
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond
fireworkEffectsCleared=\u00a76Removed all effects from held stack.
fireworkSyntax=\u00a76Firework parameters:\u00a7c color:<color> [fade:<color>] [shape:<shape>] [effect:<effect>]\n\u00a76To use multiple colors/effects, seperate values with commas: \u00a7cred,blue,pink\n\u00a76Shapes:\u00a7c star, ball, large, creeper, burst \u00a76Effects:\u00a7c trail, twinkle

View File

@ -494,3 +494,5 @@ resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online play
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond
fireworkEffectsCleared=\u00a76Removed all effects from held stack.
fireworkSyntax=\u00a76Firework parameters:\u00a7c color:<color> [fade:<color>] [shape:<shape>] [effect:<effect>]\n\u00a76To use multiple colors/effects, seperate values with commas: \u00a7cred,blue,pink\n\u00a76Shapes:\u00a7c star, ball, large, creeper, burst \u00a76Effects:\u00a7c trail, twinkle

View File

@ -494,3 +494,5 @@ resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online play
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond
fireworkEffectsCleared=\u00a76Removed all effects from held stack.
fireworkSyntax=\u00a76Firework parameters:\u00a7c color:<color> [fade:<color>] [shape:<shape>] [effect:<effect>]\n\u00a76To use multiple colors/effects, seperate values with commas: \u00a7cred,blue,pink\n\u00a76Shapes:\u00a7c star, ball, large, creeper, burst \u00a76Effects:\u00a7c trail, twinkle

View File

@ -494,3 +494,5 @@ resetBal=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all online play
resetBalAll=\u00a76Balance has been reset to \u00a7a{0} \u00a76 for all players
messageTruncated=\u00a74Message truncated, to see the full output type:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75is currently AFK and may not respond
fireworkEffectsCleared=\u00a76Removed all effects from held stack.
fireworkSyntax=\u00a76Firework parameters:\u00a7c color:<color> [fade:<color>] [shape:<shape>] [effect:<effect>]\n\u00a76To use multiple colors/effects, seperate values with commas: \u00a7cred,blue,pink\n\u00a76Shapes:\u00a7c star, ball, large, creeper, burst \u00a76Effects:\u00a7c trail, twinkle

View File

@ -467,30 +467,32 @@ teleportationDisabledFor=\u00a76Teleportering inaktiverat f\u00f6r {0}
kitOnce=\u00a74Du kan inte av\u00e4nda det kitet igen.
fullStack=\u00a74Du har redan en full stapel
oversizedTempban=\u00a74Du kan inte banna en spelare just vid denna tidpunkt.
recipeNone=Inga recept existerar för {0}
recipeNone=Inga recept existerar f\u00c3\u00b6r {0}
invalidNumber=Felaktigt nummer
recipeBadIndex=Det finns inget recept med det numret
recipeNothing=ingenting
recipe=\u00a76Recept för \u00a7c{0}\u00a76 ({1} av {2})
recipeFurnace=\u00a76Smält \u00a7c{0}
recipe=\u00a76Recept f\u00c3\u00b6r \u00a7c{0}\u00a76 ({1} av {2})
recipeFurnace=\u00a76Sm\u00c3\u00a4lt \u00a7c{0}
recipeGrid=\u00a7{0}X \u00a76| \u00a7{1}X \u00a76| \u00a7{2}X
recipeGridItem=\ \u00a7{0}X \u00a76är \u00a7c{1}
recipeMore=\u00a76Skriv /{0} \u00a7c{1}\u00a76 <nummer> för att se andra recept för \u00a7c{2}
recipeGridItem=\ \u00a7{0}X \u00a76\u00c3\u00a4r \u00a7c{1}
recipeMore=\u00a76Skriv /{0} \u00a7c{1}\u00a76 <nummer> f\u00c3\u00b6r att se andra recept f\u00c3\u00b6r \u00a7c{2}
recipeWhere=\u00a76Var: {0}
recipeShapeless=\u00a76Kombinera \u00a7c{0}
editBookContents=\u00a7eDu kan nu ändra innehållet i denna bok
bookAuthorSet=\u00a76Författaren av boken är nu{0}
bookTitleSet=\u00a76Titeln av boken har blivit ändrad till {0}
denyChangeAuthor=\u00a74Du kan inte byta författare på denna bok
denyChangeTitle=\u00a74Du kan inte byta titel på denna bok
denyBookEdit=\u00a74Du kan inte låsa upp denna boken
bookLocked=\u00a7cDenna bok är nu låst
holdBook=\u00a74Boken du håller i är inte skrivbar
fireworkColor=\u00a74Du måste lägga till en färg till fyrverkeripjäsen för att lägga till en effekt
holdFirework=\u00a74Du måste hålla i en fyrverkeripjäs för att lägga till effekter
invalidFireworkFormat=\u00a76Alternativet \u00a74{0} \u00a76is är inte ett korrekt alternativ för \u00a74{1}
editBookContents=\u00a7eDu kan nu \u00c3\u00a4ndra inneh\u00c3\u00a5llet i denna bok
bookAuthorSet=\u00a76F\u00c3\u00b6rfattaren av boken \u00c3\u00a4r nu{0}
bookTitleSet=\u00a76Titeln av boken har blivit \u00c3\u00a4ndrad till {0}
denyChangeAuthor=\u00a74Du kan inte byta f\u00c3\u00b6rfattare p\u00c3\u00a5 denna bok
denyChangeTitle=\u00a74Du kan inte byta titel p\u00c3\u00a5 denna bok
denyBookEdit=\u00a74Du kan inte l\u00c3\u00a5sa upp denna boken
bookLocked=\u00a7cDenna bok \u00c3\u00a4r nu l\u00c3\u00a5st
holdBook=\u00a74Boken du h\u00c3\u00a5ller i \u00c3\u00a4r inte skrivbar
fireworkColor=\u00a74Du m\u00c3\u00a5ste l\u00c3\u00a4gga till en f\u00c3\u00a4rg till fyrverkeripj\u00c3\u00a4sen f\u00c3\u00b6r att l\u00c3\u00a4gga till en effekt
holdFirework=\u00a74Du m\u00c3\u00a5ste h\u00c3\u00a5lla i en fyrverkeripj\u00c3\u00a4s f\u00c3\u00b6r att l\u00c3\u00a4gga till effekter
invalidFireworkFormat=\u00a76Alternativet \u00a74{0} \u00a76is \u00c3\u00a4r inte ett korrekt alternativ f\u00c3\u00b6r \u00a74{1}
muteNotify=\u00a74{0} \u00a76har tystat \u00a74{1}
resetBal=\u00a76Balansen har blivit återställd till \u00a7a{0} \u00a76 för alla spelare som är online
resetBalAll=\u00a76Balansen har blivit återställd till \u00a7a{0} \u00a76 för alla spelare
messageTruncated=\u00a74Meddelandet har blivit förkortat, för att se allt, skriv:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75är för närvarande borta och svarar kanske inte
resetBal=\u00a76Balansen har blivit \u00c3\u00a5terst\u00c3\u00a4lld till \u00a7a{0} \u00a76 f\u00c3\u00b6r alla spelare som \u00c3\u00a4r online
resetBalAll=\u00a76Balansen har blivit \u00c3\u00a5terst\u00c3\u00a4lld till \u00a7a{0} \u00a76 f\u00c3\u00b6r alla spelare
messageTruncated=\u00a74Meddelandet har blivit f\u00c3\u00b6rkortat, f\u00c3\u00b6r att se allt, skriv:\u00a7c /{0} {1}
userAFK=\u00a75{0} \u00a75\u00c3\u00a4r f\u00c3\u00b6r n\u00c3\u00a4rvarande borta och svarar kanske inte
fireworkEffectsCleared=\u00a76Removed all effects from held stack.
fireworkSyntax=\u00a76Firework parameters:\u00a7c color:<color> [fade:<color>] [shape:<shape>] [effect:<effect>]\n\u00a76To use multiple colors/effects, seperate values with commas: \u00a7cred,blue,pink\n\u00a76Shapes:\u00a7c star, ball, large, creeper, burst \u00a76Effects:\u00a7c trail, twinkle

View File

@ -120,8 +120,8 @@ commands:
usage: /<command> [small|skull]
aliases: [efireball,fireskull,efireskull,fireentity,efireentity]
firework:
description: Adds a charge or clears all effects of a firework
usage: /<command> [clear|fire|power|params]
description: Allows you to modify a stack of fireworks
usage: /<command> [<meta param>|power [amount]|clear]
aliases: [efirework]
gamemode:
description: Change player gamemode.