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
This commit is contained in:
@ -0,0 +1,26 @@
|
||||
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 the plugin's about command
|
||||
*/
|
||||
public class CommandAbout implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s,
|
||||
@NotNull String[] strings) {
|
||||
|
||||
commandSender.sendMessage(ChatColor.GOLD + "Stargate Plugin created by " + ChatColor.GREEN + "Drakia");
|
||||
String author = Stargate.languageLoader.getString("author");
|
||||
if (!author.isEmpty())
|
||||
commandSender.sendMessage(ChatColor.GOLD + "Language created by " + ChatColor.GREEN + author);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package net.knarcraft.stargate.command;
|
||||
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This command represents the plugin's reload command
|
||||
*/
|
||||
public class CommandReload implements CommandExecutor {
|
||||
|
||||
private Stargate plugin;
|
||||
|
||||
/**
|
||||
* Instantiates the reload command
|
||||
* @param plugin <p>A reference to the calling plugin object</p>
|
||||
*/
|
||||
public CommandReload(Stargate plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s,
|
||||
@NotNull String[] strings) {
|
||||
if (commandSender instanceof Player) {
|
||||
Player player = (Player) commandSender;
|
||||
if (!player.hasPermission("stargate.reload")) {
|
||||
Stargate.sendMessage(commandSender, "Permission Denied");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
plugin.reload(commandSender);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package net.knarcraft.stargate.command;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class StarGateTabCompleter implements TabCompleter {
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command,
|
||||
@NotNull String s, @NotNull String[] strings) {
|
||||
List<String> commands = new ArrayList<>();
|
||||
commands.add("about");
|
||||
commands.add("reload");
|
||||
return commands;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user