Actually start actions

This commit is contained in:
skippyall
2024-09-18 21:21:18 +02:00
parent d6a324a93f
commit 6526f92a67
8 changed files with 55 additions and 20 deletions
@@ -1,15 +1,10 @@
package io.github.skippyall.minions.command;
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
import net.minecraft.item.Item;
import net.minecraft.network.packet.LoginPackets;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
public interface Command {
public interface Command extends CommandExecutor {
Text getName();
Text getDescription();
Item getItemRepresentation();
void onRun(ServerPlayerEntity player, MinionFakePlayer minion);
}
@@ -0,0 +1,8 @@
package io.github.skippyall.minions.command;
import io.github.skippyall.minions.fakeplayer.MinionFakePlayer;
import net.minecraft.server.network.ServerPlayerEntity;
public interface CommandExecutor {
void execute(ServerPlayerEntity player, MinionFakePlayer minion);
}
@@ -5,20 +5,17 @@ import net.minecraft.item.Item;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
public class SimpleCommand implements Command {
private final Text name;
private final Text description;
private final Item itemRepresentation;
private final BiConsumer<ServerPlayerEntity, MinionFakePlayer> onRun;
private final CommandExecutor executor;
public SimpleCommand(Text name, Text description, Item itemRepresentation, BiConsumer<ServerPlayerEntity, MinionFakePlayer> onRun) {
public SimpleCommand(Text name, Text description, Item itemRepresentation, CommandExecutor executor) {
this.name = name;
this.description = description;
this.itemRepresentation = itemRepresentation;
this.onRun = onRun;
this.executor = executor;
}
@Override
@@ -37,7 +34,7 @@ public class SimpleCommand implements Command {
}
@Override
public void onRun(ServerPlayerEntity player, MinionFakePlayer minion) {
onRun.accept(player, minion);
public void execute(ServerPlayerEntity player, MinionFakePlayer minion) {
executor.execute(player, minion);
}
}