mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-02-17 21:12:03 +01:00
Add configurable option to allow unsafe worldname.
This commit is contained in:
parent
f72cc6764b
commit
0e9fe0c3ec
@ -1,7 +1,5 @@
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
|
||||
import com.onarandombox.MultiverseCore.event.MVDebugModeEvent;
|
||||
@ -10,6 +8,8 @@ import me.main__.util.SerializationConfig.Property;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Our configuration.
|
||||
*/
|
||||
@ -77,6 +77,8 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
private volatile boolean autopurge;
|
||||
@Property
|
||||
private volatile boolean idonotwanttodonate;
|
||||
@Property
|
||||
private volatile boolean allowunsafeworldname;
|
||||
|
||||
public MultiverseCoreConfiguration() {
|
||||
super();
|
||||
@ -111,6 +113,7 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
portalsearchradius = 128;
|
||||
autopurge = true;
|
||||
idonotwanttodonate = false;
|
||||
allowunsafeworldname = false;
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
}
|
||||
|
||||
@ -382,4 +385,14 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
public void setShowDonateMessage(boolean showDonateMessage) {
|
||||
this.idonotwanttodonate = !showDonateMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowUnsafeWorldName() {
|
||||
return allowunsafeworldname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAllowUnsafeWorldName(boolean allowUnsafeWorldName) {
|
||||
this.allowunsafeworldname = allowUnsafeWorldName;
|
||||
}
|
||||
}
|
||||
|
@ -239,4 +239,8 @@ public interface MultiverseCoreConfig extends ConfigurationSerializable {
|
||||
* @param idonotwanttodonate True if donation/patreon messages should be shown.
|
||||
*/
|
||||
void setShowDonateMessage(boolean idonotwanttodonate);
|
||||
|
||||
boolean isAllowUnsafeWorldName();
|
||||
|
||||
void setAllowUnsafeWorldName(boolean allowUnsafeWorldName);
|
||||
}
|
||||
|
@ -48,7 +48,6 @@ import java.util.Set;
|
||||
import java.util.Stack;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -130,7 +129,11 @@ public class WorldManager implements MVWorldManager {
|
||||
}
|
||||
|
||||
// Check for valid world name
|
||||
if (!(WorldNameChecker.isValidWorldName(oldName) && WorldNameChecker.isValidWorldName(newName))) {
|
||||
if (!this.plugin.getMVConfig().isAllowUnsafeWorldName() && !WorldNameChecker.isValidWorldName(newName)) {
|
||||
Logging.warning("Unable to clone world as world name '" + newName + "' is invalid.");
|
||||
Logging.warning("World name should not contain spaces or special characters!");
|
||||
Logging.warning("Enable allowunsafeworldname to bypass the check if you are absolutely sure this world is valid.");
|
||||
Logging.warning("However, MV is not response of any damage to your world if you enable this option.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -234,13 +237,12 @@ public class WorldManager implements MVWorldManager {
|
||||
@Override
|
||||
public boolean addWorld(String name, Environment env, String seedString, WorldType type, Boolean generateStructures,
|
||||
String generator, boolean useSpawnAdjust) {
|
||||
if (name.equalsIgnoreCase("plugins") || name.equalsIgnoreCase("logs")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!WorldNameChecker.isValidWorldName(name)) {
|
||||
Logging.warning("Invalid world name '" + name + "'");
|
||||
if (!this.plugin.getMVConfig().isAllowUnsafeWorldName() && !WorldNameChecker.isValidWorldName(name)) {
|
||||
Logging.warning("Unable to add world as world name '" + name + "' is invalid.");
|
||||
Logging.warning("World name should not contain spaces or special characters!");
|
||||
Logging.warning("Enable allowunsafeworldname to bypass the check if you are absolutely sure this world is valid.");
|
||||
Logging.warning("However, MV is not response of any damage to your world if you enable this option.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user