mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-01 23:23:31 +01:00
Properly validate shulker color in command
This commit is contained in:
parent
6c9ba07737
commit
4b95ebb427
@ -1514,6 +1514,10 @@ public class NPCCommands {
|
|||||||
}
|
}
|
||||||
if (args.hasValueFlag("color")) {
|
if (args.hasValueFlag("color")) {
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("color"));
|
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("color"));
|
||||||
|
if (color == null) {
|
||||||
|
Messaging.sendErrorTr(sender, Messages.INVALID_SHULKER_COLOR, Util.listValuesPretty(DyeColor.values()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
trait.setColor(color);
|
trait.setColor(color);
|
||||||
Messaging.sendTr(sender, Messages.SHULKER_COLOR_SET, npc.getName(), Util.prettyEnum(color));
|
Messaging.sendTr(sender, Messages.SHULKER_COLOR_SET, npc.getName(), Util.prettyEnum(color));
|
||||||
hasArg = true;
|
hasArg = true;
|
||||||
|
@ -26,6 +26,9 @@ public class ShulkerTrait extends Trait {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (color == null) {
|
||||||
|
color = DyeColor.PURPLE;
|
||||||
|
}
|
||||||
if (npc.getEntity() instanceof Shulker) {
|
if (npc.getEntity() instanceof Shulker) {
|
||||||
NMS.setShulkerPeek((Shulker) npc.getEntity(), peek);
|
NMS.setShulkerPeek((Shulker) npc.getEntity(), peek);
|
||||||
NMS.setShulkerColor((Shulker) npc.getEntity(), color);
|
NMS.setShulkerColor((Shulker) npc.getEntity(), color);
|
||||||
|
@ -114,6 +114,7 @@ public class Messages {
|
|||||||
public static final String INVALID_RABBIT_TYPE = "citizens.commands.npc.rabbittype.invalid-type";
|
public static final String INVALID_RABBIT_TYPE = "citizens.commands.npc.rabbittype.invalid-type";
|
||||||
public static final String INVALID_SCRIPT_FILE = "citizens.commands.npc.script.invalid-file";
|
public static final String INVALID_SCRIPT_FILE = "citizens.commands.npc.script.invalid-file";
|
||||||
public static final String INVALID_SHEEP_COLOR = "citizens.commands.npc.sheep.invalid-color";
|
public static final String INVALID_SHEEP_COLOR = "citizens.commands.npc.sheep.invalid-color";
|
||||||
|
public static final String INVALID_SHULKER_COLOR = "citizens.commands.npc.shulker.invalid-color";
|
||||||
public static final String INVALID_SKELETON_TYPE = "citizens.commands.npc.skeletontype.invalid-type";
|
public static final String INVALID_SKELETON_TYPE = "citizens.commands.npc.skeletontype.invalid-type";
|
||||||
public static final String INVALID_SOUND = "citizens.commands.npc.sound.invalid-sound";
|
public static final String INVALID_SOUND = "citizens.commands.npc.sound.invalid-sound";
|
||||||
public static final String INVALID_SPAWN_LOCATION = "citizens.commands.npc.create.invalid-location";
|
public static final String INVALID_SPAWN_LOCATION = "citizens.commands.npc.create.invalid-location";
|
||||||
|
@ -112,9 +112,12 @@ citizens.commands.npc.respawn.delay-set=Respawn delay set to [[{0}]].
|
|||||||
citizens.commands.npc.respawn.describe=Respawn delay is currently [[{0}]].
|
citizens.commands.npc.respawn.describe=Respawn delay is currently [[{0}]].
|
||||||
citizens.commands.npc.select.already-selected=You already have that NPC selected.
|
citizens.commands.npc.select.already-selected=You already have that NPC selected.
|
||||||
citizens.commands.npc.script.invalid-file=Unknown or unavailable script ''[[{0}]]''.
|
citizens.commands.npc.script.invalid-file=Unknown or unavailable script ''[[{0}]]''.
|
||||||
|
citizens.commands.npc.sheep.color-set=The sheep''s color was set to [[{0}]].
|
||||||
|
citizens.commands.npc.sheep.invalid-color=Invalid sheep color given. Valid colors are: [[{0}]].
|
||||||
citizens.commands.npc.script.current-scripts=[[{0}]]''s current scripts are [[{1}]].
|
citizens.commands.npc.script.current-scripts=[[{0}]]''s current scripts are [[{1}]].
|
||||||
citizens.commands.npc.shulker.peek-set=[[{0}]]''s peek amount set to [[{1}]].
|
citizens.commands.npc.shulker.peek-set=[[{0}]]''s peek amount set to [[{1}]].
|
||||||
citizens.commands.npc.shulker.color-set=[[{0}]]''s color set to [[{1}]].
|
citizens.commands.npc.shulker.color-set=[[{0}]]''s color set to [[{1}]].
|
||||||
|
citizens.commands.npc.shulker.invalid-color=Invalid shulker color given. Valid colors are: [[{0}]].
|
||||||
citizens.commands.npc.skin.set=[[{0}]]''s skin name set to [[{1}]].
|
citizens.commands.npc.skin.set=[[{0}]]''s skin name set to [[{1}]].
|
||||||
citizens.commands.npc.skin.missing-skin=A skin name is required.
|
citizens.commands.npc.skin.missing-skin=A skin name is required.
|
||||||
citizens.commands.npc.skin.cleared=[[{0}]]''s skin name was cleared.
|
citizens.commands.npc.skin.cleared=[[{0}]]''s skin name was cleared.
|
||||||
|
Loading…
Reference in New Issue
Block a user