mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-23 11:06:13 +01:00
Added weather-lock flag.
Valid values are clear or downfall. Unset to restore to normal world weather.
This commit is contained in:
parent
99d042d260
commit
98af7966cd
@ -21,6 +21,7 @@
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.WeatherType;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
/**
|
||||
@ -118,6 +119,7 @@ public final class DefaultFlag {
|
||||
public static final SetFlag<EntityType> DENY_SPAWN = new SetFlag<EntityType>("deny-spawn", new EntityTypeFlag(null));
|
||||
public static final EnumFlag<GameMode> GAME_MODE = new EnumFlag<GameMode>("game-mode", GameMode.class);
|
||||
public static final StringFlag TIME_LOCK = new StringFlag("time-lock");
|
||||
public static final EnumFlag<WeatherType> WEATHER_LOCK = new EnumFlag<WeatherType>("weather-lock", WeatherType.class);
|
||||
public static final IntegerFlag HEAL_DELAY = new IntegerFlag("heal-delay");
|
||||
public static final IntegerFlag HEAL_AMOUNT = new IntegerFlag("heal-amount");
|
||||
public static final DoubleFlag MIN_HEAL = new DoubleFlag("heal-min-health");
|
||||
@ -150,7 +152,7 @@ public final class DefaultFlag {
|
||||
SNOW_FALL, SNOW_MELT, ICE_FORM, ICE_MELT, SOIL_DRY, GAME_MODE,
|
||||
MUSHROOMS, LEAF_DECAY, GRASS_SPREAD, MYCELIUM_SPREAD, VINE_GROWTH,
|
||||
SEND_CHAT, RECEIVE_CHAT, FIRE_SPREAD, LAVA_FIRE, LAVA_FLOW, WATER_FLOW,
|
||||
TELE_LOC, SPAWN_LOC, POTION_SPLASH, TIME_LOCK,
|
||||
TELE_LOC, SPAWN_LOC, POTION_SPLASH, TIME_LOCK, WEATHER_LOCK,
|
||||
BLOCKED_CMDS, ALLOWED_CMDS, PRICE, BUYABLE, ENABLE_SHOP
|
||||
};
|
||||
|
||||
|
@ -148,6 +148,7 @@ private Session createSession(Player player) {
|
||||
session.register(new GameModeFlag(session));
|
||||
session.register(new InvincibilityFlag(session));
|
||||
session.register(new TimeLockFlag(session));
|
||||
session.register(new WeatherLockFlag(session));
|
||||
session.register(new GodMode(session));
|
||||
session.register(new WaterBreathing(session));
|
||||
session.initialize(player);
|
||||
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.session.handler;
|
||||
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.session.MoveType;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.WeatherType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class WeatherLockFlag extends FlagValueChangeHandler<WeatherType> {
|
||||
|
||||
private WeatherType initialWeather;
|
||||
|
||||
public WeatherLockFlag(Session session) {
|
||||
super(session, DefaultFlag.WEATHER_LOCK);
|
||||
}
|
||||
|
||||
private void updatePlayerWeather(Player player, @Nullable WeatherType value) {
|
||||
initialWeather = player.getPlayerWeather();
|
||||
player.setPlayerWeather(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInitialValue(Player player, ApplicableRegionSet set, WeatherType value) {
|
||||
initialWeather = player.getPlayerWeather();
|
||||
updatePlayerWeather(player, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSetValue(Player player, Location from, Location to, ApplicableRegionSet toSet, WeatherType currentValue, WeatherType lastValue, MoveType moveType) {
|
||||
updatePlayerWeather(player, currentValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onAbsentValue(Player player, Location from, Location to, ApplicableRegionSet toSet, WeatherType lastValue, MoveType moveType) {
|
||||
if (initialWeather != null) {
|
||||
player.setPlayerWeather(initialWeather);
|
||||
} else {
|
||||
player.resetPlayerWeather();
|
||||
}
|
||||
initialWeather = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user