mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-25 20:16:06 +01:00
Much needed code re-format
This commit is contained in:
parent
4006e53243
commit
c4dd2e3005
@ -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;
|
||||
@ -536,8 +532,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
* This is a convenience method to allow the QueuedCommand system to call it. You should NEVER call this directly.
|
||||
*
|
||||
* @param teleporter The Person requesting that the teleport should happen.
|
||||
* @param p Player The Person being teleported.
|
||||
* @param l The potentially unsafe location.
|
||||
* @param p Player The Person being teleported.
|
||||
* @param l The potentially unsafe location.
|
||||
*/
|
||||
public void teleportPlayer(CommandSender teleporter, Player p, Location l) {
|
||||
// This command is the override, and MUST NOT TELEPORT SAFELY
|
||||
|
@ -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;
|
||||
|
@ -27,69 +27,69 @@ public class ConfigPropertyFactory {
|
||||
}
|
||||
|
||||
public BooleanConfigProperty getNewProperty(String name, boolean defaultValue, String node, String help) {
|
||||
return new BooleanConfigProperty(this.section, name, defaultValue, node, help) ;
|
||||
return new BooleanConfigProperty(this.section, name, defaultValue, node, help);
|
||||
}
|
||||
|
||||
// Integers
|
||||
public IntegerConfigProperty getNewProperty(String name, int defaultValue, String help) {
|
||||
return new IntegerConfigProperty(this.section, name, defaultValue, help) ;
|
||||
return new IntegerConfigProperty(this.section, name, defaultValue, help);
|
||||
}
|
||||
|
||||
public IntegerConfigProperty getNewProperty(String name, int defaultValue, String node, String help) {
|
||||
return new IntegerConfigProperty(this.section, name, defaultValue, node, help) ;
|
||||
return new IntegerConfigProperty(this.section, name, defaultValue, node, help);
|
||||
}
|
||||
|
||||
// Doubles
|
||||
public DoubleConfigProperty getNewProperty(String name, double defaultValue, String help) {
|
||||
return new DoubleConfigProperty(this.section, name, defaultValue, help) ;
|
||||
return new DoubleConfigProperty(this.section, name, defaultValue, help);
|
||||
}
|
||||
|
||||
public DoubleConfigProperty getNewProperty(String name, double defaultValue, String node, String help) {
|
||||
return new DoubleConfigProperty(this.section, name, defaultValue, node, help) ;
|
||||
return new DoubleConfigProperty(this.section, name, defaultValue, node, help);
|
||||
}
|
||||
|
||||
// Strings
|
||||
public StringConfigProperty getNewProperty(String name, String defaultValue, String help) {
|
||||
return new StringConfigProperty(this.section, name, defaultValue, help) ;
|
||||
return new StringConfigProperty(this.section, name, defaultValue, help);
|
||||
}
|
||||
|
||||
public StringConfigProperty getNewProperty(String name, String defaultValue, String node, String help) {
|
||||
return new StringConfigProperty(this.section, name, defaultValue, node, help) ;
|
||||
return new StringConfigProperty(this.section, name, defaultValue, node, help);
|
||||
}
|
||||
|
||||
// Colors
|
||||
public ColorConfigProperty getNewProperty(String name, EnglishChatColor defaultValue, String help) {
|
||||
return new ColorConfigProperty(this.section, name, defaultValue, help) ;
|
||||
return new ColorConfigProperty(this.section, name, defaultValue, help);
|
||||
}
|
||||
|
||||
public ColorConfigProperty getNewProperty(String name, EnglishChatColor defaultValue, String node, String help) {
|
||||
return new ColorConfigProperty(this.section, name, defaultValue, node, help) ;
|
||||
return new ColorConfigProperty(this.section, name, defaultValue, node, help);
|
||||
}
|
||||
|
||||
// Difficulty
|
||||
public DifficultyConfigProperty getNewProperty(String name, Difficulty defaultValue, String help) {
|
||||
return new DifficultyConfigProperty(this.section, name, defaultValue, help) ;
|
||||
return new DifficultyConfigProperty(this.section, name, defaultValue, help);
|
||||
}
|
||||
|
||||
public DifficultyConfigProperty getNewProperty(String name, Difficulty defaultValue, String node, String help) {
|
||||
return new DifficultyConfigProperty(this.section, name, defaultValue, node, help) ;
|
||||
return new DifficultyConfigProperty(this.section, name, defaultValue, node, help);
|
||||
}
|
||||
|
||||
// GameMode
|
||||
public GameModeConfigProperty getNewProperty(String name, GameMode defaultValue, String help) {
|
||||
return new GameModeConfigProperty(this.section, name, defaultValue, help) ;
|
||||
return new GameModeConfigProperty(this.section, name, defaultValue, help);
|
||||
}
|
||||
|
||||
public GameModeConfigProperty getNewProperty(String name, GameMode defaultValue, String node, String help) {
|
||||
return new GameModeConfigProperty(this.section, name, defaultValue, node, help) ;
|
||||
return new GameModeConfigProperty(this.section, name, defaultValue, node, help);
|
||||
}
|
||||
|
||||
// GameMode
|
||||
public LocationConfigProperty getNewProperty(String name, Location defaultValue, String help) {
|
||||
return new LocationConfigProperty(this.section, name, defaultValue, help) ;
|
||||
return new LocationConfigProperty(this.section, name, defaultValue, help);
|
||||
}
|
||||
|
||||
public LocationConfigProperty getNewProperty(String name, Location defaultValue, String node, String help) {
|
||||
return new LocationConfigProperty(this.section, name, defaultValue, node, help) ;
|
||||
return new LocationConfigProperty(this.section, name, defaultValue, node, help);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
|
||||
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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()
|
||||
*/
|
||||
|
@ -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);
|
||||
|
@ -257,10 +257,10 @@ public class LocationManipulation {
|
||||
return new Location(w, Double.parseDouble(xyzsplit[0]), Double.parseDouble(xyzsplit[1]), Double.parseDouble(xyzsplit[2]));
|
||||
}
|
||||
if (split.length == 3) {
|
||||
return new Location(w, Double.parseDouble(xyzsplit[0]), Double.parseDouble(xyzsplit[1]), Double.parseDouble(xyzsplit[2]), (float) Double.parseDouble(split[2]),(float) 0.0);
|
||||
return new Location(w, Double.parseDouble(xyzsplit[0]), Double.parseDouble(xyzsplit[1]), Double.parseDouble(xyzsplit[2]), (float) Double.parseDouble(split[2]), (float) 0.0);
|
||||
}
|
||||
return new Location(w, Double.parseDouble(xyzsplit[0]), Double.parseDouble(xyzsplit[1]), Double.parseDouble(xyzsplit[2]), (float) Double.parseDouble(split[2]), (float) Double.parseDouble(split[3]));
|
||||
} catch(NumberFormatException e) {
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -312,15 +312,15 @@ public class SafeTTeleporter {
|
||||
return blockA;
|
||||
}
|
||||
// Center our calculations
|
||||
blockA.add(.5,0,.5);
|
||||
blockB.add(.5,0,.5);
|
||||
blockA.add(.5, 0, .5);
|
||||
blockB.add(.5, 0, .5);
|
||||
|
||||
// Retrieve the distance to the normalized blocks
|
||||
double testA = source.distance(blockA);
|
||||
double testB = source.distance(blockB);
|
||||
|
||||
// Compare and return
|
||||
if(testA <= testB) {
|
||||
if (testA <= testB) {
|
||||
return blockA;
|
||||
}
|
||||
return blockB;
|
||||
|
Loading…
Reference in New Issue
Block a user