mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
Show edithome privacy toggle buttons only if user has permission, close #157
This commit is contained in:
1 parent
713bf2ea42
commit
ceafcf3f38
3 files changed
+25
-16
No files matched your search
@@ -2,6 +2,7 @@ package net.william278.huskhomes.command;
|
||||
|
||||
import de.themoep.minedown.MineDown;
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.config.Locales;
|
||||
import net.william278.huskhomes.config.Settings;
|
||||
import net.william278.huskhomes.player.OnlineUser;
|
||||
import net.william278.huskhomes.position.Home;
|
||||
@@ -88,7 +89,8 @@ public class EditHomeCommand extends CommandBase implements TabCompletable, Cons
|
||||
|
||||
if (editOperation == null) {
|
||||
getHomeEditorWindow(home, true, otherOwner,
|
||||
!otherOwner || editor.hasPermission(Permission.COMMAND_HOME_OTHER.node))
|
||||
!otherOwner || editor.hasPermission(Permission.COMMAND_HOME_OTHER.node),
|
||||
editor.hasPermission(Permission.COMMAND_EDIT_HOME_PRIVACY.node))
|
||||
.forEach(editor::sendMessage);
|
||||
return;
|
||||
}
|
||||
@@ -178,7 +180,8 @@ public class EditHomeCommand extends CommandBase implements TabCompletable, Cons
|
||||
// Show the menu if the menu flag is set
|
||||
if (showMenuFlag.get()) {
|
||||
getHomeEditorWindow(home, false, otherOwner,
|
||||
!otherOwner || editor.hasPermission(Permission.COMMAND_HOME_OTHER.node))
|
||||
!otherOwner || editor.hasPermission(Permission.COMMAND_HOME_OTHER.node),
|
||||
editor.hasPermission(Permission.COMMAND_EDIT_HOME_PRIVACY.node))
|
||||
.forEach(editor::sendMessage);
|
||||
}
|
||||
}));
|
||||
@@ -242,7 +245,8 @@ public class EditHomeCommand extends CommandBase implements TabCompletable, Cons
|
||||
// Show the menu if the menu flag is set
|
||||
if (showMenuFlag.get()) {
|
||||
getHomeEditorWindow(home, false, otherOwner,
|
||||
!otherOwner || editor.hasPermission(Permission.COMMAND_HOME_OTHER.node))
|
||||
!otherOwner || editor.hasPermission(Permission.COMMAND_HOME_OTHER.node),
|
||||
editor.hasPermission(Permission.COMMAND_EDIT_HOME_PRIVACY.node))
|
||||
.forEach(editor::sendMessage);
|
||||
}
|
||||
}
|
||||
@@ -267,15 +271,16 @@ public class EditHomeCommand extends CommandBase implements TabCompletable, Cons
|
||||
/**
|
||||
* Get a formatted home editor chat window for a supplied {@link Home}
|
||||
*
|
||||
* @param home The home to display
|
||||
* @param showTitle Whether to show the menu title
|
||||
* @param otherViewer If the viewer of the editor is not the homeowner
|
||||
* @param showTeleportButton Whether to show the teleport "use" button
|
||||
* @param home The home to display
|
||||
* @param showTitle Whether to show the menu title
|
||||
* @param otherViewer If the viewer of the editor is not the homeowner
|
||||
* @param showTeleportButton Whether to show the teleport "use" button
|
||||
* @param showPrivacyToggleButton Whether to show the home privacy toggle button
|
||||
* @return List of {@link MineDown} messages to send to the editor that form the menu
|
||||
*/
|
||||
@NotNull
|
||||
private List<MineDown> getHomeEditorWindow(@NotNull Home home, final boolean showTitle,
|
||||
final boolean otherViewer, final boolean showTeleportButton) {
|
||||
private List<MineDown> getHomeEditorWindow(@NotNull Home home, final boolean showTitle, final boolean otherViewer,
|
||||
final boolean showTeleportButton, final boolean showPrivacyToggleButton) {
|
||||
return new ArrayList<>() {{
|
||||
if (showTitle) {
|
||||
if (!otherViewer) {
|
||||
@@ -303,9 +308,11 @@ public class EditHomeCommand extends CommandBase implements TabCompletable, Cons
|
||||
}
|
||||
|
||||
if (!plugin.getSettings().crossServer) {
|
||||
plugin.getLocales().getLocale("edit_home_menu_world", home.world.name).ifPresent(this::add);
|
||||
plugin.getLocales().getLocale("edit_home_menu_world", home.world.name)
|
||||
.ifPresent(this::add);
|
||||
} else {
|
||||
plugin.getLocales().getLocale("edit_home_menu_world_server", home.world.name, home.server.name).ifPresent(this::add);
|
||||
plugin.getLocales().getLocale("edit_home_menu_world_server", home.world.name, home.server.name)
|
||||
.ifPresent(this::add);
|
||||
}
|
||||
|
||||
plugin.getLocales().getLocale("edit_home_menu_coordinates",
|
||||
@@ -319,9 +326,10 @@ public class EditHomeCommand extends CommandBase implements TabCompletable, Cons
|
||||
formattedName)
|
||||
.ifPresent(this::add);
|
||||
}
|
||||
plugin.getLocales().getLocale("edit_home_menu_manage_buttons",
|
||||
formattedName)
|
||||
.ifPresent(this::add);
|
||||
plugin.getLocales().getRawLocale("edit_home_menu_manage_buttons",
|
||||
Locales.escapeMineDown(formattedName), showPrivacyToggleButton ? plugin.getLocales()
|
||||
.getRawLocale("edit_home_menu_toggle_privacy_button").orElse("") : "")
|
||||
.map(MineDown::new).ifPresent(this::add);
|
||||
plugin.getLocales().getLocale("edit_home_menu_meta_edit_buttons",
|
||||
formattedName)
|
||||
.ifPresent(this::add);
|
||||
|
||||
@@ -103,7 +103,7 @@ public class Locales {
|
||||
* @return The escaped string
|
||||
*/
|
||||
@NotNull
|
||||
private static String escapeMineDown(@NotNull String string) {
|
||||
public static String escapeMineDown(@NotNull String string) {
|
||||
final StringBuilder value = new StringBuilder();
|
||||
for (int i = 0; i < string.length(); ++i) {
|
||||
char c = string.charAt(i);
|
||||
|
||||
@@ -17,7 +17,8 @@ edit_home_menu_world: '[⭘ %1%](#3b76ff-#5286ff show_text=b76ff&World:\n&8Th
|
||||
edit_home_menu_world_server: '[⭘ %1%](#3b76ff-#477fff show_text=b76ff&World:\n&8The world where the home is set) [☁ %2%](#477fff-#5286ff show_text=b76ff&Server:\n&8The server where the home is set)'
|
||||
edit_home_menu_coordinates: '[⚐ x: %1%, y: %2%, z: %3%](#ffc43b-#f5c962 show_text=&#ffc43b&Coordinates:\n&8Location of the home in the world\n&8yaw: %4%, pitch: %5%)\n'
|
||||
edit_home_menu_use_buttons: '[Use:](gray) [[⏩ Teleport…]](#00fb9a show_text=&7Click to teleport to this home run_command=/huskhomes:home %1%)'
|
||||
edit_home_menu_manage_buttons: '[Manage:](gray) [[❌ Delete…]](#ff3300 show_text=&7Click to delete this home\n&#ff3300&⚠ This cannot be undone! run_command=/huskhomes:delhome %1%) [[⚐ Relocate…]](#ffc43b-#f5c962 show_text=&7Click to relocate this home to your position run_command=/huskhomes:edithome %1% relocate -m) [[☀ Public/Private…]](#6fff00 show_text=&7Click to toggle the privacy of this home run_command=/huskhomes:edithome %1% privacy -m)'
|
||||
edit_home_menu_manage_buttons: '[Manage:](gray) [[❌ Delete…]](#ff3300 show_text=&7Click to delete this home\n&#ff3300&⚠ This cannot be undone! run_command=/huskhomes:delhome %1%) [[⚐ Relocate…]](#ffc43b-#f5c962 show_text=&7Click to relocate this home to your position run_command=/huskhomes:edithome %1% relocate -m) %2%'
|
||||
edit_home_menu_toggle_privacy_button: '[[☀ Public/Private…]](#6fff00 show_text=&7Click to toggle the privacy of this home run_command=/huskhomes:edithome %1% privacy -m)'
|
||||
edit_home_menu_meta_edit_buttons: '[Edit:](gray) [[✎ Rename…]](#c160ff-#bb50ff show_text=&7Click to suggest the rename command suggest_command=/huskhomes:edithome %1% rename ) [[ℹ Description…]](#bb50ff-#b43fff show_text=&7Click to suggest the edit description command suggest_command=/huskhomes:edithome %1% description )'
|
||||
|
||||
edit_home_privacy_public_success: '[Successfully made your home,](#00fb9a) [%1%](#00fb9a bold)[, open to the public.](#00fb9a)'
|
||||
|
||||
Reference in new issue
Block a user