Amazing progress!!

This commit is contained in:
benwoo1110 2020-12-15 21:19:02 +08:00
parent 9cda6556c9
commit df3c9574aa
14 changed files with 508 additions and 154 deletions

View File

@ -32,14 +32,16 @@ import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
import com.onarandombox.MultiverseCore.api.MultiverseMessaging;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.commands_acf.CommandTools;
import com.onarandombox.MultiverseCore.commands_acf.CoordCommand;
import com.onarandombox.MultiverseCore.commands_acf.CreateCommand;
import com.onarandombox.MultiverseCore.commands_helper.CommandTools;
import com.onarandombox.MultiverseCore.commands_acf.ConfigCommand;
import com.onarandombox.MultiverseCore.commands_acf.ConfirmCommand;
import com.onarandombox.MultiverseCore.commands_acf.DebugCommand;
import com.onarandombox.MultiverseCore.commands_acf.DeleteCommand;
import com.onarandombox.MultiverseCore.commands_acf.InfoCommand;
import com.onarandombox.MultiverseCore.commands_acf.LoadCommand;
import com.onarandombox.MultiverseCore.commands_acf.CommandQueueManager;
import com.onarandombox.MultiverseCore.commands_helper.CommandQueueManager;
import com.onarandombox.MultiverseCore.commands_acf.UnloadCommand;
import com.onarandombox.MultiverseCore.destination.AnchorDestination;
import com.onarandombox.MultiverseCore.destination.BedDestination;
@ -720,13 +722,15 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
tools.registerCommandContexts();
tools.registerCommandCompletions();
commandHandler.registerCommand(new UnloadCommand(this));
commandHandler.registerCommand(new LoadCommand(this));
commandHandler.registerCommand(new ConfigCommand(this));
commandHandler.registerCommand(new InfoCommand(this));
commandHandler.registerCommand(new DebugCommand(this));
commandHandler.registerCommand(new DeleteCommand(this));
commandHandler.registerCommand(new ConfirmCommand(this));
this.commandHandler.registerCommand(new UnloadCommand(this));
this.commandHandler.registerCommand(new LoadCommand(this));
this.commandHandler.registerCommand(new ConfigCommand(this));
this.commandHandler.registerCommand(new InfoCommand(this));
this.commandHandler.registerCommand(new DebugCommand(this));
this.commandHandler.registerCommand(new DeleteCommand(this));
this.commandHandler.registerCommand(new ConfirmCommand(this));
this.commandHandler.registerCommand(new CoordCommand(this));
this.commandHandler.registerCommand(new CreateCommand(this));
}
/**

View File

@ -1,123 +0,0 @@
package com.onarandombox.MultiverseCore.commands_acf;
import co.aikar.commands.InvalidCommandArgument;
import co.aikar.commands.PaperCommandManager;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.UUID;
import java.util.stream.Collectors;
public class CommandTools {
private final MultiverseCore plugin;
private final PaperCommandManager commandHandler;
private final MVWorldManager worldManager;
private static final String UUID_REGEX = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[34][0-9a-fA-F]{3}-[89ab][0-9a-fA-F]{3}-[0-9a-fA-F]{12}"
;
public CommandTools(MultiverseCore plugin) {
this.plugin = plugin;
this.commandHandler = this.plugin.getCommandHandler();
this.worldManager = this.plugin.getMVWorldManager();
}
public void registerCommandCompletions() {
commandHandler.getCommandCompletions().registerAsyncCompletion(
"mvworlds",
context -> worldManager.getMVWorlds()
.stream()
.map(MultiverseWorld::getName)
.collect(Collectors.toList())
);
commandHandler.getCommandCompletions().registerAsyncCompletion(
"unloadedmvworlds",
context -> new ArrayList<>(this.worldManager.getUnloadedWorlds())
);
commandHandler.getCommandCompletions().registerAsyncCompletion(
"mvconfig",
context -> this.plugin.getMVConfig().serialize().keySet()
);
//TODO: set properties
//TODO: add properties
//TODO: remove properties
//TODO: destination
//TODO: version
//TODO: environment
//TODO: world types
}
public void registerCommandContexts() {
commandHandler.getCommandContexts().registerIssuerAwareContext(
MultiverseWorld.class,
context -> {
String worldName = context.popFirstArg();
if (worldName != null) {
MultiverseWorld targetWorld = this.worldManager.getMVWorld(worldName);
if (targetWorld == null) {
throw new InvalidCommandArgument("World '" + worldName + "' not found.");
}
return targetWorld;
}
return GetPlayerMVWorld(context.getPlayer());
}
);
commandHandler.getCommandContexts().registerContext(
Player.class,
context -> {
String playerIdentifier = context.popFirstArg();
Player targetPlayer = Bukkit.getPlayerExact(playerIdentifier);
if (targetPlayer == null) {
return tryGetPlayerByUUID(playerIdentifier);
}
return targetPlayer;
}
);
//TODO: Destination
}
private Player tryGetPlayerByUUID(String playerIdentifier) {
if (!playerIdentifier.matches(UUID_REGEX)) {
return null;
}
UUID playerUUID;
try {
playerUUID = UUID.fromString(playerIdentifier);
}
catch (Exception e) {
return null;
}
return Bukkit.getPlayer(playerUUID);
}
@NotNull
private MultiverseWorld GetPlayerMVWorld(Player player) {
if (player == null) {
throw new InvalidCommandArgument("You need to specific a world from console.");
}
MultiverseWorld targetWorld = this.worldManager.getMVWorld(player.getWorld());
if (targetWorld == null) {
throw new InvalidCommandArgument("Player is not in a multiverse world.");
}
return targetWorld;
}
}

View File

@ -0,0 +1,50 @@
package com.onarandombox.MultiverseCore.commands_acf;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Flags;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.text.DecimalFormat;
@CommandAlias("mv")
public class CoordCommand extends MultiverseCommand {
public CoordCommand(MultiverseCore plugin) {
super(plugin);
}
@Subcommand("coord")
@CommandPermission("multiverse.core.coord")
@Syntax("[player]")
@CommandCompletion("@players")
@Description("")
public void onCoordCommand(CommandSender sender, @Flags("deriveFromPlayer") Player targetPlayer) {
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(targetPlayer.getWorld());
if (world == null) {
this.plugin.showNotMVWorldMessage(sender, targetPlayer.getWorld().getName());
return;
}
DecimalFormat df = new DecimalFormat();
df.setMinimumFractionDigits(0);
df.setMaximumFractionDigits(2);
sender.sendMessage(ChatColor.AQUA + "--- Location Information ---");
sender.sendMessage(ChatColor.AQUA + "World: " + ChatColor.WHITE + world.getName());
sender.sendMessage(ChatColor.AQUA + "Alias: " + world.getColoredWorldString());
sender.sendMessage(ChatColor.AQUA + "World Scale: " + ChatColor.WHITE + world.getScaling());
sender.sendMessage(ChatColor.AQUA + "Coordinates: " + ChatColor.WHITE + plugin.getLocationManipulation().strCoords(targetPlayer.getLocation()));
sender.sendMessage(ChatColor.AQUA + "Direction: " + ChatColor.WHITE + plugin.getLocationManipulation().getDirection(targetPlayer.getLocation()));
sender.sendMessage(ChatColor.AQUA + "Block: " + ChatColor.WHITE + world.getCBWorld().getBlockAt(targetPlayer.getLocation()).getType());
}
}

View File

@ -0,0 +1,30 @@
package com.onarandombox.MultiverseCore.commands_acf;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.World;
import org.bukkit.WorldType;
import org.bukkit.command.CommandSender;
@CommandAlias("mv")
public class CreateCommand extends MultiverseCommand {
public CreateCommand(MultiverseCore plugin) {
super(plugin);
}
@Subcommand("create")
@CommandPermission("multiverse.core.info")
@Syntax("<name> <env> -s [seed] -g [generator[:id]] -t [worldtype] [-n] -a [true|false]")
@CommandCompletion("")
@Description("")
public void onCreateCommand(CommandSender sender, String worldName, World.Environment environment) {
sender.sendMessage("World name: " + worldName);
sender.sendMessage("World environment: " + environment.toString());
}
}

View File

@ -4,10 +4,12 @@ import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Flags;
import co.aikar.commands.annotation.Single;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
@ -23,17 +25,17 @@ public class DeleteCommand extends MultiverseCommand {
@Syntax("<world>")
@CommandCompletion("@mvworlds")
@Description("")
public void onDeleteCommand(CommandSender sender, @Single String worldName) {
this.plugin.getCommandQueueManager().addToQueue(sender, deleteRunnable(sender, worldName));
public void onDeleteCommand(CommandSender sender, MultiverseWorld world) {
this.plugin.getCommandQueueManager().addToQueue(sender, deleteRunnable(sender, world));
}
private Runnable deleteRunnable(CommandSender sender, String worldName) {
private Runnable deleteRunnable(CommandSender sender, MultiverseWorld world) {
return () -> {
//TODO: deleteWorld method should take world object directly
if (!this.plugin.getMVWorldManager().deleteWorld(worldName)) {
sender.sendMessage(ChatColor.RED + "World '" + worldName + "' could NOT be deleted!");
if (!this.plugin.getMVWorldManager().deleteWorld(world.getName())) {
sender.sendMessage(ChatColor.RED + "World '" + world.getName() + "' could NOT be deleted!");
}
sender.sendMessage(ChatColor.GREEN + "World '" + worldName + "' Deleted!");
sender.sendMessage(ChatColor.GREEN + "World '" + world.getName() + "' Deleted!");
};
}
}

View File

@ -11,6 +11,7 @@ import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.commands_helper.WorldAndPage;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -25,14 +26,11 @@ public class InfoCommand extends MultiverseCommand {
@Subcommand("info")
@CommandPermission("multiverse.core.info")
@Syntax("[world] [page]")
@CommandCompletion("@mvworlds")
@CommandCompletion("@mvworlds @range:1-3")
@Description("")
public void onInfoCommand(CommandSender sender, MultiverseWorld world, @Default("1") int page) {
ShowWorldInfo(sender, world, page);
}
private void ShowWorldInfo(CommandSender sender, MultiverseWorld world, int page) {
sender.sendMessage(world.toString());
sender.sendMessage("Page of " + page);
public void onInfoCommand(CommandSender sender, WorldAndPage worldAndPage) {
//TODO: The actual paged info
sender.sendMessage(worldAndPage.getWorld().toString());
sender.sendMessage("Page of " + worldAndPage.getPage());
}
}

View File

@ -7,6 +7,7 @@ import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Single;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import co.aikar.commands.annotation.Values;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -21,7 +22,7 @@ public class LoadCommand extends MultiverseCommand {
@Subcommand("load")
@CommandPermission("multiverse.core.load")
@Syntax("<world>")
@CommandCompletion("@unloadedmvworlds")
@CommandCompletion("@unloadedworlds")
@Description("Loads a world into Multiverse.")
public void onLoadCommand(CommandSender sender, @Single String world) {
if (!this.plugin.getMVWorldManager().loadWorld(world)) {

View File

@ -0,0 +1,46 @@
package com.onarandombox.MultiverseCore.commands_acf;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Subcommand;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.commands_helper.WorldAndPage;
import com.onarandombox.MultiverseCore.event.MVConfigReloadEvent;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import java.util.ArrayList;
import java.util.List;
@CommandAlias("mv")
public class ReloadCommand extends MultiverseCommand {
public ReloadCommand(MultiverseCore plugin) {
super(plugin);
}
@Subcommand("reload")
@CommandPermission("multiverse.core.reload")
@Description("Reloads config files for all multiverse modules.")
public void onReloadCommand(CommandSender sender) {
sender.sendMessage(ChatColor.GOLD + "Reloading all Multiverse Plugin configs...");
this.plugin.loadConfigs();
this.plugin.getAnchorManager().loadAnchors();
this.plugin.getMVWorldManager().loadWorlds(true);
List<String> configsLoaded = new ArrayList<String>();
configsLoaded.add("Multiverse-Core - config.yml");
configsLoaded.add("Multiverse-Core - worlds.yml");
configsLoaded.add("Multiverse-Core - anchors.yml");
MVConfigReloadEvent configReload = new MVConfigReloadEvent(configsLoaded);
this.plugin.getServer().getPluginManager().callEvent(configReload);
for (String s : configReload.getAllConfigsLoaded()) {
sender.sendMessage(s);
}
sender.sendMessage(ChatColor.GREEN + "Reload Complete!");
}
}

View File

@ -8,6 +8,7 @@ import co.aikar.commands.annotation.Single;
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -23,11 +24,12 @@ public class UnloadCommand extends MultiverseCommand {
@Syntax("<world>")
@CommandCompletion("@mvworlds")
@Description("Unloads a world from Multiverse. This does NOT remove the world folder. This does NOT remove it from the config file.")
public void onUnloadCommand(CommandSender sender, @Single String worldName) {
if (!this.plugin.getMVWorldManager().unloadWorld(worldName)) {
sender.sendMessage("Error trying to unload world '" + worldName + "'!");
public void onUnloadCommand(CommandSender sender, MultiverseWorld world) {
//TODO: Should be able to use MVWorld object directly
if (!this.plugin.getMVWorldManager().unloadWorld(world.getName())) {
sender.sendMessage("Error trying to unload world '" + world.getName() + "'!");
return;
}
Command.broadcastCommandMessage(sender, "Unloaded world '" + worldName + "'!");
Command.broadcastCommandMessage(sender, "Unloaded world '" + world.getName() + "'!");
}
}

View File

@ -1,7 +1,8 @@
package com.onarandombox.MultiverseCore.commands_acf;
package com.onarandombox.MultiverseCore.commands_helper;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.commands_helper.QueuedCommand;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitTask;
@ -69,7 +70,7 @@ public class CommandQueueManager {
public boolean runQueuedCommand(@NotNull CommandSender sender) {
QueuedCommand queuedCommand = this.queuedCommands.get(sender);
if (queuedCommand == null) {
Logging.fine("No queued command.");
sender.sendMessage("You do not have any commands in queue.");
return false;
}

View File

@ -0,0 +1,247 @@
package com.onarandombox.MultiverseCore.commands_helper;
import co.aikar.commands.BukkitCommandExecutionContext;
import co.aikar.commands.InvalidCommandArgument;
import co.aikar.commands.PaperCommandManager;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import sun.security.pkcs.PKCS9Attribute;
import java.util.UUID;
import java.util.stream.Collectors;
public class CommandTools {
private final MultiverseCore plugin;
private final PaperCommandManager commandHandler;
private final MVWorldManager worldManager;
private static final String UUID_REGEX = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[34][0-9a-fA-F]{3}-[89ab][0-9a-fA-F]{3}-[0-9a-fA-F]{12}";
public CommandTools(MultiverseCore plugin) {
this.plugin = plugin;
this.commandHandler = this.plugin.getCommandHandler();
this.worldManager = this.plugin.getMVWorldManager();
}
public void registerCommandCompletions() {
this.commandHandler.getCommandCompletions().registerAsyncCompletion(
"mvworlds",
context -> worldManager.getMVWorlds()
.stream()
.map(MultiverseWorld::getName)
.collect(Collectors.toList())
);
this.commandHandler.getCommandCompletions().registerAsyncCompletion(
"unloadedworlds",
context -> this.worldManager.getUnloadedWorlds()
);
this.commandHandler.getCommandCompletions().registerAsyncCompletion(
"mvconfig",
context -> this.plugin.getMVConfig().serialize().keySet()
);
//TODO: set properties
//TODO: add properties
//TODO: remove properties
//TODO: destination
//TODO: version
//TODO: environment
//TODO: world types
}
public void registerCommandContexts() {
this.commandHandler.getCommandContexts().registerIssuerAwareContext(
WorldAndPage.class,
this::deriveWorldAndPage
);
this.commandHandler.getCommandContexts().registerIssuerAwareContext(
MultiverseWorld.class,
this::deriveMultiverseWorld
);
this.commandHandler.getCommandContexts().registerIssuerAwareContext(
Player.class,
this::derivePlayer
);
this.commandHandler.getCommandContexts().registerContext(
World.Environment.class,
this::deriveEnvironment
);
//TODO: Destination
}
private WorldAndPage deriveWorldAndPage(@NotNull BukkitCommandExecutionContext context) {
String eitherWorldOrPage = context.popFirstArg();
Player player = context.getPlayer();
if (eitherWorldOrPage == null) {
return new WorldAndPage(
getPlayerWorld(context.getPlayer()),
1);
}
// Maybe its a world
MultiverseWorld targetWorld = getMultiverseWorld(eitherWorldOrPage, true);
if (targetWorld == null) {
if (player == null) {
throw new InvalidCommandArgument("World '" + eitherWorldOrPage + "' not found.");
}
// Safely assume its a page
return new WorldAndPage(
getPlayerWorld(context.getPlayer()),
parsePageNumber(eitherWorldOrPage, "World '" + eitherWorldOrPage + "' not found."));
}
String optionalPageValue = context.popFirstArg();
return new WorldAndPage(
targetWorld,
parsePageNumber(optionalPageValue, "'" + optionalPageValue + "' is not a valid page number."));
}
private Integer parsePageNumber(@Nullable String value, @NotNull String errorReason) {
if (value == null) {
return 1;
}
try {
return Integer.parseInt(value);
}
catch (NumberFormatException e) {
throw new InvalidCommandArgument(errorReason);
}
}
private MultiverseWorld deriveMultiverseWorld(@NotNull BukkitCommandExecutionContext context) {
String worldName = context.popFirstArg();
boolean worldFromPLayer = context.hasFlag("deriveFromPlayer");
boolean checkUnloaded = context.hasFlag("checkUnloaded");
if (worldName == null) {
if (worldFromPLayer) {
return getPlayerWorld(context.getPlayer());
}
throw new InvalidCommandArgument("Please specify a world name.");
}
MultiverseWorld world = getMultiverseWorld(worldName, checkUnloaded);
if (world == null) {
throw new InvalidCommandArgument("World '" + worldName + "' not found.");
}
return world;
}
private MultiverseWorld getMultiverseWorld(@Nullable String worldName, boolean checkUnloaded) {
if (worldName == null) {
return null;
}
MultiverseWorld targetWorld = this.worldManager.getMVWorld(worldName);
if (targetWorld != null) {
return targetWorld;
}
if (checkUnloaded && this.worldManager.getUnloadedWorlds().contains(worldName)) {
throw new InvalidCommandArgument("World " + worldName + " exists, but you need to load it first with: /mv load");
}
return null;
}
private MultiverseWorld getPlayerWorld(@Nullable Player player) {
if (player == null) {
throw new InvalidCommandArgument("You need to specific a world from console.");
}
MultiverseWorld targetWorld = this.worldManager.getMVWorld(player.getWorld());
if (targetWorld == null) {
//TODO: Overload that doesnt need world name.
this.plugin.showNotMVWorldMessage(player, player.getWorld().getName());
throw new InvalidCommandArgument("Invalid world!");
}
return targetWorld;
}
private Player derivePlayer(@NotNull BukkitCommandExecutionContext context) {
String playerIdentifier = context.popFirstArg();
boolean playerFromSelf = context.hasFlag("deriveFromPlayer");
Player targetPlayer = getPlayerFromValue(playerIdentifier);
if (targetPlayer != null) {
return targetPlayer;
}
if (!playerFromSelf) {
throw new InvalidCommandArgument("Player '" + playerIdentifier + "' not found.");
}
Player self = context.getPlayer();
if (self == null) {
throw new InvalidCommandArgument("You need to specific a player from console.");
}
return self;
}
private Player getPlayerFromValue(@Nullable String value) {
if (value == null) {
return null;
}
Player targetPlayer = Bukkit.getPlayerExact(value);
if (targetPlayer == null) {
return getPlayerByUUID(value);
}
return targetPlayer;
}
private Player getPlayerByUUID(@NotNull String playerIdentifier) {
if (!playerIdentifier.matches(UUID_REGEX)) {
return null;
}
UUID playerUUID;
try {
playerUUID = UUID.fromString(playerIdentifier);
}
catch (Exception e) {
return null;
}
return Bukkit.getPlayer(playerUUID);
}
private World.Environment deriveEnvironment(@NotNull BukkitCommandExecutionContext context) {
String env = context.popFirstArg();
if (env.equalsIgnoreCase("NORMAL") || env.equalsIgnoreCase("WORLD")) {
env = "NORMAL";
}
else if (env.equalsIgnoreCase("HELL") || env.equalsIgnoreCase("NETHER")) {
env = "NETHER";
}
else if (env.equalsIgnoreCase("END") || env.equalsIgnoreCase("THEEND") || env.equalsIgnoreCase("STARWARS")) {
env = "THE_END";
}
try {
return World.Environment.valueOf(env);
}
catch (IllegalArgumentException e) {
return null;
}
}
}

View File

@ -0,0 +1,75 @@
package com.onarandombox.MultiverseCore.commands_helper;
import co.aikar.commands.BukkitCommandExecutionContext;
import com.dumptruckman.minecraft.util.Logging;
import org.bukkit.WorldType;
import java.util.Map;
public class CreateWorldFlags {
private final String seed;
private final String generator;
private final WorldType worldType;
private final boolean spawnAdjust;
private final boolean generateStructures;
public CreateWorldFlags(String seed, String generator, WorldType worldType, boolean spawnAdjust, boolean generateStructures) {
this.seed = seed;
this.generator = generator;
this.worldType = worldType;
this.spawnAdjust = spawnAdjust;
this.generateStructures = generateStructures;
}
// public static CreateWorldFlags Parse(Map<String, String> flags) {
// return new CreateWorldFlags(
//
// )
// }
private WorldType getWorldType(String type) {
if (type == null) {
return WorldType.NORMAL;
}
if (type.equalsIgnoreCase("normal")) {
type = "NORMAL";
}
else if (type.equalsIgnoreCase("flat")) {
type = "FLAT";
}
else if (type.equalsIgnoreCase("largebiomes")) {
type = "LARGE_BIOMES";
}
else if (type.equalsIgnoreCase("amplified")) {
type = "AMPLIFIED";
}
try {
return WorldType.valueOf(type);
}
catch (IllegalArgumentException e) {
return null;
}
}
public String getSeed() {
return seed;
}
public String getGenerator() {
return generator;
}
public WorldType getWorldType() {
return worldType;
}
public boolean isSpawnAdjust() {
return spawnAdjust;
}
public boolean isGenerateStructures() {
return generateStructures;
}
}

View File

@ -1,4 +1,4 @@
package com.onarandombox.MultiverseCore.commands_acf;
package com.onarandombox.MultiverseCore.commands_helper;
import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitTask;

View File

@ -0,0 +1,21 @@
package com.onarandombox.MultiverseCore.commands_helper;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
public class WorldAndPage {
private final MultiverseWorld world;
private final int page;
public WorldAndPage(MultiverseWorld world, int page) {
this.world = world;
this.page = page;
}
public MultiverseWorld getWorld() {
return world;
}
public int getPage() {
return page;
}
}