Improve handling of filenames containing spaces

This commit is contained in:
SydMontague 2021-05-09 22:28:58 +02:00
parent fa6588be58
commit 66d2cc474a
4 changed files with 8 additions and 6 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>net.craftcitizen</groupId> <groupId>net.craftcitizen</groupId>
<artifactId>imagemaps</artifactId> <artifactId>imagemaps</artifactId>
<version>1.0.6</version> <version>1.0.7-SNAPSHOT</version>
<name>ImageMaps</name> <name>ImageMaps</name>
<description>Render Images onto maps!</description> <description>Render Images onto maps!</description>

View File

@ -45,10 +45,10 @@ public class ImageMapInfoCommand extends ImageMapSubCommand {
Tuple<Integer, Integer> size = getPlugin().getImageSize(filename, null); Tuple<Integer, Integer> size = getPlugin().getImageSize(filename, null);
BaseComponent reloadAction = new TextComponent("[Reload]"); BaseComponent reloadAction = new TextComponent("[Reload]");
reloadAction.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/imagemap reload " + filename)); reloadAction.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/imagemap reload \"%s\"", filename)));
reloadAction.setColor(ChatColor.GOLD); reloadAction.setColor(ChatColor.GOLD);
BaseComponent placeAction = new TextComponent("[Place]"); BaseComponent placeAction = new TextComponent("[Place]");
placeAction.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/imagemap place " + filename)); placeAction.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/imagemap place \"%s\"", filename)));
placeAction.setColor(ChatColor.GOLD); placeAction.setColor(ChatColor.GOLD);
BaseComponent actions = new TextComponent("Action: "); BaseComponent actions = new TextComponent("Action: ");

View File

@ -36,13 +36,13 @@ public class ImageMapListCommand extends ImageMapSubCommand {
boolean even = false; boolean even = false;
for(String filename : Utils.paginate(fileList, page)) { for(String filename : Utils.paginate(fileList, page)) {
BaseComponent infoAction = new TextComponent("[Info]"); BaseComponent infoAction = new TextComponent("[Info]");
infoAction.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/imagemap info " + filename)); infoAction.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/imagemap info \"%s\"", filename)));
infoAction.setColor(ChatColor.GOLD); infoAction.setColor(ChatColor.GOLD);
BaseComponent reloadAction = new TextComponent("[Reload]"); BaseComponent reloadAction = new TextComponent("[Reload]");
reloadAction.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/imagemap reload " + filename)); reloadAction.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/imagemap reload \"%s\"", filename)));
reloadAction.setColor(ChatColor.GOLD); reloadAction.setColor(ChatColor.GOLD);
BaseComponent placeAction = new TextComponent("[Place]"); BaseComponent placeAction = new TextComponent("[Place]");
placeAction.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/imagemap place " + filename)); placeAction.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/imagemap place \"%s\"", filename)));
placeAction.setColor(ChatColor.GOLD); placeAction.setColor(ChatColor.GOLD);
BaseComponent message = new TextComponent(filename); BaseComponent message = new TextComponent(filename);

View File

@ -49,6 +49,8 @@ import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
// TODO permissions per image or folder
// TODO per-user maps
public class ImageMaps extends JavaPlugin implements Listener { public class ImageMaps extends JavaPlugin implements Listener {
private static final String MAPS_YML = "maps.yml"; private static final String MAPS_YML = "maps.yml";
private static final String CONFIG_VERSION_KEY = "storageVersion"; private static final String CONFIG_VERSION_KEY = "storageVersion";