->Elite monsters have been implemented. They will appear very rarely and

only when certain conditions are met. These are EXTREMELY TOUGH MONSTERS
and it would be in your best interest to be extremely geared before
challenging these bosses.
->Recommended Stats:
---->TANKS: 70+ HP, 98% Damage Reduction
---->Damage Dealers: 100+ Raw DPS, 50+ HP, 85% Damage Reduction
---->Recommended Party Size: 4 Members
---->Do not expect to be able to escape from these fights easily. It's
kill, or be killed. Elites do not despawn.
->You can hunt for an Elite Monster by finding a 'Hunter's Compass'.
These can be found as drops from Zombie Leaders rarely.
->Fixed a bug where Greed would end up having a negative % chance of
breaking.
->Fixed a bug where 'Headshot!' and the "!" pre-emptive strike
indicators were not appearing properly.
->Fix Rabbit's Foot not working for Malleable Bases. If you had a
Malleable Base before this patch, you may type '/fix' while holding the
bad bases to have the timer reset and continue.
->Fixed a bug where Explosions were not properly dealing damage to
players.
->Fixed a bug where Explosions were ignoring Damage Reduction.
->Fixed a bug where monster damage was ignoring Absorption health.
->Name tags now cancel the naming process and are refunded if you try to
name it something that would turn it into a stronger monster. (Example:
Deadly Zombie)
->After death, players respawn with 10 seconds of invulnerability.
->Increased health pool of lower tier Zombie Leaders.
->Death Mark and AoE damage now appears in '/dps'.
->Greed knock off chance reduced dramatically.
->Ranger's Base arrow damage increased from x2 -> x4 again.
->Sniping mode now lowers Dodge Chance by 10% per Slowness stack, but
gives you a Resistance buff equal to your Slowness level, and 10% Crit
Chance per slowness stack.
->Enabling '/dps' now shows more colors when the number appears
on-screen. Yellow = Critical Strike, Blue = Pre-emptive Strike, Red =
Headshot, Aqua = Normal.
->Monsters now take damage from all sources of player damage. This means
multiple players can release their damage onto one monster at once,
enabling parties to damage monsters more effectively.
dev
sigonasr2 9 years ago
parent db04feaa3b
commit fafb4652a4
  1. BIN
      TwosideKeeper.jar
  2. 2
      src/plugin.yml
  3. 426
      src/sig/plugin/TwosideKeeper/EliteMonster.java
  4. 4
      src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java
  5. 250
      src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java
  6. 16
      src/sig/plugin/TwosideKeeper/HelperStructures/Loot.java
  7. 3
      src/sig/plugin/TwosideKeeper/HelperStructures/MalleableBaseQuest.java
  8. 94
      src/sig/plugin/TwosideKeeper/HelperStructures/MonsterDifficulty.java
  9. 83
      src/sig/plugin/TwosideKeeper/MonsterController.java
  10. 44
      src/sig/plugin/TwosideKeeper/NewCombat.java
  11. 3
      src/sig/plugin/TwosideKeeper/PlayerStructure.java
  12. 32
      src/sig/plugin/TwosideKeeper/Recipes.java
  13. 732
      src/sig/plugin/TwosideKeeper/TwosideKeeper.java

Binary file not shown.

@ -1,6 +1,6 @@
name: TwosideKeeper
main: sig.plugin.TwosideKeeper.TwosideKeeper
version: 3.8.0-alpha1
version: 3.8.0
commands:
money:
description: Tells the player the amount of money they are holding.

@ -0,0 +1,426 @@
package sig.plugin.TwosideKeeper;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.attribute.Attribute;
import org.bukkit.block.Block;
import org.bukkit.entity.AreaEffectCloud;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionType;
import org.bukkit.util.Vector;
import org.inventivetalent.glow.GlowAPI;
import sig.plugin.TwosideKeeper.HelperStructures.MonsterDifficulty;
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
public class EliteMonster {
static int REFRESH_BUFFS = 20*30;
static int RESTORE_HEALTH = 20*10;
static float DEFAULT_MOVE_SPD = 0.4f;
static float FAST_MOVE_SPD = 0.65f;
static long BURST_TIME = 20*3;
static float BURST_LIMIT = 10f;
static int WEAKNESS_DURATION = 20*10;
static int POISON_DURATION = 20*10;
static int LEAP_COOLDOWN = 20*40;
static int ENRAGE_COOLDOWN = 20*60;
static int STORINGENERGY_COOLDOWN = 20*50;
static int GLOW_TIME = 20*1;
Monster m;
long last_rebuff_time=0;
long last_regen_time=0;
long last_burstcheck_time=0;
long last_applyglow_time=0;
double hp_before_burstcheck=0;
double last_leap_time=0;
double last_enrage_time=0;
double last_storingenergy_time=0;
double last_storingenergy_health=0;
double storingenergy_hit=0;
boolean leaping=false;
boolean chasing=false;
boolean enraged=false;
boolean storingenergy=false;
Location target_leap_loc = null;
HashMap<Block,Material> storedblocks = new HashMap<Block,Material>();
List<Player> targetlist = new ArrayList<Player>();
//Contains all functionality specific to Elite Monsters.
//These are checked every 5 ticks, so have very high control over the monster itself.
EliteMonster(Monster m) {
this.m=m;
m.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(DEFAULT_MOVE_SPD);
this.hp_before_burstcheck=m.getHealth();
}
public void runTick() {
//This monster constantly gives itself its buffs as it may lose some (Debilitation mode).
dontDrown();
if (m.isValid() && targetlist.size()>0) {
rebuff();
regenerateHealth();
moveFasterToTarget();
weakenTeam();
retargetInAir();
destroyLiquids(2);
reapplyGlow();
}
}
private void dontDrown() {
m.setRemainingAir(m.getMaximumAir());
}
private void reapplyGlow() {
if (last_applyglow_time+GLOW_TIME<=TwosideKeeper.getServerTickTime()) {
GlowAPI.Color col = GlowAPI.Color.DARK_PURPLE;
if (m.hasPotionEffect(PotionEffectType.INCREASE_DAMAGE)) {
col = GlowAPI.Color.YELLOW;
}
if (storingenergy) {
col = GlowAPI.Color.GREEN;
}
GenericFunctions.setGlowing(m, col);
}
}
private void destroyLiquids(int radius) {
for (int x=-radius;x<=radius;x++) {
for (int y=-radius;y<=radius;y++) {
for (int z=-radius;z<=radius;z++) {
Block b = m.getLocation().add(0,-0.9,0).getBlock().getRelative(x,y,z);
if (b.isLiquid()) {
b.setType(Material.AIR);
}
}
}
}
}
private void retargetInAir() {
Player p = ChooseRandomTarget();
if (p!=null) {
if (Math.random()<=0.2 && !p.isOnGround()) {
//p.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,20*5,-31));
p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,20*5,-1));
m.setTarget(p);
p.setFlying(false);
p.setVelocity(new Vector(0,-1,0));
p.removePotionEffect(PotionEffectType.LEVITATION);
p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION,(int)(20*2.25),0));
p.playSound(p.getLocation(), Sound.BLOCK_ANVIL_FALL, 0.4f, 0.8f);
p.playSound(p.getLocation(), Sound.ENTITY_MAGMACUBE_SQUISH, 1.0f, 1.0f);
}
}
}
private void weakenTeam() {
if (last_burstcheck_time+BURST_TIME<=TwosideKeeper.getServerTickTime()) {
if (hp_before_burstcheck-BURST_LIMIT>m.getHealth()) {
//Apply a Weakness debuff aura based on how much stronger the team is.
int weaknesslv = Math.min(8,(int)((hp_before_burstcheck-BURST_LIMIT)/BURST_LIMIT));
createWeaknessCloud(m.getLocation(),weaknesslv);
}
last_burstcheck_time=TwosideKeeper.getServerTickTime();
hp_before_burstcheck=m.getHealth();
}
}
private void createWeaknessCloud(Location loc, int weaknesslv) {
AreaEffectCloud lp = (AreaEffectCloud)loc.getWorld().spawnEntity(loc, EntityType.AREA_EFFECT_CLOUD);
lp.setColor(Color.BLACK);
DecimalFormat df = new DecimalFormat("0.00");
lp.setCustomName("WEAK "+weaknesslv+" "+WEAKNESS_DURATION);
lp.setRadius(2f);
lp.setRadiusPerTick(0.5f/20);
lp.setDuration(20*5);
lp.setReapplicationDelay(5);
lp.setBasePotionData(new PotionData(PotionType.POISON));
lp.setParticle(Particle.SPELL);
loc.getWorld().playSound(loc, Sound.ENTITY_HOSTILE_SPLASH, 1.0f, 1.0f);
}
private void regenerateHealth() {
if (m.getHealth()<m.getMaxHealth() && last_regen_time+RESTORE_HEALTH<=TwosideKeeper.getServerTickTime()) {
m.setHealth(Math.min(m.getHealth()+1,m.getMaxHealth()));
}
}
private void moveFasterToTarget() {
if (m.isInsideVehicle()) {
m.eject();
}
LivingEntity l = m.getTarget();
if (l!=null) {
if (l.isDead()) {
targetlist.remove(l);
if (targetlist.size()>0) {
m.setTarget(ChooseRandomTarget());
} else {
m.setTarget(null);
}
}
if (!storingenergy) {
if (l.getLocation().distanceSquared(m.getLocation())>100 && !leaping) {
l.getWorld().playSound(l.getLocation(), Sound.ENTITY_CAT_HISS, 1.0f, 1.0f);
chasing=true;
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
public void run() {
m.teleport(l.getLocation().add(Math.random(),Math.random(),Math.random()));
l.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,20*5,7));
l.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,20*5,7));
chasing=false;
}
},20*2);
} else if (l.getLocation().distanceSquared(m.getLocation())>4) {
m.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(FAST_MOVE_SPD);
} else {
m.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(DEFAULT_MOVE_SPD);
}
}
if (l.getLocation().getY()>m.getLocation().getY()+1) {
//Jump up to compensate. Move towards the player too.
m.setVelocity((m.getLocation().getDirection()).add(new Vector(0,0.2*(l.getLocation().getY()-m.getLocation().getY()),0)));
}
}
}
private void rebuff() {
if (last_rebuff_time+REFRESH_BUFFS<=TwosideKeeper.getServerTickTime()) {
last_rebuff_time=TwosideKeeper.getServerTickTime();
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8),true);
m.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,Integer.MAX_VALUE,8),true);
//m.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,Integer.MAX_VALUE,2),true);
}
}
//Triggers when this mob is hit.
public void runHitEvent(LivingEntity damager) {
if (!targetlist.contains(damager) && (damager instanceof Player)) {
targetlist.add((Player)damager);
}
last_regen_time=TwosideKeeper.getServerTickTime();
double randomrate = 0d;
if (!chasing && NewCombat.getPercentHealthRemaining(m)<=50) {
if (last_leap_time+LEAP_COOLDOWN<=TwosideKeeper.getServerTickTime()) {
performLeap();
}
}
if (NewCombat.getPercentHealthRemaining(m)<=25) {
if (!leaping && !chasing &&
last_storingenergy_time+STORINGENERGY_COOLDOWN<=TwosideKeeper.getServerTickTime()) {
last_storingenergy_time=TwosideKeeper.getServerTickTime();
storingenergy=true;
for (int i=0;i<targetlist.size();i++) {
targetlist.get(i).sendMessage(ChatColor.GOLD+"The "+m.getCustomName()+ChatColor.GOLD+" is absorbing energy!");
}
m.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0f);
last_storingenergy_health=m.getHealth();
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
public void run() {
Player target = ChooseRandomTarget();
if (target!=null) {
if (last_storingenergy_health-m.getHealth()>0) {
storingenergy_hit=(last_storingenergy_health-m.getHealth())*90d;
for (int i=0;i<targetlist.size();i++) {
targetlist.get(i).sendMessage(ChatColor.GOLD+"The "+m.getCustomName()+ChatColor.GOLD+"'s next hit is stronger!");
targetlist.get(i).sendMessage(ChatColor.DARK_RED+""+ChatColor.ITALIC+" \"DIE "+target.getName()+ChatColor.DARK_RED+"! DIEE!\"");
}
m.setTarget(target);
storingenergy=false;
}
}
}
},5*20);
}
}
if (NewCombat.getPercentHealthRemaining(m)<=10) {
if (last_enrage_time+ENRAGE_COOLDOWN<=TwosideKeeper.getServerTickTime()) {
last_enrage_time=TwosideKeeper.getServerTickTime();
for (int i=0;i<targetlist.size();i++) {
targetlist.get(i).sendMessage(ChatColor.BOLD+""+ChatColor.YELLOW+"WARNING!"+ChatColor.RESET+ChatColor.GREEN+"The "+m.getCustomName()+ChatColor.GREEN+" is going into a tantrum!");
}
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
public void run() {
if (!m.isDead()) {
for (int i=0;i<targetlist.size();i++) {
targetlist.get(i).sendMessage(ChatColor.RED+"The "+m.getCustomName()+ChatColor.RED+" becomes much stronger!");
}
enraged=true;
if (m.hasPotionEffect(PotionEffectType.INCREASE_DAMAGE)) {
m.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,ENRAGE_COOLDOWN*2,GenericFunctions.getPotionEffectLevel(PotionEffectType.INCREASE_DAMAGE, m)+15));
} else {
m.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,ENRAGE_COOLDOWN*2,14));
}
}
}},20*20);
}
}
if (NewCombat.getPercentHealthRemaining(m)<=75 &&
NewCombat.getPercentHealthRemaining(m)>50) {
randomrate = 1/16d;
} else
if (NewCombat.getPercentHealthRemaining(m)<=50 &&
NewCombat.getPercentHealthRemaining(m)>25) {
randomrate = 1/8d;
} else
{
randomrate = 1/4d;
}
if (Math.random()<=randomrate) {
EntityType choice = null;
switch ((int)(Math.random()*4)) {
case 0 :{
choice = EntityType.ZOMBIE;
}break;
case 1 :{
choice = EntityType.SKELETON;
}break;
case 2 :{
choice = EntityType.CREEPER;
}break;
case 3 :{
choice = EntityType.ENDERMAN;
}break;
default:{
choice = EntityType.ZOMBIE;
}
}
Monster nm = (Monster)m.getWorld().spawnEntity(getNearbyFreeLocation(m.getLocation()),choice);
Player target = targetlist.get((int)(Math.random() * targetlist.size()));
nm.setTarget(target);
MonsterController.convertMonster(nm, MonsterDifficulty.HELLFIRE);
}
if (NewCombat.getPercentHealthRemaining(m)<10) {
Player target = targetlist.get((int)(Math.random() * targetlist.size()));
Creeper nm = (Creeper)m.getWorld().spawnEntity(target.getLocation().add(0,30,0),EntityType.CREEPER);
if (Math.random()<=0.5) {
nm.setPowered(true);
}
nm.setTarget(target);
MonsterController.convertMonster(nm, MonsterDifficulty.HELLFIRE);
}
}
private void performLeap() {
last_leap_time = TwosideKeeper.getServerTickTime();
int radius = (int)(6*(NewCombat.getPercentHealthMissing(m)/100d));
//Choose a target randomly.
Player target = ChooseRandomTarget();
m.setTarget(target);
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
public void run() {
m.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,Integer.MAX_VALUE,60));
}
},8);
target_leap_loc = target.getLocation();
m.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,Integer.MAX_VALUE,20));
for (int x=-radius;x<radius+1;x++) {
for (int z=-radius;z<radius+1;z++) {
Block b = target.getLocation().add(x,-0.9,z).getBlock();
if (b.getType()!=Material.AIR && aPlugin.API.isDestroyable(b)) {
storedblocks.put(b, b.getType());
b.setType(Material.STAINED_GLASS);
b.setData((byte)4);
}
}
}
leaping=true;
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
public void run() {
restoreBlocks();
m.teleport(target_leap_loc);
leaping=false;
m.removePotionEffect(PotionEffectType.LEVITATION);
}
private void restoreBlocks() {
for (Block b : storedblocks.keySet()) {
FallingBlock fb = (FallingBlock)b.getLocation().getWorld().spawnFallingBlock(b.getLocation(), storedblocks.get(b), b.getData());
fb.setMetadata("FAKE", new FixedMetadataValue(TwosideKeeper.plugin,true));
fb.setVelocity(new Vector(0,Math.random()*1.7,0));
//b.setType(storedblocks.get(b));
b.setType(Material.AIR);
aPlugin.API.sendSoundlessExplosion(target_leap_loc, 4);
b.getLocation().getWorld().playSound(b.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.7f, 1.2f);
}
storedblocks.clear();
GenericFunctions.DealDamageToNearbyPlayers(target_leap_loc, 160, radius, true, 2);
}
},(int)(((20*4)*(NewCombat.getPercentHealthRemaining(m)/100d))+10));
}
private Player ChooseRandomTarget() {
if (targetlist.size()>0) {
return targetlist.get((int)(Math.random() * targetlist.size()));
} else {
return null;
}
}
private Location getNearbyFreeLocation(Location l) {
int tries = 0;
while (tries<10) {
Location testloc = l.add((Math.random()*3)-(Math.random()*6),Math.random()*5,Math.random()*3-(Math.random()*6));
Block testblock = testloc.getBlock();
if (testblock.getType()==Material.AIR && testblock.getRelative(0, 1, 0).getType()==Material.AIR) {
return testloc;
}
}
return l;
}
//Triggers when this mob hits something.
public void hitEvent(LivingEntity ent) {
if (!targetlist.contains(ent) && (ent instanceof Player)) {
targetlist.add((Player)ent);
}
if (ent.hasPotionEffect(PotionEffectType.POISON)) {
int poisonlv = GenericFunctions.getPotionEffectLevel(PotionEffectType.POISON, ent);
ent.addPotionEffect(new PotionEffect(PotionEffectType.POISON,POISON_DURATION,poisonlv+1),true);
ent.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING,POISON_DURATION,poisonlv+1));
} else {
ent.addPotionEffect(new PotionEffect(PotionEffectType.POISON,POISON_DURATION,0));
ent.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING,POISON_DURATION,0));
}
if (ent instanceof Player) {
Player p = (Player)ent;
if (storingenergy_hit>0) {
p.playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 1.0f, 1.0f);
p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION,20*4,0));
TwosideKeeper.log("Got hit for "+storingenergy_hit+" damage!", 2);
GenericFunctions.DealDamageToMob(NewCombat.CalculateDamageReduction(storingenergy_hit,p,m),p,m);
storingenergy_hit=0;
}
}
}
public Monster getMonster() {
return m;
}
public List<Player> getTargetList() {
return targetlist;
}
}

@ -593,7 +593,7 @@ public enum ArtifactAbility {
msg=msg.replace("[FATALDMG]", ChatColor.BLUE+df.format(120*abilitylv)+ChatColor.RESET);
msg=msg.replace("[REPAIRCHANCE]", ChatColor.BLUE+df.format(tier/3)+ChatColor.RESET);
msg=msg.replace("[DODGEVAL]", ChatColor.BLUE+df.format(tier)+ChatColor.RESET);
msg=msg.replace("[GREEDCHANCE]", ChatColor.BLUE+df.format((11-tier)*5)+ChatColor.RESET);
msg=msg.replace("[GREEDCHANCE]", ChatColor.BLUE+df.format((16-tier)*0.1d)+ChatColor.RESET);
return msg;
}
public static String displayDescriptionUpgrade(ArtifactAbility ability, int tier, int fromlv, int tolv, double playerdmgval) { //Level to display information for.
@ -605,7 +605,7 @@ public enum ArtifactAbility {
msg=msg.replace("[FATALDMG]", DisplayChangedValue(df.format(120-fromlv),df.format(120-tolv)));
msg=msg.replace("[REPAIRCHANCE]", df.format(tier/3));
msg=msg.replace("[DODGEVAL]", df.format(tier));
msg=msg.replace("[GREEDCHANCE]", ChatColor.BLUE+df.format((11-tier)*5)+ChatColor.RESET);
msg=msg.replace("[GREEDCHANCE]", ChatColor.BLUE+df.format((16-tier)*0.1d)+ChatColor.RESET);
return msg;
}

@ -6,6 +6,7 @@ import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -55,6 +56,7 @@ import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import sig.plugin.TwosideKeeper.Artifact;
import sig.plugin.TwosideKeeper.AwakenedArtifact;
import sig.plugin.TwosideKeeper.EliteMonster;
import sig.plugin.TwosideKeeper.MonsterController;
import sig.plugin.TwosideKeeper.MonsterStructure;
import sig.plugin.TwosideKeeper.NewCombat;
@ -63,6 +65,7 @@ import sig.plugin.TwosideKeeper.TwosideKeeper;
import sig.plugin.TwosideKeeper.HelperStructures.ArtifactAbility;
import sig.plugin.TwosideKeeper.HelperStructures.BowMode;
import sig.plugin.TwosideKeeper.HelperStructures.ItemSet;
import sig.plugin.TwosideKeeper.HelperStructures.MonsterDifficulty;
import sig.plugin.TwosideKeeper.HelperStructures.WorldShop;
public class GenericFunctions {
@ -2083,14 +2086,14 @@ public class GenericFunctions {
return ChatColor.DARK_GREEN+""+ChatColor.BOLD+mode+" mode Perks: "+ChatColor.RESET+"\n"
+ ChatColor.WHITE+"->Players are identified as 'Rangers' when they carry a bow in their main hand. Off-hand items are permitted, except for a shield. Can only be wearing leather armor, or no armor.\n"
+ ChatColor.GRAY+"->Left-clicking mobs will cause them to be knocked back extremely far, basically in headshot range, when walls permit.\n"
+ ChatColor.WHITE+"->Base Arrow Damage increases from x1->x2.\n"
+ ChatColor.WHITE+"->Base Arrow Damage increases from x2->x4.\n"
+ ChatColor.GRAY+"->You can dodge 50% of all incoming attacks from any damage sources.\n"
+ ChatColor.WHITE+"You have immunity to all Thorns damage.\n"
+ ChatColor.GRAY+"Shift-Right Click to change Bow Modes.\n"
+ ChatColor.WHITE+"- "+ChatColor.BOLD+"Close Range Mode (Default):"+ChatColor.RESET+ChatColor.WHITE+" \n"
+ ChatColor.GRAY+" You gain the ability to deal headshots from any distance, even directly onto an enemy's face. Each kill made in this mode gives you 100% dodge chance for the next hit taken. You can tumble and gain invulnerability for 1 second by dropping your bow. Sneak while dropping it to tumble backwards.\n"
+ ChatColor.WHITE+"- "+ChatColor.BOLD+"Sniping Mode:"+ChatColor.RESET+ChatColor.WHITE+" \n"
+ ChatColor.GRAY+" Headshot collision area increases by x3. Headshots will deal an extra x0.25 damage for each headshot landed, up to a cap of 8 stacks. Each stack also increases your Slowness level by 1.\n"
+ ChatColor.GRAY+" Headshot collision area increases by x3. Headshots will deal an extra x0.25 damage for each headshot landed, up to a cap of 8 stacks. Each stack also increases your Slowness level by 1. You lose 10% dodge chance per Slowness stack, but gain one Resistance level and 10% critical chance per Slowness stack.\n"
+ ChatColor.WHITE+" Arrows are lightning-fast in Sniping Mode.\n"
+ ChatColor.GRAY+"- "+ChatColor.BOLD+"Debilitation Mode:"+ChatColor.RESET+ChatColor.WHITE+" \n"
+ ChatColor.WHITE+" Adds a stack of Poison when hitting non-poisoned targets (20 second duration). Hitting mobs in this mode refreshes the duration of the poison stacks. Headshots made in this mode will increase the level of Poison on the mob, making the mob more and more vulnerable.\n"
@ -2620,6 +2623,10 @@ public class GenericFunctions {
}
public static void DealDamageToMob(double dmg, LivingEntity target, Entity damager, ItemStack artifact, String reason) {
DealDamageToMob(dmg,target,damager,artifact,reason,null,null);
}
public static void DealDamageToMob(double dmg, LivingEntity target, Entity damager, ItemStack artifact, String reason, String titlemsg, ChatColor color) {
LivingEntity shooter = NewCombat.getDamagerEntity(damager);
if (enoughTicksHavePassed(target,shooter)) {
if (damager!=null && (target instanceof Monster)) {
@ -2631,21 +2638,26 @@ public class GenericFunctions {
}
aPlugin.API.sendEntityHurtAnimation(target);
TwosideKeeper.log("Call event with "+dmg, 5);
if (!reason.equalsIgnoreCase("") && (damager instanceof Player)) {
//Add this to the final total of damage.
NewCombat.addToPlayerLogger(damager,reason,dmg);
NewCombat.addToLoggerTotal(damager, dmg);
}
if (shooter!=null) {
if (!(shooter instanceof Monster) || !(target instanceof Monster)) {
TwosideKeeper.log(GenericFunctions.GetEntityDisplayName(shooter)+"->"+
GenericFunctions.GetEntityDisplayName(target)+ChatColor.WHITE+": Damage dealt was "+dmg,2);
GenericFunctions.GetEntityDisplayName(target)+ChatColor.WHITE+": Damage dealt was "+dmg,4);
}
} else {
if (!(target instanceof Monster)) {
TwosideKeeper.log(reason+"->"+
GenericFunctions.GetEntityDisplayName(target)+ChatColor.WHITE+": Damage dealt was "+dmg,2);
GenericFunctions.GetEntityDisplayName(target)+ChatColor.WHITE+": Damage dealt was "+dmg,4);
}
}
double oldhp=((LivingEntity)target).getHealth();
LivingEntity le = NewCombat.getDamagerEntity(damager);
if (le!=null) {
GenericFunctions.subtractHealth(target, le, dmg, artifact);
GenericFunctions.subtractHealth(target, le, dmg, artifact, titlemsg, color);
if (artifact!=null &&
GenericFunctions.isArtifactEquip(artifact) &&
(le instanceof Player)) {
@ -2676,10 +2688,10 @@ public class GenericFunctions {
ItemStack item = p.getEquipment().getArmorContents()[i];
if (isArtifactEquip(item) &&
ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, item)) {
TwosideKeeper.log("Found one.",2);
TwosideKeeper.log("Found one.",5);
int tier = item.getEnchantmentLevel(Enchantment.LUCK);
item = ArtifactAbility.downgradeEnchantment(p, item, ArtifactAbility.GREED);
if (Math.random()<=((11-tier)*5)/100d) {p.sendMessage(ChatColor.DARK_AQUA+"A level of "+ChatColor.YELLOW+"Greed"+ChatColor.DARK_AQUA+" has been knocked off of your "+((item.hasItemMeta() && item.getItemMeta().hasDisplayName())?item.getItemMeta().getDisplayName():UserFriendlyMaterialName(item)));
if (Math.random()<=((16-tier)*0.1d)/100d) {p.sendMessage(ChatColor.DARK_AQUA+"A level of "+ChatColor.YELLOW+"Greed"+ChatColor.DARK_AQUA+" has been knocked off of your "+((item.hasItemMeta() && item.getItemMeta().hasDisplayName())?item.getItemMeta().getDisplayName():UserFriendlyMaterialName(item)));
brokeone=true;
break;
}
@ -2805,13 +2817,20 @@ public class GenericFunctions {
return ArtifactAbility.calculateValue(ab, weapon.getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ab, weapon));
}
public static void subtractHealth(LivingEntity entity, LivingEntity damager, double dmg) {
subtractHealth(entity,damager,dmg,null);
subtractHealth(entity,damager,dmg,null,null,null);
}
public static void subtractHealth(LivingEntity entity, LivingEntity damager, double dmg, ItemStack artifact) {
entity.setLastDamage(0);
entity.setNoDamageTicks(0);
entity.setMaximumNoDamageTicks(0);
subtractHealth(entity,damager,dmg,artifact,null,null);
}
public static void subtractHealth(LivingEntity entity, LivingEntity damager, double dmg, ItemStack artifact, String message, ChatColor color) {
dmg = NewCombat.calculateAbsorptionHearts(entity, dmg);
if (damager!=null) {
entity.setLastDamage(0);
entity.setNoDamageTicks(0);
entity.setMaximumNoDamageTicks(0);
}
boolean hitallowed=enoughTicksHavePassed(entity,damager);
if (hitallowed) {
updateNoDamageTickMap(entity,damager);
@ -2826,12 +2845,33 @@ public class GenericFunctions {
if (pd.damagelogging) {
pd.target=entity;
DecimalFormat df = new DecimalFormat("0.0");
TwosideKeeper.updateTitle(p,ChatColor.AQUA+df.format(dmg));
TwosideKeeper.log("In here",2);
if (color!=null) {
TwosideKeeper.updateTitle(p,color+df.format(dmg));
} else {
if (pd.crit) {
TwosideKeeper.updateTitle(p,ChatColor.YELLOW+df.format(dmg));
} else
if (pd.preemptive) {
TwosideKeeper.updateTitle(p,ChatColor.BLUE+df.format(dmg));
} else
if (pd.headshot) {
TwosideKeeper.updateTitle(p,ChatColor.DARK_RED+df.format(dmg));
} else {
TwosideKeeper.updateTitle(p,ChatColor.AQUA+df.format(dmg));
}
}
TwosideKeeper.log("In here",5);
} else {
pd.target=entity;
TwosideKeeper.updateTitle(p);
pd.target=entity;
if (message!=null) {
TwosideKeeper.updateTitle(p,message);
} else {
TwosideKeeper.updateTitle(p,pd.headshot,pd.preemptive);
}
}
pd.crit=false;
pd.headshot=false;
pd.preemptive=false;
//Bukkit.getPluginManager().callEvent(new EntityDamageByEntityEvent(damager,entity,DamageCause.CUSTOM,dmg+TwosideKeeper.CUSTOM_DAMAGE_IDENTIFIER));
} else {
if (entity instanceof Player) {
@ -2862,7 +2902,6 @@ public class GenericFunctions {
aPlugin.API.sendEntityHurtAnimation((Player)entity);
}
}
else {
//List<ItemStack> drops = new ArrayList<ItemStack>();
//EntityDeathEvent ev = new EntityDeathEvent(entity,drops);
@ -2900,40 +2939,75 @@ public class GenericFunctions {
if (entity instanceof Player) {
Player p = (Player)entity;
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (pd.hitlist.containsKey(damager.getUniqueId())) {
long time = pd.hitlist.get(damager.getUniqueId());
if (time+10<TwosideKeeper.getServerTickTime()) {
if (damager!=null) {
if (pd.hitlist.containsKey(damager.getUniqueId())) {
long time = pd.hitlist.get(damager.getUniqueId());
if (time+10<TwosideKeeper.getServerTickTime()) {
return true;
}
} else {
return true;
}
} else {
return true;
if (pd.hitlist.containsKey(p.getUniqueId())) {
long time = pd.hitlist.get(p.getUniqueId());
if (time+10<TwosideKeeper.getServerTickTime()) {
return true;
}
} else {
return true;
}
}
}
if (entity instanceof Monster) {
Monster m = (Monster)entity;
MonsterStructure md = MonsterStructure.getMonsterStructure(m);
if (md.hitlist.containsKey(damager.getUniqueId())) {
long time = md.hitlist.get(damager.getUniqueId());
if (time+10<TwosideKeeper.getServerTickTime()) {
if (damager!=null) {
if (md.hitlist.containsKey(damager.getUniqueId())) {
long time = md.hitlist.get(damager.getUniqueId());
if (time+10<TwosideKeeper.getServerTickTime()) {
return true;
}
} else {
return true;
}
} else {
return true;
if (md.hitlist.containsKey(m.getUniqueId())) {
long time = md.hitlist.get(m.getUniqueId());
if (time+10<TwosideKeeper.getServerTickTime()) {
return true;
}
} else {
return true;
}
}
}
if ((entity instanceof LivingEntity) &&
!(entity instanceof Monster) &&
!(entity instanceof Player)) {
return true;
}
return false;
}
private static void updateNoDamageTickMap(LivingEntity entity, LivingEntity damager) {
public static void updateNoDamageTickMap(LivingEntity entity, LivingEntity damager) {
if (entity instanceof Player) {
Player p = (Player)entity;
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
pd.hitlist.put(damager.getUniqueId(), TwosideKeeper.getServerTickTime());
if (damager!=null) {
pd.hitlist.put(damager.getUniqueId(), TwosideKeeper.getServerTickTime());
} else {
pd.hitlist.put(p.getUniqueId(), TwosideKeeper.getServerTickTime());
}
}
if (entity instanceof Monster) {
Monster m = (Monster)entity;
MonsterStructure md = MonsterStructure.getMonsterStructure(m);
md.hitlist.put(damager.getUniqueId(), TwosideKeeper.getServerTickTime());
if (damager!=null) {
md.hitlist.put(damager.getUniqueId(), TwosideKeeper.getServerTickTime());
} else {
md.hitlist.put(m.getUniqueId(), TwosideKeeper.getServerTickTime());
}
}
}
@ -2987,7 +3061,10 @@ public class GenericFunctions {
b.getType()==Material.CLAY ||
b.getType()==Material.SOIL ||
b.getType()==Material.SNOW ||
b.getType()==Material.SOUL_SAND) {
b.getType()==Material.SOUL_SAND ||
b.getType()==Material.STONE ||
b.getType()==Material.COBBLESTONE ||
b.getType()==Material.NETHERRACK) {
return true;
} else {
return false;
@ -3035,7 +3112,7 @@ public class GenericFunctions {
}
public static void updateSetItems(Player player) {
TwosideKeeper.log("Inventory is size "+player.getInventory().getSize(),2);
TwosideKeeper.log("Inventory is size "+player.getInventory().getSize(),5);
for (int i=0;i<player.getInventory().getSize();i++) {
if (ItemSet.isSetItem(player.getInventory().getItem(i))) {
//Update the lore. See if it's hardened. If it is, we will save just that piece.
@ -3056,9 +3133,10 @@ public class GenericFunctions {
}
}
public static void spawnXP(Location location, int expAmount) {
public static ExperienceOrb spawnXP(Location location, int expAmount) {
ExperienceOrb orb = location.getWorld().spawn(location, ExperienceOrb.class);
orb.setExperience(orb.getExperience() + expAmount);
return orb;
}
public static boolean AttemptRevive(Player p, double dmg) {
@ -3108,6 +3186,7 @@ public class GenericFunctions {
i--;
}
}
TwosideKeeper.log("In here", 5);
//We cleared the non-living entities, deal damage to the rest.
for (int i=0;i<nearbyentities.size();i++) {
double damage_mult = 2.0d/(l.distance(nearbyentities.get(i).getLocation())+1.0);
@ -3119,7 +3198,27 @@ public class GenericFunctions {
Player p = (Player)nearbyentities.get(i);
dodgechance = NewCombat.CalculateDodgeChance(p);
}
DealDamageToMob(dmg,(LivingEntity)nearbyentities.get(i),null,null,"Explosion");
if (Math.random()>dodgechance) {
//DealDamageToMob(dmg,(LivingEntity)nearbyentities.get(i),null,null,"Explosion");
TwosideKeeper.log("dmg dealt is supposed to be "+dmg, 5);
subtractHealth((LivingEntity)nearbyentities.get(i),null,NewCombat.CalculateDamageReduction(dmg, (LivingEntity)nearbyentities.get(i), null));
} else {
if (nearbyentities.get(i) instanceof Player) {
Player p = (Player)nearbyentities.get(i);
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_ATTACK_SWEEP, 3.0f, 1.0f);
for (int j=0;j<p.getEquipment().getArmorContents().length;j++) {
ItemStack equip = p.getEquipment().getArmorContents()[j];
if (ArtifactAbility.containsEnchantment(ArtifactAbility.GRACEFULDODGE, equip)) {
p.addPotionEffect(
new PotionEffect(PotionEffectType.GLOWING,
(int)(GenericFunctions.getAbilityValue(ArtifactAbility.GRACEFULDODGE, equip)*20),
0)
);
}
}
p.setNoDamageTicks(10);
}
}
}
}
@ -3195,4 +3294,91 @@ public class GenericFunctions {
}
}
}
public static void DealDamageToNearbyPlayers(Location l, double basedmg, int range) {
DealDamageToNearbyPlayers(l,basedmg,range,false,0);
}
public static void DealDamageToNearbyPlayers(Location l, double basedmg, int range, boolean knockup, double knockupamt) {
List<Entity> nearbyentities = new ArrayList<Entity>();
nearbyentities.addAll(l.getWorld().getNearbyEntities(l, range, range, range));
for (int i=0;i<nearbyentities.size();i++) {
Entity ent = nearbyentities.get(i);
if (!(ent instanceof LivingEntity)) {
nearbyentities.remove(i);
i--;
}
}
//We cleared the non-living entities, deal damage to the rest.
for (int i=0;i<nearbyentities.size();i++) {
double dodgechance = 0.0;
if (nearbyentities.get(i) instanceof Player) {
Player p = (Player)nearbyentities.get(i);
dodgechance = NewCombat.CalculateDodgeChance(p);
if (Math.random()>dodgechance) {
TwosideKeeper.log("Dealt "+basedmg+" raw damage.", 5);
DealDamageToMob(NewCombat.CalculateDamageReduction(basedmg,p,null),(LivingEntity)nearbyentities.get(i),null,null,"Slam");
if (knockup) {
p.setVelocity(new Vector(0,knockupamt,0));
}
} else {
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_ATTACK_SWEEP, 3.0f, 1.0f);
for (int j=0;j<p.getEquipment().getArmorContents().length;j++) {
ItemStack equip = p.getEquipment().getArmorContents()[j];
if (ArtifactAbility.containsEnchantment(ArtifactAbility.GRACEFULDODGE, equip)) {
p.addPotionEffect(
new PotionEffect(PotionEffectType.GLOWING,
(int)(GenericFunctions.getAbilityValue(ArtifactAbility.GRACEFULDODGE, equip)*20),
0)
);
}
}
p.setNoDamageTicks(10);
}
}
}
}
public static boolean isEliteMonster(Monster m) {
MonsterStructure md = MonsterStructure.getMonsterStructure(m);
return md.getElite();
}
public static EliteMonster getEliteMonster(Monster m) {
for (int i=0;i<TwosideKeeper.elitemonsters.size();i++) {
if (TwosideKeeper.elitemonsters.get(i).getMonster().equals(m)) {
return TwosideKeeper.elitemonsters.get(i);
}
}
return null;
}
public static Location defineNewEliteLocation() {
int randomx = (int)((Math.random()*10000) - 5000);
int randomz = (int)((Math.random()*10000) - 5000);
Location testloc = new Location(Bukkit.getWorld("world"),randomx,96,randomz);
do {
randomx = (int)((Math.random()*10000) - 5000);
randomz = (int)((Math.random()*10000) - 5000);
testloc = new Location(Bukkit.getWorld("world"),randomx,96,randomz);
testloc.getChunk().load(); } while
(testloc.getBlock().getType()!=Material.AIR || testloc.getBlock().getRelative(0, 1, 0).getType()!=Material.AIR);
return new Location(Bukkit.getWorld("world"),randomx,testloc.getBlockY(),randomz);
}
public static void generateNewElite() {
TwosideKeeper.ELITE_LOCATION = defineNewEliteLocation();
Monster m = (Monster)TwosideKeeper.ELITE_LOCATION.getWorld().spawnEntity(TwosideKeeper.ELITE_LOCATION, EntityType.ZOMBIE);
MonsterController.convertMonster(m, MonsterDifficulty.ELITE);
}
public static boolean isHunterCompass(ItemStack item) {
if (item!=null &&
item.getType()==Material.COMPASS &&
item.containsEnchantment(Enchantment.LUCK)) {
return true;
} else {
return false;
}
}
}

@ -21,8 +21,12 @@ public class Loot {
public static ItemStack GenerateMegaPiece(Material mat_type, boolean hardened) {
return GenerateMegaPiece(mat_type, hardened, false);
}
public static ItemStack GenerateMegaPiece(Material mat_type, boolean hardened, boolean setitem) {
return GenerateMegaPiece(mat_type,hardened,setitem,0);
}
public static ItemStack GenerateMegaPiece(Material mat_type, boolean hardened, boolean setitem, int settier) {
ItemStack raresword = new ItemStack(mat_type);
ItemMeta sword_meta = raresword.getItemMeta();
sword_meta.setDisplayName(ChatColor.AQUA+""+ChatColor.BOLD+"Mega "+GenericFunctions.UserFriendlyMaterialName(mat_type));
@ -41,7 +45,7 @@ public class Loot {
}
if (setitem && (raresword.getType().toString().contains("SWORD") || GenericFunctions.isArmor(raresword))) {
raresword = GenerateSetPiece(raresword,hardened);
raresword = GenerateSetPiece(raresword,hardened,settier);
}
return raresword;
@ -125,8 +129,12 @@ public class Loot {
raresword = addEnchantments(raresword,false);
return raresword;
}
public static ItemStack GenerateSetPiece(ItemStack item, boolean hardened) {
return GenerateSetPiece(item,hardened,0);
}
static ItemStack GenerateSetPiece(ItemStack item, boolean hardened) {
public static ItemStack GenerateSetPiece(ItemStack item, boolean hardened, int tierbonus) {
List<String> lore = new ArrayList<String>();
int type = (int)(Math.random()*3);
String set_name = "";
@ -163,7 +171,7 @@ public class Loot {
if (item.getItemMeta().hasLore()) {
lore = item.getItemMeta().getLore();
}
int tier = 0;
int tier = tierbonus;
do {tier++;} while(Math.random()<=0.25);
lore.addAll(ItemSet.GenerateLore(set,tier));
ItemMeta m = item.getItemMeta();

@ -115,6 +115,9 @@ public class MalleableBaseQuest {
ItemMeta m = base.getItemMeta();
List<String> lore = m.getLore();
String material_name = lore.get(1).split("'")[1];
if (lore.get(1).contains("Rabbit")) {
return "Rabbit's Foot";
} else
if (lore.get(1).contains("Jack o")) {
return "Jack o'Lantern";
} else {

@ -4,7 +4,12 @@ import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import net.md_5.bungee.api.ChatColor;
import sig.plugin.TwosideKeeper.TwosideKeeper;
@ -211,10 +216,10 @@ public enum MonsterDifficulty {
new LootStructure(Material.GOLD_LEGGINGS, true),
new LootStructure(Material.GOLD_BOOTS, true),
new LootStructure(Material.GOLD_HELMET, true),
new LootStructure(Material.LEATHER_HELMET,3),
new LootStructure(Material.LEATHER_CHESTPLATE,3),
new LootStructure(Material.LEATHER_LEGGINGS,3),
new LootStructure(Material.LEATHER_BOOTS,3),
new LootStructure(Material.LEATHER_HELMET,4),
new LootStructure(Material.LEATHER_CHESTPLATE,4),
new LootStructure(Material.LEATHER_LEGGINGS,4),
new LootStructure(Material.LEATHER_BOOTS,4),
},
new LootStructure[]{ //Legendary Loot
new LootStructure(Material.PRISMARINE_SHARD),
@ -309,7 +314,7 @@ public enum MonsterDifficulty {
}
TwosideKeeper.Loot_Logger.AddRareLoot();
}
//Legendary Loot roll.
//Legendary Loot roll.
if (Math.random()<TwosideKeeper.LEGENDARY_DROP_RATE &&
this.loot_legendary.length>0) {
TwosideKeeper.log(">Attempting Legendary roll.", 3);
@ -318,6 +323,31 @@ public enum MonsterDifficulty {
TwosideKeeper.log("Adding "+gen_loot.toString()+" to loot table.", 4);
droplist.add(gen_loot);
double randomness = Math.random();
if (isBoss) {
if (randomness<=0.2) {
ItemStack hunters_compass = new ItemStack(Material.COMPASS);
hunters_compass.addUnsafeEnchantment(Enchantment.LUCK, 1);
ItemMeta m = hunters_compass.getItemMeta();
m.setDisplayName(ChatColor.RED+"Hunter's Compass");
List<String> lore = new ArrayList<String>();
lore.add("A compass for the true hunter.");
lore.add("Legends tell of hunters that have");
lore.add("come back with great treasures and");
lore.add("much wealth from following the.");
lore.add("directions of the guided arrow.");
lore.add("");
lore.add("You may need to calibrate it by");
lore.add("holding it first.");
lore.add("");
lore.add("The compass appears to be slightly");
lore.add("unstable...");
m.setLore(lore);
hunters_compass.setItemMeta(m);
hunters_compass.addUnsafeEnchantment(Enchantment.LUCK, 1);
droplist.add(hunters_compass);
}
}
randomness = Math.random();
TwosideKeeper.log(ChatColor.DARK_GREEN+" Randomness is "+randomness, 4);
if (randomness<=0.2) {
TwosideKeeper.log(ChatColor.DARK_GREEN+" Spawn a Core!", 4);
@ -381,6 +411,60 @@ public enum MonsterDifficulty {
if (lootlist.length>0) {
//Choose an element.
LootStructure ls = lootlist[(int)((Math.random())*lootlist.length)];
if (ls.GetMaterial()==Material.PRISMARINE_SHARD) {
ItemStack item = new ItemStack(Material.PRISMARINE_SHARD);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.GREEN+"Upgrade Shard");
List<String> lore = new ArrayList<String>();
lore.add("An eerie glow radiates from");
lore.add("this item. It seems to possess");
lore.add("some other-worldly powers.");
meta.setLore(lore);
item.setItemMeta(meta);
item.addUnsafeEnchantment(Enchantment.LUCK, 1);
return item;
}
if (ls.GetMaterial()==Material.POTION) {
//Create a Strengthing Vial.
if (Math.random()<=0.1) {
ItemStack item = new ItemStack(Material.POTION);
PotionMeta pm = (PotionMeta)item.getItemMeta();
pm.addCustomEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,20*60*15,(int)(Math.random()*20+20)), true);
List<String> lore = new ArrayList<String>();
lore.add("A fantastic potion, it comes straight");
lore.add("from the elixir of the gods.");
pm.setLore(lore);
pm.setDisplayName("Strengthing Vial");
item.setItemMeta(pm);
return item;
} else if (Math.random()<=0.85) {
ItemStack item = new ItemStack(Material.POTION);
PotionMeta pm = (PotionMeta)item.getItemMeta();
pm.addCustomEffect(new PotionEffect(PotionEffectType.ABSORPTION,20*60*15,(int)(Math.random()*50+50)), true);
List<String> lore = new ArrayList<String>();
lore.add("A fantastic potion, it comes straight");
lore.add("from the elixir of the gods.");
pm.setLore(lore);
pm.setDisplayName("Life Vial");
item.setItemMeta(pm);
return item;
} else {
ItemStack item = new ItemStack(Material.POTION);
PotionMeta pm = (PotionMeta)item.getItemMeta();
pm.addCustomEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,20*60*15,(int)(Math.random()*3+6)), true);
List<String> lore = new ArrayList<String>();
lore.add("A fantastic potion, it comes straight");
lore.add("from the elixir of the gods.");
pm.setLore(lore);
pm.setDisplayName("Hardening Vial");
item.setItemMeta(pm);
return item;
}
}
if (ls.GetMinSetLevel()>0) {
//Make a set piece.
return Loot.GenerateMegaPiece(ls.GetMaterial(), ls.GetHardened(),true,ls.GetMinSetLevel());
}
if (GenericFunctions.isEquip(new ItemStack(ls.GetMaterial()))) {
//Turn it into a Mega Piece.
if (GenericFunctions.isTool(new ItemStack(ls.GetMaterial()))) {

@ -12,6 +12,7 @@ import org.bukkit.block.Banner;
import org.bukkit.block.banner.Pattern;
import org.bukkit.block.banner.PatternType;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Enderman;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Guardian;
import org.bukkit.entity.LivingEntity;
@ -141,9 +142,11 @@ public class MonsterController {
}
private static boolean meetsConditionsToBeElite(LivingEntity ent) {
if (Math.random()<=TwosideKeeper.ELITE_MONSTER_CHANCE && TwosideKeeper.LAST_ELITE_SPAWN+72000<TwosideKeeper.getServerTickTime()) {
if (Math.random()<=TwosideKeeper.ELITE_MONSTER_CHANCE && TwosideKeeper.LAST_ELITE_SPAWN+72000<TwosideKeeper.getServerTickTime() &&
((ent instanceof Zombie) || ((ent instanceof Skeleton) && ((Skeleton)ent).getSkeletonType()==SkeletonType.WITHER))) {
TwosideKeeper.log("Trying for an elite monster.", 4);
if (GenericFunctions.PercentBlocksAroundArea(ent.getLocation().getBlock(),Material.AIR,16,8,16)>=75) {
if (GenericFunctions.PercentBlocksAroundArea(ent.getLocation().getBlock(),Material.AIR,16,8,16)>=75 &&
ent.getNearbyEntities(64, 16, 64).size()<=2) {
TwosideKeeper.LAST_ELITE_SPAWN=TwosideKeeper.getServerTickTime();
return true;
}
@ -474,6 +477,54 @@ public class MonsterController {
m.getEquipment().setLeggingsDropChance(0.3f);
m.getEquipment().setHelmetDropChance(0.3f);
}break;
case 4:{
ItemStack helm = new ItemStack(Material.GOLD_HELMET);
m.getEquipment().setHelmet(helm);
m.getEquipment().setHelmet(Loot.GenerateSetPiece(helm, true, 1));
helm = new ItemStack(Material.GOLD_CHESTPLATE);
m.getEquipment().setChestplate(helm);
m.getEquipment().setChestplate(Loot.GenerateSetPiece(helm, true, 1));
helm = new ItemStack(Material.GOLD_LEGGINGS);
m.getEquipment().setLeggings(helm);
m.getEquipment().setLeggings(Loot.GenerateSetPiece(helm, true, 1));
helm = new ItemStack(Material.GOLD_BOOTS);
m.getEquipment().setBoots(helm);
m.getEquipment().setBoots(Loot.GenerateSetPiece(helm, true, 1));
TwosideKeeper.log("Helmet durability set to "+m.getEquipment().getHelmet().getDurability(), 5);
TwosideKeeper.log("Chestplate durability set to "+m.getEquipment().getChestplate().getDurability(), 5);
TwosideKeeper.log("Leggings durability set to "+m.getEquipment().getLeggings().getDurability(), 5);
TwosideKeeper.log("Boots durability set to "+m.getEquipment().getBoots().getDurability(), 5);
if ((m.getType()==EntityType.ZOMBIE &&
!((Zombie)m).isBaby()) ||
m.getType()==EntityType.GIANT ||
(m.getType()==EntityType.SKELETON &&
((Skeleton)m).getSkeletonType()==SkeletonType.WITHER)) {
//Equip a sword or rarely, an axe.
ItemStack weapon;
if (Math.random()<0.03) {
weapon = new ItemStack(Material.GOLD_AXE);
m.getEquipment().setItemInMainHand(Loot.GenerateSetPiece(weapon, true, 1));
} else {
weapon = new ItemStack(Material.GOLD_SWORD);
m.getEquipment().setItemInMainHand(Loot.GenerateSetPiece(weapon, true, 1));
}
if (Math.random()<0.5) {
ItemStack shield = new ItemStack(Material.SHIELD,1,(short)((Math.random()*DyeColor.values().length)));
m.getEquipment().setItemInOffHand(shield);
}
} else {
ItemStack weapon = new ItemStack(Material.BOW);
m.getEquipment().setItemInMainHand(Loot.GenerateSetPiece(weapon, true, 1));
}
if (m.getType()==EntityType.PIG_ZOMBIE) {
ItemStack weapon = new ItemStack(Material.GOLD_SWORD);
m.getEquipment().setItemInMainHand(Loot.GenerateSetPiece(weapon, true, 1));
}
m.getEquipment().setBootsDropChance(1.0f);
m.getEquipment().setChestplateDropChance(1.0f);
m.getEquipment().setLeggingsDropChance(1.0f);
m.getEquipment().setHelmetDropChance(1.0f);
}break;
default:{
if (Math.random()<0.1) {
if (Math.random()<0.5) {
@ -629,9 +680,9 @@ public class MonsterController {
}
if(isZombieLeader(m))
{
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99999,4));
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,4));
GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers());
m.setMaxHealth(20);
m.setMaxHealth(60);
m.setHealth(m.getMaxHealth());
MonsterStructure.getMonsterStructure(m).SetLeader(true);
}
@ -647,12 +698,12 @@ public class MonsterController {
m.getEquipment().clear();
RandomizeEquipment(m,2);
}
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99999,1));
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,1));
if(isZombieLeader(m))
{
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99999,4));
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,4));
GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers());
m.setMaxHealth(50);
m.setMaxHealth(120);
m.setHealth(m.getMaxHealth());
MonsterStructure.getMonsterStructure(m).SetLeader(true);
}
@ -667,18 +718,18 @@ public class MonsterController {
m.setMaxHealth(m.getMaxHealth()*4.0);
m.setHealth(m.getMaxHealth());
if (m.getType()!=EntityType.ENDERMAN) {
m.setFireTicks(999999);
m.setFireTicks(Integer.MAX_VALUE);
}
if (isAllowedToEquipItems(m)) {
m.getEquipment().clear();
RandomizeEquipment(m,3);
}
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99999,1));
m.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,99999,1));
if (Math.random()<=0.2) {m.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,99999,1));}
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,1));
m.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,Integer.MAX_VALUE,1));
if (Math.random()<=0.2) {m.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,Integer.MAX_VALUE,1));}
if(isZombieLeader(m))
{
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99999,4));
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,4));
GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers());
m.setMaxHealth(200);
m.setHealth(m.getMaxHealth());
@ -697,10 +748,10 @@ public class MonsterController {
GlowAPI.setGlowing(m, Color.DARK_PURPLE, Bukkit.getOnlinePlayers());
if (isAllowedToEquipItems(m)) {
m.getEquipment().clear();
RandomizeEquipment(m,3);
RandomizeEquipment(m,4);
}
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99999,8));
m.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,99999,8));
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8));
m.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,Integer.MAX_VALUE,8));
if (!GenericFunctions.isArmoredMob(m)) {
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8));
m.setMaxHealth(m.getMaxHealth()*2.0);
@ -718,7 +769,7 @@ public class MonsterController {
if(isZombieLeader(m))
{
GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers());
m.setMaxHealth(40);
m.setMaxHealth(100);
m.setHealth(m.getMaxHealth());
}
}break;

@ -129,7 +129,7 @@ public class NewCombat {
playerAddArtifactEXP(target,finaldmg);
applyOnHitMobEffects(target,damager,finaldmg);
finaldmg = CalculateDamageReduction(finaldmg,target,damager);
return calculateAbsorptionHearts(target, finaldmg);
}
@ -151,6 +151,7 @@ public class NewCombat {
addMultiplierToPlayerLogger(damager,"Critical Strike Mult",mult1);
if (mult1>1.0) {
aPlugin.API.critEntity(target, 15);
PlayerStructure.GetPlayerStructure(p).crit=true;
}
bonusmult*=mult1;
}
@ -311,6 +312,9 @@ public class NewCombat {
case NORMAL:
mult*=1.0;
break;
case ELITE:
mult*=15.0;
break;
default:
mult*=1.0;
break;
@ -608,10 +612,12 @@ public class NewCombat {
if (shooter instanceof Player) {
pd.target=getDamagerEntity(target);
}
pd.headshot=headshot;
pd.preemptive=preemptive;
if (pd.damagelogging) {
DecimalFormat df = new DecimalFormat("0.0");
TwosideKeeper.updateTitle(pl,pd);
//TwosideKeeper.updateTitle(pl,pd);
} else {
TwosideKeeper.updateTitle(pl,headshot,preemptive);
}
@ -849,6 +855,7 @@ public class NewCombat {
Player p = (Player)shooter;
critchance += (GenericFunctions.isStriker(p)?0.2:0.0);
critchance += ItemSet.TotalBaseAmountBasedOnSetBonusCount(p,ItemSet.PANROS,4,4)/100d;
critchance += (GenericFunctions.isRanger(p)?(GenericFunctions.getPotionEffectLevel(PotionEffectType.SLOW, p)+1)*0.1:0.0);
}
}
return critchance;
@ -899,7 +906,7 @@ public class NewCombat {
if (shooter instanceof Player) {
Player p = (Player)shooter;
if (GenericFunctions.isRanger(p)) {
double mult1 = 2.0;
double mult1 = 4.0;
addMultiplierToPlayerLogger(damager,"Ranger Passive Mult",mult1);
mult *= mult1; //x4 damage - Ranger passive.
}
@ -913,7 +920,7 @@ public class NewCombat {
addMultiplierToPlayerLogger(damager,"STRENGTH Mult",mult1);
mult *= mult1;
int weaknesslv = GenericFunctions.getPotionEffectLevel(PotionEffectType.WEAKNESS, damager)+1;
int weaknesslv = Math.abs(GenericFunctions.getPotionEffectLevel(PotionEffectType.WEAKNESS, damager))+1;
if (weaknesslv<=10) {
mult1 = 1.0-(weaknesslv*0.1);
addMultiplierToPlayerLogger(damager,ChatColor.RED+"WEAKNESS Mult",mult1);
@ -976,7 +983,7 @@ public class NewCombat {
for (int i=0;i<hitlist.size();i++) {
if (!hitlist.get(i).equals(target)) {
//hitlist.get(i).damage(dmg);
GenericFunctions.DealDamageToMob(dmg, hitlist.get(i), shooter, weapon);
GenericFunctions.DealDamageToMob(CalculateDamageReduction(dmg,target,damager), hitlist.get(i), shooter, weapon, "AoE Damage");
};
if (applyDeathMark) {
GenericFunctions.ApplyDeathMark(hitlist.get(i));
@ -1177,7 +1184,8 @@ public class NewCombat {
//Blocking: -((p.isBlocking())?ev.getDamage()*0.33:0) //33% damage will be reduced if we are blocking.
//Shield: -((p.getEquipment().getItemInOffHand()!=null && p.getEquipment().getItemInOffHand().getType()==Material.SHIELD)?ev.getDamage()*0.05:0) //5% damage will be reduced if we are holding a shield.
TwosideKeeper.log("Protection level: "+protectionlevel, 5);
resistlevel=(resistlevel>10)?10:resistlevel;
protectionlevel=(protectionlevel>100)?100:protectionlevel;
@ -1290,12 +1298,16 @@ public class NewCombat {
TwosideKeeper.log("New Slowness level: "+lv,5);
p.removePotionEffect(PotionEffectType.SLOW);
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,99,lv+1));
p.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99,lv+1));
break;
}
}
} else {
p.removePotionEffect(PotionEffectType.SLOW);
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,99,0));
p.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99,0));
}
final Player pl = p;
Bukkit.getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("TwosideKeeper"), new Runnable() {
@ -1370,7 +1382,6 @@ public class NewCombat {
pd.vendetta_amt+=(dmg-CalculateDamageReduction(dmg,target,damager))*0.3;
aPlugin.API.sendActionBarMessage(p, ChatColor.YELLOW+"Vendetta: "+ChatColor.GREEN+Math.round(pd.vendetta_amt)+" dmg stored");
}
}
if (damager instanceof Enderman) {
if (MonsterController.getMonsterDifficulty(((Monster)damager))==MonsterDifficulty.HELLFIRE) {
@ -1385,7 +1396,7 @@ public class NewCombat {
}
}
private static void addToPlayerLogger(Entity p, String event, double val) {
public static void addToPlayerLogger(Entity p, String event, double val) {
LivingEntity l = getDamagerEntity(p);
if (l!=null && l instanceof Player) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)l);
@ -1395,6 +1406,17 @@ public class NewCombat {
}
}
public static void addToLoggerTotal(Entity p, double val) {
LivingEntity l = getDamagerEntity(p);
if (l!=null && l instanceof Player) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)l);
if (pd.damagelogging) {
pd.damagedata.addCalculatedActualDamage(val);
pd.damagedata.addCalculatedTotalDamage(val);
}
}
}
private static void addMultiplierToPlayerLogger(Entity p, String event, double val) {
LivingEntity l = getDamagerEntity(p);
if (l!=null && l instanceof Player) {
@ -1405,7 +1427,7 @@ public class NewCombat {
}
}
private static double calculateAbsorptionHearts(LivingEntity target, double finaldmg) {
public 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.
@ -1476,7 +1498,7 @@ public class NewCombat {
p.isOnGround() && p.getLocation().getY()>=0 && p.getLocation().add(0,0,0).getBlock().getLightLevel()<=4) {
dodgechance+=0.01*p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK);
}
dodgechance+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p,ItemSet.PANROS,3,3)/100d;
if (GenericFunctions.isStriker(p) &&

@ -98,6 +98,9 @@ public class PlayerStructure {
public int debuffcount=0;
public boolean isViewingInventory=false;
public boolean destroyedminecart=false;
public boolean headshot=false;
public boolean preemptive=false;
public boolean crit=false;
//Needs the instance of the player object to get all other info. Only to be called at the beginning.
public PlayerStructure(Player p, long serverTickTime) {

@ -576,4 +576,36 @@ public class Recipes {
checkrecipe.addIngredient(Material.FEATHER);
Bukkit.addRecipe(checkrecipe);
}
public static void Initialize_HunterCompass_Recipe() {
ItemStack huntercompass = new ItemStack(Material.COMPASS);
huntercompass.addUnsafeEnchantment(Enchantment.LUCK, 1);
ItemMeta m = huntercompass.getItemMeta();
m.setDisplayName(ChatColor.RED+"Hunter's Compass");
List<String> lore = new ArrayList<String>();
lore.add("A compass for the true hunter.");
lore.add("Legends tell of hunters that have");
lore.add("come back with great treasures and");
lore.add("much wealth from following the.");
lore.add("directions of the guided arrow.");
lore.add("");
lore.add("You may need to calibrate it by");
lore.add("holding it first.");
lore.add("");
lore.add("The compass appears to be slightly");
lore.add("unstable...");
m.setLore(lore);
huntercompass.setItemMeta(m);
huntercompass.addUnsafeEnchantment(Enchantment.LUCK, 1);
ShapelessRecipe huntercompass_recipe = new ShapelessRecipe(huntercompass);
huntercompass_recipe.addIngredient(Material.COMPASS);
huntercompass_recipe.addIngredient(Material.DIAMOND_BLOCK);
huntercompass_recipe.addIngredient(Material.DIAMOND_BLOCK);
huntercompass_recipe.addIngredient(Material.DIAMOND_BLOCK);
huntercompass_recipe.addIngredient(Material.DIAMOND_BLOCK);
huntercompass_recipe.addIngredient(Material.DIAMOND_BLOCK);
huntercompass_recipe.addIngredient(Material.DIAMOND_BLOCK);
huntercompass_recipe.addIngredient(Material.DIAMOND_BLOCK);
huntercompass_recipe.addIngredient(Material.DIAMOND_BLOCK);
Bukkit.addRecipe(huntercompass_recipe);
}
}

@ -249,6 +249,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
public static ServerType SERVER_TYPE=ServerType.TEST; //The type of server this is running on.
public static int COMMONITEMPCT=3;
public static long LAST_ELITE_SPAWN = 0;
public static Location ELITE_LOCATION = null;
public static List<ArtifactAbility> TEMPORARYABILITIES = new ArrayList<ArtifactAbility>();
public static final int DODGE_COOLDOWN=100;
@ -277,6 +278,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
public static List<Party> PartyList = new ArrayList<Party>();
public List<Integer> colors_used = new ArrayList<Integer>();
public static List<ChargeZombie> chargezombies = new ArrayList<ChargeZombie>();
public static List<EliteMonster> elitemonsters = new ArrayList<EliteMonster>();
public static RecyclingCenter TwosideRecyclingCenter;
@ -328,6 +330,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
sig.plugin.TwosideKeeper.Recipes.Initialize_Artifact_Recipes();
sig.plugin.TwosideKeeper.Recipes.Initialize_ArtifactHelper_Recipes();
sig.plugin.TwosideKeeper.Recipes.Initialize_Check_Recipe();
//sig.plugin.TwosideKeeper.Recipes.Initialize_HunterCompass_Recipe();
//Bukkit.createWorld(new WorldCreator("ItemCube"));
@ -444,6 +447,16 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
cz.BreakBlocksAroundArea(1);
}
}
//Control elite monsters.
for (int i=0;i<elitemonsters.size();i++) {
EliteMonster em = elitemonsters.get(i);
if (!em.m.isValid()) {
elitemonsters.remove(i);
i--;
} else {
em.runTick();
}
}
}}, 5l, 5l);
if (SERVER_TYPE==ServerType.MAIN) { //Only perform this on the official servers. Test servers do not require constant updating.
@ -563,6 +576,15 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (mon.isElite) {
//Make it glow dark purple.
GenericFunctions.setGlowing(m, GlowAPI.Color.DARK_PURPLE);
boolean hasstruct = false;
for (int i=0;i<elitemonsters.size();i++) {
if (elitemonsters.get(i).m.equals(m)) {
hasstruct=true;
}
}
if (!hasstruct) {
elitemonsters.add(new EliteMonster(m));
}
}
}
}
@ -942,7 +964,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (cmd.getName().equalsIgnoreCase("fix")) {
Player p = (Player)sender;
if (Artifact.isMalleableBase(p.getEquipment().getItemInMainHand()) &&
MalleableBaseQuest.getTimeStarted(p.getEquipment().getItemInMainHand())<=147337849) {
MalleableBaseQuest.getTimeStarted(p.getEquipment().getItemInMainHand())<=213747510) {
p.getEquipment().setItemInMainHand(MalleableBaseQuest.setTimeStarted(p.getEquipment().getItemInMainHand(), getServerTickTime()));
}
if (GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand()) &&
@ -968,6 +990,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
p.getLocation().add(0,0,0).getBlock().setType(Material.AIR);
}
if (SERVER_TYPE==ServerType.TEST || SERVER_TYPE==ServerType.QUIET) {
Monster m = MonsterController.convertMonster((Monster)p.getWorld().spawnEntity(p.getLocation(),EntityType.ZOMBIE), MonsterDifficulty.ELITE);
m.setHealth(m.getMaxHealth()/16d);
//TwosideKeeperAPI.spawnAdjustedMonster(MonsterType.GIANT, p.getLocation());
//TwosideKeeper.log("This is from set "+ItemSet.GetSet(p.getEquipment().getItemInMainHand())+" T"+ItemSet.GetTier(p.getEquipment().getItemInMainHand()),2);
/*Skeleton s = (Skeleton)p.getWorld().spawnEntity(p.getLocation(), EntityType.SKELETON);
@ -1918,16 +1942,32 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
}
/*@EventHandler(priority=EventPriority.LOW)
@EventHandler(priority=EventPriority.LOW)
public void onPlayerInteract(PlayerInteractEntityEvent ev) {
log("Clicked with "+ ev.getHand().name(),2);
log("Clicked on: "+ev.getRightClicked().getName(),2);
if (ev.getHand()==EquipmentSlot.OFF_HAND) {aPlugin.API.swingOffHand(ev.getPlayer());};
}*/
log("Clicked with "+ ev.getHand().name(),5);
log("Clicked on: "+ev.getRightClicked().getName(),5);
MonsterDifficulty md = null;
if (ev.getPlayer().getEquipment().getItemInMainHand().getType()==Material.NAME_TAG && (ev.getRightClicked() instanceof Monster)) {
//TwosideKeeper.log("Check this out.", 2);
Monster m = (Monster)ev.getRightClicked();
//MonsterController.convertMonster(m,md);
final String oldname = m.getCustomName();
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
@Override
public void run() {
if (MonsterController.getMonsterDifficulty(m)!=MonsterDifficulty.NORMAL) {
log("It's not normal!",5);
m.setCustomName(oldname);
ev.getPlayer().getEquipment().getItemInMainHand().setAmount(ev.getPlayer().getEquipment().getItemInMainHand().getAmount()+1);
}
}
},1);
}
///if (ev.getHand()==EquipmentSlot.OFF_HAND) {aPlugin.API.swingOffHand(ev.getPlayer());};
}
@EventHandler(priority=EventPriority.LOW)
public void onPlayerInteract(PlayerInteractEvent ev) {
if (ev.isCancelled() && ev.getAction() == Action.RIGHT_CLICK_BLOCK) {
return;
} else {
@ -2028,8 +2068,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
aPlugin.API.sendCooldownPacket(player, player.getEquipment().getItemInMainHand(), 240);
pd.last_deathmark = getServerTickTime();
int stackamt = GenericFunctions.GetDeathMarkAmt(m);
m.setNoDamageTicks(0);
GenericFunctions.DealDamageToMob(stackamt*dmg, m, player);
m.setLastDamage(0);
m.setNoDamageTicks(0);
m.setMaximumNoDamageTicks(0);
GenericFunctions.DealDamageToMob(stackamt*dmg, m, player, null, "Death Mark");
m.removePotionEffect(PotionEffectType.UNLUCK);
player.playSound(m.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 1.0f, 1.0f);
}
@ -3043,6 +3085,49 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
setPlayerMaxHealth(player);
}
},1);
if (GenericFunctions.isHunterCompass(player.getInventory().getItem(ev.getNewSlot()))) {
player.sendMessage("Calibrating "+player.getInventory().getItem(ev.getNewSlot()).getItemMeta().getDisplayName()+ChatColor.WHITE+"...");
String name = player.getInventory().getItem(ev.getNewSlot()).getItemMeta().getDisplayName();
if (Math.random()<=0.5) {
if (player.getInventory().getItem(ev.getNewSlot()).getAmount()<=1) {
player.getInventory().getItem(ev.getNewSlot()).setType(Material.AIR);
} else {
player.getInventory().getItem(ev.getNewSlot()).setAmount(player.getInventory().getItem(ev.getNewSlot()).getAmount()-1);
}
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
@Override
public void run() {
player.sendMessage("The "+name+ChatColor.WHITE+" is now...");
}
},15);
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
@Override
public void run() {
player.playSound(player.getLocation(), Sound.BLOCK_METAL_BREAK, 1.0f, 1.0f);
}
},20);
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
@Override
public void run() {
player.sendMessage(ChatColor.ITALIC+" Oh my! It appears to have broke!");
}
},45);
} else {
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
@Override
public void run() {
player.sendMessage("The "+name+ChatColor.WHITE+" is now properly calibrated!");
}
},15);
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
@Override
public void run() {
player.sendMessage(ChatColor.ITALIC+" Good luck on your adventure!");
}
},45);
player.setCompassTarget(TwosideKeeper.ELITE_LOCATION);
}
}
}
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
@ -3601,10 +3686,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
log("Denied chicken spawn.",4);
}
if (ev.getSpawnReason().equals(SpawnReason.CHUNK_GEN)) {
log("Chunk gen",2);
}
if ((ev.getSpawnReason().equals(SpawnReason.NATURAL) ||
ev.getSpawnReason().equals(SpawnReason.SPAWNER_EGG) ||
ev.getSpawnReason().equals(SpawnReason.REINFORCEMENTS) ||
@ -3706,247 +3787,276 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ev.setDamage(DamageModifier.RESISTANCE,0);
ev.setDamage(DamageModifier.ARMOR,0);
//Calculate as true damage.
}
}
if (e instanceof LivingEntity) {
LivingEntity l = (LivingEntity)e;
int poisonlv = 0;
if (l.hasPotionEffect(PotionEffectType.POISON)) {
for (int j=0;j<l.getActivePotionEffects().size();j++) {
if (Iterables.get(l.getActivePotionEffects(), j).getType().equals(PotionEffectType.POISON)) {
poisonlv = Iterables.get(l.getActivePotionEffects(), j).getAmplifier()+1;
break;
}
}
if (poisonlv>0 && ev.getCause()!=DamageCause.POISON) {
ev.setDamage(ev.getDamage()+(ev.getDamage()*poisonlv*0.5));
log("New damage set to "+ev.getDamage()+" from Poison "+poisonlv,5);
}
}
if (l instanceof Monster) {
if (l.hasPotionEffect(PotionEffectType.BLINDNESS)) {
for (int j=0;j<l.getActivePotionEffects().size();j++) {
if (Iterables.get(l.getActivePotionEffects(), j).getType().equals(PotionEffectType.BLINDNESS)) {
poisonlv = Iterables.get(l.getActivePotionEffects(), j).getAmplifier()+1;
break;
}
}
if (poisonlv>0) {
ev.setDamage(ev.getDamage()+(ev.getDamage()*poisonlv*0.5));
log("New damage set to "+ev.getDamage()+" from Poison "+poisonlv,5);
}
if (ev.getEntity() instanceof Player) {
Player p = (Player)ev.getEntity();
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (pd.hitlist.containsKey(p.getUniqueId())) {
if (pd.hitlist.get(p.getUniqueId())+10>TwosideKeeper.getServerTickTime()) {
ev.setCancelled(true);
} else {
pd.hitlist.put(p.getUniqueId(), TwosideKeeper.getServerTickTime());
}
} else {
pd.hitlist.put(p.getUniqueId(), TwosideKeeper.getServerTickTime());
}
}
}
}
if (e instanceof Player) {
log("Damage reason is "+ev.getCause().toString(),4);
final Player p = (Player)e;
if (GenericFunctions.isDefender(p) && p.isBlocking()) {
log("Reducing knockback...",3);
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
public void run() {
if (p!=null) {
p.setVelocity(p.getVelocity().multiply(0.25));
if (ev.getEntity() instanceof Monster) {
Monster m = (Monster)ev.getEntity();
MonsterStructure md = MonsterStructure.getMonsterStructure(m);
if (md.hitlist.containsKey(m.getUniqueId())) {
if (md.hitlist.get(m.getUniqueId())+10>TwosideKeeper.getServerTickTime()) {
ev.setCancelled(true);
} else {
md.hitlist.put(m.getUniqueId(), TwosideKeeper.getServerTickTime());
}
}}
,1);
}
if (ev.getCause()==DamageCause.BLOCK_EXPLOSION) {
//Calculate new damage based on armor worn.
//Remove all other damage modifiers since we will calculate it manually.
ev.setDamage(DamageModifier.BLOCKING,0);
ev.setDamage(DamageModifier.MAGIC,0);
ev.setDamage(DamageModifier.RESISTANCE,0);
ev.setDamage(DamageModifier.ARMOR,0);
//Damage reduction is also set based on how much blast resistance we have.
ItemStack[] armor = p.getEquipment().getArmorContents();
int protectionlevel = 0;
for (int i=0;i<armor.length;i++) {
if (armor[i]!=null &&
armor[i].getType()!=Material.AIR) {
protectionlevel+=armor[i].getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS);
} else {
md.hitlist.put(m.getUniqueId(), TwosideKeeper.getServerTickTime());
}
}
ev.setDamage(DamageModifier.BASE,NewCombat.CalculateDamageReduction(ev.getDamage()*EXPLOSION_DMG_MULT*((100-protectionlevel)*0.01),p,null));
ev.setDamage(NewCombat.CalculateDamageReduction(ev.getDamage()*EXPLOSION_DMG_MULT*((100-protectionlevel)*0.01),p,null));
log("Explosion Damage is "+ev.getDamage(),2);
//ev.setDamage(CalculateDamageReduction(ev.getDamage()*EXPLOSION_DMG_MULT,p,null));
}
if (ev.getCause()==DamageCause.VOID) {
Location p_loc = p.getLocation();
double totalmoney = getPlayerMoney(p);
if (totalmoney>=0.01) {
p_loc.setY(0);
p.teleport(p_loc);
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,20*2 /*Approx 2 sec of no movement.*/,10));
p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,20*18 /*Approx 18 sec to reach height 100*/,6));
p.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,20*18 /*Approx 18 sec to reach height 100*/,6));
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,20*26 /*Reduces fall damage temporarily.*/,500));
DecimalFormat df = new DecimalFormat("0.00");
double rand_amt = 0.0;
if (totalmoney>5) {
rand_amt = Math.random()*5;
} else {
rand_amt = Math.random()*getPlayerMoney(p);
}
p.sendMessage("A Mysterious Entity forcefully removes "+ChatColor.YELLOW+"$"+df.format(rand_amt)+ChatColor.WHITE+" from your pockets.");
givePlayerMoney(p, -rand_amt);
}
}
if (!ev.isCancelled()) {
if (e instanceof LivingEntity) {
LivingEntity l = (LivingEntity)e;
int poisonlv = 0;
if (l.hasPotionEffect(PotionEffectType.POISON)) {
for (int j=0;j<l.getActivePotionEffects().size();j++) {
if (Iterables.get(l.getActivePotionEffects(), j).getType().equals(PotionEffectType.POISON)) {
poisonlv = Iterables.get(l.getActivePotionEffects(), j).getAmplifier()+1;
break;
}
}
if (poisonlv>0 && ev.getCause()!=DamageCause.POISON) {
ev.setDamage(ev.getDamage()+(ev.getDamage()*poisonlv*0.5));
log("New damage set to "+ev.getDamage()+" from Poison "+poisonlv,5);
}
}
if (l instanceof Monster) {
if (l.hasPotionEffect(PotionEffectType.BLINDNESS)) {
for (int j=0;j<l.getActivePotionEffects().size();j++) {
if (Iterables.get(l.getActivePotionEffects(), j).getType().equals(PotionEffectType.BLINDNESS)) {
poisonlv = Iterables.get(l.getActivePotionEffects(), j).getAmplifier()+1;
break;
}
}
if (poisonlv>0) {
ev.setDamage(ev.getDamage()+(ev.getDamage()*poisonlv*0.5));
log("New damage set to "+ev.getDamage()+" from Poison "+poisonlv,5);
}
}
}
}
if (e instanceof Player) {
log("Damage reason is "+ev.getCause().toString(),4);
final Player p = (Player)e;
if (GenericFunctions.isDefender(p) && p.isBlocking()) {
log("Reducing knockback...",3);
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
public void run() {
if (p!=null) {
p.sendMessage(ChatColor.AQUA+""+ChatColor.ITALIC+" \"Enjoy the ride!\"");
p.setVelocity(p.getVelocity().multiply(0.25));
}
}}
,40);
} else {
PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId());
if (pd.last_laugh_time+400<getServerTickTime()) {
p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+"A Mysterious Entity looks at your empty pockets with disdain, then laughs chaotically as you fall to your doom.");
pd.last_laugh_time=getServerTickTime();
}
}
}
//See if we're in a party with a defender.
for (int i=0;i<PartyList.size();i++) {
Party check = PartyList.get(i);
if (check.IsInParty(p)) {
for (int j=0;j<check.partyplayers.size();j++) {
//See if there's a defender blocking in there.
Player pcheck = check.partyplayers.get(j);
if (GenericFunctions.isDefender(pcheck) &&
pcheck.isBlocking() &&
!p.equals(check.partyplayers.get(j))) {
//This is a defender. Transfer half the damage to them!
ev.setDamage(ev.getDamage()/2);
//Send the rest of the damage to the defender.
double dmg = ev.getDamage()/2;
dmg=NewCombat.CalculateDamageReduction(dmg, pcheck, ev.getEntity());
if (pcheck.getHealth()-dmg<0) {
pcheck.setHealth(0);
} else {
pcheck.setHealth(pcheck.getHealth()-dmg);
}
log("Damage was absorbed by "+pcheck.getName()+". Tanked "+dmg+" damage. Original damage: "+ev.getDamage()/2,4);
break;
}
}
break;
}
}
//If glowing, the player is invulnerable.
if (p.hasPotionEffect(PotionEffectType.GLOWING)) {
p.setNoDamageTicks(20);
ev.setCancelled(true);
} else {
//Dodge should not activate when we have invincibility frames.
//final double pcthp = ((p.getHealth())/p.getMaxHealth())*100;
double dodgechance = NewCombat.CalculateDodgeChance(p);
if (ev.getCause()==DamageCause.THORNS &&
GenericFunctions.isRanger(p)) {
dodgechance=1;
double dmg = p.getHealth()-0.25;
if (!GenericFunctions.AttemptRevive(p,dmg)) {
ev.setDamage(dmg);
p.playSound(p.getLocation(), Sound.ENCHANT_THORNS_HIT, 0.8f, 3.0f);
} else {
ev.setCancelled(true);
}
,1);
}
PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId());
if (ev.getCause()==DamageCause.BLOCK_EXPLOSION) {
//Calculate new damage based on armor worn.
//Remove all other damage modifiers since we will calculate it manually.
ev.setDamage(DamageModifier.BLOCKING,0);
ev.setDamage(DamageModifier.MAGIC,0);
ev.setDamage(DamageModifier.RESISTANCE,0);
ev.setDamage(DamageModifier.ARMOR,0);
//Damage reduction is also set based on how much blast resistance we have.
ItemStack[] armor = p.getEquipment().getArmorContents();
int protectionlevel = 0;
for (int i=0;i<armor.length;i++) {
if (armor[i]!=null &&
armor[i].getType()!=Material.AIR) {
protectionlevel+=armor[i].getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS);
}
}
ev.setDamage(DamageModifier.BASE,NewCombat.CalculateDamageReduction(ev.getDamage()*EXPLOSION_DMG_MULT*((100-protectionlevel)*0.01),p,null));
ev.setDamage(NewCombat.CalculateDamageReduction(ev.getDamage()*EXPLOSION_DMG_MULT*((100-protectionlevel)*0.01),p,null));
log("Explosion Damage is "+ev.getDamage(),5);
//ev.setDamage(CalculateDamageReduction(ev.getDamage()*EXPLOSION_DMG_MULT,p,null));
}
if (pd.fulldodge) {
pd.fulldodge=false;
if (ev.getCause()==DamageCause.VOID) {
Location p_loc = p.getLocation();
double totalmoney = getPlayerMoney(p);
if (totalmoney>=0.01) {
p_loc.setY(0);
p.teleport(p_loc);
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,20*2 /*Approx 2 sec of no movement.*/,10));
p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,20*18 /*Approx 18 sec to reach height 100*/,6));
p.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,20*18 /*Approx 18 sec to reach height 100*/,6));
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,20*26 /*Reduces fall damage temporarily.*/,500));
DecimalFormat df = new DecimalFormat("0.00");
double rand_amt = 0.0;
if (totalmoney>5) {
rand_amt = Math.random()*5;
} else {
rand_amt = Math.random()*getPlayerMoney(p);
}
p.sendMessage("A Mysterious Entity forcefully removes "+ChatColor.YELLOW+"$"+df.format(rand_amt)+ChatColor.WHITE+" from your pockets.");
givePlayerMoney(p, -rand_amt);
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
public void run() {
if (p!=null) {
p.sendMessage(ChatColor.AQUA+""+ChatColor.ITALIC+" \"Enjoy the ride!\"");
}
}}
,40);
} else {
PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId());
if (pd.last_laugh_time+400<getServerTickTime()) {
p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+"A Mysterious Entity looks at your empty pockets with disdain, then laughs chaotically as you fall to your doom.");
pd.last_laugh_time=getServerTickTime();
}
}
}
if (Math.random()<=dodgechance) {
//Cancel this event, we dodged the attack.
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_ATTACK_SWEEP, 3.0f, 1.0f);
log("Triggered Dodge.",3);
for (int i=0;i<p.getEquipment().getArmorContents().length;i++) {
ItemStack equip = p.getEquipment().getArmorContents()[i];
if (ArtifactAbility.containsEnchantment(ArtifactAbility.GRACEFULDODGE, equip)) {
p.addPotionEffect(
new PotionEffect(PotionEffectType.GLOWING,
(int)(GenericFunctions.getAbilityValue(ArtifactAbility.GRACEFULDODGE, equip)*20),
0)
);
//See if we're in a party with a defender.
for (int i=0;i<PartyList.size();i++) {
Party check = PartyList.get(i);
if (check.IsInParty(p)) {
for (int j=0;j<check.partyplayers.size();j++) {
//See if there's a defender blocking in there.
Player pcheck = check.partyplayers.get(j);
if (GenericFunctions.isDefender(pcheck) &&
pcheck.isBlocking() &&
!p.equals(check.partyplayers.get(j))) {
//This is a defender. Transfer half the damage to them!
ev.setDamage(ev.getDamage()/2);
//Send the rest of the damage to the defender.
double dmg = ev.getDamage()/2;
dmg=NewCombat.CalculateDamageReduction(dmg, pcheck, ev.getEntity());
if (pcheck.getHealth()-dmg<0) {
pcheck.setHealth(0);
} else {
pcheck.setHealth(pcheck.getHealth()-dmg);
}
log("Damage was absorbed by "+pcheck.getName()+". Tanked "+dmg+" damage. Original damage: "+ev.getDamage()/2,4);
break;
}
}
p.setNoDamageTicks(10);
break;
}
}
//If glowing, the player is invulnerable.
if (p.hasPotionEffect(PotionEffectType.GLOWING)) {
p.setNoDamageTicks(20);
ev.setCancelled(true);
} else {
//Dodge should not activate when we have invincibility frames.
//final double pcthp = ((p.getHealth())/p.getMaxHealth())*100;
double dodgechance = NewCombat.CalculateDodgeChance(p);
if (ev.getCause()==DamageCause.THORNS &&
GenericFunctions.isRanger(p)) {
dodgechance=1;
double dmg = p.getHealth()-0.25;
if (!GenericFunctions.AttemptRevive(p,dmg)) {
ev.setDamage(dmg);
p.playSound(p.getLocation(), Sound.ENCHANT_THORNS_HIT, 0.8f, 3.0f);
} else {
ev.setCancelled(true);
}
}
PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId());
if (pd.fulldodge) {
pd.fulldodge=false;
}
if (Math.random()<=dodgechance) {
//Cancel this event, we dodged the attack.
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_ATTACK_SWEEP, 3.0f, 1.0f);
log("Triggered Dodge.",3);
for (int i=0;i<p.getEquipment().getArmorContents().length;i++) {
ItemStack equip = p.getEquipment().getArmorContents()[i];
if (ArtifactAbility.containsEnchantment(ArtifactAbility.GRACEFULDODGE, equip)) {
p.addPotionEffect(
new PotionEffect(PotionEffectType.GLOWING,
(int)(GenericFunctions.getAbilityValue(ArtifactAbility.GRACEFULDODGE, equip)*20),
0)
);
}
}
p.setNoDamageTicks(10);
ev.setCancelled(true);
}
log("Dodge chance is "+dodgechance,5);
}
log("Dodge chance is "+dodgechance,5);
}
if (!ev.isCancelled() && GenericFunctions.AttemptRevive(p,ev.getFinalDamage())) {
ev.setCancelled(true);
}
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
public void run() {
if (p!=null) {
p.getScoreboard().getTeam(p.getName().toLowerCase()).setSuffix(createHealthbar(((p.getHealth())/p.getMaxHealth())*100,p));
p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(GenericFunctions.PlayerModePrefix(p));
}
}}
,2);
} else {
if (e instanceof Monster) {
final Monster m = (Monster)e;
if (ev.getCause()==DamageCause.ENTITY_EXPLOSION ||
ev.getCause()==DamageCause.BLOCK_EXPLOSION) {
//Calculate new damage based on armor worn.
//Remove all other damage modifiers since we will calculate it manually.
//ev.setDamage(DamageModifier.BLOCKING,0);
ev.setDamage(DamageModifier.MAGIC,0);
ev.setDamage(DamageModifier.RESISTANCE,0);
ev.setDamage(DamageModifier.ARMOR,0);
//Damage reduction is also set based on how much blast resistance we have.
ItemStack[] armor = m.getEquipment().getArmorContents();
int protectionlevel = 0;
for (int i=0;i<armor.length;i++) {
if (armor[i]!=null &&
armor[i].getType()!=Material.AIR) {
protectionlevel+=armor[i].getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS);
}
}
double dmg = NewCombat.CalculateDamageReduction(ev.getDamage()*EXPLOSION_DMG_MULT*((100-protectionlevel)*0.01),m,null);
ev.setDamage(dmg);
//log("Damage is "+ev.getDamage(),4);
//ev.setDamage(CalculateDamageReduction(ev.getDamage()*EXPLOSION_DMG_MULT,p,null));
}
}
}
if (ev.getCause()==DamageCause.CUSTOM) {
if (ev.getEntity() instanceof LivingEntity) {
//NewCombat.setupTrueDamage(ev);
log("Dealing "+ev.getFinalDamage()+" damage.",2);
}
}
if (!ev.isCancelled() && GenericFunctions.AttemptRevive(p,ev.getFinalDamage())) {
ev.setCancelled(true);
}
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
public void run() {
if (p!=null) {
p.getScoreboard().getTeam(p.getName().toLowerCase()).setSuffix(createHealthbar(((p.getHealth())/p.getMaxHealth())*100,p));
p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(GenericFunctions.PlayerModePrefix(p));
}
}}
,2);
} else {
if (e instanceof Monster) {
final Monster m = (Monster)e;
if (ev.getCause()==DamageCause.ENTITY_EXPLOSION ||
ev.getCause()==DamageCause.BLOCK_EXPLOSION) {
//Calculate new damage based on armor worn.
//Remove all other damage modifiers since we will calculate it manually.
//ev.setDamage(DamageModifier.BLOCKING,0);
ev.setDamage(DamageModifier.MAGIC,0);
ev.setDamage(DamageModifier.RESISTANCE,0);
ev.setDamage(DamageModifier.ARMOR,0);
//Damage reduction is also set based on how much blast resistance we have.
ItemStack[] armor = m.getEquipment().getArmorContents();
int protectionlevel = 0;
for (int i=0;i<armor.length;i++) {
if (armor[i]!=null &&
armor[i].getType()!=Material.AIR) {
protectionlevel+=armor[i].getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS);
}
}
double dmg = NewCombat.CalculateDamageReduction(ev.getDamage()*EXPLOSION_DMG_MULT*((100-protectionlevel)*0.01),m,null);
ev.setDamage(dmg);
//log("Damage is "+ev.getDamage(),4);
//ev.setDamage(CalculateDamageReduction(ev.getDamage()*EXPLOSION_DMG_MULT,p,null));
}
}
}
if (ev.getCause()==DamageCause.CUSTOM) {
if (ev.getEntity() instanceof LivingEntity) {
//NewCombat.setupTrueDamage(ev);
log("Dealing "+ev.getFinalDamage()+" damage.",4);
}
}
}
}
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
@ -3979,7 +4089,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
Player p = (Player)m.getTarget();
if (GenericFunctions.isRanger(p)) {
//Teleport it into oblivion.
log("Going into another dimension...",2);
log("Going into another dimension...",5);
m.teleport(new Location(Bukkit.getWorld("world_nether"),m.getLocation().getX(),m.getLocation().getY(),m.getLocation().getZ()));
}
}
@ -3999,7 +4109,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
public void run() {
c.getLocation().getWorld().createExplosion(c.getLocation().getX(),c.getLocation().getY(),c.getLocation().getZ(),4.0f,false,false);
GenericFunctions.DealExplosionDamageToEntities(c.getLocation(), 6, 4);
GenericFunctions.DealExplosionDamageToEntities(c.getLocation(), 16, 4);
}}
,10);
} else
@ -4008,27 +4118,17 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
public void run() {
c.getLocation().getWorld().createExplosion(c.getLocation().getX(),c.getLocation().getY(),c.getLocation().getZ(),6.0f,true,false);
GenericFunctions.DealExplosionDamageToEntities(c.getLocation(), 12, 6);
GenericFunctions.DealExplosionDamageToEntities(c.getLocation(), 32, 6);
}}
,10);
} else
if (c.getCustomName().contains("Hellfire")) {
log("Preparing to explode.",5);
c.getLocation().getWorld().playSound(c.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1.0f, 1.0f);
for (int i=0;i<6;i++) {
final int val = i;
final Location offset = c.getLocation().add((i==0||i==1)?(i==0)?6:-6:0,(i==2||i==3)?(i==2)?6:-6:0,(i==4||i==5)?(i==4)?6:-6:0);
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
public void run() {
c.getLocation().getWorld().createExplosion(c.getLocation().getX()+offset.getX(),c.getLocation().getY()+offset.getY(),c.getLocation().getZ()+offset.getZ(),6.0f,true,false);
GenericFunctions.DealExplosionDamageToEntities(c.getLocation(), 12, 6);
}}
,val+4);
}
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
public void run() {
c.getLocation().getWorld().createExplosion(c.getLocation().getX(),c.getLocation().getY(),c.getLocation().getZ(),8.0f,true,false);
GenericFunctions.DealExplosionDamageToEntities(c.getLocation(), 24, 8);
GenericFunctions.DealExplosionDamageToEntities(c.getLocation(), 64, 8);
}}
,30);
}
@ -4055,6 +4155,24 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
public void entityTargetEvent(EntityTargetLivingEntityEvent ev) {
if ((ev.getEntity() instanceof Monster)) {
Monster m = (Monster)ev.getEntity();
MonsterStructure ms = MonsterStructure.getMonsterStructure(m);
if (ms.getElite()) {
EliteMonster em = null;
for (int i=0;i<elitemonsters.size();i++) {
if (elitemonsters.get(i).m.equals(ev.getEntity())) {
em = elitemonsters.get(i);
break;
}
}
if (em!=null && (ev.getTarget() instanceof Player) && !em.targetlist.contains((Player)ev.getTarget())) {
em.targetlist.add((Player)ev.getTarget());
}
m.setTarget(ev.getTarget());
ev.setCancelled(true);
}
}
if (ev.getEntity() instanceof LivingEntity &&
ev.getReason()==TargetReason.PIG_ZOMBIE_TARGET) {
LivingEntity l = (LivingEntity)ev.getEntity();
@ -4084,6 +4202,24 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
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);
if (ev.getEntity() instanceof Monster &&
monsterdata.containsKey(ev.getEntity().getUniqueId())) {
MonsterStructure ms = MonsterStructure.getMonsterStructure((Monster)ev.getEntity());
if (ms.getElite()) {
boolean exists=false;
for (int i=0;i<elitemonsters.size();i++) {
if (elitemonsters.get(i).m.equals(ev.getEntity())) {
exists=true;
elitemonsters.get(i).runHitEvent((Player)ev.getDamager());
}
}
if (!exists) {
elitemonsters.add(new EliteMonster((Monster)ev.getEntity()));
}
}
}
log("New Damage: "+ev.getFinalDamage(),4);
} else {
double dmg = 0.0;
@ -4136,7 +4272,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
dmg = NewCombat.applyDamage((LivingEntity)ev.getEntity(), ev.getDamager());
if (!(ev.getEntity() instanceof Monster) || !(ev.getDamager() instanceof Monster)) {
log(GenericFunctions.GetEntityDisplayName(ev.getDamager())+ChatColor.GRAY+"->"+
GenericFunctions.GetEntityDisplayName(ev.getEntity())+ChatColor.GRAY+": Damage dealt was "+dmg,2);
GenericFunctions.GetEntityDisplayName(ev.getEntity())+ChatColor.GRAY+": Damage dealt was "+dmg,4);
}
}
if (ev.getCause()==DamageCause.THORNS) {
@ -4164,6 +4300,14 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ev.setCancelled(true);
}
}
if (NewCombat.getDamagerEntity(ev.getDamager()) instanceof Monster &&
ev.getEntity() instanceof LivingEntity) {
for (int i=0;i<elitemonsters.size();i++) {
if (elitemonsters.get(i).m.equals(NewCombat.getDamagerEntity(ev.getDamager()))) {
elitemonsters.get(i).hitEvent((LivingEntity)ev.getEntity());
}
}
}
if (NewCombat.getDamagerEntity(ev.getDamager()) instanceof Player) {
if (ev.getDamager() instanceof Projectile) {
ev.getDamager().remove();
@ -4219,6 +4363,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
double dropmult = 0.0d;
boolean isBoss=false;
boolean isElite=false;
boolean killedByPlayer = false;
final Location deathloc = m.getLocation();
MonsterStructure ms = null;
@ -4276,6 +4421,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
isBoss=GenericFunctions.isBossMonster(m);
isElite=GenericFunctions.isEliteMonster(m);
if (killedByPlayer && GenericFunctions.isCoreMonster(m) && Math.random()<RARE_DROP_RATE*dropmult*ARTIFACT_RARITY) {
switch ((int)(Math.random()*4)) {
@ -4328,6 +4474,41 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
}
}
if (isElite) {
dropmult+=50;
EliteMonster em = GenericFunctions.getEliteMonster(m);
//For each target, drop additional loot and exp.
List<Player> participants = em.getTargetList();
StringBuilder participants_list = new StringBuilder();
for (int i=0;i<participants.size();i++) {
Player pl = participants.get(i);
ExperienceOrb exp = GenericFunctions.spawnXP(pl.getLocation(), ev.getDroppedExp()*300);
exp.setInvulnerable(true);
List<ItemStack> generatedloot = MonsterController.getMonsterDifficulty((Monster)ev.getEntity()).RandomizeDrops(dropmult/participants.size(),false,false);
for (int j=0;j<generatedloot.size();j++) {
Item it = pl.getWorld().dropItemNaturally(pl.getLocation(),generatedloot.get(j));
it.setInvulnerable(true);
log("Dropping "+generatedloot.get(j).toString(),2);
}
if (participants_list.length()<1) {
participants_list.append(pl.getName());
} else {
if (i==participants.size()-1) {
if (participants.size()==2) {
participants_list.append(" and "+pl.getName());
} else {
participants_list.append(", and "+pl.getName());
}
} else {
participants_list.append(","+pl.getName());
}
}
}
Bukkit.getServer().broadcastMessage(ChatColor.GREEN+participants_list.toString()+ChatColor.WHITE+" have successfully slain "+m.getCustomName()+ChatColor.WHITE+"!");
aPlugin.API.discordSendRaw(ChatColor.GREEN+participants_list.toString()+ChatColor.WHITE+" have successfully slain **"+m.getCustomName()+ChatColor.WHITE+"**!");
GenericFunctions.generateNewElite();
}
dropmult = dropmult + (luckmult * 0.5) - (unluckmult * 0.5);
@ -4355,7 +4536,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
break;
case DANGEROUS:
totalexp=ev.getDroppedExp()*4;
ev.setDroppedExp((int)(totalexp*0.75));
droplist.addAll(originaldroplist);
break;
case DEADLY:
@ -4416,6 +4596,14 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}}
,50);
break;
case ELITE:
totalexp=ev.getDroppedExp()*300;
final Monster mer2 = m;
for (int i=0;i<drop.size();i++) {
Item it = deathloc.getWorld().dropItemNaturally(mer2.getLocation(), drop.get(i));
it.setInvulnerable(true);
}
break;
}
log("Drop list contains "+(droplist.size()+originaldroplist.size())+" elements.",5);
log(" Drops "+"["+(drop.size()+originaldroplist.size())+"]: "+ChatColor.GOLD+ChatColor.stripColor(originaldroplist.toString())+ChatColor.WHITE+","+ChatColor.LIGHT_PURPLE+ChatColor.stripColor(drop.toString()),2);
@ -4447,10 +4635,13 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (DeathManager.getDeathStructure(p)!=null) {
DeathManager.continueAction(p);
}
p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION,1,0),true);
p.removePotionEffect(PotionEffectType.ABSORPTION);
}
},1);
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
pd.hasDied=false;
GenericFunctions.addIFrame(p, 20*10);
}
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
@ -4525,7 +4716,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (affected.get(i) instanceof Monster) {
if (ev.getEntity().getCustomName()!=null) {
log("Custom name is "+ev.getEntity().getCustomName(),5);
affected.get(i).setNoDamageTicks(0);
if (ev.getEntity().getCustomName().contains("EW ")) {
double dmgdealt=Double.parseDouble(ev.getEntity().getCustomName().split(" ")[1]);
log("Dealing "+dmgdealt+" damage. Player is "+Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]).getName(),4);
@ -4548,8 +4738,26 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
pd.last_strikerspell = pd.last_strikerspell-40;
aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), (int)(LINEDRIVE_COOLDOWN-(TwosideKeeper.getServerTickTime()-pd.last_strikerspell)));
}
} else {
affected.remove(i);
i--;
}
} else {
affected.remove(i);
i--;
}
} else
if (affected.get(i) instanceof Player) {
if (ev.getEntity().getCustomName().contains("WEAK")) {
Player p = (Player)(affected.get(i));
int weaknesslv = Integer.parseInt(ev.getEntity().getCustomName().split(" ")[1]);
int duration = Integer.parseInt(ev.getEntity().getCustomName().split(" ")[2]);
p.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS,duration,-weaknesslv),true);
log("Weakness Level: "+GenericFunctions.getPotionEffectLevel(PotionEffectType.WEAKNESS, p),5);
} else {
affected.remove(i);
i--;
}
} else {
affected.remove(i);
i--;
@ -5418,6 +5626,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
//getConfig().set("ARTIFACT_RARITY", ARTIFACT_RARITY);
getConfig().set("SERVER_TYPE", SERVER_TYPE.GetValue());
getConfig().set("LAST_ELITE_SPAWN", LAST_ELITE_SPAWN);
getConfig().set("ELITE_LOCATION_X", ELITE_LOCATION.getBlockX());
getConfig().set("ELITE_LOCATION_Z", ELITE_LOCATION.getBlockZ());
//getConfig().set("MOTD", MOTD); //It makes no sense to save the MOTD as it will never be modified in-game.
saveConfig();
@ -5504,6 +5714,19 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ARTIFACT_RARITY = getConfig().getDouble("ARTIFACT_RARITY");
SERVER_TYPE = ServerType.GetTypeFromValue(getConfig().getInt("SERVER_TYPE"));
LAST_ELITE_SPAWN = getConfig().getLong("LAST_ELITE_SPAWN");
if (getConfig().contains("ELITE_LOCATION_X")) {
int x = getConfig().getInt("ELITE_LOCATION_X");
int z = getConfig().getInt("ELITE_LOCATION_Z");
TwosideKeeper.ELITE_LOCATION=new Location(Bukkit.getWorld("world"),x,0,z);
} else {
log("Did not find a valid Elite Location! Creating a new one!",2);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
GenericFunctions.generateNewElite();
}
},20);
}
getMOTD();
//Informational reports to the console.
@ -6046,6 +6269,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
public static void updateTitle(final Player p, boolean headshot) {
if (headshot) {
updateTitle(p,ChatColor.DARK_RED+"HEADSHOT !");
TwosideKeeper.log("Run here.", 5);
/*
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
public void run() {
@ -6121,7 +6345,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ChatColor finalcolor = GetHeartColor(color1);
ChatColor finalcolor2 = GetHeartColor(color2);
final String finalheartdisplay=finalcolor2+((finalcolor2==ChatColor.MAGIC)?remainingheartdisplay.replace((char)0x2665, 'A'):remainingheartdisplay)+finalcolor+((finalcolor==ChatColor.MAGIC)?heartdisplay.substring(0, heartdisplay.length()-remainingheartdisplay.length()).replace((char)0x2665, 'A'):heartdisplay.substring(0, heartdisplay.length()-remainingheartdisplay.length()));
TwosideKeeper.log("Message 1 is "+message1, 5);
p.sendTitle(message1, finalMonsterName+" "+finalheartdisplay+" "+ChatColor.RESET+ChatColor.DARK_GRAY+"x"+(int)(pd2.target.getHealth()/20+1));
}}}
,1);

Loading…
Cancel
Save