mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-23 17:47:35 +01:00
Added the ability to disable fall, water, lava, and fire damage individually.
This commit is contained in:
parent
cf31df35ec
commit
19aa20537d
@ -103,6 +103,9 @@ public void initialize() {
|
|||||||
if (!registerHook("HEALTH_CHANGE", PluginListener.Priority.MEDIUM)) {
|
if (!registerHook("HEALTH_CHANGE", PluginListener.Priority.MEDIUM)) {
|
||||||
missingFeatures.add("god mode");
|
missingFeatures.add("god mode");
|
||||||
}
|
}
|
||||||
|
if (!registerHook("DAMAGE", PluginListener.Priority.MEDIUM)) {
|
||||||
|
missingFeatures.add("disabling fall, water, lava, and fire damage");
|
||||||
|
}
|
||||||
|
|
||||||
if (missingFeatures.size() > 0) {
|
if (missingFeatures.size() > 0) {
|
||||||
logger.log(Level.WARNING, "WorldGuard: Your version of hMod does not support "
|
logger.log(Level.WARNING, "WorldGuard: Your version of hMod does not support "
|
||||||
|
@ -85,6 +85,10 @@ public class WorldGuardListener extends PluginListener {
|
|||||||
private boolean noPhysicsGravel;
|
private boolean noPhysicsGravel;
|
||||||
private boolean noPhysicsSand;
|
private boolean noPhysicsSand;
|
||||||
private boolean allowPortalAnywhere;
|
private boolean allowPortalAnywhere;
|
||||||
|
private boolean disableFallDamage;
|
||||||
|
private boolean disableLavaDamage;
|
||||||
|
private boolean disableFireDamage;
|
||||||
|
private boolean disableWaterDamage;
|
||||||
private int loginProtection;
|
private int loginProtection;
|
||||||
private int spawnProtection;
|
private int spawnProtection;
|
||||||
private boolean kickOnDeath;
|
private boolean kickOnDeath;
|
||||||
@ -160,6 +164,10 @@ public void loadConfiguration() {
|
|||||||
noPhysicsGravel = properties.getBoolean("no-physics-gravel", false);
|
noPhysicsGravel = properties.getBoolean("no-physics-gravel", false);
|
||||||
noPhysicsSand = properties.getBoolean("no-physics-sand", false);
|
noPhysicsSand = properties.getBoolean("no-physics-sand", false);
|
||||||
allowPortalAnywhere = properties.getBoolean("allow-portal-anywhere", false);
|
allowPortalAnywhere = properties.getBoolean("allow-portal-anywhere", false);
|
||||||
|
disableFallDamage = properties.getBoolean("disable-fall-damage", false);
|
||||||
|
disableLavaDamage = properties.getBoolean("disable-lava-damage", false);
|
||||||
|
disableFireDamage = properties.getBoolean("disable-fire-damage", false);
|
||||||
|
disableWaterDamage = properties.getBoolean("disable-water-damage", false);
|
||||||
loginProtection = properties.getInt("login-protection", 3);
|
loginProtection = properties.getInt("login-protection", 3);
|
||||||
spawnProtection = properties.getInt("spawn-protection", 0);
|
spawnProtection = properties.getInt("spawn-protection", 0);
|
||||||
kickOnDeath = properties.getBoolean("kick-on-death", false);
|
kickOnDeath = properties.getBoolean("kick-on-death", false);
|
||||||
@ -922,6 +930,45 @@ public boolean onHealthChange(Player player, int oldValue, int newValue) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a living object is attacked.
|
||||||
|
* tip:
|
||||||
|
* Use isMob() and isPlayer() and getPlayer().
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* type of damage dealt.
|
||||||
|
* @param attacker
|
||||||
|
* object that is attacking.
|
||||||
|
* @param defender
|
||||||
|
* object that is defending.
|
||||||
|
* @param amount
|
||||||
|
* amount of damage dealt.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean onDamage(PluginLoader.DamageType type, BaseEntity attacker,
|
||||||
|
BaseEntity defender, int amount) {
|
||||||
|
|
||||||
|
if (disableFallDamage && type == PluginLoader.DamageType.FALL) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disableLavaDamage && type == PluginLoader.DamageType.LAVA) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disableFireDamage && (type == PluginLoader.DamageType.FIRE
|
||||||
|
|| type == PluginLoader.DamageType.FIRE_TICK)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disableWaterDamage && type == PluginLoader.DamageType.WATER) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called on player disconnect
|
* Called on player disconnect
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user