mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-07 11:20:32 +01:00
Implement new config items
This commit is contained in:
parent
4366b16a74
commit
f4093cbe51
@ -11,11 +11,14 @@ import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
|||||||
import com.onarandombox.MultiverseCore.utils.EnglishChatColor;
|
import com.onarandombox.MultiverseCore.utils.EnglishChatColor;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
import org.bukkit.permissions.PermissionDefault;
|
import org.bukkit.permissions.PermissionDefault;
|
||||||
import org.bukkit.util.config.Configuration;
|
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -26,7 +29,8 @@ import java.util.logging.Level;
|
|||||||
public class MVWorld implements MultiverseWorld {
|
public class MVWorld implements MultiverseWorld {
|
||||||
|
|
||||||
private MultiverseCore plugin; // Hold the Plugin Instance.
|
private MultiverseCore plugin; // Hold the Plugin Instance.
|
||||||
private Configuration config; // Hold the Configuration File.
|
private FileConfiguration config; // Hold the Configuration File.
|
||||||
|
private ConfigurationSection worldSection; // Holds the section of the config file for this world.
|
||||||
|
|
||||||
private World world; // The World Instance.
|
private World world; // The World Instance.
|
||||||
private Environment environment; // Hold the Environment type EG Environment.NETHER / Environment.NORMAL
|
private Environment environment; // Hold the Environment type EG Environment.NETHER / Environment.NORMAL
|
||||||
@ -63,7 +67,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
private Location spawnLocation;
|
private Location spawnLocation;
|
||||||
private boolean isHidden = false;
|
private boolean isHidden = false;
|
||||||
|
|
||||||
public MVWorld(World world, Configuration config, MultiverseCore instance, Long seed, String generatorString) {
|
public MVWorld(World world, FileConfiguration config, MultiverseCore instance, Long seed, String generatorString) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.plugin = instance;
|
this.plugin = instance;
|
||||||
|
|
||||||
@ -75,40 +79,41 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
// Initialize our lists
|
// Initialize our lists
|
||||||
this.initLists();
|
this.initLists();
|
||||||
|
worldSection = config.getConfigurationSection("worlds." + this.name);
|
||||||
// Write these files to the config (once it's saved)
|
// Write these files to the config (once it's saved)
|
||||||
if (generatorString != null) {
|
if (generatorString != null) {
|
||||||
config.setProperty("worlds." + this.name + ".generator", generatorString);
|
worldSection.set("generator", generatorString);
|
||||||
}
|
}
|
||||||
if (seed != null) {
|
if (seed != null) {
|
||||||
config.setProperty("worlds." + this.name + ".seed", this.seed);
|
worldSection.set("worlds." + this.name + "seed", this.seed);
|
||||||
}
|
}
|
||||||
config.setProperty("worlds." + this.name + ".environment", this.environment.toString());
|
worldSection.set("worlds." + this.name + "environment", this.environment.toString());
|
||||||
|
|
||||||
|
|
||||||
// Set local values that CAN be changed by the user
|
// Set local values that CAN be changed by the user
|
||||||
this.setAlias(config.getString("worlds." + this.name + ".alias.name", ""));
|
this.setAlias(worldSection.getString("alias.name", ""));
|
||||||
this.setColor(config.getString("worlds." + this.name + ".alias.color", ChatColor.WHITE.toString()));
|
this.setColor(worldSection.getString("alias.color", ChatColor.WHITE.toString()));
|
||||||
this.setFakePVPMode(config.getBoolean("worlds." + this.name + ".fakepvp", false));
|
this.setFakePVPMode(worldSection.getBoolean("fakepvp", false));
|
||||||
this.setPVPMode(config.getBoolean("worlds." + this.name + ".pvp", true));
|
this.setPVPMode(worldSection.getBoolean("pvp", true));
|
||||||
this.setScaling(config.getDouble("worlds." + this.name + ".scale", this.getDefaultScale(this.environment)));
|
this.setScaling(worldSection.getDouble("scale", this.getDefaultScale(this.environment)));
|
||||||
this.setRespawnToWorld(config.getString("worlds." + this.name + ".respawnworld", ""));
|
this.setRespawnToWorld(worldSection.getString("respawnworld", ""));
|
||||||
this.setEnableWeather(config.getBoolean("worlds." + this.name + ".allowweather", true));
|
this.setEnableWeather(worldSection.getBoolean("allowweather", true));
|
||||||
this.setDifficulty(config.getString("worlds." + this.name + ".difficulty", "1"));
|
this.setDifficulty(worldSection.getString("difficulty", "1"));
|
||||||
|
|
||||||
this.setAllowAnimalSpawn(config.getBoolean("worlds." + this.name + ".animals.spawn", true));
|
this.setAllowAnimalSpawn(worldSection.getBoolean("animals.spawn", true));
|
||||||
this.setAllowMonsterSpawn(config.getBoolean("worlds." + this.name + ".monsters.spawn", true));
|
this.setAllowMonsterSpawn(worldSection.getBoolean("monsters.spawn", true));
|
||||||
this.setPrice(config.getDouble("worlds." + this.name + ".entryfee.amount", 0.0));
|
this.setPrice(worldSection.getDouble("entryfee.amount", 0.0));
|
||||||
this.setCurrency(config.getInt("worlds." + this.name + ".entryfee.currency", -1));
|
this.setCurrency(worldSection.getInt("entryfee.currency", -1));
|
||||||
this.setHunger(config.getBoolean("worlds." + this.name + ".hunger", true));
|
this.setHunger(worldSection.getBoolean("hunger", true));
|
||||||
this.setHidden(config.getBoolean("worlds." + this.name + ".hidden", false));
|
this.setHidden(worldSection.getBoolean("hidden", false));
|
||||||
this.getMobExceptions();
|
this.getMobExceptions();
|
||||||
|
|
||||||
this.setGameMode(config.getString("worlds." + this.name + ".gamemode", GameMode.SURVIVAL.toString()));
|
this.setGameMode(worldSection.getString("gamemode", GameMode.SURVIVAL.toString()));
|
||||||
|
|
||||||
this.setKeepSpawnInMemory(config.getBoolean("worlds." + this.name + ".keepspawninmemory", true));
|
this.setKeepSpawnInMemory(worldSection.getBoolean("keepspawninmemory", true));
|
||||||
|
|
||||||
this.getWorldBlacklist().addAll(config.getStringList("worlds." + this.name + ".worldblacklist", new ArrayList<String>()));
|
this.getWorldBlacklist().addAll(worldSection.getList("worldblacklist", new ArrayList<String>()));
|
||||||
this.translateTempSpawn(config);
|
this.translateTempSpawn(worldSection);
|
||||||
this.readSpawnFromConfig(this.getCBWorld());
|
this.readSpawnFromConfig(this.getCBWorld());
|
||||||
this.canSave = true;
|
this.canSave = true;
|
||||||
saveConfig();
|
saveConfig();
|
||||||
@ -138,7 +143,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
this.getCBWorld().setStorm(false);
|
this.getCBWorld().setStorm(false);
|
||||||
this.getCBWorld().setThundering(false);
|
this.getCBWorld().setThundering(false);
|
||||||
}
|
}
|
||||||
this.config.setProperty("worlds." + this.name + ".allowweather", weather);
|
this.worldSection.set("allowweather", weather);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,8 +173,8 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(allWorlds);
|
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(allWorlds);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void translateTempSpawn(Configuration config) {
|
private void translateTempSpawn(ConfigurationSection section) {
|
||||||
String tempspawn = config.getString("worlds." + this.name + ".tempspawn", "");
|
String tempspawn = section.getString("tempspawn", "");
|
||||||
if (tempspawn.length() > 0) {
|
if (tempspawn.length() > 0) {
|
||||||
String[] coordsString = tempspawn.split(":");
|
String[] coordsString = tempspawn.split(":");
|
||||||
if (coordsString.length >= 3) {
|
if (coordsString.length >= 3) {
|
||||||
@ -186,7 +191,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
this.plugin.log(Level.WARNING, "A MV1 spawn value was found, but it could not be migrated. Format Error. Sorry.");
|
this.plugin.log(Level.WARNING, "A MV1 spawn value was found, but it could not be migrated. Format Error. Sorry.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.config.removeProperty("worlds." + this.name + ".tempspawn");
|
this.worldSection.set("tempspawn", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,13 +201,13 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
private void getMobExceptions() {
|
private void getMobExceptions() {
|
||||||
List<String> temp;
|
List<String> temp;
|
||||||
temp = this.config.getStringList("worlds." + this.name + ".animals.exceptions", new ArrayList<String>());
|
temp = this.worldSection.getList("animals.exceptions", new ArrayList<String>());
|
||||||
// Add Animals to the exclusion list
|
// Add Animals to the exclusion list
|
||||||
|
|
||||||
for (String s : temp) {
|
for (String s : temp) {
|
||||||
this.masterList.get("animals").add(s.toUpperCase());
|
this.masterList.get("animals").add(s.toUpperCase());
|
||||||
}
|
}
|
||||||
temp = this.config.getStringList("worlds." + this.name + ".monsters.exceptions", new ArrayList<String>());
|
temp = this.worldSection.getList("monsters.exceptions", new ArrayList<String>());
|
||||||
// Add Monsters to the exclusion list
|
// Add Monsters to the exclusion list
|
||||||
for (String s : temp) {
|
for (String s : temp) {
|
||||||
this.masterList.get("monsters").add(s.toUpperCase());
|
this.masterList.get("monsters").add(s.toUpperCase());
|
||||||
@ -227,7 +232,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.config.setProperty("worlds." + this.name + "." + property.toLowerCase(), new ArrayList<String>());
|
this.worldSection.set(property.toLowerCase(), new ArrayList<String>());
|
||||||
this.saveConfig();
|
this.saveConfig();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -238,11 +243,11 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
if (property.equalsIgnoreCase("animals") || property.equalsIgnoreCase("monsters")) {
|
if (property.equalsIgnoreCase("animals") || property.equalsIgnoreCase("monsters")) {
|
||||||
this.masterList.get(property).add(value.toUpperCase());
|
this.masterList.get(property).add(value.toUpperCase());
|
||||||
this.config.setProperty("worlds." + this.name + "." + property.toLowerCase() + ".exceptions", this.masterList.get(property));
|
this.worldSection.set(property.toLowerCase() + ".exceptions", this.masterList.get(property));
|
||||||
this.syncMobs();
|
this.syncMobs();
|
||||||
} else {
|
} else {
|
||||||
this.masterList.get(property).add(value);
|
this.masterList.get(property).add(value);
|
||||||
this.config.setProperty("worlds." + this.name + "." + property.toLowerCase(), this.masterList.get(property));
|
this.worldSection.set(property.toLowerCase(), this.masterList.get(property));
|
||||||
}
|
}
|
||||||
saveConfig();
|
saveConfig();
|
||||||
return true;
|
return true;
|
||||||
@ -256,11 +261,11 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
if (property.equalsIgnoreCase("animals") || property.equalsIgnoreCase("monsters")) {
|
if (property.equalsIgnoreCase("animals") || property.equalsIgnoreCase("monsters")) {
|
||||||
this.masterList.get(property).remove(value.toUpperCase());
|
this.masterList.get(property).remove(value.toUpperCase());
|
||||||
this.config.setProperty("worlds." + this.name + "." + property.toLowerCase() + ".exceptions", this.masterList.get(property));
|
this.worldSection.set("" + property.toLowerCase() + ".exceptions", this.masterList.get(property));
|
||||||
this.syncMobs();
|
this.syncMobs();
|
||||||
} else {
|
} else {
|
||||||
this.masterList.get(property).remove(value);
|
this.masterList.get(property).remove(value);
|
||||||
this.config.setProperty("worlds." + this.name + "." + property.toLowerCase(), this.masterList.get(property));
|
this.worldSection.set("" + property.toLowerCase(), this.masterList.get(property));
|
||||||
}
|
}
|
||||||
saveConfig();
|
saveConfig();
|
||||||
return true;
|
return true;
|
||||||
@ -320,7 +325,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
public void setKeepSpawnInMemory(boolean value) {
|
public void setKeepSpawnInMemory(boolean value) {
|
||||||
this.world.setKeepSpawnInMemory(value);
|
this.world.setKeepSpawnInMemory(value);
|
||||||
this.keepSpawnInMemory = value;
|
this.keepSpawnInMemory = value;
|
||||||
this.config.setProperty("worlds." + this.name + ".keepspawninmemory", value);
|
this.worldSection.set("keepspawninmemory", value);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,7 +422,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
@Override
|
@Override
|
||||||
public void setAlias(String alias) {
|
public void setAlias(String alias) {
|
||||||
this.alias = alias;
|
this.alias = alias;
|
||||||
this.config.setProperty("worlds." + this.name + ".alias.name", alias);
|
this.worldSection.set("alias.name", alias);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,7 +436,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
this.allowAnimals = animals;
|
this.allowAnimals = animals;
|
||||||
// If animals are a boolean, then we can turn them on or off on the server
|
// If animals are a boolean, then we can turn them on or off on the server
|
||||||
// If there are ANY exceptions, there will be something spawning, so turn them on
|
// If there are ANY exceptions, there will be something spawning, so turn them on
|
||||||
this.config.setProperty("worlds." + this.name + ".animals.spawn", animals);
|
this.worldSection.set("animals.spawn", animals);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
this.syncMobs();
|
this.syncMobs();
|
||||||
}
|
}
|
||||||
@ -451,7 +456,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
this.allowMonsters = monsters;
|
this.allowMonsters = monsters;
|
||||||
// If monsters are a boolean, then we can turn them on or off on the server
|
// If monsters are a boolean, then we can turn them on or off on the server
|
||||||
// If there are ANY exceptions, there will be something spawning, so turn them on
|
// If there are ANY exceptions, there will be something spawning, so turn them on
|
||||||
this.config.setProperty("worlds." + this.name + ".monsters.spawn", monsters);
|
this.worldSection.set("monsters.spawn", monsters);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
this.syncMobs();
|
this.syncMobs();
|
||||||
}
|
}
|
||||||
@ -474,7 +479,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
this.world.setPVP(pvp);
|
this.world.setPVP(pvp);
|
||||||
}
|
}
|
||||||
this.pvp = pvp;
|
this.pvp = pvp;
|
||||||
this.config.setProperty("worlds." + this.name + ".pvp", pvp);
|
this.worldSection.set("pvp", pvp);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -498,13 +503,13 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
@Override
|
@Override
|
||||||
public void setHidden(boolean hidden) {
|
public void setHidden(boolean hidden) {
|
||||||
this.isHidden = hidden;
|
this.isHidden = hidden;
|
||||||
this.config.setProperty("worlds." + this.name + ".hidden", hidden);
|
this.worldSection.set("hidden", hidden);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFakePVPMode(Boolean fakePVPMode) {
|
public void setFakePVPMode(Boolean fakePVPMode) {
|
||||||
this.fakePVP = fakePVPMode;
|
this.fakePVP = fakePVPMode;
|
||||||
this.config.setProperty("worlds." + this.name + ".fakepvp", this.fakePVP);
|
this.worldSection.set("fakepvp", this.fakePVP);
|
||||||
// Now that we've set PVP mode, make sure to go through the normal setting too!
|
// Now that we've set PVP mode, make sure to go through the normal setting too!
|
||||||
// This method will perform the save for us to eliminate one write.
|
// This method will perform the save for us to eliminate one write.
|
||||||
this.setPVPMode(this.pvp);
|
this.setPVPMode(this.pvp);
|
||||||
@ -526,7 +531,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
scaling = 1.0;
|
scaling = 1.0;
|
||||||
}
|
}
|
||||||
this.scaling = scaling;
|
this.scaling = scaling;
|
||||||
this.config.setProperty("worlds." + this.name + ".scale", scaling);
|
this.worldSection.set("scale", scaling);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -537,7 +542,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.aliasColor = color.getColor();
|
this.aliasColor = color.getColor();
|
||||||
this.config.setProperty("worlds." + this.name + ".alias.color", color.getText());
|
this.worldSection.set("alias.color", color.getText());
|
||||||
saveConfig();
|
saveConfig();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -554,7 +559,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
public boolean clearList(String property) {
|
public boolean clearList(String property) {
|
||||||
if (this.masterList.containsKey(property)) {
|
if (this.masterList.containsKey(property)) {
|
||||||
this.masterList.get(property).clear();
|
this.masterList.get(property).clear();
|
||||||
this.config.setProperty("worlds." + this.name + "." + property.toLowerCase(), this.masterList.get(property));
|
this.worldSection.set(property.toLowerCase(), this.masterList.get(property));
|
||||||
this.syncMobs();
|
this.syncMobs();
|
||||||
saveConfig();
|
saveConfig();
|
||||||
return true;
|
return true;
|
||||||
@ -578,7 +583,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
public boolean setRespawnToWorld(String respawnToWorld) {
|
public boolean setRespawnToWorld(String respawnToWorld) {
|
||||||
if (this.plugin.getServer().getWorld(respawnToWorld) != null) {
|
if (this.plugin.getServer().getWorld(respawnToWorld) != null) {
|
||||||
this.respawnWorld = respawnToWorld;
|
this.respawnWorld = respawnToWorld;
|
||||||
this.config.setProperty("worlds." + this.name + ".respawnworld", respawnToWorld);
|
this.worldSection.set("respawnworld", respawnToWorld);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -603,14 +608,14 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
@Override
|
@Override
|
||||||
public void setCurrency(int currency) {
|
public void setCurrency(int currency) {
|
||||||
this.currency = currency;
|
this.currency = currency;
|
||||||
config.setProperty("worlds." + this.name + ".entryfee.currency", currency);
|
this.worldSection.set("entryfee.currency", currency);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPrice(double price) {
|
public void setPrice(double price) {
|
||||||
this.price = price;
|
this.price = price;
|
||||||
config.setProperty("worlds." + this.name + ".entryfee.amount", price);
|
this.worldSection.set("entryfee.amount", price);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -627,7 +632,11 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
private void saveConfig() {
|
private void saveConfig() {
|
||||||
if (this.canSave) {
|
if (this.canSave) {
|
||||||
this.config.save();
|
try {
|
||||||
|
this.config.save(new File(this.plugin.getDataFolder(), "worlds.yml"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
this.plugin.log(Level.SEVERE, "Could not save worlds.yml. Please check your filesystem permissions.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -649,7 +658,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.setGameMode(mode);
|
this.setGameMode(mode);
|
||||||
config.setProperty("worlds." + this.name + ".gamemode", mode.getValue());
|
this.worldSection.set("gamemode", mode.getValue());
|
||||||
saveConfig();
|
saveConfig();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -658,7 +667,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
private boolean setGameMode(GameMode mode) {
|
private boolean setGameMode(GameMode mode) {
|
||||||
|
|
||||||
this.gameMode = mode;
|
this.gameMode = mode;
|
||||||
config.setProperty("worlds." + this.name + ".gamemode", this.gameMode.toString());
|
this.worldSection.set("gamemode", this.gameMode.toString());
|
||||||
saveConfig();
|
saveConfig();
|
||||||
|
|
||||||
if (MultiverseCore.EnforceGameModes) {
|
if (MultiverseCore.EnforceGameModes) {
|
||||||
@ -687,7 +696,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
@Override
|
@Override
|
||||||
public void setHunger(boolean hunger) {
|
public void setHunger(boolean hunger) {
|
||||||
this.hunger = hunger;
|
this.hunger = hunger;
|
||||||
config.setProperty("worlds." + this.name + ".hunger", this.hunger);
|
this.worldSection.set("hunger", this.hunger);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -699,22 +708,22 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
@Override
|
@Override
|
||||||
public void setSpawnLocation(Location l) {
|
public void setSpawnLocation(Location l) {
|
||||||
this.getCBWorld().setSpawnLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
this.getCBWorld().setSpawnLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||||
config.setProperty("worlds." + this.name + ".spawn.x", l.getX());
|
this.worldSection.set("spawn.x", l.getX());
|
||||||
config.setProperty("worlds." + this.name + ".spawn.y", l.getY());
|
this.worldSection.set("spawn.y", l.getY());
|
||||||
config.setProperty("worlds." + this.name + ".spawn.z", l.getZ());
|
this.worldSection.set("spawn.z", l.getZ());
|
||||||
config.setProperty("worlds." + this.name + ".spawn.pitch", l.getPitch());
|
this.worldSection.set("spawn.pitch", l.getPitch());
|
||||||
config.setProperty("worlds." + this.name + ".spawn.yaw", l.getYaw());
|
this.worldSection.set("spawn.yaw", l.getYaw());
|
||||||
this.getCBWorld().setSpawnLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
this.getCBWorld().setSpawnLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||||
this.spawnLocation = l.clone();
|
this.spawnLocation = l.clone();
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readSpawnFromConfig(World w) {
|
private void readSpawnFromConfig(World w) {
|
||||||
double x = config.getDouble("worlds." + this.name + ".spawn.x", w.getSpawnLocation().getX());
|
double x = config.getDouble("spawn.x", w.getSpawnLocation().getX());
|
||||||
double y = config.getDouble("worlds." + this.name + ".spawn.y", w.getSpawnLocation().getY());
|
double y = config.getDouble("spawn.y", w.getSpawnLocation().getY());
|
||||||
double z = config.getDouble("worlds." + this.name + ".spawn.z", w.getSpawnLocation().getZ());
|
double z = config.getDouble("spawn.z", w.getSpawnLocation().getZ());
|
||||||
float pitch = (float) config.getDouble("worlds." + this.name + ".spawn.pitch", w.getSpawnLocation().getPitch());
|
float pitch = (float) config.getDouble("spawn.pitch", w.getSpawnLocation().getPitch());
|
||||||
float yaw = (float) config.getDouble("worlds." + this.name + ".spawn.yaw", w.getSpawnLocation().getYaw());
|
float yaw = (float) config.getDouble("spawn.yaw", w.getSpawnLocation().getYaw());
|
||||||
this.spawnLocation = new Location(w, x, y, z, yaw, pitch);
|
this.spawnLocation = new Location(w, x, y, z, yaw, pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -746,8 +755,20 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.getCBWorld().setDifficulty(worlddiff);
|
this.getCBWorld().setDifficulty(worlddiff);
|
||||||
config.setProperty("worlds." + this.name + ".difficulty", worlddiff.getValue());
|
this.worldSection.set("difficulty", worlddiff.getValue());
|
||||||
saveConfig();
|
saveConfig();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Implment this, I'm going to bed tonight.
|
||||||
|
@Override
|
||||||
|
public boolean getAutoHeal() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implment this, I'm going to bed tonight.
|
||||||
|
@Override
|
||||||
|
public void setAutoHeal(boolean heal) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import com.fernferret.allpay.GenericBank;
|
|||||||
import com.onarandombox.MultiverseCore.api.Core;
|
import com.onarandombox.MultiverseCore.api.Core;
|
||||||
import com.onarandombox.MultiverseCore.api.MVPlugin;
|
import com.onarandombox.MultiverseCore.api.MVPlugin;
|
||||||
import com.onarandombox.MultiverseCore.commands.*;
|
import com.onarandombox.MultiverseCore.commands.*;
|
||||||
import com.onarandombox.MultiverseCore.configuration.DefaultConfig;
|
|
||||||
import com.onarandombox.MultiverseCore.configuration.MVConfigMigrator;
|
import com.onarandombox.MultiverseCore.configuration.MVConfigMigrator;
|
||||||
import com.onarandombox.MultiverseCore.configuration.MVCoreConfigMigrator;
|
import com.onarandombox.MultiverseCore.configuration.MVCoreConfigMigrator;
|
||||||
import com.onarandombox.MultiverseCore.destination.*;
|
import com.onarandombox.MultiverseCore.destination.*;
|
||||||
@ -28,7 +27,7 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.Configuration;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -36,7 +35,6 @@ import org.bukkit.event.Event;
|
|||||||
import org.bukkit.event.Event.Priority;
|
import org.bukkit.event.Event.Priority;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.util.config.Configuration;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -52,6 +50,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
// to worlds.
|
// to worlds.
|
||||||
public static boolean EnforceAccess;
|
public static boolean EnforceAccess;
|
||||||
public static boolean EnforceGameModes;
|
public static boolean EnforceGameModes;
|
||||||
|
public static boolean PrefixChat;
|
||||||
|
public static boolean BedRespawn;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -89,7 +89,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
private MVPermissions ph;
|
private MVPermissions ph;
|
||||||
|
|
||||||
// Configurations
|
// Configurations
|
||||||
private Configuration configMV = null;
|
|
||||||
private FileConfiguration multiverseConfig = null;
|
private FileConfiguration multiverseConfig = null;
|
||||||
|
|
||||||
private WorldManager worldManager = new WorldManager(this);
|
private WorldManager worldManager = new WorldManager(this);
|
||||||
@ -125,10 +124,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
debugLog = new DebugLog("Multiverse-Core", getDataFolder() + File.separator + "debug.log");
|
debugLog = new DebugLog("Multiverse-Core", getDataFolder() + File.separator + "debug.log");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Configuration getMVConfig() {
|
|
||||||
return this.configMV;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileConfiguration getMVConfiguration() {
|
public FileConfiguration getMVConfiguration() {
|
||||||
return this.multiverseConfig;
|
return this.multiverseConfig;
|
||||||
}
|
}
|
||||||
@ -259,40 +254,28 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
|
|
||||||
/** Load the Configuration files OR create the default config files. */
|
/** Load the Configuration files OR create the default config files. */
|
||||||
public void loadConfigs() {
|
public void loadConfigs() {
|
||||||
|
|
||||||
// Call the defaultConfiguration class to create the config files if they don't already exist.
|
|
||||||
new DefaultConfig(getDataFolder(), "config.yml", this.migrator);
|
|
||||||
new DefaultConfig(getDataFolder(), "worlds.yml", this.migrator);
|
|
||||||
// Now grab the Configuration Files.
|
// Now grab the Configuration Files.
|
||||||
this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
|
this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
|
||||||
|
Configuration coreDefaults = YamlConfiguration.loadConfiguration(this.getClass().getResourceAsStream("/defaults/config.yml"));
|
||||||
|
this.multiverseConfig.setDefaults(coreDefaults);
|
||||||
this.worldManager.loadWorldConfig(new File(getDataFolder(), "worlds.yml"));
|
this.worldManager.loadWorldConfig(new File(getDataFolder(), "worlds.yml"));
|
||||||
|
|
||||||
// Now attempt to Load the configurations.
|
|
||||||
try {
|
|
||||||
this.configMV.load();
|
|
||||||
log(Level.INFO, "- Multiverse Config -- Loaded");
|
|
||||||
} catch (Exception e) {
|
|
||||||
log(Level.INFO, "- Failed to load config.yml");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
this.worldManager.propagateConfigFile();
|
|
||||||
log(Level.INFO, "- World Config -- Loaded");
|
|
||||||
} catch (Exception e) {
|
|
||||||
log(Level.INFO, "- Failed to load worlds.yml");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup the Debug option, we'll default to false because this option will not be in the default config.
|
// Setup the Debug option, we'll default to false because this option will not be in the default config.
|
||||||
GlobalDebug = this.configMV.getInt("debug", 0);
|
GlobalDebug = this.multiverseConfig.getInt("debug", 0);
|
||||||
// Lets cache this value due to the fact that it will be accessed many times.
|
// Lets cache this value due to the fact that it will be accessed many times.
|
||||||
EnforceAccess = this.configMV.getBoolean("enforceaccess", false);
|
EnforceAccess = this.multiverseConfig.getBoolean("enforceaccess", false);
|
||||||
EnforceGameModes = this.configMV.getBoolean("enforcegamemodes", true);
|
EnforceGameModes = this.multiverseConfig.getBoolean("enforcegamemodes", true);
|
||||||
this.configMV.setProperty("enforceaccess", EnforceAccess);
|
PrefixChat = this.multiverseConfig.getBoolean("worldnameprefix", true);
|
||||||
this.configMV.setProperty("enforcegamemodes", EnforceAccess);
|
BedRespawn = this.multiverseConfig.getBoolean("bedrespawn", true);
|
||||||
|
this.multiverseConfig.set("enforceaccess", EnforceAccess);
|
||||||
|
this.multiverseConfig.set("enforcegamemodes", EnforceAccess);
|
||||||
this.messaging = new MVMessaging(this);
|
this.messaging = new MVMessaging(this);
|
||||||
this.messaging.setCooldown(this.configMV.getInt("messagecooldown", 5000));
|
this.messaging.setCooldown(this.multiverseConfig.getInt("messagecooldown", 5000));
|
||||||
this.configMV.save();
|
try {
|
||||||
|
this.multiverseConfig.save(new File(getDataFolder(), "config.yml"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
this.log(Level.SEVERE, "Could not save Multiverse config. Please check your file permissions.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MVMessaging getMessaging() {
|
public MVMessaging getMessaging() {
|
||||||
@ -381,7 +364,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
if (this.playerSessions.containsKey(player.getName())) {
|
if (this.playerSessions.containsKey(player.getName())) {
|
||||||
return this.playerSessions.get(player.getName());
|
return this.playerSessions.get(player.getName());
|
||||||
} else {
|
} else {
|
||||||
this.playerSessions.put(player.getName(), new MVPlayerSession(player, this.configMV, this));
|
this.playerSessions.put(player.getName(), new MVPlayerSession(player, this.multiverseConfig, this));
|
||||||
return this.playerSessions.get(player.getName());
|
return this.playerSessions.get(player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,14 +21,6 @@ import org.bukkit.util.config.Configuration;
|
|||||||
* This API contains a bunch of useful things you can get out of Multiverse in general!
|
* This API contains a bunch of useful things you can get out of Multiverse in general!
|
||||||
*/
|
*/
|
||||||
public interface Core {
|
public interface Core {
|
||||||
/**
|
|
||||||
* Gets the Multiverse config file.
|
|
||||||
* Now Deprecated, use {@link #getMVConfiguration()}
|
|
||||||
*
|
|
||||||
* @return The Multiverse config file.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public Configuration getMVConfig();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Multiverse config file.
|
* Gets the Multiverse config file.
|
||||||
|
@ -424,4 +424,18 @@ public interface MultiverseWorld {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean clearList(String property);
|
public boolean clearList(String property);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether or not a world will autoheal players if the difficulty is on peaceful.
|
||||||
|
*
|
||||||
|
* @param heal True if the world will heal.
|
||||||
|
*/
|
||||||
|
public void setAutoHeal(boolean heal);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether or not a world will autoheal players if the difficulty is on peaceful.
|
||||||
|
*
|
||||||
|
* @return True if the world should heal (default), false if not.
|
||||||
|
*/
|
||||||
|
public boolean getAutoHeal();
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ public class ConfigCommand extends MultiverseCommand {
|
|||||||
public void runCommand(CommandSender sender, List<String> args) {
|
public void runCommand(CommandSender sender, List<String> args) {
|
||||||
if (args.get(0).equalsIgnoreCase("messagecooldown") || args.get(0).equalsIgnoreCase("teleportcooldown") || args.get(0).equalsIgnoreCase("debug")) {
|
if (args.get(0).equalsIgnoreCase("messagecooldown") || args.get(0).equalsIgnoreCase("teleportcooldown") || args.get(0).equalsIgnoreCase("debug")) {
|
||||||
try {
|
try {
|
||||||
this.plugin.getMVConfig().setProperty(args.get(0).toLowerCase(), Integer.parseInt(args.get(1)));
|
this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), Integer.parseInt(args.get(1)));
|
||||||
this.plugin.loadConfigs();
|
this.plugin.loadConfigs();
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE + " must be an integer!");
|
sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE + " must be an integer!");
|
||||||
@ -47,7 +47,7 @@ public class ConfigCommand extends MultiverseCommand {
|
|||||||
} else {
|
} else {
|
||||||
if (ConfigProperty.valueOf(args.get(0).toLowerCase()) != null) {
|
if (ConfigProperty.valueOf(args.get(0).toLowerCase()) != null) {
|
||||||
try {
|
try {
|
||||||
this.plugin.getMVConfig().setProperty(args.get(0).toLowerCase(), Boolean.parseBoolean(args.get(0)));
|
this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), Boolean.parseBoolean(args.get(0)));
|
||||||
this.plugin.loadConfigs();
|
this.plugin.loadConfigs();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE + " must be true or false!");
|
sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE + " must be true or false!");
|
||||||
|
@ -54,13 +54,13 @@ public class VersionCommand extends MultiverseCommand {
|
|||||||
logAndAddToPasteBinBuffer("Multiverse Plugins Loaded: " + this.plugin.getPluginCount());
|
logAndAddToPasteBinBuffer("Multiverse Plugins Loaded: " + this.plugin.getPluginCount());
|
||||||
logAndAddToPasteBinBuffer("Economy being used: " + this.plugin.getBank().getEconUsed());
|
logAndAddToPasteBinBuffer("Economy being used: " + this.plugin.getBank().getEconUsed());
|
||||||
logAndAddToPasteBinBuffer("Permissions Plugin: " + this.plugin.getMVPerms().getType());
|
logAndAddToPasteBinBuffer("Permissions Plugin: " + this.plugin.getMVPerms().getType());
|
||||||
logAndAddToPasteBinBuffer("Dumping Config Values: (version " + this.plugin.getMVConfig().getString("version", "NOT SET") + ")");
|
logAndAddToPasteBinBuffer("Dumping Config Values: (version " + this.plugin.getMVConfiguration().getString("version", "NOT SET") + ")");
|
||||||
logAndAddToPasteBinBuffer("messagecooldown: " + this.plugin.getMVConfig().getString("messagecooldown", "NOT SET"));
|
logAndAddToPasteBinBuffer("messagecooldown: " + this.plugin.getMVConfiguration().getString("messagecooldown", "NOT SET"));
|
||||||
logAndAddToPasteBinBuffer("teleportcooldown: " + this.plugin.getMVConfig().getString("teleportcooldown", "NOT SET"));
|
logAndAddToPasteBinBuffer("teleportcooldown: " + this.plugin.getMVConfiguration().getString("teleportcooldown", "NOT SET"));
|
||||||
logAndAddToPasteBinBuffer("worldnameprefix: " + this.plugin.getMVConfig().getString("worldnameprefix", "NOT SET"));
|
logAndAddToPasteBinBuffer("worldnameprefix: " + this.plugin.getMVConfiguration().getString("worldnameprefix", "NOT SET"));
|
||||||
logAndAddToPasteBinBuffer("opfallback: " + this.plugin.getMVConfig().getString("opfallback", "NOT SET"));
|
logAndAddToPasteBinBuffer("opfallback: " + this.plugin.getMVConfiguration().getString("opfallback", "NOT SET"));
|
||||||
logAndAddToPasteBinBuffer("disableautoheal: " + this.plugin.getMVConfig().getString("disableautoheal", "NOT SET"));
|
logAndAddToPasteBinBuffer("disableautoheal: " + this.plugin.getMVConfiguration().getString("disableautoheal", "NOT SET"));
|
||||||
logAndAddToPasteBinBuffer("fakepvp: " + this.plugin.getMVConfig().getString("fakepvp", "NOT SET"));
|
logAndAddToPasteBinBuffer("fakepvp: " + this.plugin.getMVConfiguration().getString("fakepvp", "NOT SET"));
|
||||||
logAndAddToPasteBinBuffer("Special Code: FRN001");
|
logAndAddToPasteBinBuffer("Special Code: FRN001");
|
||||||
|
|
||||||
MVVersionRequestEvent versionEvent = new MVVersionRequestEvent(pasteBinBuffer);
|
MVVersionRequestEvent versionEvent = new MVVersionRequestEvent(pasteBinBuffer);
|
||||||
|
@ -1,57 +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 java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
public class DefaultConfig {
|
|
||||||
|
|
||||||
public DefaultConfig(File folder, String name, MVConfigMigrator migrator) {
|
|
||||||
File actual = new File(folder, name);
|
|
||||||
if (actual.exists() && migrator.createdDefaults.contains(name)) {
|
|
||||||
actual.delete();
|
|
||||||
}
|
|
||||||
// If defaults have been created, and we're being called again, we should try to migrate
|
|
||||||
if (!actual.exists() && !migrator.migrate(name, folder)) {
|
|
||||||
|
|
||||||
InputStream defConfig = this.getClass().getResourceAsStream("/defaults/" + name);
|
|
||||||
if (defConfig != null) {
|
|
||||||
FileOutputStream newConfig = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
newConfig = new FileOutputStream(actual);
|
|
||||||
byte[] buf = new byte[8192];
|
|
||||||
int length = 0;
|
|
||||||
|
|
||||||
while ((length = defConfig.read(buf)) > 0) {
|
|
||||||
newConfig.write(buf, 0, length);
|
|
||||||
}
|
|
||||||
migrator.createdDefaults.add(name);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (defConfig != null)
|
|
||||||
defConfig.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (newConfig != null)
|
|
||||||
newConfig.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
package com.onarandombox.MultiverseCore.listeners;
|
package com.onarandombox.MultiverseCore.listeners;
|
||||||
|
|
||||||
|
import com.onarandombox.MultiverseCore.MVWorld;
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||||
@ -82,7 +83,7 @@ public class MVEntityListener extends EntityListener {
|
|||||||
MultiverseWorld world = this.worldManager.getMVWorld(w.getName());
|
MultiverseWorld world = this.worldManager.getMVWorld(w.getName());
|
||||||
|
|
||||||
if (attacker instanceof Player) {
|
if (attacker instanceof Player) {
|
||||||
if (!world.isPVPEnabled() && this.plugin.getMVConfig().getBoolean("fakepvp", false)) {
|
if (!world.isPVPEnabled() && world.getFakePVP()) {
|
||||||
((Player) attacker).sendMessage(ChatColor.RED + "PVP is disabled in this World.");
|
((Player) attacker).sendMessage(ChatColor.RED + "PVP is disabled in this World.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -96,7 +97,8 @@ public class MVEntityListener extends EntityListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RegainReason reason = event.getRegainReason();
|
RegainReason reason = event.getRegainReason();
|
||||||
if (reason == RegainReason.REGEN && this.plugin.getMVConfig().getBoolean("disableautoheal", false)) {
|
MultiverseWorld world = this.worldManager.getMVWorld(event.getEntity().getLocation().getWorld());
|
||||||
|
if (world != null && reason == RegainReason.REGEN && !world.getAutoHeal()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,9 +37,9 @@ public class MVPlayerListener extends PlayerListener {
|
|||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Check whether the Server is set to prefix the chat with the World name. If not we do nothing, if so we need to check if the World has an Alias.
|
// Check whether the Server is set to prefix the chat with the World name.
|
||||||
if (this.plugin.getMVConfig().getBoolean("worldnameprefix", true)) {
|
// If not we do nothing, if so we need to check if the World has an Alias.
|
||||||
this.plugin.getMVConfig().save();
|
if (MultiverseCore.PrefixChat) {
|
||||||
String world = event.getPlayer().getWorld().getName();
|
String world = event.getPlayer().getWorld().getName();
|
||||||
String prefix = "";
|
String prefix = "";
|
||||||
// If we're not a MV world, don't do anything
|
// If we're not a MV world, don't do anything
|
||||||
@ -62,7 +62,7 @@ public class MVPlayerListener extends PlayerListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.isBedSpawn() && this.plugin.getMVConfig().getBoolean("bedrespawn", true)) {
|
if (MultiverseCore.BedRespawn) {
|
||||||
this.plugin.log(Level.FINE, "Spawning " + event.getPlayer().getName() + " at their bed");
|
this.plugin.log(Level.FINE, "Spawning " + event.getPlayer().getName() + " at their bed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
package com.onarandombox.MultiverseCore.utils;
|
package com.onarandombox.MultiverseCore.utils;
|
||||||
|
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
|
import org.bukkit.configuration.Configuration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.config.Configuration;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
@ -14,16 +14,19 @@ import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.util.config.Configuration;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,7 +38,7 @@ public class WorldManager implements MVWorldManager {
|
|||||||
private MultiverseCore plugin;
|
private MultiverseCore plugin;
|
||||||
private PurgeWorlds worldPurger;
|
private PurgeWorlds worldPurger;
|
||||||
private HashMap<String, MultiverseWorld> worlds;
|
private HashMap<String, MultiverseWorld> worlds;
|
||||||
private Configuration configWorlds = null;
|
private FileConfiguration configWorlds = null;
|
||||||
|
|
||||||
public WorldManager(MultiverseCore core) {
|
public WorldManager(MultiverseCore core) {
|
||||||
|
|
||||||
@ -126,11 +129,16 @@ public class WorldManager implements MVWorldManager {
|
|||||||
* @return True if success, false if failure.
|
* @return True if success, false if failure.
|
||||||
*/
|
*/
|
||||||
public boolean removeWorldFromConfig(String name) {
|
public boolean removeWorldFromConfig(String name) {
|
||||||
if (this.configWorlds.getProperty("worlds." + name) != null) {
|
if (this.configWorlds.get("worlds." + name) != null) {
|
||||||
unloadWorld(name);
|
unloadWorld(name);
|
||||||
this.plugin.log(Level.INFO, "World '" + name + "' was removed from config.yml");
|
this.plugin.log(Level.INFO, "World '" + name + "' was removed from config.yml");
|
||||||
this.configWorlds.removeProperty("worlds." + name);
|
this.configWorlds.set("worlds." + name, null);
|
||||||
this.configWorlds.save();
|
try {
|
||||||
|
this.configWorlds.save(new File(this.plugin.getDataFolder(), "config.yml"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
this.plugin.log(Level.SEVERE, "Could not save worlds.yml. Please check your settings.");
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
this.plugin.log(Level.INFO, "World '" + name + "' was already removed from config.yml");
|
this.plugin.log(Level.INFO, "World '" + name + "' was already removed from config.yml");
|
||||||
@ -161,7 +169,7 @@ public class WorldManager implements MVWorldManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Grab all the Worlds from the Config.
|
// Grab all the Worlds from the Config.
|
||||||
List<String> worldKeys = this.configWorlds.getKeys("worlds");
|
Set<String> worldKeys = this.configWorlds.getConfigurationSection("worlds").getKeys(false);
|
||||||
|
|
||||||
// Check that the list is not null and that the config contains the world
|
// Check that the list is not null and that the config contains the world
|
||||||
if ((worldKeys != null) && (worldKeys.contains(name))) {
|
if ((worldKeys != null) && (worldKeys.contains(name))) {
|
||||||
@ -349,7 +357,7 @@ public class WorldManager implements MVWorldManager {
|
|||||||
// Basic Counter to count how many Worlds we are loading.
|
// Basic Counter to count how many Worlds we are loading.
|
||||||
int count = 0;
|
int count = 0;
|
||||||
// Grab all the Worlds from the Config.
|
// Grab all the Worlds from the Config.
|
||||||
List<String> worldKeys = this.configWorlds.getKeys("worlds");
|
Set<String> worldKeys = this.configWorlds.getConfigurationSection("worlds").getKeys(false);
|
||||||
|
|
||||||
// Force the worlds to be loaded, ie don't just load new worlds.
|
// Force the worlds to be loaded, ie don't just load new worlds.
|
||||||
if (forceLoad) {
|
if (forceLoad) {
|
||||||
@ -413,14 +421,8 @@ public class WorldManager implements MVWorldManager {
|
|||||||
*
|
*
|
||||||
* @return A loaded configuration.
|
* @return A loaded configuration.
|
||||||
*/
|
*/
|
||||||
public Configuration loadWorldConfig(File file) {
|
public FileConfiguration loadWorldConfig(File file) {
|
||||||
this.configWorlds = new Configuration(file);
|
this.configWorlds = YamlConfiguration.loadConfiguration(file);
|
||||||
return this.configWorlds;
|
return this.configWorlds;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Reload the Config File */
|
|
||||||
public void propagateConfigFile() {
|
|
||||||
this.configWorlds.load();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
worlds:
|
|
||||||
|
|
||||||
#############################################
|
|
||||||
### - Examples & Explanation of Settings- ###
|
|
||||||
#############################################
|
|
||||||
##worlds:
|
|
||||||
## default: ## This world is called 'default'
|
|
||||||
## environment: NORMAL ## Created with a NORMAL environment.
|
|
||||||
## animals:
|
|
||||||
## spawn: true ## We want animals to Spawn.
|
|
||||||
## exceptions: ## We want all animals to spawn so we won't make any exceptions.
|
|
||||||
## monsters:
|
|
||||||
## spawn: true ## We want monsters to Spawn.
|
|
||||||
## exceptions: 'CREEPER' ## But we don't want Creepers to spawn as they destroy peoples homes and valuables.
|
|
||||||
## pvp: true ## We wan't PVP to be enabled so players can fight each other.
|
|
||||||
## worldBlacklist: '' ## We are not blacklisting any worlds so this allows Players to teleport to this world from all other worlds.
|
|
||||||
## playerBlacklist: '' ## We are not blacklisting any players or groups so anyone can enter this world.
|
|
||||||
## playerWhitelist: '' ## Because we have not blacklisted anyone we do not have to Whitelist someone.
|
|
||||||
##
|
|
||||||
## creative: ## This world is called 'creative'
|
|
||||||
## environment: NORMAL ## Created with a NORMAL environment.
|
|
||||||
## animals:
|
|
||||||
## spawn: true ## We want animals to spawn.
|
|
||||||
## exceptions: ## We want all animals to spawn so we won't make any exceptions.
|
|
||||||
## monsters:
|
|
||||||
## spawn: false ## We don't want monsters to Spawn because this is a Creative World.
|
|
||||||
## enforced: true ## We want to enforce this rule, this means any Monster that was alive during world load/creation will be removed. No monsters can inhabit this world.
|
|
||||||
## exceptions: ## We don't want to make any exceptions to this.
|
|
||||||
## pvp: false ## We want to disable PVP because this world is for creativeness only.
|
|
||||||
## worldBlacklist: '' ## We are not blacklisting any worlds so this allows Players to teleport to this world from all other worlds.
|
|
||||||
## playerBlacklist: 'g:Griefers' ## We don't want to allow the group 'Griefers' into the World.
|
|
||||||
## playerWhitelist: 'g:Artists' ## We want to allow the group 'Artists' to enter this World.
|
|
||||||
##
|
|
||||||
## nether: ## This world is called 'nether'
|
|
||||||
## environment: NETHER ## Created with a NETHER environment.
|
|
||||||
## animals:
|
|
||||||
## spawn: true ## We want animals to spawn.
|
|
||||||
## monsters:
|
|
||||||
## spawn: true ## We want monsters to spawn.
|
|
||||||
## pvp: true ## We want to enable PVP on this World.
|
|
||||||
## worldBlacklist: '' ## We are not blacklisting any worlds so this allows Players to teleport to this world from all other worlds.
|
|
||||||
## playerBlacklist: '' ## We are not blacklisting any players or groups so anyone can enter this world.
|
|
||||||
## playerWhitelist: '' ## Because we have not blacklisted anyone we do not have to Whitelist someone.
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user