Added a position command

This commit is contained in:
kuroppoi 2021-05-30 23:03:21 +02:00
parent c0bdf7c166
commit b11984cb03
2 changed files with 43 additions and 0 deletions

View file

@ -18,6 +18,7 @@ import brainwine.gameserver.command.commands.GiveCommand;
import brainwine.gameserver.command.commands.HelpCommand;
import brainwine.gameserver.command.commands.KickCommand;
import brainwine.gameserver.command.commands.PlayerIdCommand;
import brainwine.gameserver.command.commands.PositionCommand;
import brainwine.gameserver.command.commands.RegisterCommand;
import brainwine.gameserver.command.commands.SayCommand;
import brainwine.gameserver.command.commands.SeedCommand;
@ -61,6 +62,7 @@ public class CommandManager {
registerCommand(new GiveCommand());
registerCommand(new GenerateZoneCommand());
registerCommand(new SeedCommand());
registerCommand(new PositionCommand());
}
public static void executeCommand(CommandExecutor executor, String commandLine) {

View file

@ -0,0 +1,41 @@
package brainwine.gameserver.command.commands;
import static brainwine.gameserver.entity.player.NotificationType.SYSTEM;
import brainwine.gameserver.command.Command;
import brainwine.gameserver.command.CommandExecutor;
import brainwine.gameserver.entity.player.Player;
public class PositionCommand extends Command {
@Override
public void execute(CommandExecutor executor, String[] args) {
Player player = (Player)executor;
player.notify(String.format("X: %s Y: %s", (int)player.getX(), (int)player.getY() + 1), SYSTEM);
}
@Override
public String getName() {
return "pos";
}
@Override
public String[] getAliases() {
return new String[] { "position", "feet", "coords", "location" };
}
@Override
public String getDescription() {
return "Displays the coordinates of the block you are standing on.";
}
@Override
public String getUsage(CommandExecutor executor) {
return "/pos";
}
@Override
public boolean canExecute(CommandExecutor executor) {
return executor instanceof Player && executor.isAdmin();
}
}