mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-25 20:16:06 +01:00
Fixed long seeds not loading properly (this happened with the new config), Add Regenning of worlds. This works for the same seed, but new seeds are still in the works.
This commit is contained in:
parent
fa0c843f39
commit
d2a5898e53
@ -60,6 +60,7 @@ public class MVWorld implements MultiverseWorld {
|
||||
// Set local values that CANNOT be changed by user
|
||||
this.world = world;
|
||||
this.name = world.getName();
|
||||
System.out.println("MVWorld recieved seed: " + seed);
|
||||
this.seed = seed;
|
||||
this.environment = world.getEnvironment();
|
||||
|
||||
|
@ -11,6 +11,8 @@ import com.fernferret.allpay.AllPay;
|
||||
import com.fernferret.allpay.GenericBank;
|
||||
import com.onarandombox.MultiverseCore.api.Core;
|
||||
import com.onarandombox.MultiverseCore.api.MVPlugin;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.commands.*;
|
||||
import com.onarandombox.MultiverseCore.destination.*;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
|
||||
@ -37,6 +39,7 @@ import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -92,7 +95,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// Configurations
|
||||
private FileConfiguration multiverseConfig = null;
|
||||
|
||||
private WorldManager worldManager = new WorldManager(this);
|
||||
private MVWorldManager worldManager = new WorldManager(this);
|
||||
|
||||
// Setup the block/player/entity listener.
|
||||
private MVPlayerListener playerListener = new MVPlayerListener(this);
|
||||
@ -234,7 +237,9 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
this.destFactory.registerDestinationType(BedDestination.class, "b");
|
||||
}
|
||||
|
||||
/** Function to Register all the Events needed. */
|
||||
/**
|
||||
* Function to Register all the Events needed.
|
||||
*/
|
||||
private void registerEvents() {
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
// pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Highest, this); // Low so it acts above any other.
|
||||
@ -258,7 +263,9 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
pm.registerEvent(Event.Type.THUNDER_CHANGE, this.weatherListener, Priority.Normal, this);
|
||||
}
|
||||
|
||||
/** Load the Configuration files OR create the default config files. */
|
||||
/**
|
||||
* Load the Configuration files OR create the default config files.
|
||||
*/
|
||||
public void loadConfigs() {
|
||||
// Now grab the Configuration Files.
|
||||
this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
|
||||
@ -284,7 +291,9 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
return this.messaging;
|
||||
}
|
||||
|
||||
/** Register Multiverse-Core commands to Command Manager. */
|
||||
/**
|
||||
* Register Multiverse-Core commands to Command Manager.
|
||||
*/
|
||||
private void registerCommands() {
|
||||
// Intro Commands
|
||||
this.commandHandler.registerCommand(new HelpCommand(this));
|
||||
@ -304,6 +313,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
this.commandHandler.registerCommand(new LoadCommand(this));
|
||||
this.commandHandler.registerCommand(new RemoveCommand(this));
|
||||
this.commandHandler.registerCommand(new DeleteCommand(this));
|
||||
this.commandHandler.registerCommand(new RegenCommand(this));
|
||||
this.commandHandler.registerCommand(new ConfirmCommand(this));
|
||||
// Modification commands
|
||||
this.commandHandler.registerCommand(new ModifyCommand(this));
|
||||
@ -320,7 +330,9 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
this.commandHandler.registerCommand(new CheckCommand(this));
|
||||
}
|
||||
|
||||
/** What happens when the plugin gets disabled... */
|
||||
/**
|
||||
* What happens when the plugin gets disabled...
|
||||
*/
|
||||
public void onDisable() {
|
||||
debugLog.close();
|
||||
this.banker = null;
|
||||
@ -356,7 +368,9 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
return this.ph;
|
||||
}
|
||||
|
||||
/** onCommand */
|
||||
/**
|
||||
* onCommand
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
|
||||
if (!this.isEnabled()) {
|
||||
@ -445,7 +459,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
* This code should get moved somewhere more appropriate, but for now, it's here.
|
||||
*
|
||||
* @param env
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Environment getEnvFromString(String env) {
|
||||
@ -487,12 +500,16 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
return this.pluginCount;
|
||||
}
|
||||
|
||||
/** Increments the number of plugins that have specifically hooked into core. */
|
||||
/**
|
||||
* Increments the number of plugins that have specifically hooked into core.
|
||||
*/
|
||||
public void incrementPluginCount() {
|
||||
this.pluginCount += 1;
|
||||
}
|
||||
|
||||
/** Decrements the number of plugins that have specifically hooked into core. */
|
||||
/**
|
||||
* Decrements the number of plugins that have specifically hooked into core.
|
||||
*/
|
||||
public void decrementPluginCount() {
|
||||
this.pluginCount -= 1;
|
||||
}
|
||||
@ -563,7 +580,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
return this.spoutInterface;
|
||||
}
|
||||
|
||||
public WorldManager getMVWorldManager() {
|
||||
public MVWorldManager getMVWorldManager() {
|
||||
return this.worldManager;
|
||||
}
|
||||
|
||||
@ -597,10 +614,40 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
* NOT deprecated for the time as queued commands use this.
|
||||
*
|
||||
* @param name World to delete
|
||||
*
|
||||
* @return True if success, false if fail.
|
||||
*/
|
||||
public Boolean deleteWorld(String name) {
|
||||
return this.worldManager.deleteWorld(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by queued commands to delete a world on a delay.
|
||||
*
|
||||
* @param name World to delete
|
||||
* @return True if success, false if fail.
|
||||
*/
|
||||
public Boolean regenWorld(String name, Boolean useNewSeed, Boolean randomSeed, String seed) {
|
||||
MultiverseWorld world = this.worldManager.getMVWorld(name);
|
||||
if(world == null) {
|
||||
return false;
|
||||
}
|
||||
if (useNewSeed) {
|
||||
System.out.println("Using a new seed");
|
||||
// Set the worldseed.
|
||||
if(randomSeed) {
|
||||
System.out.println("Using a random seed");
|
||||
Random random = new Random();
|
||||
Long newseed = random.nextLong();
|
||||
seed = newseed.toString();
|
||||
} else {
|
||||
System.out.println("Using " + seed);
|
||||
}
|
||||
((WorldManager)this.worldManager).getConfigWorlds().set("worlds." + name + "seed", seed);
|
||||
}
|
||||
if (this.worldManager.deleteWorld(name, false)) {
|
||||
this.worldManager.loadWorlds(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -97,5 +97,5 @@ public interface Core {
|
||||
*
|
||||
* @return {@link WorldManager}.
|
||||
*/
|
||||
public WorldManager getMVWorldManager();
|
||||
public MVWorldManager getMVWorldManager();
|
||||
}
|
||||
|
@ -10,8 +10,10 @@ package com.onarandombox.MultiverseCore.api;
|
||||
import com.onarandombox.MultiverseCore.utils.PurgeWorlds;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@ -31,7 +33,6 @@ public interface MVWorldManager {
|
||||
* If the seed is a Long,
|
||||
* it will be interpreted as such.
|
||||
* @param generator The Custom generator plugin to use.
|
||||
*
|
||||
* @return True if the world is added, false if not.
|
||||
*/
|
||||
public boolean addWorld(String name, Environment env, String seedString, String generator);
|
||||
@ -41,16 +42,25 @@ public interface MVWorldManager {
|
||||
* config and deletes the folder
|
||||
*
|
||||
* @param name The name of the world to remove
|
||||
*
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
public Boolean deleteWorld(String name);
|
||||
|
||||
/**
|
||||
* Remove the world from the Multiverse list, from the
|
||||
* config and deletes the folder
|
||||
*
|
||||
* @param name The name of the world to remove
|
||||
* @param removeConfig If true(default), we'll remove the entries from the
|
||||
* config. If false, they'll stay and the world may come back.
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
public Boolean deleteWorld(String name, boolean removeConfig);
|
||||
|
||||
/**
|
||||
* Unload a world from Multiverse
|
||||
*
|
||||
* @param name Name of the world to unload
|
||||
*
|
||||
* @return True if the world was unloaded, false if not.
|
||||
*/
|
||||
public boolean unloadWorld(String name);
|
||||
@ -60,7 +70,6 @@ public interface MVWorldManager {
|
||||
* unloaded with {@link #unloadWorld(String)}.
|
||||
*
|
||||
* @param name The name of the world to load
|
||||
*
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
public boolean loadWorld(String name);
|
||||
@ -78,7 +87,6 @@ public interface MVWorldManager {
|
||||
* @param generator The generator name.
|
||||
* @param generatorID The generator id.
|
||||
* @param worldName The worldName to use as the default.
|
||||
*
|
||||
* @return A {@link ChunkGenerator} or null
|
||||
*/
|
||||
public ChunkGenerator getChunkGenerator(String generator, String generatorID, String worldName);
|
||||
@ -96,7 +104,6 @@ public interface MVWorldManager {
|
||||
* This will search name AND alias.
|
||||
*
|
||||
* @param name The name or alias of the world to get.
|
||||
*
|
||||
* @return A {@link MultiverseWorld} or null.
|
||||
*/
|
||||
public MultiverseWorld getMVWorld(String name);
|
||||
@ -105,7 +112,6 @@ public interface MVWorldManager {
|
||||
* Returns a {@link MultiverseWorld} if it exists, and null if it does not.
|
||||
*
|
||||
* @param world The Bukkit world to check.
|
||||
*
|
||||
* @return A {@link MultiverseWorld} or null.
|
||||
*/
|
||||
public MultiverseWorld getMVWorld(World world);
|
||||
@ -114,7 +120,6 @@ public interface MVWorldManager {
|
||||
* Checks to see if the given name is a valid {@link MultiverseWorld}
|
||||
*
|
||||
* @param name The name or alias of the world to check.
|
||||
*
|
||||
* @return True if the world exists, false if not.
|
||||
*/
|
||||
public boolean isMVWorld(String name);
|
||||
@ -123,7 +128,6 @@ public interface MVWorldManager {
|
||||
* Checks to see if the given world is a valid {@link MultiverseWorld}
|
||||
*
|
||||
* @param world The Bukkit world to check.
|
||||
*
|
||||
* @return True if the world has been loaded into MV2, false if not.
|
||||
*/
|
||||
public boolean isMVWorld(World world);
|
||||
@ -136,6 +140,13 @@ public interface MVWorldManager {
|
||||
*/
|
||||
public void loadWorlds(boolean forceLoad);
|
||||
|
||||
/**
|
||||
* Loads the Worlds & Settings for any worlds that bukkit loaded before us.
|
||||
* <p/>
|
||||
* This way people will _always_ have some worlds in the list.
|
||||
*/
|
||||
public void loadDefaultWorlds();
|
||||
|
||||
/**
|
||||
* Return the World Purger.
|
||||
*
|
||||
@ -151,5 +162,38 @@ public interface MVWorldManager {
|
||||
*/
|
||||
public MultiverseWorld getSpawnWorld();
|
||||
|
||||
/**
|
||||
* Gets the list of worlds in the config, but unloaded.
|
||||
*
|
||||
* @return A List of worlds as strings.
|
||||
*/
|
||||
public List<String> getUnloadedWorlds();
|
||||
|
||||
/**
|
||||
* This method populates an internal list and needs to be called after multiverse initialization.
|
||||
*/
|
||||
public void getDefaultWorldGenerators();
|
||||
|
||||
/**
|
||||
* Load the config from a file.
|
||||
*
|
||||
* @param file The file to load.
|
||||
* @return A loaded configuration.
|
||||
*/
|
||||
public FileConfiguration loadWorldConfig(File file);
|
||||
|
||||
/**
|
||||
* Saves the world config to disk.
|
||||
*
|
||||
* @return True if success, false if fail.
|
||||
*/
|
||||
public boolean saveWorldsConfig();
|
||||
|
||||
/**
|
||||
* Remove the world from the Multiverse list and from the config
|
||||
*
|
||||
* @param name The name of the world to remove
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
public boolean removeWorldFromConfig(String name);
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
|
||||
import com.onarandombox.MultiverseCore.utils.MVPermissions;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -20,7 +19,6 @@ import org.bukkit.permissions.PermissionDefault;
|
||||
import java.util.List;
|
||||
|
||||
public class CheckCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
|
||||
public CheckCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
@ -33,7 +31,6 @@ public class CheckCommand extends MultiverseCommand {
|
||||
this.addCommandExample("/mv check " + ChatColor.GREEN + "Rigby90 " + ChatColor.LIGHT_PURPLE + "p:MyPortal");
|
||||
this.addCommandExample("/mv check " + ChatColor.GREEN + "lithium3141 " + ChatColor.LIGHT_PURPLE + "ow:WarpName");
|
||||
this.setPermission("multiverse.core.debug", "Checks to see if a player can go to a destination. Prints debug if false.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,9 +8,9 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -22,7 +22,7 @@ import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
public class CoordCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public CoordCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
|
@ -8,6 +8,7 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -20,7 +21,7 @@ import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class CreateCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public CreateCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
|
@ -8,7 +8,7 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.command.Command;
|
||||
@ -20,7 +20,7 @@ import java.io.FilenameFilter;
|
||||
import java.util.List;
|
||||
|
||||
public class ImportCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public ImportCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
|
@ -9,8 +9,12 @@ package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.FancyText;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.utils.*;
|
||||
import com.onarandombox.MultiverseCore.utils.FancyColorScheme;
|
||||
import com.onarandombox.MultiverseCore.utils.FancyHeader;
|
||||
import com.onarandombox.MultiverseCore.utils.FancyMessage;
|
||||
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -24,7 +28,7 @@ import java.util.List;
|
||||
//import com.sun.xml.internal.ws.util.StringUtils;
|
||||
|
||||
public class InfoCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public InfoCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
|
@ -8,9 +8,9 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.enums.Action;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -22,7 +22,7 @@ import java.util.List;
|
||||
// Anything not in here will only support the SET action
|
||||
|
||||
public class ModifyAddCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public ModifyAddCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
|
@ -8,6 +8,7 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.enums.Action;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
@ -19,7 +20,7 @@ import org.bukkit.permissions.PermissionDefault;
|
||||
import java.util.List;
|
||||
|
||||
public class ModifyClearCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public ModifyClearCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
|
@ -8,9 +8,9 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.enums.Action;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -19,7 +19,7 @@ import org.bukkit.permissions.PermissionDefault;
|
||||
import java.util.List;
|
||||
|
||||
public class ModifyRemoveCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public ModifyRemoveCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
|
@ -8,6 +8,7 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
|
||||
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
||||
@ -20,7 +21,7 @@ import org.bukkit.permissions.PermissionDefault;
|
||||
import java.util.List;
|
||||
|
||||
public class ModifySetCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public ModifySetCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
|
@ -8,9 +8,9 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.utils.PurgeWorlds;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -21,7 +21,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PurgeCommand extends MultiverseCommand {
|
||||
private WorldManager worldManager;
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public PurgeCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
|
@ -0,0 +1,47 @@
|
||||
/******************************************************************************
|
||||
* 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.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RegenCommand extends MultiverseCommand {
|
||||
|
||||
public RegenCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Regenerates a World");
|
||||
this.setCommandUsage("/mv regen" + ChatColor.GREEN + " {WORLD}" + ChatColor.GOLD + " [-s [SEED]]");
|
||||
this.setArgRange(1, 3);
|
||||
this.addKey("mvregen");
|
||||
this.addKey("mv regen");
|
||||
this.addCommandExample("You can use the -s with no args to get a new seed:");
|
||||
this.addCommandExample("/mv regen " + ChatColor.GREEN + "MyWorld" + ChatColor.GOLD + " -s");
|
||||
this.addCommandExample("or specifiy a seed to get that one:");
|
||||
this.addCommandExample("/mv regen " + ChatColor.GREEN + "MyWorld" + ChatColor.GOLD + " -s" + ChatColor.AQUA + " gargamel");
|
||||
this.setPermission("multiverse.core.delete", "Deletes a world on your server. " + ChatColor.RED + "PERMANENTLY.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
Boolean useseed = (!(args.size() == 1));
|
||||
Boolean randomseed = (args.size() == 2 && args.get(1).equalsIgnoreCase("-s"));
|
||||
String seed = (args.size() == 3) ? args.get(2) : "";
|
||||
Class<?> paramTypes[] = {String.class, Boolean.class, Boolean.class, String.class};
|
||||
List<Object> objectArgs = new ArrayList<Object>();
|
||||
objectArgs.add(args.get(0));
|
||||
objectArgs.add(useseed);
|
||||
objectArgs.add(randomseed);
|
||||
objectArgs.add(seed);
|
||||
this.plugin.getCommandHandler().queueCommand(sender, "mvregen", "regenWorld", objectArgs, paramTypes, ChatColor.GREEN + "World Regenerated!", ChatColor.RED + "World could NOT be regenerated!");
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -20,7 +21,7 @@ import java.util.List;
|
||||
|
||||
public class WhoCommand extends MultiverseCommand {
|
||||
|
||||
private WorldManager worldManager;
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public WhoCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
|
@ -8,6 +8,7 @@
|
||||
package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import org.bukkit.World;
|
||||
@ -27,7 +28,7 @@ import java.util.logging.Level;
|
||||
public class MVEntityListener extends EntityListener {
|
||||
|
||||
private MultiverseCore plugin;
|
||||
private WorldManager worldManager;
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public MVEntityListener(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
|
@ -9,6 +9,7 @@ package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import com.fernferret.allpay.GenericBank;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
|
||||
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
|
||||
@ -22,7 +23,7 @@ import java.util.logging.Level;
|
||||
public class MVPlayerListener extends PlayerListener {
|
||||
MultiverseCore plugin;
|
||||
SafeTTeleporter mvteleporter;
|
||||
WorldManager worldManager;
|
||||
MVWorldManager worldManager;
|
||||
|
||||
public MVPlayerListener(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
|
@ -9,6 +9,7 @@ package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.pneumaticraft.commandhandler.PermissionsInterface;
|
||||
import org.bukkit.Location;
|
||||
@ -23,7 +24,7 @@ import java.util.logging.Level;
|
||||
public class MVPermissions implements PermissionsInterface {
|
||||
|
||||
private MultiverseCore plugin;
|
||||
private WorldManager worldMgr;
|
||||
private MVWorldManager worldMgr;
|
||||
|
||||
/**
|
||||
* Constructor FTW
|
||||
@ -40,7 +41,6 @@ public class MVPermissions implements PermissionsInterface {
|
||||
*
|
||||
* @param p The player to check.
|
||||
* @param w
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean canTravelFromWorld(Player p, MultiverseWorld w) {
|
||||
@ -74,7 +74,6 @@ public class MVPermissions implements PermissionsInterface {
|
||||
*
|
||||
* @param p
|
||||
* @param w
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean canEnterWorld(Player p, MultiverseWorld w) {
|
||||
@ -103,7 +102,6 @@ public class MVPermissions implements PermissionsInterface {
|
||||
*
|
||||
* @param sender The CommandSender to check.
|
||||
* @param d The destination they are requesting.
|
||||
*
|
||||
* @return True if that sender can go to that destination
|
||||
*/
|
||||
public boolean canEnterDestination(CommandSender sender, MVDestination d) {
|
||||
@ -130,7 +128,6 @@ public class MVPermissions implements PermissionsInterface {
|
||||
* @param sender Who is requesting the permission.
|
||||
* @param node The permission node in string format; multiverse.core.list.worlds for example.
|
||||
* @param isOpRequired @Deprecated. This is not used for anything anymore.
|
||||
*
|
||||
* @return True if they have that permission or any parent.
|
||||
*/
|
||||
public boolean hasPermission(CommandSender sender, String node, boolean isOpRequired) {
|
||||
@ -177,7 +174,6 @@ public class MVPermissions implements PermissionsInterface {
|
||||
*
|
||||
* @param sender Who is asking for the permission.
|
||||
* @param node The permission node to check (possibly already a parent).
|
||||
*
|
||||
* @return True if they have any parent perm, false if none.
|
||||
*/
|
||||
private boolean hasAnyParentPermission(CommandSender sender, String node) {
|
||||
@ -198,7 +194,6 @@ public class MVPermissions implements PermissionsInterface {
|
||||
* Given multiverse.core.list.worlds will return multiverse.core.list
|
||||
*
|
||||
* @param node The root node to check.
|
||||
*
|
||||
* @return The parent of the node
|
||||
*/
|
||||
private String pullOneLevelOff(String node) {
|
||||
@ -292,7 +287,6 @@ public class MVPermissions implements PermissionsInterface {
|
||||
* If the given permission was 'multiverse.core.tp.self', this would return 'multiverse.core.tp.*'.
|
||||
*
|
||||
* @param seperated
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getParentPerm(String[] seperated) {
|
||||
|
@ -47,6 +47,10 @@ public class WorldManager implements MVWorldManager {
|
||||
this.worldPurger = new PurgeWorlds(this.plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void getDefaultWorldGenerators() {
|
||||
this.defaultGens = new HashMap<String, String>();
|
||||
File[] files = this.plugin.getServerFolder().listFiles(new FilenameFilter() {
|
||||
@ -69,6 +73,7 @@ public class WorldManager implements MVWorldManager {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean addWorld(String name, Environment env, String seedString, String generator) {
|
||||
plugin.log(Level.FINE, "Adding world with: " + name + ", " + env.toString() + ", " + seedString + ", " + generator);
|
||||
Long seed = null;
|
||||
@ -117,7 +122,7 @@ public class WorldManager implements MVWorldManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
MultiverseWorld mvworld = new MVWorld(world, this.configWorlds, this.plugin, seed, generator);
|
||||
MultiverseWorld mvworld = new MVWorld(world, this.configWorlds, this.plugin, this.plugin.getServer().getWorld(name).getSeed(), generator);
|
||||
this.worldPurger.purgeWorld(null, mvworld);
|
||||
this.worlds.put(name, mvworld);
|
||||
if (this.unloadedWorlds.contains(name)) {
|
||||
@ -140,6 +145,7 @@ public class WorldManager implements MVWorldManager {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ChunkGenerator getChunkGenerator(String generator, String generatorID, String worldName) {
|
||||
if (generator == null) {
|
||||
return null;
|
||||
@ -155,11 +161,9 @@ public class WorldManager implements MVWorldManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the world from the Multiverse list and from the config
|
||||
*
|
||||
* @param name The name of the world to remove
|
||||
* @return True if success, false if failure.
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean removeWorldFromConfig(String name) {
|
||||
if (!unloadWorld(name)) {
|
||||
return false;
|
||||
@ -183,6 +187,7 @@ public class WorldManager implements MVWorldManager {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean unloadWorld(String name) {
|
||||
if (this.worlds.containsKey(name)) {
|
||||
if (this.unloadWorldFromBukkit(name, true)) {
|
||||
@ -206,6 +211,7 @@ public class WorldManager implements MVWorldManager {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean loadWorld(String name) {
|
||||
// Check if the World is already loaded
|
||||
if (this.worlds.containsKey(name)) {
|
||||
@ -239,15 +245,22 @@ public class WorldManager implements MVWorldManager {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Boolean deleteWorld(String name) {
|
||||
@Override
|
||||
public Boolean deleteWorld(String name, boolean removeFromConfig) {
|
||||
World world = this.plugin.getServer().getWorld(name);
|
||||
if (world == null) {
|
||||
// We can only delete loaded worlds
|
||||
return false;
|
||||
}
|
||||
if (removeFromConfig) {
|
||||
if (!removeWorldFromConfig(name)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!this.unloadWorld(name)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
File worldFile = world.getWorldFolder();
|
||||
@ -266,11 +279,19 @@ public class WorldManager implements MVWorldManager {
|
||||
this.plugin.log(Level.SEVERE, "You can go politely explain your situation in #multiverse on esper.net");
|
||||
this.plugin.log(Level.SEVERE, "But from here, it looks like your folder is oddly named.");
|
||||
this.plugin.log(Level.SEVERE, "This world has been removed from Multiverse-Core so your best bet is to go delete the folder by hand. Sorry.");
|
||||
e.printStackTrace();
|
||||
this.plugin.log(Level.SEVERE, e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWorld(String name) {
|
||||
return this.deleteWorld(name, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload a world from Bukkit
|
||||
*
|
||||
@ -286,6 +307,7 @@ public class WorldManager implements MVWorldManager {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void removePlayersFromWorld(String name) {
|
||||
World w = this.plugin.getServer().getWorld(name);
|
||||
if (w != null) {
|
||||
@ -302,6 +324,7 @@ public class WorldManager implements MVWorldManager {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Collection<MultiverseWorld> getMVWorlds() {
|
||||
return this.worlds.values();
|
||||
}
|
||||
@ -374,13 +397,16 @@ public class WorldManager implements MVWorldManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void loadDefaultWorlds() {
|
||||
this.ensureConfigIsPrepared();
|
||||
List<World> worlds = this.plugin.getServer().getWorlds();
|
||||
Set<String> worldStrings = this.configWorlds.getConfigurationSection("worlds").getKeys(false);
|
||||
for (World w : worlds) {
|
||||
String name = w.getName();
|
||||
System.out.println(defaultGens);
|
||||
if (!worldStrings.contains(name)) {
|
||||
if (this.defaultGens.containsKey(name)) {
|
||||
this.addWorld(name, w.getEnvironment(), w.getSeed() + "", this.defaultGens.get(name));
|
||||
@ -406,6 +432,7 @@ public class WorldManager implements MVWorldManager {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void loadWorlds(boolean forceLoad) {
|
||||
// Basic Counter to count how many Worlds we are loading.
|
||||
int count = 0;
|
||||
@ -453,7 +480,12 @@ public class WorldManager implements MVWorldManager {
|
||||
}
|
||||
// Grab the initial values from the config file.
|
||||
String environment = this.configWorlds.getString("worlds." + worldKey + ".environment", "NORMAL"); // Grab the Environment as a String.
|
||||
String seedString = this.configWorlds.getString("worlds." + worldKey + ".seed", "");
|
||||
String seedString = this.configWorlds.getString("worlds." + worldKey + ".seed", null);
|
||||
if(seedString == null) {
|
||||
seedString = this.configWorlds.getLong("worlds." + worldKey + ".seed") + "";
|
||||
}
|
||||
|
||||
System.out.println("SEEEEEEEED: " + seedString);
|
||||
|
||||
String generatorString = this.configWorlds.getString("worlds." + worldKey + ".generator");
|
||||
if (environment.equalsIgnoreCase("skylands")) {
|
||||
@ -474,6 +506,7 @@ public class WorldManager implements MVWorldManager {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public PurgeWorlds getWorldPurger() {
|
||||
return this.worldPurger;
|
||||
}
|
||||
@ -484,11 +517,16 @@ public class WorldManager implements MVWorldManager {
|
||||
* @param file The file to load.
|
||||
* @return A loaded configuration.
|
||||
*/
|
||||
@Override
|
||||
public FileConfiguration loadWorldConfig(File file) {
|
||||
this.configWorlds = YamlConfiguration.loadConfiguration(file);
|
||||
return this.configWorlds;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean saveWorldsConfig() {
|
||||
try {
|
||||
this.configWorlds.save(new File(this.plugin.getDataFolder(), "worlds.yml"));
|
||||
@ -499,12 +537,23 @@ public class WorldManager implements MVWorldManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public MultiverseWorld getSpawnWorld() {
|
||||
return this.getMVWorld(this.plugin.getServer().getWorlds().get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<String> getUnloadedWorlds() {
|
||||
return this.unloadedWorlds;
|
||||
}
|
||||
|
||||
public FileConfiguration getConfigWorlds() {
|
||||
return this.configWorlds;
|
||||
}
|
||||
}
|
||||
|
@ -197,4 +197,8 @@ commands:
|
||||
mvload:
|
||||
description: Loads a world into Multiverse.
|
||||
usage: |
|
||||
/<command>
|
||||
/<command> {WORLD}
|
||||
mvregen:
|
||||
description: Regenerates a world Multiverse already knows about.
|
||||
usage: |
|
||||
/<command> {WORLD}
|
||||
|
Loading…
Reference in New Issue
Block a user