This commit is contained in:
bm01 2012-05-01 01:32:50 +02:00
parent ca1954ff80
commit 18c52a5e23
5 changed files with 75 additions and 82 deletions

View File

@ -123,7 +123,6 @@ public class mcMMO extends JavaPlugin {
}
}
/**
* Get profile of the player.
* </br>
@ -164,18 +163,15 @@ public class mcMMO extends JavaPlugin {
* Things to be run when the plugin is disabled.
*/
public void onDisable() {
//Make sure to save player information if the server shuts down
for (PlayerProfile x : Users.getProfiles().values()) {
x.save();
}
this.getServer().getScheduler().cancelTasks(this); //This removes our tasks
//Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
try { //Try the backup
try {
ZipLibrary.mcMMObackup();
} catch (IOException e) {
p.getLogger().severe(e.toString());
@ -188,7 +184,6 @@ public class mcMMO extends JavaPlugin {
* Register the commands.
*/
private void registerCommands() {
//Register aliases with the aliasmap (used in the playercommandpreprocessevent to ugly alias them to actual commands)
//Skills commands
aliasMap.put(LocaleLoader.getString("Acrobatics.SkillName").toLowerCase(), "acrobatics");

View File

@ -121,6 +121,7 @@ public class BleedTimer implements Runnable {
* Add a LivingEntity to the bleedList if it is not in it.
*
* @param entity LivingEntity to add
* @param ticks Number of bleeding ticks
*/
public static void add(LivingEntity entity, int ticks) {
int newTicks = ticks;

View File

@ -236,6 +236,7 @@ public class BlastMining {
/**
* Detonate TNT for Blast Mining
*
* @param event The PlayerInteractEvent
* @param player Player detonating the TNT
* @param plugin mcMMO plugin instance
*/

View File

@ -350,7 +350,6 @@ public class Combat {
break;
}
switch (type) {
case SWORDS:
if (entity instanceof Player) {

View File

@ -23,12 +23,13 @@ public class ZipLibrary {
private static File ConfigFile = new File(mcMMO.mainDirectory + "config.yml");
private static File Leaderboards = new File(mcMMO.leaderboardDirectory);
public static void mcMMObackup() throws IOException {
if (BackupDir.mkdir()) {
try {
if (BackupDir.mkdir()) { mcMMO.p.getLogger().info("Created Backup Directory."); }
} catch (Exception h) {
mcMMO.p.getLogger().severe(h.toString());
mcMMO.p.getLogger().info("Created Backup Directory.");
} catch (Exception e) {
mcMMO.p.getLogger().severe(e.toString());
}
}
//Generate the proper date for the backup filename
@ -36,7 +37,6 @@ public class ZipLibrary {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
File fileZip = new File(BackupDirectory + File.separator + dateFormat.format(date) + ".zip");
//Create the Source List, and add directories/etc to the file.
List<File> sources = new ArrayList<File>();
sources.add(FlatFileDirectory);
@ -44,12 +44,10 @@ public class ZipLibrary {
sources.add(ConfigFile);
sources.add(Leaderboards);
//Actually do something
System.out.println("Backing up your mcMMO Configuration... ");
packZip(fileZip, sources);
}
private static void packZip(File output, List<File> sources) throws IOException
@ -58,10 +56,10 @@ public class ZipLibrary {
zipOut.setLevel(Deflater.DEFAULT_COMPRESSION);
for (File source : sources) {
if (source.isDirectory()) {
zipDir(zipOut, "", source);
} else {
}
else {
zipFile(zipOut, "", source);
}
}
@ -74,7 +72,8 @@ public class ZipLibrary {
private static String buildPath(String path, String file) {
if (path == null || path.isEmpty()) {
return file;
} else {
}
else {
return path + "/" + file;
}
}
@ -91,11 +90,11 @@ public class ZipLibrary {
for (File source : files) {
if (source.isDirectory()) {
zipDir(zos, path, source);
} else {
}
else {
zipFile(zos, path, source);
}
}
}
private static void zipFile(ZipOutputStream zos, String path, File file) throws IOException {
@ -107,9 +106,9 @@ public class ZipLibrary {
zos.putNextEntry(new ZipEntry(buildPath(path, file.getName())));
FileInputStream fis = new FileInputStream(file);
byte[] buffer = new byte[4092];
int byteCount = 0;
while ((byteCount = fis.read(buffer)) != -1) {
zos.write(buffer, 0, byteCount);
}
@ -117,6 +116,4 @@ public class ZipLibrary {
fis.close();
zos.closeEntry();
}
}