From b38f0fe356ee8f3dfc9ae72552cfbc158e5c099c Mon Sep 17 00:00:00 2001 From: William Date: Fri, 27 Aug 2021 12:58:01 +0100 Subject: [PATCH] Add ability for staff to visit and edit players homes, Close #66 --- .../william278/huskhomes2/EditingHandler.java | 24 +++-- .../api/events/PlayerHomeUpdateEvent.java | 3 +- .../api/events/PlayerSetHomeEvent.java | 3 +- .../api/events/PlayerSetWarpEvent.java | 3 +- .../api/events/PlayerWarpUpdateEvent.java | 3 +- .../huskhomes2/commands/DelHomeCommand.java | 12 ++- .../huskhomes2/commands/EditHomeCommand.java | 82 +++++++++-------- .../huskhomes2/commands/HomeCommand.java | 13 +-- .../huskhomes2/commands/HomeListCommand.java | 42 ++++++--- .../huskhomes2/commands/HuskHomesCommand.java | 4 +- .../commands/PublicHomeCommand.java | 46 +++++----- .../commands/PublicHomeListCommand.java | 2 +- .../huskhomes2/commands/WarpListCommand.java | 2 +- .../huskhomes2/config/Settings.java | 2 - .../huskhomes2/data/DataManager.java | 35 ++++++-- .../data/pluginmessage/PluginMessageType.java | 4 +- .../listeners/PluginMessageListener.java | 9 +- .../huskhomes2/teleport/SettingHandler.java | 87 ++++++++++--------- .../huskhomes2/teleport/TeleportRequest.java | 2 +- .../teleport/TeleportRequestHandler.java | 16 ++-- .../william278/huskhomes2/util/ChatList.java | 7 +- src/main/resources/languages/en-gb.yml | 32 ++++--- src/main/resources/languages/it-it.yml | 20 +++-- src/main/resources/languages/pl.yml | 22 ++--- src/main/resources/languages/zh-cn.yml | 20 +++-- src/main/resources/plugin.yml | 18 +++- 26 files changed, 315 insertions(+), 198 deletions(-) diff --git a/src/main/java/me/william278/huskhomes2/EditingHandler.java b/src/main/java/me/william278/huskhomes2/EditingHandler.java index fc7304e0..02be02a2 100644 --- a/src/main/java/me/william278/huskhomes2/EditingHandler.java +++ b/src/main/java/me/william278/huskhomes2/EditingHandler.java @@ -9,22 +9,30 @@ import org.bukkit.entity.Player; public class EditingHandler { public static void showEditHomeOptions(Player p, Home home) { - MessageManager.sendMessage(p, "edit_home_title", home.getName()); + if (home.getOwnerUsername().equalsIgnoreCase(p.getName())) { + MessageManager.sendMessage(p, "edit_home_title", home.getName()); + } else { + MessageManager.sendMessage(p, "edit_home_title_other", home.getOwnerUsername(), home.getName()); + } showPointDetails(p, home); if (!home.isPublic()) { - MessageManager.sendMessage(p, "edit_home_privacy_private"); + if (home.getOwnerUsername().equalsIgnoreCase(p.getName())) { + MessageManager.sendMessage(p, "edit_home_privacy_private"); + } else { + MessageManager.sendMessage(p, "edit_home_privacy_private_other", home.getOwnerUsername()); + } } else { MessageManager.sendMessage(p, "edit_home_privacy_public"); } if (p.hasPermission("huskhomes.edithome.public")) { if (home.isPublic()) { - MessageManager.sendMessage(p, "edit_home_options_make_private", home.getName()); + MessageManager.sendMessage(p, "edit_home_options_make_private", home.getOwnerUsername(), home.getName()); } else { - MessageManager.sendMessage(p, "edit_home_options_make_public", home.getName()); + MessageManager.sendMessage(p, "edit_home_options_make_public", home.getOwnerUsername(), home.getName()); } } else { - MessageManager.sendMessage(p, "edit_home_options", home.getName()); + MessageManager.sendMessage(p, "edit_home_options", home.getOwnerUsername(), home.getName()); } } @@ -36,7 +44,11 @@ public class EditingHandler { } private static void showPointDetails(Player p, SetPoint point) { - MessageManager.sendMessage(p, "edit_description", MineDown.escape(point.getDescription().replace("]", "]").replace("[", "[").replace("(", "❲").replace(")", "❳"))); + MessageManager.sendMessage(p, "edit_description", MineDown.escape(point.getDescription() + .replace("]", "\\]") + .replace("[", "\\[") + .replace("(", "\\(") + .replace(")", "\\)"))); MessageManager.sendMessage(p, "edit_timestamp", point.getFormattedCreationTime()); MessageManager.sendMessage(p, "edit_location", Integer.toString((int) point.getX()), diff --git a/src/main/java/me/william278/huskhomes2/api/events/PlayerHomeUpdateEvent.java b/src/main/java/me/william278/huskhomes2/api/events/PlayerHomeUpdateEvent.java index 8c9d5bf6..2e053f56 100644 --- a/src/main/java/me/william278/huskhomes2/api/events/PlayerHomeUpdateEvent.java +++ b/src/main/java/me/william278/huskhomes2/api/events/PlayerHomeUpdateEvent.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * An event, fired when a home is updated @@ -32,7 +33,7 @@ public class PlayerHomeUpdateEvent extends Event implements Cancellable { } @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return HANDLER_LIST; } diff --git a/src/main/java/me/william278/huskhomes2/api/events/PlayerSetHomeEvent.java b/src/main/java/me/william278/huskhomes2/api/events/PlayerSetHomeEvent.java index 07cd5b75..b8bb7786 100644 --- a/src/main/java/me/william278/huskhomes2/api/events/PlayerSetHomeEvent.java +++ b/src/main/java/me/william278/huskhomes2/api/events/PlayerSetHomeEvent.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * An event, fired when a player sets a new home @@ -29,7 +30,7 @@ public class PlayerSetHomeEvent extends Event implements Cancellable { } @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return HANDLER_LIST; } diff --git a/src/main/java/me/william278/huskhomes2/api/events/PlayerSetWarpEvent.java b/src/main/java/me/william278/huskhomes2/api/events/PlayerSetWarpEvent.java index e7816329..2005c96e 100644 --- a/src/main/java/me/william278/huskhomes2/api/events/PlayerSetWarpEvent.java +++ b/src/main/java/me/william278/huskhomes2/api/events/PlayerSetWarpEvent.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * An event, fired when a player sets a new warp @@ -29,7 +30,7 @@ public class PlayerSetWarpEvent extends Event implements Cancellable { } @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return HANDLER_LIST; } diff --git a/src/main/java/me/william278/huskhomes2/api/events/PlayerWarpUpdateEvent.java b/src/main/java/me/william278/huskhomes2/api/events/PlayerWarpUpdateEvent.java index 1058ae42..df32594a 100644 --- a/src/main/java/me/william278/huskhomes2/api/events/PlayerWarpUpdateEvent.java +++ b/src/main/java/me/william278/huskhomes2/api/events/PlayerWarpUpdateEvent.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * An event, fired when a warp is updated @@ -33,7 +34,7 @@ public class PlayerWarpUpdateEvent extends Event implements Cancellable { } @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return HANDLER_LIST; } diff --git a/src/main/java/me/william278/huskhomes2/commands/DelHomeCommand.java b/src/main/java/me/william278/huskhomes2/commands/DelHomeCommand.java index b9ddd780..e08fd695 100644 --- a/src/main/java/me/william278/huskhomes2/commands/DelHomeCommand.java +++ b/src/main/java/me/william278/huskhomes2/commands/DelHomeCommand.java @@ -2,6 +2,7 @@ package me.william278.huskhomes2.commands; import me.william278.huskhomes2.MessageManager; import me.william278.huskhomes2.teleport.SettingHandler; +import me.william278.huskhomes2.util.RegexUtil; import org.bukkit.command.Command; import org.bukkit.entity.Player; @@ -10,8 +11,15 @@ public class DelHomeCommand extends CommandBase { @Override protected void onCommand(Player p, Command command, String label, String[] args) { if (args.length == 1) { - String homeName = args[0]; - SettingHandler.deleteHome(p, homeName); + String homeArgument = args[0]; + if (RegexUtil.OWNER_NAME_PATTERN.matcher(homeArgument).matches()) { + String[] split = homeArgument.split("\\."); + final String ownerName = split[0]; + final String homeName = split[1]; + SettingHandler.deleteHome(p, ownerName, homeName); + } else { + SettingHandler.deleteHome(p, homeArgument); + } return; } else if (args.length == 2) { if (args[0].equalsIgnoreCase("all") && args[1].equalsIgnoreCase("confirm")) { diff --git a/src/main/java/me/william278/huskhomes2/commands/EditHomeCommand.java b/src/main/java/me/william278/huskhomes2/commands/EditHomeCommand.java index 013918af..a6f614d4 100644 --- a/src/main/java/me/william278/huskhomes2/commands/EditHomeCommand.java +++ b/src/main/java/me/william278/huskhomes2/commands/EditHomeCommand.java @@ -42,37 +42,49 @@ public class EditHomeCommand extends CommandBase implements TabCompleter { return; } - String homeName = args[0]; Connection connection = HuskHomes.getConnection(); Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + String homeName = args[0]; + String ownerName = p.getName(); + if (RegexUtil.OWNER_NAME_PATTERN.matcher(args[0]).matches()) { + ownerName = args[0].split("\\.")[0]; + homeName = args[0].split("\\.")[1]; + } + if (!ownerName.equalsIgnoreCase(p.getName())) { + if (!p.hasPermission("huskhomes.edithome.other")) { + MessageManager.sendMessage(p, "error_no_permission"); + return; + } + } + try { - if (!DataManager.homeExists(p.getName(), homeName, connection)) { + if (!DataManager.homeExists(ownerName, homeName, connection)) { MessageManager.sendMessage(p, "error_home_invalid", homeName); return; } + Home home = DataManager.getHome(ownerName, homeName, connection); + assert home != null; if (args.length == 1) { - Home home = DataManager.getHome(p.getName(), homeName, connection); - assert home != null; EditingHandler.showEditHomeOptions(p, home); return; } switch (args[1].toLowerCase(Locale.ENGLISH)) { - case "location" -> editHomeLocation(p, homeName, connection); - case "public" -> editHomePrivacy(p, homeName, true, connection); - case "private" -> editHomePrivacy(p, homeName, false, connection); + case "location" -> editHomeLocation(p, home, connection); + case "public" -> editHomePrivacy(p, home, true, connection); + case "private" -> editHomePrivacy(p, home, false, connection); case "description" -> { if (args.length >= 3) { // Get the new description - editHomeDescription(p, homeName, buildDescription(args), connection); + editHomeDescription(p, home, buildDescription(args), connection); } else { MessageManager.sendMessage(p, "error_invalid_syntax", "/edithome description "); } } case "rename" -> { if (args.length >= 3) { - editHomeName(p, homeName, args[2], connection); + editHomeName(p, home, args[2], connection); } else { MessageManager.sendMessage(p, "error_invalid_syntax", "/edithome rename "); } @@ -97,11 +109,10 @@ public class EditHomeCommand extends CommandBase implements TabCompleter { return newDescription.toString(); } - private void editHomeLocation(Player p, String homeName, Connection connection) throws SQLException { + private void editHomeLocation(Player p, Home locationMovedHome, Connection connection) throws SQLException { Location newLocation = p.getLocation(); TeleportationPoint newTeleportLocation = new TeleportationPoint(newLocation, HuskHomes.getSettings().getServerID()); - Home locationMovedHome = DataManager.getHome(p.getName(), homeName, connection); assert locationMovedHome != null; PlayerRelocateHomeEvent relocateHomeEvent = new PlayerRelocateHomeEvent(p, locationMovedHome, newTeleportLocation); Bukkit.getScheduler().runTask(plugin, () -> { @@ -112,11 +123,11 @@ public class EditHomeCommand extends CommandBase implements TabCompleter { try { // Remove old marker on map if (locationMovedHome.isPublic() && HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showPublicHomesOnMap()) { - HuskHomes.getMap().removePublicHomeMarker(homeName, p.getName()); + HuskHomes.getMap().removePublicHomeMarker(locationMovedHome.getName(), locationMovedHome.getOwnerUsername()); } - DataManager.updateHomeLocation(p.getName(), homeName, newLocation, connection); - MessageManager.sendMessage(p, "edit_home_update_location", homeName); + DataManager.updateHomeLocation(locationMovedHome.getOwnerUsername(), locationMovedHome.getName(), newLocation, connection); + MessageManager.sendMessage(p, "edit_home_update_location", locationMovedHome.getName()); // Add new updated marker on map locationMovedHome.setLocation(newLocation, HuskHomes.getSettings().getServerID()); @@ -129,8 +140,7 @@ public class EditHomeCommand extends CommandBase implements TabCompleter { }); } - private void editHomeDescription(Player p, String homeName, String newDescriptionString, Connection connection) throws SQLException { - Home descriptionChangedHome = DataManager.getHome(p.getName(), homeName, connection); + private void editHomeDescription(Player p, Home descriptionChangedHome, String newDescriptionString, Connection connection) throws SQLException { assert descriptionChangedHome != null; PlayerChangeHomeDescriptionEvent changeHomeDescriptionEvent = new PlayerChangeHomeDescriptionEvent(p, descriptionChangedHome, newDescriptionString); Bukkit.getScheduler().runTask(plugin, () -> { @@ -154,11 +164,11 @@ public class EditHomeCommand extends CommandBase implements TabCompleter { // Remove old marker if using a map integration if (descriptionChangedHome.isPublic() && HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showPublicHomesOnMap()) { - HuskHomes.getMap().removePublicHomeMarker(homeName, p.getName()); + HuskHomes.getMap().removePublicHomeMarker(descriptionChangedHome.getName(), descriptionChangedHome.getOwnerUsername()); } // Update description - DataManager.updateHomeDescription(p.getName(), homeName, newDescriptionString, connection); + DataManager.updateHomeDescription(descriptionChangedHome.getOwnerUsername(), descriptionChangedHome.getName(), newDescriptionString, connection); // Add new marker if using a map integration descriptionChangedHome.setDescription(newDescriptionString); @@ -167,7 +177,7 @@ public class EditHomeCommand extends CommandBase implements TabCompleter { } // Confirmation message - MessageManager.sendMessage(p, "edit_home_update_description", homeName, MineDown.escape(newDescriptionString.replace("]", "]").replace("[", "[").replace("(", "❲").replace(")", "❳"))); + MessageManager.sendMessage(p, "edit_home_update_description", descriptionChangedHome.getName(), MineDown.escape(newDescriptionString.replace("]", "]").replace("[", "[").replace("(", "❲").replace(")", "❳"))); } catch (SQLException e) { plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred editing a home description."); } @@ -175,7 +185,7 @@ public class EditHomeCommand extends CommandBase implements TabCompleter { }); } - private void editHomeName(Player p, String homeName, String newName, Connection connection) throws SQLException { + private void editHomeName(Player p, Home renamedHome, String newName, Connection connection) throws SQLException { if (newName.length() > 16) { MessageManager.sendMessage(p, "error_set_home_invalid_length"); return; @@ -184,12 +194,11 @@ public class EditHomeCommand extends CommandBase implements TabCompleter { MessageManager.sendMessage(p, "error_set_home_invalid_characters"); return; } - if (DataManager.homeExists(p.getName(), newName, connection)) { + if (DataManager.homeExists(renamedHome.getOwnerUsername(), newName, connection)) { MessageManager.sendMessage(p, "error_set_home_name_taken"); return; } - Home renamedHome = DataManager.getHome(p.getName(), homeName, connection); - assert renamedHome != null; + final String oldHomeName = renamedHome.getName(); PlayerRenameHomeEvent renameHomeEvent = new PlayerRenameHomeEvent(p, renamedHome, newName); Bukkit.getScheduler().runTask(plugin, () -> { Bukkit.getPluginManager().callEvent(renameHomeEvent); @@ -200,19 +209,19 @@ public class EditHomeCommand extends CommandBase implements TabCompleter { try { if (renamedHome.isPublic()) { if (HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showPublicHomesOnMap()) { - HuskHomes.getMap().removePublicHomeMarker(homeName, p.getName()); + HuskHomes.getMap().removePublicHomeMarker(oldHomeName, renamedHome.getOwnerUsername()); } - DataManager.updateHomeName(p.getName(), homeName, newName, connection); + DataManager.updateHomeName(renamedHome.getOwnerUsername(), oldHomeName, newName, connection); PublicHomeCommand.updatePublicHomeTabCache(); } else { - DataManager.updateHomeName(p.getName(), homeName, newName, connection); + DataManager.updateHomeName(renamedHome.getOwnerUsername(), oldHomeName, newName, connection); } renamedHome.setName(newName); if (renamedHome.isPublic() && HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showPublicHomesOnMap()) { HuskHomes.getMap().addPublicHomeMarker(renamedHome); } HomeCommand.Tab.updatePlayerHomeCache(p); - MessageManager.sendMessage(p, "edit_home_update_name", homeName, newName); + MessageManager.sendMessage(p, "edit_home_update_name", oldHomeName, newName); } catch (SQLException e) { plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred editing a home name."); } @@ -220,8 +229,7 @@ public class EditHomeCommand extends CommandBase implements TabCompleter { }); } - private void editHomePrivacy(Player p, String homeName, boolean makingHomePublic, Connection connection) throws SQLException { - Home privacyUpdatingHome = DataManager.getHome(p.getName(), homeName, connection); + private void editHomePrivacy(Player p, Home privacyUpdatingHome, boolean makingHomePublic, Connection connection) throws SQLException { assert privacyUpdatingHome != null; if (makingHomePublic) { // Making a private home @@ -233,13 +241,13 @@ public class EditHomeCommand extends CommandBase implements TabCompleter { MessageManager.sendMessage(p, "error_insufficient_funds", VaultIntegration.format(publicHomeCost)); return; } else { - MessageManager.sendMessage(p, "edit_home_privacy_public_success_economy", homeName, VaultIntegration.format(publicHomeCost)); + MessageManager.sendMessage(p, "edit_home_privacy_public_success_economy", privacyUpdatingHome.getName(), VaultIntegration.format(publicHomeCost)); } } else { - MessageManager.sendMessage(p, "edit_home_privacy_public_success", homeName); + MessageManager.sendMessage(p, "edit_home_privacy_public_success", privacyUpdatingHome.getName()); } } else { - MessageManager.sendMessage(p, "edit_home_privacy_public_success", homeName); + MessageManager.sendMessage(p, "edit_home_privacy_public_success", privacyUpdatingHome.getName()); } PlayerMakeHomePublicEvent makeHomePublicEvent = new PlayerMakeHomePublicEvent(p, privacyUpdatingHome); Bukkit.getScheduler().runTask(plugin, () -> { @@ -249,7 +257,7 @@ public class EditHomeCommand extends CommandBase implements TabCompleter { } Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { try { - DataManager.updateHomePrivacy(p.getName(), homeName, true, connection); + DataManager.updateHomePrivacy(privacyUpdatingHome.getOwnerUsername(), privacyUpdatingHome.getName(), true, connection); PublicHomeCommand.updatePublicHomeTabCache(); if (HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showPublicHomesOnMap()) { HuskHomes.getMap().addPublicHomeMarker(privacyUpdatingHome); @@ -260,7 +268,7 @@ public class EditHomeCommand extends CommandBase implements TabCompleter { }); }); } else { - MessageManager.sendMessage(p, "error_edit_home_privacy_already_public", homeName); + MessageManager.sendMessage(p, "error_edit_home_privacy_already_public", privacyUpdatingHome.getName()); } } else { if (privacyUpdatingHome.isPublic()) { @@ -272,8 +280,8 @@ public class EditHomeCommand extends CommandBase implements TabCompleter { } Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { try { - DataManager.updateHomePrivacy(p.getName(), homeName, false, connection); - MessageManager.sendMessage(p, "edit_home_privacy_private_success", homeName); + DataManager.updateHomePrivacy(privacyUpdatingHome.getOwnerUsername(), privacyUpdatingHome.getName(), false, connection); + MessageManager.sendMessage(p, "edit_home_privacy_private_success", privacyUpdatingHome.getName()); if (HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showPublicHomesOnMap()) { HuskHomes.getMap().removePublicHomeMarker(privacyUpdatingHome.getName(), privacyUpdatingHome.getOwnerUsername()); } @@ -284,7 +292,7 @@ public class EditHomeCommand extends CommandBase implements TabCompleter { }); }); } else { - MessageManager.sendMessage(p, "error_edit_home_privacy_already_private", homeName); + MessageManager.sendMessage(p, "error_edit_home_privacy_already_private", privacyUpdatingHome.getName()); } } } diff --git a/src/main/java/me/william278/huskhomes2/commands/HomeCommand.java b/src/main/java/me/william278/huskhomes2/commands/HomeCommand.java index 8eec2106..ebf6b518 100644 --- a/src/main/java/me/william278/huskhomes2/commands/HomeCommand.java +++ b/src/main/java/me/william278/huskhomes2/commands/HomeCommand.java @@ -5,6 +5,7 @@ import me.william278.huskhomes2.MessageManager; import me.william278.huskhomes2.data.DataManager; import me.william278.huskhomes2.teleport.TeleportManager; import me.william278.huskhomes2.teleport.points.Home; +import me.william278.huskhomes2.util.RegexUtil; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -33,12 +34,14 @@ public class HomeCommand extends CommandBase { Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { try { if (args.length == 1) { - String homeName = args[0]; - if (DataManager.homeExists(p, homeName, connection)) { - Home home = DataManager.getHome(p.getName(), homeName, connection); + String homeArgument = args[0]; + if (RegexUtil.OWNER_NAME_PATTERN.matcher(homeArgument).matches()) { + PublicHomeCommand.queueHomeTeleport(p, homeArgument); + } else if (DataManager.homeExists(p, homeArgument, connection)) { + Home home = DataManager.getHome(p.getName(), homeArgument, connection); TeleportManager.queueTimedTeleport(p, home, connection); } else { - MessageManager.sendMessage(p, "error_home_invalid", homeName); + MessageManager.sendMessage(p, "error_home_invalid", homeArgument); } } else { List homes = DataManager.getPlayerHomes(p.getName(), connection); @@ -47,7 +50,7 @@ public class HomeCommand extends CommandBase { TeleportManager.queueTimedTeleport(p, homes.get(0), connection); return; } - HomeListCommand.displayPlayerHomeList(p, 1); + HomeListCommand.displayPlayerHomeList(p, p.getName(), 1); } } catch (SQLException e) { plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred teleporting home.", e); diff --git a/src/main/java/me/william278/huskhomes2/commands/HomeListCommand.java b/src/main/java/me/william278/huskhomes2/commands/HomeListCommand.java index cb54a678..49db0922 100644 --- a/src/main/java/me/william278/huskhomes2/commands/HomeListCommand.java +++ b/src/main/java/me/william278/huskhomes2/commands/HomeListCommand.java @@ -23,22 +23,40 @@ public class HomeListCommand extends CommandBase { @Override protected void onCommand(Player p, Command command, String label, String[] args) { int pageNo = 1; - if (args.length == 1) { + String homeOwnerName = p.getName(); + if (args.length == 1 || args.length == 2) { try { pageNo = Integer.parseInt(args[0]); - } catch (Exception e) { - MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage()); - return; + } catch (NumberFormatException numberFormatException) { + homeOwnerName = args[0]; + if (args.length == 2) { + try { + pageNo = Integer.parseInt(args[1]); + } catch (NumberFormatException numberFormatException2) { + MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage()); + return; + } + } } } - displayPlayerHomeList(p, pageNo); + displayPlayerHomeList(p, homeOwnerName, pageNo); } - public static void displayPlayerHomeList(Player player, int pageNumber) { + public static void displayPlayerHomeList(Player player, String homeOwnerName, int pageNumber) { Connection connection = HuskHomes.getConnection(); Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + if (!player.getName().equalsIgnoreCase(homeOwnerName)) { + if (!player.hasPermission("huskhomes.home.other")) { + MessageManager.sendMessage(player, "error_no_permission"); + return; + } + } try { - List homes = DataManager.getPlayerHomes(player.getName(), connection); + if (!DataManager.playerExists(homeOwnerName, connection)) { + MessageManager.sendMessage(player, "error_invalid_player"); + return; + } + List homes = DataManager.getPlayerHomes(homeOwnerName, connection); if (homes.isEmpty()) { MessageManager.sendMessage(player, "error_no_homes_set"); return; @@ -46,7 +64,11 @@ public class HomeListCommand extends CommandBase { ArrayList homeList = new ArrayList<>(); for (Home home : homes) { - homeList.add(MessageManager.getRawMessage("home_list_item", home.getName(), MineDown.escape(home.getDescription().replace("]", "]").replace("[", "[").replace("(", "❲").replace(")", "❳")))); + homeList.add(MessageManager.getRawMessage("home_list_item", home.getName(), home.getOwnerUsername(), MineDown.escape(home.getDescription() + .replace("]", "\\]") + .replace("[", "\\[") + .replace("(", "\\(") + .replace(")", "\\)")))); } final int itemsPerPage = HuskHomes.getSettings().getPrivateHomesPerPage(); @@ -56,13 +78,13 @@ public class HomeListCommand extends CommandBase { homeUpperBound = homeList.size(); } - ChatList homeChatList = new ChatList(homeList, itemsPerPage, "/huskhomes:homelist", MessageManager.getRawMessage("list_item_divider")); + ChatList homeChatList = new ChatList(homeList, itemsPerPage, "/huskhomes:homelist " + homeOwnerName, MessageManager.getRawMessage("list_item_divider"), true); if (homeChatList.doesNotContainPage(pageNumber)) { MessageManager.sendMessage(player, "error_invalid_page_number"); return; } - MessageManager.sendMessage(player, "private_home_list_page_top", player.getName(), Integer.toString(homeLowerBound + 1), Integer.toString(homeUpperBound), Integer.toString(homeList.size())); + MessageManager.sendMessage(player, "private_home_list_page_top", homeOwnerName, Integer.toString(homeLowerBound + 1), Integer.toString(homeUpperBound), Integer.toString(homeList.size())); player.spigot().sendMessage(homeChatList.getPage(pageNumber)); } catch (SQLException e) { plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred!", e); diff --git a/src/main/java/me/william278/huskhomes2/commands/HuskHomesCommand.java b/src/main/java/me/william278/huskhomes2/commands/HuskHomesCommand.java index 34347b27..11ac4fee 100644 --- a/src/main/java/me/william278/huskhomes2/commands/HuskHomesCommand.java +++ b/src/main/java/me/william278/huskhomes2/commands/HuskHomesCommand.java @@ -52,7 +52,7 @@ public class HuskHomesCommand extends CommandBase implements TabCompleter { } MessageManager.sendMessage(player, "command_list_header"); - ChatList helpList = new ChatList(commandDisplay, 10, "/huskhomes help", "\n"); + ChatList helpList = new ChatList(commandDisplay, 10, "/huskhomes help", "\n", false); if (helpList.doesNotContainPage(pageNumber)) { MessageManager.sendMessage(player, "error_invalid_page_number"); return; @@ -176,7 +176,7 @@ public class HuskHomesCommand extends CommandBase implements TabCompleter { final static String[] COMMAND_TAB_ARGS = {"help", "about", "update", "reload"}; @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, Command command, @NotNull String alias, String[] args) { Player p = (Player) sender; if (command.getPermission() != null) { if (!p.hasPermission(command.getPermission())) { diff --git a/src/main/java/me/william278/huskhomes2/commands/PublicHomeCommand.java b/src/main/java/me/william278/huskhomes2/commands/PublicHomeCommand.java index d887228c..afe422fd 100644 --- a/src/main/java/me/william278/huskhomes2/commands/PublicHomeCommand.java +++ b/src/main/java/me/william278/huskhomes2/commands/PublicHomeCommand.java @@ -47,6 +47,30 @@ public class PublicHomeCommand extends CommandBase implements TabCompleter { }); } + public static void queueHomeTeleport(Player p, String publicHome) { + Connection connection = HuskHomes.getConnection(); + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + try { + String[] split = publicHome.split("\\."); + String ownerName = split[0]; + String homeName = split[1]; + if (DataManager.homeExists(ownerName, homeName, connection)) { + Home home = DataManager.getHome(ownerName, homeName, connection); + assert home != null; + if (home.isPublic() || p.getName().equalsIgnoreCase(ownerName) || p.hasPermission("huskhomes.home.other")) { + TeleportManager.queueTimedTeleport(p, home, connection); + } else { + MessageManager.sendMessage(p, "error_public_home_invalid", ownerName, homeName); + } + } else { + MessageManager.sendMessage(p, "error_public_home_invalid", ownerName, homeName); + } + } catch (SQLException e) { + plugin.getLogger().log(Level.SEVERE, "An exception occurred teleporting to a public home."); + } + }); + } + @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (!(sender instanceof Player p)) { @@ -59,27 +83,7 @@ public class PublicHomeCommand extends CommandBase implements TabCompleter { } String publicHome = args[0]; if (RegexUtil.OWNER_NAME_PATTERN.matcher(publicHome).matches()) { - Connection connection = HuskHomes.getConnection(); - Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { - try { - String[] split = publicHome.split("\\."); - String ownerName = split[0]; - String homeName = split[1]; - if (DataManager.homeExists(ownerName, homeName, connection)) { - Home home = DataManager.getHome(ownerName, homeName, connection); - assert home != null; - if (home.isPublic()) { - TeleportManager.queueTimedTeleport(p, home, connection); - } else { - MessageManager.sendMessage(p, "error_public_home_invalid", ownerName, homeName); - } - } else { - MessageManager.sendMessage(p, "error_public_home_invalid", ownerName, homeName); - } - } catch (SQLException e) { - plugin.getLogger().log(Level.SEVERE, "An exception occurred teleporting to a public home."); - } - }); + queueHomeTeleport(p, publicHome); } else { MessageManager.sendMessage(p, "error_invalid_syntax", command.getUsage()); } diff --git a/src/main/java/me/william278/huskhomes2/commands/PublicHomeListCommand.java b/src/main/java/me/william278/huskhomes2/commands/PublicHomeListCommand.java index 386d8507..63d4ed6c 100644 --- a/src/main/java/me/william278/huskhomes2/commands/PublicHomeListCommand.java +++ b/src/main/java/me/william278/huskhomes2/commands/PublicHomeListCommand.java @@ -54,7 +54,7 @@ public class PublicHomeListCommand extends CommandBase { homeUpperBound = publicHomeList.size(); } - ChatList homeChatList = new ChatList(publicHomeList, itemsPerPage, "/huskhomes:publichomelist", MessageManager.getRawMessage("list_item_divider")); + ChatList homeChatList = new ChatList(publicHomeList, itemsPerPage, "/huskhomes:publichomelist", MessageManager.getRawMessage("list_item_divider"), true); if (homeChatList.doesNotContainPage(pageNumber)) { MessageManager.sendMessage(player, "error_invalid_page_number"); return; diff --git a/src/main/java/me/william278/huskhomes2/commands/WarpListCommand.java b/src/main/java/me/william278/huskhomes2/commands/WarpListCommand.java index 804f67d2..2a06e39d 100644 --- a/src/main/java/me/william278/huskhomes2/commands/WarpListCommand.java +++ b/src/main/java/me/william278/huskhomes2/commands/WarpListCommand.java @@ -62,7 +62,7 @@ public class WarpListCommand extends CommandBase { warpsUpperBound = warpList.size(); } - ChatList homeChatList = new ChatList(warpList, itemsPerPage, "/huskhomes:warplist", MessageManager.getRawMessage("list_item_divider")); + ChatList homeChatList = new ChatList(warpList, itemsPerPage, "/huskhomes:warplist", MessageManager.getRawMessage("list_item_divider"), true); if (homeChatList.doesNotContainPage(pageNumber)) { MessageManager.sendMessage(player, "error_invalid_page_number"); return; diff --git a/src/main/java/me/william278/huskhomes2/config/Settings.java b/src/main/java/me/william278/huskhomes2/config/Settings.java index b6762594..dba237e2 100644 --- a/src/main/java/me/william278/huskhomes2/config/Settings.java +++ b/src/main/java/me/william278/huskhomes2/config/Settings.java @@ -7,8 +7,6 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; -import java.util.Locale; - public class Settings { private final Plugin plugin; diff --git a/src/main/java/me/william278/huskhomes2/data/DataManager.java b/src/main/java/me/william278/huskhomes2/data/DataManager.java index f12db97a..0f41d595 100644 --- a/src/main/java/me/william278/huskhomes2/data/DataManager.java +++ b/src/main/java/me/william278/huskhomes2/data/DataManager.java @@ -1,6 +1,7 @@ package me.william278.huskhomes2.data; import me.william278.huskhomes2.HuskHomes; +import me.william278.huskhomes2.MessageManager; import me.william278.huskhomes2.teleport.points.Home; import me.william278.huskhomes2.teleport.points.TeleportationPoint; import me.william278.huskhomes2.teleport.points.Warp; @@ -561,6 +562,17 @@ public class DataManager { } } + public static Boolean playerExists(String username, Connection connection) throws SQLException { + try (PreparedStatement statement = connection.prepareStatement( + "SELECT * FROM " + HuskHomes.getSettings().getPlayerDataTable() + " WHERE `username`=?;")) { + statement.setString(1, username); + ResultSet resultSet = statement.executeQuery(); + final boolean exists = resultSet.next(); + statement.close(); + return exists; + } + } + public static TeleportationPoint getTeleportationPoint(Integer locationID, Connection connection) throws SQLException, IllegalArgumentException { try (PreparedStatement statement = connection.prepareStatement( "SELECT * FROM " + HuskHomes.getSettings().getLocationsDataTable() + " WHERE `location_id`=?;")) { @@ -802,16 +814,23 @@ public class DataManager { addHome(home, p.getUniqueId(), connection); } - public static void deleteHome(String homeName, Player p, Connection connection) throws SQLException { - Integer playerID = getPlayerId(p.getUniqueId(), connection); - if (playerID != null) { - deleteHomeTeleportLocation(playerID, homeName, connection); - deleteHome(homeName, p.getName(), connection); - } else { - Bukkit.getLogger().warning("Player ID returned null when deleting a home"); - } + public static void deleteHome(Player p, String homeName, Connection connection) throws SQLException { + deleteHome(p, p.getName(), homeName, connection); } + public static void deleteHome(Player deleter, String ownerName, String homeName, Connection connection) throws SQLException { + if (!homeExists(ownerName, homeName, connection)) { + MessageManager.sendMessage(deleter, "error_invalid_home"); + return; + } + Integer playerID = getPlayerId(ownerName, connection); + if (playerID != null) { + deleteHomeTeleportLocation(playerID, homeName, connection); + deleteHome(homeName, ownerName, connection); + } else { + MessageManager.sendMessage(deleter, "error_invalid_player"); + } + } public static void createPlayer(Player p, Connection connection) throws SQLException { addPlayer(p, connection); diff --git a/src/main/java/me/william278/huskhomes2/data/pluginmessage/PluginMessageType.java b/src/main/java/me/william278/huskhomes2/data/pluginmessage/PluginMessageType.java index 8cc475ef..f0dbab13 100644 --- a/src/main/java/me/william278/huskhomes2/data/pluginmessage/PluginMessageType.java +++ b/src/main/java/me/william278/huskhomes2/data/pluginmessage/PluginMessageType.java @@ -4,9 +4,9 @@ public enum PluginMessageType { SET_TP_DESTINATION, CONFIRM_DESTINATION_SET, TPA_REQUEST, - TPAHERE_REQUEST, + TPA_HERE_REQUEST, TPA_REQUEST_REPLY, - TPAHERE_REQUEST_REPLY, + TPA_HERE_REQUEST_REPLY, TELEPORT_TO_ME, GET_PLAYER_LIST, RETURN_PLAYER_LIST diff --git a/src/main/java/me/william278/huskhomes2/listeners/PluginMessageListener.java b/src/main/java/me/william278/huskhomes2/listeners/PluginMessageListener.java index e00bb3a2..f8134f58 100644 --- a/src/main/java/me/william278/huskhomes2/listeners/PluginMessageListener.java +++ b/src/main/java/me/william278/huskhomes2/listeners/PluginMessageListener.java @@ -14,6 +14,7 @@ import me.william278.huskhomes2.teleport.TeleportRequestHandler; import me.william278.huskhomes2.teleport.points.TeleportationPoint; import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; import java.io.ByteArrayInputStream; import java.io.DataInputStream; @@ -52,10 +53,10 @@ public class PluginMessageListener implements org.bukkit.plugin.messaging.Plugin } } } - case TPAHERE_REQUEST -> { + case TPA_HERE_REQUEST -> { if (!VanishChecker.isVanished(recipient)) { if (!HuskHomes.isIgnoringTeleportRequests(recipient.getUniqueId())) { - TeleportRequestHandler.teleportRequests.put(recipient, new TeleportRequest(pluginMessage.getMessageData(), TeleportRequest.RequestType.TPAHERE)); + TeleportRequestHandler.teleportRequests.put(recipient, new TeleportRequest(pluginMessage.getMessageData(), TeleportRequest.RequestType.TPA_HERE)); MessageManager.sendMessage(recipient, "tpahere_request_ask", pluginMessage.getMessageData()); MessageManager.sendMessage(recipient, "teleport_request_options"); } @@ -77,7 +78,7 @@ public class PluginMessageListener implements org.bukkit.plugin.messaging.Plugin MessageManager.sendMessage(recipient, "tpa_has_declined", tpaReplierName); } } - case TPAHERE_REQUEST_REPLY -> { + case TPA_HERE_REQUEST_REPLY -> { final String tpaHereReplierName = pluginMessage.getMessageDataItems()[0]; final boolean tpaHereAccepted = Boolean.parseBoolean(pluginMessage.getMessageDataItems()[1]); if (tpaHereAccepted) { @@ -114,7 +115,7 @@ public class PluginMessageListener implements org.bukkit.plugin.messaging.Plugin } @Override @SuppressWarnings("UnstableApiUsage") - public void onPluginMessageReceived(String channel, Player player, byte[] message) { + public void onPluginMessageReceived(String channel, @NotNull Player player, byte[] message) { // Return if the message is not a Bungee message if (!channel.equals("BungeeCord")) { return; diff --git a/src/main/java/me/william278/huskhomes2/teleport/SettingHandler.java b/src/main/java/me/william278/huskhomes2/teleport/SettingHandler.java index c6543668..6b90718a 100644 --- a/src/main/java/me/william278/huskhomes2/teleport/SettingHandler.java +++ b/src/main/java/me/william278/huskhomes2/teleport/SettingHandler.java @@ -55,12 +55,8 @@ public class SettingHandler { }); } else { switch (setHomeConditions.getConditionsNotMetReason()) { - case "error_set_home_maximum_homes" -> { - MessageManager.sendMessage(player, "error_set_home_maximum_homes", Integer.toString(Home.getSetHomeLimit(player))); - } - case "error_insufficient_funds" -> { - MessageManager.sendMessage(player, "error_insufficient_funds", VaultIntegration.format(HuskHomes.getSettings().getSetHomeCost())); - } + case "error_set_home_maximum_homes" -> MessageManager.sendMessage(player, "error_set_home_maximum_homes", Integer.toString(Home.getSetHomeLimit(player))); + case "error_insufficient_funds" -> MessageManager.sendMessage(player, "error_insufficient_funds", VaultIntegration.format(HuskHomes.getSettings().getSetHomeCost())); default -> MessageManager.sendMessage(player, setHomeConditions.getConditionsNotMetReason()); } } @@ -76,7 +72,7 @@ public class SettingHandler { try { if (SettingHandler.setCrossServerSpawnWarp(p.getLocation(), p, connection)) { SettingHandler.setSpawnLocation(p.getLocation()); - p.getLocation().getWorld().setSpawnLocation(p.getLocation()); + p.getWorld().setSpawnLocation(p.getLocation()); MessageManager.sendMessage(p, "set_spawn_success"); } } catch (SQLException e) { @@ -158,19 +154,7 @@ public class SettingHandler { int homesDeleted = 0; for (Home home : DataManager.getPlayerHomes(player.getName(), connection)) { if (home != null) { - String homeName = home.getName(); - if (home.isPublic()) { - // Delete Dynmap marker if it exists & if the home is public - if (HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showPublicHomesOnMap()) { - HuskHomes.getMap().removePublicHomeMarker(homeName, player.getName()); - } - PlayerDeleteHomeEvent event = new PlayerDeleteHomeEvent(player, home); - Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getPluginManager().callEvent(event)); - DataManager.deleteHome(homeName, player, connection); - PublicHomeCommand.updatePublicHomeTabCache(); - } else { - DataManager.deleteHome(homeName, player, connection); - } + deleteHomeData(player, home, connection); } homesDeleted++; } @@ -187,28 +171,35 @@ public class SettingHandler { }); } - // Delete a home public static void deleteHome(Player player, String homeName) { + deleteHome(player, player.getName(), homeName); + } + + // Delete a home + public static void deleteHome(Player player, String ownerName, String homeName) { + if (ownerName.equalsIgnoreCase(player.getName())) { + if (!player.hasPermission("huskhomes.delhome.other")) { + MessageManager.sendMessage(player, "error_no_permission"); + return; + } + } Connection connection = HuskHomes.getConnection(); Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { try { - if (DataManager.homeExists(player, homeName, connection)) { - Home home = DataManager.getHome(player.getName(), homeName, connection); + if (DataManager.homeExists(ownerName, homeName, connection)) { + Home home = DataManager.getHome(ownerName, homeName, connection); if (home != null) { - if (home.isPublic()) { - // Delete Dynmap marker if it exists & if the home is public - if (HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showPublicHomesOnMap()) { - HuskHomes.getMap().removePublicHomeMarker(homeName, player.getName()); - } - PlayerDeleteHomeEvent event = new PlayerDeleteHomeEvent(player, home); - Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getPluginManager().callEvent(event)); - DataManager.deleteHome(homeName, player, connection); - PublicHomeCommand.updatePublicHomeTabCache(); + deleteHomeData(player, home, connection); + if (home.getOwnerUsername().equalsIgnoreCase(player.getName())) { + HomeCommand.Tab.updatePlayerHomeCache(player); + MessageManager.sendMessage(player, "home_deleted", homeName); } else { - DataManager.deleteHome(homeName, player, connection); + Player homeOwner = Bukkit.getPlayerExact(ownerName); + if (homeOwner != null) { + HomeCommand.Tab.updatePlayerHomeCache(homeOwner); + } + MessageManager.sendMessage(player, "home_deleted_other", ownerName, homeName); } - HomeCommand.Tab.updatePlayerHomeCache(player); - MessageManager.sendMessage(player, "home_deleted", homeName); } else { MessageManager.sendMessage(player, "error_home_invalid", homeName); } @@ -218,7 +209,7 @@ public class SettingHandler { MessageManager.sendMessage(player, "error_no_permission"); return; } - if (DataManager.getPlayerHomes(player.getName(), connection).size() == 0) { + if (DataManager.getPlayerHomes(ownerName, connection).size() == 0) { MessageManager.sendMessage(player, "error_no_homes_set"); return; } @@ -233,6 +224,21 @@ public class SettingHandler { }); } + private static void deleteHomeData(Player player, Home home, Connection connection) throws SQLException { + if (home.isPublic()) { + // Delete Map marker if needed & if the home is public + if (HuskHomes.getSettings().doMapIntegration() && HuskHomes.getSettings().showPublicHomesOnMap()) { + HuskHomes.getMap().removePublicHomeMarker(home.getName(), home.getOwnerUsername()); + } + PlayerDeleteHomeEvent event = new PlayerDeleteHomeEvent(player, home); + Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getPluginManager().callEvent(event)); + DataManager.deleteHome(player, home.getOwnerUsername(), home.getName(), connection); + PublicHomeCommand.updatePublicHomeTabCache(); + } else { + DataManager.deleteHome(player, home.getOwnerUsername(), home.getName(), connection); + } + } + // Delete all server warps public static void deleteAllWarps(Player player) { Connection connection = HuskHomes.getConnection(); @@ -303,6 +309,10 @@ public class SettingHandler { // Set spawn location public static void setSpawnLocation(Location location) { + // Don't set the spawn location in an invalid world + if (location.getWorld() == null) { + return; + } Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { // Write the new location to config FileConfiguration config = plugin.getConfig(); @@ -321,10 +331,7 @@ public class SettingHandler { // Update current spawn location from config public static void fetchSpawnLocation() { - Connection connection = HuskHomes.getConnection(); - Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { - TeleportManager.setSpawnLocation(getSpawnLocation()); - }); + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> TeleportManager.setSpawnLocation(getSpawnLocation())); } // Get spawn location from config diff --git a/src/main/java/me/william278/huskhomes2/teleport/TeleportRequest.java b/src/main/java/me/william278/huskhomes2/teleport/TeleportRequest.java index 3f008413..f2b9dec0 100644 --- a/src/main/java/me/william278/huskhomes2/teleport/TeleportRequest.java +++ b/src/main/java/me/william278/huskhomes2/teleport/TeleportRequest.java @@ -32,6 +32,6 @@ public class TeleportRequest { public enum RequestType { TPA, - TPAHERE + TPA_HERE } } \ No newline at end of file diff --git a/src/main/java/me/william278/huskhomes2/teleport/TeleportRequestHandler.java b/src/main/java/me/william278/huskhomes2/teleport/TeleportRequestHandler.java index 33452830..adcceb0d 100644 --- a/src/main/java/me/william278/huskhomes2/teleport/TeleportRequestHandler.java +++ b/src/main/java/me/william278/huskhomes2/teleport/TeleportRequestHandler.java @@ -24,16 +24,16 @@ public class TeleportRequestHandler { private static void sendTeleportRequestCrossServer(Player requester, String targetPlayerName, TeleportRequest.RequestType requestType) { if (requestType == TeleportRequest.RequestType.TPA) { new PluginMessage(targetPlayerName, PluginMessageType.TPA_REQUEST, requester.getName()).send(requester); - } else if (requestType == TeleportRequest.RequestType.TPAHERE) { - new PluginMessage(targetPlayerName, PluginMessageType.TPAHERE_REQUEST, requester.getName()).send(requester); + } else if (requestType == TeleportRequest.RequestType.TPA_HERE) { + new PluginMessage(targetPlayerName, PluginMessageType.TPA_HERE_REQUEST, requester.getName()).send(requester); } } private static void replyTeleportRequestCrossServer(Player replier, String requesterName, TeleportRequest.RequestType requestType, boolean accepted) { if (requestType == TeleportRequest.RequestType.TPA) { new PluginMessage(requesterName, PluginMessageType.TPA_REQUEST_REPLY, replier.getName(), Boolean.toString(accepted)).send(replier); - } else if (requestType == TeleportRequest.RequestType.TPAHERE) { - new PluginMessage(requesterName, PluginMessageType.TPAHERE_REQUEST_REPLY, replier.getName(), Boolean.toString(accepted)).send(replier); + } else if (requestType == TeleportRequest.RequestType.TPA_HERE) { + new PluginMessage(requesterName, PluginMessageType.TPA_HERE_REQUEST_REPLY, replier.getName(), Boolean.toString(accepted)).send(replier); } } @@ -70,7 +70,7 @@ public class TeleportRequestHandler { if (targetPlayer.getUniqueId() != requester.getUniqueId()) { MessageManager.sendMessage(requester, "tpahere_request_sent", targetPlayerName); if (!HuskHomes.isIgnoringTeleportRequests(targetPlayer.getUniqueId())) { - teleportRequests.put(targetPlayer, new TeleportRequest(requester.getName(), TeleportRequest.RequestType.TPAHERE)); + teleportRequests.put(targetPlayer, new TeleportRequest(requester.getName(), TeleportRequest.RequestType.TPA_HERE)); MessageManager.sendMessage(targetPlayer, "tpahere_request_ask", requester.getName()); MessageManager.sendMessage(targetPlayer, "teleport_request_options"); } @@ -79,7 +79,7 @@ public class TeleportRequestHandler { } } else { if (HuskHomes.getSettings().doBungee()) { - sendTeleportRequestCrossServer(requester, targetPlayerName, TeleportRequest.RequestType.TPAHERE); + sendTeleportRequestCrossServer(requester, targetPlayerName, TeleportRequest.RequestType.TPA_HERE); MessageManager.sendMessage(requester, "tpahere_request_sent", targetPlayerName); } else { MessageManager.sendMessage(requester, "error_player_not_found", targetPlayerName); @@ -116,7 +116,7 @@ public class TeleportRequestHandler { if (requestType == TeleportRequest.RequestType.TPA) { TeleportManager.queueTimedTeleport(requester, p.getName(), connection); - } else if (requestType == TeleportRequest.RequestType.TPAHERE) { + } else if (requestType == TeleportRequest.RequestType.TPA_HERE) { TeleportManager.queueTimedTeleport(p, requesterName, connection); } } else { @@ -128,7 +128,7 @@ public class TeleportRequestHandler { if (accepted) { MessageManager.sendMessage(p, "tpa_you_accepted", requesterName); replyTeleportRequestCrossServer(p, requesterName, requestType, true); - if (requestType == TeleportRequest.RequestType.TPAHERE) { + if (requestType == TeleportRequest.RequestType.TPA_HERE) { TeleportManager.queueTimedTeleport(p, requesterName, connection); } } else { diff --git a/src/main/java/me/william278/huskhomes2/util/ChatList.java b/src/main/java/me/william278/huskhomes2/util/ChatList.java index ef7cec1a..adf7494a 100644 --- a/src/main/java/me/william278/huskhomes2/util/ChatList.java +++ b/src/main/java/me/william278/huskhomes2/util/ChatList.java @@ -13,14 +13,16 @@ public class ChatList { private final int itemsPerPage; private final int maxPage; private final String itemSeparator; + private final boolean spacePageOptions; - public ChatList(ArrayList items, int itemsPerPage, String pageChangeCommand, String itemSeparator) { + public ChatList(ArrayList items, int itemsPerPage, String pageChangeCommand, String itemSeparator, boolean spacePageOptions) { this.pageChangeCommand = pageChangeCommand; this.items = new ArrayList<>(); this.itemsPerPage = itemsPerPage; this.items.addAll(items); this.maxPage = (int) Math.ceil(((double) items.size()) / itemsPerPage); this.itemSeparator = itemSeparator; + this.spacePageOptions = spacePageOptions; } public boolean doesNotContainPage(int pageNo) { @@ -45,6 +47,9 @@ public class ChatList { builder.append(MessageManager.getRawMessage("page_no_items")); } builder.append("\n"); + if (spacePageOptions) { + builder.append("\n"); + } if (pageNo == 1) { if (pageNo == maxPage) { diff --git a/src/main/resources/languages/en-gb.yml b/src/main/resources/languages/en-gb.yml index 00b3f2f6..3499fd27 100644 --- a/src/main/resources/languages/en-gb.yml +++ b/src/main/resources/languages/en-gb.yml @@ -10,21 +10,24 @@ teleporting_action_bar_countdown: '[Teleporting in](#00fb9a) [%1%](#00fb9a bold) teleporting_action_bar_cancelled: '[Teleportation cancelled!](#ff7e5e)' teleporting_please_stand_still: '[Teleportation will be cancelled if you move or take damage.](gray)' home_deleted: '[Successfully deleted the home called](#00fb9a) [%1%](#00fb9a bold)' +home_deleted_other: '[Successfully deleted %1%''s home,](#00fb9a) [%2%](#00fb9a bold)' warp_deleted: '[Successfully deleted the warp called](#00fb9a) [%1%](#00fb9a bold)' error_home_invalid: '[Error:](#ff3300) [You do not have a home named "%1%"](#ff7e5e)' error_warp_invalid: '[Error:](#ff3300) [There is no warp set named "%1%"](#ff7e5e)' error_invalid_syntax: '[Error:](#ff3300) [Incorrect syntax. Usage: %1%](#ff7e5e)' edit_home_title: '\n[Edit home details for](#00fb9a) [%1%](#00fb9a bold)[:](#00fb9a)' -edit_home_options: '\n[[Teleport]](green show_text=&7Teleport to your home run_command=/huskhomes:home %1%) [[Delete]](red show_text=&7Delete your home run_command=/huskhomes:delhome %1%) [[Relocate]](blue show_text=&7Update your home''s location run_command=/huskhomes:edithome %1% location)\n[[Rename]](yellow show_text=&7Change the name of your home suggest_command=/huskhomes:edithome %1% rename ) [[Edit Description]](gold show_text=&7Update the description of your home suggest_command=/huskhomes:edithome %1% description )\n' -edit_home_options_make_public: '\n[[Teleport]](green show_text=&7Teleport to your home run_command=/huskhomes:home %1%) [[Delete]](red show_text=&7Delete your home run_command=/huskhomes:delhome %1%) [[Relocate]](blue show_text=&7Update your home''s location run_command=/huskhomes:edithome %1% location)\n[[Rename]](yellow show_text=&7Change the name of your home suggest_command=/huskhomes:edithome %1% rename ) [[Edit Description]](gold show_text=&7Update the description of your home suggest_command=/huskhomes:edithome %1% description ) [[Make Public]](dark_green show_text=&7Open your home to the public run_command=/huskhomes:edithome %1% public)\n' -edit_home_options_make_private: '\n[[Teleport]](green show_text=&7Teleport to your home run_command=/huskhomes:home %1%) [[Delete]](red show_text=&7Delete your home run_command=/huskhomes:delhome %1%) [[Relocate]](blue show_text=&7Update your home''s location run_command=/huskhomes:edithome %1% location)\n[[Rename]](yellow show_text=&7Change the name of your home suggest_command=/huskhomes:edithome %1% rename ) [[Edit Description]](gold show_text=&7Update the description of your home suggest_command=/huskhomes:edithome %1% description ) [[Make Private]](dark_red show_text=&7Make your home private run_command=/huskhomes:edithome %1% private)\n' +edit_home_title_other: '\n[Edit home details for %1%''s home,](#00fb9a) [%2%](#00fb9a bold)[:](#00fb9a)' +edit_home_options: '\n[[Teleport]](green show_text=&7Teleport to this home run_command=/huskhomes:home %1%.%2%) [[Delete]](red show_text=&7Delete this home run_command=/huskhomes:delhome %1%.%2%) [[Relocate]](blue show_text=&7Update this home''s location run_command=/huskhomes:edithome %1%.%2% location)\n[[Rename]](yellow show_text=&7Change the name of this home suggest_command=/huskhomes:edithome %1%.%2% rename ) [[Edit Description]](gold show_text=&7Update the description of this home suggest_command=/huskhomes:edithome %1%.%2% description )\n' +edit_home_options_make_public: '\n[[Teleport]](green show_text=&7Teleport to this home run_command=/huskhomes:home %1%.%2%) [[Delete]](red show_text=&7Delete this home run_command=/huskhomes:delhome %1%.%2%) [[Relocate]](blue show_text=&7Update this home''s location run_command=/huskhomes:edithome %1%.%2% location)\n[[Rename]](yellow show_text=&7Change the name of this home suggest_command=/huskhomes:edithome %1%.%2% rename ) [[Edit Description]](gold show_text=&7Update the description of this home suggest_command=/huskhomes:edithome %1%.%2% description ) [[Make Public]](dark_green show_text=&7Open this home to the public run_command=/huskhomes:edithome %1%.%2% public)\n' +edit_home_options_make_private: '\n[[Teleport]](green show_text=&7Teleport to this home run_command=/huskhomes:home %1%.%2%) [[Delete]](red show_text=&7Delete this home run_command=/huskhomes:delhome %1%.%2%) [[Relocate]](blue show_text=&7Update this home''s location run_command=/huskhomes:edithome %1%.%2% location)\n[[Rename]](yellow show_text=&7Change the name of this home suggest_command=/huskhomes:edithome %1%.%2% rename ) [[Edit Description]](gold show_text=&7Update the description of this home suggest_command=/huskhomes:edithome %1%.%2% description ) [[Make Private]](dark_red show_text=&7Make this home private run_command=/huskhomes:edithome %1%.%2% private)\n' edit_home_privacy_private: '• Access: &#ff7e5e&Private &7(Only you can use it)' +edit_home_privacy_private_other: '• Access: &#ff7e5e&Private &7(Only %1% can use it)' edit_home_privacy_public: '• Access: &aPublic &7(Anyone can use it)' -edit_home_privacy_public_success: '[Successfully made your home,](#00fb9a) [%1%](#00fb9a bold)[, open to the public.](#00fb9a)' -edit_home_privacy_public_success_economy: '[Successfully made your home,](#00fb9a) [%1%](#00fb9a bold)[, open to the public for %2%.](#00fb9a)' -edit_home_privacy_private_success: '[Successfully made your home,](#00fb9a) [%1%](#00fb9a bold)[, private.](#00fb9a)' -error_edit_home_privacy_already_public: '[Error:](#ff3300) [Your home is already set to public.](#ff7e5e)' -error_edit_home_privacy_already_private: '[Error:](#ff3300) [Your home is already set to private.](#ff7e5e)' +edit_home_privacy_public_success: '[Successfully made the home,](#00fb9a) [%1%](#00fb9a bold)[, open to the public.](#00fb9a)' +edit_home_privacy_public_success_economy: '[Successfully made the home,](#00fb9a) [%1%](#00fb9a bold)[, open to the public for %2%.](#00fb9a)' +edit_home_privacy_private_success: '[Successfully made the home,](#00fb9a) [%1%](#00fb9a bold)[, private.](#00fb9a)' +error_edit_home_privacy_already_public: '[Error:](#ff3300) [This home is already set as public.](#ff7e5e)' +error_edit_home_privacy_already_private: '[Error:](#ff3300) [This home is already set as private.](#ff7e5e)' error_edit_home_privacy_no_permission: '[Error:](#ff3300) [You do not have permission to make homes public.](#ff7e5e)' error_edit_home_description_length: '[Error:](#ff3300) [Home descriptions must be less than 255 characters in length.](#ff7e5e)' error_edit_home_description_characters: '[Error:](#ff3300) [Home descriptions may only contain alphanumeric (A-Z, 0-9) characters, hyphens (-) and underscores (_)](#ff7e5e)' @@ -87,7 +90,7 @@ error_console_only: '[Error:](#ff3300) [That command can only be run from the se error_tp_invalid_world: '[Error:](#ff3300) [Please specify a valid server world.](#ff7e5e)' error_rtp_randomization_timeout: '[Error:](#ff3300) [Failed to find a safe random location to teleport you.](#ff7e5e)' list_item_divider: ' [•](gray) ' -home_list_item: '[[%1%]](show_text=&7%2% run_command=/huskhomes:edithome %1%)' +home_list_item: '[[%1%]](show_text=&7%2% run_command=/huskhomes:edithome %2%.%1%)' public_home_list_item: '[[%1%]](show_text=�fb9a&%2%: &7%3% run_command=/huskhomes:phome %2%.%1%)' warp_list_item: '[[%1%]](show_text=&7%2% run_command=/huskhomes:warp %1%)' home_default_description: '%1%''s home' @@ -100,10 +103,10 @@ error_permission_restricted_warp: '[Error:](#ff3300) [You do not have permission teleporting_complete_console: '[Console teleported you to %1%.](gray)' spawn_warp_default_description: 'The /spawn position of the server' error_invalid_page_number: '[Error:](#ff3300) [Please specify a valid page number.](#ff7e5e)' -page_options: '\n[←](gray show_text=&7View previous page run_command=%1%) [Viewing Page %2%/%3%](#00fb9a) [→](gray show_text=&7View next page run_command=%4%)' -page_options_min: '\n[Viewing Page %1%/%2%](#00fb9a) [→](gray show_text=&7View next page run_command=%3%)' -page_options_min_max: '\n[Viewing Page %1%/%2%](#00fb9a)' -page_options_max: '\n[←](gray show_text=&7View previous page run_command=%1%) [Viewing Page %2%/%3%](#00fb9a)' +page_options: '[←](gray show_text=&7View previous page run_command=%1%) [Viewing Page %2%/%3%](#00fb9a) [→](gray show_text=&7View next page run_command=%4%)' +page_options_min: '[Viewing Page %1%/%2%](#00fb9a) [→](gray show_text=&7View next page run_command=%3%)' +page_options_min_max: '[Viewing Page %1%/%2%](#00fb9a)' +page_options_max: '[←](gray show_text=&7View previous page run_command=%1%) [Viewing Page %2%/%3%](#00fb9a)' page_no_items: '[(No items to display on this page)](gray show_text=&7Try a different page number)' command_list_header: '\n[HuskHomes](#00fb9a bold) [| Command List](#00fb9a)' command_list_item: '[/%1%](#00fb9a show_text=�fb9a&%2% suggest_command=/%1%) [•](white) [%3%](gray)' @@ -112,4 +115,5 @@ tpignore_toggle_on: '[You are now](#00fb9a) [ignoring](#00fb9a bold) [incoming t tpignore_toggle_off: '[You are now](#00fb9a) [listening](#00fb9a bold) [to any incoming teleport requests.](#00fb9a) [(Click to toggle)](gray show_text=&7Click to ignore incoming teleport requests run_command=/huskhomes:tpignore)' tpignore_on_reminder: '[You are currently ignoring incoming teleport requests!](gray) [(Click to toggle)](gray show_text=&7Click to listen for incoming teleport requests run_command=/huskhomes:tpignore)' error_ignoring_teleport_requests: '[Error:](#ff3300) [You are currently ignoring teleport requests!](#ff7e5e) [(Click to toggle)](#ff7e5e show_text=&#ff7e5e&Click to listen for incoming teleport requests run_command=/huskhomes:tpignore)' -error_no_offline_position: '[Error:](#ff3300) [Could not find where %1% last logged out.](#ff7e5e)' \ No newline at end of file +error_no_offline_position: '[Error:](#ff3300) [Could not find where %1% last logged out.](#ff7e5e)' +error_invalid_player: '[Error:](#ff3300) [Please specify the name of a valid player!](#ff7e5e)' \ No newline at end of file diff --git a/src/main/resources/languages/it-it.yml b/src/main/resources/languages/it-it.yml index dbf153d1..08c00977 100644 --- a/src/main/resources/languages/it-it.yml +++ b/src/main/resources/languages/it-it.yml @@ -15,9 +15,9 @@ error_home_invalid: '[Errore:](#ff3300) [Non hai nessuna home chiamata "%1%"](#f error_warp_invalid: '[Errore:](#ff3300) [Non c’’è nessun warp chiamato "%1%"](#ff7e5e)' error_invalid_syntax: '[Errore:](#ff3300) [Comando non riconosciuto. Utilizza: %1%](#ff7e5e)' edit_home_title: '\n[Modifica della home](#00fb9a) [%1%](#00fb9a bold)[:](#00fb9a)' -edit_home_options: '\n[[Teletrasporto]](green show_text=&7Teletrasportati alla tua home run_command=/huskhomes:home %1%) [[Cancella]](red show_text=&7Cancella la tua home run_command=/huskhomes:delhome %1%) [[Riposiziona]](blue show_text=&7Aggiorna le coordinate della tua home run_command=/huskhomes:edithome %1% location)\n[[Rinomina]](yellow show_text=&7Cambia il nome della tua home suggest_command=/huskhomes:edithome %1% rename ) [[Modifica Descrizione]](gold show_text=&7Aggiorna la descrizione della tua home suggest_command=/huskhomes:edithome %1% description )\n' -edit_home_options_make_public: '\n[[Teletrasporto]](green show_text=&7Teletrasportati alla tua home run_command=/huskhomes:home %1%) [[Cancella]](red show_text=&7Cancella la tua home run_command=/huskhomes:delhome %1%) [[Riposiziona]](blue show_text=&7Aggiorna le coordinate della tua home run_command=/huskhomes:edithome %1% location)\n[[Rinomina]](yellow show_text=&7Cambia il nome della tua home suggest_command=/huskhomes:edithome %1% rename ) [[Modifica Descrizione]](gold show_text=&7Aggiorna la descrizione della tua home suggest_command=/huskhomes:edithome %1% description ) [[Rendi Pubblica]](dark_green show_text=&7Rendi la tua home pubblica run_command=/huskhomes:edithome %1% public)\n' -edit_home_options_make_private: '\n[[Teletrasporto]](green show_text=&7Teletrasportati alla tua home run_command=/huskhomes:home %1%) [[Cancella]](red show_text=&7Cancella la tua home run_command=/huskhomes:delhome %1%) [[Riposiziona]](blue show_text=&7Aggiorna le coordinate della tua home run_command=/huskhomes:edithome %1% location)\n[[Rinomina]](yellow show_text=&7Cambia il nome della tua home suggest_command=/huskhomes:edithome %1% rename ) [[Modifica Descrizione]](gold show_text=&7Aggiorna la descrizione della tua home suggest_command=/huskhomes:edithome %1% description ) [[Rendi Privata]](dark_red show_text=&7Rendi la tua home privata run_command=/huskhomes:edithome %1% private)\n' +edit_home_options: '\n[[Teletrasporto]](green show_text=&7Teletrasportati alla tua home run_command=/huskhomes:home %1%.%2%) [[Cancella]](red show_text=&7Cancella la tua home run_command=/huskhomes:delhome %1%.%2%) [[Riposiziona]](blue show_text=&7Aggiorna le coordinate della tua home run_command=/huskhomes:edithome %1%.%2% location)\n[[Rinomina]](yellow show_text=&7Cambia il nome della tua home suggest_command=/huskhomes:edithome %1%.%2% rename ) [[Modifica Descrizione]](gold show_text=&7Aggiorna la descrizione della tua home suggest_command=/huskhomes:edithome %1%.%2% description )\n' +edit_home_options_make_public: '\n[[Teletrasporto]](green show_text=&7Teletrasportati alla tua home run_command=/huskhomes:home %1%.%2%) [[Cancella]](red show_text=&7Cancella la tua home run_command=/huskhomes:delhome %1%.%2%) [[Riposiziona]](blue show_text=&7Aggiorna le coordinate della tua home run_command=/huskhomes:edithome %1%.%2% location)\n[[Rinomina]](yellow show_text=&7Cambia il nome della tua home suggest_command=/huskhomes:edithome %1%.%2% rename ) [[Modifica Descrizione]](gold show_text=&7Aggiorna la descrizione della tua home suggest_command=/huskhomes:edithome %1%.%2% description ) [[Rendi Pubblica]](dark_green show_text=&7Rendi la tua home pubblica run_command=/huskhomes:edithome %1%.%2% public)\n' +edit_home_options_make_private: '\n[[Teletrasporto]](green show_text=&7Teletrasportati alla tua home run_command=/huskhomes:home %1%.%2%) [[Cancella]](red show_text=&7Cancella la tua home run_command=/huskhomes:delhome %1%.%2%) [[Riposiziona]](blue show_text=&7Aggiorna le coordinate della tua home run_command=/huskhomes:edithome %1%.%2% location)\n[[Rinomina]](yellow show_text=&7Cambia il nome della tua home suggest_command=/huskhomes:edithome %1%.%2% rename ) [[Modifica Descrizione]](gold show_text=&7Aggiorna la descrizione della tua home suggest_command=/huskhomes:edithome %1%.%2% description ) [[Rendi Privata]](dark_red show_text=&7Rendi la tua home privata run_command=/huskhomes:edithome %1%.%2% private)\n' edit_home_privacy_private: '• Accesso: &#ff7e5e&Privata &7(Solo tu puoi usarla)' edit_home_privacy_public: '• Accesso: &aPubblica &7(Tutti possono usarla)' edit_home_privacy_public_success: '[Hai impostato la privacy della tua home](#00fb9a) [%1%](#00fb9a bold) [come pubblica.](#00fb9a)' @@ -32,6 +32,7 @@ edit_home_update_location: '[Hai riposizionato la home](#00fb9a) [%1%](#00fb9a b edit_home_update_description: '[Hai cambiato la descrizione di](#00fb9a) [%1%](#00fb9a bold) [in "%2%"](#00fb9a)' edit_home_update_name: '[Hai cambiato il nome della tua home: %1% →](#00fb9a) [%2%](#00fb9a bold)' edit_warp_title: '\n[Modifica dettagli del warp](#00fb9a) [%1%](#00fb9a bold)[:](#00fb9a)' +edit_home_title_other: '\n[Edit home details for %1%''s home,](#00fb9a) [%2%](#00fb9a bold)[:](#00fb9a)' edit_warp_options: '\n[[Teletrasporto]](green show_text=&7Teletrasportati al warp run_command=/huskhomes:warp %1%) [[Cancella]](red show_text=&7Cancella il warp run_command=/huskhomes:delwarp %1%) [[Riposiziona]](blue show_text=&7Aggiorna le coordinate del warp run_command=/huskhomes:editwarp %1% location)\n[[Rinomina]](yellow show_text=&7Cambia il nome del warp suggest_command=/huskhomes:editwarp %1% rename ) [[Modifica Descrizione]](gold show_text=&7Aggiorna la descrizione del warp suggest_command=/huskhomes:editwarp %1% description )\n' error_edit_warp_description_length: '[Error:](#ff3300) [Warp descriptions must be less than 255 characters in length.](#ff7e5e)' error_edit_warp_description_characters: '[Error:](#ff3300) [Warp descriptions may only contain alphanumeric (A-Z, 0-9) characters, hyphens (-) and underscores (_)](#ff7e5e)' @@ -87,7 +88,7 @@ error_console_only: '[Errore:](#ff3300) [Quel comando può essere eseguito solo error_tp_invalid_world: '[Errore:](#ff3300) [Per favore, specifica un mondo valido nel server.](#ff7e5e)' error_rtp_randomization_timeout: '[Errore:](#ff3300) [Non sono riuscito a trovare una posizione sicura, riprova.](#ff7e5e)' list_item_divider: ' [•](gray) ' -home_list_item: '[[%1%]](show_text=&7%2% run_command=/huskhomes:edithome %1%)' +home_list_item: '[[%1%]](show_text=&7%2% run_command=/huskhomes:edithome %2%.%1%)' public_home_list_item: '[[%1%]](show_text=�fb9a&%2%: &7%3% run_command=/huskhomes:phome %2%.%1%)' warp_list_item: '[[%1%]](show_text=&7%2% run_command=/huskhomes:warp %1%)' home_default_description: 'Home di %1%' @@ -100,10 +101,10 @@ error_permission_restricted_warp: '[Errore:](#ff3300) [Non hai i permessi per us teleporting_complete_console: '[La console ti ha teletrasportato a %1%.](gray)' spawn_warp_default_description: 'La posizione di /spawn del server' error_invalid_page_number: '[Errore:](#ff3300) [Specifica un numero di pagina corretto.](#ff7e5e)' -page_options: '\n[←](gray show_text=&7Pagina precedente run_command=%1%) [Pagina %2%/%3%](#00fb9a) [→](gray show_text=&7Pagina successiva run_command=%4%)' -page_options_min: '\n[Pagina %1%/%2%](#00fb9a) [→](gray show_text=&7Pagina successiva run_command=%3%)' -page_options_min_max: '\n[Pagina %1%/%2%](#00fb9a)' -page_options_max: '\n[←](gray show_text=&7Pagina precedente run_command=%1%) [Pagina %2%/%3%](#00fb9a)' +page_options: '[←](gray show_text=&7Pagina precedente run_command=%1%) [Pagina %2%/%3%](#00fb9a) [→](gray show_text=&7Pagina successiva run_command=%4%)' +page_options_min: '[Pagina %1%/%2%](#00fb9a) [→](gray show_text=&7Pagina successiva run_command=%3%)' +page_options_min_max: '[Pagina %1%/%2%](#00fb9a)' +page_options_max: '[←](gray show_text=&7Pagina precedente run_command=%1%) [Pagina %2%/%3%](#00fb9a)' page_no_items: '[(Nessun oggetto visibile in questa pagina)](gray show_text=&7Prova un numero differente)' command_list_header: '\n[HuskHomes](#00fb9a bold) [| Comandi](#00fb9a)' command_list_item: '[/%1%](#00fb9a show_text=�fb9a&%2% suggest_command=/%1%) [•](white) [%3%](gray)' @@ -112,4 +113,5 @@ tpignore_toggle_on: '[You are now](#00fb9a) [ignoring](#00fb9a bold) [incoming t tpignore_toggle_off: '[You are now](#00fb9a) [listening](#00fb9a bold) [to any incoming teleport requests.](#00fb9a) [(Click to toggle)](gray show_text=&7Click to ignore incoming teleport requests run_command=/huskhomes:tpignore)' tpignore_on_reminder: '[You are currently ignoring incoming teleport requests!](gray) [(Click to toggle)](gray show_text=&7Click to listen for incoming teleport requests run_command=/huskhomes:tpignore)' error_ignoring_teleport_requests: '[Error:](#ff3300) [You are currently ignoring teleport requests!](#ff7e5e) [(Click to toggle)](#ff7e5e show_text=&#ff7e5e&Click to listen for incoming teleport requests run_command=/huskhomes:tpignore)' -error_no_offline_position: '[Error:](#ff3300) [Could not find where %1% last logged out.](#ff7e5e)' \ No newline at end of file +error_no_offline_position: '[Error:](#ff3300) [Could not find where %1% last logged out.](#ff7e5e)' +error_invalid_player: '[Error:](#ff3300) [Please specify the name of a valid player!](#ff7e5e)' \ No newline at end of file diff --git a/src/main/resources/languages/pl.yml b/src/main/resources/languages/pl.yml index f3c60210..31554ea7 100644 --- a/src/main/resources/languages/pl.yml +++ b/src/main/resources/languages/pl.yml @@ -15,9 +15,10 @@ error_home_invalid: '[error:](#ff3300) [Nie masz domu o nazwie "%1%"](#ff7e5e)' error_warp_invalid: '[error:](#ff3300) [Nie ma warpu o nazwie "%1%"](#ff7e5e)' error_invalid_syntax: '[error:](#ff3300) [Niepoprawna składnia. Wpisz: %1%](#ff7e5e)' edit_home_title: '\n[Edytuj właściwości domu](#00fb9a) [%1%](#00fb9a bold)[:](#00fb9a)' -edit_home_options: '\n[[Teleportuj]](green show_text=&Przeteleportuj się do swojego domu run_command=/huskhomes:home %1%) [[ Usuń]](red show_text=&7Usuń swój dom run_command=/huskhomes:delhome %1%) [[Relocate]](blue show_text=&7Zaktualizuj lokalizację domu run_command=/huskhomes:edithome %1% location)\n[[Zmień nazwę]](yellow show_text=&7Zmień nazwe domu suggest_command=/huskhomes:edithome %1% rename ) [[Edytuj opis]](gold show_text=&7Zaktualizuj opis domu suggest_command=/huskhomes:edithome %1% description )\n' -edit_home_options_make_public: '\n[[Teleport]](green show_text=&7Przeteleportuj się do swojego domu run_command=/huskhomes:home %1%) [[Usuń]](red show_text=&7Usuń swój dom run_command=/huskhomes:delhome %1%) [[Relocate]](blue show_text=&7Zaktualizuj lokalizację domu run_command=/huskhomes:edithome %1% location)\n[[Zmień nazwę]](yellow show_text=&7Zmień nazwe domu suggest_command=/huskhomes:edithome %1% rename ) [[Edytuj opis]](gold show_text=&7Zaktualizuj opis domu suggest_command=/huskhomes:edithome %1% description ) [[Ustaw jako publiczny]](dark_green show_text=&7Ustaw swój d0m jako publiczny run_command=/huskhomes:edithome %1% public)\n' -edit_home_options_make_private: '\n[[Teleport]](green show_text=&7Przeteleportuj się do swojego domu run_command=/huskhomes:home %1%) [[Usuń]](red show_text=&7Usuń swój dom run_command=/huskhomes:delhome %1%) [[Relocate]](blue show_text=&7Zaktualizuj lokalizację domu run_command=/huskhomes:edithome %1% location)\n[[Zmień nazwę]](yellow show_text=&7Zmień nazwe domu suggest_command=/huskhomes:edithome %1% rename ) [[Edytuj opis]](gold show_text=&7Zaktualizuj opis domu suggest_command=/huskhomes:edithome %1% description ) [[Ustaw jako prywatny]](dark_red show_text=&7Ustaw swój dom jako prywatny run_command=/huskhomes:edithome %1% private)\n' +edit_home_title_other: '\n[Edit home details for %1%''s home,](#00fb9a) [%2%](#00fb9a bold)[:](#00fb9a)' +edit_home_options: '\n[[Teleportuj]](green show_text=&Przeteleportuj się do swojego domu run_command=/huskhomes:home %1%.%2%) [[ Usuń]](red show_text=&7Usuń swój dom run_command=/huskhomes:delhome %1%.%2%) [[Relocate]](blue show_text=&7Zaktualizuj lokalizację domu run_command=/huskhomes:edithome %1%.%2% location)\n[[Zmień nazwę]](yellow show_text=&7Zmień nazwe domu suggest_command=/huskhomes:edithome %1%.%2% rename ) [[Edytuj opis]](gold show_text=&7Zaktualizuj opis domu suggest_command=/huskhomes:edithome %1%.%2% description )\n' +edit_home_options_make_public: '\n[[Teleport]](green show_text=&7Przeteleportuj się do swojego domu run_command=/huskhomes:home %1%.%2%) [[Usuń]](red show_text=&7Usuń swój dom run_command=/huskhomes:delhome %1%.%2%) [[Relocate]](blue show_text=&7Zaktualizuj lokalizację domu run_command=/huskhomes:edithome %1%.%2% location)\n[[Zmień nazwę]](yellow show_text=&7Zmień nazwe domu suggest_command=/huskhomes:edithome %1%.%2% rename ) [[Edytuj opis]](gold show_text=&7Zaktualizuj opis domu suggest_command=/huskhomes:edithome %1%.%2% description ) [[Ustaw jako publiczny]](dark_green show_text=&7Ustaw swój d0m jako publiczny run_command=/huskhomes:edithome %1%.%2% public)\n' +edit_home_options_make_private: '\n[[Teleport]](green show_text=&7Przeteleportuj się do swojego domu run_command=/huskhomes:home %1%.%2%) [[Usuń]](red show_text=&7Usuń swój dom run_command=/huskhomes:delhome %1%.%2%) [[Relocate]](blue show_text=&7Zaktualizuj lokalizację domu run_command=/huskhomes:edithome %1%.%2% location)\n[[Zmień nazwę]](yellow show_text=&7Zmień nazwe domu suggest_command=/huskhomes:edithome %1%.%2% rename ) [[Edytuj opis]](gold show_text=&7Zaktualizuj opis domu suggest_command=/huskhomes:edithome %1%.%2% description ) [[Ustaw jako prywatny]](dark_red show_text=&7Ustaw swój dom jako prywatny run_command=/huskhomes:edithome %1%.%2% private)\n' edit_home_privacy_private: '• Dostęp: &#ff7e5e&Prywatny &7(Tylko ty możesz go użyć)' edit_home_privacy_public: '• Dostęp: &aPubliczny &7(Każdy może go użyć)' edit_home_privacy_public_success: '[Pomyślnie utworzono dom,](#00fb9a) [%1%](#00fb9a bold)[, otwórz jako publiczny.](#00fb9a)' @@ -70,7 +71,7 @@ error_player_not_found: '[error:](#ff3300) [Nie odnalazłem gracza %1%.](#ff7e5e return_by_death: '[Powrót w miejsce śmierci?](gray) [/back](#00fb9a show_text=�fb9a&Kliknij aby wrócić do ostatniej pozycji smierci. run_command=/back)' teleport_request_options: '[Wybierz opcję:](gray) [[Zaakceptuj]](#00fb9a show_text=�fb9a&Zaakceptuj prośbę o teleporacje; /tpaccept run_command=/tpaccept) [•](gray) [[Decline]](#ff7e5e show_text=&#ff7e5e&Odrzuć prośbę o teleportacje; /tpdeny run_command=/tpdeny)' tpa_you_accepted: '[Zaakceptowałeś prośbę o teleportacje od %1%](#00fb9a)' -tpa_you_declined: '[Odrzuciłeś prośbę o teleporacje od %1%'](#ff7e5e)' +tpa_you_declined: '[Odrzuciłeś prośbę o teleporacje od %1%''](#ff7e5e)' tpa_has_accepted: '[%1% zaakceptował twoją prośbę o teleportacje](#00fb9a)' tpa_has_declined: '[%1% odrzucił twoją prośbę o teleportacje](#ff7e5e)' tpa_request_sent: '[Wysłałeś prośbę o teleportacje do](#00fb9a) [%1%](#00fb9a bold)' @@ -87,7 +88,7 @@ error_console_only: '[error:](#ff3300) [To polecenie możesz wykonać tylko z ko error_tp_invalid_world: '[error:](#ff3300) [Podałeś niepoprwawny świat.](#ff7e5e)' error_rtp_randomization_timeout: '[error:](#ff3300) [Nie mogę znaleśc bezpiecznej lokalizacji dla Ciebie.](#ff7e5e)' list_item_divider: ' [•](gray) ' -home_list_item: '[[%1%]](show_text=&7%2% run_command=/huskhomes:edithome %1%)' +home_list_item: '[[%1%]](show_text=&7%2% run_command=/huskhomes:edithome %2%.%1%)' public_home_list_item: '[[%1%]](show_text=�fb9a&%2%: &7%3% run_command=/huskhomes:phome %2%.%1%)' warp_list_item: '[[%1%]](show_text=&7%2% run_command=/huskhomes:warp %1%)' home_default_description: 'Dom %1%' @@ -100,10 +101,10 @@ error_permission_restricted_warp: '[error:](#ff3300) [Nie masz uprawnień do war teleporting_complete_console: '[Konsola przeteleportowała Cię %1%.](gray)' spawn_warp_default_description: 'Serwerowa pozycja spawnu' error_invalid_page_number: '[error:](#ff3300) [Podaj poprawny numer strony.](#ff7e5e)' -page_options: '\n[←](gray show_text=&7View previous page run_command=%1%) [Viewing Page %2%/%3%](#00fb9a) [→](gray show_text=&7View next page run_command=%4%)' -page_options_min: '\n[Viewing Page %1%/%2%](#00fb9a) [→](gray show_text=&7View next page run_command=%3%)' -page_options_min_max: '\n[Viewing Page %1%/%2%](#00fb9a)' -page_options_max: '\n[←](gray show_text=&7Zobacz poprzednią stronę run_command=%1%) [Oglądasz stronę %2%/%3%](#00fb9a)' +page_options: '[←](gray show_text=&7View previous page run_command=%1%) [Viewing Page %2%/%3%](#00fb9a) [→](gray show_text=&7View next page run_command=%4%)' +page_options_min: '[Viewing Page %1%/%2%](#00fb9a) [→](gray show_text=&7View next page run_command=%3%)' +page_options_min_max: '[Viewing Page %1%/%2%](#00fb9a)' +page_options_max: '[←](gray show_text=&7Zobacz poprzednią stronę run_command=%1%) [Oglądasz stronę %2%/%3%](#00fb9a)' page_no_items: '[(Brak rzeczy do wyświetlenia)](gray show_text=&7Spróboj podać numer innej strony)' command_list_header: '\n[HuskHomes](#00fb9a bold) [| Lista poleceń](#00fb9a)' command_list_item: '[/%1%](#00fb9a show_text=�fb9a&%2% suggest_command=/%1%) [•](white) [%3%](gray)' @@ -112,4 +113,5 @@ tpignore_toggle_on: '[Jesteś teraz](#00fb9a) [ignoring](#00fb9a bold) [przychod tpignore_toggle_off: '[Jesteś teraz](#00fb9a) [listening](#00fb9a bold) [na wszystkie przychodzące żądania teleportu.](#00fb9a) [(Click to toggle)](gray show_text=&7Kliknij, aby nasłuchiwać przychodzących żądań teleportu run_command=/huskhomes:tpignore)' tpignore_on_reminder: '[Obecnie ignorujesz przychodzące żądania teleportu.!](gray) [(Kliknij aby zmienić)](gray show_text=&7Kliknij, aby nasłuchiwać przychodzących żądań teleportu run_command=/huskhomes:tpignore)' error_ignoring_teleport_requests: '[error:](#ff3300) [Obecnie ignorujesz prośby o teleport.!](#ff7e5e) [(Kliknij aby zmienić)](#ff7e5e show_text=&#ff7e5e&Kliknij, aby nasłuchiwać przychodzących żądań teleportu run_command=/huskhomes:tpignore)' -error_no_offline_position: '[error:](#ff3300) [Nie mogę znaleźć, gdzie ostatnio wylogował się%1%.](#ff7e5e)' \ No newline at end of file +error_no_offline_position: '[error:](#ff3300) [Nie mogę znaleźć, gdzie ostatnio wylogował się%1%.](#ff7e5e)' +error_invalid_player: '[Error:](#ff3300) [Please specify the name of a valid player!](#ff7e5e)' \ No newline at end of file diff --git a/src/main/resources/languages/zh-cn.yml b/src/main/resources/languages/zh-cn.yml index 75c36816..600e915b 100644 --- a/src/main/resources/languages/zh-cn.yml +++ b/src/main/resources/languages/zh-cn.yml @@ -15,9 +15,10 @@ error_home_invalid: '[错误:](#ff3300) [你没有叫 “%1%” 的家](#ff7e5e) error_warp_invalid: '[错误:](#ff3300) [没有叫做 “%1%” 的传送点](#ff7e5e)' error_invalid_syntax: '[错误:](#ff3300) [语法不正确.使用: %1%](#ff7e5e)' edit_home_title: '\n[编辑家的详细信息](#00fb9a) [%1%](#00fb9a bold)[:](#00fb9a)' -edit_home_options: '\n[[传送]](green show_text=&7传送到你的家 run_command=/huskhomes:home %1%) [[删除]](red show_text=&7删除你的家 run_command=/huskhomes:delhome %1%) [[更新位置]](blue show_text=&7更新家的坐标到 run_command=/huskhomes:edithome %1% location)\n[[更改名字]](yellow show_text=&7更改家的名字 suggest_command=/huskhomes:edithome %1% rename ) [[编辑描述]](gold show_text=&7更改家的描述 suggest_command=/huskhomes:edithome %1% description )\n' -edit_home_options_make_public: '\n[[传送]](green show_text=&7传送到你的家 run_command=/huskhomes:home %1%) [[删除]](red show_text=&7删除你的家 run_command=/huskhomes:delhome %1%) [[更新位置]](blue show_text=&7更新家的坐标到 run_command=/huskhomes:edithome %1% location)\n[[更改名字]](yellow show_text=&7更改家的名字 suggest_command=/huskhomes:edithome %1% rename ) [[编辑描述]](gold show_text=&7更改家的描述 suggest_command=/huskhomes:edithome %1% description ) [[更改隐私为公共]](dark_green show_text=&7开放家的传送到全部人 run_command=/huskhomes:edithome %1% public)\n' -edit_home_options_make_private: '\n[[传送]](green show_text=&7传送到你的家 run_command=/huskhomes:home %1%) [[删除]](red show_text=&7删除你的家 run_command=/huskhomes:delhome %1%) [[更新位置]](blue show_text=&7更新家的坐标到 run_command=/huskhomes:edithome %1% location)\n[[更改名字]](yellow show_text=&7更改家的名字 suggest_command=/huskhomes:edithome %1% rename ) [[编辑描述]](gold show_text=&7更改家的描述 suggest_command=/huskhomes:edithome %1% description ) [[更改隐私为私人]](dark_red show_text=&7更改家的传送为近自己可见 run_command=/huskhomes:edithome %1% private)\n' +edit_home_title_other: '\n[Edit home details for %1%''s home,](#00fb9a) [%2%](#00fb9a bold)[:](#00fb9a)' +edit_home_options: '\n[[传送]](green show_text=&7传送到你的家 run_command=/huskhomes:home %1%.%2%) [[删除]](red show_text=&7删除你的家 run_command=/huskhomes:delhome %1%.%2%) [[更新位置]](blue show_text=&7更新家的坐标到 run_command=/huskhomes:edithome %1%.%2% location)\n[[更改名字]](yellow show_text=&7更改家的名字 suggest_command=/huskhomes:edithome %1%.%2% rename ) [[编辑描述]](gold show_text=&7更改家的描述 suggest_command=/huskhomes:edithome %1%.%2% description )\n' +edit_home_options_make_public: '\n[[传送]](green show_text=&7传送到你的家 run_command=/huskhomes:home %1%.%2%) [[删除]](red show_text=&7删除你的家 run_command=/huskhomes:delhome %1%.%2%) [[更新位置]](blue show_text=&7更新家的坐标到 run_command=/huskhomes:edithome %1%.%2% location)\n[[更改名字]](yellow show_text=&7更改家的名字 suggest_command=/huskhomes:edithome %1%.%2% rename ) [[编辑描述]](gold show_text=&7更改家的描述 suggest_command=/huskhomes:edithome %1%.%2% description ) [[更改隐私为公共]](dark_green show_text=&7开放家的传送到全部人 run_command=/huskhomes:edithome %1%.%2% public)\n' +edit_home_options_make_private: '\n[[传送]](green show_text=&7传送到你的家 run_command=/huskhomes:home %1%.%2%) [[删除]](red show_text=&7删除你的家 run_command=/huskhomes:delhome %1%.%2%) [[更新位置]](blue show_text=&7更新家的坐标到 run_command=/huskhomes:edithome %1%.%2% location)\n[[更改名字]](yellow show_text=&7更改家的名字 suggest_command=/huskhomes:edithome %1%.%2% rename ) [[编辑描述]](gold show_text=&7更改家的描述 suggest_command=/huskhomes:edithome %1%.%2% description ) [[更改隐私为私人]](dark_red show_text=&7更改家的传送为近自己可见 run_command=/huskhomes:edithome %1%.%2% private)\n' edit_home_privacy_private: '• 访问: &#ff7e5e&私人住宅 &7(只有你可以访问)' edit_home_privacy_public: '• 访问: &a公共 &7(所有人都可以访问)' edit_home_privacy_public_success: '[成功更改家 ](#00fb9a) [%1%](#00fb9a bold)[ 的设置为开放到所有人.](#00fb9a)' @@ -87,7 +88,7 @@ error_console_only: '[错误:](#ff3300) [该命令只能从服务器控制台运 error_tp_invalid_world: '[错误:](#ff3300) [请指定有效的服务器世界.](#ff7e5e)' error_rtp_randomization_timeout: '[错误:](#ff3300) [找不到安全的随机位置传送你.](#ff7e5e)' list_item_divider: ' [•](gray) ' -home_list_item: '[[%1%]](show_text=&7%2% run_command=/huskhomes:edithome %1%)' +home_list_item: '[[%1%]](show_text=&7%2% run_command=/huskhomes:edithome %2%.%1%)' public_home_list_item: '[[%1%]](show_text=�fb9a&%2%: &7%3% run_command=/huskhomes:phome %2%.%1%)' warp_list_item: '[[%1%]](show_text=&7%2% run_command=/huskhomes:warp %1%)' home_default_description: '%1% 的家' @@ -100,10 +101,10 @@ error_permission_restricted_warp: '[错误:](#ff3300) [你没有权限去传送 teleporting_complete_console: '[控制台传送你到 %1%.](gray)' spawn_warp_default_description: '这个服务器的 /spawn 位置' error_invalid_page_number: '[错误:](#ff3300) [请指定有效的页码.](#ff7e5e)' -page_options: '\n[←](gray show_text=&7View previous page run_command=%1%) [查看页面 %2%/%3%](#00fb9a) [→](gray show_text=&7查看下一页 page run_command=%4%)' -page_options_min: '\n[查看页面 %1%/%2%](#00fb9a) [→](gray show_text=&7查看下一页 page run_command=%3%)' -page_options_min_max: '\n[查看页面 %1%/%2%](#00fb9a)' -page_options_max: '\n[←](gray show_text=&7查看上一页 run_command=%1%) [Viewing Page %2%/%3%](#00fb9a)' +page_options: '[←](gray show_text=&7View previous page run_command=%1%) [查看页面 %2%/%3%](#00fb9a) [→](gray show_text=&7查看下一页 page run_command=%4%)' +page_options_min: '[查看页面 %1%/%2%](#00fb9a) [→](gray show_text=&7查看下一页 page run_command=%3%)' +page_options_min_max: '[查看页面 %1%/%2%](#00fb9a)' +page_options_max: '[←](gray show_text=&7查看上一页 run_command=%1%) [查看页面 %2%/%3%](#00fb9a)' page_no_items: '[(此页上没有要显示的项目)](gray show_text=&7请尝试其他页码)' command_list_header: '\n[HuskHomes](#00fb9a bold) [| 指令列表](#00fb9a)' command_list_item: '[/%1%](#00fb9a show_text=�fb9a&%2% suggest_command=/%1%) [•](white) [%3%](gray)' @@ -112,4 +113,5 @@ tpignore_toggle_on: '[你现在是](#00fb9a) [勿扰模式](#00fb9a bold) [拒 tpignore_toggle_off: '[你现在是](#00fb9a) [正常模式](#00fb9a bold) [接受所有的传送请求.](#00fb9a) [(点击来切换)](gray show_text=&7单击以关闭接受传送请求 run_command=/huskhomes:tpignore)' tpignore_on_reminder: '[您当前正在忽略接受传送请求!](gray) [(点击来切换)](gray show_text=&7单击以开启接受传送请求run_command=/huskhomes:tpignore)' error_ignoring_teleport_requests: '[错误:](#ff3300) [你当前正在忽略传送请求!](#ff7e5e) [(点击来切换)](#ff7e5e show_text=&#ff7e5e&单击以开启接受传送请求 run_command=/huskhomes:tpignore)' -error_no_offline_position: '[错误:](#ff3300) [找不到 %1% 上次离线的位置.](#ff7e5e)' \ No newline at end of file +error_no_offline_position: '[错误:](#ff3300) [找不到 %1% 上次离线的位置.](#ff7e5e)' +error_invalid_player: '[Error:](#ff3300) [Please specify the name of a valid player!](#ff7e5e)' \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 60166e44..ee040941 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -126,6 +126,13 @@ permissions: children: huskhomes.bypass_timers: true huskhomes.commands: true + huskhomes.private_home_admin: true + huskhomes.private_home_admin: + description: Lets you access and edit private homes + children: + huskhomes.home.other: true + huskhomes.edithome.other: true + huskhomes.delhome.other: true huskhomes.bypass_timers: description: Bypass all timer restrictions. children: @@ -174,12 +181,18 @@ permissions: huskhomes.home: description: Allows you to teleport to a home default: true + huskhomes.home.other: + description: Allows you to teleport to all player homes + default: op huskhomes.sethome: description: Allows you to set homes default: true huskhomes.delhome: description: Allows you to delete a home default: true + huskhomes.delhome.other: + description: Allows you to delete any player home + default: op huskhomes.delhome.all: description: Allows you to delete all your homes default: true @@ -202,8 +215,11 @@ permissions: description: Allows you to teleport to public homes default: true huskhomes.edithome: - description: Allows you to edit home information + description: Allows you to edit home settings default: true + huskhomes.edithome.other: + description: Allows you to edit home settings for any home + default: op huskhomes.editwarp: description: Allows you to edit home information default: op