mirror of
https://github.com/taoneill/war.git
synced 2024-11-24 03:05:54 +01:00
Finished regain-health-prevention
This commit is contained in:
parent
7cafc2dde5
commit
9e7ec98789
@ -156,6 +156,7 @@ public class War extends JavaPlugin {
|
|||||||
pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.ENTITY_COMBUST, entityListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_COMBUST, entityListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.CREATURE_SPAWN, entityListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.CREATURE_SPAWN, entityListener, Priority.Normal, this);
|
||||||
|
pm.registerEvent(Event.Type.ENTITY_REGAIN_HEALTH, entityListener, Priority.Normal, this);
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Normal, this);
|
||||||
|
@ -208,8 +208,18 @@ public class WarEntityListener extends EntityListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
|
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
|
||||||
if(!war.isLoaded()) return;
|
if(war.isLoaded()) {
|
||||||
if (((org.bukkit.craftbukkit.entity.CraftPlayer) event.getEntity()).getHandle().ticksLived % 20 * 12 == 0)
|
Entity entity = event.getEntity();
|
||||||
event.setCancelled(true);
|
if(entity instanceof Player) {
|
||||||
|
Player player = (Player) entity;
|
||||||
|
Location location = player.getLocation();
|
||||||
|
Warzone zone = war.warzone(location);
|
||||||
|
if(zone != null) {
|
||||||
|
if (((CraftPlayer) player).getHandle().ticksLived % 20 * 12 == 0) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user