mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-01-14 12:11:31 +01:00
Convert heal flags datatype from integer to double.
Existing data should be cast with no data loss.
This commit is contained in:
parent
60c3ed4f6b
commit
a57c162cd8
@ -19,18 +19,19 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit;
|
package com.sk89q.worldguard.bukkit;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
|
||||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
|
||||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
|
||||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
|
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||||
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This processes per-player state information and is also meant to be used
|
* This processes per-player state information and is also meant to be used
|
||||||
@ -59,6 +60,7 @@ public FlagStateManager(WorldGuardPlugin plugin) {
|
|||||||
/**
|
/**
|
||||||
* Run the task.
|
* Run the task.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Player[] players = plugin.getServer().getOnlinePlayers();
|
Player[] players = plugin.getServer().getOnlinePlayers();
|
||||||
ConfigurationManager config = plugin.getGlobalStateManager();
|
ConfigurationManager config = plugin.getGlobalStateManager();
|
||||||
@ -112,14 +114,18 @@ private void processHeal(ApplicableRegionSet applicable, Player player,
|
|||||||
|
|
||||||
Integer healAmount = applicable.getFlag(DefaultFlag.HEAL_AMOUNT);
|
Integer healAmount = applicable.getFlag(DefaultFlag.HEAL_AMOUNT);
|
||||||
Integer healDelay = applicable.getFlag(DefaultFlag.HEAL_DELAY);
|
Integer healDelay = applicable.getFlag(DefaultFlag.HEAL_DELAY);
|
||||||
Integer minHealth = applicable.getFlag(DefaultFlag.MIN_HEAL);
|
Double minHealth = applicable.getFlag(DefaultFlag.MIN_HEAL);
|
||||||
Integer maxHealth = applicable.getFlag(DefaultFlag.MAX_HEAL);
|
Double maxHealth = applicable.getFlag(DefaultFlag.MAX_HEAL);
|
||||||
|
|
||||||
if (healAmount == null || healDelay == null || healAmount == 0 || healDelay < 0) {
|
if (healAmount == null || healDelay == null || healAmount == 0 || healDelay < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (minHealth == null) minHealth = 0;
|
if (minHealth == null) {
|
||||||
if (maxHealth == null) maxHealth = player.getMaxHealth();
|
minHealth = 0.0;
|
||||||
|
}
|
||||||
|
if (maxHealth == null) {
|
||||||
|
maxHealth = player.getMaxHealth();
|
||||||
|
}
|
||||||
|
|
||||||
// Apply a cap to prevent possible exceptions
|
// Apply a cap to prevent possible exceptions
|
||||||
minHealth = Math.min(player.getMaxHealth(), minHealth);
|
minHealth = Math.min(player.getMaxHealth(), minHealth);
|
||||||
@ -159,8 +165,12 @@ private void processFeed(ApplicableRegionSet applicable, Player player,
|
|||||||
if (feedAmount == null || feedDelay == null || feedAmount == 0 || feedDelay < 0) {
|
if (feedAmount == null || feedDelay == null || feedAmount == 0 || feedDelay < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (minHunger == null) minHunger = 0;
|
if (minHunger == null) {
|
||||||
if (maxHunger == null) maxHunger = 20;
|
minHunger = 0;
|
||||||
|
}
|
||||||
|
if (maxHunger == null) {
|
||||||
|
maxHunger = 20;
|
||||||
|
}
|
||||||
|
|
||||||
// Apply a cap to prevent possible exceptions
|
// Apply a cap to prevent possible exceptions
|
||||||
minHunger = Math.min(20, minHunger);
|
minHunger = Math.min(20, minHunger);
|
||||||
|
@ -80,8 +80,8 @@ public final class DefaultFlag {
|
|||||||
public static final EnumFlag<GameMode> GAME_MODE = new EnumFlag<GameMode>("game-mode", GameMode.class, RegionGroup.ALL);
|
public static final EnumFlag<GameMode> GAME_MODE = new EnumFlag<GameMode>("game-mode", GameMode.class, RegionGroup.ALL);
|
||||||
public static final IntegerFlag HEAL_DELAY = new IntegerFlag("heal-delay", RegionGroup.ALL);
|
public static final IntegerFlag HEAL_DELAY = new IntegerFlag("heal-delay", RegionGroup.ALL);
|
||||||
public static final IntegerFlag HEAL_AMOUNT = new IntegerFlag("heal-amount", RegionGroup.ALL);
|
public static final IntegerFlag HEAL_AMOUNT = new IntegerFlag("heal-amount", RegionGroup.ALL);
|
||||||
public static final IntegerFlag MIN_HEAL = new IntegerFlag("heal-min-health", RegionGroup.ALL);
|
public static final DoubleFlag MIN_HEAL = new DoubleFlag("heal-min-health", RegionGroup.ALL);
|
||||||
public static final IntegerFlag MAX_HEAL = new IntegerFlag("heal-max-health", RegionGroup.ALL);
|
public static final DoubleFlag MAX_HEAL = new DoubleFlag("heal-max-health", RegionGroup.ALL);
|
||||||
public static final IntegerFlag FEED_DELAY = new IntegerFlag("feed-delay", RegionGroup.ALL);
|
public static final IntegerFlag FEED_DELAY = new IntegerFlag("feed-delay", RegionGroup.ALL);
|
||||||
public static final IntegerFlag FEED_AMOUNT = new IntegerFlag("feed-amount", RegionGroup.ALL);
|
public static final IntegerFlag FEED_AMOUNT = new IntegerFlag("feed-amount", RegionGroup.ALL);
|
||||||
public static final IntegerFlag MIN_FOOD = new IntegerFlag("feed-min-hunger", RegionGroup.ALL);
|
public static final IntegerFlag MIN_FOOD = new IntegerFlag("feed-min-hunger", RegionGroup.ALL);
|
||||||
|
Loading…
Reference in New Issue
Block a user