mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-28 19:11:53 +01:00
Show warning when invalid mob type is specified for /remove
This commit is contained in:
parent
723e458a81
commit
5b64c31e86
@ -71,23 +71,23 @@ public class Commandremove extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
for (String s : args[0].split(","))
|
||||
for (String entityType : args[0].split(","))
|
||||
{
|
||||
ToRemove toRemove;
|
||||
try
|
||||
{
|
||||
toRemove = ToRemove.valueOf(s.toUpperCase(Locale.ENGLISH));
|
||||
toRemove = ToRemove.valueOf(entityType.toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
try
|
||||
{
|
||||
toRemove = ToRemove.valueOf(s.concat("S").toUpperCase(Locale.ENGLISH));
|
||||
toRemove = ToRemove.valueOf(entityType.concat("S").toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
toRemove = ToRemove.CUSTOM;
|
||||
customTypes.add(s);
|
||||
customTypes.add(entityType);
|
||||
}
|
||||
}
|
||||
types.add(toRemove.toString());
|
||||
@ -105,12 +105,33 @@ public class Commandremove extends EssentialsCommand
|
||||
}
|
||||
|
||||
ArrayList<ToRemove> removeTypes = new ArrayList<ToRemove>();
|
||||
ArrayList<Mob> customRemoveTypes = new ArrayList<Mob>();
|
||||
|
||||
for (String s : types)
|
||||
{
|
||||
removeTypes.add(ToRemove.valueOf(s));
|
||||
}
|
||||
|
||||
boolean warnUser = false;
|
||||
|
||||
for (String s : customTypes)
|
||||
{
|
||||
Mob mobType = Mob.fromName(s);
|
||||
if (mobType == null)
|
||||
{
|
||||
warnUser = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
customRemoveTypes.add(mobType);
|
||||
}
|
||||
}
|
||||
|
||||
if (warnUser)
|
||||
{
|
||||
sender.sendMessage(_("invalidMob"));
|
||||
}
|
||||
|
||||
for (Chunk chunk : world.getLoadedChunks())
|
||||
{
|
||||
for (Entity e : chunk.getEntities())
|
||||
@ -242,9 +263,9 @@ public class Commandremove extends EssentialsCommand
|
||||
}
|
||||
break;
|
||||
case CUSTOM:
|
||||
for (String type : customTypes)
|
||||
for (Mob type : customRemoveTypes)
|
||||
{
|
||||
if (e.getType() == Mob.fromName(type).getType())
|
||||
if (e.getType() == type.getType())
|
||||
{
|
||||
e.remove();
|
||||
removed++;
|
||||
|
@ -171,7 +171,7 @@ invalidCharge=\u00a74Invalid charge.
|
||||
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}\u00a76.
|
||||
invalidHome=\u00a74Home\u00a7c {0} \u00a74doesn''t exist\!
|
||||
invalidHomeName=\u00a74Invalid home name\!
|
||||
invalidMob=Invalid mob type.
|
||||
invalidMob=\u00a74Invalid mob type.
|
||||
invalidNumber=Invalid Number.
|
||||
invalidPotion=\u00a74Invalid Potion.
|
||||
invalidPotionMeta=\u00a74Invalid potion meta\: \u00a7c{0}\u00a74.
|
||||
|
@ -171,7 +171,7 @@ invalidCharge=\u00a74Invalid charge.
|
||||
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}\u00a76.
|
||||
invalidHome=\u00a74Home\u00a7c {0} \u00a74doesn''t exist\!
|
||||
invalidHomeName=\u00a74Invalid home name\!
|
||||
invalidMob=Invalid mob type.
|
||||
invalidMob=\u00a74Invalid mob type.
|
||||
invalidNumber=Invalid Number.
|
||||
invalidPotion=\u00a74Invalid Potion.
|
||||
invalidPotionMeta=\u00a74Invalid potion meta\: \u00a7c{0}\u00a74.
|
||||
|
Loading…
Reference in New Issue
Block a user