From de2a8f4e3b0a5362c077bcac3812fd24d58fcc21 Mon Sep 17 00:00:00 2001 From: TonyJamesStark Date: Fri, 24 Apr 2026 11:52:55 -0700 Subject: [PATCH 1/3] hotfix: changed format of searchchest command to include customname and print as list --- .../command/SearchContainerCommand.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/plugin/src/main/java/com/lishid/openinv/command/SearchContainerCommand.java b/plugin/src/main/java/com/lishid/openinv/command/SearchContainerCommand.java index 1b8eb1b2..6fd6d1a3 100644 --- a/plugin/src/main/java/com/lishid/openinv/command/SearchContainerCommand.java +++ b/plugin/src/main/java/com/lishid/openinv/command/SearchContainerCommand.java @@ -28,6 +28,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; +import org.bukkit.Nameable; import org.bukkit.inventory.InventoryHolder; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; @@ -95,6 +96,7 @@ public boolean onCommand( World world = senderPlayer.getWorld(); Chunk centerChunk = senderPlayer.getLocation().getChunk(); StringBuilder locations = new StringBuilder(); + locations.append("\n"); for (int dX = -radius; dX <= radius; ++dX) { for (int dZ = -radius; dZ <= radius; ++dZ) { @@ -109,17 +111,25 @@ public boolean onCommand( if (!SearchHelper.findMatch(holder.getInventory(), itemStack -> itemStack.getType() == material)) { continue; } - locations.append(holder.getInventory().getType().name().toLowerCase(Locale.ENGLISH)).append(" (") - .append(tileEntity.getX()).append(',').append(tileEntity.getY()).append(',') - .append(tileEntity.getZ()).append("), "); + locations.append(holder.getInventory().getType().name().toLowerCase(Locale.ENGLISH)).append(": "); + if (holder instanceof Nameable){ + Nameable nm = (Nameable) holder; + String custom_name = nm.getCustomName(); + if (custom_name != null){ + locations.append(custom_name.toLowerCase(Locale.ENGLISH).strip()).append(" - "); + } + } + locations.append(" (").append(tileEntity.getX()).append(',').append(tileEntity.getY()).append(',') + .append(tileEntity.getZ()).append(")\n"); } } } // Matches found, delete trailing comma and space - if (!locations.isEmpty()) { - locations.delete(locations.length() - 2, locations.length()); - } else { + // if (!locations.isEmpty()) { + // locations.delete(locations.length() - 2, locations.length()); + // } else { + if (locations.isEmpty()){ lang.sendMessage( sender, "messages.info.container.noMatches", From 8fefe763f349dff439dfd52144587fb3e806d588 Mon Sep 17 00:00:00 2001 From: TonyJamesStark Date: Tue, 28 Apr 2026 10:12:09 -0700 Subject: [PATCH 2/3] changes requested from PR --- .../command/SearchContainerCommand.java | 30 +++++++------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/plugin/src/main/java/com/lishid/openinv/command/SearchContainerCommand.java b/plugin/src/main/java/com/lishid/openinv/command/SearchContainerCommand.java index 6fd6d1a3..480a1f88 100644 --- a/plugin/src/main/java/com/lishid/openinv/command/SearchContainerCommand.java +++ b/plugin/src/main/java/com/lishid/openinv/command/SearchContainerCommand.java @@ -55,8 +55,7 @@ public boolean onCommand( @NotNull CommandSender sender, @NotNull Command command, @NotNull String label, - @NotNull String[] args - ) { + @NotNull String[] args) { if (!(sender instanceof Player senderPlayer)) { lang.sendMessage(sender, "messages.error.consoleUnsupported"); return true; @@ -73,8 +72,7 @@ public boolean onCommand( lang.sendMessage( sender, "messages.error.invalidMaterial", - new Replacement("%target%", args[0]) - ); + new Replacement("%target%", args[0])); return false; } @@ -112,11 +110,10 @@ public boolean onCommand( continue; } locations.append(holder.getInventory().getType().name().toLowerCase(Locale.ENGLISH)).append(": "); - if (holder instanceof Nameable){ - Nameable nm = (Nameable) holder; - String custom_name = nm.getCustomName(); - if (custom_name != null){ - locations.append(custom_name.toLowerCase(Locale.ENGLISH).strip()).append(" - "); + if (holder instanceof Nameable named) { + String customName = named.getCustomName(); + if (customName != null) { + locations.append(customName.toLowerCase(Locale.ENGLISH).strip()).append(" - "); } } locations.append(" (").append(tileEntity.getX()).append(',').append(tileEntity.getY()).append(',') @@ -125,16 +122,11 @@ public boolean onCommand( } } - // Matches found, delete trailing comma and space - // if (!locations.isEmpty()) { - // locations.delete(locations.length() - 2, locations.length()); - // } else { - if (locations.isEmpty()){ + if (locations.isEmpty()) { lang.sendMessage( sender, "messages.info.container.noMatches", - new Replacement("%target%", material.name()) - ); + new Replacement("%target%", material.name())); return true; } @@ -142,8 +134,7 @@ public boolean onCommand( sender, "messages.info.container.matches", new Replacement("%target%", material.name()), - new Replacement("%detail%", locations.toString()) - ); + new Replacement("%detail%", locations.toString())); return true; } @@ -152,8 +143,7 @@ public List onTabComplete( @NotNull CommandSender sender, @NotNull Command command, @NotNull String label, - String[] args - ) { + String[] args) { if (args.length < 1 || args.length > 2 || !command.testPermissionSilent(sender)) { return Collections.emptyList(); } From 503ac62844f5a7e17b9952f3c9c4f6345a27c627 Mon Sep 17 00:00:00 2001 From: TonyJamesStark Date: Mon, 4 May 2026 05:32:18 -0700 Subject: [PATCH 3/3] additional requested change, logic bug --- .../java/com/lishid/openinv/command/SearchContainerCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/src/main/java/com/lishid/openinv/command/SearchContainerCommand.java b/plugin/src/main/java/com/lishid/openinv/command/SearchContainerCommand.java index 480a1f88..db0bb781 100644 --- a/plugin/src/main/java/com/lishid/openinv/command/SearchContainerCommand.java +++ b/plugin/src/main/java/com/lishid/openinv/command/SearchContainerCommand.java @@ -122,7 +122,7 @@ public boolean onCommand( } } - if (locations.isEmpty()) { + if (locations.length() < 2) { lang.sendMessage( sender, "messages.info.container.noMatches",