diff --git a/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java index ff9e3e8966..6f9f71eb69 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java @@ -107,16 +107,16 @@ public final class SimplePluginManager implements PluginManager { itr.remove(); } catch (UnknownDependencyException ex) { if(finalPass) { - server.getLogger().log(Level.SEVERE, "Could not load " + file.getPath() + " in " + directory.getPath() + ": " + ex.getMessage(), ex); + server.getLogger().log(Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + directory.getPath() + "': " + ex.getMessage(), ex); itr.remove(); } else { plugin = null; } } catch (InvalidPluginException ex) { - server.getLogger().log(Level.SEVERE, "Could not load " + file.getPath() + " in " + directory.getPath() + ": " + ex.getMessage(), ex); + server.getLogger().log(Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + directory.getPath() + "': ", ex.getCause()); itr.remove(); } catch (InvalidDescriptionException ex) { - server.getLogger().log(Level.SEVERE, "Could not load " + file.getPath() + " in " + directory.getPath() + ": " + ex.getMessage(), ex); + server.getLogger().log(Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + directory.getPath() + "': " + ex.getMessage(), ex); itr.remove(); } diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index 017076c7a2..2018d0af7c 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -12,6 +12,7 @@ import java.util.Set; import java.util.ArrayList; import java.util.jar.JarEntry; import java.util.jar.JarFile; +import java.util.logging.Level; import java.util.regex.Pattern; import org.bukkit.Server; import org.bukkit.event.CustomEventListener; @@ -67,7 +68,39 @@ public final class JavaPluginLoader implements PluginLoader { throw new InvalidPluginException(ex); } - File dataFolder = getDataFolder(file); + File dataFolder = new File(file.getParentFile(), description.getName()); + File oldDataFolder = getDataFolder(file); + + // Found old data folder + if (dataFolder.isDirectory() && oldDataFolder.isDirectory()) { + server.getLogger().log( Level.INFO, String.format( + "While loading %s (%s) found old-data folder: %s next to the new one: %s", + description.getName(), + file, + oldDataFolder, + dataFolder + )); + } else if (oldDataFolder.isDirectory() && !dataFolder.exists()) { + if (!oldDataFolder.renameTo(dataFolder)) { + throw new InvalidPluginException(new Exception("Unable to rename old data folder: '" + oldDataFolder + "' to: '" + dataFolder + "'")); + } + server.getLogger().log( Level.INFO, String.format( + "While loading %s (%s) renamed data folder: '%s' to '%s'", + description.getName(), + file, + oldDataFolder, + dataFolder + )); + } + + if (dataFolder.exists() && !dataFolder.isDirectory()) { + throw new InvalidPluginException(new Exception(String.format( + "Projected datafolder: '%s' for %s (%s) exists and is not a directory", + dataFolder, + description.getName(), + file + ))); + } ArrayList depend; try {