mirror of https://github.com/Minestom/Minestom.git
Update demo command with the new SimpleCommand, update comment to reflect permission access change
This commit is contained in:
parent
1760c95ebe
commit
7309d05666
|
@ -31,9 +31,6 @@ public abstract class SimpleCommand extends Command {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to know if a player has access to the command.
|
* Called to know if a player has access to the command.
|
||||||
* <p>
|
|
||||||
* Right now it is only used to know if the player should see the command in auto-completion.
|
|
||||||
* Conditions still need to be checked in {@link #process(CommandSender, String, String[])}.
|
|
||||||
*
|
*
|
||||||
* @param sender the command sender to check the access
|
* @param sender the command sender to check the access
|
||||||
* @param commandString the raw command string,
|
* @param commandString the raw command string,
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class Main {
|
||||||
commandManager.register(new GamemodeCommand());
|
commandManager.register(new GamemodeCommand());
|
||||||
commandManager.register(new EntitySelectorCommand());
|
commandManager.register(new EntitySelectorCommand());
|
||||||
commandManager.register(new HealthCommand());
|
commandManager.register(new HealthCommand());
|
||||||
commandManager.register(new SimpleCommand());
|
commandManager.register(new LegacyCommand());
|
||||||
commandManager.register(new DimensionCommand());
|
commandManager.register(new DimensionCommand());
|
||||||
commandManager.register(new ShutdownCommand());
|
commandManager.register(new ShutdownCommand());
|
||||||
commandManager.register(new TeleportCommand());
|
commandManager.register(new TeleportCommand());
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package demo.commands;
|
||||||
|
|
||||||
|
import net.minestom.server.command.CommandSender;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public class LegacyCommand extends net.minestom.server.command.builder.SimpleCommand {
|
||||||
|
public LegacyCommand() {
|
||||||
|
super("test", "alias");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean process(@NotNull CommandSender sender, @NotNull String command, @NotNull String[] args) {
|
||||||
|
if (!sender.isPlayer())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
System.gc();
|
||||||
|
sender.sendMessage("Explicit GC");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasAccess(@NotNull CommandSender sender, @Nullable String commandString) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,46 +0,0 @@
|
||||||
package demo.commands;
|
|
||||||
|
|
||||||
import net.minestom.server.command.CommandProcessor;
|
|
||||||
import net.minestom.server.command.CommandSender;
|
|
||||||
import net.minestom.server.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class SimpleCommand implements CommandProcessor {
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public String getCommandName() {
|
|
||||||
return "test";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] getAliases() {
|
|
||||||
return new String[]{"alias"};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean process(@NotNull CommandSender sender, @NotNull String command, @NotNull String[] args) {
|
|
||||||
if (!sender.isPlayer())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
sender.asPlayer().getInstance().saveChunksToStorage(() -> System.out.println("END SAVE"));
|
|
||||||
|
|
||||||
System.gc();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasAccess(@NotNull Player player) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean enableWritingTracking() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] onWrite(@NotNull CommandSender sender, @NotNull String text) {
|
|
||||||
return new String[]{"Complete1", "Complete2"};
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue