mirror of
https://github.com/zDevelopers/ImageOnMap.git
synced 2024-09-29 06:57:29 +02:00
Fixed bypass permission.
This commit is contained in:
parent
5701296d67
commit
c8c26a3cc6
@ -45,7 +45,8 @@ public enum Permissions
|
|||||||
GET("imageonmap.get"),
|
GET("imageonmap.get"),
|
||||||
RENAME("imageonmap.rename"),
|
RENAME("imageonmap.rename"),
|
||||||
DELETE("imageonmap.delete"),
|
DELETE("imageonmap.delete"),
|
||||||
ADMINISTRATIVE("imageonmap.administrative")
|
ADMINISTRATIVE("imageonmap.administrative"),
|
||||||
|
BYPASS_SIZE("imageonmap.bypasssize")
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
package fr.moribus.imageonmap.image;
|
package fr.moribus.imageonmap.image;
|
||||||
|
|
||||||
|
import fr.moribus.imageonmap.Permissions;
|
||||||
import fr.moribus.imageonmap.PluginConfiguration;
|
import fr.moribus.imageonmap.PluginConfiguration;
|
||||||
import fr.moribus.imageonmap.map.ImageMap;
|
import fr.moribus.imageonmap.map.ImageMap;
|
||||||
import fr.moribus.imageonmap.map.MapManager;
|
import fr.moribus.imageonmap.map.MapManager;
|
||||||
@ -69,6 +70,7 @@ public class ImageRendererExecutor extends Worker
|
|||||||
{
|
{
|
||||||
final URLConnection connection = url.openConnection();
|
final URLConnection connection = url.openConnection();
|
||||||
connection.connect();
|
connection.connect();
|
||||||
|
|
||||||
if (connection instanceof HttpURLConnection)
|
if (connection instanceof HttpURLConnection)
|
||||||
{
|
{
|
||||||
final HttpURLConnection httpConnection = (HttpURLConnection) connection;
|
final HttpURLConnection httpConnection = (HttpURLConnection) connection;
|
||||||
@ -78,29 +80,34 @@ public class ImageRendererExecutor extends Worker
|
|||||||
throw new IOException(I.t("HTTP error: {0} {1}", httpCode, httpConnection.getResponseMessage()));
|
throw new IOException(I.t("HTTP error: {0} {1}", httpCode, httpConnection.getResponseMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final InputStream stream = connection.getInputStream();
|
final InputStream stream = connection.getInputStream();
|
||||||
final BufferedImage image = ImageIO.read(stream);
|
final BufferedImage image = ImageIO.read(stream);
|
||||||
|
|
||||||
if (image == null) throw new IOException(I.t("The given URL is not a valid image"));
|
if (image == null) throw new IOException(I.t("The given URL is not a valid image"));
|
||||||
|
|
||||||
|
|
||||||
// Limits are in place and the player does NOT have rights to avoid them.
|
// Limits are in place and the player does NOT have rights to avoid them.
|
||||||
if((PluginConfiguration.LIMIT_SIZE_X.get() > 0 || PluginConfiguration.LIMIT_SIZE_Y.get() > 0) && !Bukkit.getPlayer(playerUUID).hasPermission("imageonmap.bypasssize")) {
|
if ((PluginConfiguration.LIMIT_SIZE_X.get() > 0 || PluginConfiguration.LIMIT_SIZE_Y.get() > 0) && !Permissions.BYPASS_SIZE.grantedTo(Bukkit.getPlayer(playerUUID)))
|
||||||
if(PluginConfiguration.LIMIT_SIZE_X.get() > 0) {
|
{
|
||||||
if(image.getWidth() > PluginConfiguration.LIMIT_SIZE_X.get()) throw new IOException(I.t("The image is too wide!"));
|
if (PluginConfiguration.LIMIT_SIZE_X.get() > 0)
|
||||||
|
{
|
||||||
|
if (image.getWidth() > PluginConfiguration.LIMIT_SIZE_X.get())
|
||||||
|
throw new IOException(I.t("The image is too wide!"));
|
||||||
}
|
}
|
||||||
if(PluginConfiguration.LIMIT_SIZE_Y.get() > 0) {
|
if (PluginConfiguration.LIMIT_SIZE_Y.get() > 0)
|
||||||
if(image.getHeight() > PluginConfiguration.LIMIT_SIZE_Y.get()) throw new IOException(I.t("The image is too tall!"));
|
{
|
||||||
|
if (image.getHeight() > PluginConfiguration.LIMIT_SIZE_Y.get())
|
||||||
|
throw new IOException(I.t("The image is too tall!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(scaling != ImageUtils.ScalingType.NONE && height <= 1 && width <= 1) {
|
if (scaling != ImageUtils.ScalingType.NONE && height <= 1 && width <= 1)
|
||||||
|
{
|
||||||
return renderSingle(scaling.resize(image, ImageMap.WIDTH, ImageMap.HEIGHT), playerUUID);
|
return renderSingle(scaling.resize(image, ImageMap.WIDTH, ImageMap.HEIGHT), playerUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
final BufferedImage resizedImage = scaling.resize(image, ImageMap.WIDTH * width, ImageMap.HEIGHT * height);
|
final BufferedImage resizedImage = scaling.resize(image, ImageMap.WIDTH * width, ImageMap.HEIGHT * height);
|
||||||
return renderPoster(resizedImage, playerUUID);
|
return renderPoster(resizedImage, playerUUID);
|
||||||
//return RenderPoster(image, playerUUID);
|
|
||||||
}
|
}
|
||||||
}, callback);
|
}, callback);
|
||||||
}
|
}
|
||||||
@ -154,7 +161,8 @@ public class ImageRendererExecutor extends Worker
|
|||||||
|
|
||||||
ImageIOExecutor.saveImage(mapsIDs, poster);
|
ImageIOExecutor.saveImage(mapsIDs, poster);
|
||||||
|
|
||||||
if(PluginConfiguration.SAVE_FULL_IMAGE.get()) {
|
if (PluginConfiguration.SAVE_FULL_IMAGE.get())
|
||||||
|
{
|
||||||
ImageIOExecutor.saveImage(ImageMap.getFullImageFile(mapsIDs[0], mapsIDs[mapsIDs.length - 1]), image);
|
ImageIOExecutor.saveImage(ImageMap.getFullImageFile(mapsIDs[0], mapsIDs[mapsIDs.length - 1]), image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,9 +8,9 @@ commands:
|
|||||||
description: render an image in a map
|
description: render an image in a map
|
||||||
usage: /<command> [URL]
|
usage: /<command> [URL]
|
||||||
maptool:
|
maptool:
|
||||||
description: manage maps
|
description: Manage maps
|
||||||
maps:
|
maps:
|
||||||
description: manage maps through a GUI
|
description: Manage maps through a GUI
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
imageonmap.*:
|
imageonmap.*:
|
||||||
@ -24,6 +24,7 @@ permissions:
|
|||||||
imageonmap.explore: true
|
imageonmap.explore: true
|
||||||
imageonmap.rename: true
|
imageonmap.rename: true
|
||||||
imageonmap.delete: true
|
imageonmap.delete: true
|
||||||
|
imageonmap.bypasssize: false
|
||||||
|
|
||||||
imageonmap.userender:
|
imageonmap.userender:
|
||||||
description: "Allows you to use /tomap and related commands (/maptool getremaing). Alias of imageonmap.new."
|
description: "Allows you to use /tomap and related commands (/maptool getremaing). Alias of imageonmap.new."
|
||||||
@ -56,3 +57,7 @@ permissions:
|
|||||||
imageonmap.administrative:
|
imageonmap.administrative:
|
||||||
description: "Allows you to perform administrative tasks (like /maptool migrate)."
|
description: "Allows you to perform administrative tasks (like /maptool migrate)."
|
||||||
default: op
|
default: op
|
||||||
|
|
||||||
|
imageonmap.bypasssize:
|
||||||
|
description: "Allows you to create maps larger than the configured limit."
|
||||||
|
default: op
|
||||||
|
Loading…
Reference in New Issue
Block a user