diff --git a/api/src/main/java/com/lishid/openinv/internal/IPlayerDataManager.java b/common/src/main/java/com/lishid/openinv/internal/IPlayerDataManager.java similarity index 87% rename from api/src/main/java/com/lishid/openinv/internal/IPlayerDataManager.java rename to common/src/main/java/com/lishid/openinv/internal/IPlayerDataManager.java index cddf6a5..4024564 100644 --- a/api/src/main/java/com/lishid/openinv/internal/IPlayerDataManager.java +++ b/common/src/main/java/com/lishid/openinv/internal/IPlayerDataManager.java @@ -16,6 +16,8 @@ package com.lishid.openinv.internal; +import java.util.Collection; + import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; @@ -47,4 +49,11 @@ public interface IPlayerDataManager { */ public OfflinePlayer getPlayerByID(String identifier); + /** + * Gets a Collection of all Players currently online. + * + * @return the Collection of Players + */ + public Collection getOnlinePlayers(); + } diff --git a/internal/1_4_5/src/main/java/com/lishid/openinv/internal/v1_4_5/PlayerDataManager.java b/internal/1_4_5/src/main/java/com/lishid/openinv/internal/v1_4_5/PlayerDataManager.java index e3a8ea5..104b282 100644 --- a/internal/1_4_5/src/main/java/com/lishid/openinv/internal/v1_4_5/PlayerDataManager.java +++ b/internal/1_4_5/src/main/java/com/lishid/openinv/internal/v1_4_5/PlayerDataManager.java @@ -16,6 +16,9 @@ package com.lishid.openinv.internal.v1_4_5; +import java.util.Arrays; +import java.util.Collection; + import com.lishid.openinv.internal.IPlayerDataManager; import org.bukkit.Bukkit; @@ -69,4 +72,9 @@ public class PlayerDataManager implements IPlayerDataManager { return player; } + @Override + public Collection getOnlinePlayers() { + return Arrays.asList(Bukkit.getOnlinePlayers()); + } + } diff --git a/internal/1_4_6/src/main/java/com/lishid/openinv/internal/v1_4_6/PlayerDataManager.java b/internal/1_4_6/src/main/java/com/lishid/openinv/internal/v1_4_6/PlayerDataManager.java index 0c09f7b..38c91c2 100644 --- a/internal/1_4_6/src/main/java/com/lishid/openinv/internal/v1_4_6/PlayerDataManager.java +++ b/internal/1_4_6/src/main/java/com/lishid/openinv/internal/v1_4_6/PlayerDataManager.java @@ -16,6 +16,9 @@ package com.lishid.openinv.internal.v1_4_6; +import java.util.Arrays; +import java.util.Collection; + import com.lishid.openinv.internal.IPlayerDataManager; import org.bukkit.Bukkit; @@ -69,4 +72,9 @@ public class PlayerDataManager implements IPlayerDataManager { return player; } + @Override + public Collection getOnlinePlayers() { + return Arrays.asList(Bukkit.getOnlinePlayers()); + } + } diff --git a/internal/v1_10_R1/src/main/java/com/lishid/openinv/internal/v1_10_R1/PlayerDataManager.java b/internal/v1_10_R1/src/main/java/com/lishid/openinv/internal/v1_10_R1/PlayerDataManager.java index 3909151..1b784fd 100644 --- a/internal/v1_10_R1/src/main/java/com/lishid/openinv/internal/v1_10_R1/PlayerDataManager.java +++ b/internal/v1_10_R1/src/main/java/com/lishid/openinv/internal/v1_10_R1/PlayerDataManager.java @@ -16,6 +16,7 @@ package com.lishid.openinv.internal.v1_10_R1; +import java.util.Collection; import java.util.UUID; import com.lishid.openinv.internal.IPlayerDataManager; @@ -79,4 +80,9 @@ public class PlayerDataManager implements IPlayerDataManager { } } + @Override + public Collection getOnlinePlayers() { + return Bukkit.getOnlinePlayers(); + } + } diff --git a/internal/v1_11_R1/src/main/java/com/lishid/openinv/internal/v1_11_R1/PlayerDataManager.java b/internal/v1_11_R1/src/main/java/com/lishid/openinv/internal/v1_11_R1/PlayerDataManager.java index 30bb00e..cc376ad 100644 --- a/internal/v1_11_R1/src/main/java/com/lishid/openinv/internal/v1_11_R1/PlayerDataManager.java +++ b/internal/v1_11_R1/src/main/java/com/lishid/openinv/internal/v1_11_R1/PlayerDataManager.java @@ -16,6 +16,7 @@ package com.lishid.openinv.internal.v1_11_R1; +import java.util.Collection; import java.util.UUID; import com.lishid.openinv.internal.IPlayerDataManager; @@ -79,4 +80,9 @@ public class PlayerDataManager implements IPlayerDataManager { } } + @Override + public Collection getOnlinePlayers() { + return Bukkit.getOnlinePlayers(); + } + } diff --git a/internal/v1_4_R1/src/main/java/com/lishid/openinv/internal/v1_4_R1/PlayerDataManager.java b/internal/v1_4_R1/src/main/java/com/lishid/openinv/internal/v1_4_R1/PlayerDataManager.java index f88713c..796d272 100644 --- a/internal/v1_4_R1/src/main/java/com/lishid/openinv/internal/v1_4_R1/PlayerDataManager.java +++ b/internal/v1_4_R1/src/main/java/com/lishid/openinv/internal/v1_4_R1/PlayerDataManager.java @@ -16,6 +16,9 @@ package com.lishid.openinv.internal.v1_4_R1; +import java.util.Arrays; +import java.util.Collection; + import com.lishid.openinv.internal.IPlayerDataManager; import org.bukkit.Bukkit; @@ -70,4 +73,9 @@ public class PlayerDataManager implements IPlayerDataManager { return player; } + @Override + public Collection getOnlinePlayers() { + return Arrays.asList(Bukkit.getOnlinePlayers()); + } + } diff --git a/internal/v1_5_R2/src/main/java/com/lishid/openinv/internal/v1_5_R2/PlayerDataManager.java b/internal/v1_5_R2/src/main/java/com/lishid/openinv/internal/v1_5_R2/PlayerDataManager.java index 1bea276..50ed22b 100644 --- a/internal/v1_5_R2/src/main/java/com/lishid/openinv/internal/v1_5_R2/PlayerDataManager.java +++ b/internal/v1_5_R2/src/main/java/com/lishid/openinv/internal/v1_5_R2/PlayerDataManager.java @@ -16,6 +16,9 @@ package com.lishid.openinv.internal.v1_5_R2; +import java.util.Arrays; +import java.util.Collection; + import com.lishid.openinv.internal.IPlayerDataManager; import org.bukkit.Bukkit; @@ -69,4 +72,9 @@ public class PlayerDataManager implements IPlayerDataManager { return player; } + @Override + public Collection getOnlinePlayers() { + return Arrays.asList(Bukkit.getOnlinePlayers()); + } + } diff --git a/internal/v1_5_R3/src/main/java/com/lishid/openinv/internal/v1_5_R3/PlayerDataManager.java b/internal/v1_5_R3/src/main/java/com/lishid/openinv/internal/v1_5_R3/PlayerDataManager.java index fbe6646..c0b181e 100644 --- a/internal/v1_5_R3/src/main/java/com/lishid/openinv/internal/v1_5_R3/PlayerDataManager.java +++ b/internal/v1_5_R3/src/main/java/com/lishid/openinv/internal/v1_5_R3/PlayerDataManager.java @@ -16,6 +16,9 @@ package com.lishid.openinv.internal.v1_5_R3; +import java.util.Arrays; +import java.util.Collection; + import com.lishid.openinv.internal.IPlayerDataManager; import org.bukkit.Bukkit; @@ -69,4 +72,9 @@ public class PlayerDataManager implements IPlayerDataManager { return player; } + @Override + public Collection getOnlinePlayers() { + return Arrays.asList(Bukkit.getOnlinePlayers()); + } + } diff --git a/internal/v1_6_R1/src/main/java/com/lishid/openinv/internal/v1_6_R1/PlayerDataManager.java b/internal/v1_6_R1/src/main/java/com/lishid/openinv/internal/v1_6_R1/PlayerDataManager.java index 3429d10..d1559f6 100644 --- a/internal/v1_6_R1/src/main/java/com/lishid/openinv/internal/v1_6_R1/PlayerDataManager.java +++ b/internal/v1_6_R1/src/main/java/com/lishid/openinv/internal/v1_6_R1/PlayerDataManager.java @@ -16,6 +16,9 @@ package com.lishid.openinv.internal.v1_6_R1; +import java.util.Arrays; +import java.util.Collection; + import com.lishid.openinv.internal.IPlayerDataManager; import org.bukkit.Bukkit; @@ -69,4 +72,9 @@ public class PlayerDataManager implements IPlayerDataManager { return player; } + @Override + public Collection getOnlinePlayers() { + return Arrays.asList(Bukkit.getOnlinePlayers()); + } + } diff --git a/internal/v1_6_R2/src/main/java/com/lishid/openinv/internal/v1_6_R2/PlayerDataManager.java b/internal/v1_6_R2/src/main/java/com/lishid/openinv/internal/v1_6_R2/PlayerDataManager.java index 03f50fa..36160bc 100644 --- a/internal/v1_6_R2/src/main/java/com/lishid/openinv/internal/v1_6_R2/PlayerDataManager.java +++ b/internal/v1_6_R2/src/main/java/com/lishid/openinv/internal/v1_6_R2/PlayerDataManager.java @@ -16,6 +16,9 @@ package com.lishid.openinv.internal.v1_6_R2; +import java.util.Arrays; +import java.util.Collection; + import com.lishid.openinv.internal.IPlayerDataManager; import org.bukkit.Bukkit; @@ -69,4 +72,9 @@ public class PlayerDataManager implements IPlayerDataManager { return player; } + @Override + public Collection getOnlinePlayers() { + return Arrays.asList(Bukkit.getOnlinePlayers()); + } + } diff --git a/internal/v1_6_R3/src/main/java/com/lishid/openinv/internal/v1_6_R3/PlayerDataManager.java b/internal/v1_6_R3/src/main/java/com/lishid/openinv/internal/v1_6_R3/PlayerDataManager.java index b0abe80..4f8758c 100644 --- a/internal/v1_6_R3/src/main/java/com/lishid/openinv/internal/v1_6_R3/PlayerDataManager.java +++ b/internal/v1_6_R3/src/main/java/com/lishid/openinv/internal/v1_6_R3/PlayerDataManager.java @@ -16,6 +16,9 @@ package com.lishid.openinv.internal.v1_6_R3; +import java.util.Arrays; +import java.util.Collection; + import com.lishid.openinv.internal.IPlayerDataManager; import org.bukkit.Bukkit; @@ -69,4 +72,9 @@ public class PlayerDataManager implements IPlayerDataManager { return player; } + @Override + public Collection getOnlinePlayers() { + return Arrays.asList(Bukkit.getOnlinePlayers()); + } + } diff --git a/internal/v1_7_R1/src/main/java/com/lishid/openinv/internal/v1_7_R1/PlayerDataManager.java b/internal/v1_7_R1/src/main/java/com/lishid/openinv/internal/v1_7_R1/PlayerDataManager.java index aa3795a..1b94342 100644 --- a/internal/v1_7_R1/src/main/java/com/lishid/openinv/internal/v1_7_R1/PlayerDataManager.java +++ b/internal/v1_7_R1/src/main/java/com/lishid/openinv/internal/v1_7_R1/PlayerDataManager.java @@ -16,6 +16,9 @@ package com.lishid.openinv.internal.v1_7_R1; +import java.util.Arrays; +import java.util.Collection; + import com.lishid.openinv.internal.IPlayerDataManager; import org.bukkit.Bukkit; @@ -70,4 +73,9 @@ public class PlayerDataManager implements IPlayerDataManager { return player; } + @Override + public Collection getOnlinePlayers() { + return Arrays.asList(Bukkit.getOnlinePlayers()); + } + } diff --git a/internal/v1_7_R2/src/main/java/com/lishid/openinv/internal/v1_7_R2/PlayerDataManager.java b/internal/v1_7_R2/src/main/java/com/lishid/openinv/internal/v1_7_R2/PlayerDataManager.java index d30a20c..cd786df 100644 --- a/internal/v1_7_R2/src/main/java/com/lishid/openinv/internal/v1_7_R2/PlayerDataManager.java +++ b/internal/v1_7_R2/src/main/java/com/lishid/openinv/internal/v1_7_R2/PlayerDataManager.java @@ -16,6 +16,9 @@ package com.lishid.openinv.internal.v1_7_R2; +import java.util.Arrays; +import java.util.Collection; + import com.lishid.openinv.internal.IPlayerDataManager; import org.bukkit.Bukkit; @@ -71,4 +74,9 @@ public class PlayerDataManager implements IPlayerDataManager { return player; } + @Override + public Collection getOnlinePlayers() { + return Arrays.asList(Bukkit.getOnlinePlayers()); + } + } diff --git a/internal/v1_7_R3/src/main/java/com/lishid/openinv/internal/v1_7_R3/PlayerDataManager.java b/internal/v1_7_R3/src/main/java/com/lishid/openinv/internal/v1_7_R3/PlayerDataManager.java index 8569033..ecc6cf0 100644 --- a/internal/v1_7_R3/src/main/java/com/lishid/openinv/internal/v1_7_R3/PlayerDataManager.java +++ b/internal/v1_7_R3/src/main/java/com/lishid/openinv/internal/v1_7_R3/PlayerDataManager.java @@ -16,6 +16,8 @@ package com.lishid.openinv.internal.v1_7_R3; +import java.util.Arrays; +import java.util.Collection; import java.util.UUID; import com.lishid.openinv.internal.IPlayerDataManager; @@ -78,4 +80,9 @@ public class PlayerDataManager implements IPlayerDataManager { } } + @Override + public Collection getOnlinePlayers() { + return Arrays.asList(Bukkit.getOnlinePlayers()); + } + } diff --git a/internal/v1_7_R4/pom.xml b/internal/v1_7_R4/pom.xml index 50ec61f..5afa9b8 100644 --- a/internal/v1_7_R4/pom.xml +++ b/internal/v1_7_R4/pom.xml @@ -17,6 +17,12 @@ openinvcommon 1.0-SNAPSHOT + + org.spigotmc + spigot-api + 1.7.10-R0.1-snapshot + provided + org.bukkit craftbukkit diff --git a/internal/v1_7_R4/src/main/java/com/lishid/openinv/internal/v1_7_R4/PlayerDataManager.java b/internal/v1_7_R4/src/main/java/com/lishid/openinv/internal/v1_7_R4/PlayerDataManager.java index 5209859..62f85b9 100644 --- a/internal/v1_7_R4/src/main/java/com/lishid/openinv/internal/v1_7_R4/PlayerDataManager.java +++ b/internal/v1_7_R4/src/main/java/com/lishid/openinv/internal/v1_7_R4/PlayerDataManager.java @@ -16,6 +16,7 @@ package com.lishid.openinv.internal.v1_7_R4; +import java.util.Collection; import java.util.UUID; import com.lishid.openinv.internal.IPlayerDataManager; @@ -78,4 +79,9 @@ public class PlayerDataManager implements IPlayerDataManager { } } + @Override + public Collection getOnlinePlayers() { + return Bukkit.getOnlinePlayers(); + } + } diff --git a/internal/v1_8_R1/src/main/java/com/lishid/openinv/internal/v1_8_R1/PlayerDataManager.java b/internal/v1_8_R1/src/main/java/com/lishid/openinv/internal/v1_8_R1/PlayerDataManager.java index bbd9e26..4e5c5c5 100644 --- a/internal/v1_8_R1/src/main/java/com/lishid/openinv/internal/v1_8_R1/PlayerDataManager.java +++ b/internal/v1_8_R1/src/main/java/com/lishid/openinv/internal/v1_8_R1/PlayerDataManager.java @@ -16,6 +16,7 @@ package com.lishid.openinv.internal.v1_8_R1; +import java.util.Collection; import java.util.UUID; import com.lishid.openinv.internal.IPlayerDataManager; @@ -79,4 +80,9 @@ public class PlayerDataManager implements IPlayerDataManager { } } + @Override + public Collection getOnlinePlayers() { + return Bukkit.getOnlinePlayers(); + } + } diff --git a/internal/v1_8_R2/src/main/java/com/lishid/openinv/internal/v1_8_R2/PlayerDataManager.java b/internal/v1_8_R2/src/main/java/com/lishid/openinv/internal/v1_8_R2/PlayerDataManager.java index 6e9d1de..4106af1 100644 --- a/internal/v1_8_R2/src/main/java/com/lishid/openinv/internal/v1_8_R2/PlayerDataManager.java +++ b/internal/v1_8_R2/src/main/java/com/lishid/openinv/internal/v1_8_R2/PlayerDataManager.java @@ -16,6 +16,7 @@ package com.lishid.openinv.internal.v1_8_R2; +import java.util.Collection; import java.util.UUID; import com.lishid.openinv.internal.IPlayerDataManager; @@ -79,4 +80,9 @@ public class PlayerDataManager implements IPlayerDataManager { } } + @Override + public Collection getOnlinePlayers() { + return Bukkit.getOnlinePlayers(); + } + } diff --git a/internal/v1_8_R3/src/main/java/com/lishid/openinv/internal/v1_8_R3/PlayerDataManager.java b/internal/v1_8_R3/src/main/java/com/lishid/openinv/internal/v1_8_R3/PlayerDataManager.java index e7e6a4e..62eee4c 100644 --- a/internal/v1_8_R3/src/main/java/com/lishid/openinv/internal/v1_8_R3/PlayerDataManager.java +++ b/internal/v1_8_R3/src/main/java/com/lishid/openinv/internal/v1_8_R3/PlayerDataManager.java @@ -16,6 +16,7 @@ package com.lishid.openinv.internal.v1_8_R3; +import java.util.Collection; import java.util.UUID; import com.lishid.openinv.internal.IPlayerDataManager; @@ -79,4 +80,9 @@ public class PlayerDataManager implements IPlayerDataManager { } } + @Override + public Collection getOnlinePlayers() { + return Bukkit.getOnlinePlayers(); + } + } diff --git a/internal/v1_9_R1/src/main/java/com/lishid/openinv/internal/v1_9_R1/PlayerDataManager.java b/internal/v1_9_R1/src/main/java/com/lishid/openinv/internal/v1_9_R1/PlayerDataManager.java index 7e2cd46..3a89a49 100644 --- a/internal/v1_9_R1/src/main/java/com/lishid/openinv/internal/v1_9_R1/PlayerDataManager.java +++ b/internal/v1_9_R1/src/main/java/com/lishid/openinv/internal/v1_9_R1/PlayerDataManager.java @@ -16,6 +16,7 @@ package com.lishid.openinv.internal.v1_9_R1; +import java.util.Collection; import java.util.UUID; import com.lishid.openinv.internal.IPlayerDataManager; @@ -79,4 +80,9 @@ public class PlayerDataManager implements IPlayerDataManager { } } + @Override + public Collection getOnlinePlayers() { + return Bukkit.getOnlinePlayers(); + } + } diff --git a/internal/v1_9_R2/src/main/java/com/lishid/openinv/internal/v1_9_R2/PlayerDataManager.java b/internal/v1_9_R2/src/main/java/com/lishid/openinv/internal/v1_9_R2/PlayerDataManager.java index fa8d3d8..d5fc3d2 100644 --- a/internal/v1_9_R2/src/main/java/com/lishid/openinv/internal/v1_9_R2/PlayerDataManager.java +++ b/internal/v1_9_R2/src/main/java/com/lishid/openinv/internal/v1_9_R2/PlayerDataManager.java @@ -16,6 +16,7 @@ package com.lishid.openinv.internal.v1_9_R2; +import java.util.Collection; import java.util.UUID; import com.lishid.openinv.internal.IPlayerDataManager; @@ -79,4 +80,9 @@ public class PlayerDataManager implements IPlayerDataManager { } } + @Override + public Collection getOnlinePlayers() { + return Bukkit.getOnlinePlayers(); + } + } diff --git a/plugin/plugin-core/src/main/java/com/lishid/openinv/OpenInv.java b/plugin/plugin-core/src/main/java/com/lishid/openinv/OpenInv.java index 2cbdeb3..36586ba 100644 --- a/plugin/plugin-core/src/main/java/com/lishid/openinv/OpenInv.java +++ b/plugin/plugin-core/src/main/java/com/lishid/openinv/OpenInv.java @@ -16,6 +16,10 @@ package com.lishid.openinv; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -143,10 +147,10 @@ public class OpenInv extends JavaPlugin implements IOpenInv { // Register commands to their executors getCommand("openinv").setExecutor(new OpenInvPluginCommand(this)); getCommand("openender").setExecutor(new OpenEnderPluginCommand(this)); - SearchInvPluginCommand searchInv = new SearchInvPluginCommand(); + SearchInvPluginCommand searchInv = new SearchInvPluginCommand(this); getCommand("searchinv").setExecutor(searchInv); getCommand("searchender").setExecutor(searchInv); - getCommand("searchenchant").setExecutor(new SearchEnchantPluginCommand()); + getCommand("searchenchant").setExecutor(new SearchEnchantPluginCommand(this)); getCommand("silentchest").setExecutor(new SilentChestPluginCommand(this)); getCommand("anychest").setExecutor(new AnyChestPluginCommand(this)); @@ -526,6 +530,36 @@ public class OpenInv extends JavaPlugin implements IOpenInv { this.pluginUsage.removeAll(plugin.getClass()); } + @SuppressWarnings("unchecked") + public Collection getOnlinePlayers() { + + if (this.playerLoader != null) { + return this.playerLoader.getOnlinePlayers(); + } + + Method getOnlinePlayers; + try { + getOnlinePlayers = Bukkit.class.getDeclaredMethod("getOnlinePlayers"); + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); + } + + Object onlinePlayers; + try { + onlinePlayers = getOnlinePlayers.invoke(null); + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); + } + + if (onlinePlayers instanceof List) { + return (Collection) onlinePlayers; + } + + return Arrays.asList((Player[]) onlinePlayers); + } + /** * Method for handling a Player coming online. * diff --git a/plugin/plugin-core/src/main/java/com/lishid/openinv/commands/SearchEnchantPluginCommand.java b/plugin/plugin-core/src/main/java/com/lishid/openinv/commands/SearchEnchantPluginCommand.java index 4e8a16d..ec50990 100644 --- a/plugin/plugin-core/src/main/java/com/lishid/openinv/commands/SearchEnchantPluginCommand.java +++ b/plugin/plugin-core/src/main/java/com/lishid/openinv/commands/SearchEnchantPluginCommand.java @@ -1,6 +1,7 @@ package com.lishid.openinv.commands; -import org.bukkit.Bukkit; +import com.lishid.openinv.OpenInv; + import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -19,6 +20,12 @@ import org.bukkit.inventory.meta.ItemMeta; */ public class SearchEnchantPluginCommand implements CommandExecutor { + private final OpenInv plugin; + + public SearchEnchantPluginCommand(OpenInv plugin) { + this.plugin = plugin; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (args.length == 0) { @@ -45,7 +52,7 @@ public class SearchEnchantPluginCommand implements CommandExecutor { } StringBuilder players = new StringBuilder(); - for (Player player : Bukkit.getServer().getOnlinePlayers()) { + for (Player player : plugin.getOnlinePlayers()) { boolean flagInventory = containsEnchantment(player.getInventory(), enchant, level); boolean flagEnder = containsEnchantment(player.getEnderChest(), enchant, level); diff --git a/plugin/plugin-core/src/main/java/com/lishid/openinv/commands/SearchInvPluginCommand.java b/plugin/plugin-core/src/main/java/com/lishid/openinv/commands/SearchInvPluginCommand.java index 9dc2966..2979593 100644 --- a/plugin/plugin-core/src/main/java/com/lishid/openinv/commands/SearchInvPluginCommand.java +++ b/plugin/plugin-core/src/main/java/com/lishid/openinv/commands/SearchInvPluginCommand.java @@ -16,7 +16,8 @@ package com.lishid.openinv.commands; -import org.bukkit.Bukkit; +import com.lishid.openinv.OpenInv; + import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.command.Command; @@ -27,6 +28,12 @@ import org.bukkit.inventory.Inventory; public class SearchInvPluginCommand implements CommandExecutor { + private final OpenInv plugin; + + public SearchInvPluginCommand(OpenInv plugin) { + this.plugin = plugin; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -54,7 +61,7 @@ public class SearchInvPluginCommand implements CommandExecutor { } StringBuilder players = new StringBuilder(); - for (Player player : Bukkit.getServer().getOnlinePlayers()) { + for (Player player : plugin.getOnlinePlayers()) { Inventory inventory = command.getName().equals("searchinv") ? player.getInventory() : player.getEnderChest(); if (inventory.contains(material, count)) { players.append(player.getName()).append(", ");