mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-25 03:55:35 +01:00
Allow other image urls
This commit is contained in:
parent
acca995aa5
commit
59ab56bdd7
@ -87,13 +87,8 @@ public class CreateFromImage extends Command {
|
|||||||
final BufferedImage image;
|
final BufferedImage image;
|
||||||
if (argList.get(0).toLowerCase().startsWith("http")) {
|
if (argList.get(0).toLowerCase().startsWith("http")) {
|
||||||
try {
|
try {
|
||||||
URL url = new URL(argList.get(0));
|
|
||||||
if (!url.getHost().equals("i.imgur.com")) {
|
|
||||||
player.sendMessage("Images can only be loaded from i.imgur.com");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
player.sendMessage(BBC.getPrefix() + "Loading image... (1)");
|
player.sendMessage(BBC.getPrefix() + "Loading image... (1)");
|
||||||
image = com.boydti.fawe.util.MainUtil.toRGB(ImageIO.read(url));
|
image = getImage(argList.get(0), fp);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
player.sendMessage(e.getMessage());
|
player.sendMessage(e.getMessage());
|
||||||
return;
|
return;
|
||||||
@ -201,7 +196,7 @@ public class CreateFromImage extends Command {
|
|||||||
int argOffset = 0;
|
int argOffset = 0;
|
||||||
BufferedImage img = null;
|
BufferedImage img = null;
|
||||||
if (argList.get(1).startsWith("http")) {
|
if (argList.get(1).startsWith("http")) {
|
||||||
img = getImgurImage(argList.get(1), fp);
|
img = getImage(argList.get(1), fp);
|
||||||
argOffset++;
|
argOffset++;
|
||||||
}
|
}
|
||||||
World world = fp.getWorld();
|
World world = fp.getWorld();
|
||||||
@ -299,7 +294,7 @@ public class CreateFromImage extends Command {
|
|||||||
C.COMMAND_SYNTAX.send(player, "/2 cfi " + argList.get(0) + " <url>");
|
C.COMMAND_SYNTAX.send(player, "/2 cfi " + argList.get(0) + " <url>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BufferedImage image = getImgurImage(argList.get(1), fp);
|
BufferedImage image = getImage(argList.get(1), fp);
|
||||||
generator.setColor(image);
|
generator.setColor(image);
|
||||||
player.sendMessage("Set color, what's next?");
|
player.sendMessage("Set color, what's next?");
|
||||||
return;
|
return;
|
||||||
@ -310,7 +305,7 @@ public class CreateFromImage extends Command {
|
|||||||
C.COMMAND_SYNTAX.send(player, "/2 cfi " + argList.get(0) + " <url>");
|
C.COMMAND_SYNTAX.send(player, "/2 cfi " + argList.get(0) + " <url>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BufferedImage image = getImgurImage(argList.get(1), fp);
|
BufferedImage image = getImage(argList.get(1), fp);
|
||||||
generator.setBiomeColor(image);
|
generator.setBiomeColor(image);
|
||||||
player.sendMessage("Set color, what's next?");
|
player.sendMessage("Set color, what's next?");
|
||||||
return;
|
return;
|
||||||
@ -321,7 +316,7 @@ public class CreateFromImage extends Command {
|
|||||||
C.COMMAND_SYNTAX.send(player, "/2 cfi " + argList.get(0) + " <url>");
|
C.COMMAND_SYNTAX.send(player, "/2 cfi " + argList.get(0) + " <url>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BufferedImage image = getImgurImage(argList.get(1), fp);
|
BufferedImage image = getImage(argList.get(1), fp);
|
||||||
generator.setBlockAndBiomeColor(image);
|
generator.setBlockAndBiomeColor(image);
|
||||||
player.sendMessage("Set color, what's next?");
|
player.sendMessage("Set color, what's next?");
|
||||||
return;
|
return;
|
||||||
@ -333,7 +328,7 @@ public class CreateFromImage extends Command {
|
|||||||
C.COMMAND_SYNTAX.send(player, "/2 cfi " + argList.get(0) + " <url>");
|
C.COMMAND_SYNTAX.send(player, "/2 cfi " + argList.get(0) + " <url>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BufferedImage image = getImgurImage(argList.get(1), fp);
|
BufferedImage image = getImage(argList.get(1), fp);
|
||||||
generator.setColorWithGlass(image);
|
generator.setColorWithGlass(image);
|
||||||
player.sendMessage("Set glass color, what's next?");
|
player.sendMessage("Set glass color, what's next?");
|
||||||
return;
|
return;
|
||||||
@ -370,7 +365,7 @@ public class CreateFromImage extends Command {
|
|||||||
}
|
}
|
||||||
if (argList.get(1).startsWith("http")) {
|
if (argList.get(1).startsWith("http")) {
|
||||||
player.sendMessage("Loading image (3)...");
|
player.sendMessage("Loading image (3)...");
|
||||||
BufferedImage image = getImgurImage(argList.get(1), fp);
|
BufferedImage image = getImage(argList.get(1), fp);
|
||||||
generator.setHeight(image);
|
generator.setHeight(image);
|
||||||
} else {
|
} else {
|
||||||
generator.setHeights(Integer.parseInt(args[1]));
|
generator.setHeights(Integer.parseInt(args[1]));
|
||||||
@ -424,7 +419,7 @@ public class CreateFromImage extends Command {
|
|||||||
generator.setBiome(id);
|
generator.setBiome(id);
|
||||||
} else {
|
} else {
|
||||||
id = getBiome(argList.get(2), fp).getId();
|
id = getBiome(argList.get(2), fp).getId();
|
||||||
BufferedImage img = getImgurImage(argList.get(1), fp);
|
BufferedImage img = getImage(argList.get(1), fp);
|
||||||
if (img != null) {
|
if (img != null) {
|
||||||
boolean whiteOnly = argList.size() == 4 && Boolean.parseBoolean(argList.get(3));
|
boolean whiteOnly = argList.size() == 4 && Boolean.parseBoolean(argList.get(3));
|
||||||
generator.setBiome(img, (byte) id, whiteOnly);
|
generator.setBiome(img, (byte) id, whiteOnly);
|
||||||
@ -443,7 +438,7 @@ public class CreateFromImage extends Command {
|
|||||||
}
|
}
|
||||||
int radius = Integer.parseInt(argList.get(2));
|
int radius = Integer.parseInt(argList.get(2));
|
||||||
int iterations = Integer.parseInt(argList.get(3));
|
int iterations = Integer.parseInt(argList.get(3));
|
||||||
BufferedImage img = getImgurImage(argList.get(1), fp);
|
BufferedImage img = getImage(argList.get(1), fp);
|
||||||
if (img != null) {
|
if (img != null) {
|
||||||
boolean whiteOnly = argList.size() == 5 && Boolean.parseBoolean(argList.get(4));
|
boolean whiteOnly = argList.size() == 5 && Boolean.parseBoolean(argList.get(4));
|
||||||
generator.smooth(img, whiteOnly, radius, iterations);
|
generator.smooth(img, whiteOnly, radius, iterations);
|
||||||
@ -466,7 +461,7 @@ public class CreateFromImage extends Command {
|
|||||||
generator.setOverlay(id);
|
generator.setOverlay(id);
|
||||||
} else {
|
} else {
|
||||||
id = we.getPatternFactory().parseFromInput(argList.get(2), context);
|
id = we.getPatternFactory().parseFromInput(argList.get(2), context);
|
||||||
BufferedImage img = getImgurImage(argList.get(1), fp);
|
BufferedImage img = getImage(argList.get(1), fp);
|
||||||
if (img != null) {
|
if (img != null) {
|
||||||
boolean whiteOnly = argList.size() == 4 && Boolean.parseBoolean(argList.get(3));
|
boolean whiteOnly = argList.size() == 4 && Boolean.parseBoolean(argList.get(3));
|
||||||
generator.setOverlay(img, id, whiteOnly);
|
generator.setOverlay(img, id, whiteOnly);
|
||||||
@ -489,7 +484,7 @@ public class CreateFromImage extends Command {
|
|||||||
generator.setMain(id);
|
generator.setMain(id);
|
||||||
} else {
|
} else {
|
||||||
id = we.getPatternFactory().parseFromInput(argList.get(2), context);
|
id = we.getPatternFactory().parseFromInput(argList.get(2), context);
|
||||||
BufferedImage img = getImgurImage(argList.get(1), fp);
|
BufferedImage img = getImage(argList.get(1), fp);
|
||||||
if (img != null) {
|
if (img != null) {
|
||||||
boolean whiteOnly = argList.size() == 4 && Boolean.parseBoolean(argList.get(3));
|
boolean whiteOnly = argList.size() == 4 && Boolean.parseBoolean(argList.get(3));
|
||||||
generator.setMain(img, id, whiteOnly);
|
generator.setMain(img, id, whiteOnly);
|
||||||
@ -512,7 +507,7 @@ public class CreateFromImage extends Command {
|
|||||||
generator.setFloor(id);
|
generator.setFloor(id);
|
||||||
} else {
|
} else {
|
||||||
id = we.getPatternFactory().parseFromInput(argList.get(2), context);
|
id = we.getPatternFactory().parseFromInput(argList.get(2), context);
|
||||||
BufferedImage img = getImgurImage(argList.get(1), fp);
|
BufferedImage img = getImage(argList.get(1), fp);
|
||||||
if (img != null) {
|
if (img != null) {
|
||||||
boolean whiteOnly = argList.size() == 4 && Boolean.parseBoolean(argList.get(3));
|
boolean whiteOnly = argList.size() == 4 && Boolean.parseBoolean(argList.get(3));
|
||||||
generator.setFloor(img, id, whiteOnly);
|
generator.setFloor(img, id, whiteOnly);
|
||||||
@ -535,7 +530,7 @@ public class CreateFromImage extends Command {
|
|||||||
generator.setColumn(id);
|
generator.setColumn(id);
|
||||||
} else {
|
} else {
|
||||||
id = we.getPatternFactory().parseFromInput(argList.get(2), context);
|
id = we.getPatternFactory().parseFromInput(argList.get(2), context);
|
||||||
BufferedImage img = getImgurImage(argList.get(1), fp);
|
BufferedImage img = getImage(argList.get(1), fp);
|
||||||
if (img != null) {
|
if (img != null) {
|
||||||
boolean whiteOnly = argList.size() == 4 && Boolean.parseBoolean(argList.get(3));
|
boolean whiteOnly = argList.size() == 4 && Boolean.parseBoolean(argList.get(3));
|
||||||
generator.setColumn(img, id, whiteOnly);
|
generator.setColumn(img, id, whiteOnly);
|
||||||
@ -602,12 +597,9 @@ public class CreateFromImage extends Command {
|
|||||||
return Biomes.findBiomeByName(knownBiomes, arg, biomeRegistry);
|
return Biomes.findBiomeByName(knownBiomes, arg, biomeRegistry);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BufferedImage getImgurImage(String arg, FawePlayer fp) throws IOException {
|
private BufferedImage getImage(String arg, FawePlayer fp) throws IOException {
|
||||||
if (arg.startsWith("http")) {
|
if (arg.startsWith("http")) {
|
||||||
URL url = new URL(arg);
|
URL url = new URL(arg);
|
||||||
if (!url.getHost().equalsIgnoreCase("i.imgur.com")) {
|
|
||||||
throw new IOException("Only i.imgur.com links are allowed!");
|
|
||||||
}
|
|
||||||
fp.sendMessage(BBC.getPrefix() + "Downloading image... (3)");
|
fp.sendMessage(BBC.getPrefix() + "Downloading image... (3)");
|
||||||
return com.boydti.fawe.util.MainUtil.toRGB(ImageIO.read(url));
|
return com.boydti.fawe.util.MainUtil.toRGB(ImageIO.read(url));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user