mirror of
https://github.com/zDevelopers/ImageOnMap.git
synced 2024-09-29 06:57:29 +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.net.URL;
|
||||||
import java.util.HashMap;
|
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"})
|
@WithFlags ({"confirm"})
|
||||||
public class UpdateCommand extends IoMCommand
|
public class UpdateCommand extends IoMCommand
|
||||||
{
|
{
|
||||||
@ -66,14 +66,30 @@ public class UpdateCommand extends IoMCommand
|
|||||||
protected void run() throws CommandException
|
protected void run() throws CommandException
|
||||||
{
|
{
|
||||||
final Player player = playerSender();
|
final Player player = playerSender();
|
||||||
ImageUtils.ScalingType scaling = ImageUtils.ScalingType.NONE;
|
ImageUtils.ScalingType scaling;
|
||||||
|
|
||||||
URL url;
|
URL url;
|
||||||
|
|
||||||
if(args.length < 1) throwInvalidArgument(I.t("You must give an URL and a map name to update."));
|
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."));
|
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
|
try
|
||||||
{
|
{
|
||||||
url = new URL(args[0]);
|
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.
|
// Limits are in place and the player does NOT have rights to avoid them.
|
||||||
checkSizeLimit(playerUUID, image );
|
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;
|
return map;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,6 @@ package fr.moribus.imageonmap.map;
|
|||||||
import fr.moribus.imageonmap.ImageOnMap;
|
import fr.moribus.imageonmap.ImageOnMap;
|
||||||
import fr.moribus.imageonmap.ui.MapItemManager;
|
import fr.moribus.imageonmap.ui.MapItemManager;
|
||||||
import fr.zcraft.zlib.components.i18n.I;
|
import fr.zcraft.zlib.components.i18n.I;
|
||||||
import fr.zcraft.zlib.tools.PluginLogger;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
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");
|
List<Map<String, Object>> list = (List<Map<String, Object>>) section.getList("mapList");
|
||||||
if(list == null) return null;
|
if(list == null) return null;
|
||||||
|
|
||||||
PluginLogger.info("list ");
|
|
||||||
for(Map<String, Object> tMap : list)
|
for(Map<String, Object> tMap : list)
|
||||||
{
|
{
|
||||||
PluginLogger.info(" "+tMap.toString());
|
|
||||||
if(tMap.get("id").equals(id)) {
|
if(tMap.get("id").equals(id)) {
|
||||||
return new Integer[]{(Integer)tMap.get("columns"), (Integer)tMap.get("rows")};
|
return new Integer[]{(Integer)tMap.get("columns"), (Integer)tMap.get("rows")};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user