mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-01-07 16:57:50 +01:00
Add environment and regen commands.
This commit is contained in:
parent
3809f47a54
commit
e4f043216e
@ -25,7 +25,7 @@ public class DeleteCommand extends MultiverseCommand {
|
||||
@CommandPermission("multiverse.core.delete")
|
||||
@Syntax("<world>")
|
||||
@CommandCompletion("@MVWorlds|@unloadedWorlds")
|
||||
@Description("")
|
||||
@Description("Deletes a world on your server PERMANENTLY.")
|
||||
public void onDeleteCommand(@NotNull CommandSender sender,
|
||||
@NotNull @Single @Flags("trim") @Conditions("isWorldInConfig|validWorldFolder") String worldName) {
|
||||
|
||||
@ -37,11 +37,9 @@ public class DeleteCommand extends MultiverseCommand {
|
||||
|
||||
return () -> {
|
||||
//TODO: deleteWorld method should take world object directly
|
||||
String resultMessage = (this.plugin.getMVWorldManager().deleteWorld(worldName))
|
||||
sender.sendMessage((this.plugin.getMVWorldManager().deleteWorld(worldName))
|
||||
? ChatColor.GREEN + "World '" + worldName + "' is deleted!"
|
||||
: ChatColor.RED + "World '" + worldName + "' could not be deleted!";
|
||||
|
||||
sender.sendMessage(resultMessage);
|
||||
: ChatColor.RED + "World '" + worldName + "' could not be deleted!");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
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 org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class EnvironmentCommand extends MultiverseCommand {
|
||||
|
||||
public EnvironmentCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("env|environments")
|
||||
@CommandPermission("multiverse.core.list.environments")
|
||||
@Description("Lists valid known environments/world types.")
|
||||
public void onEnvironmentCommand(CommandSender sender) {
|
||||
showEnvironments(sender);
|
||||
showWorldTypes(sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows all valid known environments to a {@link CommandSender}.
|
||||
*
|
||||
* @param sender The {@link CommandSender}.
|
||||
*/
|
||||
private void showEnvironments(CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "Valid Environments are:");
|
||||
sender.sendMessage(ChatColor.GREEN + "NORMAL");
|
||||
sender.sendMessage(ChatColor.RED + "NETHER");
|
||||
sender.sendMessage(ChatColor.AQUA + "END");
|
||||
}
|
||||
/**
|
||||
* Shows all valid known world types to a {@link CommandSender}.
|
||||
*
|
||||
* @param sender The {@link CommandSender}.
|
||||
*/
|
||||
private void showWorldTypes(CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "Valid World Types are:");
|
||||
sender.sendMessage(String.format("%sNORMAL%s, %sFLAT, %sLARGEBIOMES %sor %sAMPLIFIED",
|
||||
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, ChatColor.RED, ChatColor.WHITE, ChatColor.GOLD));
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
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 com.onarandombox.MultiverseCore.commands_helper.WorldFlags;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@CommandAlias("mv")
|
||||
public class RegenCommand extends MultiverseCommand {
|
||||
|
||||
public RegenCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Subcommand("regen")
|
||||
@CommandPermission("multiverse.core.regen")
|
||||
@Syntax("<world>")
|
||||
@CommandCompletion("@MVWorlds")
|
||||
@Description("Regenerates a world on your server. The previous state will be lost PERMANENTLY.")
|
||||
public void onRegenCommand(@NotNull CommandSender sender,
|
||||
//TODO: Allow regen of unloaded worlds.
|
||||
@NotNull @Flags("other") MultiverseWorld world,
|
||||
@NotNull WorldFlags flags) {
|
||||
|
||||
this.plugin.getMVCommandManager().getQueueManager().addToQueue(sender, regenRunnable(sender, world, flags));
|
||||
}
|
||||
|
||||
private Runnable regenRunnable(@NotNull CommandSender sender,
|
||||
@NotNull MultiverseWorld world,
|
||||
@NotNull WorldFlags flags) {
|
||||
|
||||
return () -> {
|
||||
//TODO: regenWorld method should take world object directly
|
||||
//TODO: Shouldn't need randomSeed, just check if seed parameter is null.
|
||||
sender.sendMessage((this.plugin.getMVWorldManager().regenWorld(
|
||||
world.getName(),
|
||||
flags.hasFlag("-s"),
|
||||
flags.getSeed() == null,
|
||||
flags.getSeed())
|
||||
)
|
||||
? ChatColor.GREEN + "World Regenerated!"
|
||||
: ChatColor.RED + "World could NOT be regenerated!");
|
||||
};
|
||||
}
|
||||
}
|
@ -262,6 +262,7 @@ public class MVCommandContexts extends PaperCommandContexts {
|
||||
private WorldFlags deriveWorldFlags(@NotNull BukkitCommandExecutionContext context) {
|
||||
Map<String, String> flags = parseFlags(context.getArgs());
|
||||
return new WorldFlags(
|
||||
flags.keySet(),
|
||||
flags.get("-s"),
|
||||
validateGenerator(flags.get("-g")),
|
||||
getWorldType(flags.get("-t")),
|
||||
|
@ -18,12 +18,14 @@ import com.onarandombox.MultiverseCore.commands_acf.CoordCommand;
|
||||
import com.onarandombox.MultiverseCore.commands_acf.CreateCommand;
|
||||
import com.onarandombox.MultiverseCore.commands_acf.DebugCommand;
|
||||
import com.onarandombox.MultiverseCore.commands_acf.DeleteCommand;
|
||||
import com.onarandombox.MultiverseCore.commands_acf.EnvironmentCommand;
|
||||
import com.onarandombox.MultiverseCore.commands_acf.GameRuleCommand;
|
||||
import com.onarandombox.MultiverseCore.commands_acf.GeneratorCommand;
|
||||
import com.onarandombox.MultiverseCore.commands_acf.ImportCommand;
|
||||
import com.onarandombox.MultiverseCore.commands_acf.InfoCommand;
|
||||
import com.onarandombox.MultiverseCore.commands_acf.ListCommand;
|
||||
import com.onarandombox.MultiverseCore.commands_acf.LoadCommand;
|
||||
import com.onarandombox.MultiverseCore.commands_acf.RegenCommand;
|
||||
import com.onarandombox.MultiverseCore.commands_acf.ReloadCommand;
|
||||
import com.onarandombox.MultiverseCore.commands_acf.RemoveCommand;
|
||||
import com.onarandombox.MultiverseCore.commands_acf.ScriptCommand;
|
||||
@ -82,6 +84,8 @@ public class MVCommandManager extends PaperCommandManager {
|
||||
registerCommand(new ImportCommand(plugin));
|
||||
registerCommand(new CheckCommand(plugin));
|
||||
registerCommand(new GameRuleCommand(plugin));
|
||||
registerCommand(new EnvironmentCommand(plugin));
|
||||
registerCommand(new RegenCommand(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,14 +2,23 @@ package com.onarandombox.MultiverseCore.commands_helper;
|
||||
|
||||
import org.bukkit.WorldType;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class WorldFlags {
|
||||
private final Set<String> flagsUsed;
|
||||
private final String seed;
|
||||
private final String generator;
|
||||
private final WorldType worldType;
|
||||
private final boolean spawnAdjust;
|
||||
private final boolean generateStructures;
|
||||
|
||||
public WorldFlags(String seed, String generator, WorldType worldType, boolean spawnAdjust, boolean generateStructures) {
|
||||
public WorldFlags(Set<String> flagsUsed,
|
||||
String seed, String generator,
|
||||
WorldType worldType,
|
||||
boolean spawnAdjust,
|
||||
boolean generateStructures) {
|
||||
|
||||
this.flagsUsed = flagsUsed;
|
||||
this.seed = seed;
|
||||
this.generator = generator;
|
||||
this.worldType = worldType;
|
||||
@ -17,6 +26,10 @@ public class WorldFlags {
|
||||
this.generateStructures = generateStructures;
|
||||
}
|
||||
|
||||
public boolean hasFlag(String flag) {
|
||||
return flagsUsed.contains(flag);
|
||||
}
|
||||
|
||||
public String getSeed() {
|
||||
return seed;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user