mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 10:36:06 +01:00
Add migrater for new configs, remove default, it's autogenned now
This commit is contained in:
parent
5d1532e811
commit
90b04aa798
2
pom.xml
2
pom.xml
@ -180,7 +180,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.1-R2</version>
|
||||
<version>1.1-R3</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
@ -252,14 +252,10 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
|
||||
// Now set the firstspawnworld (after the worlds are loaded):
|
||||
// Default as the server.props world.
|
||||
this.worldManager.setFirstSpawnWorld(this.multiverseConfig.getString("firstspawnworld", getDefaultWorldName()));
|
||||
// We have to set this one here, if it's not present, we don't know the name of the default world.
|
||||
// and this one won't be in the defaults yml file.
|
||||
try {
|
||||
this.multiverseConfig.set("firstspawnworld", this.worldManager.getFirstSpawnWorld().getName());
|
||||
} catch (NullPointerException e) {
|
||||
// A test that had no worlds loaded was being run. This should never happen in production
|
||||
if (this.config.getFirstSpawnWorld() == null) {
|
||||
this.config.setFirstSpawnWorld(getDefaultWorldName());
|
||||
}
|
||||
this.worldManager.setFirstSpawnWorld(this.config.getFirstSpawnWorld());
|
||||
this.saveMVConfig();
|
||||
// Check to see if spout was already loaded (most likely):
|
||||
if (this.getServer().getPluginManager().getPlugin("Spout") != null) {
|
||||
@ -333,11 +329,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
public void loadConfigs() {
|
||||
// Now grab the Configuration Files.
|
||||
this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
|
||||
Configuration coreDefaults = YamlConfiguration.loadConfiguration(this.getClass().getResourceAsStream("/defaults/config.yml"));
|
||||
this.multiverseConfig.setDefaults(coreDefaults);
|
||||
this.multiverseConfig.options().copyDefaults(true);
|
||||
this.saveMVConfig();
|
||||
this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
|
||||
this.worldManager.loadWorldConfig(new File(getDataFolder(), "worlds.yml"));
|
||||
|
||||
MultiverseCoreConfiguration wantedConfig = null;
|
||||
@ -358,9 +349,62 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
this.multiverseConfig.set("bedrespawn", null);
|
||||
this.multiverseConfig.set("opfallback", null);
|
||||
|
||||
// Old Config Format
|
||||
this.migrate22Values();
|
||||
this.saveMVConfigs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Thes are the MV config 2.0-2.2 values,
|
||||
* they should be migrated to the new format.
|
||||
*/
|
||||
private void migrate22Values() {
|
||||
if (this.multiverseConfig.isSet("worldnameprefix")) {
|
||||
this.log(Level.INFO, "Migrating 'worldnameprefix'...");
|
||||
this.config.setPrefixChat(this.multiverseConfig.getBoolean("worldnameprefix"));
|
||||
this.multiverseConfig.set("worldnameprefix", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("firstspawnworld")) {
|
||||
this.log(Level.INFO, "Migrating 'firstspawnworld'...");
|
||||
this.config.setFirstSpawnWorld(this.multiverseConfig.getString("firstspawnworld"));
|
||||
this.multiverseConfig.set("firstspawnworld", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("enforceaccess")) {
|
||||
this.log(Level.INFO, "Migrating 'enforceaccess'...");
|
||||
this.config.setEnforceAccess(this.multiverseConfig.getBoolean("enforceaccess"));
|
||||
this.multiverseConfig.set("enforceaccess", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("displaypermerrors")) {
|
||||
this.log(Level.INFO, "Migrating 'displaypermerrors'...");
|
||||
this.config.setDisplayPermErrors(this.multiverseConfig.getBoolean("displaypermerrors"));
|
||||
this.multiverseConfig.set("displaypermerrors", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("teleportintercept")) {
|
||||
this.log(Level.INFO, "Migrating 'teleportintercept'...");
|
||||
this.config.setTeleportIntercept(this.multiverseConfig.getBoolean("teleportintercept"));
|
||||
this.multiverseConfig.set("teleportintercept", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("firstspawnoverride")) {
|
||||
this.log(Level.INFO, "Migrating 'firstspawnoverride'...");
|
||||
this.config.setFirstSpawnOverride(this.multiverseConfig.getBoolean("firstspawnoverride"));
|
||||
this.multiverseConfig.set("firstspawnoverride", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("messagecooldown")) {
|
||||
this.log(Level.INFO, "Migrating 'messagecooldown'...");
|
||||
this.config.setMessageCooldown(this.multiverseConfig.getInt("messagecooldown"));
|
||||
this.multiverseConfig.set("messagecooldown", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("debug")) {
|
||||
this.log(Level.INFO, "Migrating 'debug'...");
|
||||
this.config.setGlobalDebug(this.multiverseConfig.getInt("debug"));
|
||||
this.multiverseConfig.set("debug", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("version")) {
|
||||
this.log(Level.INFO, "Migrating 'version'...");
|
||||
this.multiverseConfig.set("version", null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely return a world name.
|
||||
* (The tests call this with no worlds loaded)
|
||||
|
@ -18,11 +18,15 @@ public class MultiverseCoreConfiguration extends SerializationConfig {
|
||||
@Property
|
||||
private boolean firstSpawnOverride;
|
||||
@Property
|
||||
private String firstSpawnWorld;
|
||||
@Property
|
||||
private boolean displayPermErrors;
|
||||
@Property
|
||||
private int globalDebug;
|
||||
@Property
|
||||
private int messageCooldown;
|
||||
@Property
|
||||
private double version;
|
||||
|
||||
public MultiverseCoreConfiguration() {
|
||||
super();
|
||||
@ -45,6 +49,7 @@ public class MultiverseCoreConfiguration extends SerializationConfig {
|
||||
displayPermErrors = true;
|
||||
globalDebug = 0;
|
||||
messageCooldown = 5000;
|
||||
this.version = 2.8;
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
}
|
||||
|
||||
@ -55,7 +60,7 @@ public class MultiverseCoreConfiguration extends SerializationConfig {
|
||||
* @return enforceAccess.
|
||||
*/
|
||||
public boolean getEnforceAccess() {
|
||||
return enforceAccess;
|
||||
return this.enforceAccess;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,7 +76,7 @@ public class MultiverseCoreConfiguration extends SerializationConfig {
|
||||
* @return prefixChat.
|
||||
*/
|
||||
public boolean getPrefixChat() {
|
||||
return prefixChat;
|
||||
return this.prefixChat;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -87,7 +92,7 @@ public class MultiverseCoreConfiguration extends SerializationConfig {
|
||||
* @return teleportIntercept.
|
||||
*/
|
||||
public boolean getTeleportIntercept() {
|
||||
return teleportIntercept;
|
||||
return this.teleportIntercept;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,7 +108,7 @@ public class MultiverseCoreConfiguration extends SerializationConfig {
|
||||
* @return firstSpawnOverride.
|
||||
*/
|
||||
public boolean getFirstSpawnOverride() {
|
||||
return firstSpawnOverride;
|
||||
return this.firstSpawnOverride;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,7 +124,7 @@ public class MultiverseCoreConfiguration extends SerializationConfig {
|
||||
* @return displayPermErrors.
|
||||
*/
|
||||
public boolean getDisplayPermErrors() {
|
||||
return displayPermErrors;
|
||||
return this.displayPermErrors;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,7 +140,7 @@ public class MultiverseCoreConfiguration extends SerializationConfig {
|
||||
* @return globalDebug.
|
||||
*/
|
||||
public int getGlobalDebug() {
|
||||
return globalDebug;
|
||||
return this.globalDebug;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -151,7 +156,7 @@ public class MultiverseCoreConfiguration extends SerializationConfig {
|
||||
* @return messageCooldown.
|
||||
*/
|
||||
public int getMessageCooldown() {
|
||||
return messageCooldown;
|
||||
return this.messageCooldown;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -161,4 +166,28 @@ public class MultiverseCoreConfiguration extends SerializationConfig {
|
||||
public void setMessageCooldown(int messageCooldown) {
|
||||
this.messageCooldown = messageCooldown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets firstSpawnWorld.
|
||||
* @return firstSpawnWorld.
|
||||
*/
|
||||
public String getFirstSpawnWorld() {
|
||||
return this.firstSpawnWorld;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets firstSpawnWorld.
|
||||
* @param firstSpawnWorld The new value.
|
||||
*/
|
||||
public void setFirstSpawnWorld(String firstSpawnWorld) {
|
||||
this.firstSpawnWorld = firstSpawnWorld;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the version of this config.
|
||||
* @return version.
|
||||
*/
|
||||
public double getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +99,7 @@ public class MVPermissions implements PermissionsInterface {
|
||||
public boolean canEnterWorld(Player p, MultiverseWorld w) {
|
||||
// If we're not enforcing access, anyone can enter.
|
||||
if (!MultiverseCore.getStaticConfig().getEnforceAccess()) {
|
||||
this.plugin.log(Level.FINEST, "EnforceAccess is OFF. Player was allowed in " + w.getAlias());
|
||||
return true;
|
||||
}
|
||||
return this.hasPermission(p, "multiverse.access." + w.getName(), false);
|
||||
@ -169,9 +170,9 @@ public class MVPermissions implements PermissionsInterface {
|
||||
// plugin reloads, when MV asks the API if a player has a perm, it reports that they do NOT.
|
||||
// For the moment, we're going to check all of this node's parents to see if the user has those. It stops
|
||||
// when if finds a true or there are no more parents. --FF
|
||||
if (!hasPermission) {
|
||||
hasPermission = this.hasAnyParentPermission(sender, node);
|
||||
}
|
||||
// if (!hasPermission) {
|
||||
// hasPermission = this.hasAnyParentPermission(sender, node);
|
||||
// }
|
||||
|
||||
return hasPermission;
|
||||
}
|
||||
@ -179,10 +180,12 @@ public class MVPermissions implements PermissionsInterface {
|
||||
// TODO: Better player checks, most likely not needed, but safer.
|
||||
private boolean checkActualPermission(CommandSender sender, String node) {
|
||||
Player player = (Player) sender;
|
||||
this.plugin.log(Level.FINEST, "Checking to see if player [" + player.getName() + "] has permission [" + node + "]");
|
||||
|
||||
boolean hasPermission = sender.hasPermission(node);
|
||||
if (hasPermission) {
|
||||
this.plugin.log(Level.FINER, "Player [" + player.getName() + "] HAS PERMISSION [" + node + "]!");
|
||||
this.plugin.log(Level.FINEST, "Checking to see if player [" + player.getName() + "] has permission [" + node + "]... YES");
|
||||
} else {
|
||||
this.plugin.log(Level.FINEST, "Checking to see if player [" + player.getName() + "] has permission [" + node + "]... NO");
|
||||
}
|
||||
return hasPermission;
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
# This is the MV2 Config. If you mess it up, copy the values out
|
||||
# delete it, and it will be regenerated. Then use the ingame interface
|
||||
# to add your values back via the "/mv conf" command.
|
||||
# When in-game, simply type: "/mv conf ?" for help.
|
||||
# A config with explanations can be found here:
|
||||
# https://github.com/Multiverse/Multiverse-Core/wiki/config.yml
|
||||
|
||||
worldnameprefix: true
|
||||
enforceaccess: true
|
||||
displaypermerrors: true
|
||||
teleportintercept: true
|
||||
firstspawnoverride: true
|
||||
messagecooldown: 5000
|
||||
version: 2.7
|
Loading…
Reference in New Issue
Block a user