mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Capped bleeding ticks for monsters, moved players bleeding to BleedTimer
This commit is contained in:
parent
b46997bc1a
commit
9e98351923
@ -19,8 +19,6 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
|
|
||||||
public class PlayerProfile {
|
public class PlayerProfile {
|
||||||
|
|
||||||
final static int MAX_BLEED_TICKS = 10;
|
|
||||||
|
|
||||||
/* HUD */
|
/* HUD */
|
||||||
private HUDType hud;
|
private HUDType hud;
|
||||||
private int xpbarinc = 0;
|
private int xpbarinc = 0;
|
||||||
@ -52,7 +50,6 @@ public class PlayerProfile {
|
|||||||
/* mySQL STUFF */
|
/* mySQL STUFF */
|
||||||
private int lastlogin = 0;
|
private int lastlogin = 0;
|
||||||
private int userid = 0;
|
private int userid = 0;
|
||||||
private int bleedticks = 0;
|
|
||||||
|
|
||||||
HashMap<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); //Skills and Levels
|
HashMap<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); //Skills and Levels
|
||||||
HashMap<SkillType, Integer> skillsXp = new HashMap<SkillType, Integer>(); //Skills and XP
|
HashMap<SkillType, Integer> skillsXp = new HashMap<SkillType, Integer>(); //Skills and XP
|
||||||
@ -608,30 +605,6 @@ public class PlayerProfile {
|
|||||||
partyChatMode = !partyChatMode;
|
partyChatMode = !partyChatMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Bleed Stuff
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void decreaseBleedTicks() {
|
|
||||||
bleedticks--;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBleedTicks() {
|
|
||||||
return bleedticks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetBleedTicks() {
|
|
||||||
bleedticks = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addBleedTicks(int newvalue){
|
|
||||||
bleedticks += newvalue;
|
|
||||||
|
|
||||||
if (bleedticks > MAX_BLEED_TICKS) {
|
|
||||||
bleedticks = MAX_BLEED_TICKS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Exploit Prevention
|
* Exploit Prevention
|
||||||
*/
|
*/
|
||||||
|
@ -143,17 +143,13 @@ public class EntityListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler (priority = EventPriority.MONITOR)
|
@EventHandler (priority = EventPriority.MONITOR)
|
||||||
public void onEntityDeath(EntityDeathEvent event) {
|
public void onEntityDeath(EntityDeathEvent event) {
|
||||||
LivingEntity x = event.getEntity();
|
LivingEntity entity = event.getEntity();
|
||||||
x.setFireTicks(0);
|
entity.setFireTicks(0);
|
||||||
|
|
||||||
/* Remove bleed track */
|
/* Remove bleed track */
|
||||||
BleedTimer.remove(x);
|
BleedTimer.remove(entity);
|
||||||
|
|
||||||
Archery.arrowRetrievalCheck(x, plugin);
|
Archery.arrowRetrievalCheck(entity, plugin);
|
||||||
|
|
||||||
if (x instanceof Player) {
|
|
||||||
Users.getProfile((Player)x).resetBleedTicks();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,6 +27,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.commands.general.XprateCommand;
|
import com.gmail.nossr50.commands.general.XprateCommand;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.runnables.BleedTimer;
|
||||||
import com.gmail.nossr50.runnables.RemoveProfileFromMemoryTask;
|
import com.gmail.nossr50.runnables.RemoveProfileFromMemoryTask;
|
||||||
import com.gmail.nossr50.spout.SpoutStuff;
|
import com.gmail.nossr50.spout.SpoutStuff;
|
||||||
import com.gmail.nossr50.datatypes.AbilityType;
|
import com.gmail.nossr50.datatypes.AbilityType;
|
||||||
@ -43,7 +44,6 @@ import com.gmail.nossr50.skills.Repair;
|
|||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.Skills;
|
||||||
import com.gmail.nossr50.skills.Taming;
|
import com.gmail.nossr50.skills.Taming;
|
||||||
import com.gmail.nossr50.util.BlockChecks;
|
import com.gmail.nossr50.util.BlockChecks;
|
||||||
import com.gmail.nossr50.util.Combat;
|
|
||||||
import com.gmail.nossr50.util.Item;
|
import com.gmail.nossr50.util.Item;
|
||||||
import com.gmail.nossr50.util.ItemChecks;
|
import com.gmail.nossr50.util.ItemChecks;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@ -140,7 +140,6 @@ public class PlayerListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
PlayerProfile PP = Users.getProfile(player);
|
|
||||||
|
|
||||||
/* GARBAGE COLLECTION */
|
/* GARBAGE COLLECTION */
|
||||||
|
|
||||||
@ -150,9 +149,7 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Bleed it out
|
//Bleed it out
|
||||||
if(PP.getBleedTicks() > 0) {
|
BleedTimer.bleedOut(player);
|
||||||
Combat.dealDamage(player, PP.getBleedTicks() * 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Schedule PlayerProfile removal 2 minutes after quitting
|
//Schedule PlayerProfile removal 2 minutes after quitting
|
||||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RemoveProfileFromMemoryTask(player.getName()), 2400);
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RemoveProfileFromMemoryTask(player.getName()), 2400);
|
||||||
|
@ -114,7 +114,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
//Regen & Cooldown timer (Runs every second)
|
//Regen & Cooldown timer (Runs every second)
|
||||||
scheduler.scheduleSyncRepeatingTask(this, new SkillMonitor(this), 0, 20);
|
scheduler.scheduleSyncRepeatingTask(this, new SkillMonitor(this), 0, 20);
|
||||||
//Bleed timer (Runs every two seconds)
|
//Bleed timer (Runs every two seconds)
|
||||||
scheduler.scheduleSyncRepeatingTask(this, new BleedTimer(this), 0, 40);
|
scheduler.scheduleSyncRepeatingTask(this, new BleedTimer(), 0, 40);
|
||||||
|
|
||||||
registerCommands();
|
registerCommands();
|
||||||
|
|
||||||
|
@ -1,45 +1,51 @@
|
|||||||
package com.gmail.nossr50.runnables;
|
package com.gmail.nossr50.runnables;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Combat;
|
import com.gmail.nossr50.util.Combat;
|
||||||
import com.gmail.nossr50.util.Users;
|
|
||||||
|
|
||||||
public class BleedTimer implements Runnable {
|
public class BleedTimer implements Runnable {
|
||||||
private final mcMMO plugin;
|
private final static int MAX_BLEED_TICKS = 10;
|
||||||
|
|
||||||
private static HashSet<LivingEntity> bleedList = new HashSet<LivingEntity>();
|
private static Map<LivingEntity, Integer> bleedList = new HashMap<LivingEntity, Integer>();
|
||||||
private static HashSet<LivingEntity> bleedAddList = new HashSet<LivingEntity>();
|
private static Map<LivingEntity, Integer> bleedAddList = new HashMap<LivingEntity, Integer>();
|
||||||
private static HashSet<LivingEntity> bleedRemoveList = new HashSet<LivingEntity>();
|
private static List<LivingEntity> bleedRemoveList = new ArrayList<LivingEntity>();
|
||||||
|
|
||||||
private static boolean lock = false;
|
private static boolean lock = false;
|
||||||
|
|
||||||
public BleedTimer(final mcMMO plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
updateBleedList();
|
updateBleedList();
|
||||||
|
bleedSimulate();
|
||||||
|
}
|
||||||
|
|
||||||
// Player bleed simulation
|
private void bleedSimulate() {
|
||||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
lock = true;
|
||||||
if (player == null) {
|
|
||||||
continue;
|
for (Entry<LivingEntity, Integer> entry : bleedList.entrySet()) {
|
||||||
|
LivingEntity entity = entry.getKey();
|
||||||
|
|
||||||
|
if (entry.getValue() <= 0 || entity.isDead() || entity == null) {
|
||||||
|
remove(entity);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerProfile PP = Users.getProfile(player);
|
// Player bleed simulation
|
||||||
if (PP == null) {
|
if (entity instanceof Player) {
|
||||||
continue;
|
Player player = (Player) entity;
|
||||||
}
|
|
||||||
|
|
||||||
if (PP.getBleedTicks() >= 1) {
|
if (!player.isOnline()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//Never kill with Bleeding
|
//Never kill with Bleeding
|
||||||
if (player.getHealth() - 2 < 0) {
|
if (player.getHealth() - 2 < 0) {
|
||||||
@ -51,29 +57,16 @@ public class BleedTimer implements Runnable {
|
|||||||
Combat.dealDamage(player, 2);
|
Combat.dealDamage(player, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
PP.decreaseBleedTicks();
|
entry.setValue(entry.getValue() - 1);
|
||||||
|
|
||||||
if (PP.getBleedTicks() == 0) {
|
if (entry.getValue() <= 0) {
|
||||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Stopped"));
|
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Stopped"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// Bleed monsters/animals
|
||||||
|
|
||||||
// Non-player bleed simulation
|
|
||||||
bleedSimulate();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void bleedSimulate() {
|
|
||||||
lock = true;
|
|
||||||
|
|
||||||
// Bleed monsters/animals
|
|
||||||
for (LivingEntity entity : bleedList) {
|
|
||||||
if ((entity == null || entity.isDead())) {
|
|
||||||
remove(entity);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
Combat.dealDamage(entity, 2);
|
Combat.dealDamage(entity, 2);
|
||||||
|
entry.setValue(entry.getValue() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,17 +76,29 @@ public class BleedTimer implements Runnable {
|
|||||||
|
|
||||||
private void updateBleedList() {
|
private void updateBleedList() {
|
||||||
if (lock) {
|
if (lock) {
|
||||||
plugin.getLogger().warning("mcBleedTimer attempted to update the bleedList but the list was locked!");
|
mcMMO.p.getLogger().warning("mcBleedTimer attempted to update the bleedList but the list was locked!");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bleedList.removeAll(bleedRemoveList);
|
bleedList.keySet().removeAll(bleedRemoveList);
|
||||||
bleedRemoveList.clear();
|
bleedRemoveList.clear();
|
||||||
|
|
||||||
bleedList.addAll(bleedAddList);
|
bleedList.putAll(bleedAddList);
|
||||||
bleedAddList.clear();
|
bleedAddList.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantly Bleed out a LivingEntity
|
||||||
|
*
|
||||||
|
* @param entity LivingEntity to bleed out
|
||||||
|
*/
|
||||||
|
public static void bleedOut(LivingEntity entity) {
|
||||||
|
if (bleedList.containsKey(entity)) {
|
||||||
|
Combat.dealDamage(entity, bleedList.get(entity) * 2);
|
||||||
|
bleedList.remove(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a LivingEntity from the bleedList if it is in it
|
* Remove a LivingEntity from the bleedList if it is in it
|
||||||
*
|
*
|
||||||
@ -106,7 +111,7 @@ public class BleedTimer implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (bleedList.contains(entity)) {
|
if (bleedList.containsKey(entity)) {
|
||||||
bleedList.remove(entity);
|
bleedList.remove(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,15 +122,50 @@ public class BleedTimer implements Runnable {
|
|||||||
*
|
*
|
||||||
* @param entity LivingEntity to add
|
* @param entity LivingEntity to add
|
||||||
*/
|
*/
|
||||||
public static void add(LivingEntity entity) {
|
public static void add(LivingEntity entity, int ticks) {
|
||||||
|
int newTicks = ticks;
|
||||||
|
|
||||||
if (lock) {
|
if (lock) {
|
||||||
if (!bleedAddList.contains(entity)) {
|
if (bleedAddList.containsKey(entity)) {
|
||||||
bleedAddList.add(entity);
|
newTicks += bleedAddList.get(entity);
|
||||||
|
|
||||||
|
if (newTicks > MAX_BLEED_TICKS) {
|
||||||
|
newTicks = MAX_BLEED_TICKS;
|
||||||
|
}
|
||||||
|
|
||||||
|
bleedAddList.put(entity, newTicks);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (newTicks > MAX_BLEED_TICKS) {
|
||||||
|
newTicks = MAX_BLEED_TICKS;
|
||||||
|
}
|
||||||
|
|
||||||
|
bleedAddList.put(entity, newTicks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!bleedList.contains(entity)){
|
if (bleedList.containsKey(entity)) {
|
||||||
bleedList.add(entity);
|
newTicks += bleedList.get(entity);
|
||||||
|
|
||||||
|
if (newTicks > MAX_BLEED_TICKS) {
|
||||||
|
newTicks = MAX_BLEED_TICKS;
|
||||||
|
}
|
||||||
|
|
||||||
|
bleedList.put(entity, newTicks);
|
||||||
|
|
||||||
|
// Need to find a better way to ensure that the entity stays in bleedList
|
||||||
|
// when some ticks are added but already marked for removal.
|
||||||
|
// Suggestion: Why not use Iterator.remove() and drop the lock boolean?
|
||||||
|
if (bleedRemoveList.contains(entity)) {
|
||||||
|
bleedRemoveList.remove(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (newTicks > MAX_BLEED_TICKS) {
|
||||||
|
newTicks = MAX_BLEED_TICKS;
|
||||||
|
}
|
||||||
|
|
||||||
|
bleedList.put(entity, newTicks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,6 +177,6 @@ public class BleedTimer implements Runnable {
|
|||||||
* @return true if in the list, false if not
|
* @return true if in the list, false if not
|
||||||
*/
|
*/
|
||||||
public static boolean contains(LivingEntity entity) {
|
public static boolean contains(LivingEntity entity) {
|
||||||
return (bleedList.contains(entity) || bleedAddList.contains(entity));
|
return (bleedList.containsKey(entity) || bleedAddList.containsKey(entity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,22 +57,16 @@ public class Swords {
|
|||||||
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||||
|
|
||||||
if (random.nextInt(1000) <= skillCheck && !entity.isDead()) {
|
if (random.nextInt(1000) <= skillCheck && !entity.isDead()) {
|
||||||
if (entity instanceof Player) {
|
int bleedTicks = 0;
|
||||||
Player target = (Player) entity;
|
|
||||||
int bleedTicks;
|
|
||||||
|
|
||||||
if (skillLevel >= 750) {
|
if (skillLevel >= 750) {
|
||||||
bleedTicks = 3;
|
bleedTicks = 3;
|
||||||
}
|
|
||||||
else {
|
|
||||||
bleedTicks = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
Users.getProfile(target).addBleedTicks(bleedTicks);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BleedTimer.add(entity);
|
bleedTicks = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BleedTimer.add(entity, bleedTicks);
|
||||||
attacker.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding"));
|
attacker.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,14 +92,10 @@ public class Taming {
|
|||||||
event.setDamage(event.getDamage() * GORE_MULTIPLIER);
|
event.setDamage(event.getDamage() * GORE_MULTIPLIER);
|
||||||
|
|
||||||
if (entity instanceof Player) {
|
if (entity instanceof Player) {
|
||||||
Player target = (Player) entity;
|
((Player) entity).sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
|
||||||
|
}
|
||||||
|
|
||||||
target.sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
|
BleedTimer.add((LivingEntity) entity, 2);
|
||||||
Users.getProfile(target).addBleedTicks(2);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
BleedTimer.add((LivingEntity) entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
master.sendMessage(LocaleLoader.getString("Combat.Gore"));
|
master.sendMessage(LocaleLoader.getString("Combat.Gore"));
|
||||||
}
|
}
|
||||||
|
@ -62,12 +62,13 @@ public class Combat {
|
|||||||
combatAbilityChecks(attacker);
|
combatAbilityChecks(attacker);
|
||||||
|
|
||||||
if (ItemChecks.isSword(itemInHand) && Permissions.getInstance().swords(attacker)) {
|
if (ItemChecks.isSword(itemInHand) && Permissions.getInstance().swords(attacker)) {
|
||||||
if (!BleedTimer.contains(target) && Permissions.getInstance().swordsBleed(attacker)) {
|
if (Permissions.getInstance().swordsBleed(attacker)) {
|
||||||
Swords.bleedCheck(attacker, target, plugin);
|
Swords.bleedCheck(attacker, target, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PPa.getAbilityMode(AbilityType.SERRATED_STRIKES) && Permissions.getInstance().serratedStrikes(attacker)) {
|
if (PPa.getAbilityMode(AbilityType.SERRATED_STRIKES) && Permissions.getInstance().serratedStrikes(attacker)) {
|
||||||
applyAbilityAoE(attacker, target, event.getDamage(), plugin, SkillType.SWORDS);
|
applyAbilityAoE(attacker, target, event.getDamage() / 4, plugin, SkillType.SWORDS);
|
||||||
|
BleedTimer.add(target, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
startGainXp(attacker, PPa, target, SkillType.SWORDS, plugin);
|
startGainXp(attacker, PPa, target, SkillType.SWORDS, plugin);
|
||||||
@ -86,7 +87,7 @@ public class Combat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (PPa.getAbilityMode(AbilityType.SKULL_SPLIITER) && Permissions.getInstance().skullSplitter(attacker)) {
|
if (PPa.getAbilityMode(AbilityType.SKULL_SPLIITER) && Permissions.getInstance().skullSplitter(attacker)) {
|
||||||
applyAbilityAoE(attacker, target, event.getDamage(), plugin, SkillType.AXES);
|
applyAbilityAoE(attacker, target, event.getDamage() / 2, plugin, SkillType.AXES);
|
||||||
}
|
}
|
||||||
|
|
||||||
startGainXp(attacker, PPa, target, SkillType.AXES, plugin);
|
startGainXp(attacker, PPa, target, SkillType.AXES, plugin);
|
||||||
@ -139,9 +140,6 @@ public class Combat {
|
|||||||
case ARROW:
|
case ARROW:
|
||||||
archeryCheck((EntityDamageByEntityEvent) event, plugin);
|
archeryCheck((EntityDamageByEntityEvent) event, plugin);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetType.equals(EntityType.PLAYER)) {
|
if (targetType.equals(EntityType.PLAYER)) {
|
||||||
@ -297,89 +295,76 @@ public class Combat {
|
|||||||
*/
|
*/
|
||||||
private static void applyAbilityAoE(Player attacker, LivingEntity target, int damage, mcMMO plugin, SkillType type) {
|
private static void applyAbilityAoE(Player attacker, LivingEntity target, int damage, mcMMO plugin, SkillType type) {
|
||||||
int numberOfTargets = Misc.getTier(attacker.getItemInHand()); //The higher the weapon tier, the more targets you hit
|
int numberOfTargets = Misc.getTier(attacker.getItemInHand()); //The higher the weapon tier, the more targets you hit
|
||||||
int damageAmount = 0;
|
int damageAmount = damage;
|
||||||
|
|
||||||
if (type.equals(SkillType.AXES)) {
|
|
||||||
damageAmount = damage / 2;
|
|
||||||
}
|
|
||||||
else if (type.equals(SkillType.SWORDS)) {
|
|
||||||
damageAmount = damage / 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (damageAmount < 1) {
|
if (damageAmount < 1) {
|
||||||
damageAmount = 1;
|
damageAmount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Entity entity : target.getNearbyEntities(2.5, 2.5, 2.5)) {
|
for (Entity entity : target.getNearbyEntities(2.5, 2.5, 2.5)) {
|
||||||
EntityType entityType = entity.getType();
|
if (!(entity instanceof LivingEntity)) {
|
||||||
|
continue;
|
||||||
if (entityType.equals(EntityType.WOLF)) {
|
}
|
||||||
Wolf wolf = (Wolf) entity;
|
|
||||||
AnimalTamer tamer = wolf.getOwner();
|
if (numberOfTargets <= 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (entity.getType()) {
|
||||||
|
case WOLF:
|
||||||
|
AnimalTamer tamer = ((Wolf) entity).getOwner();
|
||||||
|
|
||||||
if (tamer instanceof Player) {
|
if (tamer instanceof Player) {
|
||||||
Player owner = (Player) tamer;
|
if (tamer.equals(attacker) || Party.getInstance().inSameParty(attacker, (Player) tamer)) {
|
||||||
|
|
||||||
if (owner.equals(attacker) || Party.getInstance().inSameParty(attacker, owner)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case PLAYER:
|
||||||
|
Player defender = (Player) entity;
|
||||||
|
|
||||||
|
if (!target.getWorld().getPVP()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defender.getName().equals(attacker.getName())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Party.getInstance().inSameParty(attacker, defender)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerProfile playerProfile = Users.getProfile((Player) entity);
|
||||||
|
|
||||||
|
if (playerProfile.getGodMode()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity instanceof LivingEntity && numberOfTargets >= 1) {
|
|
||||||
if (entityType.equals(EntityType.PLAYER)) {
|
switch (type) {
|
||||||
Player defender = (Player) entity;
|
case SWORDS:
|
||||||
PlayerProfile PP = Users.getProfile(defender);
|
if (entity instanceof Player) {
|
||||||
|
((Player) entity).sendMessage(LocaleLoader.getString("Swords.Combat.SS.Struck"));
|
||||||
//Reasons why the target shouldn't be hit
|
|
||||||
if (PP.getGodMode()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defender.getName().equals(attacker.getName())) { //Is this even possible?
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Party.getInstance().inSameParty(attacker, defender)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defender.isDead()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Apply effect to players only if PVP is enabled
|
|
||||||
if (target.getWorld().getPVP()) {
|
|
||||||
String message = "";
|
|
||||||
|
|
||||||
if (type.equals(SkillType.AXES)) {
|
|
||||||
message = LocaleLoader.getString("Axes.Combat.Cleave.Struck");
|
|
||||||
}
|
|
||||||
else if (type.equals(SkillType.SWORDS)) {
|
|
||||||
message = LocaleLoader.getString("Swords.Combat.SS.Struck");
|
|
||||||
}
|
|
||||||
|
|
||||||
dealDamage(defender, damageAmount, attacker);
|
|
||||||
defender.sendMessage(message);
|
|
||||||
|
|
||||||
if (type.equals(SkillType.SWORDS)) {
|
|
||||||
PP.addBleedTicks(5);
|
|
||||||
}
|
|
||||||
|
|
||||||
numberOfTargets--;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
LivingEntity livingEntity = (LivingEntity) entity;
|
BleedTimer.add((LivingEntity) entity, 5);
|
||||||
|
|
||||||
if (type.equals(SkillType.SWORDS)) {
|
break;
|
||||||
BleedTimer.add(livingEntity);
|
case AXES:
|
||||||
}
|
if (entity instanceof Player) {
|
||||||
|
((Player) entity).sendMessage(LocaleLoader.getString("Axes.Combat.Cleave.Struck"));
|
||||||
dealDamage(livingEntity, damageAmount, attacker);
|
|
||||||
numberOfTargets--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dealDamage((LivingEntity) entity, damageAmount, attacker);
|
||||||
|
numberOfTargets--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user