basic bukkit implementation

This commit is contained in:
dfsek
2021-03-08 01:40:12 -07:00
parent 026a6066d3
commit b1256427a2
19 changed files with 356 additions and 54 deletions
@@ -0,0 +1,28 @@
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;
@Command(
subcommands = {
@Subcommand(value = "query", aliases = {"q"}, clazz = ProfileQueryCommand.class),
@Subcommand(value = "start", aliases = {"s"}, clazz = ProfileStartCommand.class),
@Subcommand(value = "stop", aliases = {"st"}, clazz = ProfileStopCommand.class),
@Subcommand(value = "reset", aliases = {"r"}, clazz = ProfileResetCommand.class)
},
usage = "Commands to enable/disable/query/reset the profiler."
)
@WorldCommand
@PlayerCommand
@DebugCommand
public class ProfileCommand implements CommandTemplate {
@Override
public void execute(ExecutionState state) {
}
}
@@ -0,0 +1,28 @@
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.entity.Player;
import com.dfsek.terra.world.TerraWorld;
@Command
@WorldCommand
@PlayerCommand
@DebugCommand
public class ProfileQueryCommand implements CommandTemplate {
@Inject
private TerraPlugin main;
@Override
public void execute(ExecutionState state) {
Player player = (Player) state.getSender();
TerraWorld world = main.getWorld(player.getWorld());
state.getSender().sendMessage(world.getProfiler().getResultsFormatted());
}
}
@@ -0,0 +1,29 @@
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.entity.Player;
import com.dfsek.terra.world.TerraWorld;
@Command
@WorldCommand
@PlayerCommand
@DebugCommand
public class ProfileResetCommand implements CommandTemplate {
@Inject
private TerraPlugin main;
@Override
public void execute(ExecutionState state) {
Player player = (Player) state.getSender();
TerraWorld world = main.getWorld(player.getWorld());
world.getProfiler().reset();
state.getSender().sendMessage("Profiler reset.");
}
}
@@ -0,0 +1,29 @@
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.entity.Player;
import com.dfsek.terra.world.TerraWorld;
@Command
@WorldCommand
@PlayerCommand
@DebugCommand
public class ProfileStartCommand implements CommandTemplate {
@Inject
private TerraPlugin main;
@Override
public void execute(ExecutionState state) {
Player player = (Player) state.getSender();
TerraWorld world = main.getWorld(player.getWorld());
world.getProfiler().setProfiling(true);
state.getSender().sendMessage("Profiling enabled.");
}
}
@@ -0,0 +1,29 @@
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.entity.Player;
import com.dfsek.terra.world.TerraWorld;
@Command
@WorldCommand
@PlayerCommand
@DebugCommand
public class ProfileStopCommand implements CommandTemplate {
@Inject
private TerraPlugin main;
@Override
public void execute(ExecutionState state) {
Player player = (Player) state.getSender();
TerraWorld world = main.getWorld(player.getWorld());
world.getProfiler().setProfiling(false);
state.getSender().sendMessage("Profiling enabled.");
}
}