1.8.8 Help

Discussion in 'Spigot Plugin Development' started by QuackSporty, Aug 16, 2021.

  1. Where is the code failing? Is it able to retrieve the consumer from the map?
  2. No. I tested it by printing the Map's size by the event and it's returning 0, just when I add it with put method, the size is 1, but when I try to access it by the event, the size returns 0.
  3. Use the player's UUID as the key to the map instead of the Player object itself. I just tested this and it works (while using the Player object as the key does not).
  4. It's still not working. I tried the way you mentioned, but it's still not working, when I use the method, the Map size is 1 (which is right), but when I get the Map size by the event, it returns 0.
  5. Can you send your full code?
  6. My code is this:
    Code (Text):

    public class Main extends JavaPlugin implements CommandExecutor {

        private HashMap<UUID, Consumer<AsyncPlayerChatEvent>> map = new HashMap<>();
        public void onEnable() {
            Bukkit.getPluginManager().registerEvents(this, this);

        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            method((Player)sender, consumer -> {
            return true;

        public void event(AsyncPlayerChatEvent event){
            Player player = event.getPlayer();
            player.sendMessage(map.size() + "");
        public void method(Player player, Consumer<AsyncPlayerChatEvent> consumer){
            map.put(player.getUniqueId(), consumer);
            player.sendMessage(map.size() + "");