Merge branch 'webbukkit:v3.0' into v3.0

This commit is contained in:
JurgenKuyper 2023-10-01 10:44:26 +02:00 committed by GitHub
commit 0d15ee5a46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 122 additions and 27 deletions

View file

@ -164,6 +164,7 @@ public class DynmapCore implements DynmapCommonAPI {
private File dataDirectory;
private File tilesDirectory;
private File exportDirectory;
private File importDirectory;
private String plugin_ver;
private MapStorage defaultStorage;
@ -224,6 +225,9 @@ public class DynmapCore implements DynmapCommonAPI {
public final File getExportFolder() {
return exportDirectory;
}
public final File getImportFolder() {
return importDirectory;
}
public void setMinecraftVersion(String mcver) {
this.platformVersion = mcver;
}
@ -428,6 +432,11 @@ public class DynmapCore implements DynmapCommonAPI {
if (!exportDirectory.isDirectory() && !exportDirectory.mkdirs()) {
Log.warning("Could not create directory for exports ('" + exportDirectory + "').");
}
// Prime the imports directory
importDirectory = getFile(configuration.getString("importpath", "import"));
if (!importDirectory.isDirectory() && !importDirectory.mkdirs()) {
Log.warning("Could not create directory for imports ('" + importDirectory + "').");
}
// Create default storage handler
String storetype = configuration.getString("storage/type", "filetree");
if (storetype.equals("filetree")) {

View file

@ -2176,6 +2176,10 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
sender.sendMessage("file:\"filename\" required");
return true;
}
if (!validateImportFile(file)) {
sender.sendMessage("Error: '" + ARG_FILE + "' cannot include directory separators - must be just filename in " + plugin.getImportFolder().getAbsolutePath() + " directory");
return true;
}
if(label == null)
label = id;
MarkerIcon ico = MarkerAPIImpl.getMarkerIconImpl(id);
@ -2184,10 +2188,9 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
return true;
}
/* Open stream to filename */
File iconf = new File(file);
FileInputStream fis = null;
try {
fis = new FileInputStream(iconf);
fis = new FileInputStream(new File(plugin.getImportFolder(), file));
/* Create new icon */
MarkerIcon mi = api.createMarkerIcon(id, label, fis);
if(mi == null) {
@ -3201,6 +3204,12 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
}
return true;
}
private static boolean validateImportFile(String fname) {
if ((fname.indexOf('/') >= 0) || (fname.indexOf('\\') >= 0)) {
return false;
}
return true;
}
/** Process importdesc for given item */
private static boolean processImportDesc(DynmapCore plugin, DynmapCommandSender sender, String cmd, String commandLabel, String[] args) {
if(args.length > 1) {
@ -3214,13 +3223,17 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
}
String f = parms.get(ARG_FILE);
if (f == null) {
sender.sendMessage("Error: no '" + ARG_FILE + "' parameter");
sender.sendMessage("file:\"filename\" required");
return true;
}
if (!validateImportFile(f)) {
sender.sendMessage("Error: '" + ARG_FILE + "' cannot include directory separators - must be just filename in " + plugin.getImportFolder().getAbsolutePath() + " directory");
return true;
}
FileReader fr = null;
String val = null;
try {
fr = new FileReader(f);
fr = new FileReader(new File(plugin.getImportFolder(), f));
StringBuilder sb = new StringBuilder();
char[] buf = new char[512];
int len;
@ -3261,13 +3274,17 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
}
String f = parms.get(ARG_FILE);
if (f == null) {
sender.sendMessage("Error: no '" + ARG_FILE + "' parameter");
sender.sendMessage("file:\"filename\" required");
return true;
}
if (!validateImportFile(f)) {
sender.sendMessage("Error: '" + ARG_FILE + "' cannot include directory separators - must be just filename in " + plugin.getImportFolder().getAbsolutePath() + " directory");
return true;
}
FileReader fr = null;
String val = null;
try {
fr = new FileReader(f);
fr = new FileReader(new File(plugin.getImportFolder(), f));
StringBuilder sb = new StringBuilder();
char[] buf = new char[512];
int len;