Protect our file paths.

This commit is contained in:
GJ 2012-07-09 10:55:33 -04:00
parent d038cbf357
commit f0b2cc1bab
8 changed files with 42 additions and 21 deletions

View File

@ -26,7 +26,7 @@ public class McremoveCommand implements CommandExecutor {
public McremoveCommand (mcMMO plugin) {
this.plugin = plugin;
this.location = mcMMO.usersFile;
this.location = mcMMO.getUsersFile();
}
@Override

View File

@ -51,7 +51,7 @@ public class PlayerProfile {
HashMap<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>();
HashMap<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
private final static String location = mcMMO.usersFile;
private final static String location = mcMMO.getUsersFile();
public PlayerProfile(String playerName, boolean addNew) {
this.playerName = playerName;

View File

@ -102,11 +102,11 @@ public class mcMMO extends JavaPlugin {
public static File mcmmo;
//File Paths
public static String mainDirectory;
public static String flatFileDirectory;
public static String usersFile;
public static String leaderboardDirectory;
public static String modDirectory;
private static String mainDirectory;
private static String flatFileDirectory;
private static String usersFile;
private static String leaderboardDirectory;
private static String modDirectory;
//Spout Check
public static boolean spoutEnabled;
@ -480,4 +480,25 @@ public class mcMMO extends JavaPlugin {
public void removeFromTNTTracker(int tntID) {
tntTracker.remove(tntID);
}
public static String getMainDirectory() {
return mainDirectory;
}
public static String getFlatFileDirectory() {
return flatFileDirectory;
}
public static String getUsersFile() {
return usersFile;
}
public static String getLeaderboardDirectory() {
return leaderboardDirectory;
}
public static String getModDirectory() {
return modDirectory;
}
}

View File

@ -17,7 +17,7 @@ public class SQLConversionTask implements Runnable {
@Override
public void run() {
String location = mcMMO.usersFile;
String location = mcMMO.getUsersFile();
try {
FileReader file = new FileReader(location);

View File

@ -30,7 +30,7 @@ import com.gmail.nossr50.util.Users;
public class SpoutStuff {
private static mcMMO plugin = mcMMO.p;
public final static String spoutDirectory = mcMMO.mainDirectory + "Resources" + File.separator;
public final static String spoutDirectory = mcMMO.getMainDirectory() + "Resources" + File.separator;
public final static String hudDirectory = spoutDirectory + "HUD" + File.separator;
public final static String hudStandardDirectory = hudDirectory + "Standard" + File.separator;
public final static String hudRetroDirectory = hudDirectory + "Retro" + File.separator;

View File

@ -15,8 +15,8 @@ import com.gmail.nossr50.datatypes.Tree;
public class Leaderboard {
private static mcMMO plugin = mcMMO.p;
private static String leaderboardsDirectory = mcMMO.leaderboardDirectory;
private final static String location = mcMMO.usersFile;
private static String leaderboardsDirectory = mcMMO.getLeaderboardDirectory();
private final static String location = mcMMO.getUsersFile();
/**
* Create the leaderboards.

View File

@ -19,11 +19,11 @@ public class Users {
* Load users.
*/
public static void loadUsers() {
new File(mcMMO.flatFileDirectory).mkdir();
new File(mcMMO.leaderboardDirectory).mkdir();
new File(mcMMO.getFlatFileDirectory()).mkdir();
new File(mcMMO.getLeaderboardDirectory()).mkdir();
try {
new File(mcMMO.usersFile).createNewFile();
new File(mcMMO.getUsersFile()).createNewFile();
}
catch (IOException e) {
e.printStackTrace();

View File

@ -16,14 +16,14 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
public class ZipLibrary {
private static String BackupDirectory = mcMMO.mainDirectory + "backup" + File.separator;
private static String BackupDirectory = mcMMO.getMainDirectory() + "backup" + File.separator;
private static File BackupDir = new File(BackupDirectory);
private static File FlatFileDirectory = new File(mcMMO.flatFileDirectory);
private static File ModFileDirectory = new File(mcMMO.modDirectory);
private static File UsersFile = new File(mcMMO.usersFile);
private static File ConfigFile = new File(mcMMO.mainDirectory + "config.yml");
private static File TreasuresFile = new File(mcMMO.mainDirectory + "treasures.yml");
private static File Leaderboards = new File(mcMMO.leaderboardDirectory);
private static File FlatFileDirectory = new File(mcMMO.getFlatFileDirectory());
private static File ModFileDirectory = new File(mcMMO.getModDirectory());
private static File UsersFile = new File(mcMMO.getUsersFile());
private static File ConfigFile = new File(mcMMO.getMainDirectory() + "config.yml");
private static File TreasuresFile = new File(mcMMO.getMainDirectory() + "treasures.yml");
private static File Leaderboards = new File(mcMMO.getLeaderboardDirectory());
public static void mcMMObackup() throws IOException {
if (Config.getInstance().getUseMySQL()) {