Search in sources :

Example 1 with StateChangeMessage

use of net.glowstone.net.message.play.game.StateChangeMessage in project Glowstone by GlowstoneMC.

the class GlowPlayer method setGameMode.

@Override
public void setGameMode(GameMode mode) {
    if (getGameMode() != mode) {
        PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(this, mode);
        if (EventFactory.getInstance().callEvent(event).isCancelled()) {
            return;
        }
        super.setGameMode(mode);
        super.setFallDistance(0);
        updateUserListEntries(UserListItemMessage.gameModeOne(getUniqueId(), mode.getValue()));
        session.send(new StateChangeMessage(Reason.GAMEMODE, mode.getValue()));
    }
    setGameModeDefaults();
}
Also used : StateChangeMessage(net.glowstone.net.message.play.game.StateChangeMessage) PlayerGameModeChangeEvent(org.bukkit.event.player.PlayerGameModeChangeEvent)

Example 2 with StateChangeMessage

use of net.glowstone.net.message.play.game.StateChangeMessage in project Glowstone by GlowstoneMC.

the class GlowPlayer method sendWeather.

/**
 * Sends a {@link StateChangeMessage} with the current weather.
 */
public void sendWeather() {
    boolean stormy = playerWeather == null ? getWorld().hasStorm() : playerWeather == WeatherType.DOWNFALL;
    session.send(new StateChangeMessage(stormy ? Reason.START_RAIN : Reason.STOP_RAIN, 0));
}
Also used : StateChangeMessage(net.glowstone.net.message.play.game.StateChangeMessage)

Aggregations

StateChangeMessage (net.glowstone.net.message.play.game.StateChangeMessage)2 PlayerGameModeChangeEvent (org.bukkit.event.player.PlayerGameModeChangeEvent)1