Class ChatChannelSwitchEvent

java.lang.Object
org.bukkit.event.Event
dev.itsharshxd.zentrix.api.events.ZentrixEvent
dev.itsharshxd.zentrix.api.events.chat.ChatChannelSwitchEvent
All Implemented Interfaces:
org.bukkit.event.Cancellable

public class ChatChannelSwitchEvent extends ZentrixEvent implements org.bukkit.event.Cancellable
Called when a player switches their chat channel.

This event is cancellable. Cancelling prevents the channel change.

Example Usage


 @EventHandler
 public void onChannelSwitch(ChatChannelSwitchEvent event) {
     if (event.getNewChannel() == ChatChannel.PARTY) {
         // Block switching to party chat for certain players
         if (!hasPermission(event.getPlayer())) {
             event.setCancelled(true);
         }
     }
 }
 
Since:
1.2.0
  • Constructor Details

    • ChatChannelSwitchEvent

      public ChatChannelSwitchEvent(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull ChatChannel oldChannel, @NotNull @NotNull ChatChannel newChannel)
  • Method Details

    • getPlayer

      @NotNull public @NotNull org.bukkit.entity.Player getPlayer()
      Gets the player switching channels.
      Returns:
      The player
    • getPlayerId

      @NotNull public @NotNull UUID getPlayerId()
      Gets the player's UUID.
      Returns:
      The player's UUID
    • getOldChannel

      @NotNull public @NotNull ChatChannel getOldChannel()
      Gets the channel the player is switching from.
      Returns:
      The old/current channel
    • getNewChannel

      @NotNull public @NotNull ChatChannel getNewChannel()
      Gets the channel the player is switching to.
      Returns:
      The new channel
    • setNewChannel

      public void setNewChannel(@NotNull @NotNull ChatChannel newChannel)
      Sets the channel the player will switch to.

      This allows addons to redirect channel switches.

      Parameters:
      newChannel - The new target channel
    • isCancelled

      public boolean isCancelled()
      Specified by:
      isCancelled in interface org.bukkit.event.Cancellable
    • setCancelled

      public void setCancelled(boolean cancel)
      Specified by:
      setCancelled in interface org.bukkit.event.Cancellable
    • getHandlers

      @NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()
      Description copied from class: ZentrixEvent
      Gets the handler list for this event.
      Overrides:
      getHandlers in class ZentrixEvent
      Returns:
      The handler list
    • getHandlerList

      public static org.bukkit.event.HandlerList getHandlerList()