mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-10 17:56:03 +00:00
Implement new config exceptions, general config cleanup
This commit is contained in:
@@ -2,7 +2,7 @@ package com.dfsek.terra.command;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.command.type.Command;
|
||||
import com.dfsek.terra.config.ConfigUtil;
|
||||
import com.dfsek.terra.config.base.ConfigUtil;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.dfsek.terra.command.image.gui;
|
||||
|
||||
import com.dfsek.terra.command.type.WorldCommand;
|
||||
import com.dfsek.terra.config.ConfigUtil;
|
||||
import com.dfsek.terra.config.WorldConfig;
|
||||
import com.dfsek.terra.config.base.ConfigUtil;
|
||||
import com.dfsek.terra.config.base.WorldConfig;
|
||||
import com.dfsek.terra.image.ImageLoader;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.dfsek.terra.command.image.gui;
|
||||
|
||||
import com.dfsek.terra.command.type.WorldCommand;
|
||||
import com.dfsek.terra.config.ConfigUtil;
|
||||
import com.dfsek.terra.config.WorldConfig;
|
||||
import com.dfsek.terra.config.base.ConfigUtil;
|
||||
import com.dfsek.terra.config.base.WorldConfig;
|
||||
import com.dfsek.terra.image.ImageLoader;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
|
||||
@@ -6,11 +6,54 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a command or subcommand, can be nested via getSubCommands.
|
||||
*/
|
||||
public abstract class Command {
|
||||
/**
|
||||
* Gets the name of the command/subcommand
|
||||
* @return Name of command
|
||||
*/
|
||||
public abstract String getName();
|
||||
|
||||
/**
|
||||
* Gets a list of subcommands
|
||||
* @return List of subcommands
|
||||
*/
|
||||
public abstract List<Command> getSubCommands();
|
||||
|
||||
/**
|
||||
* Executes the given command, returning its success.
|
||||
* <br>
|
||||
* If false is returned, then the "usage" plugin.yml entry for this command
|
||||
* (if defined) will be sent to the player.
|
||||
*
|
||||
* @param sender Source of the command
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args Passed command arguments
|
||||
* @return true if a valid command, otherwise false
|
||||
*/
|
||||
public abstract boolean onCommand(@NotNull CommandSender sender, @NotNull org.bukkit.command.Command command, @NotNull String label, @NotNull String[] args);
|
||||
|
||||
/**
|
||||
* Gets the number of arguments
|
||||
* @return Number of arguments
|
||||
*/
|
||||
public abstract int arguments();
|
||||
|
||||
/**
|
||||
* Executes the given command, invoking subcommands if applicable and returning its success.
|
||||
* <br>
|
||||
* If false is returned, then the "usage" plugin.yml entry for this command
|
||||
* (if defined) will be sent to the player.
|
||||
*
|
||||
* @param sender Source of the command
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args Passed command arguments
|
||||
* @return true if a valid command, otherwise false
|
||||
*/
|
||||
public final boolean execute(@NotNull CommandSender sender, @NotNull org.bukkit.command.Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if(args.length > 0) {
|
||||
for(Command c : getSubCommands()) {
|
||||
|
||||
@@ -4,7 +4,22 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A command that may only be executed by a player. If executor is not a player, a message will be displayed and no action will be performed.
|
||||
*/
|
||||
public abstract class PlayerCommand extends Command {
|
||||
/**
|
||||
* Executes the given command, returning its success.
|
||||
* <br>
|
||||
* If false is returned, then the "usage" plugin.yml entry for this command
|
||||
* (if defined) will be sent to the player.
|
||||
*
|
||||
* @param sender Source of the command
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args Passed command arguments
|
||||
* @return true if a valid command, otherwise false
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, org.bukkit.command.@NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
@@ -14,5 +29,17 @@ public abstract class PlayerCommand extends Command {
|
||||
Player p = (Player) sender;
|
||||
return onCommand(p, command, label, args);
|
||||
}
|
||||
/**
|
||||
* Executes the given command, returning its success.
|
||||
* <br>
|
||||
* If false is returned, then the "usage" plugin.yml entry for this command
|
||||
* (if defined) will be sent to the player.
|
||||
*
|
||||
* @param sender Player that executed command
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args Passed command arguments
|
||||
* @return true if a valid command, otherwise false
|
||||
*/
|
||||
public abstract boolean onCommand(@NotNull Player sender, org.bukkit.command.@NotNull Command command, @NotNull String label, @NotNull String[] args);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,22 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A command that must be executed by a player, in a Terra world.
|
||||
*/
|
||||
public abstract class WorldCommand extends PlayerCommand {
|
||||
/**
|
||||
* Executes the given command, returning its success.
|
||||
* <br>
|
||||
* If false is returned, then the "usage" plugin.yml entry for this command
|
||||
* (if defined) will be sent to the player.
|
||||
*
|
||||
* @param sender Source of the command
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args Passed command arguments
|
||||
* @return true if a valid command, otherwise false
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if(sender.getWorld().getGenerator() instanceof TerraChunkGenerator) {
|
||||
@@ -17,5 +32,18 @@ public abstract class WorldCommand extends PlayerCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the given command, returning its success.
|
||||
* <br>
|
||||
* If false is returned, then the "usage" plugin.yml entry for this command
|
||||
* (if defined) will be sent to the player.
|
||||
*
|
||||
* @param sender Player that executed command
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args Passed command arguments
|
||||
* @param world World in which command was executed
|
||||
* @return true if a valid command, otherwise false
|
||||
*/
|
||||
public abstract boolean onCommand(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user