Skip to content

Commit

Permalink
Fix crash when trying to set a colour not from the list
Browse files Browse the repository at this point in the history
Added a check and throws an error message now
  • Loading branch information
uberifix committed Feb 5, 2020
1 parent f5e3019 commit 5962c73
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ private static int setColour(CommandSource source, TextFormatting colour) {
if (!Configuration.ALLOW_CUSTOM.get()) {
source.sendErrorMessage(new StringTextComponent("Command is disabled by config").applyTextStyle(TextFormatting.RED));
return 0;
} else if (colour == null) {
source.sendErrorMessage(new StringTextComponent("Invalid colour specified").applyTextStyle(TextFormatting.RED));
return 0;
} else {
ColouredChat.getCap(source.getEntity()).ifPresent(colourData -> {
if (!colourData.getUsePlayerColour()) colourData.setUsePlayerColour(true);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/network/pxl8/colouredchat/lib/LibColour.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public static TextFormatting getColourFromName(String colour) {
case("RED"): return TextFormatting.RED;
case("LIGHT_PURPLE"): return TextFormatting.LIGHT_PURPLE;
case("YELLOW"): return TextFormatting.YELLOW;
default: return null;
}
return null;
}

public static TextFormatting randomFormattedColour() {
Expand Down

0 comments on commit 5962c73

Please sign in to comment.