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) { public McremoveCommand (mcMMO plugin) {
this.plugin = plugin; this.plugin = plugin;
this.location = mcMMO.usersFile; this.location = mcMMO.getUsersFile();
} }
@Override @Override

View File

@ -51,7 +51,7 @@ public class PlayerProfile {
HashMap<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); HashMap<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>();
HashMap<ToolType, Integer> toolATS = new HashMap<ToolType, 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) { public PlayerProfile(String playerName, boolean addNew) {
this.playerName = playerName; this.playerName = playerName;

View File

@ -102,11 +102,11 @@ public class mcMMO extends JavaPlugin {
public static File mcmmo; public static File mcmmo;
//File Paths //File Paths
public static String mainDirectory; private static String mainDirectory;
public static String flatFileDirectory; private static String flatFileDirectory;
public static String usersFile; private static String usersFile;
public static String leaderboardDirectory; private static String leaderboardDirectory;
public static String modDirectory; private static String modDirectory;
//Spout Check //Spout Check
public static boolean spoutEnabled; public static boolean spoutEnabled;
@ -480,4 +480,25 @@ public class mcMMO extends JavaPlugin {
public void removeFromTNTTracker(int tntID) { public void removeFromTNTTracker(int tntID) {
tntTracker.remove(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 @Override
public void run() { public void run() {
String location = mcMMO.usersFile; String location = mcMMO.getUsersFile();
try { try {
FileReader file = new FileReader(location); FileReader file = new FileReader(location);

View File

@ -30,7 +30,7 @@ import com.gmail.nossr50.util.Users;
public class SpoutStuff { public class SpoutStuff {
private static mcMMO plugin = mcMMO.p; 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 hudDirectory = spoutDirectory + "HUD" + File.separator;
public final static String hudStandardDirectory = hudDirectory + "Standard" + File.separator; public final static String hudStandardDirectory = hudDirectory + "Standard" + File.separator;
public final static String hudRetroDirectory = hudDirectory + "Retro" + 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 { public class Leaderboard {
private static mcMMO plugin = mcMMO.p; private static mcMMO plugin = mcMMO.p;
private static String leaderboardsDirectory = mcMMO.leaderboardDirectory; private static String leaderboardsDirectory = mcMMO.getLeaderboardDirectory();
private final static String location = mcMMO.usersFile; private final static String location = mcMMO.getUsersFile();
/** /**
* Create the leaderboards. * Create the leaderboards.

View File

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

View File

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