diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index 1029b65..155ea3a 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/plugin.yml b/src/plugin.yml index 0091e9f..5033910 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: TwosideKeeper main: sig.plugin.TwosideKeeper.TwosideKeeper -version: 3.10.5 +version: 3.10.6 loadbefore: [aPlugin] commands: money: diff --git a/src/sig/plugin/TwosideKeeper/ChargeZombie.java b/src/sig/plugin/TwosideKeeper/ChargeZombie.java index 2b22667..501038d 100644 --- a/src/sig/plugin/TwosideKeeper/ChargeZombie.java +++ b/src/sig/plugin/TwosideKeeper/ChargeZombie.java @@ -10,6 +10,8 @@ import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils; public class ChargeZombie { Monster m; + long stuckTimer=0; + Location lastLoc = null; public ChargeZombie(Monster m) { this.m=m; diff --git a/src/sig/plugin/TwosideKeeper/CustomDamage.java b/src/sig/plugin/TwosideKeeper/CustomDamage.java index ce66c55..09f2818 100644 --- a/src/sig/plugin/TwosideKeeper/CustomDamage.java +++ b/src/sig/plugin/TwosideKeeper/CustomDamage.java @@ -4,6 +4,7 @@ import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.UUID; import org.bukkit.Achievement; import org.bukkit.Bukkit; @@ -538,11 +539,14 @@ public class CustomDamage { if ((shooter instanceof Player) && target!=null) { Player p = (Player)shooter; PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); - if (damager instanceof TippedArrow) { - TippedArrow a = (TippedArrow)damager; + //TwosideKeeper.log("Exploding Arrow 2. Damager is "+GenericFunctions.GetEntityDisplayName(damager), 0); + if (damager instanceof Arrow || damager instanceof TippedArrow) { + Arrow a = (Arrow)damager; + //TwosideKeeper.log("Exploding Arrow 1", 0); if (a.hasMetadata("EXPLODE_ARR")) { //Create an explosion. TwosideKeeper.log("In here", 5); + //TwosideKeeper.log("Exploding Arrow", 0); Location hitloc = aPlugin.API.getArrowHitLocation(target, a); GenericFunctions.DealExplosionDamageToEntities(hitloc, getBaseWeaponDamage(weapon,damager,target)+60, 6); SoundUtils.playGlobalSound(hitloc, Sound.ENTITY_ENDERDRAGON_FIREBALL_EXPLODE, 0.5f, 1.0f); @@ -1205,6 +1209,15 @@ public class CustomDamage { } } } + if (target instanceof Wither) { + Wither w = (Wither)target; + for (UUID id : TwosideKeeper.custommonsters.keySet()) { + if (id.equals(w.getUniqueId())) { + sig.plugin.TwosideKeeper.Monster.Wither wi = (sig.plugin.TwosideKeeper.Monster.Wither)TwosideKeeper.custommonsters.get(id); + wi.runHitEvent(p, dmg); + } + } + } } private static void addHealthFromLifesteal(Player p, double damage, ItemStack weapon, String reason) { @@ -1809,6 +1822,7 @@ public class CustomDamage { double darknessdiv = 0; double playermodediv = 0; double witherdiv = 0; + double artifactmult = 0; if (target instanceof LivingEntity) { ItemStack[] armor = GenericFunctions.getArmor(target); @@ -1873,6 +1887,7 @@ public class CustomDamage { double dmgval=-1; if (dmgval!=-1) { dmgreduction += dmgval; + artifactmult += 0.08; } } else { switch (armor[i].getType()) { @@ -2008,6 +2023,7 @@ public class CustomDamage { *(1d-tacticspct) *(1d-playermodediv) *(1d-witherdiv) + *(1d-artifactmult) *setbonus *((target instanceof Player && ((Player)target).isBlocking())?(PlayerMode.isDefender((Player)target))?0.30:0.50:1) *((target instanceof Player)?((PlayerMode.isDefender((Player)target))?0.9:(target.getEquipment().getItemInOffHand()!=null && target.getEquipment().getItemInOffHand().getType()==Material.SHIELD)?0.95:1):1); diff --git a/src/sig/plugin/TwosideKeeper/Drops/DropRandomFirework.java b/src/sig/plugin/TwosideKeeper/Drops/DropRandomFirework.java new file mode 100644 index 0000000..2269c16 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/Drops/DropRandomFirework.java @@ -0,0 +1,20 @@ +package sig.plugin.TwosideKeeper.Drops; + +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +import aPlugin.Drop; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemUtils; + +public class DropRandomFirework extends Drop { + + public DropRandomFirework(int min, int max, int weight) { + super(min,max,weight,"Holiday Firework"); + } + + @Override + public ItemStack getItemStack() { + return ItemUtils.createRandomFirework(); + } + +} diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java b/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java index 67bd7c1..c1595d4 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java @@ -32,7 +32,7 @@ public enum ArtifactAbility { new double[]{1.0,0.975,0.95,0.925,0.9,0.875,0.85,0.8,0.75,0.7,0.65,0.6,0.55,0.5,0.4},100,1,UpgradePath.BASIC), EXECUTION("Execute","Deals [VAL] extra damage for every 20% of target's missing health.",new double[]{0.3,0.45,0.6,0.75,0.9,1.05,1.2,1.35,1.50,1.65,1.80,1.95,2.10,2.40,2.70}, new double[]{1.0,0.975,0.95,0.925,0.9,0.875,0.85,0.8,0.75,0.7,0.65,0.6,0.55,0.5,0.4},100,1,UpgradePath.BASIC), - LIFESTEAL("Lifesteal","Heals [VAL]% of the damage dealt to targets back to your health pool.",new double[]{0.8,1.2,1.6,2.0,2.4,2.8,3.2,3.6,4.0,4.4,4.8,5.6,6.4,7.2,8.0,8.8}, + LIFESTEAL("Lifesteal","Heals [VAL]% of the damage dealt to targets back to your health pool.",new double[]{0.2,0.3,0.6,0.7,0.8,0.9,1.1,1.3,1.4,1.5,1.6,1.8,2.1,2.6,2.8,3.5}, new double[]{1.0,1.0,0.9,0.9,0.8,0.8,0.75,0.75,0.7,0.7,0.6,0.6,0.5,0.5,0.4},100,1,UpgradePath.WEAPON), CRITICAL("Critical","[VAL]% chance to deal critical strikes.",new double[]{1.0,1.25,1.5,1.75,2.0,2.25,2.50,2.75,3.0,3.25,3.50,3.75,4.00,4.25,4.50}, new double[]{1.0,0.975,0.95,0.925,0.9,0.875,0.85,0.825,0.8,0.75,0.7,0.65,0.6,0.55,0.5},100,1,UpgradePath.WEAPON), diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java index 956bcfa..669c64a 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java @@ -3689,7 +3689,7 @@ public class GenericFunctions { return pct; } - public static void setGlowing(Monster m, Color color) { + public static void setGlowing(LivingEntity m, Color color) { /* for (Player p : Bukkit.getOnlinePlayers()) { GlowAPI.setGlowing(m, false, p); @@ -3792,6 +3792,17 @@ public class GenericFunctions { return monsterlist; } + public static List getNearbyMonsters(Location l, int range) { + Collection ents = l.getWorld().getNearbyEntities(l, range, range, range); + List monsterlist = new ArrayList(); + for (Entity e : ents) { + if ((e instanceof LivingEntity) && !(e instanceof Player)) { + monsterlist.add((LivingEntity)e); + } + } + return monsterlist; + } + public static List getNearbyPlayers(Location l, int range) { List players = new ArrayList(); Collection nearbyentities = l.getWorld().getNearbyEntities(l, range, range, range); @@ -3837,7 +3848,7 @@ public class GenericFunctions { } public static void generateNewElite(Player p, String name) { - Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new EliteMonsterLocationFinder(p,name), 20l); + Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new EliteMonsterLocationFinder(p,name), 2l); } public static boolean isHunterCompass(ItemStack item) { @@ -4328,7 +4339,33 @@ public class GenericFunctions { public static void PerformAssassinate(Player player, Material name) { //Try to find a target to look at. //LivingEntity target = aPlugin.API.rayTraceTargetEntity(player, 100); - LivingEntity target = aPlugin.API.getTargetEntity(player, 100); + Location originalloc = player.getLocation().clone(); + if (aPlugin.API.performAssassinate(player)) { + SoundUtils.playGlobalSound(player.getLocation(), Sound.BLOCK_NOTE_SNARE, 1.0f, 1.0f); + PlayerStructure pd = PlayerStructure.GetPlayerStructure(player); + LivingEntity target = aPlugin.API.getTargetEntity(player, 100); + if (name!=Material.SKULL_ITEM || pd.lastlifesavertime+GetModifiedCooldown(TwosideKeeper.LIFESAVER_COOLDOWN,player) items = WorldShop.pricelist.keySet(); + int rand = r.nextInt(5); //20-60% + double pctoff = 0.2+(rand*0.1); + return pctoff; + } + public static ItemStack generateItemDealOftheDay(int iter) { Calendar cal = Calendar.getInstance(); int seed = cal.get(Calendar.YEAR)*cal.get(Calendar.DAY_OF_YEAR)*iter; diff --git a/src/sig/plugin/TwosideKeeper/HolidayEvents/Christmas.java b/src/sig/plugin/TwosideKeeper/HolidayEvents/Christmas.java index c63c281..1d1c67a 100644 --- a/src/sig/plugin/TwosideKeeper/HolidayEvents/Christmas.java +++ b/src/sig/plugin/TwosideKeeper/HolidayEvents/Christmas.java @@ -41,6 +41,7 @@ import sig.plugin.TwosideKeeper.CustomDamage; import sig.plugin.TwosideKeeper.PlayerStructure; import sig.plugin.TwosideKeeper.TwosideKeeper; import sig.plugin.TwosideKeeper.aPluginAPIWrapper; +import sig.plugin.TwosideKeeper.Drops.DropRandomFirework; import sig.plugin.TwosideKeeper.Drops.SigDrop; import sig.plugin.TwosideKeeper.HelperStructures.ItemSet; import sig.plugin.TwosideKeeper.HelperStructures.LivingEntityDifficulty; @@ -534,7 +535,7 @@ public class Christmas { c.addDrop(new DropMaterial(Material.LAPIS_BLOCK,1,4,5)); c.addDrop(new DropMaterial(Material.DIAMOND_BLOCK,1,4,5)); c.addDrop(new DropMaterial(Material.EMERALD_BLOCK,1,4,5)); - c.addDrop(new DropMaterial(Material.FIREWORK,32,64,30)); + c.addDrop(new DropRandomFirework(32,64,30)); c.addDrop(new DropMaterial(Material.NETHER_STAR,1)); c.addDrop(new DropItem(getCookieItem(),1,3,20)); c.addDrop(new DropItem(getSmallCandyItem(),1,3,5)); diff --git a/src/sig/plugin/TwosideKeeper/Monster/Wither.java b/src/sig/plugin/TwosideKeeper/Monster/Wither.java index cc4d076..88e524b 100644 --- a/src/sig/plugin/TwosideKeeper/Monster/Wither.java +++ b/src/sig/plugin/TwosideKeeper/Monster/Wither.java @@ -1,9 +1,15 @@ package sig.plugin.TwosideKeeper.Monster; +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.Location; import org.bukkit.Sound; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Monster; @@ -12,6 +18,7 @@ import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton.SkeletonType; import sig.plugin.TwosideKeeper.ChargeZombie; +import sig.plugin.TwosideKeeper.CustomDamage; import sig.plugin.TwosideKeeper.CustomMonster; import sig.plugin.TwosideKeeper.MonsterController; import sig.plugin.TwosideKeeper.TwosideKeeper; @@ -24,6 +31,8 @@ public class Wither extends CustomMonster{ private long lastWitherSkeletonSpawned=0; private long stuckTimer=0; private Location lastLoc = null; + private List activeplayers = new ArrayList(); + private HashMap dmgbreakdown = new HashMap(); public Wither(LivingEntity m) { super(m); @@ -38,8 +47,29 @@ public class Wither extends CustomMonster{ this.lastSkullShot = TwosideKeeper.getServerTickTime(); } + public void runHitEvent(Entity damager, double damage) { //Runs when this monster gets hit. + LivingEntity shooter = CustomDamage.getDamagerEntity(damager); + if (shooter instanceof Player) { + Player p = (Player)shooter; + if (dmgbreakdown.containsKey(p.getName())) { + dmgbreakdown.put(p.getName(), dmgbreakdown.get(p.getName())+damage); + } else { + dmgbreakdown.put(p.getName(), damage); + } + if (!activeplayers.contains(p)) { + activeplayers.add(p); + } + } + } + public void runTick() { if (m instanceof Monster) { + RemoveInactivePlayers(); + + if (activeplayers.size()==0 && dmgbreakdown.size()>0) { + DisplayFailedDPSReport(); + } + if (((Monster) m).getTarget()!=null) { ChargeZombie.BreakBlocksAroundArea((Monster)m, 2); } @@ -57,7 +87,7 @@ public class Wither extends CustomMonster{ SoundUtils.playGlobalSound(m.getLocation(), Sound.ENTITY_ENDERMEN_TELEPORT, 1.0f, 1.0f); m.teleport(m.getLocation().add(Math.random()*10-5,0,0)); } else - if (numb<=0.33) { + if (numb<=0.5) { SoundUtils.playGlobalSound(m.getLocation(), Sound.ENTITY_ENDERMEN_TELEPORT, 1.0f, 1.0f); m.teleport(m.getLocation().add(0,0,Math.random()*10-5)); } else @@ -70,8 +100,13 @@ public class Wither extends CustomMonster{ if (m.getHealth()=128) { - m.teleport(m.getLocation().add(0,-32,0)); + if (m.getWorld().getName().equalsIgnoreCase("world_nether") && m.getLocation().getY()>=128) { + m.teleport(m.getLocation().add(0,-4,0)); + } else + if (m.getWorld().getName().equalsIgnoreCase("world") && m.getLocation().getY()>=164) { + Location newloc = m.getLocation().clone(); + newloc.setY(164); + m.teleport(newloc); } if (m.getHealth()<86000 && lastWitherSkeletonSpawned+40 sorted_dmg = new ArrayList(); + List sorted_pl = new ArrayList(); + double totaldmg = 0; + for (String pl : dmgbreakdown.keySet()) { + double dmg = dmgbreakdown.get(pl); + int slot = 0; + totaldmg+=dmg; + for (int i=0;isorted_dmg.get(i)) { + break; + } else { + slot++; + } + } + sorted_pl.add(slot,pl); + sorted_dmg.add(slot,dmg); + } + StringBuilder finalstr = new StringBuilder(); + DecimalFormat df = new DecimalFormat("0.00"); + for (int i=0;i=128) { les.m.teleport(les.m.getLocation().add(0,-32,0)); diff --git a/src/sig/plugin/TwosideKeeper/PlayerStructure.java b/src/sig/plugin/TwosideKeeper/PlayerStructure.java index 80d055f..dbf6672 100644 --- a/src/sig/plugin/TwosideKeeper/PlayerStructure.java +++ b/src/sig/plugin/TwosideKeeper/PlayerStructure.java @@ -25,6 +25,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.BowMode; import sig.plugin.TwosideKeeper.HelperStructures.DeathStructure; import sig.plugin.TwosideKeeper.HelperStructures.PlayerMode; import sig.plugin.TwosideKeeper.HelperStructures.ServerType; +import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; import sig.plugin.TwosideKeeper.Logging.DamageLogger; //import com.google.common.graph.*; @@ -242,7 +243,6 @@ public class PlayerStructure { this.isPlayingSpleef=false; this.iframetime=TwosideKeeper.getServerTickTime(); //Set defaults first, in case this is a new user. - setDefaultCooldowns(p); loadConfig(); p.getInventory().addItem(new ItemStack(Material.PORTAL)); @@ -282,17 +282,20 @@ public class PlayerStructure { //Joined always gets set to new time. this.joined = serverTickTime; + setDefaultCooldowns(p); } } private void setDefaultCooldowns(Player p) { - aPlugin.API.sendCooldownPacket(p, Material.BOW, TwosideKeeper.DODGE_COOLDOWN); - applyCooldownToAllTypes(p,"HOE",TwosideKeeper.DEATHMARK_COOLDOWN); - applyCooldownToAllTypes(p,"SPADE",TwosideKeeper.EARTHWAVE_COOLDOWN); - applyCooldownToAllTypes(p,"SWORD",TwosideKeeper.LINEDRIVE_COOLDOWN); - aPlugin.API.sendCooldownPacket(p, Material.SHIELD, TwosideKeeper.REJUVENATE_COOLDOWN); - aPlugin.API.sendCooldownPacket(p, Material.SKULL_ITEM, TwosideKeeper.LIFESAVER_COOLDOWN); - aPlugin.API.sendCooldownPacket(p, Material.WATCH, TwosideKeeper.ICEWAND_COOLDOWN); + aPlugin.API.sendCooldownPacket(p, Material.BOW, GenericFunctions.GetRemainingCooldownTime(p, last_dodge, TwosideKeeper.DODGE_COOLDOWN)); + applyCooldownToAllTypes(p,"HOE",GenericFunctions.GetRemainingCooldownTime(p, last_deathmark, TwosideKeeper.DEATHMARK_COOLDOWN)); + applyCooldownToAllTypes(p,"SPADE",GenericFunctions.GetRemainingCooldownTime(p, lastusedearthwave, TwosideKeeper.EARTHWAVE_COOLDOWN)); + applyCooldownToAllTypes(p,"SWORD",GenericFunctions.GetRemainingCooldownTime(p, last_strikerspell, TwosideKeeper.LINEDRIVE_COOLDOWN)); + aPlugin.API.sendCooldownPacket(p, Material.SHIELD, GenericFunctions.GetRemainingCooldownTime(p, last_rejuvenate, TwosideKeeper.REJUVENATE_COOLDOWN)); + aPlugin.API.sendCooldownPacket(p, Material.SKULL_ITEM, GenericFunctions.GetRemainingCooldownTime(p, lastlifesavertime, TwosideKeeper.LIFESAVER_COOLDOWN)); + aPlugin.API.sendCooldownPacket(p, Material.WATCH, GenericFunctions.GetRemainingCooldownTime(p, icewandused, TwosideKeeper.ICEWAND_COOLDOWN)); + aPlugin.API.sendCooldownPacket(p, Material.RAW_FISH, GenericFunctions.GetRemainingCooldownTime(p, lastcandyconsumed, 40)); + aPlugin.API.sendCooldownPacket(p, Material.GOLDEN_APPLE, GenericFunctions.GetRemainingCooldownTime(p, lastrevivecandyconsumed, 200)); } private void applyCooldownToAllTypes(Player p, String item, int cooldown) { @@ -306,7 +309,7 @@ public class PlayerStructure { //Save the configuration. public void saveConfig() { File config; - config = new File(TwosideKeeper.filesave,"users/"+name+".data"); + config = new File(TwosideKeeper.filesave,"users/"+Bukkit.getPlayer(name).getUniqueId()+".data"); FileConfiguration workable = YamlConfiguration.loadConfiguration(config); workable.set("name", name); @@ -351,6 +354,25 @@ public class PlayerStructure { workable.set("deathloc_y", deathloc_y); workable.set("deathloc_z", deathloc_z); workable.set("deathloc_world", deathloc_world); + workable.set("COOLDOWN_deathmark", last_deathmark); + workable.set("COOLDOWN_shovelspell", last_shovelspell); + workable.set("COOLDOWN_strikerspell", last_strikerspell); + workable.set("COOLDOWN_usedearthwave", lastusedearthwave); + workable.set("COOLDOWN_arrowbarrage", last_arrowbarrage); + workable.set("COOLDOWN_laughtime", last_laugh_time); + workable.set("COOLDOWN_rejuvenate", last_rejuvenate); + workable.set("COOLDOWN_swordhit", last_swordhit); + workable.set("COOLDOWN_strikerspell", last_strikerspell); + workable.set("COOLDOWN_absorptionhealthgiven", lastabsorptionhealthgiven); + workable.set("COOLDOWN_ignoretargetarmor", ignoretargetarmor); + workable.set("COOLDOWN_lastrevivecandyconsumed", lastrevivecandyconsumed); + workable.set("COOLDOWN_lastcandyconsumed", lastcandyconsumed); + workable.set("COOLDOWN_icewandused", icewandused); + workable.set("COOLDOWN_lastdodge", last_dodge); + workable.set("COOLDOWN_lastsiphon", last_siphon); + workable.set("COOLDOWN_lastmock", last_mock); + workable.set("COOLDOWN_lastassassinatetime", lastassassinatetime); + workable.set("COOLDOWN_lastlifesavertime", lastlifesavertime); try { workable.save(config); @@ -361,8 +383,14 @@ public class PlayerStructure { //Create a config for the player. public void loadConfig(){ - File config; - config = new File(TwosideKeeper.filesave,"users/"+name+".data"); + Player p = Bukkit.getPlayer(name); + File config,testconfig; + testconfig = new File(TwosideKeeper.filesave,"users/"+name+".data"); + config = new File(TwosideKeeper.filesave,"users/"+p.getUniqueId()+".data"); + if (testconfig.exists()) { + TwosideKeeper.log("Renaming old config for player "+ChatColor.YELLOW+name+ChatColor.RESET+" to UUID "+ChatColor.YELLOW+p.getUniqueId(), 1); + testconfig.renameTo(config); + } FileConfiguration workable = YamlConfiguration.loadConfiguration(config); //Add all our default settings here. @@ -382,6 +410,7 @@ public class PlayerStructure { workable.addDefault("weaponcharges", weaponcharges); workable.addDefault("lifestealstacks", lifestealstacks); workable.addDefault("vendetta_amt", vendetta_amt); + workable.addDefault("lastvendettastack", lastvendettastack); workable.addDefault("weatherwatch", weatherwatch); workable.addDefault("weatherwatch_user", weatherwatch_user); workable.addDefault("holidaychest1", holidaychest1); @@ -390,12 +419,31 @@ public class PlayerStructure { workable.addDefault("holidaychest4", holidaychest4); workable.addDefault("lastsantabox2", lastsantabox2); workable.addDefault("playermode_on_death", playermode_on_death.name()); + workable.addDefault("COOLDOWN_deathmark", last_deathmark); + workable.addDefault("COOLDOWN_shovelspell", last_shovelspell); + workable.addDefault("COOLDOWN_strikerspell", last_strikerspell); + workable.addDefault("COOLDOWN_usedearthwave", lastusedearthwave); + workable.addDefault("COOLDOWN_arrowbarrage", last_arrowbarrage); + workable.addDefault("COOLDOWN_laughtime", last_laugh_time); + workable.addDefault("COOLDOWN_rejuvenate", last_rejuvenate); + workable.addDefault("COOLDOWN_swordhit", last_swordhit); + workable.addDefault("COOLDOWN_strikerspell", last_strikerspell); + workable.addDefault("COOLDOWN_absorptionhealthgiven", lastabsorptionhealthgiven); + workable.addDefault("COOLDOWN_ignoretargetarmor", ignoretargetarmor); + workable.addDefault("COOLDOWN_lastrevivecandyconsumed", lastrevivecandyconsumed); + workable.addDefault("COOLDOWN_lastcandyconsumed", lastcandyconsumed); + workable.addDefault("COOLDOWN_icewandused", icewandused); + workable.addDefault("COOLDOWN_lastdodge", last_dodge); + workable.addDefault("COOLDOWN_lastsiphon", last_siphon); + workable.addDefault("COOLDOWN_lastmock", last_mock); + workable.addDefault("COOLDOWN_lastassassinatetime", lastassassinatetime); + workable.addDefault("COOLDOWN_lastlifesavertime", lastlifesavertime); workable.options().copyDefaults(); //Set all variables. - this.name = workable.getString("name"); + //this.name = workable.getString("name"); //this.displayName = workable.getString("displayName"); this.joined = workable.getLong("joined"); this.firstjoined = workable.getLong("firstjoined"); @@ -424,7 +472,27 @@ public class PlayerStructure { this.holidaychest3 = workable.getBoolean("holidaychest3"); this.holidaychest4 = workable.getBoolean("holidaychest4"); this.lastsantabox2 = workable.getLong("lastsantabox2"); + this.lastvendettastack = workable.getLong("lastvendettastack"); this.playermode_on_death = PlayerMode.valueOf(workable.getString("playermode_on_death")); + this.last_deathmark = workable.getLong("COOLDOWN_deathmark"); + this.last_shovelspell = workable.getLong("COOLDOWN_shovelspell"); + this.last_strikerspell = workable.getLong("COOLDOWN_strikerspell"); + this.lastusedearthwave = workable.getLong("COOLDOWN_usedearthwave"); + this.last_arrowbarrage = workable.getLong("COOLDOWN_arrowbarrage"); + this.last_laugh_time = workable.getLong("COOLDOWN_laughtime"); + this.last_rejuvenate = workable.getLong("COOLDOWN_rejuvenate"); + this.last_swordhit = workable.getLong("COOLDOWN_swordhit"); + this.last_strikerspell = workable.getLong("COOLDOWN_strikerspell"); + this.lastabsorptionhealthgiven = workable.getLong("COOLDOWN_absorptionhealthgiven"); + this.ignoretargetarmor = workable.getLong("COOLDOWN_ignoretargetarmor"); + this.lastrevivecandyconsumed = workable.getLong("COOLDOWN_lastrevivecandyconsumed"); + this.lastcandyconsumed = workable.getLong("COOLDOWN_lastcandyconsumed"); + this.icewandused = workable.getLong("COOLDOWN_icewandused"); + this.last_dodge = workable.getLong("COOLDOWN_lastdodge"); + this.last_siphon = workable.getLong("COOLDOWN_lastsiphon"); + this.last_mock = workable.getLong("COOLDOWN_lastmock"); + this.lastassassinatetime = workable.getLong("COOLDOWN_lastassassinatetime"); + this.lastlifesavertime = workable.getLong("COOLDOWN_lastlifesavertime"); if (this.hasDied) { List deathlootlist = new ArrayList(); diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index a902af6..fc66c49 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -479,6 +479,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public static Plugin plugin; public int sleepingPlayers=0; public static List validsetitems = new ArrayList(); + + public static double DEAL_OF_THE_DAY_PCT=0.2; public final static boolean CHRISTMASEVENT_ACTIVATED=false; public final static boolean CHRISTMASLINGERINGEVENT_ACTIVATED=false; //Limited Christmas drops/functionality remain while the majority of it is turned off. @@ -653,36 +655,72 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } else { //This is fine! Clear away blocks. Monster m = cz.GetZombie(); + + if (cz.lastLoc!=null && cz.lastLoc.distance(m.getLocation())<=0.4) { + cz.stuckTimer++; + //TwosideKeeper.log("Stuck. "+stuckTimer, 0); + } else { + cz.stuckTimer=0; + } + cz.lastLoc = m.getLocation().clone(); + if (cz.stuckTimer>5) { + //Teleport randomly. + double numb = Math.random(); + if (numb<=0.33) { + SoundUtils.playGlobalSound(m.getLocation(), Sound.ENTITY_ENDERMEN_TELEPORT, 1.0f, 1.0f); + m.teleport(m.getLocation().add(Math.random()*6-3,0,0)); + } else + if (numb<=0.5) { + SoundUtils.playGlobalSound(m.getLocation(), Sound.ENTITY_ENDERMEN_TELEPORT, 1.0f, 1.0f); + m.teleport(m.getLocation().add(0,0,Math.random()*6-3)); + } else + { + SoundUtils.playGlobalSound(m.getLocation(), Sound.ENTITY_ENDERMEN_TELEPORT, 1.0f, 1.0f); + m.teleport(m.getLocation().add(0,Math.random()*6-3,0)); + } + cz.stuckTimer=0; + } if (m.getTarget().getLocation().getY()>=m.getLocation().getY()+2 && - Math.abs(m.getTarget().getLocation().getX()-m.getLocation().getX())<1 && - Math.abs(m.getTarget().getLocation().getZ()-m.getLocation().getZ())<1) { + Math.abs(m.getTarget().getLocation().getX()-m.getLocation().getX())<3 && + Math.abs(m.getTarget().getLocation().getZ()-m.getLocation().getZ())<3) { //This target is higher than we can reach... Let's pillar. Random r = new Random(); r.setSeed(m.getUniqueId().getMostSignificantBits()); //Block type is chosen based on the seed. Will be cobblestone, dirt, or gravel. - if (m.getLocation().getBlock().getType()==Material.AIR && - m.getLocation().add(0,-1,0).getBlock().getType()!=Material.AIR && - !m.getLocation().add(0,-1,0).getBlock().isLiquid()) { - m.setVelocity(new Vector(0,0.5,0)); - if (m.getLocation().getWorld().getName().equalsIgnoreCase("world_nether")) { - m.getLocation().getBlock().setType(Material.NETHERRACK); - SoundUtils.playGlobalSound(m.getLocation(), Sound.BLOCK_STONE_PLACE, 1.0f, 1.0f); - } else { - switch (r.nextInt(3)) { - case 0:{ - SoundUtils.playGlobalSound(m.getLocation(), Sound.BLOCK_GRAVEL_PLACE, 1.0f, 1.0f); - }break; - case 1:{ - m.getLocation().getBlock().setType(Material.COBBLESTONE); + for (int x=-1;x<2;x++) { + for (int z=-1;z<2;z++) { + if (m.getLocation().add(x,-1,z).getBlock().getType()==Material.AIR || + m.getLocation().add(x,-1,z).getBlock().isLiquid()) { + m.setVelocity(new Vector(0,0.5,0)); + if (m.getLocation().getWorld().getName().equalsIgnoreCase("world_nether")) { + m.getLocation().getBlock().getRelative(x,0,z).setType(Material.NETHERRACK); SoundUtils.playGlobalSound(m.getLocation(), Sound.BLOCK_STONE_PLACE, 1.0f, 1.0f); - }break; - case 2:{ - m.getLocation().getBlock().setType(Material.GRAVEL); - SoundUtils.playGlobalSound(m.getLocation(), Sound.BLOCK_GRAVEL_PLACE, 1.0f, 1.0f); - }break; + } else { + switch (r.nextInt(3)) { + case 0:{ + m.getLocation().getBlock().getRelative(x,0,z).setType(Material.DIRT); + SoundUtils.playGlobalSound(m.getLocation().add(x,0,z), Sound.BLOCK_GRAVEL_PLACE, 1.0f, 1.0f); + }break; + case 1:{ + m.getLocation().getBlock().getRelative(x,0,z).setType(Material.COBBLESTONE); + SoundUtils.playGlobalSound(m.getLocation().add(x,0,z), Sound.BLOCK_STONE_PLACE, 1.0f, 1.0f); + }break; + case 2:{ + m.getLocation().getBlock().getRelative(x,0,z).setType(Material.GRAVEL); + SoundUtils.playGlobalSound(m.getLocation().add(x,0,z), Sound.BLOCK_GRAVEL_PLACE, 1.0f, 1.0f); + }break; + } + } } } } + //Command all nearby entities to jump too. + List ents = GenericFunctions.getNearbyMonsters(m.getLocation(), 2); + for (LivingEntity ent : ents) { + if (!ent.equals(m)) { + ent.setVelocity(new Vector(0,0.5,0)); + } + } } ChargeZombie.BreakBlocksAroundArea(cz.m,1); } @@ -893,6 +931,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { WorldShop.createWorldShopRecipes(); WorldShop.loadShopPrices(); TwosideKeeper.DEAL_OF_THE_DAY_ITEM = WorldShop.generateItemDealOftheDay(1); + TwosideKeeper.DEAL_OF_THE_DAY_PCT = WorldShop.generatePercentOffForDealOftheDay(); log("Deal of the day loaded successfully: "+GenericFunctions.UserFriendlyMaterialName(TwosideKeeper.DEAL_OF_THE_DAY_ITEM),2); if (!LOOT_TABLE_NEEDS_POPULATING) { @@ -1155,6 +1194,49 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (p.getLocation().add(0,0,0).getBlock().getType()==Material.PISTON_MOVING_PIECE) { p.getLocation().add(0,0,0).getBlock().setType(Material.AIR); } + if (args.length>0) { + ItemStack item = new ItemStack(p.getEquipment().getItemInMainHand().getType(),1,p.getEquipment().getItemInMainHand().getDurability()); + if (GenericFunctions.isEquip(item)) { + item.setDurability((short) 0); + } + switch (args[0]) { + case "price":{ + if (args.length<2) { //Display the price of the item in hand. + if (item!=null && item.getType()!=Material.AIR) { + double price = WorldShop.getBaseWorldShopPrice(item); + p.sendMessage("The base shop price of "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(item)+ChatColor.RESET+" is "+ChatColor.GREEN+"$"+df.format(price)+ChatColor.RESET+"."); + } else { + p.sendMessage("That is an invalid item!"); + } + } else { + if (p.getName().equalsIgnoreCase("ishiyama") || p.isOp()) { + if (isNumeric(args[1])) { + double newprice = Double.parseDouble(args[1]); + if (item!=null && item.getType()!=Material.AIR) { + double price = WorldShop.getBaseWorldShopPrice(item); + Bukkit.broadcastMessage(ChatColor.YELLOW+"The base cost of "+ChatColor.GREEN+GenericFunctions.UserFriendlyMaterialName(item)+ChatColor.YELLOW+" has been updated!"); + Bukkit.broadcastMessage(" "+ChatColor.GRAY+ChatColor.STRIKETHROUGH+"$"+df.format(price)+ChatColor.RESET+" -> "+ChatColor.BLUE+ChatColor.BOLD+"$"+df.format(newprice)); + aPlugin.API.discordSendRawItalicized(ChatColor.YELLOW+"The base cost of **"+ChatColor.GREEN+GenericFunctions.UserFriendlyMaterialName(item)+ChatColor.YELLOW+"** has been updated!"); + aPlugin.API.discordSendRawItalicized(" ~~"+ChatColor.GRAY+ChatColor.STRIKETHROUGH+"$"+df.format(price)+ChatColor.RESET+"~~ -> **"+ChatColor.BLUE+ChatColor.BOLD+"$"+df.format(newprice)+"**"); + String searchstring = item.getType().name(); + if (item.getDurability()!=0) { + searchstring = item.getType().name()+","+item.getDurability(); + } + WorldShop.pricelist.put(searchstring, newprice); + WorldShop.SaveAllPriceEntriesToFile(); + } else { + p.sendMessage("That is an invalid item!"); + } + } else { + p.sendMessage("That is an invalid price!"); + } + } else { + p.sendMessage("No permission!"); + } + } + }break; + } + } if (p.isOp()) { /*PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); pd.swordcombo=20;*/ @@ -2194,7 +2276,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { p.sendMessage("--------------------"); p.sendMessage(ChatColor.DARK_AQUA+""+ChatColor.BOLD+"Deal of the Day:"); DecimalFormat df = new DecimalFormat("0.00"); - p.sendMessage(" "+ChatColor.GREEN+""+ChatColor.BOLD+""+GenericFunctions.UserFriendlyMaterialName(TwosideKeeper.DEAL_OF_THE_DAY_ITEM)+" "+ChatColor.RESET+ChatColor.STRIKETHROUGH+"$"+df.format(TwosideKeeperAPI.getWorldShopItemBasePrice(TwosideKeeper.DEAL_OF_THE_DAY_ITEM))+ChatColor.RESET+ChatColor.GOLD+""+ChatColor.BOLD+" $"+df.format(TwosideKeeperAPI.getWorldShopItemBasePrice(TwosideKeeper.DEAL_OF_THE_DAY_ITEM)*0.8)+" "+ChatColor.DARK_GREEN+ChatColor.BOLD+"20% Off"); + DecimalFormat df2 = new DecimalFormat("0"); + p.sendMessage(" "+ChatColor.GREEN+""+ChatColor.BOLD+""+GenericFunctions.UserFriendlyMaterialName(TwosideKeeper.DEAL_OF_THE_DAY_ITEM)+" "+ChatColor.RESET+ChatColor.STRIKETHROUGH+"$"+df.format(TwosideKeeperAPI.getWorldShopItemBasePrice(TwosideKeeper.DEAL_OF_THE_DAY_ITEM))+ChatColor.RESET+ChatColor.GOLD+""+ChatColor.BOLD+" $"+df.format(TwosideKeeperAPI.getWorldShopItemBasePrice(TwosideKeeper.DEAL_OF_THE_DAY_ITEM)*(1-TwosideKeeper.DEAL_OF_THE_DAY_PCT))+" "+ChatColor.DARK_GREEN+ChatColor.BOLD+""+df2.format(TwosideKeeper.DEAL_OF_THE_DAY_PCT*100)+"% Off"); p.sendMessage(" "+ChatColor.RED+ChatColor.BOLD+"TODAY ONLY!"+ChatColor.RESET+ChatColor.YELLOW+" Find the offer at your local world shops!"); p.sendMessage("--------------------"); } @@ -5985,6 +6068,12 @@ public class TwosideKeeper extends JavaPlugin implements Listener { log("In here 1",5); Monster m = (Monster)ev.getEntity(); + if (ev.getTarget() instanceof Monster && + m.getTarget() instanceof Player) { + ev.setCancelled(true); //Monsters will not target other Monsters if they are already targeting a player. + return; + } + if (ev.getTarget() instanceof Wither) { ev.setCancelled(true); return; //Monsters will not target the Wither, even with friendly fire. @@ -6369,6 +6458,13 @@ public class TwosideKeeper extends JavaPlugin implements Listener { AttemptToPlaceChest(m.getLocation(),1,1,-1,aPlugin.API.Chests.LOOT_CUSTOM_5); AttemptToPlaceChest(m.getLocation(),1,1,1,aPlugin.API.Chests.LOOT_CUSTOM_5); + for (UUID id : custommonsters.keySet()) { + if (id.equals(m.getUniqueId())) { + sig.plugin.TwosideKeeper.Monster.Wither w = (sig.plugin.TwosideKeeper.Monster.Wither)custommonsters.get(id); + w.DisplaySuccessfulDPSReport(); + break; + } + } } if (isElite && m instanceof Monster) { @@ -6409,7 +6505,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener { it.setPickupDelay(0); } } - Bukkit.getServer().broadcastMessage(ChatColor.YELLOW+"DPS Breakdown:"); Bukkit.getServer().broadcastMessage(ChatColor.GREEN+participants_list.toString()+ChatColor.WHITE+" "+(participants_list.length()==1?"has single-handedly taken down the ":"have successfully slain ")+GenericFunctions.getDisplayName(m)+ChatColor.WHITE+"!"); aPlugin.API.discordSendRaw(ChatColor.GREEN+participants_list.toString()+ChatColor.WHITE+" "+(participants_list.length()==1?"has single-handedly taken down the ":"have successfully slain ")+"**"+GenericFunctions.getDisplayName(m)+ChatColor.WHITE+"**!"); m.getWorld().spawnEntity(m.getLocation(), EntityType.LIGHTNING); @@ -6419,6 +6514,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { public void run() { + Bukkit.getServer().broadcastMessage(ChatColor.YELLOW+"DPS Breakdown:"); Bukkit.getServer().broadcastMessage(em.generateDPSReport()); aPlugin.API.discordSendRaw(ChatColor.YELLOW+"DPS Breakdown:"+"\n```\n"+em.generateDPSReport()+"\n```"); em.Cleanup(); @@ -6474,11 +6570,12 @@ public class TwosideKeeper extends JavaPlugin implements Listener { Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { public void run() { if (!mer.getLocation().getWorld().getName().equalsIgnoreCase("world") || mer.getLocation().getBlockY()<48) { - mer.getWorld().createExplosion(mer.getLocation().getBlockX(), mer.getLocation().getBlockY(), mer.getLocation().getBlockZ(), 3.0f, false, true); - GenericFunctions.DealExplosionDamageToEntities(mer.getLocation(), 8, 3); + mer.getWorld().createExplosion(mer.getLocation().getBlockX(), mer.getLocation().getBlockY(), mer.getLocation().getBlockZ(), 1.5f, false, true); + aPlugin.API.sendSoundlessExplosion(mer.getLocation(), 3.0f); + GenericFunctions.DealExplosionDamageToEntities(mer.getLocation(), 20, 3); } else { mer.getWorld().createExplosion(mer.getLocation().getBlockX(), mer.getLocation().getBlockY(), mer.getLocation().getBlockZ(), 6.0f, false, false); - GenericFunctions.DealExplosionDamageToEntities(mer.getLocation(), 8, 6); + GenericFunctions.DealExplosionDamageToEntities(mer.getLocation(), 20, 6); } }} ,30); @@ -6505,12 +6602,13 @@ public class TwosideKeeper extends JavaPlugin implements Listener { Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { public void run() { if (!mer1.getLocation().getWorld().getName().equalsIgnoreCase("world") || mer1.getLocation().getBlockY()<48) { - mer1.getWorld().createExplosion(mer1.getLocation().getBlockX(), mer1.getLocation().getBlockY(), mer1.getLocation().getBlockZ(), 5.0f, false, true); - GenericFunctions.DealExplosionDamageToEntities(mer1.getLocation(), 12, 5); + mer1.getWorld().createExplosion(mer1.getLocation().getBlockX(), mer1.getLocation().getBlockY(), mer1.getLocation().getBlockZ(), 2.0f, false, true); + aPlugin.API.sendSoundlessExplosion(mer1.getLocation(), 5.0f); + GenericFunctions.DealExplosionDamageToEntities(mer1.getLocation(), 36, 5); GenericFunctions.RandomlyCreateFire(mer1.getLocation(),2); } else { mer1.getWorld().createExplosion(mer1.getLocation().getBlockX(), mer1.getLocation().getBlockY(), mer1.getLocation().getBlockZ(), 6.0f, false, false); - GenericFunctions.DealExplosionDamageToEntities(mer1.getLocation(), 12, 6); + GenericFunctions.DealExplosionDamageToEntities(mer1.getLocation(), 36, 6); GenericFunctions.RandomlyCreateFire(mer1.getLocation(),3); } }} @@ -6538,7 +6636,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { public void run() { if (!mer4.getLocation().getWorld().getName().equalsIgnoreCase("world") || mer4.getLocation().getBlockY()<48) { - mer4.getWorld().createExplosion(mer4.getLocation().getBlockX(), mer4.getLocation().getBlockY(), mer4.getLocation().getBlockZ(), 5.0f, false, true); + mer4.getWorld().createExplosion(mer4.getLocation().getBlockX(), mer4.getLocation().getBlockY(), mer4.getLocation().getBlockZ(), 2.0f, false, true); + aPlugin.API.sendSoundlessExplosion(mer4.getLocation(), 5.0f); GenericFunctions.DealExplosionDamageToEntities(mer4.getLocation(), 150, 5); GenericFunctions.RandomlyCreateFire(mer4.getLocation(),2); } else { diff --git a/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java b/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java index 85d8c2c..74f1256 100644 --- a/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java +++ b/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java @@ -78,14 +78,15 @@ final class runServerHeartbeat implements Runnable { //SAVE SERVER SETTINGS. final long serverTickTime = TwosideKeeper.getServerTickTime(); if (serverTickTime-TwosideKeeper.LASTSERVERCHECK>=TwosideKeeper.SERVERCHECKERTICKS) { //15 MINUTES (DEFAULT) - if (TwosideKeeper.LAST_DEAL!=Calendar.getInstance().get(Calendar.DAY_OF_WEEK)) { //This means the deal of the day has to be updated! TwosideKeeper.LAST_DEAL = Calendar.getInstance().get(Calendar.DAY_OF_WEEK); TwosideKeeper.DEAL_OF_THE_DAY_ITEM = WorldShop.generateItemDealOftheDay(1); + TwosideKeeper.DEAL_OF_THE_DAY_PCT = WorldShop.generatePercentOffForDealOftheDay(); if (TwosideKeeper.SERVER_TYPE!=ServerType.QUIET) { DecimalFormat df = new DecimalFormat("0.00"); - aPlugin.API.discordSendRaw("*The Deal of the Day has been updated!*\n **"+GenericFunctions.UserFriendlyMaterialName(TwosideKeeper.DEAL_OF_THE_DAY_ITEM)+"** ~~$"+df.format(WorldShop.getBaseWorldShopPrice(TwosideKeeper.DEAL_OF_THE_DAY_ITEM))+"~~ $"+df.format(WorldShop.getBaseWorldShopPrice(TwosideKeeper.DEAL_OF_THE_DAY_ITEM)*0.8)+" **20% Off!**"); + DecimalFormat df2 = new DecimalFormat("0"); + aPlugin.API.discordSendRaw("*The Deal of the Day has been updated!*\n **"+GenericFunctions.UserFriendlyMaterialName(TwosideKeeper.DEAL_OF_THE_DAY_ITEM)+"** ~~$"+df.format(WorldShop.getBaseWorldShopPrice(TwosideKeeper.DEAL_OF_THE_DAY_ITEM))+"~~ $"+df.format(WorldShop.getBaseWorldShopPrice(TwosideKeeper.DEAL_OF_THE_DAY_ITEM)*(1-TwosideKeeper.DEAL_OF_THE_DAY_PCT))+" **"+df2.format(TwosideKeeper.DEAL_OF_THE_DAY_PCT*100)+"% Off!**"); //MessageUtils.announceMessage("The Deal of the Day has been updated!"); } for (Player p : Bukkit.getOnlinePlayers()) { @@ -193,75 +194,25 @@ final class runServerHeartbeat implements Runnable { } if (!aPlugin.API.isAFK(p)) { - if (TwosideKeeper.TwosideShops.IsPlayerUsingTerminal(p) && - (TwosideKeeper.TwosideShops.GetSession(p).GetSign().getBlock()==null || TwosideKeeper.TwosideShops.GetSession(p).IsTimeExpired())) { - p.sendMessage(ChatColor.RED+"Ran out of time! "+ChatColor.WHITE+"Shop session closed."); - TwosideKeeper.TwosideShops.RemoveSession(p); - } + EndShopSession(p); GenericFunctions.RemoveNewDebuffs(p); - if (ItemSet.GetTotalBaseAmount(GenericFunctions.getEquipment(p), p, ItemSet.DASHER)>0) { - double spdmult = ItemSet.GetTotalBaseAmount(GenericFunctions.getEquipment(p), p, ItemSet.DASHER)/100d; - aPlugin.API.setPlayerSpeedMultiplier(p, (float)(1.0f+spdmult)); - } + ModifyDasherSetSpeedMultiplier(p); - pd.highwinder=ArtifactAbility.containsEnchantment(ArtifactAbility.HIGHWINDER, p.getEquipment().getItemInMainHand()); - if (pd.highwinder) { - pd.highwinderdmg=GenericFunctions.getAbilityValue(ArtifactAbility.HIGHWINDER, p.getEquipment().getItemInMainHand()); - } - if (93.182445*pd.velocity>4.317) { - pd.velocity/=2; - } else { - pd.velocity=0; - } - if (pd.highwinder && pd.target!=null && !pd.target.isDead()) { - GenericFunctions.sendActionBarMessage(p, TwosideKeeper.drawVelocityBar(pd.velocity,pd.highwinderdmg),true); - } - if (pd.target!=null && !pd.target.isDead() && pd.target.getLocation().getWorld().equals(p.getWorld()) && pd.target.getLocation().distanceSquared(p.getLocation())>256) { - pd.target=null; - } + ManageHighwinder(p, pd); + RemoveInvalidTarget(p, pd); - if (pd.lasthittarget+20*15<=serverTickTime && pd.storedbowxp>0 && GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand()) && - p.getEquipment().getItemInMainHand().getType()==Material.BOW) { - AwakenedArtifact.addPotentialEXP(p.getEquipment().getItemInMainHand(), pd.storedbowxp, p); - TwosideKeeper.log("Added "+pd.storedbowxp+" Artifact XP", 4); - pd.storedbowxp=0; - } + GiveArtifactBowXP(serverTickTime, p, pd); - if (p.getFireTicks()>0 && p.hasPotionEffect(PotionEffectType.FIRE_RESISTANCE)) { - int duration = GenericFunctions.getPotionEffectDuration(PotionEffectType.FIRE_RESISTANCE, p); - int lv = GenericFunctions.getPotionEffectLevel(PotionEffectType.FIRE_RESISTANCE, p); - if (lv>10) {lv=10;} - GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.FIRE_RESISTANCE, duration-(20*(10-lv)), lv, p, true); - } + ReduceFireResistanceDuration(p); - if (p.getWorld().getName().equalsIgnoreCase("world_the_end")) { - if (!pd.endnotification) { - pd.endnotification=true; - playEndWarningNotification(p); - } - randomlyAggroNearbyEndermen(p); - } else { - if (pd.endnotification) { - pd.endnotification=false; - } - } + ControlTheEnd(p, pd); ItemStack[] equips = p.getEquipment().getArmorContents(); - for (ItemStack equip : equips) { - if (ArtifactAbility.containsEnchantment(ArtifactAbility.SHADOWWALKER, equip) && - p.isOnGround() && p.getLocation().getY()>=0 && p.getLocation().getY()<=255 && p.getLocation().add(0,0,0).getBlock().getLightLevel()<=7) { - GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.SPEED,20,1,p); - } - } - if (p.getLocation().getY()>=0 && p.getLocation().getY()<=255 && p.getLocation().add(0,0,0).getBlock().getLightLevel()<=7) { - if (ArtifactAbility.containsEnchantment(ArtifactAbility.SHADOWWALKER, p.getEquipment().getItemInMainHand())) { - GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.SPEED,20,1,p); - } - //log("Apply speed. The light level here is "+p.getLocation().add(0,-1,0).getBlock().getLightLevel(),2); - } + ShadowWalkerApplication(p, equips); + //PopulatePlayerBlockList(p,15,15,2,5,false); PopRandomLavaBlock(p); @@ -271,161 +222,47 @@ final class runServerHeartbeat implements Runnable { if (GenericFunctions.hasStealth(p)) {GenericFunctions.DamageRandomTool(p);} //See if this player is sleeping. - if (p.isSleeping()) { - p.setHealth(Bukkit.getPlayer(pd.name).getMaxHealth()); //Heals the player fully when sleeping. - } + HealForSleeping(p, pd); //We need to see if this player's damage reduction has changed recently. If so, notify them. //Check damage reduction by sending an artifical "1" damage to the player. - if (!p.isDead()) {TwosideKeeper.log("Player is not dead.",5); TwosideKeeper.setPlayerMaxHealth(p);} - p.getScoreboard().getTeam(p.getName().toLowerCase()).setSuffix(TwosideKeeper.createHealthbar(((p.getHealth())/p.getMaxHealth())*100,p)); - p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(GenericFunctions.PlayerModePrefix(p)); + ManagePlayerScoreboardAndHealth(p); if (PlayerMode.isBarbarian(p)) { AutoConsumeFoods(p); } } - p.getAttribute(Attribute.GENERIC_ARMOR).setBaseValue(20*(1.0d-CustomDamage.CalculateDamageReduction(1,p,null))+subtractVanillaArmorBar(p.getEquipment().getArmorContents())); + ModifyArmorBar(p); ItemStack[] equips = p.getEquipment().getArmorContents(); - if (pd.lastcombat+(20*60)0 && pd.lastvendettastack+2007) { - TwosideKeeper.HuntingForSnowman = TwosideKeeper.SnowmanHuntList.get((int)(Math.random()*TwosideKeeper.SnowmanHuntList.size())); - aPlugin.API.discordSendRaw("The Hunt is on to kill the Snowman named **"+TwosideKeeper.HuntingForSnowman+"**!"); - Bukkit.broadcastMessage("The Hunt is on to kill the Snowman named "+ChatColor.BOLD+TwosideKeeper.HuntingForSnowman+ChatColor.RESET+"!"); - Bukkit.broadcastMessage(ChatColor.AQUA+" You will earn Holiday Tokens for successfully completing this mission!"); - TwosideKeeper.LastSnowmanHunt=TwosideKeeper.getServerTickTime(); - } - } - - if (pd.linkplayer!=null && pd.linkplayer.isValid()) { - GlowAPI.setGlowing(pd.linkplayer, true, p); - if (pd.lastlinkteleport!=0 && pd.lastlinkteleport+120000 && pd.damagepooltime+20<=serverTickTime) { - double transferdmg = CustomDamage.getTransferDamage(p)+(pd.damagepool*0.01); - TwosideKeeper.log("Transfer Dmg is "+transferdmg+". Damage Pool: "+pd.damagepool, 5); - CustomDamage.ApplyDamage(transferdmg, null, p, null, "Damage Pool", CustomDamage.IGNORE_DAMAGE_TICK|CustomDamage.TRUEDMG|CustomDamage.IGNOREDODGE); - if (pd.damagepool-transferdmg<=0) { - pd.damagepool=0; - } else { - pd.damagepool-=transferdmg; - } - } + DepleteDamagePool(serverTickTime, p, pd); - if (PlayerMode.getPlayerMode(p)==PlayerMode.NORMAL) { - p.setExhaustion(Math.max(0, p.getExhaustion()-0.5f)); - } + AdventurerModeSetExhaustion(p); - if (pd.last_regen_time+TwosideKeeper.HEALTH_REGENERATION_RATE<=serverTickTime) { - pd.last_regen_time=serverTickTime; - //See if this player needs to be healed. - if (p!=null && - !p.isDead() && //Um, don't heal them if they're dead...That's just weird. - p.getHealth()=16) { - - if (PlayerMode.getPlayerMode(p)!=PlayerMode.SLAYER || pd.lastcombat+(20*60)TwosideKeeper.getServerTickTime()) { - totalregen += totalregen*pd.pctbonusregen; - } - totalregen += totalregen*((PlayerMode.getPlayerMode(p)==PlayerMode.NORMAL)?0.5d:0d); - p.setHealth((p.getHealth()+totalregen>p.getMaxHealth())?p.getMaxHealth():p.getHealth()+totalregen); - - if (PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER) { - pd.slayermodehp=p.getHealth(); - } - } - } - } + CalculateHealthRegeneration(serverTickTime, p, pd, equips); - if (ArtifactAbility.containsEnchantment(ArtifactAbility.COMBO, p.getEquipment().getItemInMainHand()) && - pd.last_swordhit+400) { - List partymembers = PartyManager.getPartyMembers(p); - for (Player pl : partymembers) { - PlayerStructure pld = PlayerStructure.GetPlayerStructure(pl); - pld.pctbonusregen=regenbuff/100d; - pld.pctbonusregentime=TwosideKeeper.getServerTickTime(); - } - } + ApplyCometRegenBonus(p); - if (p.isSprinting() && p.getFoodLevel()<20 - && ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getArmor(p), p, ItemSet.DASHER, 4)) { - p.setFoodLevel(p.getFoodLevel()+1); - } + DasherFoodRegenPerk(p); - if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getArmor(p), p, ItemSet.RUDOLPH, 4)) { - if (!p.hasPotionEffect(PotionEffectType.NIGHT_VISION)) { - GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 1, p, true); - } - List partymembers = PartyManager.getPartyMembers(p); - for (Player pl : partymembers) { - if (!pl.hasPotionEffect(PotionEffectType.NIGHT_VISION)) { - GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 1, pl, true); - } - } - } + GivePartyNightVision(p); } //TwosideKeeper.outputArmorDurability(p,">"); } + ManageSnowmanHunt(); + CheckAndAnnounceWeather(); Christmas.ChristmasHeartbeat(); @@ -439,6 +276,265 @@ final class runServerHeartbeat implements Runnable { performTimingsReport(); } + private void ManagePlayerScoreboardAndHealth(Player p) { + if (!p.isDead()) {TwosideKeeper.log("Player is not dead.",5); TwosideKeeper.setPlayerMaxHealth(p);} + if (p.getScoreboard().getTeam(p.getName().toLowerCase())==null) { + p.getScoreboard().registerNewTeam(p.getName().toLowerCase()).addPlayer(p); + } + p.getScoreboard().getTeam(p.getName().toLowerCase()).setSuffix(TwosideKeeper.createHealthbar(((p.getHealth())/p.getMaxHealth())*100,p)); + p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(GenericFunctions.PlayerModePrefix(p)); + } + + private void HealForSleeping(Player p, PlayerStructure pd) { + if (p.isSleeping()) { + p.setHealth(Bukkit.getPlayer(pd.name).getMaxHealth()); //Heals the player fully when sleeping. + } + } + + private void ShadowWalkerApplication(Player p, ItemStack[] equips) { + for (ItemStack equip : equips) { + if (ArtifactAbility.containsEnchantment(ArtifactAbility.SHADOWWALKER, equip) && + p.isOnGround() && p.getLocation().getY()>=0 && p.getLocation().getY()<=255 && p.getLocation().add(0,0,0).getBlock().getLightLevel()<=7) { + GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.SPEED,20,1,p); + } + } + if (p.getLocation().getY()>=0 && p.getLocation().getY()<=255 && p.getLocation().add(0,0,0).getBlock().getLightLevel()<=7) { + if (ArtifactAbility.containsEnchantment(ArtifactAbility.SHADOWWALKER, p.getEquipment().getItemInMainHand())) { + GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.SPEED,20,1,p); + } + //log("Apply speed. The light level here is "+p.getLocation().add(0,-1,0).getBlock().getLightLevel(),2); + } + } + + private void ControlTheEnd(Player p, PlayerStructure pd) { + if (p.getWorld().getName().equalsIgnoreCase("world_the_end")) { + if (!pd.endnotification) { + pd.endnotification=true; + playEndWarningNotification(p); + } + randomlyAggroNearbyEndermen(p); + } else { + if (pd.endnotification) { + pd.endnotification=false; + } + } + } + + private void ReduceFireResistanceDuration(Player p) { + if (p.getFireTicks()>0 && p.hasPotionEffect(PotionEffectType.FIRE_RESISTANCE)) { + int duration = GenericFunctions.getPotionEffectDuration(PotionEffectType.FIRE_RESISTANCE, p); + int lv = GenericFunctions.getPotionEffectLevel(PotionEffectType.FIRE_RESISTANCE, p); + if (lv>10) {lv=10;} + GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.FIRE_RESISTANCE, duration-(20*(10-lv)), lv, p, true); + } + } + + private void GiveArtifactBowXP(final long serverTickTime, Player p, PlayerStructure pd) { + if (pd.lasthittarget+20*15<=serverTickTime && pd.storedbowxp>0 && GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand()) && + p.getEquipment().getItemInMainHand().getType()==Material.BOW) { + AwakenedArtifact.addPotentialEXP(p.getEquipment().getItemInMainHand(), pd.storedbowxp, p); + TwosideKeeper.log("Added "+pd.storedbowxp+" Artifact XP", 4); + pd.storedbowxp=0; + } + } + + private void RemoveInvalidTarget(Player p, PlayerStructure pd) { + if (pd.target!=null && !pd.target.isDead() && pd.target.getLocation().getWorld().equals(p.getWorld()) && pd.target.getLocation().distanceSquared(p.getLocation())>256) { + pd.target=null; + } + } + + private void ManageHighwinder(Player p, PlayerStructure pd) { + pd.highwinder=ArtifactAbility.containsEnchantment(ArtifactAbility.HIGHWINDER, p.getEquipment().getItemInMainHand()); + if (pd.highwinder) { + pd.highwinderdmg=GenericFunctions.getAbilityValue(ArtifactAbility.HIGHWINDER, p.getEquipment().getItemInMainHand()); + } + if (93.182445*pd.velocity>4.317) { + pd.velocity/=2; + } else { + pd.velocity=0; + } + if (pd.highwinder && pd.target!=null && !pd.target.isDead()) { + GenericFunctions.sendActionBarMessage(p, TwosideKeeper.drawVelocityBar(pd.velocity,pd.highwinderdmg),true); + } + } + + private void ModifyDasherSetSpeedMultiplier(Player p) { + if (ItemSet.GetTotalBaseAmount(GenericFunctions.getEquipment(p), p, ItemSet.DASHER)>0) { + double spdmult = ItemSet.GetTotalBaseAmount(GenericFunctions.getEquipment(p), p, ItemSet.DASHER)/100d; + aPlugin.API.setPlayerSpeedMultiplier(p, (float)(1.0f+spdmult)); + } + } + + private void EndShopSession(Player p) { + if (TwosideKeeper.TwosideShops.IsPlayerUsingTerminal(p) && + (TwosideKeeper.TwosideShops.GetSession(p).GetSign().getBlock()==null || TwosideKeeper.TwosideShops.GetSession(p).IsTimeExpired())) { + p.sendMessage(ChatColor.RED+"Ran out of time! "+ChatColor.WHITE+"Shop session closed."); + TwosideKeeper.TwosideShops.RemoveSession(p); + } + } + + private void ModifyArmorBar(Player p) { + p.getAttribute(Attribute.GENERIC_ARMOR).setBaseValue(20*(1.0d-CustomDamage.CalculateDamageReduction(1,p,null))+subtractVanillaArmorBar(p.getEquipment().getArmorContents())); + } + + private void ResetVendetta(final long serverTickTime, PlayerStructure pd) { + if (pd.lastcombat+(20*60)0 && pd.lastvendettastack+2007) { + TwosideKeeper.HuntingForSnowman = TwosideKeeper.SnowmanHuntList.get((int)(Math.random()*TwosideKeeper.SnowmanHuntList.size())); + aPlugin.API.discordSendRaw("The Hunt is on to kill the Snowman named **"+TwosideKeeper.HuntingForSnowman+"**!"); + Bukkit.broadcastMessage("The Hunt is on to kill the Snowman named "+ChatColor.BOLD+TwosideKeeper.HuntingForSnowman+ChatColor.RESET+"!"); + Bukkit.broadcastMessage(ChatColor.AQUA+" You will earn Holiday Tokens for successfully completing this mission!"); + TwosideKeeper.LastSnowmanHunt=TwosideKeeper.getServerTickTime(); + } + } + } + + private void ManagePlayerLink(Player p, PlayerStructure pd) { + if (pd.linkplayer!=null && pd.linkplayer.isValid()) { + GlowAPI.setGlowing(pd.linkplayer, true, p); + if (pd.lastlinkteleport!=0 && pd.lastlinkteleport+120000 && pd.damagepooltime+20<=serverTickTime) { + double transferdmg = CustomDamage.getTransferDamage(p)+(pd.damagepool*0.01); + TwosideKeeper.log("Transfer Dmg is "+transferdmg+". Damage Pool: "+pd.damagepool, 5); + CustomDamage.ApplyDamage(transferdmg, null, p, null, "Damage Pool", CustomDamage.IGNORE_DAMAGE_TICK|CustomDamage.TRUEDMG|CustomDamage.IGNOREDODGE); + if (pd.damagepool-transferdmg<=0) { + pd.damagepool=0; + } else { + pd.damagepool-=transferdmg; + } + } + } + + private void AdventurerModeSetExhaustion(Player p) { + if (PlayerMode.getPlayerMode(p)==PlayerMode.NORMAL) { + p.setExhaustion(Math.max(0, p.getExhaustion()-0.5f)); + } + } + + private void DasherFoodRegenPerk(Player p) { + if (p.isSprinting() && p.getFoodLevel()<20 + && ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getArmor(p), p, ItemSet.DASHER, 4)) { + p.setFoodLevel(p.getFoodLevel()+1); + } + } + + private void GivePartyNightVision(Player p) { + if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getArmor(p), p, ItemSet.RUDOLPH, 4)) { + if (!p.hasPotionEffect(PotionEffectType.NIGHT_VISION)) { + GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 1, p, true); + } + List partymembers = PartyManager.getPartyMembers(p); + for (Player pl : partymembers) { + if (!pl.hasPotionEffect(PotionEffectType.NIGHT_VISION)) { + GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 1, pl, true); + } + } + } + } + + private void ApplyCometRegenBonus(Player p) { + double regenbuff = ItemSet.GetTotalBaseAmount(GenericFunctions.getEquipment(p), p, ItemSet.COMET); + if (regenbuff>0) { + List partymembers = PartyManager.getPartyMembers(p); + for (Player pl : partymembers) { + PlayerStructure pld = PlayerStructure.GetPlayerStructure(pl); + pld.pctbonusregen=regenbuff/100d; + pld.pctbonusregentime=TwosideKeeper.getServerTickTime(); + } + } + } + + private void ResetSlayerAggro(final long serverTickTime, Player p, PlayerStructure pd) { + if (PlayerMode.isSlayer(p)) { + if (pd.lastsneak+50<=serverTickTime && + p.isSneaking() && + ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getHotbarItems(p), p, ItemSet.MOONSHADOW, 7)) { + GenericFunctions.deAggroNearbyTargets(p); + GenericFunctions.applyStealth(p, true); + } + } + } + + private void ResetSwordCombo(final long serverTickTime, Player p, PlayerStructure pd) { + if (ArtifactAbility.containsEnchantment(ArtifactAbility.COMBO, p.getEquipment().getItemInMainHand()) && + pd.last_swordhit+40=16) { + + if (PlayerMode.getPlayerMode(p)!=PlayerMode.SLAYER || pd.lastcombat+(20*60)TwosideKeeper.getServerTickTime()) { + totalregen += totalregen*pd.pctbonusregen; + } + totalregen += totalregen*((PlayerMode.getPlayerMode(p)==PlayerMode.NORMAL)?0.5d:0d); + p.setHealth((p.getHealth()+totalregen>p.getMaxHealth())?p.getMaxHealth():p.getHealth()+totalregen); + + if (PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER) { + pd.slayermodehp=p.getHealth(); + } + } + } + } + } + private void performTimingsReport() { double tps = MinecraftServer.getServer().recentTps[0];