Add option to disable Bloodbending on undead mobs.

This commit is contained in:
MistPhizzle 2014-08-02 00:11:12 -04:00
parent 657ca39a0d
commit a6f834affd
4 changed files with 58 additions and 26 deletions

View file

@ -236,34 +236,34 @@ public class BendingManager implements Runnable {
// The hashmap says it is night, but it is day.
times.put(world, true);
for (Player player: world.getPlayers()) {
if (Methods.isBender(player.getName(), Element.Water)) {
if (Methods.isBender(player.getName(), Element.Water) && player.hasPermission("bending.message.nightmessage")) {
player.sendMessage(Methods.getWaterColor() + defaultmoonsetmessage);
}
if (Methods.isBender(player.getName(), Element.Fire)) {
if (Methods.isBender(player.getName(), Element.Fire) && player.hasPermission("bending.message.daymessage")) {
player.sendMessage(Methods.getFireColor() + defaultsunrisemessage);
}
}
}
}
}
/**
* This code is ran on startup, it adds all loaded worlds to the
* hashmap.
*/
if (dayNight.size() < 1) {
for (World world : plugin.getServer().getWorlds()) {
if (world.getWorldType() == WorldType.NORMAL) {
String worldName = world.getName();
if (dayNight.containsKey(worldName))
return;
if (Methods.isDay(world)) {
dayNight.put(worldName, Time.DAY);
} else {
dayNight.put(worldName, Time.NIGHT);
}
}
}
}
// /**
// * This code is ran on startup, it adds all loaded worlds to the
// * hashmap.
// */
// if (dayNight.size() < 1) {
// for (World world : plugin.getServer().getWorlds()) {
// if (world.getWorldType() == WorldType.NORMAL) {
// String worldName = world.getName();
// if (dayNight.containsKey(worldName))
// return;
// if (Methods.isDay(world)) {
// dayNight.put(worldName, Time.DAY);
// } else {
// dayNight.put(worldName, Time.NIGHT);
// }
// }
// }
// }
// for (World world : Bukkit.getWorlds()) {
// final String worldName = world.getName();

View file

@ -204,6 +204,7 @@ public class ConfigManager {
+ "launch that target off in the direction you're looking. "
+ "People who are capable of bloodbending are immune to your technique, and you are immune to theirs.");
config.addDefault("Abilities.Water.Bloodbending.CanOnlyBeUsedAtNight", false);
config.addDefault("Abilities.Water.Bloodbending.CanBeUsedOnUndeadMobs", true);
config.addDefault("Abilities.Water.Bloodbending.ThrowFactor", 2);
config.addDefault("Abilities.Water.Bloodbending.Range", 10);

View file

@ -6,6 +6,7 @@ import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Location;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
@ -25,8 +26,9 @@ public class Bloodbending {
private static final double factor = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.Bloodbending.ThrowFactor");
private static final boolean onlyUsableAtNight = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Water.Bloodbending.CanOnlyBeUsedAtNight");
private static boolean canBeUsedOnUndead = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Water.Bloodbending.CanBeUsedOnUndeadMobs");
private int range = ProjectKorra.plugin.getConfig().getInt("Abilities.Water.Bloodbending.Range");
private Player player;
public Bloodbending(Player player) {
@ -38,7 +40,7 @@ public class Bloodbending {
remove(player);
return;
}
range = (int) Methods.waterbendingNightAugment(range, player.getWorld());
if (AvatarState.isAvatarState(player)) {
range = AvatarState.getValue(range);
@ -47,8 +49,8 @@ public class Bloodbending {
if (entity instanceof Player) {
if (Methods.isRegionProtectedFromBuild(player, "Bloodbending", entity.getLocation())
|| (AvatarState.isAvatarState((Player) entity)
|| entity.getEntityId() == player.getEntityId()
|| Methods.canBend(((Player) entity).getName(), "Bloodbending")))
|| entity.getEntityId() == player.getEntityId()
|| Methods.canBend(((Player) entity).getName(), "Bloodbending")))
continue;
}
Methods.damageEntity(player, entity, 0);
@ -67,6 +69,9 @@ public class Bloodbending {
|| AvatarState.isAvatarState((Player) target))
return;
}
if (!canBeUsedOnUndead && isUndead(target)) {
return;
}
Methods.damageEntity(player, target, 0);
targetentities.put(target, target.getLocation().clone());
}
@ -101,12 +106,20 @@ public class Bloodbending {
remove(player);
return;
}
if (!canBeUsedOnUndead) {
for (Entity entity: targetentities.keySet()) {
if (isUndead(entity)) {
targetentities.remove(entity);
}
}
}
if (onlyUsableAtNight && !Methods.isNight(player.getWorld())) {
remove(player);
return;
}
if (!Methods.canBend(player.getName(), "Bloodbending")) {
remove(player);
return;
@ -215,6 +228,23 @@ public class Bloodbending {
return false;
}
public static boolean isUndead(Entity entity) {
if (entity == null) return false;
if (entity.getType() == EntityType.ZOMBIE
|| entity.getType() == EntityType.BLAZE
|| entity.getType() == EntityType.GIANT
|| entity.getType() == EntityType.IRON_GOLEM
|| entity.getType() == EntityType.MAGMA_CUBE
|| entity.getType() == EntityType.PIG_ZOMBIE
|| entity.getType() == EntityType.SKELETON
|| entity.getType() == EntityType.SLIME
|| entity.getType() == EntityType.SNOWMAN
|| entity.getType() == EntityType.ZOMBIE) {
return true;
}
return false;
}
public static Location getBloodbendingLocation(Entity entity) {
for (Player player : instances.keySet()) {
if (instances.get(player).targetentities.containsKey(entity)) {

View file

@ -152,6 +152,7 @@ Abilities:
Enabled: true
Description: "This ability was made illegal for a reason. With this ability selected, sneak while targeting something and you will bloodbend that target. Bloodbent targets cannot move, bend, or attack. You are free to control their actions by looking elsewhere - they will be forced to move in that direction. Additionally, clicking while bloodbending will launch that target off in the direction you're looking. People who are capable of bloodbending are immune to technique, and you are immune to theirs."
CanOnlyBeUsedAtNight: false
CanBeUsedOnUndeadMobs: true
ThrowFactor: 2
Range: 10
HealingWaters: