This commit is contained in:
Vlammar 2020-06-14 03:07:29 +02:00
commit 396268a0e2
6 changed files with 52 additions and 6 deletions

View File

@ -113,8 +113,16 @@ You will find amongst the new features:
- Fixed permissions support by adding a full set of permissions for every action of the plugin.
### 4.0 (Upcoming)
The 4.0 is a bit light in content but we have unified part of the plugin (splatter map) and we have make various change to zLib, next update should be bigger and will add more stuff (thumbnail, optimization, possibility to deploy and place item frame in creative, creating interactive map that can run a command if you click on a specific frame...).
Despite the changes to zLib we have a lot of things to refactor in order to keep version older than 1.15 working.
Backcompatibility is dropped for now but in the future we will try to bring it back, (use 4.0 pre1 for now :( ).
The new features added to ImageOnMap for the 4.0 are:
- You can now place a map on the ground or on a ceilling.
- Fixed bug with splattermap that throw an exception
- Fixed renderer issues when putting a map other player don't see the bottom left corner
- Added Russian and German (thx to Danechek and to ...)
## Data collection
We use metrics to collect basic information about the usage of this plugin. This can be disabled by setting `collect-data` to false in `config.yml`.

View File

@ -31,7 +31,10 @@ public final class PluginConfiguration extends Configuration
static public ConfigurationItem<Locale> LANG = item("lang", Locale.class);
static public ConfigurationItem<Boolean> COLLECT_DATA = item("collect-data", true);
static public ConfigurationItem<Boolean> SAVE_FULL_IMAGE = item("save-full-image", true);
static public ConfigurationItem<Integer> MAP_GLOBAL_LIMIT = item("map-global-limit", 0, "Limit-map-by-server");
static public ConfigurationItem<Integer> MAP_PLAYER_LIMIT = item("map-player-limit", 0, "Limit-map-by-player");
static public ConfigurationItem<Integer> LIMIT_SIZE_X = item("limit-map-size-x", 0);
static public ConfigurationItem<Integer> LIMIT_SIZE_Y = item("limit-map-size-y", 0);
}

View File

@ -18,6 +18,8 @@
package fr.moribus.imageonmap.image;
import fr.moribus.imageonmap.ImageOnMap;
import fr.moribus.imageonmap.PluginConfiguration;
import fr.moribus.imageonmap.map.ImageMap;
import fr.moribus.imageonmap.map.MapManager;
import fr.zcraft.zlib.components.i18n.I;
@ -27,6 +29,7 @@ import fr.zcraft.zlib.components.worker.WorkerCallback;
import fr.zcraft.zlib.components.worker.WorkerRunnable;
import javax.imageio.ImageIO;
import org.bukkit.Bukkit;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
@ -64,12 +67,24 @@ public class ImageRendererExecutor extends Worker
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.
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) {
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(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) {
return renderSingle(scaling.resize(image, ImageMap.WIDTH, ImageMap.HEIGHT), playerUUID);
}
final BufferedImage resizedImage = scaling.resize(image, ImageMap.WIDTH * width, ImageMap.HEIGHT * height);
return renderPoster(resizedImage, playerUUID);
//return RenderPoster(image, playerUUID);
}
}, callback);
}
@ -123,6 +138,11 @@ public class ImageRendererExecutor extends Worker
ImageIOExecutor.saveImage(mapsIDs, poster);
if(PluginConfiguration.SAVE_FULL_IMAGE.get()) {
ImageIOExecutor.saveImage(ImageMap.getFullImageFile(mapsIDs[0], mapsIDs[mapsIDs.length - 1]), image);
}
submitToMainThread(new Callable<Void>()
{
@Override

View File

@ -18,6 +18,7 @@
package fr.moribus.imageonmap.map;
import fr.moribus.imageonmap.ImageOnMap;
import fr.moribus.imageonmap.ui.MapItemManager;
import fr.zcraft.zlib.components.i18n.I;
import org.bukkit.Material;
@ -26,6 +27,7 @@ import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@ -47,7 +49,6 @@ public abstract class ImageMap implements ConfigurationSerializable
private final UUID userUUID;
private final Type mapType;
private String name;
protected ImageMap(UUID userUUID, Type mapType)
{
this(userUUID, mapType, null, null);
@ -84,6 +85,11 @@ public abstract class ImageMap implements ConfigurationSerializable
return MapItemManager.give(player, this);
}
public static File getFullImageFile(short mapIDstart, short mapIDend)
{
return new File(ImageOnMap.getPlugin().getImagesDirectory(), "_"+mapIDstart+"-"+mapIDend+".png");
}
/* ====== Serialization methods ====== */
static public ImageMap fromConfig(Map<String, Object> map, UUID userUUID) throws InvalidConfigurationException

View File

@ -2,7 +2,7 @@
# Plugin language. Empty: system language.
# Available: en_US (default, fallback) and fr_FR.
# Available: en-US (default, fallback) and fr-FR.
lang:
@ -16,3 +16,13 @@ collect-data: true
# 0 means unlimited.
map-global-limit: 0
map-player-limit: 0
#Maximum size in pixels for an image to be. 0 is unlimited.
limit-map-size-x: 0
limit-map-size-y: 0
#Should the full image be saved when a map is rendered?
save-full-image: false

View File

@ -24,7 +24,6 @@ permissions:
imageonmap.explore: true
imageonmap.rename: true
imageonmap.delete: true
imageonmap.administrative: false
imageonmap.userender:
description: "Allows you to use /tomap and related commands (/maptool getremaing). Alias of imageonmap.new."