Fixed Achievment Bugs. Modified Ghast behavior and firing rates.

This commit is contained in:
sigonasr2 2016-12-09 21:44:32 -06:00
parent 68cf1f8500
commit aa25cf1792
13 changed files with 615 additions and 136 deletions

Binary file not shown.

View File

@ -5,6 +5,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.bukkit.Achievement;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Difficulty;
@ -54,6 +55,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.PlayerMode;
import sig.plugin.TwosideKeeper.HelperStructures.WorldShop;
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils;
import sig.plugin.TwosideKeeper.Monster.HellfireSpider;
public class CustomDamage {
@ -621,6 +623,8 @@ public class CustomDamage {
}
},1);
AwardDamageAchievement(p,damage);
appendDebuffsToName(target);
}
if (target instanceof Monster) {
@ -650,6 +654,12 @@ public class CustomDamage {
return damage;
}
private static void AwardDamageAchievement(Player p, double dmg) {
if (p.hasAchievement(Achievement.ENCHANTMENTS) && dmg>18 && !p.hasAchievement(Achievement.OVERKILL)) {
p.awardAchievement(Achievement.OVERKILL);
}
}
private static void applyWitherSkeletonWither(Entity damager, Player p) {
Skeleton sk = (Skeleton)getDamagerEntity(damager);
if (sk.getSkeletonType()==SkeletonType.WITHER) {
@ -1090,6 +1100,7 @@ public class CustomDamage {
static void setMonsterTarget(Monster m, Player p) {
addChargeZombieToList(m);
addHellfireSpiderToList(m);
//addHellfireGhastToList(m);
addMonsterToTargetList(m,p);
}
@ -1101,9 +1112,17 @@ public class CustomDamage {
}
static void addHellfireSpiderToList(Monster m) {
if (!TwosideKeeper.hellfirespiders.containsKey(m.getUniqueId()) &&
if (!TwosideKeeper.custommonsters.containsKey(m.getUniqueId()) &&
MonsterController.isHellfireSpider(m)) {
TwosideKeeper.hellfirespiders.put(m.getUniqueId(),new HellfireSpider((Monster)m));
TwosideKeeper.custommonsters.put(m.getUniqueId(),new HellfireSpider((Monster)m));
TwosideKeeper.log("Added Hellfire Spider.", 2);
}
}
static void addHellfireGhastToList(Monster m) {
if (!TwosideKeeper.custommonsters.containsKey(m.getUniqueId()) &&
MonsterController.isHellfireGhast(m)) {
TwosideKeeper.custommonsters.put(m.getUniqueId(),new HellfireSpider((Monster)m));
TwosideKeeper.log("Added Hellfire Spider.", 2);
}
}
@ -2338,30 +2357,28 @@ public class CustomDamage {
static double calculateMonsterDifficultyMultiplier(LivingEntity damager) {
double mult = 1.0;
if (damager instanceof Monster) {
switch (MonsterController.getMonsterDifficulty((Monster)damager)) {
case NORMAL:
mult*=1.0;
break;
case DANGEROUS:
mult*=2.0;
break;
case DEADLY:
mult*=5.0;
break;
case HELLFIRE:
mult*=10.0;
break;
case ELITE:
mult*=40.0;
break;
case END:
mult*=24.0;
break;
default:
mult*=1.0;
break;
}
switch (MonsterController.getLivingEntityDifficulty(damager)) {
case NORMAL:
mult*=1.0;
break;
case DANGEROUS:
mult*=2.0;
break;
case DEADLY:
mult*=5.0;
break;
case HELLFIRE:
mult*=10.0;
break;
case ELITE:
mult*=40.0;
break;
case END:
mult*=24.0;
break;
default:
mult*=1.0;
break;
}
return mult;
}

View File

@ -0,0 +1,28 @@
package sig.plugin.TwosideKeeper;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster;
public class CustomMonster {
protected LivingEntity m;
public CustomMonster(LivingEntity m) {
super();
this.m=m;
}
public LivingEntity GetMonster() {
return m;
}
public boolean isAlive() {
return !m.isDead();
}
/*
public boolean hasTarget() {
return (m.getTarget()!=null)?true:false;
}*/
public void runTick() {
}
}

View File

@ -1,22 +0,0 @@
package sig.plugin.TwosideKeeper;
import org.bukkit.entity.Monster;
public class HellfireSpider {
Monster m;
public HellfireSpider(Monster m) {
this.m=m;
}
public Monster GetSpider() {
return m;
}
public boolean isAlive() {
return !m.isDead();
}
public boolean hasTarget() {
return (m.getTarget()!=null)?true:false;
}
}

View File

@ -0,0 +1,10 @@
package sig.plugin.TwosideKeeper.HelperStructures;
public enum LivingEntityDifficulty {
NORMAL,
DANGEROUS,
DEADLY,
HELLFIRE,
ELITE,
END;
}

View File

@ -18,6 +18,10 @@ import sig.plugin.TwosideKeeper.MonsterController;
import sig.plugin.TwosideKeeper.TwosideKeeper;
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
/**
* Use LivingEntityDifficulty instead.
*/
@Deprecated
public enum MonsterDifficulty {
NORMAL,

View File

@ -21,7 +21,7 @@ public class LivingEntityStructure {
public double original_movespd = 0.0d;
public HashMap<UUID,Long> hitlist = new HashMap<UUID,Long>();
public HashMap<Player,GlowAPI.Color> glowcolorlist = new HashMap<Player,GlowAPI.Color>();
public long lastSpiderBallThrow = 0;
//public long lastSpiderBallThrow = 0;
public BossMonster bm = null;
public LivingEntityStructure(LivingEntity m) {

View File

@ -0,0 +1,29 @@
package sig.plugin.TwosideKeeper.Monster;
import org.bukkit.Sound;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Snowball;
import org.bukkit.metadata.FixedMetadataValue;
import sig.plugin.TwosideKeeper.CustomMonster;
import sig.plugin.TwosideKeeper.TwosideKeeper;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils;
public class HellfireGhast extends CustomMonster{
long lastFireball = 0;
public HellfireGhast(LivingEntity m) {
super(m);
}
public long getLastFireball() {
return lastFireball;
}
public void runTick() {
}
}

View File

@ -0,0 +1,37 @@
package sig.plugin.TwosideKeeper.Monster;
import org.bukkit.Sound;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Snowball;
import org.bukkit.metadata.FixedMetadataValue;
import sig.plugin.TwosideKeeper.CustomMonster;
import sig.plugin.TwosideKeeper.TwosideKeeper;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils;
public class HellfireSpider extends CustomMonster{
long lastSpiderBallThrow = 0;
public HellfireSpider(Monster m) {
super(m);
}
public long getLastSpiderBallThrow() {
return lastSpiderBallThrow;
}
public void runTick() {
if (Math.random()<=0.24 && lastSpiderBallThrow+(20*4)<TwosideKeeper.getServerTickTime()) {
//Fire a sticky web.
Snowball sb = (Snowball)m.getLocation().getWorld().spawnEntity(m.getLocation().add(0,0.3,0), EntityType.SNOWBALL);
sb.setVelocity(m.getLocation().getDirection().multiply(1.3f));
sb.setMetadata("SPIDERBALL", new FixedMetadataValue(TwosideKeeper.plugin,true));
sb.setShooter(m);
SoundUtils.playGlobalSound(sb.getLocation(), Sound.ENTITY_SNOWBALL_THROW, 1.0f, 1.0f);
lastSpiderBallThrow = TwosideKeeper.getServerTickTime();
}
}
}

View File

@ -17,6 +17,7 @@ import org.bukkit.block.banner.PatternType;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Guardian;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.MagmaCube;
import org.bukkit.entity.Monster;
import org.bukkit.entity.PigZombie;
import org.bukkit.entity.Player;
@ -28,6 +29,7 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import sig.plugin.TwosideKeeper.HelperStructures.ItemRarity;
import sig.plugin.TwosideKeeper.HelperStructures.LivingEntityDifficulty;
import sig.plugin.TwosideKeeper.HelperStructures.Loot;
import sig.plugin.TwosideKeeper.HelperStructures.MonsterDifficulty;
import sig.plugin.TwosideKeeper.HelperStructures.MonsterType;
@ -63,90 +65,135 @@ public class MonsterController {
if (isZombieLeader(ent)) {
//Zombie leaders have faster movement.
ent.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,Integer.MAX_VALUE,1));
Monster m = (Monster)ent;
//Monster m = (Monster)ent;
LivingEntityStructure ms = TwosideKeeper.livingentitydata.get(ent.getUniqueId());
MonsterDifficulty md = getMonsterDifficulty(m);
LivingEntityDifficulty led = getLivingEntityDifficulty(ent);
ms.SetLeader(true);
convertMonster(m,md);
convertLivingEntity(ent,led);
//Set the HP of the leader to a more proper amount.
} else
if (meetsConditionsToBeElite(ent) && !minion) {
Monster m = (Monster)(ent);
MonsterDifficulty md = MonsterDifficulty.ELITE;
LivingEntityDifficulty md = LivingEntityDifficulty.ELITE;
TwosideKeeper.log(ChatColor.DARK_PURPLE+"Converting to Elite.", 2);
convertMonster(m,md);
convertLivingEntity(ent,md);
return true;
}
if (ent.getWorld().getName().equalsIgnoreCase("world_the_end")) {
Monster m = (Monster)ent;
convertMonster(m,MonsterDifficulty.END);
convertLivingEntity(ent,LivingEntityDifficulty.END);
return true;
} else
if (ylv>=128) {
//This is a 95% chance this will despawn.
if (Math.random()<=0.95 && !ent.getWorld().hasStorm() &&
ent.getWorld().getName().equalsIgnoreCase("world")) {
ent.remove();
return false;
} else {
if (isZombieLeader(ent)) {
Monster m = (Monster)ent;
convertMonster(m,MonsterDifficulty.NORMAL);
if (ent.getWorld().getName().equalsIgnoreCase("world")) {
if (ylv>=128) {
//This is a 95% chance this will despawn.
if (Math.random()<=0.95 && !ent.getWorld().hasStorm() &&
ent.getWorld().getName().equalsIgnoreCase("world")) {
ent.remove();
return false;
} else {
if (isZombieLeader(ent)) {
convertLivingEntity(ent,LivingEntityDifficulty.NORMAL);
}
return true;
}
} else
if (ylv>=64) {
//This is a 90% chance this will despawn.
if (Math.random()<=0.90 && !ent.getWorld().hasStorm() &&
ent.getWorld().getName().equalsIgnoreCase("world")) {
ent.remove();
return false;
} else {
if (isZombieLeader(ent)) {
convertLivingEntity(ent,LivingEntityDifficulty.NORMAL);
}
return true;
}
} else
if (ylv>=48) {
//"Normal" spawn rate. We're going to decrease it a bit for the time being.
//This is a 50% chance this will despawn.
if (Math.random()<=0.50 && !ent.getWorld().hasStorm()) {
ent.remove();
return false;
} else {
if (isZombieLeader(ent)) {
convertLivingEntity(ent,LivingEntityDifficulty.NORMAL);
}
return true;
}
} else
if (ylv>=32) {
//Change mobs in this range to 'Dangerous' versions. Zombies and skeletons also get armor.
LivingEntityDifficulty led = LivingEntityDifficulty.DANGEROUS;
convertLivingEntity(ent,led);
return true;
} else
if (ylv>=16) {
LivingEntityDifficulty led = LivingEntityDifficulty.DEADLY;
//Change mobs in this range to 'Dangerous' versions. Zombies and skeletons also get armor.
convertLivingEntity(ent,led);
return true;
} else
{
//Change mobs in this range to 'Dangerous' versions. Zombies and skeletons also get armor.
LivingEntityDifficulty led = LivingEntityDifficulty.HELLFIRE;
convertLivingEntity(ent,led);
return true;
}
} else
if (ylv>=64) {
//This is a 90% chance this will despawn.
if (Math.random()<=0.90 && !ent.getWorld().hasStorm() &&
ent.getWorld().getName().equalsIgnoreCase("world")) {
ent.remove();
return false;
} else {
if (ent.getWorld().getName().equalsIgnoreCase("world_nether")) {
//Difficulty is based on distance away from center.
modifyNetherMonsterHealth(ent);
final Location center = new Location(ent.getWorld(),0,64,0);
double chancer = ent.getLocation().distanceSquared(center);
if ((Math.random()*chancer)<1024) {
if (isZombieLeader(ent)) {
Monster m = (Monster)ent;
convertMonster(m,MonsterDifficulty.NORMAL);
convertLivingEntity(ent,LivingEntityDifficulty.NORMAL);
}
return true;
}
} else
if (ylv>=48) {
//"Normal" spawn rate. We're going to decrease it a bit for the time being.
//This is a 50% chance this will despawn.
if (Math.random()<=0.50 && !ent.getWorld().hasStorm()) {
ent.remove();
return false;
} else
if ((Math.random()*chancer)<65536) {
convertLivingEntity(ent,LivingEntityDifficulty.DANGEROUS);
return true;
} else
if ((Math.random()*chancer)<1048576) {
convertLivingEntity(ent,LivingEntityDifficulty.DEADLY);
return true;
} else {
if (isZombieLeader(ent)) {
Monster m = (Monster)ent;
convertMonster(m,MonsterDifficulty.NORMAL);
}
//Change mobs in this range to 'Dangerous' versions. Zombies and skeletons also get armor.
LivingEntityDifficulty led = LivingEntityDifficulty.HELLFIRE;
convertLivingEntity(ent,led);
return true;
}
} else
if (ylv>=32) {
//Change mobs in this range to 'Dangerous' versions. Zombies and skeletons also get armor.
Monster m = (Monster)(ent);
MonsterDifficulty md = MonsterDifficulty.DANGEROUS;
convertMonster(m,md);
return true;
} else
if (ylv>=16) {
MonsterDifficulty md = MonsterDifficulty.DEADLY;
//Change mobs in this range to 'Dangerous' versions. Zombies and skeletons also get armor.
Monster m = (Monster)(ent);
convertMonster(m,md);
return true;
} else
{
//Change mobs in this range to 'Dangerous' versions. Zombies and skeletons also get armor.
MonsterDifficulty md = MonsterDifficulty.HELLFIRE;
Monster m = (Monster)(ent);
convertMonster(m,md);
return true;
}
return true;
}
private static void modifyNetherMonsterHealth(LivingEntity ent) {
double hpincrease = 20;
switch (ent.getType()) {
case MAGMA_CUBE:{
MagmaCube cube = (MagmaCube)ent;
hpincrease+=cube.getSize();
}break;
case SKELETON:{
hpincrease+=20;
}break;
}
ent.setMaxHealth(ent.getMaxHealth()+hpincrease);
ent.setHealth(ent.getMaxHealth());
}
private static boolean meetsConditionsToSpawn(LivingEntity ent) {
double dist = 999999999;
int nearbyplayers=0;
@ -177,7 +224,7 @@ public class MonsterController {
return false;
}
private static void RandomizeEquipment(Monster m, int lv) {
private static void RandomizeEquipment(LivingEntity m, int lv) {
/*
* Lv1: Leather/Iron Armor.
* Lv2: Iron/Diamond Armor.
@ -650,7 +697,23 @@ public class MonsterController {
}
public static boolean isZombieLeader(LivingEntity ent) {
if ((ent instanceof Zombie) || (ent instanceof PigZombie)) {
if ((ent instanceof PigZombie)) {
MonsterDifficulty md = getMonsterDifficulty((Monster)ent);
if
(
(md==MonsterDifficulty.NORMAL && ent.getMaxHealth()>40) ||
(md==MonsterDifficulty.DANGEROUS && ent.getMaxHealth()>40*2) ||
(md==MonsterDifficulty.DEADLY && ent.getMaxHealth()>40*3) ||
(md==MonsterDifficulty.HELLFIRE && ent.getMaxHealth()>40*4) ||
(md==MonsterDifficulty.END && ent.getMaxHealth()>40*80)
)
{
return true;
} else {
return false;
}
} else
if ((ent instanceof Zombie)) {
MonsterDifficulty md = getMonsterDifficulty((Monster)ent);
if
(
@ -665,11 +728,55 @@ public class MonsterController {
} else {
return false;
}
} else {
} else
{
return false;
}
}
public static LivingEntity convertLivingEntity(LivingEntity m) {
if (m.getWorld().getName().equalsIgnoreCase("world_the_end")) {
convertLivingEntity(m,LivingEntityDifficulty.END);
}
if (m.getWorld().getName().equalsIgnoreCase("world")) {
if (m.getLocation().getY()<48) {
if (m.getLocation().getY()>=32)
return convertLivingEntity(m,LivingEntityDifficulty.DANGEROUS);
else if (m.getLocation().getY()>=16)
return convertLivingEntity(m,LivingEntityDifficulty.DEADLY);
else
return convertLivingEntity(m,LivingEntityDifficulty.HELLFIRE);
} else {
return convertLivingEntity(m,LivingEntityDifficulty.NORMAL);
}
}
if (m.getWorld().getName().equalsIgnoreCase("world_nether")) {
//Difficulty is based on distance away from center.
final Location center = new Location(m.getWorld(),0,64,0);
double chancer = m.getLocation().distanceSquared(center);
TwosideKeeper.log("Chance: "+chancer, 1);
if ((Math.random()*chancer)<1024) {
return convertLivingEntity(m,LivingEntityDifficulty.NORMAL);
} else
if ((Math.random()*chancer)<65536) {
return convertLivingEntity(m,LivingEntityDifficulty.DANGEROUS);
} else
if ((Math.random()*chancer)<1048576) {
return convertLivingEntity(m,LivingEntityDifficulty.DEADLY);
} else {
//Change mobs in this range to 'Dangerous' versions. Zombies and skeletons also get armor.
LivingEntityDifficulty led = LivingEntityDifficulty.HELLFIRE;
return convertLivingEntity(m,led);
}
}
return m;
}
/**
* Use convertLivingEntity() instead.
*/
@Deprecated
public static Monster convertMonster(Monster m) {
if (m.getWorld().getName().equalsIgnoreCase("world_the_end")) {
convertMonster(m,MonsterDifficulty.END);
@ -686,6 +793,32 @@ public class MonsterController {
}
}
public static LivingEntityDifficulty getLivingEntityDifficulty(LivingEntity m) {
if (m.getCustomName()!=null) {
if (m.getCustomName().contains("Dangerous")) {
return LivingEntityDifficulty.DANGEROUS;
} else
if (m.getCustomName().contains("Deadly")) {
return LivingEntityDifficulty.DEADLY;
} else
if (m.getCustomName().contains("Hellfire")) {
return LivingEntityDifficulty.HELLFIRE;
} else
if (m.getCustomName().contains("Elite")) {
return LivingEntityDifficulty.ELITE;
} else
if (m.getCustomName().contains("End ")) {
return LivingEntityDifficulty.END;
} else
{
return LivingEntityDifficulty.NORMAL;
}
} else {
return LivingEntityDifficulty.NORMAL;
}
}
@Deprecated
public static MonsterDifficulty getMonsterDifficulty(Monster m) {
if (m.getCustomName()!=null) {
if (m.getCustomName().contains("Dangerous")) {
@ -711,7 +844,7 @@ public class MonsterController {
}
}
public static void SetupCustomName(String prefix, Monster m) {
public static void SetupCustomName(String prefix, LivingEntity m) {
String MonsterName = m.getType().toString().toLowerCase();
if (m.getType()==EntityType.SKELETON) {
Skeleton ss = (Skeleton)m;
@ -728,6 +861,179 @@ public class MonsterController {
m.setCustomName(prefix.equalsIgnoreCase("")?"":(prefix+" ")+GenericFunctions.CapitalizeFirstLetters(MonsterName.replaceAll("_", " ")+(isZombieLeader(m)?" Leader":"")));
}
public static LivingEntity convertLivingEntity(LivingEntity m, LivingEntityDifficulty led) {
switch (led) {
case DANGEROUS: {
if (isAllowedToEquipItems(m)) {
m.getEquipment().clear();
RandomizeEquipment(m,1);
} else {
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,1));
}
SetupCustomName(ChatColor.DARK_AQUA+"Dangerous",m);
if(isZombieLeader(m))
{
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8));
//GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers());
m.setMaxHealth(800); //Target is 800 HP.
m.setHealth(m.getMaxHealth());
TwosideKeeper.log(m.getCustomName()+" health is "+m.getMaxHealth(), 5);
LivingEntityStructure ms = LivingEntityStructure.getLivingEntityStructure(m);
ms.SetLeader(true);
ms.UpdateGlow();
TwosideKeeper.log("->Setting an entity with Difficulty "+led.name()+" w/"+m.getHealth()+"/"+m.getMaxHealth()+" HP to a Leader.",5);
} else {
m.setMaxHealth(m.getMaxHealth()*2.0);
m.setHealth(m.getMaxHealth());
}
if (!GenericFunctions.isArmoredMob(m)) {
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,1));
}
m.getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(32.0);
}break;
case DEADLY: {
if (isAllowedToEquipItems(m)) {
m.getEquipment().clear();
RandomizeEquipment(m,2);
} else {
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,4));
}
SetupCustomName(ChatColor.GOLD+"Deadly",m);
if(isZombieLeader(m))
{
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8));
m.setMaxHealth(1200); //Target is 1200 HP.
m.setHealth(m.getMaxHealth());
LivingEntityStructure ms = LivingEntityStructure.getLivingEntityStructure(m);
ms.SetLeader(true);
ms.UpdateGlow();
TwosideKeeper.log("->Setting an entity with Difficulty "+led.name()+" w/"+m.getHealth()+"/"+m.getMaxHealth()+" HP to a Leader.",5);
} else {
m.setMaxHealth(m.getMaxHealth()*3.0);
m.setHealth(m.getMaxHealth());
}
if (!GenericFunctions.isArmoredMob(m)) {
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,3));
}
m.getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(48.0);
}break;
case HELLFIRE:{
//m.setCustomName(ChatColor.DARK_AQUA+"Dangerous Mob");
//m.setCustomNameVisible(true);
if (m.getType()!=EntityType.ENDERMAN) {
m.setFireTicks(Integer.MAX_VALUE);
}
if (isAllowedToEquipItems(m)) {
m.getEquipment().clear();
RandomizeEquipment(m,3);
} else {
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8));
}
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));}
SetupCustomName(ChatColor.DARK_RED+"Hellfire",m);
if(isZombieLeader(m))
{
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8));
LivingEntityStructure ms = LivingEntityStructure.getLivingEntityStructure(m);
ms.SetLeader(true);
ms.UpdateGlow();
m.setMaxHealth(1600); //Target is 1600 HP.
m.setHealth(m.getMaxHealth());
LivingEntityStructure.getLivingEntityStructure(m).SetLeader(true);
TwosideKeeper.log("->Setting an entity with Difficulty "+led.name()+" w/"+m.getHealth()+"/"+m.getMaxHealth()+" HP to a Leader.",5);
} else {
m.setMaxHealth(m.getMaxHealth()*4.0);
m.setHealth(m.getMaxHealth());
}
if (!GenericFunctions.isArmoredMob(m)) {
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,5));
}
m.getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(64.0);
}break;
case ELITE:{
SetupCustomName(ChatColor.DARK_PURPLE+"Elite",m);
//m.setCustomName(ChatColor.DARK_AQUA+"Dangerous Mob");
//m.setCustomNameVisible(true);
m.setMaxHealth(4800);
m.setHealth(m.getMaxHealth());
if (isAllowedToEquipItems(m)) {
m.getEquipment().clear();
RandomizeEquipment(m,4);
}
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);
}
m.setCustomNameVisible(true);
m.setRemoveWhenFarAway(false);
LivingEntityStructure ms = LivingEntityStructure.getLivingEntityStructure(m);
ms.SetElite(true);
ms.UpdateGlow();
m.getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(72.0);
}break;
default: {
if (isAllowedToEquipItems(m)) {
m.getEquipment().clear();
RandomizeEquipment(m,0);
} else {
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,0));
}
SetupCustomName("",m);
if(isZombieLeader(m))
{
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8));
m.setMaxHealth(400);
m.setHealth(m.getMaxHealth());
m.setCustomName("Zombie Leader");
LivingEntityStructure ms = LivingEntityStructure.getLivingEntityStructure(m);
ms.SetLeader(true);
ms.UpdateGlow();
TwosideKeeper.log("->Setting an entity with Difficulty "+led.name()+" w/"+m.getHealth()+"/"+m.getMaxHealth()+" HP to a Leader.",5);
} else {
m.setMaxHealth(m.getMaxHealth()*1.0);
m.setHealth(m.getMaxHealth());
}
m.getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(24.0);
}break;
case END:{
//m.setCustomName(ChatColor.DARK_AQUA+"Dangerous Mob");
//m.setCustomNameVisible(true);
if (m.getType()!=EntityType.ENDERMAN) {
m.setFireTicks(Integer.MAX_VALUE);
}
if (isAllowedToEquipItems(m)) {
m.getEquipment().clear();
RandomizeEquipment(m,0);
}
m.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,Integer.MAX_VALUE,1));
m.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,Integer.MAX_VALUE,3));
SetupCustomName(ChatColor.DARK_BLUE+""+ChatColor.MAGIC+"End",m);
if(isZombieLeader(m))
{
m.setMaxHealth(32000); //Target is 1600 HP.
m.setHealth(m.getMaxHealth());
LivingEntityStructure ms = LivingEntityStructure.getLivingEntityStructure(m);
ms.SetLeader(true);
ms.UpdateGlow();
TwosideKeeper.log("->Setting an entity with Difficulty "+led.name()+" w/"+m.getHealth()+"/"+m.getMaxHealth()+" HP to a Leader.",5);
} else {
m.setMaxHealth(m.getMaxHealth()*80.0);
m.setHealth(m.getMaxHealth());
}
m.getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(64.0);
}break;
}
removeZombieLeaderAttribute(m);
return m;
}
/**
* Use convertLivingEntity() instead.
*/
@Deprecated
public static Monster convertMonster(Monster m, MonsterDifficulty md) {
switch (md) {
case DANGEROUS: {
@ -897,7 +1203,7 @@ public class MonsterController {
return m;
}
private static void removeZombieLeaderAttribute(Monster m) {
private static void removeZombieLeaderAttribute(LivingEntity m) {
final AttributeInstance attribute = m.getAttribute(Attribute.GENERIC_MAX_HEALTH);
final Collection<AttributeModifier> modifiers = attribute.getModifiers();
for (AttributeModifier modifier : modifiers) {
@ -907,7 +1213,7 @@ public class MonsterController {
}
}
private static boolean isAllowedToEquipItems(Monster m) {
private static boolean isAllowedToEquipItems(LivingEntity m) {
if (m.getType()==EntityType.ZOMBIE ||
m.getType()==EntityType.PIG_ZOMBIE ||
m.getType()==EntityType.SKELETON ||
@ -918,6 +1224,14 @@ public class MonsterController {
}
}
public static LivingEntity spawnAdjustedLivingEntity(LivingEntity et, Location loc) {
return MonsterController.convertLivingEntity(et);
}
/**
* Use spawnAdjustedLivingEntity() instead.
*/
@Deprecated
public static Monster spawnAdjustedMonster(MonsterType mt,Location loc) {
Monster m = (Monster)loc.getWorld().spawnEntity(loc, mt.getEntityType());
if (mt.equals(MonsterType.WITHER_SKELETON)) {
@ -954,4 +1268,12 @@ public class MonsterController {
}
return false;
}
public static boolean isHellfireGhast(LivingEntity m) {
if (m.getType()==EntityType.GHAST &&
MonsterController.getLivingEntityDifficulty(m)==LivingEntityDifficulty.HELLFIRE) {
return true;
}
return false;
}
}

View File

@ -40,7 +40,7 @@ public class PartyManager {
private static boolean PlayersAreNearby(Player sourcep) {
for (Player checkp : Bukkit.getOnlinePlayers()) {
if (!sourcep.equals(checkp) && sourcep.getLocation().distanceSquared(checkp.getLocation())<=Math.pow(TwosideKeeper.PARTY_CHUNK_SIZE,2)) {
if (!sourcep.equals(checkp) && sourcep.getWorld().equals(checkp.getWorld()) && sourcep.getLocation().distanceSquared(checkp.getLocation())<=Math.pow(TwosideKeeper.PARTY_CHUNK_SIZE,2)) {
return true;
}
}

View File

@ -15,6 +15,7 @@ import java.util.Set;
import java.util.UUID;
import org.apache.commons.lang.WordUtils;
import org.bukkit.Achievement;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
@ -45,6 +46,8 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.ExperienceOrb;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.Ghast;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.entity.Skeleton.SkeletonType;
@ -173,6 +176,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.CustomPotion;
import sig.plugin.TwosideKeeper.HelperStructures.CustomRecipe;
import sig.plugin.TwosideKeeper.HelperStructures.ItemCube;
import sig.plugin.TwosideKeeper.HelperStructures.ItemSet;
import sig.plugin.TwosideKeeper.HelperStructures.LivingEntityDifficulty;
import sig.plugin.TwosideKeeper.HelperStructures.Loot;
import sig.plugin.TwosideKeeper.HelperStructures.MalleableBaseQuest;
import sig.plugin.TwosideKeeper.HelperStructures.MonsterDifficulty;
@ -201,6 +205,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.Utils.TimeUtils;
import sig.plugin.TwosideKeeper.Logging.BowModeLogger;
import sig.plugin.TwosideKeeper.Logging.LootLogger;
import sig.plugin.TwosideKeeper.Logging.MysteriousEssenceLogger;
import sig.plugin.TwosideKeeper.Monster.HellfireSpider;
public class TwosideKeeper extends JavaPlugin implements Listener {
@ -408,7 +413,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
public static int time_passed = 0; //The total amount of time lost due to modifications to FullTime().
public List<Integer> colors_used = new ArrayList<Integer>();
public static HashMap<UUID,ChargeZombie> chargezombies = new HashMap<UUID,ChargeZombie>();
public static HashMap<UUID,HellfireSpider> hellfirespiders = new HashMap<UUID,HellfireSpider>();
public static HashMap<UUID,CustomMonster> custommonsters = new HashMap<UUID,CustomMonster>();
public static List<EliteMonster> elitemonsters = new ArrayList<EliteMonster>();
public static RecyclingCenter TwosideRecyclingCenter;
@ -615,22 +620,12 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ChargeZombie.BreakBlocksAroundArea(cz.m,1);
}
}
for (HellfireSpider hs : hellfirespiders.values()) {
if (hs.m==null || !hs.m.isValid() || !hs.isAlive() || !hs.hasTarget() || hs.m.getLocation().getY()>32) {
for (CustomMonster cs : custommonsters.values()) {
if (cs.m==null || !cs.m.isValid() || !cs.isAlive() || cs.m.getLocation().getY()>32) {
//This has to be removed...
ScheduleRemoval(hellfirespiders,hs.m.getUniqueId());
ScheduleRemoval(custommonsters,cs.m.getUniqueId());
} else {
Monster m = hs.GetSpider();
LivingEntityStructure les = LivingEntityStructure.getLivingEntityStructure(m);
if (Math.random()<=0.24 && les.lastSpiderBallThrow+(20*4)<getServerTickTime()) {
//Fire a sticky web.
Snowball sb = (Snowball)m.getLocation().getWorld().spawnEntity(m.getLocation().add(0,0.3,0), EntityType.SNOWBALL);
sb.setVelocity(m.getLocation().getDirection().multiply(1.3f));
sb.setMetadata("SPIDERBALL", new FixedMetadataValue(TwosideKeeper.plugin,true));
sb.setShooter(m);
SoundUtils.playGlobalSound(sb.getLocation(), Sound.ENTITY_SNOWBALL_THROW, 1.0f, 1.0f);
les.lastSpiderBallThrow = getServerTickTime();
}
cs.runTick();
}
}
//Control elite monsters.
@ -1548,6 +1543,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
//Make sure to save the config for this player.
pd.saveConfig();
playerdata.remove(ev.getPlayer().getUniqueId());
Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), "scoreboard players reset "+ev.getPlayer().getName().toLowerCase());
log("[TASK] Player Data for "+ev.getPlayer().getName()+" has been removed. Size of array: "+playerdata.size(),4);
}
@ -4314,8 +4310,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ev.getSpawnReason().equals(SpawnReason.SPAWNER_EGG) ||
ev.getSpawnReason().equals(SpawnReason.REINFORCEMENTS) ||
ev.getSpawnReason().equals(SpawnReason.VILLAGE_INVASION) ||
ev.getSpawnReason().equals(SpawnReason.CHUNK_GEN)) &&
ev.getEntity() instanceof Monster) {
ev.getSpawnReason().equals(SpawnReason.CHUNK_GEN) ||
ev.getSpawnReason().equals(SpawnReason.SLIME_SPLIT))) {
if (ev.getSpawnReason().equals(SpawnReason.REINFORCEMENTS) || ev.getSpawnReason().equals(SpawnReason.VILLAGE_INVASION)) {
//Remove this one and spawn another one.
Location loc = ev.getEntity().getLocation().clone();
@ -4962,6 +4958,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
log("Killed by a player.",5);
killedByPlayer = true;
Player p = (Player)ms.GetTarget();
AwardDeathAchievements(p,ev.getEntity());
if (p!=null) {
if (GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand()) &&
GenericFunctions.isArtifactWeapon(p.getEquipment().getItemInMainHand()) &&
@ -5316,11 +5313,19 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
livingentitydata.remove(m.getUniqueId());
chargezombies.remove(m.getUniqueId());
hellfirespiders.remove(m.getUniqueId());
custommonsters.remove(m.getUniqueId());
}
}
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
private void AwardDeathAchievements(Player p, LivingEntity entity) {
if (p.hasAchievement(Achievement.BUILD_SWORD) && (entity instanceof Monster) && !p.hasAchievement(Achievement.KILL_ENEMY)) {
p.awardAchievement(Achievement.KILL_ENEMY);
}
if (p.hasAchievement(Achievement.KILL_ENEMY) && (entity instanceof Skeleton)&& !p.hasAchievement(Achievement.SNIPE_SKELETON) && p.getEquipment().getItemInMainHand().getType()==Material.BOW && entity.getWorld().equals(p.getWorld()) && entity.getLocation().distanceSquared(p.getLocation())>=2500) {
p.awardAchievement(Achievement.SNIPE_SKELETON);
}
}
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
public void updateHealthbarRespawnEvent(PlayerRespawnEvent ev) {
final Player p = ev.getPlayer();
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
@ -5703,6 +5708,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ev.setCancelled(true);
}
}*/
HandlePickupAchievements(ev.getPlayer(), ev.getItem().getItemStack());
boolean handled = AutoEquipItem(ev.getItem().getItemStack(), p);
if (handled) {
ev.getItem().remove();
@ -5761,12 +5769,21 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}
}
ev.setCancelled(true);
ev.setCancelled(true);
ev.getItem().remove();
GenericFunctions.giveItem(p, ev.getItem().getItemStack());
return;
}
private void HandlePickupAchievements(Player p, ItemStack item) {
if (p.hasAchievement(Achievement.ACQUIRE_IRON) && item.getType()==Material.DIAMOND && !p.hasAchievement(Achievement.GET_DIAMONDS)) {
p.awardAchievement(Achievement.GET_DIAMONDS);
} else
if (p.hasAchievement(Achievement.NETHER_PORTAL) && item.getType()==Material.BLAZE_ROD && !p.hasAchievement(Achievement.GET_BLAZE_ROD)) {
p.awardAchievement(Achievement.GET_BLAZE_ROD);
}
}
private boolean AutoConsumeItem(Player p, ItemStack item) {
if (PlayerMode.getPlayerMode(p)==PlayerMode.BARBARIAN) {
if (GenericFunctions.isAutoConsumeFood(item)) {
@ -6128,6 +6145,14 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (ev.getEntity() instanceof Projectile) {
Projectile arr = (Projectile)ev.getEntity();
//Arrow newarrow = arr.getLocation().getWorld().spawnArrow(arr.getLocation(), arr.getVelocity(), 1, 12);
if (arr instanceof Fireball && (arr.getShooter() instanceof Ghast)) {
Ghast g = (Ghast)arr.getShooter();
Fireball fb = (Fireball)arr;
if (MonsterController.getLivingEntityDifficulty(g)==LivingEntityDifficulty.HELLFIRE) {
//We will fire additional fireballs, directly after it.
}
fb.setVelocity(fb.getDirection().multiply(20f));
}
if (arr.getCustomName()==null && (arr instanceof Arrow)) {
if (arr.getType()==EntityType.TIPPED_ARROW) {

View File

@ -15,6 +15,7 @@ import org.bukkit.inventory.ItemStack;
import sig.plugin.TwosideKeeper.HelperStructures.ArtifactAbility;
import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItem;
import sig.plugin.TwosideKeeper.HelperStructures.ItemSet;
import sig.plugin.TwosideKeeper.HelperStructures.LivingEntityDifficulty;
import sig.plugin.TwosideKeeper.HelperStructures.Loot;
import sig.plugin.TwosideKeeper.HelperStructures.MonsterDifficulty;
import sig.plugin.TwosideKeeper.HelperStructures.MonsterType;
@ -54,18 +55,46 @@ public final class TwosideKeeperAPI {
}
//MONSTER COMMANDS.
/**
* Use spawnAdjustedLivingEntity() instead.
*/
@Deprecated
public static Monster spawnAdjustedMonster(MonsterType mt,Location loc) {
return MonsterController.spawnAdjustedMonster(mt,loc);
}
/**
* Use autoAdjustLivingEntity() instead.
*/
@Deprecated
public static Monster autoAdjustMonster(Monster m) {
return MonsterController.convertMonster(m);
}
/**
* Use adjustLivingEntityDifficulty() instead.
*/
@Deprecated
public static Monster adjustMonsterDifficulty(Monster m, MonsterDifficulty newdiff) {
return MonsterController.convertMonster(m,newdiff);
}
/**
* Use getLivingEntityDifficulty() instead.
*/
@Deprecated
public static MonsterDifficulty getMonsterDifficulty(Monster m) {
return MonsterController.getMonsterDifficulty(m);
}
public static LivingEntity spawnAdjustedLivingEntity(LivingEntity ent,Location loc) {
return MonsterController.spawnAdjustedLivingEntity(ent,loc);
}
public static LivingEntity autoAdjustLivingEntity(LivingEntity m) {
return MonsterController.convertLivingEntity(m);
}
public static LivingEntity adjustLivingEntityDifficulty(LivingEntity m, LivingEntityDifficulty newdiff) {
return MonsterController.convertLivingEntity(m,newdiff);
}
public static LivingEntityDifficulty getLivingEntityDifficulty(LivingEntity m) {
return MonsterController.getLivingEntityDifficulty(m);
}
//Artifact Commands.
public static boolean isArtifactItem(ItemStack item) {