geforkt von Mirrors/Paper
addition of PlayerGameModeChangeEvent
By: sunkid <sunkid@iminurnetz.com>
Dieser Commit ist enthalten in:
Ursprung
6d19165044
Commit
a7f6bb5cd4
@ -39,6 +39,10 @@ public class GameModeCommand extends VanillaCommand {
|
|||||||
Command.broadcastCommandMessage(sender, "Setting " + player.getName() + " to game mode " + mode.getValue());
|
Command.broadcastCommandMessage(sender, "Setting " + player.getName() + " to game mode " + mode.getValue());
|
||||||
|
|
||||||
player.setGameMode(mode);
|
player.setGameMode(mode);
|
||||||
|
|
||||||
|
if (mode != player.getGameMode()) {
|
||||||
|
Command.broadcastCommandMessage(sender, "The game mode change for " + player.getName() + " was cancelled!");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(player.getName() + " already has game mode " + mode.getValue());
|
sender.sendMessage(player.getName() + " already has game mode " + mode.getValue());
|
||||||
}
|
}
|
||||||
|
@ -301,6 +301,13 @@ public abstract class Event implements Serializable {
|
|||||||
*/
|
*/
|
||||||
PLAYER_FISH(Category.PLAYER),
|
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
|
* 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
|
* @param event Relevant event details
|
||||||
*/
|
*/
|
||||||
public void onPlayerFish(PlayerFishEvent event) {}
|
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);
|
((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
|
// Block Events
|
||||||
case BLOCK_PHYSICS:
|
case BLOCK_PHYSICS:
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren