mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-01-06 00:08:04 +01:00
refactor: Rename config methods to align with new structure
This commit is contained in:
parent
136bd3cbe2
commit
2edf955332
@ -67,7 +67,6 @@ import com.onarandombox.MultiverseCore.utils.metrics.MetricsConfigurator;
|
||||
import com.onarandombox.MultiverseCore.world.SimpleMVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.world.WorldProperties;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -148,10 +147,10 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
this.worldManager.loadWorlds(true);
|
||||
|
||||
// Now set the firstspawnworld (after the worlds are loaded):
|
||||
this.worldManager.setFirstSpawnWorld(getMVConfig().getFirstSpawnWorld());
|
||||
this.worldManager.setFirstSpawnWorld(getMVConfig().getFirstSpawnLocation());
|
||||
MVWorld firstSpawnWorld = this.worldManager.getFirstSpawnWorld();
|
||||
if (firstSpawnWorld != null) {
|
||||
getMVConfig().setFirstSpawnWorld(firstSpawnWorld.getName());
|
||||
getMVConfig().setFirstSpawnLocation(firstSpawnWorld.getName());
|
||||
}
|
||||
|
||||
//Setup economy here so vault is loaded
|
||||
|
@ -1,16 +1,37 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
public interface MVConfig {
|
||||
|
||||
/**
|
||||
* Loads the config from disk.
|
||||
* @return True if the config was loaded successfully.
|
||||
*/
|
||||
boolean load();
|
||||
|
||||
/**
|
||||
* Saves the config to disk.
|
||||
*/
|
||||
void save();
|
||||
|
||||
/**
|
||||
* Gets a property from the config.
|
||||
*
|
||||
* @param name The name of the property.
|
||||
* @return The value of the property.
|
||||
*/
|
||||
Object getProperty(String name);
|
||||
|
||||
/**
|
||||
* Sets a property in the config.
|
||||
*
|
||||
* @param name The name of the property.
|
||||
* @param value The value of the property.
|
||||
* @return True if the property was set successfully.
|
||||
*/
|
||||
boolean setProperty(String name, Object value);
|
||||
|
||||
/**
|
||||
* Sets enforceAccess.
|
||||
* Sets world access permissions should be enforced.
|
||||
* @param enforceAccess The new value.
|
||||
*/
|
||||
void setEnforceAccess(boolean enforceAccess);
|
||||
@ -21,19 +42,31 @@ public interface MVConfig {
|
||||
*/
|
||||
boolean getEnforceAccess();
|
||||
|
||||
/**
|
||||
* Sets whether the game mode should be enforced.
|
||||
* @param enforceGameMode The new value.
|
||||
*/
|
||||
void setEnforceGameMode(boolean enforceGameMode);
|
||||
|
||||
/**
|
||||
* Gets enforceGameMode value.
|
||||
* @return True if game mode should be enforced.
|
||||
*/
|
||||
boolean getEnforceGameMode();
|
||||
|
||||
/**
|
||||
* Sets whether or not the automatic purge of entities is enabled.
|
||||
*
|
||||
* @param autopurge True if automatic purge should be enabled.
|
||||
*/
|
||||
void setAutoPurgeEnabled(boolean autopurge);
|
||||
void setAutoPurgeEntities(boolean autopurge);
|
||||
|
||||
/**
|
||||
* Gets whether or not the automatic purge of entities is enabled.
|
||||
*
|
||||
* @return True if automatic purge is enabled.
|
||||
*/
|
||||
boolean isAutoPurgeEnabled();
|
||||
boolean isAutoPurgeEntities();
|
||||
|
||||
/**
|
||||
* Sets teleportIntercept.
|
||||
@ -63,13 +96,13 @@ public interface MVConfig {
|
||||
* Sets firstSpawnWorld.
|
||||
* @param firstSpawnWorld The new value.
|
||||
*/
|
||||
void setFirstSpawnWorld(String firstSpawnWorld);
|
||||
void setFirstSpawnLocation(String firstSpawnWorld);
|
||||
|
||||
/**
|
||||
* Gets firstSpawnWorld.
|
||||
* @return firstSpawnWorld.
|
||||
*/
|
||||
String getFirstSpawnWorld();
|
||||
String getFirstSpawnLocation();
|
||||
|
||||
/**
|
||||
* Sets whether or not to let Bukkit determine portal search radius on its own or if Multiverse should give input.
|
||||
@ -90,26 +123,26 @@ public interface MVConfig {
|
||||
*
|
||||
* @param searchRadius The portal search radius.
|
||||
*/
|
||||
void setPortalSearchRadius(int searchRadius);
|
||||
void setCustomPortalSearchRadius(int searchRadius);
|
||||
|
||||
/**
|
||||
* Gets the radius at which vanilla style portals will be searched for to connect to worlds together.
|
||||
*
|
||||
* @return The portal search radius.
|
||||
*/
|
||||
int getPortalSearchRadius();
|
||||
int getCustomPortalSearchRadius();
|
||||
|
||||
/**
|
||||
* Sets prefixChat.
|
||||
* @param prefixChat The new value.
|
||||
*/
|
||||
void setPrefixChat(boolean prefixChat);
|
||||
void setEnablePrefixChat(boolean prefixChat);
|
||||
|
||||
/**
|
||||
* Gets prefixChat.
|
||||
* @return prefixChat.
|
||||
*/
|
||||
boolean getPrefixChat();
|
||||
boolean isEnablePrefixChat();
|
||||
|
||||
/**
|
||||
* Sets prefixChatFormat.
|
||||
|
@ -112,12 +112,22 @@ public class DefaultMVConfig implements MVConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoPurgeEnabled(boolean autopurge) {
|
||||
public void setEnforceGameMode(boolean enforceGameMode) {
|
||||
settings.set(MVConfigNodes.ENFORCE_GAMEMODE, enforceGameMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getEnforceGameMode() {
|
||||
return settings.get(MVConfigNodes.ENFORCE_GAMEMODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoPurgeEntities(boolean autopurge) {
|
||||
settings.set(MVConfigNodes.AUTO_PURGE_ENTITIES, autopurge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoPurgeEnabled() {
|
||||
public boolean isAutoPurgeEntities() {
|
||||
return settings.get(MVConfigNodes.AUTO_PURGE_ENTITIES);
|
||||
}
|
||||
|
||||
@ -142,12 +152,12 @@ public class DefaultMVConfig implements MVConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFirstSpawnWorld(String firstSpawnWorld) {
|
||||
public void setFirstSpawnLocation(String firstSpawnWorld) {
|
||||
settings.set(MVConfigNodes.FIRST_SPAWN_LOCATION, firstSpawnWorld);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFirstSpawnWorld() {
|
||||
public String getFirstSpawnLocation() {
|
||||
return settings.get(MVConfigNodes.FIRST_SPAWN_LOCATION);
|
||||
}
|
||||
|
||||
@ -162,22 +172,22 @@ public class DefaultMVConfig implements MVConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPortalSearchRadius(int searchRadius) {
|
||||
public void setCustomPortalSearchRadius(int searchRadius) {
|
||||
settings.set(MVConfigNodes.CUSTOM_PORTAL_SEARCH_RADIUS, searchRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPortalSearchRadius() {
|
||||
public int getCustomPortalSearchRadius() {
|
||||
return settings.get(MVConfigNodes.CUSTOM_PORTAL_SEARCH_RADIUS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrefixChat(boolean prefixChat) {
|
||||
public void setEnablePrefixChat(boolean prefixChat) {
|
||||
settings.set(MVConfigNodes.ENABLE_CHAT_PREFIX, prefixChat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPrefixChat() {
|
||||
public boolean isEnablePrefixChat() {
|
||||
return settings.get(MVConfigNodes.ENABLE_CHAT_PREFIX);
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class MVChatListener implements Listener {
|
||||
}
|
||||
// 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 (plugin.getMVConfig().getPrefixChat()) {
|
||||
if (plugin.getMVConfig().isEnablePrefixChat()) {
|
||||
String world = playerListener.getPlayerWorld().get(event.getPlayer().getName());
|
||||
if (world == null) {
|
||||
world = event.getPlayer().getWorld().getName();
|
||||
|
@ -116,7 +116,7 @@ public class MVEntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
if (this.plugin.getMVConfig().isUsingCustomPortalSearch()) {
|
||||
event.setSearchRadius(this.plugin.getMVConfig().getPortalSearchRadius());
|
||||
event.setSearchRadius(this.plugin.getMVConfig().getCustomPortalSearchRadius());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ public class MVPlayerListener implements Listener {
|
||||
+ "' because enforceaccess is off.");
|
||||
}
|
||||
if (this.plugin.getMVConfig().isUsingCustomPortalSearch()) {
|
||||
event.setSearchRadius(this.plugin.getMVConfig().getPortalSearchRadius());
|
||||
event.setSearchRadius(this.plugin.getMVConfig().getCustomPortalSearchRadius());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -281,7 +281,7 @@ public class SimpleMVWorld implements MVWorld {
|
||||
}
|
||||
world.setSpawnFlags(allowMonsters, allowAnimals);
|
||||
}
|
||||
if (plugin.getMVConfig().isAutoPurgeEnabled()) {
|
||||
if (plugin.getMVConfig().isAutoPurgeEntities()) {
|
||||
plugin.getMVWorldManager().getTheWorldPurger().purgeWorld(SimpleMVWorld.this);
|
||||
}
|
||||
return super.validateChange(property, newValue, oldValue, object);
|
||||
|
@ -481,7 +481,7 @@ public class SimpleMVWorldManager implements MVWorldManager {
|
||||
return false;
|
||||
}
|
||||
SimpleMVWorld world = new SimpleMVWorld(plugin, cbworld, mvworld);
|
||||
if (plugin.getMVConfig().isAutoPurgeEnabled()) {
|
||||
if (plugin.getMVConfig().isAutoPurgeEntities()) {
|
||||
this.worldPurger.purgeWorld(world);
|
||||
}
|
||||
this.worlds.put(worldName, world);
|
||||
|
@ -177,10 +177,10 @@ public class TestWorldProperties {
|
||||
assertFalse(thunderChangeOnEvent.isCancelled());
|
||||
|
||||
// call player chat event
|
||||
core.getMVConfig().setPrefixChat(true);
|
||||
core.getMVConfig().setEnablePrefixChat(true);
|
||||
core.getChatListener().playerChat(playerChatEvent);
|
||||
verify(playerChatEvent).setFormat("[" + mvWorld.getColoredWorldString() + "]" + "format");
|
||||
core.getMVConfig().setPrefixChat(false);
|
||||
core.getMVConfig().setEnablePrefixChat(false);
|
||||
core.getChatListener().playerChat(playerChatEvent);
|
||||
verify(playerChatEvent, times(1)).setFormat(anyString()); // only ONE TIME (not the 2nd time!)
|
||||
|
||||
@ -271,7 +271,7 @@ public class TestWorldProperties {
|
||||
assertTrue(thunderChangeOnEvent.isCancelled());
|
||||
|
||||
// call player chat event
|
||||
core.getMVConfig().setPrefixChat(true);
|
||||
core.getMVConfig().setEnablePrefixChat(true);
|
||||
core.getChatListener().playerChat(playerChatEvent);
|
||||
// never because it's hidden!
|
||||
verify(playerChatEvent, never()).setFormat(
|
||||
@ -279,7 +279,7 @@ public class TestWorldProperties {
|
||||
mvWorld.setHidden(false);
|
||||
core.getChatListener().playerChat(playerChatEvent);
|
||||
verify(playerChatEvent).setFormat("[" + mvWorld.getColoredWorldString() + "]" + "format");
|
||||
core.getMVConfig().setPrefixChat(false);
|
||||
core.getMVConfig().setEnablePrefixChat(false);
|
||||
core.getChatListener().playerChat(playerChatEvent);
|
||||
verify(playerChatEvent, times(1)).setFormat(anyString()); // only ONE TIME (not the 2nd time!)
|
||||
mvWorld.setHidden(true); // reset hidden-state
|
||||
|
Loading…
Reference in New Issue
Block a user