It's been over 3 years :)
The common module was designed to prevent the internal modules depending on the core plugin. With the introduction of localization, this overcomplication became ever more exacerbated. Probably will play around a bit more to remove freshly introduced static abuse before release. Closes #61
This commit is contained in:
		@@ -22,12 +22,12 @@ import java.util.Collections;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.function.BiConsumer;
 | 
			
		||||
import java.util.function.Function;
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
import org.bukkit.OfflinePlayer;
 | 
			
		||||
import org.bukkit.command.Command;
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
import org.bukkit.command.TabExecutor;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
public class ContainerSettingCommand implements TabExecutor {
 | 
			
		||||
 | 
			
		||||
@@ -38,15 +38,14 @@ public class ContainerSettingCommand implements TabExecutor {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
 | 
			
		||||
    public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
 | 
			
		||||
        if (!(sender instanceof Player)) {
 | 
			
		||||
            sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
 | 
			
		||||
            plugin.sendMessage(sender, "messages.error.consoleUnsupported");
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Player player = (Player) sender;
 | 
			
		||||
        boolean any = command.getName().startsWith("any");
 | 
			
		||||
        String commandName = any ? "AnyContainer" : "SilentContainer";
 | 
			
		||||
        Function<Player, Boolean> getSetting = any ? plugin::getPlayerAnyChestStatus : plugin::getPlayerSilentChestStatus;
 | 
			
		||||
        BiConsumer<OfflinePlayer, Boolean> setSetting = any ? plugin::setPlayerAnyChestStatus : plugin::setPlayerSilentChestStatus;
 | 
			
		||||
 | 
			
		||||
@@ -66,13 +65,18 @@ public class ContainerSettingCommand implements TabExecutor {
 | 
			
		||||
            setSetting.accept(player, !getSetting.apply(player));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        sender.sendMessage(commandName + " is now " + (getSetting.apply(player) ? "ON" : "OFF") + ".");
 | 
			
		||||
        String onOff = plugin.getLocalizedMessage(player, getSetting.apply(player) ? "messages.info.on" : "messages.info.off");
 | 
			
		||||
        if (onOff == null) {
 | 
			
		||||
            onOff = String.valueOf(getSetting.apply(player));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        plugin.sendMessage(sender, "messages.info.settingState","%setting%", any ? "AnyContainer" : "SilentContainer", "%state%", onOff);
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
 | 
			
		||||
    public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
 | 
			
		||||
        if (!command.testPermissionSilent(sender) || args.length != 1) {
 | 
			
		||||
            return Collections.emptyList();
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -23,13 +23,13 @@ import com.lishid.openinv.util.TabCompleter;
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
import org.bukkit.OfflinePlayer;
 | 
			
		||||
import org.bukkit.command.Command;
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
import org.bukkit.command.TabExecutor;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.bukkit.scheduler.BukkitRunnable;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
public class OpenInvCommand implements TabExecutor {
 | 
			
		||||
 | 
			
		||||
@@ -42,9 +42,9 @@ public class OpenInvCommand implements TabExecutor {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
 | 
			
		||||
    public boolean onCommand(@NotNull final CommandSender sender, @NotNull final Command command, @NotNull final String label, @NotNull final String[] args) {
 | 
			
		||||
        if (!(sender instanceof Player)) {
 | 
			
		||||
            sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
 | 
			
		||||
            plugin.sendMessage(sender, "messages.error.consoleUnsupported");
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -79,7 +79,7 @@ public class OpenInvCommand implements TabExecutor {
 | 
			
		||||
                final OfflinePlayer offlinePlayer = OpenInvCommand.this.plugin.matchPlayer(name);
 | 
			
		||||
 | 
			
		||||
                if (offlinePlayer == null || !offlinePlayer.hasPlayedBefore() && !offlinePlayer.isOnline()) {
 | 
			
		||||
                    player.sendMessage(ChatColor.RED + "Player not found!");
 | 
			
		||||
                    plugin.sendMessage(player, "messages.error.invalidPlayer");
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
@@ -100,49 +100,48 @@ public class OpenInvCommand implements TabExecutor {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void openInventory(final Player player, final OfflinePlayer target, boolean openinv) {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        Player onlineTarget;
 | 
			
		||||
        boolean online = target.isOnline();
 | 
			
		||||
 | 
			
		||||
        if (!online) {
 | 
			
		||||
            // Try loading the player's data
 | 
			
		||||
            onlineTarget = this.plugin.loadPlayer(target);
 | 
			
		||||
 | 
			
		||||
            if (onlineTarget == null) {
 | 
			
		||||
                player.sendMessage(ChatColor.RED + "Player not found!");
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            onlineTarget = target.getPlayer();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (onlineTarget == null) {
 | 
			
		||||
            plugin.sendMessage(player, "messages.error.invalidPlayer");
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Permissions checks
 | 
			
		||||
        if (onlineTarget.equals(player)) {
 | 
			
		||||
            // Inventory: Additional permission required to open own inventory
 | 
			
		||||
            if (openinv && !Permissions.OPENSELF.hasPermission(player)) {
 | 
			
		||||
                player.sendMessage(ChatColor.RED + "You're not allowed to open your own inventory!");
 | 
			
		||||
                plugin.sendMessage(player, "messages.error.permissionOpenSelf");
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            // Enderchest: Additional permission required to open others' ender chests
 | 
			
		||||
            if (!openinv && !Permissions.ENDERCHEST_ALL.hasPermission(player)) {
 | 
			
		||||
                player.sendMessage(ChatColor.RED + "You do not have permission to access other players' ender chests.");
 | 
			
		||||
                plugin.sendMessage(player, "messages.error.permissionEnderAll");
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Protected check
 | 
			
		||||
            if (!Permissions.OVERRIDE.hasPermission(player)
 | 
			
		||||
                    && Permissions.EXEMPT.hasPermission(onlineTarget)) {
 | 
			
		||||
                player.sendMessage(ChatColor.RED + onlineTarget.getDisplayName() + "'s inventory is protected!");
 | 
			
		||||
                plugin.sendMessage(player, "messages.error.permissionExempt",
 | 
			
		||||
                        "%target%", onlineTarget.getDisplayName());
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Crossworld check
 | 
			
		||||
            if (!Permissions.CROSSWORLD.hasPermission(player)
 | 
			
		||||
                    && !onlineTarget.getWorld().equals(player.getWorld())) {
 | 
			
		||||
                player.sendMessage(
 | 
			
		||||
                        ChatColor.RED + onlineTarget.getDisplayName() + " is not in your world!");
 | 
			
		||||
                plugin.sendMessage(player, "messages.error.permissionCrossWorld",
 | 
			
		||||
                        "%target%", onlineTarget.getDisplayName());
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@@ -155,7 +154,7 @@ public class OpenInvCommand implements TabExecutor {
 | 
			
		||||
        try {
 | 
			
		||||
            inv = openinv ? this.plugin.getSpecialInventory(onlineTarget, online) : this.plugin.getSpecialEnderChest(onlineTarget, online);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            player.sendMessage(ChatColor.RED + "An error occurred creating " + onlineTarget.getDisplayName() + "'s inventory!");
 | 
			
		||||
            plugin.sendMessage(player, "messages.error.commandException");
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
@@ -165,7 +164,7 @@ public class OpenInvCommand implements TabExecutor {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
 | 
			
		||||
    public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
 | 
			
		||||
        if (!command.testPermissionSilent(sender) || args.length != 1) {
 | 
			
		||||
            return Collections.emptyList();
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -16,10 +16,10 @@
 | 
			
		||||
 | 
			
		||||
package com.lishid.openinv.commands;
 | 
			
		||||
 | 
			
		||||
import com.lishid.openinv.OpenInv;
 | 
			
		||||
import com.lishid.openinv.util.TabCompleter;
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
import org.bukkit.Chunk;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.World;
 | 
			
		||||
@@ -29,16 +29,23 @@ import org.bukkit.command.CommandSender;
 | 
			
		||||
import org.bukkit.command.TabExecutor;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.bukkit.inventory.InventoryHolder;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Command for searching containers in a radius of chunks.
 | 
			
		||||
 */
 | 
			
		||||
public class SearchContainerCommand implements TabExecutor {
 | 
			
		||||
 | 
			
		||||
    private final OpenInv plugin;
 | 
			
		||||
 | 
			
		||||
    public SearchContainerCommand(OpenInv plugin) {
 | 
			
		||||
        this.plugin = plugin;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
 | 
			
		||||
    public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
 | 
			
		||||
        if (!(sender instanceof Player)) {
 | 
			
		||||
            sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
 | 
			
		||||
            plugin.sendMessage(sender, "messages.error.consoleUnsupported");
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -47,10 +54,10 @@ public class SearchContainerCommand implements TabExecutor {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Material material = Material.getMaterial(args[0]);
 | 
			
		||||
        Material material = Material.getMaterial(args[0].toUpperCase());
 | 
			
		||||
 | 
			
		||||
        if (material == null) {
 | 
			
		||||
            sender.sendMessage(ChatColor.RED + "Unknown item: \"" + args[0] + "\"");
 | 
			
		||||
            plugin.sendMessage(sender, "messages.error.invalidMaterial", "%target%", args[0]);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -95,15 +102,18 @@ public class SearchContainerCommand implements TabExecutor {
 | 
			
		||||
        if (locations.length() > 0) {
 | 
			
		||||
            locations.delete(locations.length() - 2, locations.length());
 | 
			
		||||
        } else {
 | 
			
		||||
            sender.sendMessage("No containers found with " + material.toString());
 | 
			
		||||
            plugin.sendMessage(sender, "messages.info.container.noMatches",
 | 
			
		||||
                    "%target%", material.name());
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        sender.sendMessage("Containers holding item " + material.toString() + ": " + locations.toString());
 | 
			
		||||
        plugin.sendMessage(sender, "messages.info.container.matches",
 | 
			
		||||
                "%target%", material.name(), "%detail%", locations.toString());
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
 | 
			
		||||
    public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
 | 
			
		||||
        if (args.length < 1 || args.length > 2 || !command.testPermissionSilent(sender)) {
 | 
			
		||||
            return Collections.emptyList();
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -21,6 +21,7 @@ import com.lishid.openinv.util.TabCompleter;
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.NamespacedKey;
 | 
			
		||||
import org.bukkit.command.Command;
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
import org.bukkit.command.TabExecutor;
 | 
			
		||||
@@ -29,6 +30,7 @@ import org.bukkit.entity.Player;
 | 
			
		||||
import org.bukkit.inventory.Inventory;
 | 
			
		||||
import org.bukkit.inventory.ItemStack;
 | 
			
		||||
import org.bukkit.inventory.meta.ItemMeta;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Command adding the ability to search online players' inventories for enchantments of a specific
 | 
			
		||||
@@ -45,7 +47,7 @@ public class SearchEnchantCommand implements TabExecutor {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
 | 
			
		||||
    public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
 | 
			
		||||
        if (args.length == 0) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
@@ -54,14 +56,28 @@ public class SearchEnchantCommand implements TabExecutor {
 | 
			
		||||
        int level = 0;
 | 
			
		||||
 | 
			
		||||
        for (String argument : args) {
 | 
			
		||||
            Enchantment localEnchant = Enchantment.getByName(argument.toUpperCase());
 | 
			
		||||
            if (localEnchant != null) {
 | 
			
		||||
                enchant = localEnchant;
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            try {
 | 
			
		||||
                level = Integer.parseInt(argument);
 | 
			
		||||
                continue;
 | 
			
		||||
            } catch (NumberFormatException ignored) {}
 | 
			
		||||
 | 
			
		||||
            argument = argument.toLowerCase();
 | 
			
		||||
            int colon = argument.indexOf(':');
 | 
			
		||||
            NamespacedKey key;
 | 
			
		||||
            try {
 | 
			
		||||
                if (colon > -1 && colon < argument.length() - 1) {
 | 
			
		||||
                    key = new NamespacedKey(argument.substring(0, colon), argument.substring(colon + 1));
 | 
			
		||||
                } else {
 | 
			
		||||
                    key = NamespacedKey.minecraft(argument);
 | 
			
		||||
                }
 | 
			
		||||
            } catch (IllegalArgumentException ignored) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            Enchantment localEnchant = Enchantment.getByKey(key);
 | 
			
		||||
            if (localEnchant != null) {
 | 
			
		||||
                enchant = localEnchant;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Arguments not set correctly
 | 
			
		||||
@@ -97,12 +113,14 @@ public class SearchEnchantCommand implements TabExecutor {
 | 
			
		||||
            // Matches found, delete trailing comma and space
 | 
			
		||||
            players.delete(players.length() - 2, players.length());
 | 
			
		||||
        } else {
 | 
			
		||||
            sender.sendMessage("No players found with " + (enchant == null ? "any enchant" : enchant.getName())
 | 
			
		||||
                    + " of level " + level + " or higher.");
 | 
			
		||||
            plugin.sendMessage(sender, "messages.info.player.noMatches",
 | 
			
		||||
                    "%target%", (enchant != null ? enchant.getKey().toString() : "") + " >= " + level);
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        sender.sendMessage("Players: " + players.toString());
 | 
			
		||||
        plugin.sendMessage(sender, "messages.info.player.matches",
 | 
			
		||||
                "%target%", (enchant != null ? enchant.getKey().toString() : "") + " >= " + level,
 | 
			
		||||
                "%detail%", players.toString());
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -120,7 +138,7 @@ public class SearchEnchantCommand implements TabExecutor {
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
                ItemMeta meta = item.getItemMeta();
 | 
			
		||||
                if (!meta.hasEnchants()) {
 | 
			
		||||
                if (meta == null || !meta.hasEnchants()) {
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
                for (int enchLevel : meta.getEnchants().values()) {
 | 
			
		||||
@@ -134,13 +152,13 @@ public class SearchEnchantCommand implements TabExecutor {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
 | 
			
		||||
    public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
 | 
			
		||||
        if (!command.testPermissionSilent(sender) || args.length < 1 || args.length > 2) {
 | 
			
		||||
            return Collections.emptyList();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (args.length == 1) {
 | 
			
		||||
            return TabCompleter.completeObject(args[0], Enchantment::getName, Enchantment.values());
 | 
			
		||||
            return TabCompleter.completeObject(args[0], enchantment -> enchantment.getKey().toString(), Enchantment.values());
 | 
			
		||||
        } else {
 | 
			
		||||
            return TabCompleter.completeInteger(args[1]);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -20,13 +20,13 @@ import com.lishid.openinv.OpenInv;
 | 
			
		||||
import com.lishid.openinv.util.TabCompleter;
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.command.Command;
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
import org.bukkit.command.TabExecutor;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.bukkit.inventory.Inventory;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
public class SearchInvCommand implements TabExecutor {
 | 
			
		||||
 | 
			
		||||
@@ -37,32 +37,33 @@ public class SearchInvCommand implements TabExecutor {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
 | 
			
		||||
    public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
 | 
			
		||||
 | 
			
		||||
        Material material = null;
 | 
			
		||||
        int count = 1;
 | 
			
		||||
 | 
			
		||||
        if (args.length >= 1) {
 | 
			
		||||
            material = Material.getMaterial(args[0]);
 | 
			
		||||
            material = Material.getMaterial(args[0].toUpperCase());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (args.length >= 2) {
 | 
			
		||||
            try {
 | 
			
		||||
                count = Integer.parseInt(args[1]);
 | 
			
		||||
            } catch (NumberFormatException ex) {
 | 
			
		||||
                sender.sendMessage(ChatColor.RED + "'" + args[1] + "' is not a number!");
 | 
			
		||||
                plugin.sendMessage(sender, "messages.error.invalidNumber", "%target%", args[1]);
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (material == null) {
 | 
			
		||||
            sender.sendMessage(ChatColor.RED + "Unknown item: \"" + args[0] + "\"");
 | 
			
		||||
            plugin.sendMessage(sender, "messages.error.invalidMaterial", "%target%", args[0]);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        StringBuilder players = new StringBuilder();
 | 
			
		||||
        boolean searchInv = command.getName().equals("searchinv");
 | 
			
		||||
        for (Player player : plugin.getServer().getOnlinePlayers()) {
 | 
			
		||||
            Inventory inventory = command.getName().equals("searchinv") ? player.getInventory() : player.getEnderChest();
 | 
			
		||||
            Inventory inventory = searchInv ? player.getInventory() : player.getEnderChest();
 | 
			
		||||
            if (inventory.contains(material, count)) {
 | 
			
		||||
                players.append(player.getName()).append(", ");
 | 
			
		||||
            }
 | 
			
		||||
@@ -72,15 +73,18 @@ public class SearchInvCommand implements TabExecutor {
 | 
			
		||||
        if (players.length() > 0) {
 | 
			
		||||
            players.delete(players.length() - 2, players.length());
 | 
			
		||||
        } else {
 | 
			
		||||
            sender.sendMessage("No players found with " + material.toString());
 | 
			
		||||
            plugin.sendMessage(sender, "messages.info.player.noMatches",
 | 
			
		||||
                    "%target%", material.name());
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        sender.sendMessage("Players with the item " + material.toString() + ": " + players.toString());
 | 
			
		||||
        plugin.sendMessage(sender, "messages.info.player.matches",
 | 
			
		||||
                "%target%", material.name(), "%detail%", players.toString());
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
 | 
			
		||||
    public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
 | 
			
		||||
        if (args.length < 1 || args.length > 2 || !command.testPermissionSilent(sender)) {
 | 
			
		||||
            return Collections.emptyList();
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user