Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-6149

Add PlayerBedEnterEvent.sendActionBar(boolean)

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
      • This server is running CraftBukkit version git-Spigot-17d78db-f8d4da0 (MC: 1.16.3) (Implementing API version 1.16.3-R0.1-SNAPSHOT)
      • You are running the latest version
    • CraftBukkit version git-Spigot-17d78db-f8d4da0
    • Yes

      // Cancelling the event will remove the vanilla message but the action bar message won't work, it will only work if you delay it.
      
      @EventHandler(priority = EventPriority.HIGHEST)
      public void onBedEnter(PlayerBedEnterEvent e) {
         e.setCancelled(true);
         e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("This message doesn't work."));
      }
      

       

      // Working example
      
      @EventHandler(priority = EventPriority.HIGHEST)
      public void onBedEnter(PlayerBedEnterEvent e) {
          e.setCancelled(true);
          Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
              @Override
              public void run() {
                  e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("This message works."));
              }
          }, 1L);
      }

       

            Unassigned Unassigned
            xDec0de_ xDec0de_
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: