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. // The hashmap says it is night, but it is day.
times.put(world, true); times.put(world, true);
for (Player player: world.getPlayers()) { 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); 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); player.sendMessage(Methods.getFireColor() + defaultsunrisemessage);
} }
} }
} }
} }
} }
/** // /**
* This code is ran on startup, it adds all loaded worlds to the // * This code is ran on startup, it adds all loaded worlds to the
* hashmap. // * hashmap.
*/ // */
if (dayNight.size() < 1) { // if (dayNight.size() < 1) {
for (World world : plugin.getServer().getWorlds()) { // for (World world : plugin.getServer().getWorlds()) {
if (world.getWorldType() == WorldType.NORMAL) { // if (world.getWorldType() == WorldType.NORMAL) {
String worldName = world.getName(); // String worldName = world.getName();
if (dayNight.containsKey(worldName)) // if (dayNight.containsKey(worldName))
return; // return;
if (Methods.isDay(world)) { // if (Methods.isDay(world)) {
dayNight.put(worldName, Time.DAY); // dayNight.put(worldName, Time.DAY);
} else { // } else {
dayNight.put(worldName, Time.NIGHT); // dayNight.put(worldName, Time.NIGHT);
} // }
} // }
} // }
} // }
// for (World world : Bukkit.getWorlds()) { // for (World world : Bukkit.getWorlds()) {
// final String worldName = world.getName(); // final String worldName = world.getName();

View file

@ -204,6 +204,7 @@ public class ConfigManager {
+ "launch that target off in the direction you're looking. " + "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."); + "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.CanOnlyBeUsedAtNight", false);
config.addDefault("Abilities.Water.Bloodbending.CanBeUsedOnUndeadMobs", true);
config.addDefault("Abilities.Water.Bloodbending.ThrowFactor", 2); config.addDefault("Abilities.Water.Bloodbending.ThrowFactor", 2);
config.addDefault("Abilities.Water.Bloodbending.Range", 10); 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.Location;
import org.bukkit.entity.Creature; import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
@ -25,6 +26,7 @@ public class Bloodbending {
private static final double factor = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.Bloodbending.ThrowFactor"); 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 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 int range = ProjectKorra.plugin.getConfig().getInt("Abilities.Water.Bloodbending.Range");
private Player player; private Player player;
@ -67,6 +69,9 @@ public class Bloodbending {
|| AvatarState.isAvatarState((Player) target)) || AvatarState.isAvatarState((Player) target))
return; return;
} }
if (!canBeUsedOnUndead && isUndead(target)) {
return;
}
Methods.damageEntity(player, target, 0); Methods.damageEntity(player, target, 0);
targetentities.put(target, target.getLocation().clone()); targetentities.put(target, target.getLocation().clone());
} }
@ -102,6 +107,14 @@ public class Bloodbending {
return; return;
} }
if (!canBeUsedOnUndead) {
for (Entity entity: targetentities.keySet()) {
if (isUndead(entity)) {
targetentities.remove(entity);
}
}
}
if (onlyUsableAtNight && !Methods.isNight(player.getWorld())) { if (onlyUsableAtNight && !Methods.isNight(player.getWorld())) {
remove(player); remove(player);
return; return;
@ -215,6 +228,23 @@ public class Bloodbending {
return false; 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) { public static Location getBloodbendingLocation(Entity entity) {
for (Player player : instances.keySet()) { for (Player player : instances.keySet()) {
if (instances.get(player).targetentities.containsKey(entity)) { if (instances.get(player).targetentities.containsKey(entity)) {

View file

@ -152,6 +152,7 @@ Abilities:
Enabled: true 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." 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 CanOnlyBeUsedAtNight: false
CanBeUsedOnUndeadMobs: true
ThrowFactor: 2 ThrowFactor: 2
Range: 10 Range: 10
HealingWaters: HealingWaters: