Merge remote-tracking branch 'origin/master'

This commit is contained in:
Alex Stewart
2020-02-26 02:59:48 -05:00
2 changed files with 15 additions and 2 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ public class CommandColor extends Command
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res) public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
{ {
// First, try and parse out the color to make sure we can even get it. // First, try and parse out the color to make sure we can even get it.
ColorData colorData = theColorAPI.lookupHex(input.args.trim()); ColorData colorData = theColorAPI.lookupHex(input.args);
// Verify the color was even found // Verify the color was even found
if(colorData == null) if(colorData == null)
+14 -1
View File
@@ -73,9 +73,22 @@ public class NetworkTheColorAPI
public ColorData lookupHex(String hex) public ColorData lookupHex(String hex)
{ {
if(hex == null)
return null;
hex = hex.replace("#", "").trim();
int len = hex.length();
if(len == 0)
return null;
// Verify we're either a full or half length color. Intermediate colors not supported.
// Alpha is also not supported.
if(len != 6 && len != 3)
return null;
try try
{ {
hex = hex.replace("#", "").trim();
String hexUpper = hex.toUpperCase(); String hexUpper = hex.toUpperCase();
// Verify the number is hex. // Verify the number is hex.