mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-07 16:57:42 +01:00
addition of PlayerGameModeChangeEvent
By: sunkid <sunkid@iminurnetz.com>
This commit is contained in:
parent
6d19165044
commit
a7f6bb5cd4
@ -39,6 +39,10 @@ public class GameModeCommand extends VanillaCommand {
|
||||
Command.broadcastCommandMessage(sender, "Setting " + player.getName() + " to game mode " + mode.getValue());
|
||||
|
||||
player.setGameMode(mode);
|
||||
|
||||
if (mode != player.getGameMode()) {
|
||||
Command.broadcastCommandMessage(sender, "The game mode change for " + player.getName() + " was cancelled!");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(player.getName() + " already has game mode " + mode.getValue());
|
||||
}
|
||||
|
@ -301,6 +301,13 @@ public abstract class Event implements Serializable {
|
||||
*/
|
||||
PLAYER_FISH(Category.PLAYER),
|
||||
|
||||
/**
|
||||
* Called when the game mode of a player is changed
|
||||
*
|
||||
* @see org.bukkit.event.player.PlayerGameModeChangeEvent
|
||||
*/
|
||||
PLAYER_GAME_MODE_CHANGE(Category.PLAYER),
|
||||
|
||||
/**
|
||||
* BLOCK EVENTS
|
||||
*/
|
||||
|
@ -0,0 +1,28 @@
|
||||
package org.bukkit.event.player;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
public class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private boolean cancelled;
|
||||
private GameMode newGameMode;
|
||||
|
||||
public PlayerGameModeChangeEvent(Player player, GameMode newGameMode) {
|
||||
super(Type.PLAYER_GAME_MODE_CHANGE, player);
|
||||
this.newGameMode = newGameMode;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
public GameMode getNewGameMode() {
|
||||
return newGameMode;
|
||||
}
|
||||
}
|
@ -191,4 +191,11 @@ public class PlayerListener implements Listener {
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
public void onPlayerFish(PlayerFishEvent event) {}
|
||||
|
||||
/**
|
||||
* Called when a player's game mode is changed
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {}
|
||||
}
|
||||
|
@ -419,6 +419,13 @@ public class JavaPluginLoader implements PluginLoader {
|
||||
((PlayerListener) listener).onPlayerFish((PlayerFishEvent) event);
|
||||
}
|
||||
};
|
||||
|
||||
case PLAYER_GAME_MODE_CHANGE:
|
||||
return new EventExecutor() {
|
||||
public void execute(Listener listener, Event event) {
|
||||
((PlayerListener) listener).onPlayerGameModeChange((PlayerGameModeChangeEvent) event);
|
||||
}
|
||||
};
|
||||
|
||||
// Block Events
|
||||
case BLOCK_PHYSICS:
|
||||
|
Loading…
Reference in New Issue
Block a user