Skip to content

SettingUpdateEvent

David Rodriguez edited this page Mar 13, 2024 · 2 revisions

Overview

The SettingUpdateEvent is a custom event provided by the plugin called every time a setting changes for a player. The event defines methods to access the modified setting, its new value, its previous value, and the player to whom it belongs.

Example

The following is an example of how to use the custom event to send players a message that shows the name of the setting modified and the new value it was assigned:

@EventHandler
public void onSettingUpdate(SettingUpdateEvent event) {
  Player player = event.getPlayer();
  Setting setting = event.getSetting();
  int newValue = event.getNewValue();
  int previousValue = event.getPreviousValue();
  player.sendMessage("Setting " + setting.getName() + " changed from " + previousValue + " to " + newValue);
}

Clone this wiki locally