ArgumentTarget and SwitchTarget

This commit is contained in:
dfsek
2021-03-08 23:56:06 -07:00
parent 52c56af02c
commit f773ca2322
22 changed files with 245 additions and 106 deletions
@@ -1,13 +1,13 @@
package com.dfsek.terra.commands;
import com.dfsek.terra.api.command.CommandTemplate;
import com.dfsek.terra.api.command.ExecutionState;
import com.dfsek.terra.api.command.annotation.Command;
import com.dfsek.terra.api.platform.CommandSender;
@Command()
public class ReloadCommand implements CommandTemplate {
@Override
public void execute(ExecutionState state) {
public void execute(CommandSender sender) {
}
}
@@ -1,9 +1,9 @@
package com.dfsek.terra.commands;
import com.dfsek.terra.api.command.CommandTemplate;
import com.dfsek.terra.api.command.ExecutionState;
import com.dfsek.terra.api.command.annotation.Command;
import com.dfsek.terra.api.command.annotation.Subcommand;
import com.dfsek.terra.api.platform.CommandSender;
import com.dfsek.terra.commands.structure.StructureExportCommand;
import com.dfsek.terra.commands.structure.StructureLoadCommand;
@@ -23,7 +23,7 @@ import com.dfsek.terra.commands.structure.StructureLoadCommand;
)
public class StructureCommand implements CommandTemplate {
@Override
public void execute(ExecutionState state) {
public void execute(CommandSender sender) {
}
}
@@ -1,12 +1,12 @@
package com.dfsek.terra.commands.profiler;
import com.dfsek.terra.api.command.CommandTemplate;
import com.dfsek.terra.api.command.ExecutionState;
import com.dfsek.terra.api.command.annotation.Command;
import com.dfsek.terra.api.command.annotation.Subcommand;
import com.dfsek.terra.api.command.annotation.type.DebugCommand;
import com.dfsek.terra.api.command.annotation.type.PlayerCommand;
import com.dfsek.terra.api.command.annotation.type.WorldCommand;
import com.dfsek.terra.api.platform.CommandSender;
@Command(
subcommands = {
@@ -22,7 +22,7 @@ import com.dfsek.terra.api.command.annotation.type.WorldCommand;
@DebugCommand
public class ProfileCommand implements CommandTemplate {
@Override
public void execute(ExecutionState state) {
public void execute(CommandSender sender) {
}
}
@@ -2,12 +2,12 @@ package com.dfsek.terra.commands.profiler;
import com.dfsek.terra.api.TerraPlugin;
import com.dfsek.terra.api.command.CommandTemplate;
import com.dfsek.terra.api.command.ExecutionState;
import com.dfsek.terra.api.command.annotation.Command;
import com.dfsek.terra.api.command.annotation.type.DebugCommand;
import com.dfsek.terra.api.command.annotation.type.PlayerCommand;
import com.dfsek.terra.api.command.annotation.type.WorldCommand;
import com.dfsek.terra.api.injection.annotations.Inject;
import com.dfsek.terra.api.platform.CommandSender;
import com.dfsek.terra.api.platform.entity.Player;
import com.dfsek.terra.world.TerraWorld;
@@ -20,9 +20,9 @@ public class ProfileQueryCommand implements CommandTemplate {
private TerraPlugin main;
@Override
public void execute(ExecutionState state) {
Player player = (Player) state.getSender();
public void execute(CommandSender sender) {
Player player = (Player) sender;
TerraWorld world = main.getWorld(player.getWorld());
state.getSender().sendMessage(world.getProfiler().getResultsFormatted());
player.sendMessage(world.getProfiler().getResultsFormatted());
}
}
@@ -2,12 +2,12 @@ package com.dfsek.terra.commands.profiler;
import com.dfsek.terra.api.TerraPlugin;
import com.dfsek.terra.api.command.CommandTemplate;
import com.dfsek.terra.api.command.ExecutionState;
import com.dfsek.terra.api.command.annotation.Command;
import com.dfsek.terra.api.command.annotation.type.DebugCommand;
import com.dfsek.terra.api.command.annotation.type.PlayerCommand;
import com.dfsek.terra.api.command.annotation.type.WorldCommand;
import com.dfsek.terra.api.injection.annotations.Inject;
import com.dfsek.terra.api.platform.CommandSender;
import com.dfsek.terra.api.platform.entity.Player;
import com.dfsek.terra.world.TerraWorld;
@@ -20,10 +20,10 @@ public class ProfileResetCommand implements CommandTemplate {
private TerraPlugin main;
@Override
public void execute(ExecutionState state) {
Player player = (Player) state.getSender();
public void execute(CommandSender sender) {
Player player = (Player) sender;
TerraWorld world = main.getWorld(player.getWorld());
world.getProfiler().reset();
state.getSender().sendMessage("Profiler reset.");
player.sendMessage("Profiler reset.");
}
}
@@ -2,12 +2,12 @@ package com.dfsek.terra.commands.profiler;
import com.dfsek.terra.api.TerraPlugin;
import com.dfsek.terra.api.command.CommandTemplate;
import com.dfsek.terra.api.command.ExecutionState;
import com.dfsek.terra.api.command.annotation.Command;
import com.dfsek.terra.api.command.annotation.type.DebugCommand;
import com.dfsek.terra.api.command.annotation.type.PlayerCommand;
import com.dfsek.terra.api.command.annotation.type.WorldCommand;
import com.dfsek.terra.api.injection.annotations.Inject;
import com.dfsek.terra.api.platform.CommandSender;
import com.dfsek.terra.api.platform.entity.Player;
import com.dfsek.terra.world.TerraWorld;
@@ -20,10 +20,10 @@ public class ProfileStartCommand implements CommandTemplate {
private TerraPlugin main;
@Override
public void execute(ExecutionState state) {
Player player = (Player) state.getSender();
public void execute(CommandSender sender) {
Player player = (Player) sender;
TerraWorld world = main.getWorld(player.getWorld());
world.getProfiler().setProfiling(true);
state.getSender().sendMessage("Profiling enabled.");
player.sendMessage("Profiling enabled.");
}
}
@@ -2,12 +2,12 @@ package com.dfsek.terra.commands.profiler;
import com.dfsek.terra.api.TerraPlugin;
import com.dfsek.terra.api.command.CommandTemplate;
import com.dfsek.terra.api.command.ExecutionState;
import com.dfsek.terra.api.command.annotation.Command;
import com.dfsek.terra.api.command.annotation.type.DebugCommand;
import com.dfsek.terra.api.command.annotation.type.PlayerCommand;
import com.dfsek.terra.api.command.annotation.type.WorldCommand;
import com.dfsek.terra.api.injection.annotations.Inject;
import com.dfsek.terra.api.platform.CommandSender;
import com.dfsek.terra.api.platform.entity.Player;
import com.dfsek.terra.world.TerraWorld;
@@ -20,10 +20,10 @@ public class ProfileStopCommand implements CommandTemplate {
private TerraPlugin main;
@Override
public void execute(ExecutionState state) {
Player player = (Player) state.getSender();
public void execute(CommandSender sender) {
Player player = (Player) sender;
TerraWorld world = main.getWorld(player.getWorld());
world.getProfiler().setProfiling(false);
state.getSender().sendMessage("Profiling disabled.");
player.sendMessage("Profiling disabled.");
}
}
@@ -1,13 +1,13 @@
package com.dfsek.terra.commands.structure;
import com.dfsek.terra.api.command.CommandTemplate;
import com.dfsek.terra.api.command.ExecutionState;
import com.dfsek.terra.api.command.annotation.Command;
import com.dfsek.terra.api.platform.CommandSender;
@Command
public class StructureExportCommand implements CommandTemplate {
@Override
public void execute(ExecutionState state) {
public void execute(CommandSender sender) {
System.out.println("export command");
}
}
@@ -1,18 +1,20 @@
package com.dfsek.terra.commands.structure;
import com.dfsek.terra.api.command.CommandTemplate;
import com.dfsek.terra.api.command.ExecutionState;
import com.dfsek.terra.api.command.annotation.Argument;
import com.dfsek.terra.api.command.annotation.Command;
import com.dfsek.terra.api.command.annotation.Switch;
import com.dfsek.terra.api.command.annotation.inject.ArgumentTarget;
import com.dfsek.terra.api.command.arg.IntegerArgumentParser;
import com.dfsek.terra.api.platform.CommandSender;
@Command(
arguments = {
@Argument(
value = "rotation",
required = false,
type = int.class,
tabCompleter = RotationCompleter.class
tabCompleter = RotationCompleter.class,
argumentParser = IntegerArgumentParser.class
)
},
switches = {
@@ -22,8 +24,11 @@ import com.dfsek.terra.api.command.annotation.Switch;
}
)
public class StructureLoadCommand implements CommandTemplate {
@Override
public void execute(ExecutionState state) {
@ArgumentTarget("rotation")
private Integer rotation;
@Override
public void execute(CommandSender sender) {
System.out.println(rotation);
}
}