2019-07-08 17:55:14 +00:00
|
|
|
/*
|
2022-01-01 19:03:05 +00:00
|
|
|
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
|
2019-07-08 17:55:14 +00:00
|
|
|
*
|
2019-07-11 21:30:35 +00:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2019-07-08 17:55:14 +00:00
|
|
|
*
|
2019-07-11 21:30:35 +00:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
2019-07-08 17:55:14 +00:00
|
|
|
*
|
|
|
|
* @author GeyserMC
|
|
|
|
* @link https://github.com/GeyserMC/Geyser
|
|
|
|
*/
|
|
|
|
|
2021-11-20 21:34:30 +00:00
|
|
|
package org.geysermc.geyser.command;
|
2019-07-08 17:55:14 +00:00
|
|
|
|
2019-12-21 17:35:48 +00:00
|
|
|
import lombok.Getter;
|
2020-03-17 16:43:09 +00:00
|
|
|
import lombok.RequiredArgsConstructor;
|
2019-12-21 17:35:48 +00:00
|
|
|
import lombok.Setter;
|
2021-11-22 19:52:26 +00:00
|
|
|
import org.geysermc.geyser.session.GeyserSession;
|
2019-07-08 17:55:14 +00:00
|
|
|
|
2021-01-17 03:18:13 +00:00
|
|
|
import javax.annotation.Nullable;
|
2019-12-21 17:35:48 +00:00
|
|
|
import java.util.ArrayList;
|
2020-10-27 22:40:00 +00:00
|
|
|
import java.util.Collections;
|
2019-07-08 17:55:14 +00:00
|
|
|
import java.util.List;
|
|
|
|
|
2019-12-21 17:35:48 +00:00
|
|
|
@Getter
|
2020-03-17 16:43:09 +00:00
|
|
|
@RequiredArgsConstructor
|
2019-12-21 17:35:48 +00:00
|
|
|
public abstract class GeyserCommand {
|
2019-07-08 17:55:14 +00:00
|
|
|
|
2020-03-17 16:43:09 +00:00
|
|
|
protected final String name;
|
2020-10-29 22:30:52 +00:00
|
|
|
/**
|
|
|
|
* The description of the command - will attempt to be translated.
|
|
|
|
*/
|
2020-03-17 16:43:09 +00:00
|
|
|
protected final String description;
|
|
|
|
protected final String permission;
|
2019-07-08 17:55:14 +00:00
|
|
|
|
2020-03-17 16:43:09 +00:00
|
|
|
@Setter
|
2019-12-21 17:35:48 +00:00
|
|
|
private List<String> aliases = new ArrayList<>();
|
2019-07-08 17:55:14 +00:00
|
|
|
|
2021-11-22 19:52:26 +00:00
|
|
|
public abstract void execute(@Nullable GeyserSession session, CommandSender sender, String[] args);
|
2020-10-27 22:40:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If false, hides the command from being shown on the Geyser Standalone GUI.
|
|
|
|
*
|
|
|
|
* @return true if the command can be run on the server console
|
|
|
|
*/
|
|
|
|
public boolean isExecutableOnConsole() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used in the GUI to know what subcommands can be run
|
|
|
|
*
|
|
|
|
* @return a list of all possible subcommands, or empty if none.
|
|
|
|
*/
|
|
|
|
public List<String> getSubCommands() {
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shortcut to {@link #getSubCommands()}{@code .isEmpty()}.
|
|
|
|
*
|
|
|
|
* @return true if there are subcommand present for this command.
|
|
|
|
*/
|
|
|
|
public boolean hasSubCommands() {
|
|
|
|
return !getSubCommands().isEmpty();
|
|
|
|
}
|
2021-01-17 03:18:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to send a deny message to Java players if this command can only be used by Bedrock players.
|
|
|
|
*
|
|
|
|
* @return true if this command can only be used by Bedrock players.
|
|
|
|
*/
|
|
|
|
public boolean isBedrockOnly() {
|
|
|
|
return false;
|
|
|
|
}
|
2020-03-17 16:43:09 +00:00
|
|
|
}
|