Much needed code re-format

This commit is contained in:
Eric Stokes 2011-11-25 18:13:14 -07:00
parent 4006e53243
commit c4dd2e3005
10 changed files with 24 additions and 116 deletions

View File

@ -12,15 +12,12 @@ import com.fernferret.allpay.GenericBank;
import com.onarandombox.MultiverseCore.api.Core;
import com.onarandombox.MultiverseCore.api.MVPlugin;
import com.onarandombox.MultiverseCore.commands.*;
import com.onarandombox.MultiverseCore.configuration.MVConfigMigrator;
import com.onarandombox.MultiverseCore.configuration.MVCoreConfigMigrator;
import com.onarandombox.MultiverseCore.destination.*;
import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
import com.onarandombox.MultiverseCore.listeners.MVPluginListener;
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
import com.onarandombox.MultiverseCore.utils.*;
import com.onarandombox.MultiverseCore.utils.MVPermissions;
import com.pneumaticraft.commandhandler.CommandHandler;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@ -114,7 +111,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
private HashMap<String, MVPlayerSession> playerSessions;
private GenericBank bank = null;
private AllPay banker;
protected MVConfigMigrator migrator = new MVCoreConfigMigrator(this);
protected int pluginCount;
private DestinationFactory destFactory;
private SpoutInterface spoutInterface = null;

View File

@ -20,8 +20,6 @@ import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;

View File

@ -7,7 +7,6 @@
package com.onarandombox.MultiverseCore.configuration;
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
import org.bukkit.Difficulty;
import org.bukkit.configuration.ConfigurationSection;

View File

@ -7,7 +7,6 @@
package com.onarandombox.MultiverseCore.configuration;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
import org.bukkit.configuration.ConfigurationSection;

View File

@ -1,81 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.configuration;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.util.config.Configuration;
import java.io.File;
import java.util.List;
import java.util.logging.Level;
public class MVCoreConfigMigrator extends MVConfigMigrator {
private MultiverseCore core;
public MVCoreConfigMigrator(MultiverseCore core) {
this.core = core;
}
public boolean migrate(String name, File folder) {
File oldFolder = this.detectMultiverseFolders(folder, core);
if (name.equalsIgnoreCase("worlds.yml")) {
return this.migrateWorlds(name, oldFolder, folder);
}
if (name.equalsIgnoreCase("config.yml")) {
return this.migrateMainConfig(name, oldFolder, folder);
}
return true;
}
private boolean migrateWorlds(String name, File oldFolder, File newFolder) {
Configuration newConfig = new Configuration(new File(newFolder, "worlds.yml"));
this.core.log(Level.INFO, "Trying to migrate worlds.yml...");
Configuration oldConfig = new Configuration(new File(oldFolder, "Worlds.yml"));
oldConfig.load();
List<String> keys = oldConfig.getKeys("worlds");
if (keys == null) {
this.core.log(Level.SEVERE, "Migration FAILURE!");
return false;
}
for (String key : keys) {
newConfig.setProperty("worlds." + key + ".animals.spawn", oldConfig.getProperty("worlds." + key + ".animals"));
newConfig.setProperty("worlds." + key + ".monsters.spawn", oldConfig.getProperty("worlds." + key + ".mobs"));
newConfig.setProperty("worlds." + key + ".pvp", oldConfig.getProperty("worlds." + key + ".pvp"));
newConfig.setProperty("worlds." + key + ".alias.name", oldConfig.getProperty("worlds." + key + ".alias"));
newConfig.setProperty("worlds." + key + ".tempspawn", oldConfig.getProperty("worlds." + key + ".spawn"));
newConfig.setProperty("worlds." + key + ".entryfee.amount", oldConfig.getProperty("worlds." + key + ".price"));
newConfig.setProperty("worlds." + key + ".entryfee.currency", -1);
newConfig.setProperty("worlds." + key + ".environment", oldConfig.getProperty("worlds." + key + ".environment"));
// Have to convert CSLs to arrays
migrateListItem(newConfig, oldConfig, key, ".blockBlacklist", ".blockblacklist");
migrateListItem(newConfig, oldConfig, key, ".worldBlacklist", ".worldblacklist");
}
newConfig.save();
this.core.log(Level.INFO, "Migration SUCCESS!");
return true;
}
private boolean migrateMainConfig(String name, File oldFolder, File newFolder) {
Configuration newConfig = new Configuration(new File(newFolder, "config.yml"));
this.core.log(Level.INFO, "Migrating config.yml...");
Configuration oldConfig = new Configuration(new File(oldFolder, "MultiVerse.yml"));
oldConfig.load();
newConfig.setProperty("worldnameprefix", oldConfig.getProperty("prefix"));
newConfig.setProperty("messagecooldown", oldConfig.getProperty("alertcooldown"));
// Default values:
newConfig.setProperty("opfallback", true);
newConfig.setProperty("disableautoheal", false);
newConfig.setProperty("fakepvp", false);
newConfig.setProperty("version", 2.2);
newConfig.save();
return true;
}
}

View File

@ -8,7 +8,6 @@
package com.onarandombox.MultiverseCore.event;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.configuration.MVConfigProperty;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
@ -17,7 +16,7 @@ import org.bukkit.event.Event;
* This event is fired *before* the property is actually changed.
* <p/>
* If it is cancled, no change will happen.
*
* <p/>
* If you want to get the values of the world before the change, query the world.
* If you want to get the value being changed, use getProperty()
*/

View File

@ -23,9 +23,7 @@ public class BlockSafety {
// TODO Auto-generated constructor stub
}
/**
* This function checks whether the block at the given coordinates are above air or not.
*/
/** This function checks whether the block at the given coordinates are above air or not. */
public boolean isBlockAboveAir(Location l) {
Location downOne = new Location(l.getWorld(), l.getX(), l.getY(), l.getZ());
downOne.setY(downOne.getY() - 1);