Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b483bdd96 | ||
|
|
d422c240cf |
No files matched your search
@@ -0,0 +1,49 @@
|
||||
package org.mvplugins.multiverse.core.commands;
|
||||
|
||||
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 jakarta.inject.Inject;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandIssuer;
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
|
||||
import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
|
||||
import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class DifficultyCommand extends MultiverseCommand {
|
||||
|
||||
@Inject
|
||||
DifficultyCommand(@NotNull MVCommandManager commandManager) {
|
||||
super(commandManager);
|
||||
}
|
||||
|
||||
@Subcommand("difficulty")
|
||||
@CommandPermission("multiverse.core.difficulty")
|
||||
@CommandCompletion("@difficulty @mvworlds:scope=both")
|
||||
@Syntax("<difficulty> [world]")
|
||||
void onDifficultyCommand(
|
||||
MVCommandIssuer issuer,
|
||||
|
||||
@Syntax("<difficulty>")
|
||||
@Description("")
|
||||
Difficulty difficulty,
|
||||
|
||||
@Flags("resolve=issuerAware")
|
||||
@Syntax("[world]")
|
||||
@Description("")
|
||||
// TODO: Change to MultiverseWorld
|
||||
LoadedMultiverseWorld world) {
|
||||
world.setDifficulty(difficulty)
|
||||
.onSuccess(w -> issuer.sendInfo("Difficulty set to " + difficulty + " for world " + world.getName()))
|
||||
.onFailure(failure -> issuer.sendError(failure.getMessage()));
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.google.common.collect.Sets;
|
||||
import io.vavr.control.Try;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.GameRule;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
@@ -50,6 +51,7 @@ public class MVCommandCompletions extends PaperCommandCompletions {
|
||||
|
||||
registerAsyncCompletion("commands", this::suggestCommands);
|
||||
registerAsyncCompletion("destinations", this::suggestDestinations);
|
||||
registerStaticCompletion("difficulty", this::suggestDifficulty);
|
||||
registerAsyncCompletion("flags", this::suggestFlags);
|
||||
registerStaticCompletion("gamerules", this::suggestGamerules);
|
||||
registerStaticCompletion("mvconfigs", config.getNodes().getNames());
|
||||
@@ -97,6 +99,10 @@ public class MVCommandCompletions extends PaperCommandCompletions {
|
||||
.suggestDestinations((BukkitCommandIssuer)context.getIssuer(), context.getInput());
|
||||
}
|
||||
|
||||
private Collection<String> suggestDifficulty() {
|
||||
return Arrays.stream(Difficulty.values()).map(Difficulty::name).toList();
|
||||
}
|
||||
|
||||
private Collection<String> suggestFlags(@NotNull BukkitCommandCompletionContext context) {
|
||||
String groupName = context.getConfig("groupName", "");
|
||||
|
||||
@@ -106,7 +112,7 @@ public class MVCommandCompletions extends PaperCommandCompletions {
|
||||
}
|
||||
|
||||
private Collection<String> suggestGamerules() {
|
||||
return Arrays.stream(GameRule.values()).map(GameRule::getName).collect(Collectors.toList());
|
||||
return Arrays.stream(GameRule.values()).map(GameRule::getName).toList();
|
||||
}
|
||||
|
||||
private Collection<String> suggestMVWorlds(BukkitCommandCompletionContext context) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.mvplugins.multiverse.core.commandtools;
|
||||
|
||||
import co.aikar.commands.MessageKeys;
|
||||
import co.aikar.commands.MessageType;
|
||||
import co.aikar.commands.OpenBukkitCommandIssuer;
|
||||
import co.aikar.locales.MessageKeyProvider;
|
||||
@@ -22,6 +23,23 @@ public class MVCommandIssuer extends OpenBukkitCommandIssuer {
|
||||
return commandManager;
|
||||
}
|
||||
|
||||
public void sendError(String message) {
|
||||
sendMessage(MessageType.ERROR, message);
|
||||
}
|
||||
|
||||
public void sendSyntax(String message) {
|
||||
sendMessage(MessageType.SYNTAX, message);
|
||||
}
|
||||
|
||||
public void sendInfo(String message) {
|
||||
sendMessage(MessageType.INFO, message);
|
||||
}
|
||||
|
||||
public void sendMessage(MessageType messageType, String message) {
|
||||
getManager().sendMessage(this, messageType, MessageKeys.INFO_MESSAGE,
|
||||
"{message}", message);
|
||||
}
|
||||
|
||||
public void sendError(Message message) {
|
||||
sendMessage(MessageType.ERROR, message);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user