Merge pull request #2903 from Multiverse/improve-config-revamp
Improve config revamp
This commit is contained in:
commit
14472f5740
|
@ -14,6 +14,7 @@ import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
|||
import com.onarandombox.MultiverseCore.commandtools.context.MVConfigValue;
|
||||
import com.onarandombox.MultiverseCore.config.MVCoreConfig;
|
||||
import com.onarandombox.MultiverseCore.exceptions.MultiverseException;
|
||||
import io.vavr.control.Option;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
@ -66,14 +67,7 @@ public class ConfigCommand extends MultiverseCommand {
|
|||
config.save();
|
||||
issuer.sendMessage("Successfully set " + name + " to " + value);
|
||||
})
|
||||
.onFailure(e -> {
|
||||
issuer.sendMessage("Unable to set " + name + " to " + value + ".");
|
||||
if (e instanceof MultiverseException) {
|
||||
var message = ((MultiverseException) e).getMVMessage();
|
||||
if (message != null) {
|
||||
issuer.sendError(message);
|
||||
}
|
||||
}
|
||||
});
|
||||
.onFailure(ignore -> issuer.sendMessage("Unable to set " + name + " to " + value + "."))
|
||||
.onFailure(MultiverseException.class, e -> Option.of(e.getMVMessage()).peek(issuer::sendError));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.jvnet.hk2.annotations.Service;
|
|||
@Service
|
||||
public class MVCommandContexts extends PaperCommandContexts {
|
||||
|
||||
private final MVCommandManager mvCommandManager;
|
||||
private final DestinationsProvider destinationsProvider;
|
||||
private final MVWorldManager worldManager;
|
||||
private final MVCoreConfig config;
|
||||
|
@ -44,11 +45,13 @@ public class MVCommandContexts extends PaperCommandContexts {
|
|||
MVCoreConfig config
|
||||
) {
|
||||
super(mvCommandManager);
|
||||
this.mvCommandManager = mvCommandManager;
|
||||
this.destinationsProvider = destinationsProvider;
|
||||
this.worldManager = worldManager;
|
||||
this.config = config;
|
||||
|
||||
registerIssuerOnlyContext(BukkitCommandIssuer.class, BukkitCommandExecutionContext::getIssuer);
|
||||
registerIssuerOnlyContext(MVCommandIssuer.class, this::parseMVCommandIssuer);
|
||||
registerOptionalContext(ContentFilter.class, this::parseContentFilter);
|
||||
registerContext(ParsedDestination.class, this::parseDestination);
|
||||
registerContext(GameRule.class, this::parseGameRule);
|
||||
|
@ -60,6 +63,13 @@ public class MVCommandContexts extends PaperCommandContexts {
|
|||
registerIssuerAwareContext(Player[].class, this::parsePlayerArray);
|
||||
}
|
||||
|
||||
private MVCommandIssuer parseMVCommandIssuer(BukkitCommandExecutionContext context) {
|
||||
if (context.getIssuer() instanceof MVCommandIssuer) {
|
||||
return (MVCommandIssuer) context.getIssuer();
|
||||
}
|
||||
return mvCommandManager.getCommandIssuer(context.getSender());
|
||||
}
|
||||
|
||||
private ContentFilter parseContentFilter(BukkitCommandExecutionContext context) {
|
||||
if (Strings.isNullOrEmpty(context.getFirstArg())) {
|
||||
return DefaultContentFilter.get();
|
||||
|
|
Loading…
Reference in New Issue