.
This commit is contained in:
parent
a9b7f47494
commit
a088d27485
15 changed files with 65 additions and 74 deletions
|
|
@ -2,7 +2,7 @@ package site.lab0x13.scrow.configurator.action;
|
|||
|
||||
import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec;
|
||||
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
||||
import de.kentoj.scrowlib.convention.ScrowMessageStyle;
|
||||
import de.kentoj.kencommandapi.api.platform.MessageStyle;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -19,7 +19,7 @@ public interface ConfigOptionAction<T> {
|
|||
boolean requiresValue();
|
||||
|
||||
void execute(
|
||||
ScrowMessageStyle style,
|
||||
MessageStyle style,
|
||||
T node,
|
||||
CommandContext<Player> ctx
|
||||
);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.google.gson.GsonBuilder;
|
|||
import com.google.gson.JsonElement;
|
||||
import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec;
|
||||
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
||||
import de.kentoj.kencommandapi.api.platform.MessageStyle;
|
||||
import de.kentoj.scrowlib.convention.ScrowMessageStyle;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
|
|
@ -33,7 +34,7 @@ public final class GlobalShowAction<S extends ConfigNode<S>> implements ConfigOp
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(ScrowMessageStyle style, S node, CommandContext<Player> ctx) {
|
||||
public void execute(MessageStyle style, S node, CommandContext<Player> ctx) {
|
||||
var jsonElement = node.type().serialize(node.value());
|
||||
var prettyJson = GSON.toJson(jsonElement, JsonElement.class);
|
||||
var component = Component.text(prettyJson + " [click to copy]")
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
package site.lab0x13.scrow.configurator.type.location;
|
||||
package site.lab0x13.scrow.configurator.action;
|
||||
|
||||
import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec;
|
||||
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
||||
import de.kentoj.scrowlib.convention.ScrowMessageStyle;
|
||||
import de.kentoj.kencommandapi.api.platform.MessageStyle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import site.lab0x13.scrow.configurator.action.ConfigOptionAction;
|
||||
import site.lab0x13.scrow.configurator.node.ConfigNode;
|
||||
|
||||
import java.util.Collections;
|
||||
|
|
@ -29,7 +28,7 @@ public abstract class PickAction<S, T extends ConfigNode<S>> implements ConfigOp
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(ScrowMessageStyle style, T node, CommandContext<Player> ctx) {
|
||||
public void execute(MessageStyle style, T node, CommandContext<Player> ctx) {
|
||||
pick(ctx.sender())
|
||||
.orTimeout(10, TimeUnit.MINUTES)
|
||||
.whenComplete((picked, ex) -> {
|
||||
|
|
@ -1,13 +1,11 @@
|
|||
package site.lab0x13.scrow.configurator.command;
|
||||
|
||||
import com.leakyabstractions.result.core.Results;
|
||||
import de.kentoj.kencommandapi.api.literal.Literal;
|
||||
import de.kentoj.kencommandapi.api.literal.LiteralBuilder;
|
||||
import de.kentoj.scrowlib.convention.ScrowMessageStyle;
|
||||
import org.bukkit.entity.Player;
|
||||
import site.lab0x13.scrow.configurator.action.ConfigOptionAction;
|
||||
import site.lab0x13.scrow.configurator.node.ConfigNode;
|
||||
import site.lab0x13.scrow.configurator.node.ConfigValueNode;
|
||||
import site.lab0x13.scrow.configurator.noderegistry.ConfigNodeWalker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -40,13 +38,12 @@ class KeyLiteral {
|
|||
var actionLiteralBuilder = Literal.<Player>builder(action.name());
|
||||
for (var argument : action.arguments())
|
||||
actionLiteralBuilder.withArgument(argument);
|
||||
actionLiteralBuilder.withSyncExecutor(ctx -> {
|
||||
actionLiteralBuilder.withSyncExecutor((style, ctx) -> {
|
||||
if (action.requiresValue() && node.value() == null) {
|
||||
ctx.sender().sendMessage(style.err("No value set."));
|
||||
return Results.success(new Object());
|
||||
return;
|
||||
}
|
||||
action.execute(style, node, ctx);
|
||||
return Results.success(new Object());
|
||||
});
|
||||
builder.withLiteral(actionLiteralBuilder.build());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package site.lab0x13.scrow.configurator.type.location;
|
|||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import site.lab0x13.scrow.configurator.action.PickAction;
|
||||
import site.lab0x13.scrow.configurator.node.ConfigNode;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package site.lab0x13.scrow.configurator.type.location;
|
|||
|
||||
import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec;
|
||||
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
||||
import de.kentoj.kencommandapi.api.platform.MessageStyle;
|
||||
import de.kentoj.scrowlib.convention.ScrowMessageStyle;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
|
@ -29,7 +30,7 @@ class LocationTeleportAction implements ConfigOptionAction<ConfigValueNode<Locat
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(ScrowMessageStyle style, ConfigValueNode<Location> node, CommandContext<Player> ctx) {
|
||||
public void execute(MessageStyle style, ConfigValueNode<Location> node, CommandContext<Player> ctx) {
|
||||
ctx.sender().teleport(node.value());
|
||||
ctx.sender().sendMessage(style.ok("You've been teleported."));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.leakyabstractions.result.api.Result;
|
|||
import com.leakyabstractions.result.core.Results;
|
||||
import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec;
|
||||
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
||||
import de.kentoj.kencommandapi.api.platform.MessageStyle;
|
||||
import de.kentoj.kencommandapi.type.WorldArgumentType;
|
||||
import de.kentoj.scrowlib.convention.ScrowMessageStyle;
|
||||
import org.bukkit.Bukkit;
|
||||
|
|
@ -59,7 +60,7 @@ public class WorldConfigType implements ConfigType<World> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(ScrowMessageStyle style, ConfigValueNode<World> node, CommandContext<Player> ctx) {
|
||||
public void execute(MessageStyle style, ConfigValueNode<World> node, CommandContext<Player> ctx) {
|
||||
World world = ctx.getArg("world");
|
||||
node.value(world);
|
||||
ctx.sender().sendMessage(style.ok("Set world to " + world.getName() + "("+ world.getUID() + ")"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue