Merge pull request #321 from GunfighterJ/patch-10

Fix array index out of bounds on /firework fire
This commit is contained in:
KHobbits 2013-02-11 08:41:47 -08:00
commit 8ea0a152d4
2 changed files with 15 additions and 12 deletions

View File

@ -85,24 +85,27 @@ public class Commandfirework extends EssentialsCommand
} }
stack.setItemMeta(fmeta); stack.setItemMeta(fmeta);
} }
else if ((args[0].equalsIgnoreCase("fire") || (args[0].equalsIgnoreCase("p"))) else if ((args[0].equalsIgnoreCase("fire") || (args[0].equalsIgnoreCase("f")))
&& user.isAuthorized("essentials.firework.fire")) && user.isAuthorized("essentials.firework.fire"))
{ {
int amount = 1; int amount = 1;
boolean direction = false; boolean direction = false;
if (Util.isInt(args[1])) if (args.length > 1)
{ {
final int serverLimit = ess.getSettings().getSpawnMobLimit(); if (Util.isInt(args[1]))
amount = Integer.parseInt(args[1]);
if (amount > serverLimit)
{ {
amount = serverLimit; final int serverLimit = ess.getSettings().getSpawnMobLimit();
user.sendMessage(_("mobSpawnLimit")); amount = Integer.parseInt(args[1]);
if (amount > serverLimit)
{
amount = serverLimit;
user.sendMessage(_("mobSpawnLimit"));
}
}
else
{
direction = true;
} }
}
else
{
direction = true;
} }
for (int i = 0; i < amount; i++) for (int i = 0; i < amount; i++)
{ {

View File

@ -121,7 +121,7 @@ commands:
aliases: [efireball,fireskull,efireskull,fireentity,efireentity] aliases: [efireball,fireskull,efireskull,fireentity,efireentity]
firework: firework:
description: Allows you to modify a stack of fireworks description: Allows you to modify a stack of fireworks
usage: /<command> <<meta param>|power [amount]|clear|fire> usage: /<command> <<meta param>|power [amount]|clear|fire [amount]>
aliases: [efirework] aliases: [efirework]
gamemode: gamemode:
description: Change player gamemode. description: Change player gamemode.