diff options
author | Benji Dial <benji@benjidial.net> | 2023-12-30 14:24:46 -0500 |
---|---|---|
committer | Benji Dial <benji@benjidial.net> | 2023-12-30 14:24:46 -0500 |
commit | e06ee55259b3549a59358a13c095a274bacf6a05 (patch) | |
tree | a6e8b1b33434ee2c7de7028d4abad77b7fbe8296 /src/main/java/net/benjidial/nswp/commands/WaypointCommand.java | |
parent | ef65431d405a713b138a55054e78497883f27e54 (diff) | |
download | new-simple-waypoints-e06ee55259b3549a59358a13c095a274bacf6a05.tar.gz |
testing new version
Diffstat (limited to 'src/main/java/net/benjidial/nswp/commands/WaypointCommand.java')
-rw-r--r-- | src/main/java/net/benjidial/nswp/commands/WaypointCommand.java | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/src/main/java/net/benjidial/nswp/commands/WaypointCommand.java b/src/main/java/net/benjidial/nswp/commands/WaypointCommand.java deleted file mode 100644 index 618ab74..0000000 --- a/src/main/java/net/benjidial/nswp/commands/WaypointCommand.java +++ /dev/null @@ -1,71 +0,0 @@ -package net.benjidial.nswp.commands; - -import net.benjidial.nswp.Database; -import net.benjidial.nswp.Waypoint; -import net.benjidial.nswp.Plugin; - -import org.bukkit.command.CommandSender; -import org.bukkit.command.TabExecutor; -import org.bukkit.command.Command; -import org.bukkit.entity.Player; - -import java.util.logging.Level; -import java.sql.SQLException; -import java.util.ArrayList; - -public abstract class WaypointCommand implements TabExecutor { - enum CompletionType { - None, Waypoint - } - - public abstract CompletionType getCompletionType(); - - public ArrayList<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { - if (!(sender instanceof Player)) { - sender.sendMessage("Only players may use waypoints."); - return new ArrayList<>(); - } - Player player = (Player)sender; - - switch (getCompletionType()) { - case Waypoint: - if (args.length > 1) - return new ArrayList<>(); - try { - Database.createWaypointTable(player); - ArrayList<String> results = new ArrayList<>(); - for (Waypoint waypoint : Database.searchWaypoints(player, args.length == 0 ? "" : args[0])) - results.add(waypoint.name); - return results; - } - catch (SQLException ex) { - Plugin.logger.log(Level.SEVERE, "Database error:"); - ex.printStackTrace(); - sender.sendMessage("Database error."); - return new ArrayList<>(); - } - default: - return new ArrayList<>(); - } - } - - public abstract boolean body(Player player, String[] args) throws SQLException; - - public boolean onCommand(CommandSender sender, Command command, String name, String[] args) { - if (!(sender instanceof Player)) { - sender.sendMessage("Only players may use waypoints."); - return true; - } - try { - Player player = (Player)sender; - Database.createWaypointTable(player); - return body(player, args); - } - catch (SQLException ex) { - Plugin.logger.log(Level.SEVERE, "Database error:"); - ex.printStackTrace(); - sender.sendMessage("Database error."); - return true; - } - } -} |