mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-01-03 22:47:40 +01:00
*CLEANUP* - Swords.java
This commit is contained in:
parent
dc6a2b654e
commit
5a54d6e0c5
@ -1,13 +1,16 @@
|
|||||||
package com.gmail.nossr50.skills;
|
package com.gmail.nossr50.skills;
|
||||||
|
|
||||||
|
import org.bukkit.entity.AnimalTamer;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Wolf;
|
import org.bukkit.entity.Wolf;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
|
||||||
import com.gmail.nossr50.Combat;
|
import com.gmail.nossr50.Combat;
|
||||||
import com.gmail.nossr50.ItemChecks;
|
import com.gmail.nossr50.ItemChecks;
|
||||||
import com.gmail.nossr50.Users;
|
import com.gmail.nossr50.Users;
|
||||||
|
import com.gmail.nossr50.m;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.mcPermissions;
|
import com.gmail.nossr50.mcPermissions;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
@ -15,126 +18,131 @@ import com.gmail.nossr50.datatypes.SkillType;
|
|||||||
import com.gmail.nossr50.locale.mcLocale;
|
import com.gmail.nossr50.locale.mcLocale;
|
||||||
import com.gmail.nossr50.party.Party;
|
import com.gmail.nossr50.party.Party;
|
||||||
|
|
||||||
public class Swords
|
public class Swords {
|
||||||
{
|
|
||||||
public static void bleedCheck(Player attacker, LivingEntity x, mcMMO pluginx)
|
|
||||||
{
|
|
||||||
PlayerProfile PPa = Users.getProfile(attacker);
|
|
||||||
|
|
||||||
if(x instanceof Wolf)
|
|
||||||
{
|
|
||||||
Wolf wolf = (Wolf)x;
|
|
||||||
if(wolf.getOwner() instanceof Player)
|
|
||||||
{
|
|
||||||
Player owner = (Player) wolf.getOwner();
|
|
||||||
if(owner == attacker)
|
|
||||||
return;
|
|
||||||
if(Party.getInstance().inSameParty(attacker, owner))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(mcPermissions.getInstance().swords(attacker) && ItemChecks.isSword(attacker.getItemInHand())){
|
|
||||||
if(PPa.getSkillLevel(SkillType.SWORDS) >= 750)
|
|
||||||
{
|
|
||||||
if(Math.random() * 1000 <= 750)
|
|
||||||
{
|
|
||||||
if(!(x instanceof Player))
|
|
||||||
pluginx.misc.addToBleedQue(x);
|
|
||||||
if(x instanceof Player)
|
|
||||||
{
|
|
||||||
Player target = (Player)x;
|
|
||||||
Users.getProfile(target).addBleedTicks(3);
|
|
||||||
}
|
|
||||||
attacker.sendMessage(mcLocale.getString("Swords.EnemyBleeding"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Math.random() * 1000 <= PPa.getSkillLevel(SkillType.SWORDS))
|
|
||||||
{
|
|
||||||
if(!(x instanceof Player))
|
|
||||||
pluginx.misc.addToBleedQue(x);
|
|
||||||
if(x instanceof Player)
|
|
||||||
{
|
|
||||||
Player target = (Player)x;
|
|
||||||
Users.getProfile(target).addBleedTicks(2);
|
|
||||||
}
|
|
||||||
attacker.sendMessage(mcLocale.getString("Swords.EnemyBleeding"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void counterAttackChecks(EntityDamageByEntityEvent event)
|
|
||||||
{
|
|
||||||
//Don't want to counter attack stuff not alive
|
|
||||||
|
|
||||||
if(!(event.getDamager() instanceof LivingEntity))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(event instanceof EntityDamageByEntityEvent)
|
/**
|
||||||
{
|
* Check for Bleed effect.
|
||||||
Entity f = ((EntityDamageByEntityEvent) event).getDamager();
|
*
|
||||||
if(event.getEntity() instanceof Player)
|
* @param attacker The attacking player
|
||||||
{
|
* @param entity The defending entity
|
||||||
Player defender = (Player)event.getEntity();
|
* @param plugin mcMMO plugin instance
|
||||||
PlayerProfile PPd = Users.getProfile(defender);
|
*/
|
||||||
if(ItemChecks.isSword(defender.getItemInHand()) && mcPermissions.getInstance().swords(defender))
|
public static void bleedCheck(Player attacker, LivingEntity entity, mcMMO plugin) {
|
||||||
{
|
|
||||||
if(PPd.getSkillLevel(SkillType.SWORDS) >= 600)
|
if (entity instanceof Wolf) {
|
||||||
{
|
Wolf wolf = (Wolf) entity;
|
||||||
if(Math.random() * 2000 <= 600)
|
|
||||||
{
|
if (wolf.isTamed()) {
|
||||||
Combat.dealDamage((LivingEntity) f, event.getDamage() / 2);
|
AnimalTamer tamer = wolf.getOwner();
|
||||||
defender.sendMessage(mcLocale.getString("Swords.CounterAttacked"));
|
|
||||||
if(f instanceof Player)
|
if (tamer instanceof Player) {
|
||||||
((Player) f).sendMessage(mcLocale.getString("Swords.HitByCounterAttack"));
|
Player owner = (Player) tamer;
|
||||||
}
|
|
||||||
}
|
if (owner == attacker || Party.getInstance().inSameParty(attacker, owner)) {
|
||||||
else if (Math.random() * 2000 <= PPd.getSkillLevel(SkillType.SWORDS))
|
return;
|
||||||
{
|
}
|
||||||
Combat.dealDamage((LivingEntity) f, event.getDamage() / 2);
|
}
|
||||||
defender.sendMessage(mcLocale.getString("Swords.CounterAttacked"));
|
}
|
||||||
if(f instanceof Player)
|
}
|
||||||
((Player) f).sendMessage(mcLocale.getString("Swords.HitByCounterAttack"));
|
|
||||||
}
|
final int MAX_BONUS_LEVEL = 750;
|
||||||
}
|
|
||||||
}
|
PlayerProfile PPa = Users.getProfile(attacker);
|
||||||
}
|
int skillLevel = PPa.getSkillLevel(SkillType.SWORDS);
|
||||||
|
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||||
|
|
||||||
|
if (Math.random() * 1000 <= skillCheck && !entity.isDead()) {
|
||||||
|
if (entity instanceof Player) {
|
||||||
|
Player target = (Player) entity;
|
||||||
|
int bleedTicks;
|
||||||
|
|
||||||
|
if (skillLevel >= 750) {
|
||||||
|
bleedTicks = 3;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bleedTicks = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
Users.getProfile(target).addBleedTicks(bleedTicks);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
plugin.misc.addToBleedQue(entity);
|
||||||
|
}
|
||||||
|
attacker.sendMessage(mcLocale.getString("Swords.EnemyBleeding"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void bleedSimulate(mcMMO plugin)
|
/**
|
||||||
{
|
* Counter-attack entities.
|
||||||
//Add items from Que list to BleedTrack list
|
*
|
||||||
|
* @param event The event to modify
|
||||||
for(LivingEntity x : plugin.misc.bleedQue)
|
*/
|
||||||
{
|
public static void counterAttackChecks(EntityDamageByEntityEvent event) {
|
||||||
plugin.misc.bleedTracker.add(x);
|
Entity attacker = event.getDamager();
|
||||||
}
|
|
||||||
|
if (!(attacker instanceof LivingEntity)) {
|
||||||
//Clear list
|
return;
|
||||||
plugin.misc.bleedQue = new LivingEntity[plugin.misc.bleedQue.length];
|
}
|
||||||
plugin.misc.bleedQuePos = 0;
|
|
||||||
|
Entity target = event.getEntity();
|
||||||
//Cleanup any dead entities from the list
|
|
||||||
for(LivingEntity x : plugin.misc.bleedRemovalQue)
|
if (target instanceof Player) {
|
||||||
{
|
Player defender = (Player) target;
|
||||||
plugin.misc.bleedTracker.remove(x);
|
PlayerProfile PPd = Users.getProfile(defender);
|
||||||
}
|
|
||||||
|
if (ItemChecks.isSword(defender.getItemInHand()) && mcPermissions.getInstance().swords(defender)) {
|
||||||
//Clear bleed removal list
|
final int MAX_BONUS_LEVEL = 600;
|
||||||
plugin.misc.bleedRemovalQue = new LivingEntity[plugin.misc.bleedRemovalQue.length];
|
final int COUNTER_ATTACK_MODIFIER = 2;
|
||||||
plugin.misc.bleedRemovalQuePos = 0;
|
|
||||||
|
int skillLevel = PPd.getSkillLevel(SkillType.SWORDS);
|
||||||
//Bleed monsters/animals
|
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||||
for(LivingEntity x : plugin.misc.bleedTracker)
|
|
||||||
{
|
if (Math.random() * 2000 <= skillCheck) {
|
||||||
if(x == null || x.isDead())
|
Combat.dealDamage((LivingEntity) attacker, event.getDamage() / COUNTER_ATTACK_MODIFIER);
|
||||||
{
|
defender.sendMessage(mcLocale.getString("Swords.CounterAttacked"));
|
||||||
plugin.misc.addToBleedRemovalQue(x);
|
|
||||||
continue;
|
if (attacker instanceof Player) {
|
||||||
}
|
((Player) attacker).sendMessage(mcLocale.getString("Swords.HitByCounterAttack"));
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
Combat.dealDamage(x, 2);
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simulate a bleed.
|
||||||
|
*
|
||||||
|
* @param plugin mcMMO plugin instance
|
||||||
|
*/
|
||||||
|
public static void bleedSimulate(mcMMO plugin) {
|
||||||
|
|
||||||
|
/* Add items from Que list to BleedTrack list */
|
||||||
|
for (LivingEntity entity : plugin.misc.bleedQue) {
|
||||||
|
plugin.misc.bleedTracker.add(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clear the BleedQue list */
|
||||||
|
plugin.misc.bleedQue = new LivingEntity[plugin.misc.bleedQue.length];
|
||||||
|
plugin.misc.bleedQuePos = 0;
|
||||||
|
|
||||||
|
/* Cleanup any dead entities from the list */
|
||||||
|
for(LivingEntity entity : plugin.misc.bleedRemovalQue) {
|
||||||
|
plugin.misc.bleedTracker.remove(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clear bleed removal list */
|
||||||
|
plugin.misc.bleedRemovalQue = new LivingEntity[plugin.misc.bleedRemovalQue.length];
|
||||||
|
plugin.misc.bleedRemovalQuePos = 0;
|
||||||
|
|
||||||
|
/* Bleed monsters/animals */
|
||||||
|
for (LivingEntity entity : plugin.misc.bleedTracker) {
|
||||||
|
if (entity == null || entity.isDead()) {
|
||||||
|
plugin.misc.addToBleedRemovalQue(entity);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Combat.dealDamage(entity, 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user