Fixed config...
This commit is contained in:
parent
5d1532e811
commit
a1075224d3
2
pom.xml
2
pom.xml
|
@ -196,7 +196,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.main__.util</groupId>
|
<groupId>me.main__.util</groupId>
|
||||||
<artifactId>SerializationConfig</artifactId>
|
<artifactId>SerializationConfig</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.1</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
|
@ -14,6 +14,7 @@ import com.onarandombox.MultiverseCore.api.Core;
|
||||||
import com.onarandombox.MultiverseCore.api.LocationManipulation;
|
import com.onarandombox.MultiverseCore.api.LocationManipulation;
|
||||||
import com.onarandombox.MultiverseCore.api.MVPlugin;
|
import com.onarandombox.MultiverseCore.api.MVPlugin;
|
||||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||||
|
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
|
||||||
import com.onarandombox.MultiverseCore.api.MultiverseMessaging;
|
import com.onarandombox.MultiverseCore.api.MultiverseMessaging;
|
||||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||||
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
||||||
|
@ -67,6 +68,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||||
private static Map<String, String> teleportQueue = new HashMap<String, String>();
|
private static Map<String, String> teleportQueue = new HashMap<String, String>();
|
||||||
|
|
||||||
private AnchorManager anchorManager = new AnchorManager(this);
|
private AnchorManager anchorManager = new AnchorManager(this);
|
||||||
|
// TODO please let's make this non-static
|
||||||
private static MultiverseCoreConfiguration config;
|
private static MultiverseCoreConfiguration config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -186,8 +188,10 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
|
* @deprecated This is deprecated.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public FileConfiguration getMVConfiguration() {
|
public FileConfiguration getMVConfiguration() {
|
||||||
return this.multiverseConfig;
|
return this.multiverseConfig;
|
||||||
}
|
}
|
||||||
|
@ -252,11 +256,11 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||||
|
|
||||||
// Now set the firstspawnworld (after the worlds are loaded):
|
// Now set the firstspawnworld (after the worlds are loaded):
|
||||||
// Default as the server.props world.
|
// Default as the server.props world.
|
||||||
this.worldManager.setFirstSpawnWorld(this.multiverseConfig.getString("firstspawnworld", getDefaultWorldName()));
|
this.worldManager.setFirstSpawnWorld(config.getFirstSpawnWorld());
|
||||||
// We have to set this one here, if it's not present, we don't know the name of the default world.
|
// 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.
|
// and this one won't be in the defaults yml file.
|
||||||
try {
|
try {
|
||||||
this.multiverseConfig.set("firstspawnworld", this.worldManager.getFirstSpawnWorld().getName());
|
config.setFirstSpawnWorld(this.worldManager.getFirstSpawnWorld().getName());
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// A test that had no worlds loaded was being run. This should never happen in production
|
// A test that had no worlds loaded was being run. This should never happen in production
|
||||||
}
|
}
|
||||||
|
@ -335,9 +339,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||||
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"));
|
Configuration coreDefaults = YamlConfiguration.loadConfiguration(this.getClass().getResourceAsStream("/defaults/config.yml"));
|
||||||
this.multiverseConfig.setDefaults(coreDefaults);
|
this.multiverseConfig.setDefaults(coreDefaults);
|
||||||
this.multiverseConfig.options().copyDefaults(true);
|
this.multiverseConfig.options().copyDefaults(false);
|
||||||
this.saveMVConfig();
|
this.multiverseConfig.options().copyHeader(true);
|
||||||
this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
|
|
||||||
this.worldManager.loadWorldConfig(new File(getDataFolder(), "worlds.yml"));
|
this.worldManager.loadWorldConfig(new File(getDataFolder(), "worlds.yml"));
|
||||||
|
|
||||||
MultiverseCoreConfiguration wantedConfig = null;
|
MultiverseCoreConfiguration wantedConfig = null;
|
||||||
|
@ -348,8 +351,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||||
} finally {
|
} finally {
|
||||||
config = ((wantedConfig == null) ? new MultiverseCoreConfiguration() : wantedConfig);
|
config = ((wantedConfig == null) ? new MultiverseCoreConfiguration() : wantedConfig);
|
||||||
}
|
}
|
||||||
// ... and save it
|
|
||||||
multiverseConfig.set("multiverse-configuration", config);
|
|
||||||
|
|
||||||
this.messaging.setCooldown(config.getMessageCooldown());
|
this.messaging.setCooldown(config.getMessageCooldown());
|
||||||
|
|
||||||
|
@ -361,19 +362,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||||
this.saveMVConfigs();
|
this.saveMVConfigs();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Safely return a world name.
|
|
||||||
* (The tests call this with no worlds loaded)
|
|
||||||
*
|
|
||||||
* @return The default world name.
|
|
||||||
*/
|
|
||||||
private String getDefaultWorldName() {
|
|
||||||
if (this.getServer().getWorlds().size() > 0) {
|
|
||||||
return this.getServer().getWorlds().get(0).getName();
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -441,7 +429,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.multiverseConfig, this));
|
this.playerSessions.put(player.getName(), new MVPlayerSession(player, config));
|
||||||
return this.playerSessions.get(player.getName());
|
return this.playerSessions.get(player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -726,6 +714,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||||
*/
|
*/
|
||||||
public boolean saveMVConfig() {
|
public boolean saveMVConfig() {
|
||||||
try {
|
try {
|
||||||
|
this.multiverseConfig.set("multiverse-configuration", config);
|
||||||
this.multiverseConfig.save(new File(getDataFolder(), "config.yml"));
|
this.multiverseConfig.save(new File(getDataFolder(), "config.yml"));
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -853,10 +842,10 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets our {@link MultiverseCoreConfiguration}.
|
* {@inheritDoc}
|
||||||
* @return The {@link MultiverseCoreConfiguration} we're using.
|
|
||||||
*/
|
*/
|
||||||
public static MultiverseCoreConfiguration getStaticConfig() {
|
@Override
|
||||||
|
public MultiverseCoreConfig getMVConfig() {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,27 +2,35 @@ package com.onarandombox.MultiverseCore;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
|
||||||
|
|
||||||
import me.main__.util.SerializationConfig.Property;
|
import me.main__.util.SerializationConfig.Property;
|
||||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Our configuration.
|
* Our configuration.
|
||||||
*/
|
*/
|
||||||
public class MultiverseCoreConfiguration extends SerializationConfig {
|
public class MultiverseCoreConfiguration extends SerializationConfig implements MultiverseCoreConfig {
|
||||||
@Property
|
@Property
|
||||||
private boolean enforceAccess;
|
private boolean enforceaccess;
|
||||||
@Property
|
@Property
|
||||||
private boolean prefixChat;
|
private boolean prefixChat;
|
||||||
@Property
|
@Property
|
||||||
private boolean teleportIntercept;
|
private boolean teleportintercept;
|
||||||
@Property
|
@Property
|
||||||
private boolean firstSpawnOverride;
|
private boolean firstspawnoverride;
|
||||||
@Property
|
@Property
|
||||||
private boolean displayPermErrors;
|
private boolean displayPermErrors;
|
||||||
@Property
|
@Property
|
||||||
private int globalDebug;
|
private int globaldebug;
|
||||||
@Property
|
@Property
|
||||||
private int messageCooldown;
|
private int messagecooldown;
|
||||||
|
@Property
|
||||||
|
private int version;
|
||||||
|
@Property
|
||||||
|
private String firstspawnworld;
|
||||||
|
@Property
|
||||||
|
private int portalcooldown;
|
||||||
|
|
||||||
public MultiverseCoreConfiguration() {
|
public MultiverseCoreConfiguration() {
|
||||||
super();
|
super();
|
||||||
|
@ -38,127 +46,176 @@ public class MultiverseCoreConfiguration extends SerializationConfig {
|
||||||
@Override
|
@Override
|
||||||
public void setDefaults() {
|
public void setDefaults() {
|
||||||
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||||
enforceAccess = false;
|
enforceaccess = false;
|
||||||
prefixChat = true;
|
prefixChat = true;
|
||||||
teleportIntercept = true;
|
teleportintercept = true;
|
||||||
firstSpawnOverride = true;
|
firstspawnoverride = true;
|
||||||
displayPermErrors = true;
|
displayPermErrors = true;
|
||||||
globalDebug = 0;
|
globaldebug = 0;
|
||||||
messageCooldown = 5000;
|
messagecooldown = 5000;
|
||||||
|
portalcooldown = 5000;
|
||||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||||
}
|
}
|
||||||
|
|
||||||
// And here we go:
|
// And here we go:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets enforceAccess.
|
* {@inheritDoc}
|
||||||
* @return enforceAccess.
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean getEnforceAccess() {
|
public boolean getEnforceAccess() {
|
||||||
return enforceAccess;
|
return enforceaccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets enforceAccess.
|
* {@inheritDoc}
|
||||||
* @param enforceAccess The new value.
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setEnforceAccess(boolean enforceAccess) {
|
public void setEnforceAccess(boolean enforceAccess) {
|
||||||
this.enforceAccess = enforceAccess;
|
this.enforceaccess = enforceAccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets prefixChat.
|
* {@inheritDoc}
|
||||||
* @return prefixChat.
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean getPrefixChat() {
|
public boolean getPrefixChat() {
|
||||||
return prefixChat;
|
return prefixChat;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets prefixChat.
|
* {@inheritDoc}
|
||||||
* @param prefixChat The new value.
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setPrefixChat(boolean prefixChat) {
|
public void setPrefixChat(boolean prefixChat) {
|
||||||
this.prefixChat = prefixChat;
|
this.prefixChat = prefixChat;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets teleportIntercept.
|
* {@inheritDoc}
|
||||||
* @return teleportIntercept.
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean getTeleportIntercept() {
|
public boolean getTeleportIntercept() {
|
||||||
return teleportIntercept;
|
return teleportintercept;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets teleportIntercept.
|
* {@inheritDoc}
|
||||||
* @param teleportIntercept The new value.
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setTeleportIntercept(boolean teleportIntercept) {
|
public void setTeleportIntercept(boolean teleportIntercept) {
|
||||||
this.teleportIntercept = teleportIntercept;
|
this.teleportintercept = teleportIntercept;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets firstSpawnOverride.
|
* {@inheritDoc}
|
||||||
* @return firstSpawnOverride.
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean getFirstSpawnOverride() {
|
public boolean getFirstSpawnOverride() {
|
||||||
return firstSpawnOverride;
|
return firstspawnoverride;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets firstSpawnOverride.
|
* {@inheritDoc}
|
||||||
* @param firstSpawnOverride The new value.
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setFirstSpawnOverride(boolean firstSpawnOverride) {
|
public void setFirstSpawnOverride(boolean firstSpawnOverride) {
|
||||||
this.firstSpawnOverride = firstSpawnOverride;
|
this.firstspawnoverride = firstSpawnOverride;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets displayPermErrors.
|
* {@inheritDoc}
|
||||||
* @return displayPermErrors.
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean getDisplayPermErrors() {
|
public boolean getDisplayPermErrors() {
|
||||||
return displayPermErrors;
|
return displayPermErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets displayPermErrors.
|
* {@inheritDoc}
|
||||||
* @param displayPermErrors The new value.
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setDisplayPermErrors(boolean displayPermErrors) {
|
public void setDisplayPermErrors(boolean displayPermErrors) {
|
||||||
this.displayPermErrors = displayPermErrors;
|
this.displayPermErrors = displayPermErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets globalDebug.
|
* {@inheritDoc}
|
||||||
* @return globalDebug.
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getGlobalDebug() {
|
public int getGlobalDebug() {
|
||||||
return globalDebug;
|
return globaldebug;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets globalDebug.
|
* {@inheritDoc}
|
||||||
* @param globalDebug The new value.
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setGlobalDebug(int globalDebug) {
|
public void setGlobalDebug(int globalDebug) {
|
||||||
this.globalDebug = globalDebug;
|
this.globaldebug = globalDebug;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets messageCooldown.
|
* {@inheritDoc}
|
||||||
* @return messageCooldown.
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getMessageCooldown() {
|
public int getMessageCooldown() {
|
||||||
return messageCooldown;
|
return messagecooldown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets messageCooldown.
|
* {@inheritDoc}
|
||||||
* @param messageCooldown The new value.
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setMessageCooldown(int messageCooldown) {
|
public void setMessageCooldown(int messageCooldown) {
|
||||||
this.messageCooldown = messageCooldown;
|
this.messagecooldown = messageCooldown;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setVersion(int version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getFirstSpawnWorld() {
|
||||||
|
return firstspawnworld;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setFirstSpawnWorld(String firstSpawnWorld) {
|
||||||
|
this.firstspawnworld = firstSpawnWorld;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getPortalCooldown() {
|
||||||
|
return portalcooldown;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setPortalCooldown(int portalCooldown) {
|
||||||
|
this.portalcooldown = portalCooldown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,9 @@ public interface Core {
|
||||||
* Gets the Multiverse config file.
|
* Gets the Multiverse config file.
|
||||||
*
|
*
|
||||||
* @return The Multiverse config file.
|
* @return The Multiverse config file.
|
||||||
|
* @deprecated Don't modify the config-file manually!
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
FileConfiguration getMVConfiguration();
|
FileConfiguration getMVConfiguration();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -215,4 +217,9 @@ public interface Core {
|
||||||
*/
|
*/
|
||||||
void setSafeTTeleporter(SafeTTeleporter safeTTeleporter);
|
void setSafeTTeleporter(SafeTTeleporter safeTTeleporter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link MultiverseCoreConfig}.
|
||||||
|
* @return The configuration.
|
||||||
|
*/
|
||||||
|
MultiverseCoreConfig getMVConfig();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,136 @@
|
||||||
|
package com.onarandombox.MultiverseCore.api;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The configuration of MultiverseCore.
|
||||||
|
*/
|
||||||
|
public interface MultiverseCoreConfig extends ConfigurationSerializable {
|
||||||
|
/**
|
||||||
|
* Sets a property using a {@link String}.
|
||||||
|
* @param property The name of the property.
|
||||||
|
* @param value The value.
|
||||||
|
* @return True on success, false if the operation failed.
|
||||||
|
*/
|
||||||
|
boolean setProperty(String property, String value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets portalCooldown.
|
||||||
|
* @param portalCooldown The new value.
|
||||||
|
*/
|
||||||
|
void setPortalCooldown(int portalCooldown);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets portalCooldown.
|
||||||
|
* @return portalCooldown.
|
||||||
|
*/
|
||||||
|
int getPortalCooldown();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets firstSpawnWorld.
|
||||||
|
* @param firstSpawnWorld The new value.
|
||||||
|
*/
|
||||||
|
void setFirstSpawnWorld(String firstSpawnWorld);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets firstSpawnWorld.
|
||||||
|
* @return firstSpawnWorld.
|
||||||
|
*/
|
||||||
|
String getFirstSpawnWorld();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets version.
|
||||||
|
* @param version The new value.
|
||||||
|
*/
|
||||||
|
void setVersion(int version);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets version.
|
||||||
|
* @return version.
|
||||||
|
*/
|
||||||
|
int getVersion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets messageCooldown.
|
||||||
|
* @param messageCooldown The new value.
|
||||||
|
*/
|
||||||
|
void setMessageCooldown(int messageCooldown);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets messageCooldown.
|
||||||
|
* @return messageCooldown.
|
||||||
|
*/
|
||||||
|
int getMessageCooldown();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets globalDebug.
|
||||||
|
* @param globalDebug The new value.
|
||||||
|
*/
|
||||||
|
void setGlobalDebug(int globalDebug);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets globalDebug.
|
||||||
|
* @return globalDebug.
|
||||||
|
*/
|
||||||
|
int getGlobalDebug();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets displayPermErrors.
|
||||||
|
* @param displayPermErrors The new value.
|
||||||
|
*/
|
||||||
|
void setDisplayPermErrors(boolean displayPermErrors);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets displayPermErrors.
|
||||||
|
* @return displayPermErrors.
|
||||||
|
*/
|
||||||
|
boolean getDisplayPermErrors();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets firstSpawnOverride.
|
||||||
|
* @param firstSpawnOverride The new value.
|
||||||
|
*/
|
||||||
|
void setFirstSpawnOverride(boolean firstSpawnOverride);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets firstSpawnOverride.
|
||||||
|
* @return firstSpawnOverride.
|
||||||
|
*/
|
||||||
|
boolean getFirstSpawnOverride();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets teleportIntercept.
|
||||||
|
* @param teleportIntercept The new value.
|
||||||
|
*/
|
||||||
|
void setTeleportIntercept(boolean teleportIntercept);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets teleportIntercept.
|
||||||
|
* @return teleportIntercept.
|
||||||
|
*/
|
||||||
|
boolean getTeleportIntercept();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets prefixChat.
|
||||||
|
* @param prefixChat The new value.
|
||||||
|
*/
|
||||||
|
void setPrefixChat(boolean prefixChat);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets prefixChat.
|
||||||
|
* @return prefixChat.
|
||||||
|
*/
|
||||||
|
boolean getPrefixChat();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets enforceAccess.
|
||||||
|
* @param enforceAccess The new value.
|
||||||
|
*/
|
||||||
|
void setEnforceAccess(boolean enforceAccess);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets enforceAccess.
|
||||||
|
* @return enforceAccess.
|
||||||
|
*/
|
||||||
|
boolean getEnforceAccess();
|
||||||
|
}
|
|
@ -8,12 +8,12 @@
|
||||||
package com.onarandombox.MultiverseCore.commands;
|
package com.onarandombox.MultiverseCore.commands;
|
||||||
|
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
import com.onarandombox.MultiverseCore.enums.ConfigProperty;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.permissions.PermissionDefault;
|
import org.bukkit.permissions.PermissionDefault;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows you to set Global MV Variables.
|
* Allows you to set Global MV Variables.
|
||||||
|
@ -28,7 +28,6 @@ public class ConfigCommand extends MultiverseCommand {
|
||||||
this.addKey("mvconfig");
|
this.addKey("mvconfig");
|
||||||
this.addKey("mv conf");
|
this.addKey("mv conf");
|
||||||
this.addKey("mvconf");
|
this.addKey("mvconf");
|
||||||
this.addCommandExample("All values: " + ConfigProperty.getAllValues());
|
|
||||||
this.addCommandExample("/mv config show");
|
this.addCommandExample("/mv config show");
|
||||||
this.addCommandExample("/mv config " + ChatColor.GREEN + "debug" + ChatColor.AQUA + " 3");
|
this.addCommandExample("/mv config " + ChatColor.GREEN + "debug" + ChatColor.AQUA + " 3");
|
||||||
this.addCommandExample("/mv config " + ChatColor.GREEN + "enforceaccess" + ChatColor.AQUA + " false");
|
this.addCommandExample("/mv config " + ChatColor.GREEN + "enforceaccess" + ChatColor.AQUA + " false");
|
||||||
|
@ -38,55 +37,31 @@ public class ConfigCommand extends MultiverseCommand {
|
||||||
@Override
|
@Override
|
||||||
public void runCommand(CommandSender sender, List<String> args) {
|
public void runCommand(CommandSender sender, List<String> args) {
|
||||||
if (args.size() <= 1) {
|
if (args.size() <= 1) {
|
||||||
String[] allProps = ConfigProperty.getAllValues().split(" ");
|
StringBuilder builder = new StringBuilder();
|
||||||
String currentvals = "";
|
Map<String, Object> serializedConfig = this.plugin.getMVConfig().serialize();
|
||||||
for (String prop : allProps) {
|
for (Map.Entry<String, Object> entry : serializedConfig.entrySet()) {
|
||||||
currentvals += ChatColor.GREEN;
|
builder.append(ChatColor.GREEN);
|
||||||
currentvals += prop;
|
builder.append(entry.getKey());
|
||||||
currentvals += ChatColor.WHITE;
|
builder.append(ChatColor.WHITE).append(" = ").append(ChatColor.GOLD);
|
||||||
currentvals += " = ";
|
builder.append(entry.getValue().toString());
|
||||||
currentvals += ChatColor.GOLD;
|
builder.append(ChatColor.WHITE).append(", ");
|
||||||
currentvals += this.plugin.getMVConfiguration().get(prop, "NOT SET");
|
|
||||||
currentvals += ChatColor.WHITE;
|
|
||||||
currentvals += ", ";
|
|
||||||
}
|
}
|
||||||
sender.sendMessage(currentvals.substring(0, currentvals.length() - 2));
|
String message = builder.toString();
|
||||||
|
message = message.substring(0, message.length() - 2);
|
||||||
|
sender.sendMessage(message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!this.plugin.getMVConfig().setProperty(args.get(0).toLowerCase(), args.get(1))) {
|
||||||
|
sender.sendMessage(String.format("%sSetting '%s' to '%s' failed!", ChatColor.RED, args.get(0).toLowerCase(), args.get(1)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// special rule
|
||||||
if (args.get(0).equalsIgnoreCase("firstspawnworld")) {
|
if (args.get(0).equalsIgnoreCase("firstspawnworld")) {
|
||||||
this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), args.get(1));
|
|
||||||
// Don't forget to set the world!
|
// Don't forget to set the world!
|
||||||
this.plugin.getMVWorldManager().setFirstSpawnWorld(args.get(1));
|
this.plugin.getMVWorldManager().setFirstSpawnWorld(args.get(1));
|
||||||
} else if (args.get(0).equalsIgnoreCase("messagecooldown") || args.get(0).equalsIgnoreCase("teleportcooldown")
|
|
||||||
|| args.get(0).equalsIgnoreCase("debug")) {
|
|
||||||
try {
|
|
||||||
this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), Integer.parseInt(args.get(1)));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE + " must be an integer!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ConfigProperty property = null;
|
|
||||||
try {
|
|
||||||
property = ConfigProperty.valueOf(args.get(0).toLowerCase());
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA
|
|
||||||
+ args.get(0) + ChatColor.WHITE + " you can't set " + ChatColor.AQUA + args.get(0));
|
|
||||||
sender.sendMessage(ChatColor.GREEN + "Valid values are:");
|
|
||||||
sender.sendMessage(ConfigProperty.getAllValues());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (property != null) {
|
|
||||||
try {
|
|
||||||
this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), Boolean.parseBoolean(args.get(1)));
|
|
||||||
} catch (Exception e) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE + " must be true or false!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.plugin.saveMVConfigs()) {
|
if (this.plugin.saveMVConfigs()) {
|
||||||
sender.sendMessage(ChatColor.GREEN + "SUCCESS!" + ChatColor.WHITE + " Values were updated successfully!");
|
sender.sendMessage(ChatColor.GREEN + "SUCCESS!" + ChatColor.WHITE + " Values were updated successfully!");
|
||||||
this.plugin.loadConfigs();
|
this.plugin.loadConfigs();
|
||||||
|
|
|
@ -36,14 +36,14 @@ public class DebugCommand extends MultiverseCommand {
|
||||||
public void runCommand(CommandSender sender, List<String> args) {
|
public void runCommand(CommandSender sender, List<String> args) {
|
||||||
if (args.size() == 1) {
|
if (args.size() == 1) {
|
||||||
if (args.get(0).equalsIgnoreCase("off")) {
|
if (args.get(0).equalsIgnoreCase("off")) {
|
||||||
MultiverseCore.getStaticConfig().setGlobalDebug(0);
|
plugin.getMVConfig().setGlobalDebug(0);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
int debugLevel = Integer.parseInt(args.get(0));
|
int debugLevel = Integer.parseInt(args.get(0));
|
||||||
if (debugLevel > 3 || debugLevel < 0) {
|
if (debugLevel > 3 || debugLevel < 0) {
|
||||||
throw new NumberFormatException();
|
throw new NumberFormatException();
|
||||||
}
|
}
|
||||||
MultiverseCore.getStaticConfig().setGlobalDebug(debugLevel);
|
plugin.getMVConfig().setGlobalDebug(debugLevel);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
sender.sendMessage(ChatColor.RED + "Error" + ChatColor.WHITE
|
sender.sendMessage(ChatColor.RED + "Error" + ChatColor.WHITE
|
||||||
+ " setting debug level. Please use a number 0-3 " + ChatColor.AQUA + "(3 being many many messages!)");
|
+ " setting debug level. Please use a number 0-3 " + ChatColor.AQUA + "(3 being many many messages!)");
|
||||||
|
@ -55,10 +55,10 @@ public class DebugCommand extends MultiverseCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayDebugMode(CommandSender sender) {
|
private void displayDebugMode(CommandSender sender) {
|
||||||
if (MultiverseCore.getStaticConfig().getGlobalDebug() == 0) {
|
if (plugin.getMVConfig().getGlobalDebug() == 0) {
|
||||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
|
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + MultiverseCore.getStaticConfig().getGlobalDebug());
|
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + plugin.getMVConfig().getGlobalDebug());
|
||||||
this.plugin.log(Level.FINE, "Multiverse Debug ENABLED");
|
this.plugin.log(Level.FINE, "Multiverse Debug ENABLED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ public class TeleportCommand extends MultiverseCommand {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MultiverseCore.getStaticConfig().getEnforceAccess() && teleporter != null && !this.plugin.getMVPerms().canEnterDestination(teleporter, d)) {
|
if (plugin.getMVConfig().getEnforceAccess() && teleporter != null && !this.plugin.getMVPerms().canEnterDestination(teleporter, d)) {
|
||||||
if (teleportee.equals(teleporter)) {
|
if (teleportee.equals(teleporter)) {
|
||||||
teleporter.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there...");
|
teleporter.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there...");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -53,16 +53,16 @@ public class VersionCommand extends MultiverseCommand {
|
||||||
buffer.append("[Multiverse-Core] Economy being used: ").append(this.plugin.getBank().getEconUsed()).append('\n');
|
buffer.append("[Multiverse-Core] Economy being used: ").append(this.plugin.getBank().getEconUsed()).append('\n');
|
||||||
buffer.append("[Multiverse-Core] Permissions Plugin: ").append(this.plugin.getMVPerms().getType()).append('\n');
|
buffer.append("[Multiverse-Core] Permissions Plugin: ").append(this.plugin.getMVPerms().getType()).append('\n');
|
||||||
buffer.append("[Multiverse-Core] Dumping Config Values: (version ")
|
buffer.append("[Multiverse-Core] Dumping Config Values: (version ")
|
||||||
.append(this.plugin.getMVConfiguration().getDouble("version", -1)).append(")").append('\n');
|
.append(this.plugin.getMVConfig().getVersion()).append(")").append('\n');
|
||||||
buffer.append("[Multiverse-Core] messagecooldown: ").append(this.plugin.getMessaging().getCooldown()).append('\n');
|
buffer.append("[Multiverse-Core] messagecooldown: ").append(plugin.getMessaging().getCooldown()).append('\n');
|
||||||
buffer.append("[Multiverse-Core] teleportcooldown: ").append("Not yet IMPLEMENTED").append('\n');
|
buffer.append("[Multiverse-Core] teleportcooldown: ").append("Not yet IMPLEMENTED").append('\n');
|
||||||
buffer.append("[Multiverse-Core] worldnameprefix: ").append(MultiverseCore.getStaticConfig().getPrefixChat()).append('\n');
|
buffer.append("[Multiverse-Core] worldnameprefix: ").append(plugin.getMVConfig().getPrefixChat()).append('\n');
|
||||||
buffer.append("[Multiverse-Core] enforceaccess: ").append(MultiverseCore.getStaticConfig().getEnforceAccess()).append('\n');
|
buffer.append("[Multiverse-Core] enforceaccess: ").append(plugin.getMVConfig().getEnforceAccess()).append('\n');
|
||||||
buffer.append("[Multiverse-Core] displaypermerrors: ").append(MultiverseCore.getStaticConfig().getDisplayPermErrors()).append('\n');
|
buffer.append("[Multiverse-Core] displaypermerrors: ").append(plugin.getMVConfig().getDisplayPermErrors()).append('\n');
|
||||||
buffer.append("[Multiverse-Core] teleportintercept: ").append(MultiverseCore.getStaticConfig().getTeleportIntercept()).append('\n');
|
buffer.append("[Multiverse-Core] teleportintercept: ").append(plugin.getMVConfig().getTeleportIntercept()).append('\n');
|
||||||
buffer.append("[Multiverse-Core] firstspawnoverride: ").append(MultiverseCore.getStaticConfig().getFirstSpawnOverride()).append('\n');
|
buffer.append("[Multiverse-Core] firstspawnoverride: ").append(plugin.getMVConfig().getFirstSpawnOverride()).append('\n');
|
||||||
buffer.append("[Multiverse-Core] firstspawnworld: ").append(this.plugin.getMVConfiguration().getString("firstspawnworld", "NOT SET")).append('\n');
|
buffer.append("[Multiverse-Core] firstspawnworld: ").append(plugin.getMVConfig().getFirstSpawnWorld()).append('\n');
|
||||||
buffer.append("[Multiverse-Core] debug: ").append(MultiverseCore.getStaticConfig().getGlobalDebug()).append('\n');
|
buffer.append("[Multiverse-Core] debug: ").append(plugin.getMVConfig().getGlobalDebug()).append('\n');
|
||||||
buffer.append("[Multiverse-Core] Special Code: FRN002").append('\n');
|
buffer.append("[Multiverse-Core] Special Code: FRN002").append('\n');
|
||||||
|
|
||||||
MVVersionEvent versionEvent = new MVVersionEvent(buffer.toString());
|
MVVersionEvent versionEvent = new MVVersionEvent(buffer.toString());
|
||||||
|
|
|
@ -1,64 +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.enums;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An enum containing all config-properties that can be set.
|
|
||||||
*/
|
|
||||||
public enum ConfigProperty {
|
|
||||||
/**
|
|
||||||
* How long to leave in between sending a message to the player. (NOT YET IMPLEMENTED)
|
|
||||||
*/
|
|
||||||
messagecooldown,
|
|
||||||
/**
|
|
||||||
* How fast are people allowed to use /MVTP (NOT YET IMPLEMENTED).
|
|
||||||
*/
|
|
||||||
teleportcooldown,
|
|
||||||
/**
|
|
||||||
* Prefix chat-messages with world-names.
|
|
||||||
*/
|
|
||||||
worldnameprefix,
|
|
||||||
/**
|
|
||||||
* If value is set to false, Multiverse will NOT enforce world access permissions.
|
|
||||||
*/
|
|
||||||
enforceaccess,
|
|
||||||
/**
|
|
||||||
* Whether users should get detailed information about the permissions they would need.
|
|
||||||
*/
|
|
||||||
displaypermerrors,
|
|
||||||
/**
|
|
||||||
* Debug-information.
|
|
||||||
*/
|
|
||||||
debug,
|
|
||||||
/**
|
|
||||||
* The world new users will spawn in.
|
|
||||||
*/
|
|
||||||
firstspawnworld,
|
|
||||||
/**
|
|
||||||
* Whether Multiverse should intercept teleports.
|
|
||||||
*/
|
|
||||||
teleportintercept,
|
|
||||||
/**
|
|
||||||
* Whether Multiverse should override the first spawn.
|
|
||||||
*/
|
|
||||||
firstspawnoverride;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a string containing all values in this enum.
|
|
||||||
*
|
|
||||||
* @return That {@link String}.
|
|
||||||
*/
|
|
||||||
public static String getAllValues() {
|
|
||||||
String buffer = "";
|
|
||||||
for (ConfigProperty c : ConfigProperty.values()) {
|
|
||||||
// All values will NOT Contain spaces.
|
|
||||||
buffer += c.toString() + " ";
|
|
||||||
}
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -55,7 +55,7 @@ public class MVPlayerListener implements Listener {
|
||||||
}
|
}
|
||||||
// Check whether the Server is set to prefix the chat with the World name.
|
// 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.
|
// If not we do nothing, if so we need to check if the World has an Alias.
|
||||||
if (MultiverseCore.getStaticConfig().getPrefixChat()) {
|
if (plugin.getMVConfig().getPrefixChat()) {
|
||||||
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
|
||||||
|
@ -127,7 +127,7 @@ public class MVPlayerListener implements Listener {
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
if (!p.hasPlayedBefore()) {
|
if (!p.hasPlayedBefore()) {
|
||||||
this.plugin.log(Level.FINE, "Player joined first!");
|
this.plugin.log(Level.FINE, "Player joined first!");
|
||||||
if (MultiverseCore.getStaticConfig().getFirstSpawnOverride()) {
|
if (plugin.getMVConfig().getFirstSpawnOverride()) {
|
||||||
this.plugin.log(Level.FINE, "Moving NEW player to(firstspawnoverride): " + worldManager.getFirstSpawnWorld().getSpawnLocation());
|
this.plugin.log(Level.FINE, "Moving NEW player to(firstspawnoverride): " + worldManager.getFirstSpawnWorld().getSpawnLocation());
|
||||||
this.spawnNewPlayer(p);
|
this.spawnNewPlayer(p);
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ public class MVPlayerListener implements Listener {
|
||||||
teleportee.getName(), event.getTo().getWorld().getName(), teleporter.getName()));
|
teleportee.getName(), event.getTo().getWorld().getName(), teleporter.getName()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (MultiverseCore.getStaticConfig().getEnforceAccess()) {
|
if (plugin.getMVConfig().getEnforceAccess()) {
|
||||||
event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, teleporter, teleportee));
|
event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, teleporter, teleportee));
|
||||||
if (event.isCancelled() && teleporter != null) {
|
if (event.isCancelled() && teleporter != null) {
|
||||||
this.plugin.log(Level.FINE, String.format("Player '%s' was DENIED ACCESS to '%s' because '%s' don't have: multiverse.access.%s",
|
this.plugin.log(Level.FINE, String.format("Player '%s' was DENIED ACCESS to '%s' because '%s' don't have: multiverse.access.%s",
|
||||||
|
@ -262,7 +262,7 @@ public class MVPlayerListener implements Listener {
|
||||||
event.getPlayer().getName(), event.getTo().getWorld().getName()));
|
event.getPlayer().getName(), event.getTo().getWorld().getName()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (MultiverseCore.getStaticConfig().getEnforceAccess()) {
|
if (plugin.getMVConfig().getEnforceAccess()) {
|
||||||
event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, event.getPlayer(), event.getPlayer()));
|
event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, event.getPlayer(), event.getPlayer()));
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
this.plugin.log(Level.FINE, String.format("Player '%s' was DENIED ACCESS to '%s' because they don't have: multiverse.access.%s",
|
this.plugin.log(Level.FINE, String.format("Player '%s' was DENIED ACCESS to '%s' because they don't have: multiverse.access.%s",
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class MVPermissions implements PermissionsInterface {
|
||||||
*/
|
*/
|
||||||
public boolean canEnterWorld(Player p, MultiverseWorld w) {
|
public boolean canEnterWorld(Player p, MultiverseWorld w) {
|
||||||
// If we're not enforcing access, anyone can enter.
|
// If we're not enforcing access, anyone can enter.
|
||||||
if (!MultiverseCore.getStaticConfig().getEnforceAccess()) {
|
if (!plugin.getMVConfig().getEnforceAccess()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return this.hasPermission(p, "multiverse.access." + w.getName(), false);
|
return this.hasPermission(p, "multiverse.access." + w.getName(), false);
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
package com.onarandombox.MultiverseCore.utils;
|
package com.onarandombox.MultiverseCore.utils;
|
||||||
|
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import com.onarandombox.MultiverseCore.MultiverseCoreConfiguration;
|
||||||
import org.bukkit.configuration.Configuration;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -23,9 +23,9 @@ public class MVPlayerSession {
|
||||||
private long teleportLast = 0L; // Timestamp for the Players last Portal Teleportation.
|
private long teleportLast = 0L; // Timestamp for the Players last Portal Teleportation.
|
||||||
private long messageLast = 0L; // Timestamp for the Players last Alert Message.
|
private long messageLast = 0L; // Timestamp for the Players last Alert Message.
|
||||||
|
|
||||||
private Configuration config; // Configuration file to find out Cooldown Timers.
|
private MultiverseCoreConfiguration config; // Configuration file to find out Cooldown Timers.
|
||||||
|
|
||||||
public MVPlayerSession(Player player, Configuration config, MultiverseCore multiVerseCore) {
|
public MVPlayerSession(Player player, MultiverseCoreConfiguration config) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
// this.bedSpawn = null;
|
// this.bedSpawn = null;
|
||||||
|
@ -42,6 +42,6 @@ public class MVPlayerSession {
|
||||||
*/
|
*/
|
||||||
public boolean getTeleportable() {
|
public boolean getTeleportable() {
|
||||||
long time = (new Date()).getTime();
|
long time = (new Date()).getTime();
|
||||||
return ((time - this.teleportLast) > this.config.getInt("portalcooldown", 5000)); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
return ((time - this.teleportLast) > this.config.getPortalCooldown());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class PermissionTools {
|
||||||
*/
|
*/
|
||||||
public boolean playerHasMoneyToEnter(MultiverseWorld fromWorld, MultiverseWorld toWorld, CommandSender teleporter, Player teleportee, boolean pay) {
|
public boolean playerHasMoneyToEnter(MultiverseWorld fromWorld, MultiverseWorld toWorld, CommandSender teleporter, Player teleportee, boolean pay) {
|
||||||
Player teleporterPlayer;
|
Player teleporterPlayer;
|
||||||
if (MultiverseCore.getStaticConfig().getTeleportIntercept()) {
|
if (plugin.getMVConfig().getTeleportIntercept()) {
|
||||||
if (teleporter instanceof ConsoleCommandSender) {
|
if (teleporter instanceof ConsoleCommandSender) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ public class PermissionTools {
|
||||||
this.plugin.log(Level.FINEST, "Checking '" + teleporter + "' can send '" + teleportee + "' somewhere");
|
this.plugin.log(Level.FINEST, "Checking '" + teleporter + "' can send '" + teleportee + "' somewhere");
|
||||||
|
|
||||||
Player teleporterPlayer;
|
Player teleporterPlayer;
|
||||||
if (MultiverseCore.getStaticConfig().getTeleportIntercept()) {
|
if (plugin.getMVConfig().getTeleportIntercept()) {
|
||||||
// The console can send anyone anywhere
|
// The console can send anyone anywhere
|
||||||
if (teleporter instanceof ConsoleCommandSender) {
|
if (teleporter instanceof ConsoleCommandSender) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -210,7 +210,7 @@ public class WorldManager implements MVWorldManager {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setFirstSpawnWorld(String world) {
|
public void setFirstSpawnWorld(String world) {
|
||||||
if (world == null) {
|
if ((world == null) && (this.plugin.getServer().getWorlds().size() > 0)) {
|
||||||
this.firstSpawn = this.plugin.getServer().getWorlds().get(0).getName();
|
this.firstSpawn = this.plugin.getServer().getWorlds().get(0).getName();
|
||||||
} else {
|
} else {
|
||||||
this.firstSpawn = world;
|
this.firstSpawn = world;
|
||||||
|
|
|
@ -4,11 +4,3 @@
|
||||||
# When in-game, simply type: "/mv conf ?" for help.
|
# When in-game, simply type: "/mv conf ?" for help.
|
||||||
# A config with explanations can be found here:
|
# A config with explanations can be found here:
|
||||||
# https://github.com/Multiverse/Multiverse-Core/wiki/config.yml
|
# https://github.com/Multiverse/Multiverse-Core/wiki/config.yml
|
||||||
|
|
||||||
worldnameprefix: true
|
|
||||||
enforceaccess: true
|
|
||||||
displaypermerrors: true
|
|
||||||
teleportintercept: true
|
|
||||||
firstspawnoverride: true
|
|
||||||
messagecooldown: 5000
|
|
||||||
version: 2.7
|
|
||||||
|
|
|
@ -22,12 +22,14 @@ import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
|
import com.onarandombox.MultiverseCore.api.Core;
|
||||||
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
|
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
|
@ -54,6 +56,7 @@ public class TestDebugMode {
|
||||||
public void testEnableDebugMode() {
|
public void testEnableDebugMode() {
|
||||||
// Pull a core instance from the server.
|
// Pull a core instance from the server.
|
||||||
Plugin plugin = mockServer.getPluginManager().getPlugin("Multiverse-Core");
|
Plugin plugin = mockServer.getPluginManager().getPlugin("Multiverse-Core");
|
||||||
|
Core core = (Core) plugin;
|
||||||
|
|
||||||
// Make sure Core is not null
|
// Make sure Core is not null
|
||||||
assertNotNull(plugin);
|
assertNotNull(plugin);
|
||||||
|
@ -70,12 +73,12 @@ public class TestDebugMode {
|
||||||
when(mockCommand.getName()).thenReturn("mv");
|
when(mockCommand.getName()).thenReturn("mv");
|
||||||
|
|
||||||
// Assert debug mode is off
|
// Assert debug mode is off
|
||||||
Assert.assertEquals(0, MultiverseCore.getStaticConfig().getGlobalDebug());
|
Assert.assertEquals(0, core.getMVConfig().getGlobalDebug());
|
||||||
|
|
||||||
// Send the debug command.
|
// Send the debug command.
|
||||||
String[] debugArgs = new String[] { "debug", "3" };
|
String[] debugArgs = new String[] { "debug", "3" };
|
||||||
plugin.onCommand(mockCommandSender, mockCommand, "", debugArgs);
|
plugin.onCommand(mockCommandSender, mockCommand, "", debugArgs);
|
||||||
|
|
||||||
Assert.assertEquals(3, MultiverseCore.getStaticConfig().getGlobalDebug());
|
Assert.assertEquals(3, core.getMVConfig().getGlobalDebug());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.bukkit.permissions.Permission;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.internal.verification.VerificationModeFactory;
|
import org.mockito.internal.verification.VerificationModeFactory;
|
||||||
|
@ -165,10 +166,10 @@ public class TestWorldProperties {
|
||||||
assertFalse(thunderChangeOnEvent.isCancelled());
|
assertFalse(thunderChangeOnEvent.isCancelled());
|
||||||
|
|
||||||
// call player chat event
|
// call player chat event
|
||||||
MultiverseCore.getStaticConfig().setPrefixChat(true);
|
core.getMVConfig().setPrefixChat(true);
|
||||||
core.getPlayerListener().playerChat(playerChatEvent);
|
core.getPlayerListener().playerChat(playerChatEvent);
|
||||||
verify(playerChatEvent).setFormat("[" + mvWorld.getColoredWorldString() + "]" + "format");
|
verify(playerChatEvent).setFormat("[" + mvWorld.getColoredWorldString() + "]" + "format");
|
||||||
MultiverseCore.getStaticConfig().setPrefixChat(false);
|
core.getMVConfig().setPrefixChat(false);
|
||||||
core.getPlayerListener().playerChat(playerChatEvent);
|
core.getPlayerListener().playerChat(playerChatEvent);
|
||||||
verify(playerChatEvent, times(1)).setFormat(anyString()); // only ONE TIME (not the 2nd time!)
|
verify(playerChatEvent, times(1)).setFormat(anyString()); // only ONE TIME (not the 2nd time!)
|
||||||
|
|
||||||
|
@ -263,7 +264,7 @@ public class TestWorldProperties {
|
||||||
assertTrue(thunderChangeOnEvent.isCancelled());
|
assertTrue(thunderChangeOnEvent.isCancelled());
|
||||||
|
|
||||||
// call player chat event
|
// call player chat event
|
||||||
MultiverseCore.getStaticConfig().setPrefixChat(true);
|
core.getMVConfig().setPrefixChat(true);
|
||||||
core.getPlayerListener().playerChat(playerChatEvent);
|
core.getPlayerListener().playerChat(playerChatEvent);
|
||||||
// never because it's hidden!
|
// never because it's hidden!
|
||||||
verify(playerChatEvent, never()).setFormat(
|
verify(playerChatEvent, never()).setFormat(
|
||||||
|
@ -271,7 +272,7 @@ public class TestWorldProperties {
|
||||||
mvWorld.setHidden(false);
|
mvWorld.setHidden(false);
|
||||||
core.getPlayerListener().playerChat(playerChatEvent);
|
core.getPlayerListener().playerChat(playerChatEvent);
|
||||||
verify(playerChatEvent).setFormat("[" + mvWorld.getColoredWorldString() + "]" + "format");
|
verify(playerChatEvent).setFormat("[" + mvWorld.getColoredWorldString() + "]" + "format");
|
||||||
MultiverseCore.getStaticConfig().setPrefixChat(false);
|
core.getMVConfig().setPrefixChat(false);
|
||||||
core.getPlayerListener().playerChat(playerChatEvent);
|
core.getPlayerListener().playerChat(playerChatEvent);
|
||||||
verify(playerChatEvent, times(1)).setFormat(anyString()); // only ONE TIME (not the 2nd time!)
|
verify(playerChatEvent, times(1)).setFormat(anyString()); // only ONE TIME (not the 2nd time!)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue