mirror of
https://github.com/zDevelopers/ImageOnMap.git
synced 2024-09-28 06:27:38 +02:00
Added scaling support, remove an unused print
This commit is contained in:
parent
97adcf4aaf
commit
bef12a235a
@ -58,7 +58,7 @@ import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
|
||||
@CommandInfo (name = "update", usageParameters = "<new url> <map name to update> [--confirm]")
|
||||
@CommandInfo (name = "update", usageParameters = "<new url> [stretched|covered] \"<map name to update>\" [--confirm]")
|
||||
@WithFlags ({"confirm"})
|
||||
public class UpdateCommand extends IoMCommand
|
||||
{
|
||||
@ -66,14 +66,30 @@ public class UpdateCommand extends IoMCommand
|
||||
protected void run() throws CommandException
|
||||
{
|
||||
final Player player = playerSender();
|
||||
ImageUtils.ScalingType scaling = ImageUtils.ScalingType.NONE;
|
||||
ImageUtils.ScalingType scaling;
|
||||
|
||||
URL url;
|
||||
|
||||
if(args.length < 1) throwInvalidArgument(I.t("You must give an URL and a map name to update."));
|
||||
if(args.length < 2) throwInvalidArgument(I.t("You must give a map name to update."));
|
||||
|
||||
ImageMap map=getMapFromArgs(player,1,true);
|
||||
switch(args[1]) {
|
||||
|
||||
case "stretched":
|
||||
scaling = ImageUtils.ScalingType.STRETCHED;
|
||||
break;
|
||||
case "covered":
|
||||
scaling = ImageUtils.ScalingType.COVERED;
|
||||
break;
|
||||
default:
|
||||
scaling = ImageUtils.ScalingType.CONTAINED;
|
||||
break;
|
||||
}
|
||||
ImageMap map;
|
||||
if(scaling.equals(ImageUtils.ScalingType.CONTAINED))
|
||||
map=getMapFromArgs(player,1,true);
|
||||
else
|
||||
map=getMapFromArgs(player,2,true);
|
||||
try
|
||||
{
|
||||
url = new URL(args[0]);
|
||||
|
@ -142,7 +142,7 @@ public class ImageRendererExecutor extends Worker
|
||||
// Limits are in place and the player does NOT have rights to avoid them.
|
||||
checkSizeLimit(playerUUID, image );
|
||||
|
||||
updateMap(ImageUtils.ScalingType.CONTAINED.resize(image, width*128, height*128),playerUUID,map.getMapsIDs());
|
||||
updateMap(scaling.resize(image, width*128, height*128),playerUUID,map.getMapsIDs());
|
||||
return map;
|
||||
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ package fr.moribus.imageonmap.map;
|
||||
import fr.moribus.imageonmap.ImageOnMap;
|
||||
import fr.moribus.imageonmap.ui.MapItemManager;
|
||||
import fr.zcraft.zlib.components.i18n.I;
|
||||
import fr.zcraft.zlib.tools.PluginLogger;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
@ -162,10 +161,8 @@ public abstract class ImageMap implements ConfigurationSerializable
|
||||
List<Map<String, Object>> list = (List<Map<String, Object>>) section.getList("mapList");
|
||||
if(list == null) return null;
|
||||
|
||||
PluginLogger.info("list ");
|
||||
for(Map<String, Object> tMap : list)
|
||||
{
|
||||
PluginLogger.info(" "+tMap.toString());
|
||||
if(tMap.get("id").equals(id)) {
|
||||
return new Integer[]{(Integer)tMap.get("columns"), (Integer)tMap.get("rows")};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user