|
@@ -67,32 +67,12 @@ public class mcMMO extends JavaPlugin {
|
|
public void onEnable() {
|
|
public void onEnable() {
|
|
p = this;
|
|
p = this;
|
|
mcmmo = getFile();
|
|
mcmmo = getFile();
|
|
- versionFile = new File(getDataFolder(), "VERSION");
|
|
|
|
|
|
|
|
mainDirectory = getDataFolder().getPath() + File.separator;
|
|
mainDirectory = getDataFolder().getPath() + File.separator;
|
|
flatFileDirectory = mainDirectory + "FlatFileStuff" + File.separator;
|
|
flatFileDirectory = mainDirectory + "FlatFileStuff" + File.separator;
|
|
leaderboardDirectory = flatFileDirectory + "Leaderboards" + File.separator;
|
|
leaderboardDirectory = flatFileDirectory + "Leaderboards" + File.separator;
|
|
usersFile = flatFileDirectory + "mcmmo.users";
|
|
usersFile = flatFileDirectory + "mcmmo.users";
|
|
|
|
|
|
- if (!versionFile.exists()) {
|
|
|
|
- updateVersion();
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- String vnum = readVersion();
|
|
|
|
-
|
|
|
|
- //This will be changed to whatever version preceded when we actually need updater code.
|
|
|
|
- //Version 1.0.48 is the first to implement this, no checking before that version can be done.
|
|
|
|
- if (vnum.equalsIgnoreCase("1.0.48")) {
|
|
|
|
- updateFrom(1);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //Just add in more else if blocks for versions that need updater code. Increment the updateFrom age int as we do so.
|
|
|
|
- //Catch all for versions not matching and no specific code being needed
|
|
|
|
- else if (!vnum.equalsIgnoreCase(this.getDescription().getVersion())) {
|
|
|
|
- updateFrom(-1);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
this.config = new Config(this);
|
|
this.config = new Config(this);
|
|
this.config.load();
|
|
this.config.load();
|
|
|
|
|
|
@@ -335,84 +315,6 @@ public class mcMMO extends JavaPlugin {
|
|
getCommand("mchud").setExecutor(new MchudCommand(this));
|
|
getCommand("mchud").setExecutor(new MchudCommand(this));
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * Update mcMMO from a given version
|
|
|
|
- * </p>
|
|
|
|
- * It is important to always assume that you are updating from the lowest possible version.
|
|
|
|
- * Thus, every block of updater code should be complete and self-contained; finishing all
|
|
|
|
- * SQL transactions and closing all file handlers, such that the next block of updater code
|
|
|
|
- * if called will handle updating as expected.
|
|
|
|
- *
|
|
|
|
- * @param age Specifies which updater code to run
|
|
|
|
- */
|
|
|
|
- public void updateFrom(int age) {
|
|
|
|
-
|
|
|
|
- //No updater code needed, just update the version.
|
|
|
|
- if (age == -1) {
|
|
|
|
- updateVersion();
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //Updater code from age 1 goes here
|
|
|
|
- if (age <= 1) {
|
|
|
|
- //Since age 1 is an example for now, we will just let it do nothing.
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //If we are updating from age 1 but we need more to reach age 2, this will run too.
|
|
|
|
- if (age <= 2) {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- updateVersion();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Update the version file.
|
|
|
|
- */
|
|
|
|
- public void updateVersion() {
|
|
|
|
- try {
|
|
|
|
- versionFile.createNewFile();
|
|
|
|
- BufferedWriter vout = new BufferedWriter(new FileWriter(versionFile));
|
|
|
|
- vout.write(this.getDescription().getVersion());
|
|
|
|
- vout.close();
|
|
|
|
- }
|
|
|
|
- catch (IOException ex) {
|
|
|
|
- ex.printStackTrace();
|
|
|
|
- }
|
|
|
|
- catch (SecurityException ex) {
|
|
|
|
- ex.printStackTrace();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Get the current mcMMO version.
|
|
|
|
- *
|
|
|
|
- * @return a String representing the current mcMMO version
|
|
|
|
- */
|
|
|
|
- public String readVersion() {
|
|
|
|
- byte[] buffer = new byte[(int) versionFile.length()];
|
|
|
|
- BufferedInputStream f = null;
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
- f = new BufferedInputStream(new FileInputStream(versionFile));
|
|
|
|
- f.read(buffer);
|
|
|
|
- }
|
|
|
|
- catch (FileNotFoundException ex) {
|
|
|
|
- ex.printStackTrace();
|
|
|
|
- }
|
|
|
|
- catch (IOException ex) {
|
|
|
|
- ex.printStackTrace();
|
|
|
|
- }
|
|
|
|
- finally {
|
|
|
|
- if (f != null) {
|
|
|
|
- try {
|
|
|
|
- f.close();
|
|
|
|
- }
|
|
|
|
- catch (IOException ignored) {}
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return new String(buffer);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/*
|
|
/*
|
|
* Boilerplate Custom Config Stuff
|
|
* Boilerplate Custom Config Stuff
|
|
*/
|
|
*/
|