= 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.fillRect(0, 0, sideLength, sideLength);
|
||||
graphics.dispose();
|
||||
|
||||
GlobalLog.Log("2");
|
||||
|
||||
String tempFileName = ImageUtils.writeTempImageData(img, ".png");
|
||||
File file = new File(tempFileName);
|
||||
|
||||
GlobalLog.Log("3");
|
||||
|
||||
KittyEmbed response = new KittyEmbed();
|
||||
response.title = "Color Name";
|
||||
response.color = parsed;
|
||||
response.descriptionText = "`rgba` test\n`hex` test\n`hsv` test";
|
||||
response.thumbnailURL = "attachment://" + tempFileName;
|
||||
|
||||
GlobalLog.Log("4");
|
||||
|
||||
res.CallEmbed(response);
|
||||
ImageUtils.BlockingFileDelete(file);
|
||||
|
||||
GlobalLog.Log("5");
|
||||
};
|
||||
|
||||
|
||||
@@ -35,9 +35,15 @@ public class Response
|
||||
EmbedBuilder embed = new EmbedBuilder();
|
||||
|
||||
if(embedInfo.title != null && !embedInfo.title.isEmpty())
|
||||
{
|
||||
embed.setTitle(embedInfo.title);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We have to set the title to at least something that's not empty.
|
||||
// By defualt, this creates nothing really visible.
|
||||
embed.setTitle(" ");
|
||||
}
|
||||
|
||||
if(embedInfo.color != null)
|
||||
embed.setColor(embedInfo.color);
|
||||
@@ -61,6 +67,7 @@ public class Response
|
||||
String thumbPath = embedInfo.thumbnailURL;
|
||||
String thumbName = thumbPath.replace("attachment://", "");
|
||||
|
||||
// Build the message and send if the file is valid
|
||||
MessageBuilder message = new MessageBuilder();
|
||||
embed.setThumbnail(thumbPath);
|
||||
message.setEmbed(embed.build());
|
||||
|
||||
@@ -22,13 +22,26 @@ public class ImageUtils
|
||||
String name = null;
|
||||
synchronized(uniqueID)
|
||||
{
|
||||
name = "imagetempwriterutil_" + (uniqueID++) + extension;
|
||||
String end = extension;
|
||||
if(!extension.contains("."))
|
||||
{
|
||||
end = "." + extension;
|
||||
}
|
||||
|
||||
name = "imagetempwriterutil_" + (uniqueID++) + end;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user