->Absorption works once again.
->Add getArtifactAbilityValue() to the API. Returns the raw value of an ability on an artifact item. (Ex. If Strike 5 gives the player 4.2 Damage, then this method returns 4.2.) ->Fixed a bug where Preservation on Artifacts would actually increase the decay rate of Potential loss. ->Fixed a bug where the death messages from players dying would display twice. ->Eruption now releases blocks broken up into the air, making the effect more interesting.
This commit is contained in:
parent
97f91aa688
commit
40f420bf89
Binary file not shown.
@ -1,4 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE xml>
|
||||||
<project name="TwosideKeeper.makejar" default="makejar" basedir=".">
|
<project name="TwosideKeeper.makejar" default="makejar" basedir=".">
|
||||||
<target name ="makejar" description="Create a jar for the TwosideKeeper project">
|
<target name ="makejar" description="Create a jar for the TwosideKeeper project">
|
||||||
<jar jarfile="TwosideKeeper.jar" includes="**/*.class,**/*.yml" basedir="bin"/>
|
<jar jarfile="TwosideKeeper.jar" includes="**/*.class,**/*.yml" basedir="bin"/>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: TwosideKeeper
|
name: TwosideKeeper
|
||||||
main: sig.plugin.TwosideKeeper.TwosideKeeper
|
main: sig.plugin.TwosideKeeper.TwosideKeeper
|
||||||
version: 3.7.0a3
|
version: 3.7.1
|
||||||
commands:
|
commands:
|
||||||
money:
|
money:
|
||||||
description: Tells the player the amount of money they are holding.
|
description: Tells the player the amount of money they are holding.
|
||||||
|
@ -80,7 +80,7 @@ public class AwakenedArtifact {
|
|||||||
item = setEXP(item,totalval%1000);
|
item = setEXP(item,totalval%1000);
|
||||||
item = addAP(item,1);
|
item = addAP(item,1);
|
||||||
double potentialred = 10.0d;
|
double potentialred = 10.0d;
|
||||||
potentialred/=1+(ArtifactAbility.calculateValue(ArtifactAbility.PRESERVATION, artifact.getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.PRESERVATION, artifact))/100d);
|
potentialred/=1+(GenericFunctions.getAbilityValue(ArtifactAbility.PRESERVATION, artifact)/100d);
|
||||||
TwosideKeeper.log("Potential reduction is reduced by "+(10-potentialred), 4);
|
TwosideKeeper.log("Potential reduction is reduced by "+(10-potentialred), 4);
|
||||||
if (ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, item)) {
|
if (ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, item)) {
|
||||||
if (ArtifactAbility.getEnchantmentLevel(ArtifactAbility.GREED, item)>1) {
|
if (ArtifactAbility.getEnchantmentLevel(ArtifactAbility.GREED, item)>1) {
|
||||||
@ -90,7 +90,7 @@ public class AwakenedArtifact {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getPotential(item)>potentialred) {
|
if (getPotential(item)>potentialred) {
|
||||||
item = addPotential(item,(int)(-getPotential(item)/potentialred));
|
item = setPotential(item,(int)(getPotential(item)-potentialred));
|
||||||
if (Math.random() < (potentialred % 1)) {
|
if (Math.random() < (potentialred % 1)) {
|
||||||
item = addPotential(item,1);
|
item = addPotential(item,1);
|
||||||
}
|
}
|
||||||
@ -203,6 +203,21 @@ public class AwakenedArtifact {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static ItemStack setPotential(ItemStack artifact, int amt) {
|
||||||
|
if (GenericFunctions.isArtifactEquip(artifact)) {
|
||||||
|
ItemMeta m = artifact.getItemMeta();
|
||||||
|
List<String> lore = m.getLore();
|
||||||
|
int potential = amt;
|
||||||
|
String potentialline = lore.get(4).split("Potential: ")[0]+"Potential: "+drawPotential(artifact,potential);
|
||||||
|
lore.set(4, potentialline);
|
||||||
|
m.setLore(lore);
|
||||||
|
artifact.setItemMeta(m);
|
||||||
|
return artifact;
|
||||||
|
} else {
|
||||||
|
TwosideKeeper.log("Could not get the Potential value for artifact "+artifact.toString(), 1);
|
||||||
|
return artifact;
|
||||||
|
}
|
||||||
|
}
|
||||||
public static ItemStack addPotential(ItemStack artifact, int amt) {
|
public static ItemStack addPotential(ItemStack artifact, int amt) {
|
||||||
if (GenericFunctions.isArtifactEquip(artifact)) {
|
if (GenericFunctions.isArtifactEquip(artifact)) {
|
||||||
ItemMeta m = artifact.getItemMeta();
|
ItemMeta m = artifact.getItemMeta();
|
||||||
|
@ -2562,7 +2562,7 @@ public class GenericFunctions {
|
|||||||
TwosideKeeper.log(GenericFunctions.GetEntityDisplayName(damager)+"->"+
|
TwosideKeeper.log(GenericFunctions.GetEntityDisplayName(damager)+"->"+
|
||||||
GenericFunctions.GetEntityDisplayName(target)+ChatColor.WHITE+": Damage dealt was "+dmg,2);
|
GenericFunctions.GetEntityDisplayName(target)+ChatColor.WHITE+": Damage dealt was "+dmg,2);
|
||||||
double oldhp=((LivingEntity)target).getHealth();
|
double oldhp=((LivingEntity)target).getHealth();
|
||||||
GenericFunctions.subtractHealth(target, dmg);
|
GenericFunctions.subtractHealth(target, damager, dmg);
|
||||||
TwosideKeeper.log(ChatColor.BLUE+" "+oldhp+"->"+((LivingEntity)target).getHealth()+" HP",3);
|
TwosideKeeper.log(ChatColor.BLUE+" "+oldhp+"->"+((LivingEntity)target).getHealth()+" HP",3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2590,6 +2590,21 @@ public class GenericFunctions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getPotionEffectDuration(PotionEffectType type, LivingEntity ent) {
|
||||||
|
if (ent.hasPotionEffect(type)) {
|
||||||
|
for (int j=0;j<ent.getActivePotionEffects().size();j++) {
|
||||||
|
if (Iterables.get(ent.getActivePotionEffects(), j).getType().equals(type)) {
|
||||||
|
//Get the level.
|
||||||
|
return Iterables.get(ent.getActivePotionEffects(), j).getDuration();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TwosideKeeper.log("Something went wrong while getting potion effect duration of "+type+" for Entity "+ent.getName()+"!", 1);
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void PerformDodge(Player p) {
|
public static void PerformDodge(Player p) {
|
||||||
if (p.isOnGround() && GenericFunctions.isRanger(p) &&
|
if (p.isOnGround() && GenericFunctions.isRanger(p) &&
|
||||||
(GenericFunctions.getBowMode(p.getEquipment().getItemInMainHand())==BowMode.CLOSE)) {
|
(GenericFunctions.getBowMode(p.getEquipment().getItemInMainHand())==BowMode.CLOSE)) {
|
||||||
@ -2657,17 +2672,25 @@ public class GenericFunctions {
|
|||||||
return ArtifactAbility.calculateValue(ab, weapon.getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ab, weapon));
|
return ArtifactAbility.calculateValue(ab, weapon.getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ab, weapon));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void subtractHealth(final LivingEntity entity, double dmg) {
|
public static void subtractHealth(LivingEntity entity, LivingEntity damager, double dmg) {
|
||||||
|
if (damager instanceof Player) {
|
||||||
|
TwosideKeeper.log("Damage goes from "+dmg+"->"+(dmg+TwosideKeeper.CUSTOM_DAMAGE_IDENTIFIER),5);
|
||||||
|
entity.damage(dmg+TwosideKeeper.CUSTOM_DAMAGE_IDENTIFIER,damager);
|
||||||
|
//Bukkit.getPluginManager().callEvent(new EntityDamageByEntityEvent(damager,entity,DamageCause.CUSTOM,dmg+TwosideKeeper.CUSTOM_DAMAGE_IDENTIFIER));
|
||||||
|
} else {
|
||||||
|
//Use old system if we cannot get a valid damager.
|
||||||
if (entity.getHealth()>dmg) {
|
if (entity.getHealth()>dmg) {
|
||||||
entity.setHealth(entity.getHealth()-dmg);
|
entity.setHealth(entity.getHealth()-dmg);
|
||||||
|
aPlugin.API.sendEntityHurtAnimation(entity);
|
||||||
} else {
|
} else {
|
||||||
/*List<ItemStack> drops = new ArrayList<ItemStack>();
|
//List<ItemStack> drops = new ArrayList<ItemStack>();
|
||||||
EntityDeathEvent ev = new EntityDeathEvent(entity,drops);
|
//EntityDeathEvent ev = new EntityDeathEvent(entity,drops);
|
||||||
Bukkit.getPluginManager().callEvent(ev);
|
//Bukkit.getPluginManager().callEvent(ev);
|
||||||
entity.setHealth(0);*/
|
//entity.setHealth(0);
|
||||||
entity.damage(Integer.MAX_VALUE);
|
entity.damage(Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isViewingInventory(Player p) {
|
public static boolean isViewingInventory(Player p) {
|
||||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
||||||
@ -2702,4 +2725,19 @@ public class GenericFunctions {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isSoftBlock(Block b) {
|
||||||
|
if (b.getType()==Material.SAND ||
|
||||||
|
b.getType()==Material.DIRT ||
|
||||||
|
b.getType()==Material.GRASS ||
|
||||||
|
b.getType()==Material.GRAVEL ||
|
||||||
|
b.getType()==Material.CLAY ||
|
||||||
|
b.getType()==Material.SOIL ||
|
||||||
|
b.getType()==Material.SNOW ||
|
||||||
|
b.getType()==Material.SOUL_SAND) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package sig.plugin.TwosideKeeper.HelperStructures.Common;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
public class Habitation {
|
||||||
|
HashMap<String,Integer> locationhashes;
|
||||||
|
HashMap<UUID,Location> startinglocs;
|
||||||
|
|
||||||
|
public Habitation() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,7 @@ import org.bukkit.entity.Arrow;
|
|||||||
import org.bukkit.entity.Creeper;
|
import org.bukkit.entity.Creeper;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.FallingBlock;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.MagmaCube;
|
import org.bukkit.entity.MagmaCube;
|
||||||
import org.bukkit.entity.Monster;
|
import org.bukkit.entity.Monster;
|
||||||
@ -30,8 +31,11 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
|||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
import org.bukkit.metadata.MetadataValue;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
@ -71,6 +75,7 @@ public class NewCombat {
|
|||||||
ev.setDamage(DamageModifier.values()[i],0);
|
ev.setDamage(DamageModifier.values()[i],0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ev.setDamage(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double calculatePlayerDamage(LivingEntity target, Entity damager) {
|
public static double calculatePlayerDamage(LivingEntity target, Entity damager) {
|
||||||
@ -80,7 +85,7 @@ public class NewCombat {
|
|||||||
if (shooter!=null) {
|
if (shooter!=null) {
|
||||||
if (shooter instanceof Player) {
|
if (shooter instanceof Player) {
|
||||||
Player p = (Player)shooter;
|
Player p = (Player)shooter;
|
||||||
playerPerformMiscActions(p);
|
playerPerformMiscActions(p,target);
|
||||||
if (target instanceof Monster) {
|
if (target instanceof Monster) {
|
||||||
Monster m = (Monster)target;
|
Monster m = (Monster)target;
|
||||||
setMonsterTarget(m,p);
|
setMonsterTarget(m,p);
|
||||||
@ -88,6 +93,7 @@ public class NewCombat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
finaldmg += calculateTotalDamage(target, damager);
|
finaldmg += calculateTotalDamage(target, damager);
|
||||||
|
finaldmg = calculateAbsorptionHearts(target, finaldmg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shooter!=null) {
|
if (shooter!=null) {
|
||||||
@ -307,9 +313,9 @@ public class NewCombat {
|
|||||||
return finaldmg;
|
return finaldmg;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void playerPerformMiscActions(Player p) {
|
static void playerPerformMiscActions(Player p, Entity target) {
|
||||||
//GenericFunctions.PerformDodge(p);
|
//GenericFunctions.PerformDodge(p);
|
||||||
castEruption(p);
|
castEruption(p, target);
|
||||||
removePermEnchantments(p);
|
removePermEnchantments(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,36 +325,45 @@ public class NewCombat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void castEruption(Player p) {
|
private static void castEruption(Player p, Entity target) {
|
||||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
||||||
if (GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand()) &&
|
if (GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand()) &&
|
||||||
p.getEquipment().getItemInMainHand().getType().toString().contains("SPADE") && p.isSneaking()) {
|
p.getEquipment().getItemInMainHand().getType().toString().contains("SPADE") && p.isSneaking()) {
|
||||||
if (ArtifactAbility.containsEnchantment(ArtifactAbility.ERUPTION, p.getEquipment().getItemInMainHand()) &&
|
if (ArtifactAbility.containsEnchantment(ArtifactAbility.ERUPTION, p.getEquipment().getItemInMainHand()) &&
|
||||||
pd.last_shovelspell<TwosideKeeper.getServerTickTime()) {
|
pd.last_shovelspell<TwosideKeeper.getServerTickTime()) {
|
||||||
//Attempt to dig out the blocks below.
|
|
||||||
for (int x=-1;x<2;x++) {
|
|
||||||
for (int z=-1;z<2;z++) {
|
|
||||||
Block b = p.getLocation().add(x,-1,z).getBlock();
|
|
||||||
if (aPlugin.API.isDestroyable(b)) {
|
|
||||||
//log(b.getType()+" is destroyable.",2);
|
|
||||||
b.breakNaturally();
|
|
||||||
p.playSound(p.getLocation(), Sound.BLOCK_SAND_BREAK, 1.0f, 1.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Detect all nearby mobs and knock them up. Deal damage to them as well.
|
//Detect all nearby mobs and knock them up. Deal damage to them as well.
|
||||||
List<Entity> nearby = p.getNearbyEntities(2, 2, 2);
|
List<Entity> finallist = new ArrayList<Entity>();
|
||||||
|
List<Entity> nearby = target.getNearbyEntities(2, 2, 2);
|
||||||
for (int i=0;i<nearby.size();i++) {
|
for (int i=0;i<nearby.size();i++) {
|
||||||
if (nearby.get(i) instanceof Monster) {
|
if (nearby.get(i) instanceof Monster) {
|
||||||
Monster mon = (Monster)nearby.get(i);
|
finallist.add(nearby.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finallist.add(target);
|
||||||
|
for (int i=0;i<finallist.size();i++) {
|
||||||
|
Monster mon = (Monster)finallist.get(i);
|
||||||
double finaldmg = CalculateDamageReduction(GenericFunctions.getAbilityValue(ArtifactAbility.ERUPTION, p.getEquipment().getItemInMainHand()),mon,null);
|
double finaldmg = CalculateDamageReduction(GenericFunctions.getAbilityValue(ArtifactAbility.ERUPTION, p.getEquipment().getItemInMainHand()),mon,null);
|
||||||
addToPlayerLogger(p,ChatColor.BLUE+"Eruption",finaldmg);
|
addToPlayerLogger(p,ChatColor.BLUE+"Eruption",finaldmg);
|
||||||
GenericFunctions.DealDamageToMob(finaldmg, mon, p);
|
GenericFunctions.DealDamageToMob(finaldmg, mon, p);
|
||||||
mon.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,20,15));
|
mon.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,20,15));
|
||||||
|
//Attempt to dig out the blocks below.
|
||||||
|
for (int x=-1;x<2;x++) {
|
||||||
|
for (int z=-1;z<2;z++) {
|
||||||
|
Block b = mon.getLocation().add(x,-1,z).getBlock();
|
||||||
|
if (aPlugin.API.isDestroyable(b) && GenericFunctions.isSoftBlock(b)) {
|
||||||
|
//log(b.getType()+" is destroyable.",2);
|
||||||
|
FallingBlock fb = (FallingBlock)b.getLocation().getWorld().spawnFallingBlock(b.getLocation().add(0,0.1,0),b.getType(),(byte)0);
|
||||||
|
fb.setVelocity(new Vector(0,Math.random()*1.35,0));
|
||||||
|
fb.setMetadata("FAKE", new FixedMetadataValue(TwosideKeeper.plugin,true));
|
||||||
|
b.breakNaturally();
|
||||||
|
aPlugin.API.sendSoundlessExplosion(b.getLocation(), 3);
|
||||||
|
p.playSound(mon.getLocation(), Sound.BLOCK_CHORUS_FLOWER_DEATH, 1.0f, 1.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p.playSound(p.getLocation(), Sound.ENTITY_FIREWORK_LARGE_BLAST, 1.0f, 1.0f);
|
p.playSound(p.getLocation(), Sound.ENTITY_FIREWORK_LARGE_BLAST, 1.0f, 1.0f);
|
||||||
p.playEffect(p.getLocation(), Effect.LARGE_SMOKE, 0);
|
|
||||||
aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), 100);
|
aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), 100);
|
||||||
aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), 100);
|
aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), 100);
|
||||||
pd.last_shovelspell=TwosideKeeper.getServerTickTime()+TwosideKeeper.ERUPTION_COOLDOWN;
|
pd.last_shovelspell=TwosideKeeper.getServerTickTime()+TwosideKeeper.ERUPTION_COOLDOWN;
|
||||||
@ -1267,4 +1282,43 @@ public class NewCombat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static double calculateAbsorptionHearts(LivingEntity target, double finaldmg) {
|
||||||
|
if (target.hasPotionEffect(PotionEffectType.ABSORPTION)) {
|
||||||
|
int abslv = GenericFunctions.getPotionEffectLevel(PotionEffectType.ABSORPTION, target)+1;
|
||||||
|
double healthabs = abslv*4; //The amount of health absorbed per level.
|
||||||
|
|
||||||
|
if (DamageIsSmallerThanAbsorptionAmount(finaldmg,healthabs)) {
|
||||||
|
SubtractDamageFromAbsorption(target, finaldmg,healthabs);
|
||||||
|
return 0.0; //Final damage becomes 0.
|
||||||
|
} else {
|
||||||
|
SubtractDamageFromAbsorption(target, finaldmg,healthabs);
|
||||||
|
return finaldmg-healthabs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return finaldmg;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SubtractDamageFromAbsorption(LivingEntity target, double finaldmg, double healthabs) {
|
||||||
|
int lvsToRemove = (int)(finaldmg/4);
|
||||||
|
if (finaldmg % 4 > 0) {
|
||||||
|
lvsToRemove++;
|
||||||
|
}
|
||||||
|
RemoveAbsorptionLevels(target,2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void RemoveAbsorptionLevels(LivingEntity target, int amountOfAbsorptionLevels) {
|
||||||
|
int duration = GenericFunctions.getPotionEffectDuration(PotionEffectType.ABSORPTION, target);
|
||||||
|
int lv = GenericFunctions.getPotionEffectLevel(PotionEffectType.ABSORPTION, target);
|
||||||
|
target.removePotionEffect(PotionEffectType.ABSORPTION);
|
||||||
|
if (amountOfAbsorptionLevels<lv) {
|
||||||
|
target.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION,duration,lv-amountOfAbsorptionLevels));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean DamageIsSmallerThanAbsorptionAmount(double finaldmg, double healthabs) {
|
||||||
|
return finaldmg<=healthabs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ import org.bukkit.entity.EnderDragon;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.ExperienceOrb;
|
import org.bukkit.entity.ExperienceOrb;
|
||||||
|
import org.bukkit.entity.FallingBlock;
|
||||||
import org.bukkit.entity.Guardian;
|
import org.bukkit.entity.Guardian;
|
||||||
import org.bukkit.entity.Horse;
|
import org.bukkit.entity.Horse;
|
||||||
import org.bukkit.entity.Horse.Variant;
|
import org.bukkit.entity.Horse.Variant;
|
||||||
@ -73,6 +74,7 @@ import org.bukkit.event.block.SignChangeEvent;
|
|||||||
import org.bukkit.event.entity.AreaEffectCloudApplyEvent;
|
import org.bukkit.event.entity.AreaEffectCloudApplyEvent;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||||
|
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
import org.bukkit.event.entity.EntityCombustByBlockEvent;
|
import org.bukkit.event.entity.EntityCombustByBlockEvent;
|
||||||
import org.bukkit.event.entity.EntityCombustEvent;
|
import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
@ -200,6 +202,8 @@ import net.minecraft.server.v1_9_R1.MinecraftServer;
|
|||||||
|
|
||||||
public class TwosideKeeper extends JavaPlugin implements Listener {
|
public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
|
public final static int CUSTOM_DAMAGE_IDENTIFIER = 1000000;
|
||||||
|
|
||||||
public static long SERVERTICK=0; //This is the SERVER's TOTAL TICKS when first loaded.
|
public static long SERVERTICK=0; //This is the SERVER's TOTAL TICKS when first loaded.
|
||||||
public static long STARTTIME=0;
|
public static long STARTTIME=0;
|
||||||
public static long LASTSERVERCHECK=0;
|
public static long LASTSERVERCHECK=0;
|
||||||
@ -260,6 +264,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
//Bank timers and users.
|
//Bank timers and users.
|
||||||
public static HashMap banksessions;
|
public static HashMap banksessions;
|
||||||
|
|
||||||
|
public static Plugin plugin;
|
||||||
public int sleepingPlayers=0;
|
public int sleepingPlayers=0;
|
||||||
|
|
||||||
boolean reloadedchunk=false;
|
boolean reloadedchunk=false;
|
||||||
@ -290,6 +296,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
// TODO Insert logic to be performed when the plugin is enabled
|
// TODO Insert logic to be performed when the plugin is enabled
|
||||||
Bukkit.getPluginManager().registerEvents(this, this);
|
Bukkit.getPluginManager().registerEvents(this, this);
|
||||||
|
|
||||||
|
plugin=this;
|
||||||
|
|
||||||
loadConfig();
|
loadConfig();
|
||||||
|
|
||||||
sig.plugin.TwosideKeeper.Recipes.Initialize_ItemCube_Recipes();
|
sig.plugin.TwosideKeeper.Recipes.Initialize_ItemCube_Recipes();
|
||||||
@ -2615,6 +2623,16 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
||||||
|
public void onFallingBlock(EntityChangeBlockEvent ev) {
|
||||||
|
if (ev.getEntity() instanceof FallingBlock) {
|
||||||
|
FallingBlock fb = (FallingBlock)ev.getEntity();
|
||||||
|
if (fb.hasMetadata("FAKE")) {
|
||||||
|
ev.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent ev) {
|
public void onPlayerDropItem(PlayerDropItemEvent ev) {
|
||||||
|
|
||||||
@ -3738,7 +3756,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
if (ev.getCause()==DamageCause.CUSTOM) {
|
if (ev.getCause()==DamageCause.CUSTOM) {
|
||||||
if (ev.getEntity() instanceof LivingEntity) {
|
if (ev.getEntity() instanceof LivingEntity) {
|
||||||
NewCombat.setupTrueDamage(ev);
|
//NewCombat.setupTrueDamage(ev);
|
||||||
log("Dealing "+ev.getFinalDamage()+" damage.",2);
|
log("Dealing "+ev.getFinalDamage()+" damage.",2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3826,6 +3844,20 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
||||||
public void entityHitEvent(EntityDamageByEntityEvent ev) {
|
public void entityHitEvent(EntityDamageByEntityEvent ev) {
|
||||||
|
if (ev.getDamage()>=CUSTOM_DAMAGE_IDENTIFIER) {
|
||||||
|
log("Damage Breakdown:",4);
|
||||||
|
double storeddmg=ev.getDamage(DamageModifier.BASE);
|
||||||
|
for (int i=0;i<DamageModifier.values().length;i++) {
|
||||||
|
if (ev.isApplicable(DamageModifier.values()[i])) {
|
||||||
|
log(" "+DamageModifier.values()[i].name()+": "+ev.getDamage(DamageModifier.values()[i]),4);
|
||||||
|
ev.setDamage(DamageModifier.values()[i],0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log("Stored Damage is "+storeddmg+". CUSTOM_DAMAGE_IDENTIFIER:"+CUSTOM_DAMAGE_IDENTIFIER+"\n...Subtracted damage is "+(storeddmg-CUSTOM_DAMAGE_IDENTIFIER),4);
|
||||||
|
ev.setDamage(DamageModifier.BASE,storeddmg-CUSTOM_DAMAGE_IDENTIFIER);
|
||||||
|
ev.setDamage(storeddmg-CUSTOM_DAMAGE_IDENTIFIER);
|
||||||
|
log("New Damage: "+ev.getFinalDamage(),4);
|
||||||
|
} else {
|
||||||
double dmg = 0.0;
|
double dmg = 0.0;
|
||||||
if (ev.getEntity() instanceof Player) {
|
if (ev.getEntity() instanceof Player) {
|
||||||
Player p = (Player)ev.getEntity();
|
Player p = (Player)ev.getEntity();
|
||||||
@ -3879,15 +3911,23 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
if (dmg>=0) {
|
if (dmg>=0) {
|
||||||
NewCombat.setupTrueDamage(ev); //Apply this as true damage.
|
NewCombat.setupTrueDamage(ev); //Apply this as true damage.
|
||||||
ev.setDamage(0);
|
ev.setDamage(0);
|
||||||
|
//ev.setCancelled(true);
|
||||||
if (ev.getEntity() instanceof LivingEntity) {
|
if (ev.getEntity() instanceof LivingEntity) {
|
||||||
((LivingEntity)ev.getEntity()).setNoDamageTicks(10);
|
((LivingEntity)ev.getEntity()).setNoDamageTicks(10);
|
||||||
double oldhp=((LivingEntity)ev.getEntity()).getHealth();
|
double oldhp=((LivingEntity)ev.getEntity()).getHealth();
|
||||||
GenericFunctions.subtractHealth((LivingEntity)ev.getEntity(),dmg);
|
if (NewCombat.getDamagerEntity(ev.getDamager()) instanceof Player) {
|
||||||
|
GenericFunctions.subtractHealth((LivingEntity)ev.getEntity(), NewCombat.getDamagerEntity(ev.getDamager()), dmg);
|
||||||
|
ev.setCancelled(true);
|
||||||
|
} else {
|
||||||
|
//We will instead apply damage directly.
|
||||||
|
ev.setDamage(dmg);
|
||||||
|
}
|
||||||
log(ChatColor.BLUE+" "+oldhp+"->"+((LivingEntity)ev.getEntity()).getHealth()+" HP",3);
|
log(ChatColor.BLUE+" "+oldhp+"->"+((LivingEntity)ev.getEntity()).getHealth()+" HP",3);
|
||||||
}
|
}
|
||||||
} //Negative damage doesn't make sense. We'd apply it normally.
|
} //Negative damage doesn't make sense. We'd apply it normally.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
||||||
public void onLightningStrike(LightningStrikeEvent ev) {
|
public void onLightningStrike(LightningStrikeEvent ev) {
|
||||||
@ -4215,13 +4255,14 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
affected.get(i).setNoDamageTicks(0);
|
affected.get(i).setNoDamageTicks(0);
|
||||||
if (ev.getEntity().getCustomName().contains("EW ")) {
|
if (ev.getEntity().getCustomName().contains("EW ")) {
|
||||||
double dmgdealt=Double.parseDouble(ev.getEntity().getCustomName().split(" ")[1]);
|
double dmgdealt=Double.parseDouble(ev.getEntity().getCustomName().split(" ")[1]);
|
||||||
|
log("Dealing "+dmgdealt+" damage. Player is "+Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]).getName(),4);
|
||||||
double reduceddmg = CalculateDamageReduction(dmgdealt,affected.get(i),null);
|
double reduceddmg = CalculateDamageReduction(dmgdealt,affected.get(i),null);
|
||||||
DamageLogger.AddNewCalculation(Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]), ChatColor.GREEN+"Earth Wave", dmgdealt, reduceddmg);
|
DamageLogger.AddNewCalculation(Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]), ChatColor.GREEN+"Earth Wave", dmgdealt, reduceddmg);
|
||||||
GenericFunctions.DealDamageToMob(reduceddmg, affected.get(i), Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]));
|
GenericFunctions.DealDamageToMob(reduceddmg, affected.get(i), Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]));
|
||||||
} else
|
} else
|
||||||
if (ev.getEntity().getCustomName().contains("LD ")) {
|
if (ev.getEntity().getCustomName().contains("LD ")) {
|
||||||
double dmgdealt=Double.parseDouble(ev.getEntity().getCustomName().split(" ")[1]);
|
double dmgdealt=Double.parseDouble(ev.getEntity().getCustomName().split(" ")[1]);
|
||||||
log("Dealing "+dmgdealt+" damage",4);
|
log("Dealing "+dmgdealt+" damage. Player is "+Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]).getName(),4);
|
||||||
double reduceddmg = CalculateDamageReduction(dmgdealt,affected.get(i),null);
|
double reduceddmg = CalculateDamageReduction(dmgdealt,affected.get(i),null);
|
||||||
DamageLogger.AddNewCalculation(Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]), ChatColor.GREEN+"Line Drive", dmgdealt, reduceddmg);
|
DamageLogger.AddNewCalculation(Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]), ChatColor.GREEN+"Line Drive", dmgdealt, reduceddmg);
|
||||||
GenericFunctions.DealDamageToMob(reduceddmg, affected.get(i), Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]));
|
GenericFunctions.DealDamageToMob(reduceddmg, affected.get(i), Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]));
|
||||||
|
@ -85,6 +85,9 @@ public final class TwosideKeeperAPI {
|
|||||||
public static int getArtifactAbilityLevel(ArtifactAbility ability, ItemStack item) {
|
public static int getArtifactAbilityLevel(ArtifactAbility ability, ItemStack item) {
|
||||||
return ArtifactAbility.getEnchantmentLevel(ability, item);
|
return ArtifactAbility.getEnchantmentLevel(ability, item);
|
||||||
}
|
}
|
||||||
|
public static double getArtifactAbilityValue(ArtifactAbility ability, ItemStack item) {
|
||||||
|
return GenericFunctions.getAbilityValue(ability, item);
|
||||||
|
}
|
||||||
|
|
||||||
//Time Commands.
|
//Time Commands.
|
||||||
public static long getServerTickTime() {
|
public static long getServerTickTime() {
|
||||||
@ -136,12 +139,15 @@ public final class TwosideKeeperAPI {
|
|||||||
public static double getModifiedDamage(double dmg_amt, LivingEntity p) {
|
public static double getModifiedDamage(double dmg_amt, LivingEntity p) {
|
||||||
return TwosideKeeper.CalculateDamageReduction(dmg_amt, p, p);
|
return TwosideKeeper.CalculateDamageReduction(dmg_amt, p, p);
|
||||||
}
|
}
|
||||||
|
@Deprecated
|
||||||
public static void DealModifiedDamageToEntity(int dmg, LivingEntity damager, LivingEntity target) {
|
public static void DealModifiedDamageToEntity(int dmg, LivingEntity damager, LivingEntity target) {
|
||||||
GenericFunctions.DealDamageToMob(dmg, target, damager, false);
|
GenericFunctions.DealDamageToMob(dmg, target, damager, false);
|
||||||
}
|
}
|
||||||
|
@Deprecated
|
||||||
public static void DealTrueDamageToEntity(int dmg, LivingEntity damager, LivingEntity target) {
|
public static void DealTrueDamageToEntity(int dmg, LivingEntity damager, LivingEntity target) {
|
||||||
GenericFunctions.DealDamageToMob(dmg, target, damager, true);
|
GenericFunctions.DealDamageToMob(dmg, target, damager, true);
|
||||||
}
|
}
|
||||||
|
@Deprecated
|
||||||
public static void DealModifiedDamageToEntity(ItemStack weapon, LivingEntity damager, LivingEntity target) {
|
public static void DealModifiedDamageToEntity(ItemStack weapon, LivingEntity damager, LivingEntity target) {
|
||||||
TwosideKeeper.DealDamageToMob(weapon, damager, target);
|
TwosideKeeper.DealDamageToMob(weapon, damager, target);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user