Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using bukkit's path to plugins directory. Fixes issue #720 #721

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/main/java/com/griefcraft/io/BackupManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ public enum Result {
/**
* The folder backups are stored in
*/
private final File backupFolder = new File(BACKUP_FOLDER);
private File backupFolder;

private final LWC lwc = LWC.getInstance();
private final Plugin plugin = lwc.getPlugin();

/**
* Backup creation flags
Expand All @@ -112,6 +115,8 @@ public enum Flag {
}

public BackupManager() {
BACKUP_FOLDER = plugin.getDataFolder().getAbsolutePath() + "backups/";
backupFolder = new File(BACKUP_FOLDER);
if (!backupFolder.exists()) {
backupFolder.mkdir();
}
Expand Down Expand Up @@ -217,7 +222,6 @@ public Backup loadBackup(String name) throws IOException {
* @return
*/
public Backup createBackup(String name, final EnumSet<Flag> flags) {
final LWC lwc = LWC.getInstance();
final Plugin plugin = lwc.getPlugin();
Server server = Bukkit.getServer();
final BukkitScheduler scheduler = server.getScheduler();
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/griefcraft/migration/ConfigPost300.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ public class ConfigPost300 implements MigrationUtility {

public void run() {
LWC lwc = LWC.getInstance();
File configFile = new File("plugins/LWC/lwc.properties");
File coreDir = LWC.getInstance().getPlugin().getDataFolder();
File configFile = new File(coreDir, "lwc.properties");

if (!configFile.exists()) {
return;
}

// delete internal.ini
new File("plugins/LWC/internal.ini").delete();
new File(coreDir, "internal.ini").delete();
logger.info("Converting lwc.properties to new variants");

// we need to convert..
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/griefcraft/migration/MySQLPost200.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void run() {
String database = lwc.getConfiguration().getString("database.path");

if (database == null || database.trim().equals("")) {
database = "plugins/LWC/lwc.db";
database = lwc.getPlugin().getDataFolder().getAbsolutePath() + "lwc.db";
}

File file = new File(database);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/griefcraft/scripting/ModuleLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public int getExpectedArguments() {
/**
* Path to the root of scripts
*/
public final static String ROOT_PATH = "plugins/LWC/";
public static String ROOT_PATH = "plugins/LWC/";

/**
* Map of loaded modules
Expand All @@ -184,6 +184,7 @@ public int getExpectedArguments() {

public ModuleLoader(LWC lwc) {
this.lwc = lwc;
ROOT_PATH = lwc.getPlugin().getDataFolder().getAbsolutePath();
populateFastModuleCache();
}

Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/griefcraft/util/Updater.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class Updater {
/**
* The folder where libraries are stored
*/
public final static String DEST_LIBRARY_FOLDER = "plugins/LWC/lib/";
public static String DEST_LIBRARY_FOLDER = "";

/**
* The queue of files that need to be downloaded
Expand All @@ -73,6 +73,9 @@ public void init() {
downloadFiles();

final LWC lwc = LWC.getInstance();

DEST_LIBRARY_FOLDER = lwc.getPlugin().getDataFolder().getAbsolutePath() + "lib/";

if (lwc.getConfiguration().getBoolean("core.updateNotifier", true)) {
lwc.getPlugin().getServer().getScheduler().scheduleAsyncDelayedTask(lwc.getPlugin(), new Runnable() {
public void run() {
Expand Down Expand Up @@ -203,7 +206,7 @@ public void downloadFiles() {
lwc.log("Downloading file " + local.getName());

// check for LWC folder
File folder = new File("plugins/LWC/");
File folder = new File(DEST_LIBRARY_FOLDER);
if (!folder.exists()) {
folder.mkdir();
}
Expand Down