From 1b8254d46a46e9d649f4dbb2688d693b6f5296ad Mon Sep 17 00:00:00 2001 From: William278 Date: Sun, 13 Dec 2020 02:17:58 +0000 Subject: [PATCH] Re-added many HuskHomes commands --- .../huskhomes2/Commands/backCommand.java | 28 +++ .../huskhomes2/Commands/delWarpCommand.java | 27 +++ .../huskhomes2/Commands/editHomeCommand.java | 111 +++++++++ .../huskhomes2/Commands/editWarpCommand.java | 96 ++++++++ .../huskhomes2/Commands/homeCommand.java | 4 +- .../huskhomes2/Commands/homeListCommand.java | 4 +- .../huskhomes2/Commands/huskHomesCommand.java | 100 +++++++++ .../Commands/publicHomeCommand.java | 45 ++++ .../Commands/publicHomeListCommand.java | 31 +++ .../huskhomes2/Commands/setWarpCommand.java | 27 +++ .../huskhomes2/Commands/tpAcceptCommand.java | 20 ++ .../huskhomes2/Commands/tpCommand.java | 81 +++++++ .../huskhomes2/Commands/tpDenyCommand.java | 20 ++ .../huskhomes2/Commands/tpHereCommand.java | 26 +++ .../huskhomes2/Commands/tpaCommand.java | 26 +++ .../huskhomes2/Commands/tpaHereCommand.java | 27 +++ .../huskhomes2/Commands/warpCommand.java | 35 +++ .../huskhomes2/Commands/warpListCommand.java | 31 +++ .../huskhomes2/Data/SQLite/Database.java | 28 +++ .../huskhomes2/Events/onPlayerDeath.java | 41 ++++ .../java/me/william278/huskhomes2/Main.java | 5 + .../huskhomes2/Objects/RandomPoint.java | 85 +++++++ .../huskhomes2/Objects/Settings.java | 13 ++ .../Objects/TeleportationPoint.java | 2 +- .../me/william278/huskhomes2/dataManager.java | 150 ++++++++++++- .../william278/huskhomes2/editingHandler.java | 94 ++++++++ ...{homeListHandler.java => listHandler.java} | 58 ++++- .../william278/huskhomes2/runEverySecond.java | 10 +- .../huskhomes2/teleportManager.java | 20 +- .../william278/huskhomes2/versionChecker.java | 53 +++++ src/main/resources/Languages/en-gb.yml | 15 +- src/main/resources/Languages/zh-tw.yml | 5 +- src/main/resources/config.yml | 3 + src/main/resources/plugin.yml | 211 +++++++++++++++++- 34 files changed, 1485 insertions(+), 47 deletions(-) create mode 100644 src/main/java/me/william278/huskhomes2/Commands/backCommand.java create mode 100644 src/main/java/me/william278/huskhomes2/Commands/delWarpCommand.java create mode 100644 src/main/java/me/william278/huskhomes2/Commands/editHomeCommand.java create mode 100644 src/main/java/me/william278/huskhomes2/Commands/editWarpCommand.java create mode 100644 src/main/java/me/william278/huskhomes2/Commands/huskHomesCommand.java create mode 100644 src/main/java/me/william278/huskhomes2/Commands/publicHomeCommand.java create mode 100644 src/main/java/me/william278/huskhomes2/Commands/publicHomeListCommand.java create mode 100644 src/main/java/me/william278/huskhomes2/Commands/setWarpCommand.java create mode 100644 src/main/java/me/william278/huskhomes2/Commands/tpAcceptCommand.java create mode 100644 src/main/java/me/william278/huskhomes2/Commands/tpCommand.java create mode 100644 src/main/java/me/william278/huskhomes2/Commands/tpDenyCommand.java create mode 100644 src/main/java/me/william278/huskhomes2/Commands/tpHereCommand.java create mode 100644 src/main/java/me/william278/huskhomes2/Commands/tpaCommand.java create mode 100644 src/main/java/me/william278/huskhomes2/Commands/tpaHereCommand.java create mode 100644 src/main/java/me/william278/huskhomes2/Commands/warpCommand.java create mode 100644 src/main/java/me/william278/huskhomes2/Commands/warpListCommand.java create mode 100644 src/main/java/me/william278/huskhomes2/Events/onPlayerDeath.java create mode 100644 src/main/java/me/william278/huskhomes2/Objects/RandomPoint.java create mode 100644 src/main/java/me/william278/huskhomes2/editingHandler.java rename src/main/java/me/william278/huskhomes2/{homeListHandler.java => listHandler.java} (71%) create mode 100644 src/main/java/me/william278/huskhomes2/versionChecker.java diff --git a/src/main/java/me/william278/huskhomes2/Commands/backCommand.java b/src/main/java/me/william278/huskhomes2/Commands/backCommand.java new file mode 100644 index 00000000..44d24dcc --- /dev/null +++ b/src/main/java/me/william278/huskhomes2/Commands/backCommand.java @@ -0,0 +1,28 @@ +package me.william278.huskhomes2.Commands; + +import me.william278.huskhomes2.Objects.TeleportationPoint; +import me.william278.huskhomes2.dataManager; +import me.william278.huskhomes2.messageManager; +import me.william278.huskhomes2.teleportManager; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class backCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (sender instanceof Player) { + Player p = (Player) sender; + TeleportationPoint lastPosition = dataManager.getPlayerLastPosition(p); + if (lastPosition != null) { + teleportManager.queueTimedTeleport(p, lastPosition); + } else { + messageManager.sendMessage(p, "error_no_last_position"); + } + return true; + } + return false; + } +} diff --git a/src/main/java/me/william278/huskhomes2/Commands/delWarpCommand.java b/src/main/java/me/william278/huskhomes2/Commands/delWarpCommand.java new file mode 100644 index 00000000..91c2b916 --- /dev/null +++ b/src/main/java/me/william278/huskhomes2/Commands/delWarpCommand.java @@ -0,0 +1,27 @@ +package me.william278.huskhomes2.Commands; + +import me.william278.huskhomes2.messageManager; +import me.william278.huskhomes2.settingHandler; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class delWarpCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (sender instanceof Player) { + Player p = (Player) sender; + if (args.length == 1) { + String warpName = args[0]; + settingHandler.deleteWarp(p, warpName); + } else { + messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage()); + } + return true; + } + return false; + } + +} diff --git a/src/main/java/me/william278/huskhomes2/Commands/editHomeCommand.java b/src/main/java/me/william278/huskhomes2/Commands/editHomeCommand.java new file mode 100644 index 00000000..5c4d38a8 --- /dev/null +++ b/src/main/java/me/william278/huskhomes2/Commands/editHomeCommand.java @@ -0,0 +1,111 @@ +package me.william278.huskhomes2.Commands; + +import me.william278.huskhomes2.Objects.Home; +import me.william278.huskhomes2.dataManager; +import me.william278.huskhomes2.editingHandler; +import me.william278.huskhomes2.messageManager; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class editHomeCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (sender instanceof Player) { + Player p = (Player) sender; + if (args.length >= 1) { + String homeName = args[0]; + if (dataManager.homeExists(p.getName(), homeName)) { + if (args.length >= 2) { + switch (args[1]) { + case "location": + dataManager.updateHomeLocation(p.getName(), homeName, p.getLocation()); + messageManager.sendMessage(p, "edit_home_update_location", homeName); + return true; + case "description": + if (args.length >= 3) { + // Get the new description + StringBuilder newDescription = new StringBuilder(); + for (int i = 2; i < args.length; i++) { + if (i > 2) { + newDescription.append(" ").append(args[i]); + } else { + newDescription = new StringBuilder(args[i]); + } + } + String newDescriptionString = newDescription.toString(); + + // Check the description is valid + if (!newDescriptionString.matches("[a-zA-Z0-9\\d\\-_\\s]+")) { + messageManager.sendMessage(p, "error_edit_home_invalid_description"); + return true; + } + + // Update description + dataManager.updateHomeDescription(p.getName(), homeName, newDescriptionString); + + // Confirmation message + messageManager.sendMessage(p, "edit_home_update_description", homeName, newDescriptionString); + } else { + messageManager.sendMessage(p, "error_invalid_syntax", "/edithome description "); + } + return true; + case "rename": + if (args.length >= 3) { + String newName = args[2]; + if (newName.length() > 16) { + messageManager.sendMessage(p, "error_set_home_invalid_length"); + return true; + } + if (!newName.matches("[A-Za-z0-9_\\-]+")) { + messageManager.sendMessage(p, "error_set_home_invalid_characters"); + return true; + } + if (dataManager.homeExists(p.getName(), newName)) { + messageManager.sendMessage(p, "error_set_home_name_taken"); + return true; + } + dataManager.updateHomeName(p.getName(), homeName, newName); + messageManager.sendMessage(p, "edit_home_update_name", homeName, newName); + } else { + messageManager.sendMessage(p, "error_invalid_syntax", "/edithome rename "); + } + return true; + case "public": + if (!dataManager.getHome(p.getName(), homeName).isPublic()) { + dataManager.updateHomePrivacy(p.getName(), homeName, true); + messageManager.sendMessage(p, "edit_home_privacy_public_success", homeName); + } else { + messageManager.sendMessage(p, "error_edit_home_privacy_already_public", homeName); + } + return true; + case "private": + if (dataManager.getHome(p.getName(), homeName).isPublic()) { + dataManager.updateHomePrivacy(p.getName(), homeName, false); + messageManager.sendMessage(p, "edit_home_privacy_private_success", homeName); + } else { + messageManager.sendMessage(p, "error_edit_home_privacy_already_private", homeName); + } + return true; + default: + messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage()); + return true; + } + } else { + Home home = dataManager.getHome(p.getName(), homeName); + editingHandler.showEditHomeOptions(p, home); + return true; + } + } else { + messageManager.sendMessage(p, "error_home_invalid", homeName); + } + } else { + messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage()); + } + return true; + } + return false; + } +} diff --git a/src/main/java/me/william278/huskhomes2/Commands/editWarpCommand.java b/src/main/java/me/william278/huskhomes2/Commands/editWarpCommand.java new file mode 100644 index 00000000..1b17d7c1 --- /dev/null +++ b/src/main/java/me/william278/huskhomes2/Commands/editWarpCommand.java @@ -0,0 +1,96 @@ +package me.william278.huskhomes2.Commands; + +import me.william278.huskhomes2.Objects.Home; +import me.william278.huskhomes2.Objects.Warp; +import me.william278.huskhomes2.dataManager; +import me.william278.huskhomes2.editingHandler; +import me.william278.huskhomes2.messageManager; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class editWarpCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (sender instanceof Player) { + Player p = (Player) sender; + if (args.length >= 1) { + String warpName = args[0]; + if (dataManager.warpExists(warpName)) { + if (args.length >= 2) { + switch (args[1]) { + case "location": + dataManager.updateWarpLocation(warpName, p.getLocation()); + messageManager.sendMessage(p, "edit_warp_update_location", warpName); + return true; + case "description": + if (args.length >= 3) { + // Get the new description + StringBuilder newDescription = new StringBuilder(); + for (int i = 2; i < args.length; i++) { + if (i > 2) { + newDescription.append(" ").append(args[i]); + } else { + newDescription = new StringBuilder(args[i]); + } + } + String newDescriptionString = newDescription.toString(); + + // Check the description is valid + if (!newDescriptionString.matches("[a-zA-Z0-9\\d\\-_\\s]+")) { + messageManager.sendMessage(p, "error_edit_warp_invalid_description"); + return true; + } + + // Update description + dataManager.updateWarpDescription(warpName, newDescriptionString); + + // Confirmation message + messageManager.sendMessage(p, "edit_warp_update_description", warpName, newDescriptionString); + } else { + messageManager.sendMessage(p, "error_invalid_syntax", "/editwarp description "); + } + return true; + case "rename": + if (args.length >= 3) { + String newName = args[2]; + if (newName.length() > 16) { + messageManager.sendMessage(p, "error_set_warp_invalid_length"); + return true; + } + if (!newName.matches("[A-Za-z0-9_\\-]+")) { + messageManager.sendMessage(p, "error_set_warp_invalid_characters"); + return true; + } + if (dataManager.warpExists(newName)) { + messageManager.sendMessage(p, "error_set_warp_name_taken"); + return true; + } + dataManager.updateWarpName(warpName, newName); + messageManager.sendMessage(p, "edit_warp_update_name", warpName, newName); + } else { + messageManager.sendMessage(p, "error_invalid_syntax", "/editwarp rename "); + } + return true; + default: + messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage()); + return true; + } + } else { + Warp warp = dataManager.getWarp(warpName); + editingHandler.showEditWarpOptions(p, warp); + return true; + } + } else { + messageManager.sendMessage(p, "error_warp_invalid", warpName); + } + } else { + messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage()); + } + return true; + } + return false; + } +} diff --git a/src/main/java/me/william278/huskhomes2/Commands/homeCommand.java b/src/main/java/me/william278/huskhomes2/Commands/homeCommand.java index 7fa8a4b4..4b9b17cf 100644 --- a/src/main/java/me/william278/huskhomes2/Commands/homeCommand.java +++ b/src/main/java/me/william278/huskhomes2/Commands/homeCommand.java @@ -19,10 +19,10 @@ public class homeCommand implements CommandExecutor { Home home = dataManager.getHome(p.getName(), homeName); teleportManager.queueTimedTeleport(p, home); } else { - messageManager.sendMessage(p, "error_home_invalid"); + messageManager.sendMessage(p, "error_home_invalid", homeName); } } else { - homeListHandler.displayPlayerHomeList(p, 1); + listHandler.displayPlayerHomeList(p, 1); } return true; } diff --git a/src/main/java/me/william278/huskhomes2/Commands/homeListCommand.java b/src/main/java/me/william278/huskhomes2/Commands/homeListCommand.java index 5c3f8b4f..40795922 100644 --- a/src/main/java/me/william278/huskhomes2/Commands/homeListCommand.java +++ b/src/main/java/me/william278/huskhomes2/Commands/homeListCommand.java @@ -1,6 +1,6 @@ package me.william278.huskhomes2.Commands; -import me.william278.huskhomes2.homeListHandler; +import me.william278.huskhomes2.listHandler; import me.william278.huskhomes2.messageManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -22,7 +22,7 @@ public class homeListCommand implements CommandExecutor { return true; } } - homeListHandler.displayPlayerHomeList(p, pageNo); + listHandler.displayPlayerHomeList(p, pageNo); return true; } return false; diff --git a/src/main/java/me/william278/huskhomes2/Commands/huskHomesCommand.java b/src/main/java/me/william278/huskhomes2/Commands/huskHomesCommand.java new file mode 100644 index 00000000..2da1c2f2 --- /dev/null +++ b/src/main/java/me/william278/huskhomes2/Commands/huskHomesCommand.java @@ -0,0 +1,100 @@ +package me.william278.huskhomes2.Commands; + +import me.william278.huskhomes2.Main; +import me.william278.huskhomes2.configManager; +import me.william278.huskhomes2.messageManager; +import me.william278.huskhomes2.versionChecker; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.TextComponent; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import static net.md_5.bungee.api.chat.ClickEvent.Action.OPEN_URL; + +public class huskHomesCommand implements CommandExecutor { + + private static final Main plugin = Main.getInstance(); + + private static void showAboutMenu(CommandSender sender) { + sender.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "HuskHomes" + ChatColor.RESET + " " + ChatColor.GREEN + "| Version " + plugin.getDescription().getVersion()); + sender.sendMessage(ChatColor.GRAY + plugin.getDescription().getDescription()); + sender.sendMessage("• Author: " + ChatColor.GRAY + "William278"); + sender.sendMessage("• Help Wiki: " + ChatColor.GRAY + "https://github.com/WiIIiam278/HuskHomes2/wiki/"); + sender.sendMessage("• Report a bug: " + ChatColor.GRAY + "https://github.com/WiIIiam278/HuskHomes2/issues"); + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (args.length >= 1) { + switch (args[0]) { + case "about": + if (sender instanceof Player) { + Player p = (Player) sender; + if (!p.hasPermission("huskhomes.about")) { + messageManager.sendMessage(p, "error_no_permission"); + return true; + } + } + showAboutMenu(sender); + return true; + case "update": + if (sender instanceof Player) { + Player p = (Player) sender; + if (p.hasPermission("huskhomes.version_checker")) { + if (!versionChecker.getVersionCheckString().contains("HuskHomes is up to date!")) { + p.sendMessage(org.bukkit.ChatColor.DARK_RED + "Update: " + org.bukkit.ChatColor.RED + versionChecker.getVersionCheckString()); + + // Send a link to Spigot downloads page + ComponentBuilder componentBuilder = new ComponentBuilder(); + TextComponent projectURL = new TextComponent("[Download]"); + ClickEvent clickEvent = new ClickEvent(OPEN_URL, "https://www.spigotmc.org/resources/huskhomes.83767/updates"); + projectURL.setClickEvent(clickEvent); + projectURL.setColor(net.md_5.bungee.api.ChatColor.AQUA); + componentBuilder = componentBuilder.append(TextComponent.fromLegacyText("§7Get the latest version: ")); + componentBuilder = componentBuilder.append(projectURL); + p.spigot().sendMessage(componentBuilder.create()); + } else { + p.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "HuskHomes" + ChatColor.RESET + "" + ChatColor.GREEN + " | HuskHomes is up-to-date! (Version " + plugin.getDescription().getVersion() + ")"); + } + } else { + messageManager.sendMessage(p, "error_no_permission"); + } + } else { + plugin.getLogger().info(versionChecker.getVersionCheckString()); + } + return true; + case "reload": + if (sender instanceof Player) { + Player p = (Player) sender; + if (p.hasPermission("huskhomes.reload")) { + configManager.loadConfig(); + messageManager.loadMessages(Main.settings.getLanguage()); + p.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "HuskHomes" + ChatColor.RESET + "" + ChatColor.GREEN + " | Reloaded config and message files."); + } else { + messageManager.sendMessage(p, "error_no_permission"); + } + return true; + } else { + configManager.loadConfig(); + messageManager.loadMessages(Main.settings.getLanguage()); + plugin.getLogger().info("Reloaded config and message files."); + } + return true; + } + } else { + if (sender instanceof Player) { + Player p = (Player) sender; + if (!p.hasPermission("huskhomes.about")) { + messageManager.sendMessage(p, "error_no_permission"); + return true; + } + } + showAboutMenu(sender); + } + return true; + } +} diff --git a/src/main/java/me/william278/huskhomes2/Commands/publicHomeCommand.java b/src/main/java/me/william278/huskhomes2/Commands/publicHomeCommand.java new file mode 100644 index 00000000..075077b4 --- /dev/null +++ b/src/main/java/me/william278/huskhomes2/Commands/publicHomeCommand.java @@ -0,0 +1,45 @@ +package me.william278.huskhomes2.Commands; + +import me.william278.huskhomes2.Objects.Home; +import me.william278.huskhomes2.dataManager; +import me.william278.huskhomes2.listHandler; +import me.william278.huskhomes2.messageManager; +import me.william278.huskhomes2.teleportManager; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class publicHomeCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (sender instanceof Player) { + Player p = (Player) sender; + if (args.length == 1) { + String publicHome = args[0]; + if (publicHome.matches("^(?!.*\\..*\\..*)[A-Za-z0-9_\\-]([A-Za-z0-9_\\-.]*[A-Za-z0-9_\\-])?$")) { + String ownerName = publicHome.split("\\.")[0]; + String homeName = publicHome.split("\\.")[1]; + if (dataManager.homeExists(ownerName, homeName)) { + Home home = dataManager.getHome(ownerName, homeName); + if (home.isPublic()) { + teleportManager.queueTimedTeleport(p, home); + } else { + messageManager.sendMessage(p, "error_public_home_invalid", ownerName, homeName); + } + } else { + messageManager.sendMessage(p, "error_public_home_invalid", ownerName, homeName); + } + } else { + messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage()); + } + } else { + listHandler.displayPublicHomeList(p, 1); + } + return true; + } + return false; + } + +} diff --git a/src/main/java/me/william278/huskhomes2/Commands/publicHomeListCommand.java b/src/main/java/me/william278/huskhomes2/Commands/publicHomeListCommand.java new file mode 100644 index 00000000..25e8d020 --- /dev/null +++ b/src/main/java/me/william278/huskhomes2/Commands/publicHomeListCommand.java @@ -0,0 +1,31 @@ +package me.william278.huskhomes2.Commands; + +import me.william278.huskhomes2.listHandler; +import me.william278.huskhomes2.messageManager; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class publicHomeListCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (sender instanceof Player) { + Player p = (Player) sender; + int pageNo = 1; + if (args.length == 1) { + try { + pageNo = Integer.parseInt(args[0]); + } catch (Exception e) { + messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage()); + return true; + } + } + listHandler.displayPublicHomeList(p, pageNo); + return true; + } + return false; + } + +} diff --git a/src/main/java/me/william278/huskhomes2/Commands/setWarpCommand.java b/src/main/java/me/william278/huskhomes2/Commands/setWarpCommand.java new file mode 100644 index 00000000..55cc2418 --- /dev/null +++ b/src/main/java/me/william278/huskhomes2/Commands/setWarpCommand.java @@ -0,0 +1,27 @@ +package me.william278.huskhomes2.Commands; + +import me.william278.huskhomes2.messageManager; +import me.william278.huskhomes2.settingHandler; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class setWarpCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (sender instanceof Player) { + Player p = (Player) sender; + if (args.length == 1) { + String warpName = args[0]; + settingHandler.setWarp(p.getLocation(), p, warpName); + } else { + messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage()); + } + return true; + } + return false; + } + +} diff --git a/src/main/java/me/william278/huskhomes2/Commands/tpAcceptCommand.java b/src/main/java/me/william278/huskhomes2/Commands/tpAcceptCommand.java new file mode 100644 index 00000000..1e99018d --- /dev/null +++ b/src/main/java/me/william278/huskhomes2/Commands/tpAcceptCommand.java @@ -0,0 +1,20 @@ +package me.william278.huskhomes2.Commands; + +import me.william278.huskhomes2.teleportRequestHandler; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class tpAcceptCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (sender instanceof Player) { + Player p = (Player) sender; + teleportRequestHandler.replyTpRequest(p, true); + return true; + } + return false; + } +} diff --git a/src/main/java/me/william278/huskhomes2/Commands/tpCommand.java b/src/main/java/me/william278/huskhomes2/Commands/tpCommand.java new file mode 100644 index 00000000..57171b63 --- /dev/null +++ b/src/main/java/me/william278/huskhomes2/Commands/tpCommand.java @@ -0,0 +1,81 @@ +package me.william278.huskhomes2.Commands; + +import me.william278.huskhomes2.Main; +import me.william278.huskhomes2.Objects.TeleportationPoint; +import me.william278.huskhomes2.messageManager; +import me.william278.huskhomes2.teleportManager; +import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class tpCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (sender instanceof Player) { + Player p = (Player) sender; + if (args.length >= 1) { + switch (args.length) { + case 1: + String targetPlayer = args[0]; + teleportManager.teleportPlayer(p, targetPlayer); + return true; + case 3: + try { + double x = Double.parseDouble(args[0]); + double y = Double.parseDouble(args[1]); + double z = Double.parseDouble(args[2]); + TeleportationPoint teleportationPoint = new TeleportationPoint(p.getWorld().getName(), x, y, z, 0F, 0F, Main.settings.getServerID()); + teleportManager.teleportPlayer(p, teleportationPoint); + } catch (Exception e) { + messageManager.sendMessage(p, "error_invalid_syntax", "/tp "); + } + return true; + case 4: + try { + double x = Double.parseDouble(args[0]); + double y = Double.parseDouble(args[1]); + double z = Double.parseDouble(args[2]); + String worldName = args[3]; + if (Bukkit.getWorld(worldName) == null) { + messageManager.sendMessage(p, "error_invalid_syntax", "/tp "); + return true; + } + TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, 0F, 0F, Main.settings.getServerID()); + teleportManager.teleportPlayer(p, teleportationPoint); + } catch (Exception e) { + messageManager.sendMessage(p, "error_invalid_syntax", "/tp "); + } + return true; + case 5: + if (Main.settings.doBungee()) { + try { + double x = Double.parseDouble(args[0]); + double y = Double.parseDouble(args[1]); + double z = Double.parseDouble(args[2]); + String worldName = args[3]; + String serverName = args[4]; + if (Bukkit.getWorld(worldName) == null) { + messageManager.sendMessage(p, "error_invalid_syntax", "/tp "); + return true; + } + TeleportationPoint teleportationPoint = new TeleportationPoint(worldName, x, y, z, 0F, 0F, serverName); + teleportManager.teleportPlayer(p, teleportationPoint); + } catch (Exception e) { + messageManager.sendMessage(p, "error_invalid_syntax", "/tp "); + } + } else { + messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage()); + } + return true; + } + } else { + messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage()); + } + return true; + } + return false; + } +} diff --git a/src/main/java/me/william278/huskhomes2/Commands/tpDenyCommand.java b/src/main/java/me/william278/huskhomes2/Commands/tpDenyCommand.java new file mode 100644 index 00000000..42a87f64 --- /dev/null +++ b/src/main/java/me/william278/huskhomes2/Commands/tpDenyCommand.java @@ -0,0 +1,20 @@ +package me.william278.huskhomes2.Commands; + +import me.william278.huskhomes2.teleportRequestHandler; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class tpDenyCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (sender instanceof Player) { + Player p = (Player) sender; + teleportRequestHandler.replyTpRequest(p, false); + return true; + } + return false; + } +} diff --git a/src/main/java/me/william278/huskhomes2/Commands/tpHereCommand.java b/src/main/java/me/william278/huskhomes2/Commands/tpHereCommand.java new file mode 100644 index 00000000..d08daf7f --- /dev/null +++ b/src/main/java/me/william278/huskhomes2/Commands/tpHereCommand.java @@ -0,0 +1,26 @@ +package me.william278.huskhomes2.Commands; + +import me.william278.huskhomes2.messageManager; +import me.william278.huskhomes2.teleportManager; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class tpHereCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (sender instanceof Player) { + Player p = (Player) sender; + if (args.length == 1) { + String targetPlayer = args[0]; + teleportManager.teleportPlayer(p, targetPlayer); + } else { + messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage()); + } + return true; + } + return false; + } +} diff --git a/src/main/java/me/william278/huskhomes2/Commands/tpaCommand.java b/src/main/java/me/william278/huskhomes2/Commands/tpaCommand.java new file mode 100644 index 00000000..548037ee --- /dev/null +++ b/src/main/java/me/william278/huskhomes2/Commands/tpaCommand.java @@ -0,0 +1,26 @@ +package me.william278.huskhomes2.Commands; + +import me.william278.huskhomes2.messageManager; +import me.william278.huskhomes2.teleportRequestHandler; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class tpaCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (sender instanceof Player) { + Player p = (Player) sender; + if (args.length == 1) { + String targetPlayer = args[0]; + teleportRequestHandler.sendTeleportToRequest(p, targetPlayer); + } else { + messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage()); + } + return true; + } + return false; + } +} diff --git a/src/main/java/me/william278/huskhomes2/Commands/tpaHereCommand.java b/src/main/java/me/william278/huskhomes2/Commands/tpaHereCommand.java new file mode 100644 index 00000000..03bf2bdc --- /dev/null +++ b/src/main/java/me/william278/huskhomes2/Commands/tpaHereCommand.java @@ -0,0 +1,27 @@ +package me.william278.huskhomes2.Commands; + +import me.william278.huskhomes2.messageManager; +import me.william278.huskhomes2.teleportManager; +import me.william278.huskhomes2.teleportRequestHandler; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class tpaHereCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (sender instanceof Player) { + Player p = (Player) sender; + if (args.length == 1) { + String targetPlayer = args[0]; + teleportRequestHandler.sendTeleportHereRequest(p, targetPlayer); + } else { + messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage()); + } + return true; + } + return false; + } +} diff --git a/src/main/java/me/william278/huskhomes2/Commands/warpCommand.java b/src/main/java/me/william278/huskhomes2/Commands/warpCommand.java new file mode 100644 index 00000000..8a1d86de --- /dev/null +++ b/src/main/java/me/william278/huskhomes2/Commands/warpCommand.java @@ -0,0 +1,35 @@ +package me.william278.huskhomes2.Commands; + +import me.william278.huskhomes2.Objects.Warp; +import me.william278.huskhomes2.dataManager; +import me.william278.huskhomes2.listHandler; +import me.william278.huskhomes2.messageManager; +import me.william278.huskhomes2.teleportManager; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class warpCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (sender instanceof Player) { + Player p = (Player) sender; + if (args.length == 1) { + String warpName = args[0]; + if (dataManager.warpExists(warpName)) { + Warp warp = dataManager.getWarp(warpName); + teleportManager.queueTimedTeleport(p, warp); + } else { + messageManager.sendMessage(p, "error_warp_invalid", warpName); + } + } else { + listHandler.displayWarpList(p, 1); + } + return true; + } + return false; + } + +} diff --git a/src/main/java/me/william278/huskhomes2/Commands/warpListCommand.java b/src/main/java/me/william278/huskhomes2/Commands/warpListCommand.java new file mode 100644 index 00000000..00eeac6e --- /dev/null +++ b/src/main/java/me/william278/huskhomes2/Commands/warpListCommand.java @@ -0,0 +1,31 @@ +package me.william278.huskhomes2.Commands; + +import me.william278.huskhomes2.listHandler; +import me.william278.huskhomes2.messageManager; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class warpListCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (sender instanceof Player) { + Player p = (Player) sender; + int pageNo = 1; + if (args.length == 1) { + try { + pageNo = Integer.parseInt(args[0]); + } catch (Exception e) { + messageManager.sendMessage(p, "error_invalid_syntax", command.getUsage()); + return true; + } + } + listHandler.displayWarpList(p, pageNo); + return true; + } + return false; + } + +} diff --git a/src/main/java/me/william278/huskhomes2/Data/SQLite/Database.java b/src/main/java/me/william278/huskhomes2/Data/SQLite/Database.java index f3f49737..8a2863f7 100644 --- a/src/main/java/me/william278/huskhomes2/Data/SQLite/Database.java +++ b/src/main/java/me/william278/huskhomes2/Data/SQLite/Database.java @@ -252,6 +252,34 @@ public abstract class Database { } } + // Update the location of a home + public void setHomePrivacy(String homeName, int ownerID, boolean isPublic) { + Connection conn = null; + PreparedStatement ps = null; + + try { + conn = getSQLConnection(); + + // Set the home location ID to the new teleport point for the given home + ps = conn.prepareStatement("UPDATE huskhomes_home_data SET `public`=? WHERE `name`=? AND `player_id`=?;"); + ps.setBoolean(1, isPublic); + ps.setString(2, homeName); + ps.setInt(3, ownerID); + ps.executeUpdate(); + } catch (SQLException ex) { + plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex); + } finally { + try { + if (ps != null) + ps.close(); + if (conn != null) + conn.close(); + } catch (SQLException ex) { + plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionClose(), ex); + } + } + } + // Update the location of a home public void setHomeTeleportPoint(String homeName, int ownerID, TeleportationPoint point) { Connection conn = null; diff --git a/src/main/java/me/william278/huskhomes2/Events/onPlayerDeath.java b/src/main/java/me/william278/huskhomes2/Events/onPlayerDeath.java new file mode 100644 index 00000000..6fabf1f6 --- /dev/null +++ b/src/main/java/me/william278/huskhomes2/Events/onPlayerDeath.java @@ -0,0 +1,41 @@ +package me.william278.huskhomes2.Events; + +import me.william278.huskhomes2.Main; +import me.william278.huskhomes2.Objects.TeleportationPoint; +import me.william278.huskhomes2.dataManager; +import me.william278.huskhomes2.messageManager; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.chat.hover.content.Text; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.PlayerDeathEvent; + +public class onPlayerDeath implements Listener { + + private static final Main plugin = Main.getInstance(); + + private static TextComponent backButton() { + TextComponent button = new TextComponent("→ [Go Back]"); + button.setColor(ChatColor.GREEN); + + button.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, ("/back"))); + button.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(new ComponentBuilder("Return to your death location with /back").color(ChatColor.GRAY).italic(true).create()))); + return button; + } + + @EventHandler + public void onPlayerDie(PlayerDeathEvent e) { + Player p = e.getEntity(); + if (p.hasPermission("huskhomes.back.death")) { + dataManager.setPlayerLastPosition(p, new TeleportationPoint(p.getLocation(), Main.settings.getServerID())); + messageManager.sendMessage(p, "return_by_death"); + p.spigot().sendMessage(new ComponentBuilder(backButton()).create()); + } + } + +} diff --git a/src/main/java/me/william278/huskhomes2/Main.java b/src/main/java/me/william278/huskhomes2/Main.java index 76311d5e..8aea78fc 100644 --- a/src/main/java/me/william278/huskhomes2/Main.java +++ b/src/main/java/me/william278/huskhomes2/Main.java @@ -4,6 +4,7 @@ import me.william278.huskhomes2.Commands.delHomeCommand; import me.william278.huskhomes2.Commands.homeCommand; import me.william278.huskhomes2.Commands.homeListCommand; import me.william278.huskhomes2.Commands.setHomeCommand; +import me.william278.huskhomes2.Events.onPlayerDeath; import me.william278.huskhomes2.Events.onPlayerJoin; import me.william278.huskhomes2.Objects.Settings; import org.bukkit.plugin.java.JavaPlugin; @@ -33,6 +34,7 @@ public final class Main extends JavaPlugin { private static void registerEvents(Main plugin) { plugin.getServer().getPluginManager().registerEvents(new onPlayerJoin(), plugin); + plugin.getServer().getPluginManager().registerEvents(new onPlayerDeath(), plugin); } @Override @@ -43,6 +45,9 @@ public final class Main extends JavaPlugin { // Set instance for easy cross-class referencing setInstance(this); + // Check if HuskHomes is up-to-date + getLogger().info(versionChecker.getVersionCheckString()); + // Load the config configManager.loadConfig(); diff --git a/src/main/java/me/william278/huskhomes2/Objects/RandomPoint.java b/src/main/java/me/william278/huskhomes2/Objects/RandomPoint.java new file mode 100644 index 00000000..74005e72 --- /dev/null +++ b/src/main/java/me/william278/huskhomes2/Objects/RandomPoint.java @@ -0,0 +1,85 @@ +package me.william278.huskhomes2.Objects; + +import me.william278.huskhomes2.Main; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; + +import java.util.HashSet; +import java.util.Random; + +public class RandomPoint extends TeleportationPoint { + + //List of all the unsafe blocks + final static HashSet bad_blocks = new HashSet<>(); + + static{ + bad_blocks.add(Material.LAVA); + bad_blocks.add(Material.FIRE); + bad_blocks.add(Material.CACTUS); + bad_blocks.add(Material.WATER); + bad_blocks.add(Material.MAGMA_BLOCK); + bad_blocks.add(Material.JUNGLE_LEAVES); + bad_blocks.add(Material.SPRUCE_LEAVES); + } + + private Location randomLocation(World world) { + //Generate Random Location + Random random = new Random(); + + int x = 0; + int z = 0; + int y = 0; + int negativex = 0; + int negativez = 0; + x = random.nextInt(Main.settings.getRtpRange()); + z = random.nextInt(Main.settings.getRtpRange()); + negativex = random.nextInt(2); + negativez = random.nextInt(2); + if (negativex == 1) { + x = x * -1; + } + if (negativez == 1) + z = z * -1; + y = 150; + + Location randomLocation = new Location(world, x, y, z); + y = randomLocation.getWorld().getHighestBlockYAt(randomLocation); + randomLocation.setY(y); + + return randomLocation; + } + + private boolean isLocationSafe(Location location){ + + int x = location.getBlockX(); + int y = location.getBlockY(); + int z = location.getBlockZ(); + //Get instances of the blocks around where the player would spawn + Block block = location.getWorld().getBlockAt(x, y, z); + Block below = location.getWorld().getBlockAt(x, y - 1, z); + Block above = location.getWorld().getBlockAt(x, y + 1, z); + + //Check to see if the surroundings are safe or not + return !(bad_blocks.contains(below.getType())) || (block.getType().isSolid()) || (above.getType().isSolid()); + } + + private Location getRandomLocation(World world) { + Location randomLocation = randomLocation(world); + + while (!isLocationSafe(randomLocation)){ + + //Keep looking for a safe location + randomLocation = randomLocation(world); + } + return randomLocation; + } + + public RandomPoint(Player player) { + super(player.getLocation(), Main.settings.getServerID()); + setLocation(getRandomLocation(player.getWorld()), Main.settings.getServerID()); + } + +} diff --git a/src/main/java/me/william278/huskhomes2/Objects/Settings.java b/src/main/java/me/william278/huskhomes2/Objects/Settings.java index d5f0e99b..b20ddb5b 100644 --- a/src/main/java/me/william278/huskhomes2/Objects/Settings.java +++ b/src/main/java/me/william278/huskhomes2/Objects/Settings.java @@ -12,8 +12,10 @@ public class Settings { int maximumHomes; int teleportRequestExpiryTime; int teleportWarmupTime; + int rtpRange; boolean doBungee; + boolean doRtpCommand; boolean doSpawnCommand; private void setSettings(FileConfiguration configFile) { @@ -25,6 +27,9 @@ public class Settings { this.doSpawnCommand = configFile.getBoolean("spawn_command.enabled"); + this.doRtpCommand = configFile.getBoolean("rtp_command.enabled"); + this.rtpRange = configFile.getInt("rtp_command.range"); + this.maximumHomes = configFile.getInt("general.max_sethomes"); this.teleportRequestExpiryTime = configFile.getInt("general.teleport_request_expiry_time"); this.teleportWarmupTime = configFile.getInt("general.teleport_warmup_time"); @@ -63,4 +68,12 @@ public class Settings { public int getTeleportRequestExpiryTime() { return teleportRequestExpiryTime; } + public int getRtpRange() { + return rtpRange; + } + + public boolean doRtpCommand() { + return doRtpCommand; + } + } diff --git a/src/main/java/me/william278/huskhomes2/Objects/TeleportationPoint.java b/src/main/java/me/william278/huskhomes2/Objects/TeleportationPoint.java index d1aefd84..7baf1652 100644 --- a/src/main/java/me/william278/huskhomes2/Objects/TeleportationPoint.java +++ b/src/main/java/me/william278/huskhomes2/Objects/TeleportationPoint.java @@ -14,7 +14,7 @@ public class TeleportationPoint { float yaw; float pitch; - private void setLocation(Location location, String server) { + public void setLocation(Location location, String server) { worldName = location.getWorld().getName(); x = location.getX(); y = location.getY(); diff --git a/src/main/java/me/william278/huskhomes2/dataManager.java b/src/main/java/me/william278/huskhomes2/dataManager.java index 77a77f57..f99c1372 100644 --- a/src/main/java/me/william278/huskhomes2/dataManager.java +++ b/src/main/java/me/william278/huskhomes2/dataManager.java @@ -7,6 +7,7 @@ import me.william278.huskhomes2.Objects.Home; import me.william278.huskhomes2.Objects.TeleportationPoint; import me.william278.huskhomes2.Objects.Warp; import org.bukkit.Bukkit; +import org.bukkit.Location; import org.bukkit.entity.Player; import java.sql.Connection; @@ -105,8 +106,7 @@ public class dataManager { return null; } } else { - Bukkit.getLogger().severe("Result set for a player returned null while fetching player ID"); - return null; + return null; // If the player doesn't exist, playerID will be null } } catch (SQLException ex) { plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex); @@ -448,6 +448,129 @@ public class dataManager { return null; } + public static void deleteHomeTeleportLocation(int ownerID, String homeName) { + Connection conn = null; + PreparedStatement ps = null; + ResultSet rs; + + try { + conn = getConnection(); + ps = conn.prepareStatement("SELECT * FROM huskhomes_home_data WHERE `player_id`=? AND `name`=?;"); + ps.setInt(1, ownerID); + ps.setString(2, homeName); + rs = ps.executeQuery(); + if (rs != null) { + int locationID = rs.getInt("location_id"); + sqliteDatabase.deleteTeleportationPoint(locationID); + } else { + Bukkit.getLogger().severe("Failed to delete home teleportation location"); + } + } catch (SQLException ex) { + plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex); + } finally { + try { + if (ps != null) + ps.close(); + if (conn != null) + conn.close(); + } catch (SQLException ex) { + plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionClose(), ex); + } + } + } + + public static void deleteWarpTeleportLocation(String warpName) { + Connection conn = null; + PreparedStatement ps = null; + ResultSet rs; + + try { + conn = getConnection(); + ps = conn.prepareStatement("SELECT * FROM huskhomes_warp_data WHERE `name`=?;"); + ps.setString(1, warpName); + rs = ps.executeQuery(); + if (rs != null) { + int locationID = rs.getInt("location_id"); + sqliteDatabase.deleteTeleportationPoint(locationID); + } else { + Bukkit.getLogger().severe("Failed to delete warp teleportation location"); + } + } catch (SQLException ex) { + plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex); + } finally { + try { + if (ps != null) + ps.close(); + if (conn != null) + conn.close(); + } catch (SQLException ex) { + plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionClose(), ex); + } + } + } + + public static void updateHomePrivacy(String ownerName, String homeName, boolean isPublic) { + Integer playerID = getPlayerId(ownerName); + if (Main.settings.getStorageType().equalsIgnoreCase("mysql")) { + + } else { + sqliteDatabase.setHomePrivacy(homeName, playerID, isPublic); + } + } + + public static void updateHomeName(String ownerName, String homeName, String newName) { + Integer playerID = getPlayerId(ownerName); + if (Main.settings.getStorageType().equalsIgnoreCase("mysql")) { + + } else { + sqliteDatabase.setHomeName(homeName, playerID, newName); + } + } + + public static void updateHomeDescription(String ownerName, String homeName, String newDescription) { + Integer playerID = getPlayerId(ownerName); + if (Main.settings.getStorageType().equalsIgnoreCase("mysql")) { + + } else { + sqliteDatabase.setHomeDescription(homeName, playerID, newDescription); + } + } + + public static void updateHomeLocation(String ownerName, String homeName, Location newLocation) { + Integer playerID = getPlayerId(ownerName); + deleteHomeTeleportLocation(playerID, homeName); + if (Main.settings.getStorageType().equalsIgnoreCase("mysql")) { + + } else { + sqliteDatabase.setHomeTeleportPoint(homeName, playerID, new TeleportationPoint(newLocation, Main.settings.getServerID())); + } + } + + public static void updateWarpName(String warpName, String newName) { + if (Main.settings.getStorageType().equalsIgnoreCase("mysql")) { + + } else { + sqliteDatabase.setWarpName(warpName, newName); + } + } + + public static void updateWarpDescription(String warpName, String newDescription) { + if (Main.settings.getStorageType().equalsIgnoreCase("mysql")) { + + } else { + sqliteDatabase.setWarpDescription(warpName, newDescription); + } + } + + public static void updateWarpLocation(String warpName, Location newLocation) { + deleteWarpTeleportLocation(warpName); + if (Main.settings.getStorageType().equalsIgnoreCase("mysql")) { + + } else { + sqliteDatabase.setWarpTeleportPoint(warpName, new TeleportationPoint(newLocation, Main.settings.getServerID())); + } + } + // Return a home with a given owner username and home name public static Home getHome(String ownerUsername, String homeName) { Connection conn = null; @@ -526,10 +649,19 @@ public class dataManager { } public static Boolean homeExists(Player owner, String homeName) { + return homeExists(owner.getName(), homeName); + } + + public static Boolean homeExists(String ownerName, String homeName) { Connection conn = null; PreparedStatement ps = null; ResultSet rs; - Integer playerID = getPlayerId(owner.getName()); + Integer playerID = getPlayerId(ownerName); + + // Return false if the player is invalid + if (playerID == null) { + return false; + } try { conn = getConnection(); @@ -756,17 +888,21 @@ public class dataManager { } public static void deleteHome(String homeName, Player p) { - if (Main.settings.getStorageType().equalsIgnoreCase("mySQL")) { + Integer playerID = getPlayerId(p.getName()); + if (playerID != null) { + deleteHomeTeleportLocation(playerID, homeName); + if (Main.settings.getStorageType().equalsIgnoreCase("mySQL")) { - } else { - Integer playerID = getPlayerId(p.getName()); - if (playerID != null) { + } else { sqliteDatabase.deleteHome(homeName, playerID); } + } else { + Bukkit.getLogger().warning("PlayeR ID returned null when deleting a home"); } } public static void deleteWarp(String warpName) { + deleteWarpTeleportLocation(warpName); if (Main.settings.getStorageType().equalsIgnoreCase("mySQL")) { } else { diff --git a/src/main/java/me/william278/huskhomes2/editingHandler.java b/src/main/java/me/william278/huskhomes2/editingHandler.java new file mode 100644 index 00000000..0fe9952b --- /dev/null +++ b/src/main/java/me/william278/huskhomes2/editingHandler.java @@ -0,0 +1,94 @@ +package me.william278.huskhomes2; + +import me.william278.huskhomes2.Objects.Home; +import me.william278.huskhomes2.Objects.Warp; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.chat.hover.content.Text; +import org.bukkit.entity.Player; + +public class editingHandler { + + private static TextComponent optionButton(String buttonText, ChatColor color, ClickEvent.Action actionType, String command, String hoverMessage, net.md_5.bungee.api.ChatColor hoverMessageColor, Boolean hoverMessageItalic) { + TextComponent button = new TextComponent(buttonText); + button.setColor(color); + + button.setClickEvent(new ClickEvent(actionType, (command))); + button.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(new ComponentBuilder(hoverMessage).color(hoverMessageColor).italic(hoverMessageItalic).create()))); + return button; + } + + private static ComponentBuilder editWarpOptions(Warp warp) { + ComponentBuilder options = new ComponentBuilder(); + + options.append(optionButton("[Teleport] ", net.md_5.bungee.api.ChatColor.GREEN, ClickEvent.Action.RUN_COMMAND, "/warp " + warp.getName(), "Teleport to this warp", net.md_5.bungee.api.ChatColor.GRAY, true)); + options.append(optionButton("[Delete] ", net.md_5.bungee.api.ChatColor.RED, ClickEvent.Action.RUN_COMMAND, "/delwarp " + warp.getName(), "Delete this warp", net.md_5.bungee.api.ChatColor.GRAY, true)); + options.append(optionButton("[Relocate]\n", net.md_5.bungee.api.ChatColor.BLUE, ClickEvent.Action.RUN_COMMAND, "/editwarp " + warp.getName() + " location", "Update this warp's location", net.md_5.bungee.api.ChatColor.GRAY, true)); + options.append(optionButton("[Rename] ", net.md_5.bungee.api.ChatColor.YELLOW, ClickEvent.Action.SUGGEST_COMMAND, "/editwarp " + warp.getName() + " rename ", "Change the name of this warp", net.md_5.bungee.api.ChatColor.GRAY, true)); + options.append(optionButton("[Edit Description] ", net.md_5.bungee.api.ChatColor.GOLD, ClickEvent.Action.SUGGEST_COMMAND, "/editwarp " + warp.getName() + " description ", "Update this warp's description", net.md_5.bungee.api.ChatColor.GRAY, true)); + + return options; + } + + private static ComponentBuilder editHomeOptions(Player p, Home home) { + ComponentBuilder options = new ComponentBuilder(); + + options.append(optionButton("[Teleport] ", net.md_5.bungee.api.ChatColor.GREEN, ClickEvent.Action.RUN_COMMAND, "/home " + home.getName(), "Teleport to your home", net.md_5.bungee.api.ChatColor.GRAY, true)); + options.append(optionButton("[Delete] ", net.md_5.bungee.api.ChatColor.RED, ClickEvent.Action.RUN_COMMAND, "/delhome " + home.getName(), "Delete your home", net.md_5.bungee.api.ChatColor.GRAY, true)); + options.append(optionButton("[Relocate]\n", net.md_5.bungee.api.ChatColor.BLUE, ClickEvent.Action.RUN_COMMAND, "/edithome " + home.getName() + " location", "Update your home's location", net.md_5.bungee.api.ChatColor.GRAY, true)); + options.append(optionButton("[Rename] ", net.md_5.bungee.api.ChatColor.YELLOW, ClickEvent.Action.SUGGEST_COMMAND, "/edithome " + home.getName() + " rename ", "Change the name of your home", net.md_5.bungee.api.ChatColor.GRAY, true)); + options.append(optionButton("[Edit Description] ", net.md_5.bungee.api.ChatColor.GOLD, ClickEvent.Action.SUGGEST_COMMAND, "/edithome " + home.getName() + " description ", "Update the description of your home", net.md_5.bungee.api.ChatColor.GRAY, true)); + + if (p.hasPermission("huskhomes.edithome.public")) { + if (home.isPublic()) { + options.append(optionButton("[Make Public] ", net.md_5.bungee.api.ChatColor.DARK_GREEN, ClickEvent.Action.RUN_COMMAND, "/edithome " + home.getName() + " public", "Open your home to the public", net.md_5.bungee.api.ChatColor.GRAY, true)); + } else { + options.append(optionButton("[Make Private] ", net.md_5.bungee.api.ChatColor.DARK_RED, ClickEvent.Action.RUN_COMMAND, "/edithome " + home.getName() + " private", "Make your home private", net.md_5.bungee.api.ChatColor.GRAY, true)); + } + } + return options; + } + + public static void showEditHomeOptions(Player p, Home home) { + p.sendMessage(""); + messageManager.sendMessage(p, "edit_home_title", home.getName()); + messageManager.sendMessage(p, "edit_home_title", home.getDescription()); + messageManager.sendMessage(p, "edit_home_location", + Double.toString(home.getX()), + Double.toString(home.getY()), + Double.toString(home.getZ())); + messageManager.sendMessage(p, "edit_home_world", home.getWorldName()); + if (Main.settings.doBungee()) { + messageManager.sendMessage(p, "edit_home_server", home.getServer()); + } + if (home.isPublic()) { + messageManager.sendMessage(p, "edit_home_privacy_public"); + } else { + messageManager.sendMessage(p, "edit_home_privacy_private"); + } + p.sendMessage(""); + p.spigot().sendMessage(editHomeOptions(p, home).create()); + p.sendMessage(""); + } + + public static void showEditWarpOptions(Player p, Warp warp) { + p.sendMessage(""); + messageManager.sendMessage(p, "edit_warp_title", warp.getName()); + messageManager.sendMessage(p, "edit_warp_title", warp.getDescription()); + messageManager.sendMessage(p, "edit_warp_location", + Double.toString(warp.getX()), + Double.toString(warp.getY()), + Double.toString(warp.getZ())); + messageManager.sendMessage(p, "edit_warp_world", warp.getWorldName()); + if (Main.settings.doBungee()) { + messageManager.sendMessage(p, "edit_warp_server", warp.getServer()); + } + p.sendMessage(""); + p.spigot().sendMessage(editWarpOptions(warp).create()); + p.sendMessage(""); + } + +} \ No newline at end of file diff --git a/src/main/java/me/william278/huskhomes2/homeListHandler.java b/src/main/java/me/william278/huskhomes2/listHandler.java similarity index 71% rename from src/main/java/me/william278/huskhomes2/homeListHandler.java rename to src/main/java/me/william278/huskhomes2/listHandler.java index b7cf8504..d419837c 100644 --- a/src/main/java/me/william278/huskhomes2/homeListHandler.java +++ b/src/main/java/me/william278/huskhomes2/listHandler.java @@ -1,6 +1,7 @@ package me.william278.huskhomes2; import me.william278.huskhomes2.Objects.Home; +import me.william278.huskhomes2.Objects.Warp; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ComponentBuilder; @@ -11,7 +12,7 @@ import org.bukkit.entity.Player; import java.util.ArrayList; -public class homeListHandler { +public class listHandler { private static TextComponent pageButton(String buttonText, ChatColor color, String command, String hoverMessage) { TextComponent button = new TextComponent(buttonText); @@ -44,10 +45,18 @@ public class homeListHandler { return clickableHome; } - private static void displayPageButtons(Player p, int pageNumber, int homeListSize, int homeUpperBound) { + private static TextComponent clickableWarp(Warp warp) { + TextComponent clickableHome = new TextComponent("[" + warp.getName() + "]"); + clickableHome.setColor(ChatColor.ITALIC); + clickableHome.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, ("/warp " + warp.getName()))); + clickableHome.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(new ComponentBuilder(warp.getDescription()).color(net.md_5.bungee.api.ChatColor.GRAY).italic(false).create()))); + return clickableHome; + } + + private static void displayPageButtons(Player p, int pageNumber, int homeListSize, int homeUpperBound, String command) { ComponentBuilder pageButtons = new ComponentBuilder(); - TextComponent nextPageButton = pageButton("[Next Page →]", net.md_5.bungee.api.ChatColor.GREEN, "/homelist " + (pageNumber + 1), "Click to view next 10"); - TextComponent previousPageButton = pageButton("[← Last Page]", net.md_5.bungee.api.ChatColor.RED, "/homelist " + (pageNumber - 1), "Click to view previous 10"); + TextComponent nextPageButton = pageButton("[Next Page →]", net.md_5.bungee.api.ChatColor.GREEN, command + " " + (pageNumber + 1), "Click to view next 10"); + TextComponent previousPageButton = pageButton("[← Last Page]", net.md_5.bungee.api.ChatColor.RED, command + " " + (pageNumber - 1), "Click to view previous 10"); TextComponent divider = new TextComponent(" • "); divider.setColor(net.md_5.bungee.api.ChatColor.GRAY); @@ -101,7 +110,7 @@ public class homeListHandler { player.spigot().sendMessage(homeList.create()); // Display page buttons - displayPageButtons(player, pageNumber, homes.size(), homeUpperBound); + displayPageButtons(player, pageNumber, homes.size(), homeUpperBound, "/homelist"); } public static void displayPublicHomeList(Player player, int pageNumber) { @@ -138,7 +147,44 @@ public class homeListHandler { player.spigot().sendMessage(homeList.create()); // Display page buttons - displayPageButtons(player, pageNumber, homes.size(), homeUpperBound); + displayPageButtons(player, pageNumber, homes.size(), homeUpperBound, "/publichomelist"); + } + + public static void displayWarpList(Player player, int pageNumber) { + ComponentBuilder warpList = new ComponentBuilder(); + ArrayList warps = dataManager.getWarps(); + if (warps == null || warps.isEmpty()) { + messageManager.sendMessage(player, "error_no_warps_set"); + return; + } + int warpsLowerBound = (pageNumber - 1) * 10; + int warpsUpperBound = pageNumber * 10; + if (warpsUpperBound > warps.size()) { + warpsUpperBound = warps.size(); + } + + player.sendMessage(""); + messageManager.sendMessage(player, "warp_list_page_top", player.getName(), Integer.toString(warpsLowerBound + 1), Integer.toString(warpsUpperBound), Integer.toString(warps.size())); + + for (int i = warpsLowerBound; i < warpsUpperBound; i++) { + try { + Warp warp = warps.get(i); + if (i != warpsLowerBound) { + warpList.append(divider()); + } + warpList.append(clickableWarp(warp)); + } catch (IndexOutOfBoundsException e) { + if (i == warpsLowerBound) { + messageManager.sendMessage(player, "warp_list_page_empty"); + } + i = warpsUpperBound; + } + } + + player.spigot().sendMessage(warpList.create()); + + // Display page buttons + displayPageButtons(player, pageNumber, warps.size(), warpsUpperBound, "/warplist"); } } \ No newline at end of file diff --git a/src/main/java/me/william278/huskhomes2/runEverySecond.java b/src/main/java/me/william278/huskhomes2/runEverySecond.java index 3555abef..cb4c3a75 100644 --- a/src/main/java/me/william278/huskhomes2/runEverySecond.java +++ b/src/main/java/me/william278/huskhomes2/runEverySecond.java @@ -69,17 +69,11 @@ public class runEverySecond { } else { // Execute the teleport if (timedTeleport.getTargetType().equals("point")) { - dataManager.setPlayerDestinationLocation(teleporter, timedTeleport.getTargetPoint()); + teleportManager.teleportPlayer(teleporter, timedTeleport.getTargetPoint()); } else { - teleportManager.setPlayerDestinationFromTargetPlayer(teleporter, timedTeleport.getTargetPlayerName()); + teleportManager.teleportPlayer(teleporter, timedTeleport.getTargetPlayerName()); } - // Update last position - dataManager.setPlayerLastPosition(teleporter, - new TeleportationPoint(teleporter.getLocation(), Main.settings.getServerID())); - - // Teleport player - teleportManager.teleportPlayer(teleporter); completedTeleports.add(timedTeleport); } } else { diff --git a/src/main/java/me/william278/huskhomes2/teleportManager.java b/src/main/java/me/william278/huskhomes2/teleportManager.java index f6488104..f4b1193c 100644 --- a/src/main/java/me/william278/huskhomes2/teleportManager.java +++ b/src/main/java/me/william278/huskhomes2/teleportManager.java @@ -11,6 +11,18 @@ public class teleportManager { public static HashSet queuedTeleports = new HashSet<>(); + public static void teleportPlayer(Player player, String targetPlayer) { + dataManager.setPlayerLastPosition(player, new TeleportationPoint(player.getLocation(), Main.settings.getServerID())); + setPlayerDestinationFromTargetPlayer(player, targetPlayer); + teleportPlayer(player); + } + + public static void teleportPlayer(Player player, TeleportationPoint point) { + dataManager.setPlayerLastPosition(player, new TeleportationPoint(player.getLocation(), Main.settings.getServerID())); + dataManager.setPlayerDestinationLocation(player, point); + teleportPlayer(player); + } + public static void teleportPlayer(Player p) { TeleportationPoint teleportationPoint = dataManager.getPlayerDestination(p); String server = teleportationPoint.getServer(); @@ -25,9 +37,7 @@ public class teleportManager { public static void queueTimedTeleport(Player player, String targetPlayer) { if (player.hasPermission("huskhomes.bypass_warmup_timers")) { - dataManager.setPlayerLastPosition(player, new TeleportationPoint(player.getLocation(), Main.settings.getServerID())); - setPlayerDestinationFromTargetPlayer(player, targetPlayer); - teleportPlayer(player); + teleportPlayer(player, targetPlayer); return; } @@ -36,9 +46,7 @@ public class teleportManager { public static void queueTimedTeleport(Player player, TeleportationPoint point) { if (player.hasPermission("huskhomes.bypass_warmup_timers")) { - dataManager.setPlayerLastPosition(player, new TeleportationPoint(player.getLocation(), Main.settings.getServerID())); - dataManager.setPlayerDestinationLocation(player, point); - teleportPlayer(player); + teleportPlayer(player, point); return; } diff --git a/src/main/java/me/william278/huskhomes2/versionChecker.java b/src/main/java/me/william278/huskhomes2/versionChecker.java new file mode 100644 index 00000000..5b8806f6 --- /dev/null +++ b/src/main/java/me/william278/huskhomes2/versionChecker.java @@ -0,0 +1,53 @@ +package me.william278.huskhomes2; + +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.TextComponent; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; + +import static net.md_5.bungee.api.chat.ClickEvent.Action.OPEN_URL; + +public class versionChecker { + private static final Main plugin = Main.getInstance(); + + public static void adminVersionCheck(Player p) { + if (p.hasPermission("huskhomes.version_checker")) { + if (!versionChecker.getVersionCheckString().contains("HuskHomes is up to date!")) { + p.sendMessage(ChatColor.DARK_RED + "Update: " + ChatColor.RED + versionChecker.getVersionCheckString()); + + // Send a link to Spigot downloads page + ComponentBuilder componentBuilder = new ComponentBuilder(); + TextComponent projectURL = new TextComponent("[Download]"); + ClickEvent clickEvent = new ClickEvent(OPEN_URL, "https://www.spigotmc.org/resources/huskhomes.83767/updates"); + projectURL.setClickEvent(clickEvent); + projectURL.setColor(net.md_5.bungee.api.ChatColor.AQUA); + componentBuilder = componentBuilder.append(TextComponent.fromLegacyText("§7Get the latest version: ")); + componentBuilder = componentBuilder.append(projectURL); + p.spigot().sendMessage(componentBuilder.create()); + } + } + } + + public static String getVersionCheckString() { + try { + URL url = new URL("https://api.spigotmc.org/legacy/update.php?resource=83767"); // Numbers = Spigot Project ID! + URLConnection urlConnection = url.openConnection(); + String latestVersion = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())).readLine(); + String pluginVersion = plugin.getDescription().getVersion(); + if (!latestVersion.equals(pluginVersion)) { + return "An update for HuskHomes is available; v" + latestVersion + " (Currently running v" + pluginVersion + ")"; + } else { + return "HuskHomes is up to date! (Version " + pluginVersion + ")"; + } + } catch (IOException e) { + return "Error retrieving version information!"; + } + } +} diff --git a/src/main/resources/Languages/en-gb.yml b/src/main/resources/Languages/en-gb.yml index d886f3f9..0141f10b 100644 --- a/src/main/resources/Languages/en-gb.yml +++ b/src/main/resources/Languages/en-gb.yml @@ -10,8 +10,8 @@ teleporting_action_bar_cancelled: '§cTeleporting cancelled!' teleporting_please_stand_still: '§7Please stand still for that time.' home_deleted: '§aSuccessfully deleted §l%1%§r§a home.' warp_deleted: '§aSuccessfully deleted §l%1%§r§a warp.' -error_home_invalid: '§4Error: §cYou do not have a home with the name %1%' -error_warp_invalid: '§4Error: §cThere is no warp set with the name %1%' +error_home_invalid: '§4Error: §cYou do not have a home named "%1%"' +error_warp_invalid: '§4Error: §cThere is no warp set named "%1%"' error_invalid_syntax: '§4Error: §cIncorrect syntax. Usage:\n §o%1%' edit_home_title: '§aEdit home details for §l%1%§r§a:' edit_home_description: '• Description: §7%1%' @@ -32,11 +32,14 @@ edit_home_update_description: '§aChanged the description for §l%1%§r§a to "% edit_home_update_name: '§aSuccessfully changed your home''s name: %1% → §l%2%' error_no_homes_set: '§4Error: §cYou haven''t set any homes!' error_no_public_homes_set: '§4Error: §cThere aren''t any public homes set!' -private_home_list_page_top: '§a%1%''s Homes: (§l%2% - %3%§r§a of §l%4%§r§a)' -public_home_list_page_top: '§aPublic Homes: (§l%1% - %2%§r§a of §l%3%§r§a)' +error_no_warps_set: '§4Error: §cThere aren''t any warps set!' +private_home_list_page_top: '§a%1%''s Homes: (§l%2%-%3%§r§a of §l%4%§r§a)' +public_home_list_page_top: '§aPublic Homes: (§l%1%-%2%§r§a of §l%3%§r§a)' home_list_page_empty: '§7(There are no homes to list on this page)' +warp_list_page_top: '§aWarps: (§l%1%-%2%§r§a of §l%3%§r§a)' +warp_list_page_empty: '§7(There are no warps to list on this page)' error_public_home_invalid: '§4Error: §cCould not find a public home owned by %1% called %2%.' -error_set_home_invalid_characters: '§4Error: §cHome names must be alphanumeric (A-Z,0-9)' +error_set_home_invalid_characters: '§4Error: §cHome names must be alphanumeric (A-Z, 0-9)' error_set_home_invalid_length: '§4Error: §cHome names can only contain up to 16 characters!' error_set_warp_invalid_characters: '§4Error: §cWarp names must be alphanumeric (A-Z,0-9)' error_set_warp_invalid_length: '§4Error: §cWarp names can only contain up to 16 characters!' @@ -52,7 +55,7 @@ set_spawn_success: '§aUpdated /spawn command location for this server to your c error_spawn_undefined: '§4Error: §cThere is no spawn location defined on this server.' error_tpa_no_pending_request: '§4Error: §cYou do not have a pending teleport request.' error_player_not_found: '§4Error: §cCould not find %1%.' -return_by_death: 'Return to where you died? ' +return_by_death: '§7Return to where you died?:' tpa_you_accepted: '§aYou accepted %1%''s teleport request' tpa_you_declined: '§cYou declined %1%''s teleport request' tpa_has_accepted: '§a%1% accepted your teleport request' diff --git a/src/main/resources/Languages/zh-tw.yml b/src/main/resources/Languages/zh-tw.yml index 5f072b78..abcbac69 100644 --- a/src/main/resources/Languages/zh-tw.yml +++ b/src/main/resources/Languages/zh-tw.yml @@ -46,7 +46,7 @@ set_spawn_success: '§aUpdated /spawn command location for this server to your c error_spawn_undefined: '§4Error: §cThere is no spawn location defined on this server.' error_tpa_no_pending_request: '§4錯誤: §c你并沒有等待中的傳送請求.' error_player_not_found: '§4錯誤: §c找不到玩家->%1%.' -return_by_death: '返回到你死去的地方? ' +return_by_death: '返回到你死去的地方?:' tpa_you_accepted: '§a你已接受 %1% 的傳送請求' tpa_you_declined: '§c你已拒絕 %1% 的傳送請求' tpa_has_accepted: '§a%1% 接受了你的傳送請求' @@ -68,4 +68,5 @@ error_set_warp_name_taken: '§4Error: §cThere is already a warp set with that n warp_deleted: '§aSuccessfully deleted §l%1%§r§a warp.' error_warp_invalid: '§4Error: §cThere is no warp set with the name %1%' error_set_warp_invalid_characters: '§4Error: §cWarp names must be alphanumeric (A-Z,0-9)' -error_set_warp_invalid_length: '§4Error: §cWarp names can only contain up to 16 characters!' \ No newline at end of file +error_set_warp_invalid_length: '§4Error: §cWarp names can only contain up to 16 characters!' +error_no_warps_set: '§4Error: §cThere aren''t any warps set!' \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 13b4ebc0..dbd92e46 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -15,5 +15,8 @@ spawn_command: z: yaw: pitch: +rtp_command: + enabled: true + range: 25000 data_storage_options: storage_type: 'SQLite' \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 459aa478..d49bc63e 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -7,14 +7,211 @@ description: A powerful, intuitive and flexible teleportation suite website: timetobattle.net commands: home: + description: Teleport to one of your homes usage: /home - description: Return to a home + permission: huskhomes.home sethome: - usage: /sethome - description: Set a home + description: Set a new home with given name + usage: /sethome + permission: huskhomes.sethome delhome: - usage: /delhome - description: Delete a home + description: Delete a home you previously set + usage: /delhome + permission: huskhomes.delhome + edithome: + description: Edit one of your homes + usage: /edithome [arguments] + permission: huskhomes.edithome + warp: + description: Teleport to a warp + usage: /warp + permission: huskhomes.warp + setwarp: + description: Set a new warp with given name + usage: /setwarp + permission: huskhomes.setwarp + delwarp: + description: Delete a warp + usage: /delwarp + permission: huskhomes.delwarp + editwarp: + description: Edit a warp + usage: /editwarp [arguments] + permission: huskhomes.editwarp + back: + description: Return to your previous position, or where you died + usage: /back + permission: huskhomes.back homelist: - usage: /homelist [page no] - description: View a list of homes \ No newline at end of file + description: Get a list of your homes + usage: /homelist + permission: huskhomes.home + aliases: [homes, listhomes] + warplist: + description: View the list of warps + usage: /warplist + permission: huskhomes.warp + aliases: [warps, listwarps] + publichomelist: + description: View the list of public homes + usage: /publichomelist + permission: huskhomes.publichome + aliases: [phomes, phomelist, listphomes, listpublichomes] + publichome: + description: Teleport to a public home + usage: /publichome + permission: huskhomes.publichome + aliases: [phome] + tp: + description: Teleport to another player or location + usage: /tp OR /tp [world] [server] + permission: huskhomes.tp + aliases: [tpo] + tphere: + description: Teleport another player to you + usage: /tphere + permission: huskhomes.tp + aliases: [tpohere] + tpa: + description: Request to teleport to another player + usage: /tpa + permission: huskhomes.tprequest + aliases: [tprequest, tpask] + tpahere: + description: Request another player to teleport to you + usage: /tpahere + permission: huskhomes.tprequest + aliases: [tphererequest, tpaskhere] + tpaccept: + description: Accept teleport requests + usage: /tpaccept + permission: huskhomes.tprequest + aliases: [tpyes] + tpdeny: + description: Deny teleport requests + usage: /tpdeny + permission: huskhomes.tprequest + aliases: [tpno] + +permissions: + huskhomes.*: + description: Grants all HuskHomes permissions + children: + huskhomes.bypass_timers: true + huskhomes.commands: true + huskhomes.bypass_timers: + description: Bypass all timer restrictions. + children: + huskhomes.bypass_timer: true + huskhomes.rtp.bypass_cooldown: true + huskhomes.basic: + description: Access a basic pack of commands, good for Survival servers + children: + huskhomes.home: true + huskhomes.sethome: true + huskhomes.delhome: true + huskhomes.edithome: true + huskhomes.edithome.public: true + huskhomes.publichome: true + huskhomes.back: true + huskhomes.back.death: true + huskhomes.tprequest: true + huskhomes.spawn: true + huskhomes.warp: true + huskhomes.commands: + description: Access all HuskHomes commands + children: + huskhomes.home: true + huskhomes.sethome: true + huskhomes.delhome: true + huskhomes.edithome: true + huskhomes.edithome.public: true + huskhomes.publichome: true + huskhomes.back: true + huskhomes.back.death: true + huskhomes.tp: true + huskhomes.tprequest: true + huskhomes.spawn: true + huskhomes.spawn.set: true + huskhomes.warp: true + huskhomes.setwarp: true + huskhomes.delwarp: true + huskhomes.editwarp: true + huskhomes.rtp: true + huskhomes.about: true + huskhomes.version_checker: true + huskhomes.reload: true + huskhomes.bypass_timer: + description: Allows you to bypass the warmup teleportation timer + default: false + huskhomes.home: + description: Allows you to teleport to a home + default: true + huskhomes.sethome: + description: Allows you to set homes + default: true + huskhomes.delhome: + description: Allows you to delete a home + default: true + huskhomes.warp: + description: Allows you to teleport to a home + default: true + huskhomes.setwarp: + description: Allows you to set homes + default: false + huskhomes.delwarp: + description: Allows you to delete a home + default: false + huskhomes.publichome: + description: Allows you to teleport to public homes + default: true + huskhomes.edithome: + description: Allows you to edit home information + default: true + huskhomes.editwarp: + description: Allows you to edit home information + default: false + huskhomes.back: + description: Allows you to return to your last position + default: true + huskhomes.rtp: + description: Allows you to randomly teleport + default: false + huskhomes.rtp.bypass_cooldown: + description: Allows you to bypass the /rtp cooldown + default: false + children: + huskhomes.rtp: true + huskhomes.about: + description: View information about the plugin + default: true + huskhomes.reload: + description: Reload the plugin configuration + default: false + huskhomes.version_checker: + description: View if the plugin is up-to-date + default: false + huskhomes.tp: + description: Allows you to tp to another player + default: false + huskhomes.tprequest: + description: Allows you to tp to another player on request + default: true + huskhomes.back.death: + description: Allows you to return to where you died + default: true + children: + huskhomes.back: true + huskhomes.spawn: + description: Allows you to tp to spawn + default: true + huskhomes.spawn.set: + description: Allows you to set the spawn location + default: false + children: + huskhomes.spawn: true + huskhomes.edithome.public: + description: Allows you to make a public home + default: true + children: + huskhomes.edithome: true \ No newline at end of file