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
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
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
org.bukkit.event.Event.Result -
Constructor Summary
ConstructorsConstructorDescriptionChatChannelSwitchEvent(@NotNull org.bukkit.entity.Player player, @NotNull ChatChannel oldChannel, @NotNull ChatChannel newChannel) -
Method Summary
Modifier and TypeMethodDescriptionstatic org.bukkit.event.HandlerList@NotNull org.bukkit.event.HandlerListGets the handler list for this event.@NotNull ChatChannelGets the channel the player is switching to.@NotNull ChatChannelGets the channel the player is switching from.@NotNull org.bukkit.entity.PlayerGets the player switching channels.@NotNull UUIDGets the player's UUID.booleanvoidsetCancelled(boolean cancel) voidsetNewChannel(@NotNull ChatChannel newChannel) Sets the channel the player will switch to.Methods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
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
Gets the player's UUID.- Returns:
- The player's UUID
-
getOldChannel
Gets the channel the player is switching from.- Returns:
- The old/current channel
-
getNewChannel
Gets the channel the player is switching to.- Returns:
- The new channel
-
setNewChannel
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:
isCancelledin interfaceorg.bukkit.event.Cancellable
-
setCancelled
public void setCancelled(boolean cancel) - Specified by:
setCancelledin interfaceorg.bukkit.event.Cancellable
-
getHandlers
@NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()Description copied from class:ZentrixEventGets the handler list for this event.- Overrides:
getHandlersin classZentrixEvent- Returns:
- The handler list
-
getHandlerList
public static org.bukkit.event.HandlerList getHandlerList()
-