Permission Events
Package: com.hypixel.hytale.server.core.event.events.permissions
Events related to permission and group changes.
PlayerGroupEvent
Section titled “PlayerGroupEvent”Fired when a player is added to or removed from a permission group.
Class: com.hypixel.hytale.server.core.event.events.permissions.PlayerGroupEvent
| Property | Value |
|---|---|
| Extends | PlayerPermissionChangeEvent |
| KeyType | Void |
| Cancellable | No |
Getter Methods
Section titled “Getter Methods”| Method | Return Type | Description |
|---|---|---|
getPlayerUuid() | UUID | The affected player (inherited) |
getGroupName() | String | The group name |
Fields
Section titled “Fields”| Field | Type | Description |
|---|---|---|
playerUuid | UUID | The affected player |
groupName | String | The group name |
Subclasses
Section titled “Subclasses”PlayerGroupEvent.Added
Section titled “PlayerGroupEvent.Added”Fired when a player is added to a permission group.
Methods:
| Method | Return Type | Description |
|---|---|---|
getPlayerUuid() | UUID | The UUID of the affected player (inherited) |
getGroupName() | String | The name of the group the player was added to (inherited) |
PlayerGroupEvent.Removed
Section titled “PlayerGroupEvent.Removed”Fired when a player is removed from a permission group.
Methods:
| Method | Return Type | Description |
|---|---|---|
getPlayerUuid() | UUID | The UUID of the affected player (inherited) |
getGroupName() | String | The name of the group the player was removed from (inherited) |
GroupPermissionChangeEvent
Section titled “GroupPermissionChangeEvent”Fired when permissions are added to or removed from a group. This is an abstract base class.
Class: com.hypixel.hytale.server.core.event.events.permissions.GroupPermissionChangeEvent
| Property | Value |
|---|---|
| Abstract | Yes |
| Implements | IEvent<Void> |
| KeyType | Void |
| Cancellable | No |
Getter Methods
Section titled “Getter Methods”| Method | Return Type | Description |
|---|---|---|
getGroupName() | String | The affected group |
Fields
Section titled “Fields”| Field | Type | Description |
|---|---|---|
groupName | String | The affected group |
Subclasses
Section titled “Subclasses”GroupPermissionChangeEvent.Added
Section titled “GroupPermissionChangeEvent.Added”Fired when permissions are added to a group.
Methods:
| Method | Return Type | Description |
|---|---|---|
getGroupName() | String | The name of the affected group (inherited) |
getAddedPermissions() | Set<String> | An unmodifiable set of permission strings that were added |
GroupPermissionChangeEvent.Removed
Section titled “GroupPermissionChangeEvent.Removed”Fired when permissions are removed from a group.
Methods:
| Method | Return Type | Description |
|---|---|---|
getGroupName() | String | The name of the affected group (inherited) |
getRemovedPermissions() | Set<String> | An unmodifiable set of permission strings that were removed |
PlayerPermissionChangeEvent
Section titled “PlayerPermissionChangeEvent”Fired when a player’s permissions change (directly or via group). This is an abstract base class.
Class: com.hypixel.hytale.server.core.event.events.permissions.PlayerPermissionChangeEvent
| Property | Value |
|---|---|
| Abstract | Yes |
| Implements | IEvent<Void> |
| KeyType | Void |
| Cancellable | No |
Getter Methods
Section titled “Getter Methods”| Method | Return Type | Description |
|---|---|---|
getPlayerUuid() | UUID | The affected player |
Fields
Section titled “Fields”| Field | Type | Description |
|---|---|---|
playerUuid | UUID | The affected player |
Subclasses
Section titled “Subclasses”PlayerPermissionChangeEvent.PermissionsAdded
Section titled “PlayerPermissionChangeEvent.PermissionsAdded”Fired when permissions are directly added to a player.
Methods:
| Method | Return Type | Description |
|---|---|---|
getPlayerUuid() | UUID | The UUID of the affected player (inherited) |
getAddedPermissions() | Set<String> | An unmodifiable set of permission strings that were added |
PlayerPermissionChangeEvent.PermissionsRemoved
Section titled “PlayerPermissionChangeEvent.PermissionsRemoved”Fired when permissions are directly removed from a player.
Methods:
| Method | Return Type | Description |
|---|---|---|
getPlayerUuid() | UUID | The UUID of the affected player (inherited) |
getRemovedPermissions() | Set<String> | An unmodifiable set of permission strings that were removed |
PlayerPermissionChangeEvent.GroupAdded
Section titled “PlayerPermissionChangeEvent.GroupAdded”Fired when a player is added to a permission group.
Methods:
| Method | Return Type | Description |
|---|---|---|
getPlayerUuid() | UUID | The UUID of the affected player (inherited) |
getGroupName() | String | The name of the group the player was added to |
PlayerPermissionChangeEvent.GroupRemoved
Section titled “PlayerPermissionChangeEvent.GroupRemoved”Fired when a player is removed from a permission group.
Methods:
| Method | Return Type | Description |
|---|---|---|
getPlayerUuid() | UUID | The UUID of the affected player (inherited) |
getGroupName() | String | The name of the group the player was removed from |
Example (from FlyCameraModule)
Section titled “Example (from FlyCameraModule)”Real usage showing how to react to permission changes:
@Overrideprotected void setup() { EventBus eventBus = HytaleServer.get().getEventBus();
// react when permissions are directly removed from a player eventBus.register(PlayerPermissionChangeEvent.PermissionsRemoved.class, event -> { if (PermissionsModule.hasPermission(event.getRemovedPermissions(), "hytale.camera.flycam") == Boolean.TRUE) { checkAndEnforceFlyCameraPermission(event.getPlayerUuid()); } });
// react when a player is removed from a group eventBus.register(PlayerGroupEvent.Removed.class, event -> { checkAndEnforceFlyCameraPermission(event.getPlayerUuid()); });
// react when permissions are removed from a group (affects all members) eventBus.register(GroupPermissionChangeEvent.Removed.class, event -> { if (PermissionsModule.hasPermission(event.getRemovedPermissions(), "hytale.camera.flycam") != Boolean.TRUE) { return; } // check all players in this group String groupName = event.getGroupName(); for (PlayerRef playerRef : Universe.get().getPlayers()) { UUID uuid = playerRef.getUuid(); Set<String> groups = PermissionsModule.get().getGroupsForUser(uuid); if (groups.contains(groupName)) { checkAndEnforceFlyCameraPermission(uuid); } } });}
private void checkAndEnforceFlyCameraPermission(UUID playerUuid) { // disable fly camera if player no longer has permission if (!PermissionsModule.get().hasPermission(playerUuid, "hytale.camera.flycam")) { disableFlyCameraForPlayer(playerUuid); }}