EpicKnarvik97 5b7f5649b1 Makes a whole lot of changes
Adds some new tests
Improves plugin command handling by using one class for each command
Makes some changes to vehicle teleportation to support horses and pigs, but vehicle teleportation is still buggy and messy
Adds some more missing comments
Adds a wildcard permission and uses built-in permissions some places to avoid checking for three different permissions
2021-02-16 21:58:31 +01:00

44 lines
1.5 KiB
Java

package net.knarcraft.stargate.command;
import net.knarcraft.stargate.Stargate;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
/**
* This command represents any command which starts with stargate
*
* <p>This prefix command should only be used for commands which are certain to collide with others and which relate to
* the plugin itself, not commands for functions of the plugin.</p>
*/
public class CommandStarGate implements CommandExecutor {
private Stargate plugin;
/**
* Instantiates the stargate command
* @param plugin <p>A reference to the calling plugin object</p>
*/
public CommandStarGate(Stargate plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s,
@NotNull String[] strings) {
if (strings.length > 0) {
if (strings[0].equalsIgnoreCase("about")) {
return new CommandAbout().onCommand(commandSender, command, s, strings);
} else if (strings[0].equalsIgnoreCase("reload")) {
return new CommandReload(plugin).onCommand(commandSender, command, s, strings);
}
return false;
} else {
commandSender.sendMessage(ChatColor.GOLD + "Stargate version " + ChatColor.GREEN + Stargate.getPluginVersion());
return true;
}
}
}