= Removed old test and improved image utils
This commit is contained in:
@@ -46,18 +46,25 @@ public class CommandColor extends Command
|
|||||||
graphics.setColor(parsed);
|
graphics.setColor(parsed);
|
||||||
graphics.fillRect(0, 0, sideLength, sideLength);
|
graphics.fillRect(0, 0, sideLength, sideLength);
|
||||||
graphics.dispose();
|
graphics.dispose();
|
||||||
|
|
||||||
GlobalLog.Log("2");
|
GlobalLog.Log("2");
|
||||||
|
|
||||||
String tempFileName = ImageUtils.writeTempImageData(img, ".png");
|
String tempFileName = ImageUtils.writeTempImageData(img, ".png");
|
||||||
File file = new File(tempFileName);
|
File file = new File(tempFileName);
|
||||||
|
|
||||||
GlobalLog.Log("3");
|
GlobalLog.Log("3");
|
||||||
|
|
||||||
KittyEmbed response = new KittyEmbed();
|
KittyEmbed response = new KittyEmbed();
|
||||||
response.title = "Color Name";
|
response.title = "Color Name";
|
||||||
response.color = parsed;
|
response.color = parsed;
|
||||||
response.descriptionText = "`rgba` test\n`hex` test\n`hsv` test";
|
response.descriptionText = "`rgba` test\n`hex` test\n`hsv` test";
|
||||||
response.thumbnailURL = "attachment://" + tempFileName;
|
response.thumbnailURL = "attachment://" + tempFileName;
|
||||||
|
|
||||||
GlobalLog.Log("4");
|
GlobalLog.Log("4");
|
||||||
|
|
||||||
res.CallEmbed(response);
|
res.CallEmbed(response);
|
||||||
ImageUtils.BlockingFileDelete(file);
|
ImageUtils.BlockingFileDelete(file);
|
||||||
|
|
||||||
GlobalLog.Log("5");
|
GlobalLog.Log("5");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -35,9 +35,15 @@ public class Response
|
|||||||
EmbedBuilder embed = new EmbedBuilder();
|
EmbedBuilder embed = new EmbedBuilder();
|
||||||
|
|
||||||
if(embedInfo.title != null && !embedInfo.title.isEmpty())
|
if(embedInfo.title != null && !embedInfo.title.isEmpty())
|
||||||
|
{
|
||||||
embed.setTitle(embedInfo.title);
|
embed.setTitle(embedInfo.title);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
// We have to set the title to at least something that's not empty.
|
||||||
|
// By defualt, this creates nothing really visible.
|
||||||
embed.setTitle(" ");
|
embed.setTitle(" ");
|
||||||
|
}
|
||||||
|
|
||||||
if(embedInfo.color != null)
|
if(embedInfo.color != null)
|
||||||
embed.setColor(embedInfo.color);
|
embed.setColor(embedInfo.color);
|
||||||
@@ -61,6 +67,7 @@ public class Response
|
|||||||
String thumbPath = embedInfo.thumbnailURL;
|
String thumbPath = embedInfo.thumbnailURL;
|
||||||
String thumbName = thumbPath.replace("attachment://", "");
|
String thumbName = thumbPath.replace("attachment://", "");
|
||||||
|
|
||||||
|
// Build the message and send if the file is valid
|
||||||
MessageBuilder message = new MessageBuilder();
|
MessageBuilder message = new MessageBuilder();
|
||||||
embed.setThumbnail(thumbPath);
|
embed.setThumbnail(thumbPath);
|
||||||
message.setEmbed(embed.build());
|
message.setEmbed(embed.build());
|
||||||
|
|||||||
@@ -22,13 +22,26 @@ public class ImageUtils
|
|||||||
String name = null;
|
String name = null;
|
||||||
synchronized(uniqueID)
|
synchronized(uniqueID)
|
||||||
{
|
{
|
||||||
name = "imagetempwriterutil_" + (uniqueID++) + extension;
|
String end = extension;
|
||||||
|
if(!extension.contains("."))
|
||||||
|
{
|
||||||
|
end = "." + extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
name = "imagetempwriterutil_" + (uniqueID++) + end;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File outputfile = new File(name);
|
File outputfile = new File(name);
|
||||||
ImageIO.write(data, extension, outputfile);
|
extension = extension.replace(".", "");
|
||||||
|
|
||||||
|
boolean didWrite = ImageIO.write(data, extension, outputfile);
|
||||||
|
if(!didWrite)
|
||||||
|
{
|
||||||
|
GlobalLog.Error(LogFilter.Util, "Could not identify the writer for extension type '" + extension + "' - Did you accidentally include a period or other punctuation?");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user