From 6b50cdd7480ab30220c9269f13a90abd49e2bb1a Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Mon, 28 Nov 2016 18:49:58 -0600 Subject: [PATCH] First merge with basic master branch. --- src/plugin.yml | 2 +- .../TwosideKeeper/ActionBarBuffUpdater.java | 11 +- .../TwosideKeeper/Boss/EliteZombie.java | 15 +- .../plugin/TwosideKeeper/ChargeZombie.java | 10 +- .../plugin/TwosideKeeper/CustomDamage.java | 122 ++- .../plugin/TwosideKeeper/EliteMonster.java | 5 +- .../Events/EntityDamagedEvent.java | 93 +++ .../Events/PlayerDodgeEvent.java | 2 +- .../Events/PlayerLineDriveEvent.java | 2 +- .../Events/PlayerTumbleEvent.java | 2 +- .../HelperStructures/ArtifactAbility.java | 10 +- .../Common/GenericFunctions.java | 82 +- .../HelperStructures/Common/RecipeLinker.java | 2 +- .../HelperStructures/CustomItem.java | 1 - .../HelperStructures/Effects/LavaPlume.java | 129 +++ .../Effects/TemporaryLava.java | 40 + .../EliteMonsterLocationFinder.java | 4 +- .../HelperStructures/ItemCube.java | 4 +- .../HelperStructures/ItemSet.java | 8 +- .../TwosideKeeper/HelperStructures/Loot.java | 21 +- .../HelperStructures/MonsterDifficulty.java | 6 +- .../HelperStructures/PlayerMode.java | 3 +- .../HelperStructures/Utils/ItemUtils.java | 36 + .../HelperStructures/Utils/SoundUtils.java | 45 + .../HelperStructures/WorldShop.java | 32 +- .../HelperStructures/WorldShopItem.java | 44 + .../plugin/TwosideKeeper/ItemCubeWindow.java | 9 +- .../TwosideKeeper/Logging/DamageLogger.java | 4 +- .../plugin/TwosideKeeper/PartyManager.java | 37 +- .../plugin/TwosideKeeper/PlayerStructure.java | 9 +- .../plugin/TwosideKeeper/TwosideKeeper.java | 778 ++++++++++-------- .../TwosideKeeper/TwosideKeeperAPI.java | 3 + .../TwosideKeeper/WorldShopManager.java | 14 +- .../TwosideKeeper/aPluginAPIWrapper.java | 11 + .../TwosideKeeper/runServerHeartbeat.java | 246 ++++-- 35 files changed, 1302 insertions(+), 540 deletions(-) create mode 100644 src/sig/plugin/TwosideKeeper/Events/EntityDamagedEvent.java create mode 100644 src/sig/plugin/TwosideKeeper/HelperStructures/Effects/LavaPlume.java create mode 100644 src/sig/plugin/TwosideKeeper/HelperStructures/Effects/TemporaryLava.java create mode 100644 src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemUtils.java create mode 100644 src/sig/plugin/TwosideKeeper/HelperStructures/Utils/SoundUtils.java create mode 100644 src/sig/plugin/TwosideKeeper/HelperStructures/WorldShopItem.java create mode 100644 src/sig/plugin/TwosideKeeper/aPluginAPIWrapper.java diff --git a/src/plugin.yml b/src/plugin.yml index 4368602..b875836 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: TwosideKeeper main: sig.plugin.TwosideKeeper.TwosideKeeper -version: 3.9.0a +version: 3.9.1 commands: money: description: Tells the player the amount of money they are holding. diff --git a/src/sig/plugin/TwosideKeeper/ActionBarBuffUpdater.java b/src/sig/plugin/TwosideKeeper/ActionBarBuffUpdater.java index d46912d..c4d3c96 100644 --- a/src/sig/plugin/TwosideKeeper/ActionBarBuffUpdater.java +++ b/src/sig/plugin/TwosideKeeper/ActionBarBuffUpdater.java @@ -30,6 +30,11 @@ public class ActionBarBuffUpdater{ StringBuilder effectString=new StringBuilder(""); if (p instanceof Player) { PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)p); + if (p.getFireTicks()>=20) { + effectString.append(ChatColor.GOLD+"⚠"); + effectString.append(AppendAmplifier((p.getFireTicks()/20)-1,false)); + effectString.append(" "); + } if (pd.lifestealstacks>4) { effectString.append(ChatColor.AQUA+"❣"); effectString.append(AppendAmplifier(pd.lifestealstacks-1)); @@ -98,8 +103,12 @@ public class ActionBarBuffUpdater{ } private static String AppendAmplifier(int amplifier) { + return AppendAmplifier(amplifier,true); + } + + private static String AppendAmplifier(int amplifier, boolean romanNumerals) { StringBuilder amp = new StringBuilder(" "); - if (amplifier+1<=10) { + if (amplifier+1<=10 && romanNumerals) { amp.append(ChatColor.GRAY+""+WorldShop.toRomanNumeral(amplifier+1)); } else { amp.append(ChatColor.GRAY+""+(amplifier+1)); diff --git a/src/sig/plugin/TwosideKeeper/Boss/EliteZombie.java b/src/sig/plugin/TwosideKeeper/Boss/EliteZombie.java index 8f66167..6755674 100644 --- a/src/sig/plugin/TwosideKeeper/Boss/EliteZombie.java +++ b/src/sig/plugin/TwosideKeeper/Boss/EliteZombie.java @@ -36,6 +36,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.Loot; import sig.plugin.TwosideKeeper.HelperStructures.MonsterDifficulty; import sig.plugin.TwosideKeeper.HelperStructures.PlayerMode; import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils; public class EliteZombie extends EliteMonster{ static int REFRESH_BUFFS = 20*30; @@ -136,7 +137,7 @@ public class EliteZombie extends EliteMonster{ lp.setReapplicationDelay(20); lp.setBasePotionData(new PotionData(PotionType.POISON)); lp.setParticle(Particle.SPELL); - loc.getWorld().playSound(loc, Sound.ENTITY_HOSTILE_SPLASH, 1.0f, 1.0f); + SoundUtils.playGlobalSound(loc, Sound.ENTITY_HOSTILE_SPLASH, 1.0f, 1.0f); } private void adjustWillpower() { @@ -246,8 +247,8 @@ public class EliteZombie extends EliteMonster{ p.setVelocity(new Vector(0,-1,0)); GenericFunctions.logAndRemovePotionEffectFromEntity(PotionEffectType.LEVITATION,p); GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.CONFUSION,(int)(20*2.25),0,p); - p.playSound(p.getLocation(), Sound.BLOCK_ANVIL_FALL, 0.4f, 0.8f); - p.playSound(p.getLocation(), Sound.ENTITY_MAGMACUBE_SQUISH, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.BLOCK_ANVIL_FALL, 0.4f, 0.8f); + SoundUtils.playLocalSound(p, Sound.ENTITY_MAGMACUBE_SQUISH, 1.0f, 1.0f); } } @@ -284,7 +285,7 @@ public class EliteZombie extends EliteMonster{ } } else if (l.getLocation().distanceSquared(m.getLocation())>100 && !leaping) { - l.getWorld().playSound(l.getLocation(), Sound.ENTITY_CAT_HISS, 1.0f, 1.0f); + SoundUtils.playGlobalSound(l.getLocation(), Sound.ENTITY_CAT_HISS, 1.0f, 1.0f); chasing=true; Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() { public void run() { @@ -526,10 +527,10 @@ public class EliteZombie extends EliteMonster{ b.setType(storedblocks.get(b)); } aPlugin.API.sendSoundlessExplosion(target_leap_loc, 4); - b.getLocation().getWorld().playSound(b.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.7f, 1.2f); + SoundUtils.playGlobalSound(b.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.7f, 1.2f); } storedblocks.clear(); - m.getLocation().getWorld().playSound(m.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.7f, 1.2f); + SoundUtils.playGlobalSound(m.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.7f, 1.2f); List nearbyplayers = GenericFunctions.getNearbyPlayers(target_leap_loc, radius); for (int i=0;i0) { - p.playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 1.0f, 1.0f); + SoundUtils.playGlobalSound(p.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 1.0f, 1.0f); GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.CONFUSION,20*4,0,p); TwosideKeeper.log("Got hit for "+storingenergy_hit+" damage!", 2); GenericFunctions.removeNoDamageTick(p, m); diff --git a/src/sig/plugin/TwosideKeeper/ChargeZombie.java b/src/sig/plugin/TwosideKeeper/ChargeZombie.java index f2dab7a..5fba29f 100644 --- a/src/sig/plugin/TwosideKeeper/ChargeZombie.java +++ b/src/sig/plugin/TwosideKeeper/ChargeZombie.java @@ -6,6 +6,8 @@ import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.entity.Monster; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils; + public class ChargeZombie { Monster m; @@ -45,11 +47,11 @@ public class ChargeZombie { brokeliquid=true; if (m.getLocation().add(x,y,z).getBlock().getType()==Material.STATIONARY_LAVA) { m.getLocation().add(x,y,z).getBlock().setType(Material.OBSIDIAN); - m.getLocation().getWorld().playSound(m.getLocation().add(x,y,z),Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f); + SoundUtils.playGlobalSound(m.getLocation().add(x,y,z),Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f); } } if (!brokeliquid) { - m.getLocation().getWorld().playSound(m.getLocation().add(x,y,z),Sound.BLOCK_STONE_BREAK, 1.0f, 1.0f); + SoundUtils.playGlobalSound(m.getLocation().add(x,y,z),Sound.BLOCK_STONE_BREAK, 1.0f, 1.0f); } m.getLocation().add(x,y,z).getBlock().breakNaturally(); aPlugin.API.sendBlockBreakPacket(m.getLocation().add(x,y,z).getBlock(), -1); @@ -93,11 +95,11 @@ public class ChargeZombie { brokeliquid=true; if (l.add(x,y,z).getBlock().getType()==Material.STATIONARY_LAVA) { l.add(x,y,z).getBlock().setType(Material.OBSIDIAN); - l.getWorld().playSound(l.add(x,y,z),Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f); + SoundUtils.playGlobalSound(l.add(x,y,z),Sound.BLOCK_FIRE_EXTINGUISH, 1f, 1f); } } if (!brokeliquid) { - l.getWorld().playSound(l.add(x,y,z),Sound.BLOCK_STONE_BREAK, 1.0f, 1.0f); + SoundUtils.playGlobalSound(l.add(x,y,z),Sound.BLOCK_STONE_BREAK, 1.0f, 1.0f); } l.add(x,y,z).getBlock().breakNaturally(); aPlugin.API.sendBlockBreakPacket(l.add(x,y,z).getBlock(), -1); diff --git a/src/sig/plugin/TwosideKeeper/CustomDamage.java b/src/sig/plugin/TwosideKeeper/CustomDamage.java index b12a2c0..64854fa 100644 --- a/src/sig/plugin/TwosideKeeper/CustomDamage.java +++ b/src/sig/plugin/TwosideKeeper/CustomDamage.java @@ -42,6 +42,7 @@ import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionType; import org.bukkit.util.Vector; +import sig.plugin.TwosideKeeper.Events.EntityDamagedEvent; import sig.plugin.TwosideKeeper.Events.PlayerDodgeEvent; import sig.plugin.TwosideKeeper.HelperStructures.ArtifactAbility; import sig.plugin.TwosideKeeper.HelperStructures.BowMode; @@ -51,6 +52,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.MonsterType; 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; public class CustomDamage { @@ -99,7 +101,7 @@ public class CustomDamage { *     IGNOREDODGE - Ignores all Dodge and invulnerability checks.
*     TRUEDMG - Ignores all additional calculations/reductions, applying the damage directly.
*
Combining flags example: CRITICALSTRIKE|IGNOREDODGE (Force a critical strike AND ignore invulnerability check) - * @return Whether or not this attack actually was applied. Returns false if it was dodged, nodamageticks, etc. + * @return Whether or not this attack actually was applied. Returns false if it was dodged, nodamageticks, cancelled, etc. */ static public boolean ApplyDamage(double damage, Entity damager, LivingEntity target, ItemStack weapon, String reason, int flags) { if (damage!=0.0 && weapon==null) { @@ -127,8 +129,15 @@ public class CustomDamage { if (damager!=null) { TwosideKeeper.logHealth(target,target.getHealth(),dmg,damager); } - DealDamageToEntity(dmg, damager, target, weapon, reason, flags); - addToLoggerTotal(damager,dmg); + EntityDamagedEvent ev = new EntityDamagedEvent(target,damager,dmg,reason,flags); + Bukkit.getPluginManager().callEvent(ev); + if (!ev.isCancelled()) { + //TwosideKeeper.log("Inside of here.", 0); + DealDamageToEntity(dmg, damager, target, weapon, reason, flags); + addToLoggerTotal(damager,dmg); + } else { + return false; + } return true; } else { return false; @@ -208,6 +217,7 @@ public class CustomDamage { dmg += addMultiplierToPlayerLogger(damager,target,"STRENGTH Mult",dmg * calculateStrengthEffectMultiplier(shooter,target)); dmg += addMultiplierToPlayerLogger(damager,target,"WEAKNESS Mult",dmg * calculateWeaknessEffectMultiplier(shooter,target)); dmg += addMultiplierToPlayerLogger(damager,target,"POISON Mult",dmg * calculatePoisonEffectMultiplier(target)); + dmg += addMultiplierToPlayerLogger(damager,target,"Airborne Mult",dmg * calculateAirborneAttackMultiplier(shooter)); double critdmg = addMultiplierToPlayerLogger(damager,target,"Critical Strike Mult",dmg * calculateCriticalStrikeMultiplier(weapon,shooter,target,reason,flags)); if (critdmg!=0.0) {crit=true; aPlugin.API.critEntity(target, 15);} @@ -231,6 +241,25 @@ public class CustomDamage { return dmg; } + private static double calculateAirborneAttackMultiplier(LivingEntity shooter) { + if (shooter==null) {return 0.0;} + if (shooter instanceof Player) { + Player p = (Player)shooter; + if (!p.isOnGround()) { + if (p.isSprinting()) { + return 0.2; + } else { + return -0.2; + } + } + } else { + if (!shooter.isOnGround()) { + return -0.2; + } + } + return 0.0; + } + private static double getDamageFromBarbarianSetBonus(LivingEntity target) { if (target instanceof Player) { Player p = (Player)target; @@ -282,12 +311,22 @@ public class CustomDamage { dmg += addToPlayerLogger(damager,target,"Strike",GenericFunctions.getAbilityValue(ArtifactAbility.DAMAGE, weapon)); dmg += addToPlayerLogger(damager,target,"Highwinder",calculateHighwinderDamage(weapon,damager)); dmg += addToPlayerLogger(damager,target,"Set Bonus",calculateSetBonusDamage(damager)); + dmg += addMultiplierToPlayerLogger(damager,target,"Party Bonus Mult",dmg * calculatePartyBonusMultiplier(damager)); dmg += addMultiplierToPlayerLogger(damager,target,"Set Bonus Mult",dmg * calculateSetBonusMultiplier(weapon,damager)); dmg += addMultiplierToPlayerLogger(damager,target,"Belligerent Mult",dmg * calculateBeliggerentMultiplier(weapon,damager)); } return dmg; } + private static double calculatePartyBonusMultiplier(Entity damager) { + if (getDamagerEntity(damager) instanceof Player) { + Player p = (Player)getDamagerEntity(damager); + PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + return pd.partybonus*0.1; + } + return 0.0; + } + public static void DealDamageToEntity(double damage, Entity damager, LivingEntity target, ItemStack weapon, String reason) { DealDamageToEntity(damage,damager,target,weapon,reason,0); @@ -381,6 +420,7 @@ public class CustomDamage { } increaseStrikerSpeed(p); healDefenderSaturation(p); + damage=increaseDamageDealtByFireTicks(p,damage,reason); reduceKnockback(p); reduceSwiftAegisBuff(p); if (damage=30 && (reason==null || !reason.equalsIgnoreCase("forceful strike")) && weapon.equals(p.getEquipment().getItemInMainHand())) { - p.playSound(p.getLocation(), Sound.BLOCK_WOOD_BUTTON_CLICK_ON, 3.0f, 0.6f); + SoundUtils.playGlobalSound(p.getLocation(), Sound.BLOCK_WOOD_BUTTON_CLICK_ON, 3.0f, 0.6f); //Apply 10 strikes across the field. dmg*=2; GenericFunctions.addSuppressionTime(target, 20*3); @@ -671,7 +711,7 @@ public class CustomDamage { Location attackloc = p.getLocation().clone(); for (int i=0;i<10;i++) { attackloc = attackloc.add(xspd,0,zspd); - p.playSound(p.getLocation(), Sound.ENTITY_ENDERDRAGON_FIREBALL_EXPLODE, 0.1f, 1.4f); + SoundUtils.playGlobalSound(p.getLocation(), Sound.ENTITY_ENDERDRAGON_FIREBALL_EXPLODE, 0.1f, 1.4f); aPlugin.API.sendSoundlessExplosion(attackloc, 0.6f); GenericFunctions.DealDamageToNearbyMobs(attackloc, dmg, 1, true, 0.6, p, weapon, false, "Forceful Strike"); } @@ -906,7 +946,7 @@ public class CustomDamage { LivingEntity mon = (LivingEntity)finallist.get(i); //double finaldmg = CalculateDamageReduction(GenericFunctions.getAbilityValue(ArtifactAbility.ERUPTION, p.getEquipment().getItemInMainHand()),mon,null); //GenericFunctions.DealDamageToMob(finaldmg, mon, p, p.getEquipment().getItemInMainHand()); - TwosideKeeperAPI.removeNoDamageTick(p, (Monster)target); + TwosideKeeperAPI.removeNoDamageTick(p, (LivingEntity)mon); CustomDamage.ApplyDamage(GenericFunctions.getAbilityValue(ArtifactAbility.ERUPTION, weapon), p,mon,null,"Eruption",CustomDamage.NONE); mon.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,20,15)); @@ -923,12 +963,12 @@ public class CustomDamage { //b.breakNaturally(); b.setType(Material.AIR); aPlugin.API.sendSoundlessExplosion(b.getLocation(), 1); - p.playSound(mon.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1.0f, 1.0f); + SoundUtils.playGlobalSound(mon.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1.0f, 1.0f); } } } } - p.playSound(p.getLocation(), Sound.ENTITY_FIREWORK_LARGE_BLAST, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_FIREWORK_LARGE_BLAST, 1.0f, 1.0f); aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), 100); pd.last_shovelspell=TwosideKeeper.getServerTickTime()+GenericFunctions.GetModifiedCooldown(TwosideKeeper.ERUPTION_COOLDOWN,p); @@ -1074,10 +1114,10 @@ public class CustomDamage { public static void increaseArtifactArmorXP(Player p, int exp) { if (p.getHealth()>0) { - for (int i=0;i=9) { - p.playSound(p.getLocation(), Sound.BLOCK_ANVIL_LAND, 0.3f, 3.6f); + SoundUtils.playLocalSound(p, Sound.BLOCK_ANVIL_LAND, 0.3f, 3.6f); return false; } } @@ -1334,7 +1378,7 @@ public class CustomDamage { dodgechance+=0.2; } if (PlayerMode.isRanger(p)) { - dodgechance+=0.5; + dodgechance+=0.4; } if (dodgechance>0.95) { @@ -1410,13 +1454,13 @@ public class CustomDamage { case CHAINMAIL_LEGGINGS: case CHAINMAIL_CHESTPLATE: case CHAINMAIL_HELMET: { - dmgreduction+=3*((isBlockArmor)?2:1); + dmgreduction+=6*((isBlockArmor)?2:1); }break; case IRON_BOOTS: case IRON_LEGGINGS: case IRON_CHESTPLATE: case IRON_HELMET: { - dmgreduction+=5*((isBlockArmor)?2:1); + dmgreduction+=7*((isBlockArmor)?2:1); }break; case GOLD_BOOTS: case GOLD_LEGGINGS: @@ -1469,7 +1513,7 @@ public class CustomDamage { if (target instanceof Player) { Player p = (Player)target; PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); - partylevel = pd.partybonus; + partylevel = pd.partybonus; if (partylevel>9) {partylevel=9;} if (p.getLocation().getY()>=0) {TwosideKeeper.log("Light level: "+p.getLocation().add(0,0,0).getBlock().getLightLevel(),5);} for (int i=0;i
+ * This event is cancellable. Cancelling the event prevents the damage from being applied to the damaged entity and all on-hit effects will not apply. + * @param ent The entity being damaged. + * @param damager The entity that caused the damage, can be null. + * @param damage The amount of actual damage taken, after all calculations are applied. + * @param reason The reason the damage was taken. + * @param flags The flags set by this event. + */ + public EntityDamagedEvent(LivingEntity ent, Entity damager, double damage, String reason, int flags) { + this.ent=ent; + this.damager=damager; + this.damage=damage; + this.reason=reason; + this.flags=flags; + } + + @Override + public boolean isCancelled() { + // TODO Auto-generated method stub + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancelled) { + this.cancelled=cancelled; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + +} diff --git a/src/sig/plugin/TwosideKeeper/Events/PlayerDodgeEvent.java b/src/sig/plugin/TwosideKeeper/Events/PlayerDodgeEvent.java index 3b8ea31..12bc68e 100644 --- a/src/sig/plugin/TwosideKeeper/Events/PlayerDodgeEvent.java +++ b/src/sig/plugin/TwosideKeeper/Events/PlayerDodgeEvent.java @@ -12,7 +12,7 @@ public class PlayerDodgeEvent extends Event implements Cancellable{ private Entity damager; private String reason; private int flags; - private boolean cancelled; + private boolean cancelled=false; private static final HandlerList handlers = new HandlerList(); public PlayerDodgeEvent(Player p, Entity damager, String reason, int flags) { diff --git a/src/sig/plugin/TwosideKeeper/Events/PlayerLineDriveEvent.java b/src/sig/plugin/TwosideKeeper/Events/PlayerLineDriveEvent.java index c6e688b..6493960 100644 --- a/src/sig/plugin/TwosideKeeper/Events/PlayerLineDriveEvent.java +++ b/src/sig/plugin/TwosideKeeper/Events/PlayerLineDriveEvent.java @@ -7,7 +7,7 @@ import org.bukkit.event.HandlerList; public final class PlayerLineDriveEvent extends Event implements Cancellable{ private Player p; - private boolean cancelled; + private boolean cancelled=false; private static final HandlerList handlers = new HandlerList(); public PlayerLineDriveEvent(Player p) { diff --git a/src/sig/plugin/TwosideKeeper/Events/PlayerTumbleEvent.java b/src/sig/plugin/TwosideKeeper/Events/PlayerTumbleEvent.java index 71fb171..79c2246 100644 --- a/src/sig/plugin/TwosideKeeper/Events/PlayerTumbleEvent.java +++ b/src/sig/plugin/TwosideKeeper/Events/PlayerTumbleEvent.java @@ -7,7 +7,7 @@ import org.bukkit.event.HandlerList; public class PlayerTumbleEvent extends Event implements Cancellable{ private Player p; - private boolean cancelled; + private boolean cancelled=false; private static final HandlerList handlers = new HandlerList(); public PlayerTumbleEvent(Player p) { diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java b/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java index cc3c9a3..509cea6 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java @@ -114,12 +114,12 @@ public enum ArtifactAbility { new double[]{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0},10,10,UpgradePath.ALL), /*GROWTH("Growth",ChatColor.GRAY+"[Unimplemented] Increases artifact EXP gained by [VAL]% . Health is halved, health regeneration is halved, and damage reduction is halved. Consumes one level of Growth per level up.",new double[]{100,100,100,100,100,100,100,100,100,100}, new double[]{2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0},100,1000,UpgradePath.ALL),*/ - REMOVE_CURSE("Remove Curse",ChatColor.GRAY+"[Unimplemented] Removes a level of a curse from the Artifact.",new double[]{-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0}, - new double[]{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0},1,1000,UpgradePath.ALL), + REMOVE_CURSE("Remove Curse",ChatColor.GRAY+"[Unimplemented] Removes a level of a curse from the Artifact.",new double[]{-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0}, + new double[]{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0},1,1000,UpgradePath.ALL), PRESERVATION("Preservation","Potential decays [VAL]% slower.",new double[]{1.0,1.25,1.5,1.75,2.0,2.25,2.5,2.75,3.0,3.25,3.50,3.75,4.0,4.25,4.5}, - new double[]{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0},20,1,UpgradePath.ALL), - EXP_MULT("Mega XP",ChatColor.GRAY+"[Unimplemented] Increases experience dropped from monsters by [VAL]% .",new double[]{5,5,5,5,5,5,5,5,5,5}, - new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,1000,UpgradePath.ALL), + new double[]{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0},20,1,UpgradePath.ALL), + EXP_MULT("Mega XP",ChatColor.GRAY+"[Unimplemented] Increases experience dropped from monsters by [VAL]% .",new double[]{5,5,5,5,5,5,5,5,5,5,5,5,5,5,5}, + new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,1000,UpgradePath.ALL), //Bad stuff REDUCEDMG("Weakness","[VAL]% Decrease in Base Damage.",new double[]{8,8,8,8,8,8,8,8,8,8}, diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java index 70f6732..0403c9a 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java @@ -80,6 +80,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.EliteMonsterLocationFinder; import sig.plugin.TwosideKeeper.HelperStructures.ItemSet; import sig.plugin.TwosideKeeper.HelperStructures.PlayerMode; import sig.plugin.TwosideKeeper.HelperStructures.WorldShop; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils; public class GenericFunctions { @@ -120,7 +121,7 @@ public class GenericFunctions { p.sendMessage(ChatColor.GOLD+"WARNING!"+ChatColor.GREEN+ " Your "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(item)+ChatColor.WHITE+" is going to break soon! You should let it recharge by waiting 24 hours!"); } if (p!=null) { - p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); } return breakObscureHardenedItem(item); } else { @@ -140,14 +141,14 @@ public class GenericFunctions { break_count--; if (p!=null && break_count==0) { p.sendMessage(ChatColor.GOLD+"WARNING!"+ChatColor.GREEN+ " Your "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(item)+ChatColor.WHITE+" is going to break soon!"); - p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); } return item; //By setting the amount to 1, you refresh the item in the player's inventory. } else { //This item is technically destroyed. if (p!=null) { - p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); } if (isArtifactEquip(item)) { //We can turn it into dust! @@ -2757,12 +2758,12 @@ public class GenericFunctions { if (!ev.isCancelled()) { pd.last_dodge=TwosideKeeper.getServerTickTime(); aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), 100); - p.playSound(p.getLocation(), Sound.ENTITY_DONKEY_CHEST, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_DONKEY_CHEST, 1.0f, 1.0f); int dodgeduration = 20; if (GenericFunctions.HasFullRangerSet(p)) { - dodgeduration=60; + dodgeduration = 30; } if (p.isSneaking()) { //Do a backwards dodge + jump. @@ -3010,7 +3011,7 @@ public class GenericFunctions { public static void PerformRejuvenate(Player player) { PlayerStructure pd = (PlayerStructure)TwosideKeeper.playerdata.get(player.getUniqueId()); if (pd.last_rejuvenate+GetModifiedCooldown(TwosideKeeper.REJUVENATE_COOLDOWN,player)<=TwosideKeeper.getServerTickTime()) { - player.playSound(player.getLocation(), Sound.ENTITY_ZOMBIE_VILLAGER_CURE, 1.0f, 1.0f); + SoundUtils.playGlobalSound(player.getLocation(), Sound.ENTITY_ZOMBIE_VILLAGER_CURE, 1.0f, 1.0f); addIFrame(player,40); GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.REGENERATION,200,9,player,true); aPlugin.API.sendCooldownPacket(player, player.getEquipment().getItemInMainHand(), GetModifiedCooldown(TwosideKeeper.REJUVENATE_COOLDOWN,player)); @@ -3149,6 +3150,10 @@ public class GenericFunctions { public static void updateSetItemsInInventory(Inventory inv) { TwosideKeeper.log("Inventory is size "+inv.getSize(),5); + if (inv.getHolder() instanceof Player) { + Player p = (Player)inv.getHolder(); + for (ItemStack armor : GenericFunctions.getEquipment(p)) {GenericFunctions.UpdateArtifactItemType(armor);} + } for (ItemStack it : inv.getContents()) { if (it!=null) { TwosideKeeper.log("Checking "+it.toString(), 5); @@ -3204,7 +3209,7 @@ public class GenericFunctions { public static void UpdateArtifactItemType(ItemStack item) { if (isArtifactArmor(item) && item.getType()!=Material.SULPHUR) { - double durabilityratio = item.getDurability()/item.getType().getMaxDurability(); + double durabilityratio = (double)item.getDurability()/item.getType().getMaxDurability(); item.setType(Material.valueOf("LEATHER_"+item.getType().name().split("_")[1])); item.setDurability((short)(durabilityratio*item.getType().getMaxDurability())); UpdateDisplayedEnchantments(item); @@ -3454,7 +3459,7 @@ public class GenericFunctions { } } p.getInventory().setItem(i, new ItemStack(Material.AIR)); - p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); p.sendMessage(ChatColor.GOLD+""+ChatColor.BOLD+"Unlucky! "+ChatColor.RESET+ChatColor.DARK_RED+"Your "+ChatColor.YELLOW+((item.hasItemMeta() && item.getItemMeta().hasDisplayName())?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item))+ChatColor.DARK_RED+" has broken!"); } @@ -3472,7 +3477,7 @@ public class GenericFunctions { private static void RevivePlayer(Player p, double healdmg) { p.setHealth(healdmg); - p.playSound(p.getLocation(), Sound.BLOCK_REDSTONE_TORCH_BURNOUT, 1.0f, 1.5f); + SoundUtils.playLocalSound(p, Sound.BLOCK_REDSTONE_TORCH_BURNOUT, 1.0f, 1.5f); for (PotionEffect eff : p.getActivePotionEffects()) { if (isBadEffect(eff.getType())) { Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, @@ -3541,28 +3546,28 @@ public class GenericFunctions { case LEATHER_CHESTPLATE: case LEATHER_LEGGINGS: case LEATHER_BOOTS:{ - p.playSound(p.getLocation(), Sound.ITEM_ARMOR_EQUIP_LEATHER, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ITEM_ARMOR_EQUIP_LEATHER, 1.0f, 1.0f); }break; case IRON_HELMET: case IRON_CHESTPLATE: case IRON_LEGGINGS: case IRON_BOOTS:{ - p.playSound(p.getLocation(), Sound.ITEM_ARMOR_EQUIP_IRON, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ITEM_ARMOR_EQUIP_IRON, 1.0f, 1.0f); }break; case GOLD_HELMET: case GOLD_CHESTPLATE: case GOLD_LEGGINGS: case GOLD_BOOTS:{ - p.playSound(p.getLocation(), Sound.ITEM_ARMOR_EQUIP_GOLD, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ITEM_ARMOR_EQUIP_GOLD, 1.0f, 1.0f); }break; case DIAMOND_HELMET: case DIAMOND_CHESTPLATE: case DIAMOND_LEGGINGS: case DIAMOND_BOOTS:{ - p.playSound(p.getLocation(), Sound.ITEM_ARMOR_EQUIP_DIAMOND, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ITEM_ARMOR_EQUIP_DIAMOND, 1.0f, 1.0f); }break; default:{ - p.playSound(p.getLocation(), Sound.ITEM_ARMOR_EQUIP_GENERIC, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ITEM_ARMOR_EQUIP_GENERIC, 1.0f, 1.0f); } } } @@ -3772,7 +3777,10 @@ public class GenericFunctions { private static boolean isNaturalBlock(Block b) { if (b.getType()==Material.DIRT || + b.getType()==Material.SOIL || + b.getType()==Material.MYCEL || b.getType()==Material.SAND || + b.getType()==Material.SANDSTONE || b.getType()==Material.AIR || b.getType()==Material.CLAY || b.getType()==Material.GRASS || @@ -3791,6 +3799,8 @@ public class GenericFunctions { b.getType()==Material.STATIONARY_WATER ||*/ b.getType()==Material.SNOW || b.getType()==Material.ICE || + b.getType()==Material.LONG_GRASS || + b.getType()==Material.YELLOW_FLOWER || b.getType()==Material.PACKED_ICE) { return true; } @@ -4111,13 +4121,13 @@ public class GenericFunctions { public static void applyStealth(Player p, boolean blindness_effect) { GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 111, p, true); if (blindness_effect) {GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.BLINDNESS, 20*2, 111, p);} - p.playSound(p.getLocation(), Sound.ENTITY_GENERIC_EXTINGUISH_FIRE, 1.0f, 0.5f); + SoundUtils.playLocalSound(p, Sound.ENTITY_GENERIC_EXTINGUISH_FIRE, 1.0f, 0.5f); } public static void removeStealth(Player p) { GenericFunctions.logAndRemovePotionEffectFromEntity(PotionEffectType.INVISIBILITY, p); GenericFunctions.addIFrame(p, 10); - p.playSound(p.getLocation(), Sound.BLOCK_REDSTONE_TORCH_BURNOUT, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.BLOCK_REDSTONE_TORCH_BURNOUT, 1.0f, 1.0f); } public static boolean hasStealth(Player p) { @@ -4147,7 +4157,7 @@ public class GenericFunctions { aPlugin.API.sendCooldownPacket(p, weaponused, GetModifiedCooldown(TwosideKeeper.LINEDRIVE_COOLDOWN,p)); pd.last_strikerspell=TwosideKeeper.getServerTickTime(); } - p.playSound(p.getLocation(), Sound.UI_BUTTON_CLICK, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.UI_BUTTON_CLICK, 1.0f, 1.0f); aPlugin.API.damageItem(p, weaponused, (weaponused.getType().getMaxDurability()/10)+7); final Player p1 = p; @@ -4165,7 +4175,7 @@ public class GenericFunctions { public void run() { p.setVelocity(facing1.multiply(8)); addIFrame(p, 10); - p.playSound(p.getLocation(), Sound.ITEM_CHORUS_FRUIT_TELEPORT, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ITEM_CHORUS_FRUIT_TELEPORT, 1.0f, 1.0f); final Location newpos=new Location(p.getWorld(),xpos,ypos,zpos); double dmgdealt=CustomDamage.getBaseWeaponDamage(weaponused, p, null); //List monsters = getNearbyMobs(newpos, 2); @@ -4179,7 +4189,7 @@ public class GenericFunctions { } DealDamageToNearbyMobs(newpos, dmgdealt, 2, true, 0.8d, p, weaponused, true); //DecimalFormat df = new DecimalFormat("0.00"); - p.playSound(p.getLocation(), Sound.ENTITY_ARMORSTAND_HIT, 1.0f, 0.5f); + SoundUtils.playGlobalSound(p.getLocation(), Sound.ENTITY_ARMORSTAND_HIT, 1.0f, 0.5f); int range=8; for (int i=0;i0) { pd.last_siphon=TwosideKeeper.getServerTickTime(); - p.playSound(p.getLocation(), Sound.BLOCK_FENCE_GATE_OPEN, 1.0f, 0.4f); + SoundUtils.playLocalSound(p, Sound.BLOCK_FENCE_GATE_OPEN, 1.0f, 0.4f); aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), GetModifiedCooldown(TwosideKeeper.SIPHON_COOLDOWN,p)); for (LivingEntity ent : poisonlist) { //Refresh poison stacks if necessary. @@ -4650,5 +4660,33 @@ public class GenericFunctions { } } + public static void PopulatePlayerBlockList(Player p, int width, int length, int up, int down, boolean includeCurrentYLayer) { + PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + if (pd.lastStandingLoc==null || + ( + !p.getLocation().getWorld().equals(pd.lastStandingLoc.getWorld()) || + p.getLocation().getX()!=pd.lastStandingLoc.getX() || + p.getLocation().getZ()!=pd.lastStandingLoc.getZ() + ) + ) { + pd.lastStandingLoc=new Location(p.getLocation().getWorld(),p.getLocation().getX(),p.getLocation().getY(),p.getLocation().getZ()); + pd.blockscanlist.clear(); + for (int x=-width;x<=width;x++) { + for (int z=-length;z<=length;z++) { + for (int y=-down;y<=up;y++) { + //pd.blockscanlist.add(pd.lastStandingLoc.add(x,y,z).getBlock()); + Block b = pd.lastStandingLoc.add(x,y,z).getBlock(); + pd.blockscanlist.put(b.getType(), b); + TwosideKeeper.log("("+x+","+y+","+z+")"+"Added "+b.getType()+" to block list for player "+p.getName(), 0); + } + } + } + } + } + + public static HashMap GetPlayerBlockList(Player p) { + PopulatePlayerBlockList(p,15,15,2,5,false); + return PlayerStructure.GetPlayerStructure(p).blockscanlist; + } } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/RecipeLinker.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/RecipeLinker.java index 75fda26..d6f0e5b 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/RecipeLinker.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/RecipeLinker.java @@ -35,7 +35,7 @@ public enum RecipeLinker { CustomItem.EnderItemCube(2), CustomItem.EnderItemCube(),new ItemStack(Material.NETHER_STAR) }), - aq(RecipeCategory.MISC_ITEMS,ChatColor.RED,"Arrow Quiver",new ItemStack[]{ + aq(RecipeCategory.CONTAINERS,ChatColor.RED,"Arrow Quiver",new ItemStack[]{ CustomItem.ArrowQuiver(), null,new ItemStack(Material.LEATHER),new ItemStack(Material.EMERALD_BLOCK), new ItemStack(Material.LEATHER),new ItemStack(Material.SPECTRAL_ARROW),new ItemStack(Material.LEATHER), diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/CustomItem.java b/src/sig/plugin/TwosideKeeper/HelperStructures/CustomItem.java index 73dec33..9f8550b 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/CustomItem.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/CustomItem.java @@ -368,7 +368,6 @@ public class CustomItem { ArrowQuiver.setIngredient('l', Material.LEATHER); ArrowQuiver.setIngredient('e', Material.EMERALD_BLOCK); - return ArrowQuiver; } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Effects/LavaPlume.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Effects/LavaPlume.java new file mode 100644 index 0000000..5d9870b --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Effects/LavaPlume.java @@ -0,0 +1,129 @@ +package sig.plugin.TwosideKeeper.HelperStructures.Effects; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.Player; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.util.Vector; +import org.inventivetalent.glow.GlowAPI; + +import net.minecraft.server.v1_9_R1.EnumParticle; +import sig.plugin.TwosideKeeper.TwosideKeeper; +import sig.plugin.TwosideKeeper.aPluginAPIWrapper; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils; + +public class LavaPlume { + FallingBlock fb; + int lavayreached; + int delaytimer; + Location lavaplumeloc; + List lavablocks; + boolean negativevel=false; + boolean state1=true,state2=true,state3=true,state4=true; + /** + * + * @param delay Delay in ticks. + */ + public LavaPlume(int delay, Location loc) { + //this.fb=fb; + this.lavablocks=new ArrayList(); + //this.lavayreached=fb.getLocation().getBlockY(); + this.delaytimer=(int)((delay/20d)*4); + this.lavaplumeloc = loc.clone().add(0,1,0); + } + /* + * Returns false if this block is invalid. + */ + public boolean runTick() { + if (this.delaytimer>=0) { + this.delaytimer--; + if (this.delaytimer!=0) { + aPluginAPIWrapper.sendParticle(this.lavaplumeloc.clone().add(0,Math.random()*5,0), EnumParticle.DRIP_LAVA, (float)Math.random(),(float)Math.random(),(float)Math.random(), (float)Math.random(), 10); + } else { + FallingBlock fallblock = this.lavaplumeloc.clone().getWorld().spawnFallingBlock(this.lavaplumeloc.clone().add(0,1,0), Material.REDSTONE_BLOCK, (byte)0); + fallblock.setMetadata("DESTROY", new FixedMetadataValue(TwosideKeeper.plugin,true)); + fallblock.setVelocity(new Vector(0,(float)((Math.random()*2)+2),0)); + for (Player pl : Bukkit.getOnlinePlayers()) { + GlowAPI.setGlowing(fallblock, GlowAPI.Color.YELLOW, pl); + } + this.fb = fallblock; + this.lavayreached = this.lavaplumeloc.getBlockY(); + return RunLavaTick(); + } + return true; + } + else { + return RunLavaTick(); + } + } + private boolean RunLavaTick() { + for (TemporaryLava tl : lavablocks) { + if (!tl.runTick()) { + TwosideKeeper.ScheduleRemoval(lavablocks, tl); + } + } + if (fb==null || !fb.isValid()) { + //Load up the chunk and see if we can remove it. + if (this.lavablocks.size()>0) { + return true; + } else { + //Cleared for official deleting. + if (!fb.isValid()) { + fb.remove(); + } + return false; + } + } else { + if (fb.getLocation().getY()>lavayreached) { + for (int y=lavayreached;y blocklist = new ArrayList(); + int rely = (int)(y-fb.getLocation().getY()); + if (state1 && !UpdateLavaBlock(fb.getLocation().add(1,rely,0).getBlock())) {state1=false;} + if (state2 && !UpdateLavaBlock(fb.getLocation().add(-1,rely,0).getBlock())) {state2=false;} + if (state3 && !UpdateLavaBlock(fb.getLocation().add(0,rely,1).getBlock())) {state3=false;} + if (state4 && !UpdateLavaBlock(fb.getLocation().add(0,rely,-1).getBlock())) {state4=false;} + } + lavayreached=(int)fb.getLocation().getY(); + } else + if (fb.getVelocity().getY()<0) { + fb.remove(); + } + return true; + } + } + + private boolean UpdateLavaBlock(Block lavamod) { + if (lavamod.getType()==Material.AIR || lavamod.getType()==Material.LAVA) { + if (lavamod.getType()==Material.AIR) { + lavamod.setType(Material.LAVA); + lavamod.setData((byte)8); + } + this.lavablocks.add(new TemporaryLava(lavamod,(int)(3*fb.getVelocity().getY())+6)); + SoundUtils.playGlobalSound(fb.getLocation(), Sound.BLOCK_LAVA_POP, 1.0f, 1.0f); + return true; + } else { + //TwosideKeeper.log("Triggered for type "+lavamod.getType(), 0); + return false; + } + } + + public void Cleanup() { + //Delete the falling block associated with itself. + if (fb!=null) { + fb.remove(); + } + //Delete all Temporary Lava associated with this lava plume. + for (TemporaryLava tl : lavablocks) { + tl.Cleanup(); + } + } +} diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Effects/TemporaryLava.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Effects/TemporaryLava.java new file mode 100644 index 0000000..0ceef35 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Effects/TemporaryLava.java @@ -0,0 +1,40 @@ +package sig.plugin.TwosideKeeper.HelperStructures.Effects; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.block.Block; + +import sig.plugin.TwosideKeeper.TwosideKeeper; + +public class TemporaryLava { + Block b; + int ttl; //Time-to-Live. When this expires it dies. + public TemporaryLava(Block b, int timer) { + this.b=b; + this.ttl=timer; + } + public boolean runTick() { + this.ttl--; + if (this.ttl<=0) { + ResetBlock(); + return false; + } else { + return true; + } + } + private void ResetBlock() { + if (b.getType()==Material.LAVA || b.getType()==Material.STATIONARY_LAVA) { + b.setType(Material.AIR); + } + } + private void ClearLavaBlock(Block b2) { + if (b.getType()==Material.LAVA || b.getType()==Material.STATIONARY_LAVA) { + b.setType(Material.AIR); + } + } + public void Cleanup() { + ResetBlock(); + } +} diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/EliteMonsterLocationFinder.java b/src/sig/plugin/TwosideKeeper/HelperStructures/EliteMonsterLocationFinder.java index e0fac9d..25be0d9 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/EliteMonsterLocationFinder.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/EliteMonsterLocationFinder.java @@ -25,10 +25,10 @@ public class EliteMonsterLocationFinder implements Runnable{ public void run() { TwosideKeeper.ELITE_LOCATION = GenericFunctions.defineNewEliteLocation(); if (TwosideKeeper.ELITE_LOCATION==null) { - Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new EliteMonsterLocationFinder(p,name), 20l); + Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new EliteMonsterLocationFinder(p,name), 10l); if (p!=null) { PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); - if ((pd.lastcompassnotification+(20*10)) 3 seconds"); + lore.add(ChatColor.GRAY+" 1 -> 1.5 seconds"); lore.add(ChatColor.GRAY+" "+ChatColor.WHITE+"Sniper Mode:"); lore.add(ChatColor.GRAY+" Increases Critical Damage by +100%"); lore.add(ChatColor.GRAY+" "+ChatColor.WHITE+"Debilitation Mode:"); @@ -356,7 +356,7 @@ public enum ItemSet { lore.add(ChatColor.DARK_AQUA+" 5 - "+ChatColor.WHITE+" Boosts All Modes of Ranger"); lore.add(ChatColor.GRAY+" "+ChatColor.WHITE+"Close Range Mode:"); lore.add(ChatColor.GRAY+" Increases Tumble Invincibility from"); - lore.add(ChatColor.GRAY+" 1 -> 3 seconds"); + lore.add(ChatColor.GRAY+" 1 -> 1.5 seconds"); lore.add(ChatColor.GRAY+" "+ChatColor.WHITE+"Sniper Mode:"); lore.add(ChatColor.GRAY+" Increases Critical Damage by +100%"); lore.add(ChatColor.GRAY+" "+ChatColor.WHITE+"Debilitation Mode:"); @@ -370,7 +370,7 @@ public enum ItemSet { lore.add(ChatColor.DARK_AQUA+" 5 - "+ChatColor.WHITE+" Boosts All Modes of Ranger"); lore.add(ChatColor.GRAY+" "+ChatColor.WHITE+"Close Range Mode:"); lore.add(ChatColor.GRAY+" Increases Tumble Invincibility from"); - lore.add(ChatColor.GRAY+" 1 -> 3 seconds"); + lore.add(ChatColor.GRAY+" 1 -> 1.5 seconds"); lore.add(ChatColor.GRAY+" "+ChatColor.WHITE+"Sniper Mode:"); lore.add(ChatColor.GRAY+" Increases Critical Damage by +100%"); lore.add(ChatColor.GRAY+" "+ChatColor.WHITE+"Debilitation Mode:"); @@ -385,7 +385,7 @@ public enum ItemSet { lore.add(ChatColor.DARK_AQUA+" 5 - "+ChatColor.WHITE+" Boosts All Modes of Ranger"); lore.add(ChatColor.GRAY+" "+ChatColor.WHITE+"Close Range Mode:"); lore.add(ChatColor.GRAY+" Increases Tumble Invincibility from"); - lore.add(ChatColor.GRAY+" 1 -> 3 seconds"); + lore.add(ChatColor.GRAY+" 1 -> 1.5 seconds"); lore.add(ChatColor.GRAY+" "+ChatColor.WHITE+"Sniper Mode:"); lore.add(ChatColor.GRAY+" Increases Critical Damage by +100%"); lore.add(ChatColor.GRAY+" "+ChatColor.WHITE+"Debilitation Mode:"); diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Loot.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Loot.java index e0d296f..2f6b9f6 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Loot.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Loot.java @@ -33,12 +33,13 @@ public class Loot { public static void DefineLootChests() { aPlugin.API.Chests.LOOT_NORMAL.addDrop(new DropMaterial(Material.STONE_SWORD,8)); aPlugin.API.Chests.LOOT_NORMAL.addDrop(new DropItem(Artifact.createArtifactItem(ArtifactItem.MYSTERIOUS_ESSENCE),11)); - aPlugin.API.Chests.LOOT_NORMAL.addDrop(new DropMaterial(Material.COAL,101)); + //aPlugin.API.Chests.LOOT_NORMAL.addDrop(new DropMaterial(Material.AIR,101)); + aPlugin.API.Chests.LOOT_NORMAL.addDrop(new DropMaterial(Material.COAL,20)); aPlugin.API.Chests.LOOT_NORMAL.addDrop(new DropMaterial(Material.IRON_INGOT,1,17)); aPlugin.API.Chests.LOOT_NORMAL.addDrop(new DropMaterial(Material.DIAMOND,1,18)); aPlugin.API.Chests.LOOT_NORMAL.addDrop(new DropMaterial(Material.GOLD_NUGGET,1,17)); aPlugin.API.Chests.LOOT_NORMAL.addDrop(new DropMaterial(Material.ENDER_PEARL,1,8)); - aPlugin.API.Chests.LOOT_NORMAL.addDrop(new DropMaterial(Material.ENDER_CHEST,19)); + aPlugin.API.Chests.LOOT_NORMAL.addDrop(new DropMaterial(Material.ENDER_CHEST,4)); aPlugin.API.Chests.LOOT_NORMAL.addDrop(new DropItem(Artifact.createArtifactItem(ArtifactItem.ARTIFACT_CORE),4)); aPlugin.API.Chests.LOOT_NORMAL.addDrop(new SigDrop(1,18,"[Normal] Mega Armor",SigDrop.NONHARDENED,SigDrop.NONSET,SigDrop.ARMOR,MonsterDifficulty.NORMAL)); aPlugin.API.Chests.LOOT_NORMAL.addDrop(new SigDrop(1,19,"[Normal] Mega Set Armor",SigDrop.NONHARDENED,SigDrop.SET,SigDrop.ARMOR,MonsterDifficulty.NORMAL)); @@ -543,54 +544,38 @@ public class Loot { case JAMDAK:{ if (item.getType().toString().contains("SWORD")) { item.setType(Material.BOW); - tierbonus/=(custom)?1:2; } else if (!item.getType().toString().contains("LEATHER")) { allowed = false; } set_name = prefix+"Jamdak Ranger "+GenericFunctions.UserFriendlyMaterialName(item.getType()); - if (Math.random()<=0.5 && tierbonus<2) { - tierbonus+=(custom)?0:2; - } }break; case DARNYS:{ if (item.getType().toString().contains("SWORD")) { item.setType(Material.BOW); - tierbonus/=(custom)?1:2; } else if (!item.getType().toString().contains("LEATHER")) { allowed = false; } set_name = prefix+"Darnys Ranger "+GenericFunctions.UserFriendlyMaterialName(item.getType()); - if (Math.random()<=0.5 && tierbonus<1) { - tierbonus+=(custom)?0:1; - } }break; case ALIKAHN:{ if (item.getType().toString().contains("SWORD")) { item.setType(Material.BOW); - tierbonus/=(custom)?1:2; } else if (!item.getType().toString().contains("LEATHER")) { allowed = false; } set_name = prefix+"Alikahn Ranger "+GenericFunctions.UserFriendlyMaterialName(item.getType()); - if (Math.random()<=0.1 && tierbonus<1) { - tierbonus+=(custom)?0:1; - } }break; case LORASAADI:{ if (item.getType().toString().contains("SWORD")) { item.setType(Material.BOW); - tierbonus/=(custom)?1:2; } else if (!item.getType().toString().contains("LEATHER")) { allowed = false; } set_name = prefix+"Lorasaadi Ranger "+GenericFunctions.UserFriendlyMaterialName(item.getType()); - if (tierbonus>0 && Math.random()<=0.5) { - tierbonus=(custom)?tierbonus:0; - } }break; case GLADOMAIN:{ //item.setType(Material.SKULL_ITEM); else diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterDifficulty.java b/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterDifficulty.java index 929d54c..08bfdac 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterDifficulty.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterDifficulty.java @@ -54,7 +54,7 @@ public enum MonsterDifficulty { Player p = (Player)CustomDamage.getDamagerEntity(damager); for (int i=0;iPlayers are identified as 'Rangers' when they carry a bow or a quiver in one of their hands. 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 x2->x4.\n" - + ChatColor.GRAY+"->You can dodge 50% of all incoming attacks from any damage sources.\n" + + ChatColor.GRAY+"->You can dodge 40% 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" @@ -60,7 +60,6 @@ public enum PlayerMode { + ChatColor.GRAY+"->Barbarians swing their off-hand by right-clicking.\n" + ChatColor.WHITE+"->Barbarians gain 2 HP (1 Heart) per 1% of Damage reduction.\n" + ChatColor.GRAY+"->When Barbarians are hit, they take damage as if they had 0% Damage reduction.\n" - + ChatColor.WHITE+"->Players are identified as 'Slayers' by wearing no armor, and wearing a Bauble in their hotbar.\n" + ChatColor.GRAY+"->Barbarians deal 20% more damage for every 20% of an enemy's missing health.\n" + ChatColor.WHITE+"->Barbarians gain Bonus Lifesteal stacks as they hit enemies. Each stack increases Lifesteal by 1%, up to a cap of 100% extra Lifesteal. The stacks refresh every hit, but wear off after 5 seconds.\n" + ChatColor.GRAY+"->Barbarians do not instantly take full damage when hit. Instead, the HP is stored in a 'Damage Pool' and distributed every second.\n" diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemUtils.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemUtils.java new file mode 100644 index 0000000..64fd92e --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/ItemUtils.java @@ -0,0 +1,36 @@ +package sig.plugin.TwosideKeeper.HelperStructures.Utils; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class ItemUtils { + + public static void addLore(ItemStack item, String string) { + ItemMeta m = item.getItemMeta(); + List lore = new ArrayList(); + if (m.hasLore()) { + lore.addAll(m.getLore()); + } + lore.add(string); + m.setLore(lore); + item.setItemMeta(m); + } + + public static void hideEnchantments(ItemStack item) { + ItemMeta m = item.getItemMeta(); + m.addItemFlags(ItemFlag.HIDE_ENCHANTS); + item.setItemMeta(m); + } + + public static void showEnchantments(ItemStack item) { + ItemMeta m = item.getItemMeta(); + m.removeItemFlags(ItemFlag.HIDE_ENCHANTS); + item.setItemMeta(m); + } + +} diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/SoundUtils.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/SoundUtils.java new file mode 100644 index 0000000..d62aea2 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/SoundUtils.java @@ -0,0 +1,45 @@ +package sig.plugin.TwosideKeeper.HelperStructures.Utils; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +public class SoundUtils { + + /** + * Plays a sound to everyone in the world. Nearby players should be able to hear it. + */ + public static void playGlobalSound(Location loc, Sound sound, float vol, float pitch) { + loc.getWorld().playSound(loc, sound, vol, pitch); + } + /** + * Same as playGlobalSound. Just done for every single player locally. + */ + public static void playIndividualGlobalSound(Location loc, Sound sound, float vol, float pitch) { + for (Player p : Bukkit.getOnlinePlayers()) { + p.playSound(loc, sound, vol, pitch); + } + } + /** + * Plays a sound at the player's location, as if they were hearing a regular sound in the client. + */ + public static void playLocalSound(Player p, Sound sound, float vol, float pitch) { + SoundUtils.playLocalSound(p,p.getLocation(), sound, vol, pitch); + } + /** + * Plays a sound at the specified location for a single player, as if they were hearing a regular sound in the client. + */ + public static void playLocalSound(Player p, Location loc, Sound sound, float vol, float pitch) { + p.playSound(loc, sound, vol, pitch); + } + /** + * Plays a sound at the player's location for every player, as if they were hearing a regular sound in the client. Useful for notifications/pings. + */ + public static void playLocalGlobalSound(Sound sound, float vol, float pitch) { + for (Player p : Bukkit.getOnlinePlayers()) { + SoundUtils.playLocalSound(p, sound, vol, pitch); + } + } + +} diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java b/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java index 40ea5e9..6e88245 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java @@ -7,6 +7,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Location; @@ -25,6 +26,7 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ShapelessRecipe; import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.BlockStateMeta; import org.bukkit.inventory.meta.BookMeta; @@ -41,6 +43,7 @@ import sig.plugin.TwosideKeeper.Artifact; import sig.plugin.TwosideKeeper.TwosideKeeper; import sig.plugin.TwosideKeeper.WorldShopManager; import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemUtils; public class WorldShop { ItemStack item; @@ -649,6 +652,15 @@ public class WorldShop { } } + public static boolean isWorldShopSign(Block b) { + if (b!=null && (b.getType()==Material.SIGN || b.getType()==Material.WALL_SIGN || b.getType()==Material.SIGN_POST) && b.getState() instanceof Sign) { + Sign s = (Sign)b.getState(); + return isWorldShopSign(s); + } else { + return false; + } + } + public static boolean hasShopSignAttached(Block b) { //Returns true if there is a shop sign attached to this block. //Look on all four sides relative to this block. @@ -677,12 +689,13 @@ public class WorldShop { } public static boolean shopSignExists(Block block) { - return !(grabShopSign(block)==null); + return isWorldShopSign(block) || grabShopSign(block)!=null; } public static Sign grabShopSign(Block block) { Block signblock = null; Block signblock2 = null; + if (block==null) {return null;} for (int i=-1;i<2;i++) { for (int j=-1;j<2;j++) { if (i!=0^j!=0) { @@ -916,4 +929,21 @@ public class WorldShop { public static boolean canPlaceShopSignOnBlock(Block block) { return (!shopSignExists(block) && GenericFunctions.isDumpableContainer(block.getType())); } + + public static void createWorldShopRecipes() { + for (Material mat : Material.values()) { + ItemStack result = new ItemStack(Material.TRAPPED_CHEST); + ItemUtils.addLore(result,ChatColor.DARK_PURPLE+"World Shop Chest"); + ItemUtils.addLore(result,ChatColor.MAGIC+""+ChatColor.BLACK+mat.name()); + ItemUtils.addLore(result,ChatColor.LIGHT_PURPLE+"Place in the world to setup a"); + ItemUtils.addLore(result,ChatColor.LIGHT_PURPLE+"world shop that sells "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(mat)); + ItemUtils.hideEnchantments(result); + result.addUnsafeEnchantment(Enchantment.LUCK, 4); + ShapelessRecipe rec = new ShapelessRecipe(result); + rec.addIngredient(mat, -1); + rec.addIngredient(Material.CHEST); + rec.addIngredient(Material.SIGN); + Bukkit.addRecipe(rec); + } + } } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShopItem.java b/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShopItem.java new file mode 100644 index 0000000..5141286 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShopItem.java @@ -0,0 +1,44 @@ +package sig.plugin.TwosideKeeper.HelperStructures; + +import org.bukkit.Material; + +/** + * Structure contains the following: + * The Material of the item, + * The Item's Default Base Price + */ +public enum WorldShopItem { + + APPLE(Material.APPLE,1.00), + BEETROOT(Material.BEETROOT,4.00), + BEETROOT_SEEDS(Material.BEETROOT_SEEDS,3.25), + BLAZE_ROD(Material.BLAZE_POWDER,23.00), + BONE(Material.BONE,1.00), + BROWN_MUSHROOM(Material.BROWN_MUSHROOM,12.00), + CACTUS(Material.CACTUS,4.00), + CARROT_ITEM(Material.CARROT_ITEM,4.00), + CHORUS_FlOWER(Material.CHORUS_FLOWER,20.00), + CHORUS_FRUIT(Material.CHORUS_FRUIT,14.00), + CHORUS_FRUIT_POPPED(Material.CHORUS_FRUIT_POPPED,16.00), + CLAY_BALL(Material.CLAY_BALL,6.00), + CLAY_BRICK(Material.CLAY_BRICK,8.00), + COAL(Material.COAL,16.00), + COAL_ORE(Material.COAL_ORE,48.00), + COBBLESTONE(Material.COBBLESTONE,1.00), + ; + + Material mat; + double price; + short data; + + WorldShopItem(Material mat, double price) { + this.mat=mat; + this.price=price; + this.data=0; + } + WorldShopItem(Material mat, short data, double price) { + this.mat=mat; + this.price=price; + this.data=data; + } +} diff --git a/src/sig/plugin/TwosideKeeper/ItemCubeWindow.java b/src/sig/plugin/TwosideKeeper/ItemCubeWindow.java index b59ff5e..b2923cf 100644 --- a/src/sig/plugin/TwosideKeeper/ItemCubeWindow.java +++ b/src/sig/plugin/TwosideKeeper/ItemCubeWindow.java @@ -8,6 +8,7 @@ import org.bukkit.inventory.InventoryView; import sig.plugin.TwosideKeeper.HelperStructures.CubeType; import sig.plugin.TwosideKeeper.HelperStructures.ItemCube; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils; public class ItemCubeWindow { public static void addItemCubeWindow(Player p, int id) { @@ -40,13 +41,13 @@ public class ItemCubeWindow { InventoryView newinv = p.openInventory(temp); pd.opened_another_cube=false; pd.isViewingItemCube=true;}},1); - p.playSound(p.getLocation(),Sound.BLOCK_CHEST_OPEN,1.0f,1.0f); + SoundUtils.playLocalSound(p,Sound.BLOCK_CHEST_OPEN,1.0f,1.0f); } else { pd.opened_another_cube=true; Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {@Override public void run() {p.openInventory(ItemCube.getViewingItemCubeInventory(itemcubeid, p)); pd.opened_another_cube=false; pd.isViewingItemCube=true;}},1); - p.playSound(p.getLocation(), Sound.BLOCK_CHEST_OPEN, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.BLOCK_CHEST_OPEN, 1.0f, 1.0f); } }},1); } @@ -98,12 +99,12 @@ public class ItemCubeWindow { InventoryView newinv = p.openInventory(inv); TwosideKeeper.loadItemCubeInventory(inv,newinv); pd.isViewingItemCube=true; - p.playSound(p.getLocation(), Sound.BLOCK_CHEST_OPEN, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.BLOCK_CHEST_OPEN, 1.0f, 1.0f); } else { //ItemCube.displayErrorMessage(p); p.openInventory(ItemCube.getViewingItemCubeInventory(id, p)); pd.isViewingItemCube=true; - p.playSound(p.getLocation(), Sound.BLOCK_CHEST_OPEN, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.BLOCK_CHEST_OPEN, 1.0f, 1.0f); } pd.opened_inventory=false; } diff --git a/src/sig/plugin/TwosideKeeper/Logging/DamageLogger.java b/src/sig/plugin/TwosideKeeper/Logging/DamageLogger.java index 0bddc25..b91c264 100644 --- a/src/sig/plugin/TwosideKeeper/Logging/DamageLogger.java +++ b/src/sig/plugin/TwosideKeeper/Logging/DamageLogger.java @@ -43,7 +43,7 @@ public class DamageLogger { public void addMultiplierToLogger(String name, double val) { if (val!=0.0) { - TwosideKeeper.log("Add "+name+" w/value "+val, 2); + TwosideKeeper.log("Add "+name+" w/value "+val, 3); if (breakdownlist.containsKey(name)) { //Add to the already existing value. double dmg = breakdownlist.get(name); @@ -58,7 +58,7 @@ public class DamageLogger { public void addEventToLogger(String name, double val) { if (val!=0.0) { - TwosideKeeper.log("Add "+name+" w/value "+val, 2); + TwosideKeeper.log("Add "+name+" w/value "+val, 3); if (breakdownlist.containsKey(name)) { //Add to the already existing value. double dmg = breakdownlist.get(name); diff --git a/src/sig/plugin/TwosideKeeper/PartyManager.java b/src/sig/plugin/TwosideKeeper/PartyManager.java index ac0162c..41af4be 100644 --- a/src/sig/plugin/TwosideKeeper/PartyManager.java +++ b/src/sig/plugin/TwosideKeeper/PartyManager.java @@ -20,17 +20,33 @@ public class PartyManager { totalparties=0; ClearAllParties(); for (Player p : Bukkit.getOnlinePlayers()) { - if (!IsInParty(p)) { - //We only care about adding a player that's not in a party already. - //We have to make a new party for this player. - AddPlayerToParty(p,totalparties++); - //Now find nearby players and add them to this party. - AddNearbyPlayersToSameParty(p); + if (PlayersAreNearby(p)) { + if (!IsInParty(p)) { + //We only care about adding a player that's not in a party already. + //We have to make a new party for this player. + AddPlayerToParty(p,totalparties++); + //Now find nearby players and add them to this party. + AddNearbyPlayersToSameParty(p); + } + } else { + if (PlayerStructure.GetPlayerStructure(p).partybonus!=0) { + PlayerStructure.GetPlayerStructure(p).partybonus=0; + Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), "scoreboard players reset "+p.getName().toLowerCase()); + } } } UpdatePartyScoreboards(); } + 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)) { + return true; + } + } + return false; + } + private static void UpdatePartyScoreboards() { for (int i : parties.keySet()) { if (oldparties.containsKey(i)) { @@ -225,6 +241,11 @@ public class PartyManager { public static List getPartyMembers(Player p) { int partynumb = GetCurrentParty(p); - return parties.get(partynumb); - } + if (partynumb>=0) { + return parties.get(partynumb); + } else { + List partylist = new ArrayList(); + return partylist; + } + } } diff --git a/src/sig/plugin/TwosideKeeper/PlayerStructure.java b/src/sig/plugin/TwosideKeeper/PlayerStructure.java index 2e939b0..3f72c2d 100644 --- a/src/sig/plugin/TwosideKeeper/PlayerStructure.java +++ b/src/sig/plugin/TwosideKeeper/PlayerStructure.java @@ -11,6 +11,7 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.block.Block; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; @@ -104,7 +105,7 @@ public class PlayerStructure { public List lasteffectlist=null; public boolean stealthmode=false; public long lastcompassnotification=0; - public long endnotification=0; + public boolean endnotification=false; public long turnedonsneak=0; public double slayermodehp=0; public long lastassassinatetime=0; @@ -150,6 +151,9 @@ public class PlayerStructure { public int rage_amt=0; public long swiftaegistime=0; public String lastActionBarMessage=""; + public Location lastStandingLoc = null; + + public HashMap blockscanlist=new HashMap(); //Needs the instance of the player object to get all other info. Only to be called at the beginning. @SuppressWarnings("deprecation") @@ -213,6 +217,7 @@ public class PlayerStructure { //This is a new player! Let the whole world know! //Give the player free tools and items. Bukkit.getServer().broadcastMessage(ChatColor.GOLD+"Welcome to new player "+ChatColor.WHITE+""+this.name+"!"); + aPlugin.API.discordSendRaw("Welcome to new player **"+this.name+"**!"); p.sendMessage(ChatColor.GREEN+"Welcome to the server! Thanks for joining us."); p.sendMessage(ChatColor.GOLD+" Here's a manual to get you started!"); @@ -228,6 +233,8 @@ public class PlayerStructure { p.getInventory().addItem(new ItemStack(Material.BREAD,16));*/ ItemStack manual = new ItemStack(Material.WRITTEN_BOOK); BookMeta bm = (BookMeta)manual.getItemMeta(); + bm.setAuthor("Sig's Minecraft"); + //bm.setPage(arg0, arg1); p.getInventory().addItem(manual); diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index 9e03d43..eb619bd 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -16,6 +16,7 @@ import java.util.UUID; import org.apache.commons.lang.WordUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.Chunk; import org.bukkit.Color; import org.bukkit.Effect; import org.bukkit.Location; @@ -24,6 +25,7 @@ import org.bukkit.Particle; import org.bukkit.Sound; import org.bukkit.attribute.Attribute; import org.bukkit.block.Block; +import org.bukkit.block.BlockState; import org.bukkit.block.Chest; import org.bukkit.block.DoubleChest; import org.bukkit.block.Sign; @@ -68,6 +70,7 @@ import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; @@ -128,6 +131,7 @@ import org.bukkit.event.vehicle.VehicleDestroyEvent; import org.bukkit.event.vehicle.VehicleExitEvent; import org.bukkit.event.weather.LightningStrikeEvent; import org.bukkit.event.world.ChunkLoadEvent; +import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.event.world.WorldSaveEvent; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.Inventory; @@ -144,6 +148,7 @@ 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 aPlugin.API.Chests; import events.PluginLoadEvent; @@ -151,8 +156,7 @@ import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.TextComponent; -import sig.plugin.TwosideKeeper.Events.PlayerDodgeEvent; -import sig.plugin.TwosideKeeper.Events.PlayerTumbleEvent; +import sig.plugin.TwosideKeeper.Events.EntityDamagedEvent; import sig.plugin.TwosideKeeper.HelperStructures.AnvilItem; import sig.plugin.TwosideKeeper.HelperStructures.ArtifactAbility; import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItem; @@ -181,6 +185,8 @@ import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; import sig.plugin.TwosideKeeper.HelperStructures.Common.Habitation; import sig.plugin.TwosideKeeper.HelperStructures.Common.RecipeCategory; import sig.plugin.TwosideKeeper.HelperStructures.Common.RecipeLinker; +import sig.plugin.TwosideKeeper.HelperStructures.Effects.LavaPlume; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils; import sig.plugin.TwosideKeeper.Logging.BowModeLogger; import sig.plugin.TwosideKeeper.Logging.LootLogger; import sig.plugin.TwosideKeeper.Logging.MysteriousEssenceLogger; @@ -188,6 +194,239 @@ import sig.plugin.TwosideKeeper.Logging.MysteriousEssenceLogger; public class TwosideKeeper extends JavaPlugin implements Listener { + public final static int CUSTOM_DAMAGE_IDENTIFIER = 500000; + + public static long SERVERTICK=0; //This is the SERVER's TOTAL TICKS when first loaded. + public static long STARTTIME=0; + public static long LASTSERVERCHECK=0; + public static int SERVERCHECKERTICKS=18000; + public static int TERMINALTIME=220; //How much time in ticks to use the bank withdraw/deposit terminals. + public static double DEATHPENALTY=50.0; //Percent of holding money that will be taken from the player on death. + public static double RECYCLECHANCE=65.0; //65% chance to save despawned items. Can be adjusted via config. + public static double RECYCLEDECAYAMT=20.0; //% chance lost when there's another item of the same type already in there. + public static double DAYMULT=2.0; //How much the day and night length will be multiplied by. + public static int ITEMCUBEID=0; //The current number of Item Cubes in existence. + public static int ARROWQUIVERID=0; //The current number of Arrow Quivers in existence. + public static String MOTD=""; //The MOTD announcement to be announced every hour. + public static double ARMOR_LEATHER_HP=0.5f; + public static double ARMOR_IRON_HP=1f; + public static double ARMOR_GOLD_HP=3f; + public static double ARMOR_DIAMOND_HP=2f; + public static double ARMOR_IRON2_HP=2f; + public static double ARMOR_GOLD2_HP=6f; + public static double ARMOR_DIAMOND2_HP=4f; + public static long HEALTH_REGENERATION_RATE=100; //The amount of ticks between each health regeneration event. + public static long FOOD_HEAL_AMT=2; //1 Heart per food item consumed. + public static double ENEMY_DMG_MULT=1.0f; // + public static double EXPLOSION_DMG_MULT=0.6f; // + public static double HEADSHOT_ACC=1.0f; //How accurate headshots have to be. Lower values means more leniency on headshots. Higher values means more strict. + public static double COMMON_DROP_RATE=0.1; // 1/10 chance + public static double RARE_DROP_RATE=0.0078125; // 1/128 chance + public static double LEGENDARY_DROP_RATE=0.00390625; // 1/256 chance + public static int PARTY_CHUNK_SIZE=16; //The number of chunks each party spans. + public double XP_CONVERSION_RATE=0.01; //How much money per exp point? + public static int WORLD_SHOP_ID=0; //The shop ID number we are on. + public static int LOGGING_LEVEL=0; //The logging level the server will output in for the console. 0 = No Debug Messages. Toggled with /log. + public static double ARTIFACT_RARITY=1.5; //The multiplier of artifact drops. + public static double ELITE_MONSTER_CHANCE=0.01; //The chance an elite monster will be considered. + public static double ELITE_MONSTER_AREA=0.75; //The percentage of area around the monster that has to be AIR to be considered open enough to spawn. + 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 boolean LOOT_TABLE_NEEDS_POPULATING=true; + public static List TEMPORARYABILITIES = new ArrayList(); + public static Set notWorldShop = new HashSet(); + public static List suppressed_entities = new ArrayList(); + public static List lavaplume_list = new ArrayList(); + + public static CustomItem HUNTERS_COMPASS; + public static CustomItem UPGRADE_SHARD; + public static CustomItem ITEM_CUBE; + public static CustomItem LARGE_ITEM_CUBE; + public static CustomItem ENDER_ITEM_CUBE; + public static CustomItem DUPLICATE_ENDER_ITEM_CUBE; + public static CustomItem ARROW_QUIVER; + public static CustomItem HARDENED_IRON_HELMET; + public static CustomItem HARDENED_IRON_CHESTPLATE; + public static CustomItem HARDENED_IRON_LEGGINGS; + public static CustomItem HARDENED_IRON_BOOTS; + public static CustomItem HARDENED_DIAMOND_HELMET; + public static CustomItem HARDENED_DIAMOND_CHESTPLATE; + public static CustomItem HARDENED_DIAMOND_LEGGINGS; + public static CustomItem HARDENED_DIAMOND_BOOTS; + public static CustomItem HARDENED_GOLD_HELMET; + public static CustomItem HARDENED_GOLD_CHESTPLATE; + public static CustomItem HARDENED_GOLD_LEGGINGS; + public static CustomItem HARDENED_GOLD_BOOTS; + public static CustomItem WOOL_RECOLOR; + public static CustomItem SLAB_RECONSTRUCTION; + public static ShapelessRecipe ARTIFACT_RECIPE_T1; + public static ShapelessRecipe ARTIFACT_RECIPE_T2; + public static ShapelessRecipe ARTIFACT_RECIPE_T3; + public static ShapelessRecipe ARTIFACT_RECIPE_T4; + public static ShapelessRecipe ARTIFACT_RECIPE_T5; + public static ShapelessRecipe ARTIFACT_RECIPE_T6; + public static ShapelessRecipe ARTIFACT_RECIPE_T7; + public static ShapelessRecipe ARTIFACT_RECIPE_T8; + public static ShapelessRecipe ARTIFACT_RECIPE_T9; + public static ShapelessRecipe ARTIFACT_RECIPE_T10; + public static ShapelessRecipe ARTIFACT_RECIPE_T11; + public static ShapelessRecipe ARTIFACT_RECIPE_T12; + public static ShapelessRecipe ARTIFACT_RECIPE_T13; + public static ShapelessRecipe ARTIFACT_RECIPE_T14; + public static ShapelessRecipe ARTIFACT_RECIPE_T15; + public static CustomItem INCREASE_ARTIFACT_CRAFTING_TIER; + public static CustomItem DECREASE_ARTIFACT_CRAFTING_TIER; + public static CustomItem EMPOWER_ARTIFACT_CRAFTING_ITEM; + public static CustomItem MONEY_CHECK; + public static CustomItem HANDMADE_ARROW; + public static CustomItem DIAMONDTIPPED_ARROW; + public static CustomItem POISON_ARROW; + public static CustomItem TRAPPING_ARROW; + public static CustomItem EXPLODING_ARROW; + public static ShapedRecipe ITEM_CUBE_RECIPE; + public static ShapedRecipe LARGE_ITEM_CUBE_RECIPE; + public static ShapedRecipe ENDER_ITEM_CUBE_RECIPE; + public static ShapelessRecipe DUPLICATE_ENDER_ITEM_CUBE_RECIPE; + public static ShapedRecipe ARROW_QUIVER_RECIPE; + public static ShapedRecipe HARDENED_IRON_HELMET_RECIPE; + public static ShapedRecipe HARDENED_IRON_CHESTPLATE_RECIPE; + public static ShapedRecipe HARDENED_IRON_LEGGINGS_RECIPE; + public static ShapedRecipe HARDENED_IRON_BOOTS_RECIPE; + public static ShapedRecipe HARDENED_DIAMOND_HELMET_RECIPE; + public static ShapedRecipe HARDENED_DIAMOND_CHESTPLATE_RECIPE; + public static ShapedRecipe HARDENED_DIAMOND_LEGGINGS_RECIPE; + public static ShapedRecipe HARDENED_DIAMOND_BOOTS_RECIPE; + public static ShapedRecipe HARDENED_GOLD_HELMET_RECIPE; + public static ShapedRecipe HARDENED_GOLD_CHESTPLATE_RECIPE; + public static ShapedRecipe HARDENED_GOLD_LEGGINGS_RECIPE; + public static ShapedRecipe HARDENED_GOLD_BOOTS_RECIPE; + public static ShapedRecipe WOOL_RECOLOR_RECIPE; + public static ShapelessRecipe SLAB_RECONSTRUCTION_RECIPE; + public static ShapedRecipe ARTIFACT_RECIPE_T1_SWORD_RECIPE; + public static ShapedRecipe ARTIFACT_RECIPE_T1_AXE_RECIPE; + public static ShapedRecipe ARTIFACT_RECIPE_T1_PICKAXE_RECIPE; + public static ShapedRecipe ARTIFACT_RECIPE_T1_SCYTHE_RECIPE; + public static ShapedRecipe ARTIFACT_RECIPE_T1_BOW_RECIPE; + public static ShapedRecipe ARTIFACT_RECIPE_T1_SHOVEL_RECIPE; + public static ShapedRecipe ARTIFACT_RECIPE_T1_HELMET_RECIPE; + public static ShapedRecipe ARTIFACT_RECIPE_T1_CHESTPLATE_RECIPE; + public static ShapedRecipe ARTIFACT_RECIPE_T1_LEGGINGS_RECIPE; + public static ShapedRecipe ARTIFACT_RECIPE_T1_BOOTS_RECIPE; + public static ShapedRecipe ARTIFACT_RECIPE_T1_FISHING_ROD_RECIPE; + public static ShapelessRecipe ARTIFACT_RECIPE_T2_RECIPE; + public static ShapelessRecipe ARTIFACT_RECIPE_T3_RECIPE; + public static ShapelessRecipe ARTIFACT_RECIPE_T4_RECIPE; + public static ShapelessRecipe ARTIFACT_RECIPE_T5_RECIPE; + public static ShapelessRecipe ARTIFACT_RECIPE_T6_RECIPE; + public static ShapelessRecipe ARTIFACT_RECIPE_T7_RECIPE; + public static ShapelessRecipe ARTIFACT_RECIPE_T8_RECIPE; + public static ShapelessRecipe ARTIFACT_RECIPE_T9_RECIPE; + public static ShapelessRecipe ARTIFACT_RECIPE_T10_RECIPE; + public static ShapelessRecipe ARTIFACT_RECIPE_T11_RECIPE; + public static ShapelessRecipe ARTIFACT_RECIPE_T12_RECIPE; + public static ShapelessRecipe ARTIFACT_RECIPE_T13_RECIPE; + public static ShapelessRecipe ARTIFACT_RECIPE_T14_RECIPE; + public static ShapelessRecipe ARTIFACT_RECIPE_T15_RECIPE; + public static ShapelessRecipe INCREASE_ARTIFACT_CRAFTING_TIER_RECIPE; + public static ShapelessRecipe DECREASE_ARTIFACT_CRAFTING_TIER_RECIPE; + public static ShapelessRecipe EMPOWER_ARTIFACT_CRAFTING_ITEM_RECIPE; + public static ShapelessRecipe MONEY_CHECK_RECIPE; + public static ShapelessRecipe HANDMADE_ARROW_RECIPE; + public static ShapelessRecipe DIAMONDTIPPED_ARROW_RECIPE; + public static ShapelessRecipe POISON_ARROW_RECIPE; + public static ShapelessRecipe TRAPPING_ARROW_RECIPE; + public static ShapelessRecipe EXPLODING_ARROW_RECIPE; + public static ShapelessRecipe PIERCING_ARROW_RECIPE; + public static CustomPotion STRENGTHENING_VIAL; + public static CustomPotion LIFE_VIAL; + public static CustomPotion HARDENING_VIAL; + + public static final int POTION_DEBUG_LEVEL=5; + public static final int LAVA_PLUME_COOLDOWN=60; + + public static long last_lava_plume_time = 0; + + public static final int DODGE_COOLDOWN=100; + public static final int DEATHMARK_COOLDOWN=240; + public static final int EARTHWAVE_COOLDOWN=300; + public static final int ERUPTION_COOLDOWN=100; + public static final int LINEDRIVE_COOLDOWN=240; + public static final int REJUVENATE_COOLDOWN=2400; + public static final int ASSASSINATE_COOLDOWN=200; + public static final int LIFESAVER_COOLDOWN=6000; + public static final int ARROWBARRAGE_COOLDOWN=2400; + public static final int SIPHON_COOLDOWN = 700; + public static final int MOCK_COOLDOWN = 400; + + public static final Material[] ClearFallingBlockList = {Material.REDSTONE_BLOCK}; + + public static final Location TWOSIDE_LOCATION = new Location(Bukkit.getServer().getWorld("world"),1630,65,-265); + + public static final int CLEANUP_DEBUG = 2; + public static final int LOOT_DEBUG = 3; + public static final int COMBAT_DEBUG = 3; + public static double worldShopDistanceSquared = 1000000; + public static double worldShopPriceMult = 2.0; //How much higher the price increases for every increment of worlsShopDistanceSquared. + + public static String lastActionBarMessage=""; + + public static File filesave; + public static HashMap playerdata; + public static HashMap livingentitydata; + public static SpleefManager TwosideSpleefGames; + public static WorldShopManager TwosideShops; + public static MysteriousEssenceLogger EssenceLogger; //The logger for Essences. + public static BowModeLogger BowLogger; //The logger for Bow Modes. + public static LootLogger Loot_Logger; //The logger for Loot. + public static AutoUpdatePlugin pluginupdater; + public static boolean restarting_server=false; + public static List log_messages=new ArrayList(); + + long LastClearStructureTime = 0; + + public int TeamCounter = 0; + public static int time_passed = 0; //The total amount of time lost due to modifications to FullTime(). + public List colors_used = new ArrayList(); + public static HashMap chargezombies = new HashMap(); + public static HashMap hellfirespiders = new HashMap(); + public static List elitemonsters = new ArrayList(); + + public static RecyclingCenter TwosideRecyclingCenter; + + //Bank timers and users. + public static HashMap banksessions; + public static Habitation habitat_data; + + public static Plugin plugin; + public int sleepingPlayers=0; + public static List validsetitems = new ArrayList(); + + boolean reloadedchunk=false; + + int[] lampblocks = {1626,71,-255, //List of all lamp blocks in the city to be lit. + 1628,70,-223, + 1626,70,-265, + 1624,70,-267, + 1635,71,-269, + 1612,69,-269, + 1610,69,-271, + 1595,67,-267, + 1595,66,-269, + 1577,66,-271, + 1610,71,-282, + 1608,71,-295, + 1610,67,-317, + 1610,67,-338, + 1610,67,-340, + 1632,71,-342, + 1601,67,-342, + 1587,67,-340}; + + boolean lamps_are_turned_on = false; + + private final class GivePlayerPurchasedItems implements Runnable { private final Chest cc; private final AsyncPlayerChatEvent ev; @@ -337,19 +576,19 @@ public class TwosideKeeper extends JavaPlugin implements Listener { m.setVelocity(new Vector(0,0.5,0)); if (m.getLocation().getWorld().getName().equalsIgnoreCase("world_nether")) { m.getLocation().getBlock().setType(Material.NETHERRACK); - m.getLocation().getWorld().playSound(m.getLocation(), Sound.BLOCK_STONE_PLACE, 1.0f, 1.0f); + SoundUtils.playGlobalSound(m.getLocation(), Sound.BLOCK_STONE_PLACE, 1.0f, 1.0f); } else { switch (r.nextInt(3)) { case 0:{ - m.getLocation().getWorld().playSound(m.getLocation(), Sound.BLOCK_GRAVEL_PLACE, 1.0f, 1.0f); + SoundUtils.playGlobalSound(m.getLocation(), Sound.BLOCK_GRAVEL_PLACE, 1.0f, 1.0f); }break; case 1:{ m.getLocation().getBlock().setType(Material.COBBLESTONE); - m.getLocation().getWorld().playSound(m.getLocation(), Sound.BLOCK_STONE_PLACE, 1.0f, 1.0f); + SoundUtils.playGlobalSound(m.getLocation(), Sound.BLOCK_STONE_PLACE, 1.0f, 1.0f); }break; case 2:{ m.getLocation().getBlock().setType(Material.GRAVEL); - m.getLocation().getWorld().playSound(m.getLocation(), Sound.BLOCK_GRAVEL_PLACE, 1.0f, 1.0f); + SoundUtils.playGlobalSound(m.getLocation(), Sound.BLOCK_GRAVEL_PLACE, 1.0f, 1.0f); }break; } } @@ -371,7 +610,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { sb.setVelocity(m.getLocation().getDirection().multiply(1.3f)); sb.setMetadata("SPIDERBALL", new FixedMetadataValue(TwosideKeeper.plugin,true)); sb.setShooter(m); - m.getWorld().playSound(sb.getLocation(), Sound.ENTITY_SNOWBALL_THROW, 1.0f, 1.0f); + SoundUtils.playGlobalSound(sb.getLocation(), Sound.ENTITY_SNOWBALL_THROW, 1.0f, 1.0f); les.lastSpiderBallThrow = getServerTickTime(); } } @@ -395,6 +634,15 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ScheduleRemoval(suppressed_entities,e); } } + for (LavaPlume lp : lavaplume_list) { + if (!lp.runTick()) { + ScheduleRemoval(lavaplume_list,lp); + } + } + } + + private void UpdateLavaBlock(Block lavamod) { + if (lavamod.getType()==Material.AIR) {lavamod.setType(Material.LAVA);lavamod.setData((byte)9);BlockState state = lavamod.getState();state.update(true,true);} } } @@ -419,224 +667,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } - public final static int CUSTOM_DAMAGE_IDENTIFIER = 500000; - - public static long SERVERTICK=0; //This is the SERVER's TOTAL TICKS when first loaded. - public static long STARTTIME=0; - public static long LASTSERVERCHECK=0; - public static int SERVERCHECKERTICKS=18000; - public static int TERMINALTIME=220; //How much time in ticks to use the bank withdraw/deposit terminals. - public static double DEATHPENALTY=50.0; //Percent of holding money that will be taken from the player on death. - public static double RECYCLECHANCE=65.0; //65% chance to save despawned items. Can be adjusted via config. - public static double RECYCLEDECAYAMT=20.0; //% chance lost when there's another item of the same type already in there. - public static double DAYMULT=2.0; //How much the day and night length will be multiplied by. - public static int ITEMCUBEID=0; //The current number of Item Cubes in existence. - public static int ARROWQUIVERID=0; //The current number of Arrow Quivers in existence. - public static String MOTD=""; //The MOTD announcement to be announced every hour. - public static double ARMOR_LEATHER_HP=0.5f; - public static double ARMOR_IRON_HP=1f; - public static double ARMOR_GOLD_HP=3f; - public static double ARMOR_DIAMOND_HP=2f; - public static double ARMOR_IRON2_HP=2f; - public static double ARMOR_GOLD2_HP=6f; - public static double ARMOR_DIAMOND2_HP=4f; - public static long HEALTH_REGENERATION_RATE=100; //The amount of ticks between each health regeneration event. - public static long FOOD_HEAL_AMT=2; //1 Heart per food item consumed. - public static double ENEMY_DMG_MULT=1.0f; // - public static double EXPLOSION_DMG_MULT=0.6f; // - public static double HEADSHOT_ACC=1.0f; //How accurate headshots have to be. Lower values means more leniency on headshots. Higher values means more strict. - public static double COMMON_DROP_RATE=0.1; // 1/10 chance - public static double RARE_DROP_RATE=0.0078125; // 1/128 chance - public static double LEGENDARY_DROP_RATE=0.00390625; // 1/256 chance - public static int PARTY_CHUNK_SIZE=16; //The number of chunks each party spans. - public double XP_CONVERSION_RATE=0.01; //How much money per exp point? - public static int WORLD_SHOP_ID=0; //The shop ID number we are on. - public static int LOGGING_LEVEL=0; //The logging level the server will output in for the console. 0 = No Debug Messages. Toggled with /log. - public static double ARTIFACT_RARITY=1.5; //The multiplier of artifact drops. - public static double ELITE_MONSTER_CHANCE=0.01; //The chance an elite monster will be considered. - public static double ELITE_MONSTER_AREA=0.75; //The percentage of area around the monster that has to be AIR to be considered open enough to spawn. - 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 boolean LOOT_TABLE_NEEDS_POPULATING=true; - public static List TEMPORARYABILITIES = new ArrayList(); - public static Set notWorldShop = new HashSet(); - public static List suppressed_entities = new ArrayList(); - - public static CustomItem HUNTERS_COMPASS; - public static CustomItem UPGRADE_SHARD; - public static CustomItem ITEM_CUBE; - public static CustomItem LARGE_ITEM_CUBE; - public static CustomItem ENDER_ITEM_CUBE; - public static CustomItem DUPLICATE_ENDER_ITEM_CUBE; - public static CustomItem ARROW_QUIVER; - public static CustomItem HARDENED_IRON_HELMET; - public static CustomItem HARDENED_IRON_CHESTPLATE; - public static CustomItem HARDENED_IRON_LEGGINGS; - public static CustomItem HARDENED_IRON_BOOTS; - public static CustomItem HARDENED_DIAMOND_HELMET; - public static CustomItem HARDENED_DIAMOND_CHESTPLATE; - public static CustomItem HARDENED_DIAMOND_LEGGINGS; - public static CustomItem HARDENED_DIAMOND_BOOTS; - public static CustomItem HARDENED_GOLD_HELMET; - public static CustomItem HARDENED_GOLD_CHESTPLATE; - public static CustomItem HARDENED_GOLD_LEGGINGS; - public static CustomItem HARDENED_GOLD_BOOTS; - public static CustomItem WOOL_RECOLOR; - public static CustomItem SLAB_RECONSTRUCTION; - public static ShapelessRecipe ARTIFACT_RECIPE_T1; - public static ShapelessRecipe ARTIFACT_RECIPE_T2; - public static ShapelessRecipe ARTIFACT_RECIPE_T3; - public static ShapelessRecipe ARTIFACT_RECIPE_T4; - public static ShapelessRecipe ARTIFACT_RECIPE_T5; - public static ShapelessRecipe ARTIFACT_RECIPE_T6; - public static ShapelessRecipe ARTIFACT_RECIPE_T7; - public static ShapelessRecipe ARTIFACT_RECIPE_T8; - public static ShapelessRecipe ARTIFACT_RECIPE_T9; - public static ShapelessRecipe ARTIFACT_RECIPE_T10; - public static ShapelessRecipe ARTIFACT_RECIPE_T11; - public static ShapelessRecipe ARTIFACT_RECIPE_T12; - public static ShapelessRecipe ARTIFACT_RECIPE_T13; - public static ShapelessRecipe ARTIFACT_RECIPE_T14; - public static ShapelessRecipe ARTIFACT_RECIPE_T15; - public static CustomItem INCREASE_ARTIFACT_CRAFTING_TIER; - public static CustomItem DECREASE_ARTIFACT_CRAFTING_TIER; - public static CustomItem EMPOWER_ARTIFACT_CRAFTING_ITEM; - public static CustomItem MONEY_CHECK; - public static CustomItem HANDMADE_ARROW; - public static CustomItem DIAMONDTIPPED_ARROW; - public static CustomItem POISON_ARROW; - public static CustomItem TRAPPING_ARROW; - public static CustomItem EXPLODING_ARROW; - public static ShapedRecipe ITEM_CUBE_RECIPE; - public static ShapedRecipe LARGE_ITEM_CUBE_RECIPE; - public static ShapedRecipe ENDER_ITEM_CUBE_RECIPE; - public static ShapelessRecipe DUPLICATE_ENDER_ITEM_CUBE_RECIPE; - public static ShapedRecipe ARROW_QUIVER_RECIPE; - public static ShapedRecipe HARDENED_IRON_HELMET_RECIPE; - public static ShapedRecipe HARDENED_IRON_CHESTPLATE_RECIPE; - public static ShapedRecipe HARDENED_IRON_LEGGINGS_RECIPE; - public static ShapedRecipe HARDENED_IRON_BOOTS_RECIPE; - public static ShapedRecipe HARDENED_DIAMOND_HELMET_RECIPE; - public static ShapedRecipe HARDENED_DIAMOND_CHESTPLATE_RECIPE; - public static ShapedRecipe HARDENED_DIAMOND_LEGGINGS_RECIPE; - public static ShapedRecipe HARDENED_DIAMOND_BOOTS_RECIPE; - public static ShapedRecipe HARDENED_GOLD_HELMET_RECIPE; - public static ShapedRecipe HARDENED_GOLD_CHESTPLATE_RECIPE; - public static ShapedRecipe HARDENED_GOLD_LEGGINGS_RECIPE; - public static ShapedRecipe HARDENED_GOLD_BOOTS_RECIPE; - public static ShapedRecipe WOOL_RECOLOR_RECIPE; - public static ShapelessRecipe SLAB_RECONSTRUCTION_RECIPE; - public static ShapedRecipe ARTIFACT_RECIPE_T1_SWORD_RECIPE; - public static ShapedRecipe ARTIFACT_RECIPE_T1_AXE_RECIPE; - public static ShapedRecipe ARTIFACT_RECIPE_T1_PICKAXE_RECIPE; - public static ShapedRecipe ARTIFACT_RECIPE_T1_SCYTHE_RECIPE; - public static ShapedRecipe ARTIFACT_RECIPE_T1_BOW_RECIPE; - public static ShapedRecipe ARTIFACT_RECIPE_T1_SHOVEL_RECIPE; - public static ShapedRecipe ARTIFACT_RECIPE_T1_HELMET_RECIPE; - public static ShapedRecipe ARTIFACT_RECIPE_T1_CHESTPLATE_RECIPE; - public static ShapedRecipe ARTIFACT_RECIPE_T1_LEGGINGS_RECIPE; - public static ShapedRecipe ARTIFACT_RECIPE_T1_BOOTS_RECIPE; - public static ShapedRecipe ARTIFACT_RECIPE_T1_FISHING_ROD_RECIPE; - public static ShapelessRecipe ARTIFACT_RECIPE_T2_RECIPE; - public static ShapelessRecipe ARTIFACT_RECIPE_T3_RECIPE; - public static ShapelessRecipe ARTIFACT_RECIPE_T4_RECIPE; - public static ShapelessRecipe ARTIFACT_RECIPE_T5_RECIPE; - public static ShapelessRecipe ARTIFACT_RECIPE_T6_RECIPE; - public static ShapelessRecipe ARTIFACT_RECIPE_T7_RECIPE; - public static ShapelessRecipe ARTIFACT_RECIPE_T8_RECIPE; - public static ShapelessRecipe ARTIFACT_RECIPE_T9_RECIPE; - public static ShapelessRecipe ARTIFACT_RECIPE_T10_RECIPE; - public static ShapelessRecipe ARTIFACT_RECIPE_T11_RECIPE; - public static ShapelessRecipe ARTIFACT_RECIPE_T12_RECIPE; - public static ShapelessRecipe ARTIFACT_RECIPE_T13_RECIPE; - public static ShapelessRecipe ARTIFACT_RECIPE_T14_RECIPE; - public static ShapelessRecipe ARTIFACT_RECIPE_T15_RECIPE; - public static ShapelessRecipe INCREASE_ARTIFACT_CRAFTING_TIER_RECIPE; - public static ShapelessRecipe DECREASE_ARTIFACT_CRAFTING_TIER_RECIPE; - public static ShapelessRecipe EMPOWER_ARTIFACT_CRAFTING_ITEM_RECIPE; - public static ShapelessRecipe MONEY_CHECK_RECIPE; - public static ShapelessRecipe HANDMADE_ARROW_RECIPE; - public static ShapelessRecipe DIAMONDTIPPED_ARROW_RECIPE; - public static ShapelessRecipe POISON_ARROW_RECIPE; - public static ShapelessRecipe TRAPPING_ARROW_RECIPE; - public static ShapelessRecipe EXPLODING_ARROW_RECIPE; - public static ShapelessRecipe PIERCING_ARROW_RECIPE; - public static CustomPotion STRENGTHENING_VIAL; - public static CustomPotion LIFE_VIAL; - public static CustomPotion HARDENING_VIAL; - - public static final int POTION_DEBUG_LEVEL=5; - - public static final int DODGE_COOLDOWN=100; - public static final int DEATHMARK_COOLDOWN=240; - public static final int EARTHWAVE_COOLDOWN=300; - public static final int ERUPTION_COOLDOWN=100; - public static final int LINEDRIVE_COOLDOWN=240; - public static final int REJUVENATE_COOLDOWN=2400; - public static final int ASSASSINATE_COOLDOWN=200; - public static final int LIFESAVER_COOLDOWN=6000; - public static final int ARROWBARRAGE_COOLDOWN=2400; - public static final int SIPHON_COOLDOWN = 700; - public static final int MOCK_COOLDOWN = 400; - - public static String lastActionBarMessage=""; - - public static File filesave; - public static HashMap playerdata; - public static HashMap livingentitydata; - public static SpleefManager TwosideSpleefGames; - public static WorldShopManager TwosideShops; - public static MysteriousEssenceLogger EssenceLogger; //The logger for Essences. - public static BowModeLogger BowLogger; //The logger for Bow Modes. - public static LootLogger Loot_Logger; //The logger for Loot. - public static AutoUpdatePlugin pluginupdater; - public static boolean restarting_server=false; - public static List log_messages=new ArrayList(); - - long LastClearStructureTime = 0; - - public int TeamCounter = 0; - public static int time_passed = 0; //The total amount of time lost due to modifications to FullTime(). - public List colors_used = new ArrayList(); - public static HashMap chargezombies = new HashMap(); - public static HashMap hellfirespiders = new HashMap(); - public static List elitemonsters = new ArrayList(); - - public static RecyclingCenter TwosideRecyclingCenter; - - //Bank timers and users. - public static HashMap banksessions; - public static Habitation habitat_data; - - public static Plugin plugin; - public int sleepingPlayers=0; - public static List validsetitems = new ArrayList(); - - boolean reloadedchunk=false; - - int[] lampblocks = {1626,71,-255, //List of all lamp blocks in the city to be lit. - 1628,70,-223, - 1626,70,-265, - 1624,70,-267, - 1635,71,-269, - 1612,69,-269, - 1610,69,-271, - 1595,67,-267, - 1595,66,-269, - 1577,66,-271, - 1610,71,-282, - 1608,71,-295, - 1610,67,-317, - 1610,67,-338, - 1610,67,-340, - 1632,71,-342, - 1601,67,-342, - 1587,67,-340}; - - boolean lamps_are_turned_on = false; - @Override public void onEnable() { Bukkit.getPluginManager().registerEvents(this, this); @@ -759,6 +789,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } //Announce the server has restarted soon after. + WorldShop.createWorldShopRecipes(); if (!LOOT_TABLE_NEEDS_POPULATING) { Loot.DefineLootChests(); @@ -790,9 +821,21 @@ public class TwosideKeeper extends JavaPlugin implements Listener { Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard objectives remove Party"+i); } saveOurData(); //Saves all of our server variables and closes down. + PerformCleanupMaintenance(); } - @Override + private void PerformCleanupMaintenance() { + long starttime = System.currentTimeMillis(); + log("Starting Cleanup Maintenance Procedures...",CLEANUP_DEBUG); + log("Cleaning up Lava Plumes ["+lavaplume_list.size()+"]",CLEANUP_DEBUG); + for (LavaPlume lp : lavaplume_list) { + lp.Cleanup(); + } + long endtime = System.currentTimeMillis(); + log("Cleanup Maintenance completed. Total Time: "+(endtime-starttime)+"ms.",CLEANUP_DEBUG); + } + + @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("log")) { LOGGING_LEVEL = (LOGGING_LEVEL+1) % 6; @@ -1019,8 +1062,14 @@ public class TwosideKeeper extends JavaPlugin implements Listener { GenericFunctions.addSuppressionTime(p, 30); TwosideKeeper.log("Suppression Time: "+GenericFunctions.getSuppressionTime(p), 1); TwosideKeeper.log("Suppressed: "+GenericFunctions.isSuppressed(p),1);*/ - /*ItemStack item = p.getEquipment().getItemInMainHand(); - AwakenedArtifact.addPotentialEXP(item, 50000, p);*/ + //ItemStack item = p.getEquipment().getItemInMainHand(); + //AwakenedArtifact.addPotentialEXP(item, 50000, p); + /*FallingBlock fb = p.getWorld().spawnFallingBlock(p.getLocation(), Material.REDSTONE_BLOCK, (byte)0); + fb.setMetadata("DESTROY", new FixedMetadataValue(this,true)); + GlowAPI.setGlowing(fb, GlowAPI.Color.YELLOW, Bukkit.getOnlinePlayers());*/ + /*log("Start Time: "+System.currentTimeMillis(),0); + HashMap blocklist = GenericFunctions.GetPlayerBlockList(p); + log("Finish Time: "+System.currentTimeMillis(),0);*/ //p.getEquipment().getItemInMainHand().setType(Material.SULPHUR); //if (GenericFunctions.isSuppressed(p) //TwosideKeeperAPI.removeAllArtifactAbilityPoints(p.getEquipment().getItemInMainHand()); @@ -1274,7 +1323,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener { private void DisplayCraftingRecipe(Player p, String string) { RecipeLinker l = RecipeLinker.valueOf(string); ItemStack[] newarray = Arrays.copyOfRange(l.getRec(), 1, l.getRec().length); - aPlugin.API.viewRecipe(p, l.getRec()[0], newarray); + if (p.hasPermission("createViaCraftMenu") && (getServerType()==ServerType.TEST || getServerType()==ServerType.QUIET)) { + GenericFunctions.giveItem(p, l.getRec()[0]); + } else { + aPlugin.API.viewRecipe(p, l.getRec()[0], newarray); + } } private void DisplayArguments(Player p) { p.sendMessage(ChatColor.GREEN+"Choose a category to view:"); @@ -1315,7 +1368,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (val.getCategory().equals(RecipeCategory.valueOf(arg))) { j++; TextComponent tc = new TextComponent(ChatColor.values()[j+2]+"["+val.getColor()+val.getName()+ChatColor.values()[j+2]+"] "); - tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new ComponentBuilder("Click to view the recipe for "+val.getColor()+val.getName()).create())); + if (p.hasPermission("createViaCraftMenu") && (getServerType()==ServerType.TEST || getServerType()==ServerType.QUIET)) { + tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new ComponentBuilder("Click to be given a "+val.getColor()+val.getName()).create())); + } else { + tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new ComponentBuilder("Click to view the recipe for "+val.getColor()+val.getName()).create())); + } tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,"/craft "+val.name()+" view")); if (j>2) { tc.addExtra("\n"); @@ -1381,7 +1438,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { for (int i=0;i nearby = p.getNearbyEntities(3.5, 3.5, 3.5); @@ -2118,7 +2175,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,100,(currentStrengthLevel+1<5)?currentStrengthLevel+1:4));*/ GenericFunctions.addStackingPotionEffect(p, PotionEffectType.INCREASE_DAMAGE, 20*5, 4); - p.playSound(p.getLocation(), Sound.ITEM_SHIELD_BLOCK, 1.0f, 3.0f); + SoundUtils.playLocalSound(p, Sound.ITEM_SHIELD_BLOCK, 1.0f, 3.0f); Arrow a = (Arrow)nearby.get(i); a.setCustomName("HIT"); a.setVelocity(new Vector(0,0,0)); @@ -2309,13 +2366,13 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ev.getPlayer().openInventory(temp); PlayerStructure pd = (PlayerStructure) playerdata.get(ev.getPlayer().getUniqueId()); pd.isViewingItemCube=true; - ev.getPlayer().playSound(ev.getPlayer().getLocation(), Sound.BLOCK_CHEST_OPEN, 1.0f, 1.0f); + SoundUtils.playLocalSound(ev.getPlayer(), Sound.BLOCK_CHEST_OPEN, 1.0f, 1.0f); } else { //ItemCube.displayErrorMessage(ev.getPlayer()); ev.getPlayer().openInventory(ItemCube.getViewingItemCubeInventory(itemcube_id, ev.getPlayer())); PlayerStructure pd = (PlayerStructure) playerdata.get(ev.getPlayer().getUniqueId()); pd.isViewingItemCube=true; - ev.getPlayer().playSound(ev.getPlayer().getLocation(), Sound.BLOCK_CHEST_OPEN, 1.0f, 1.0f); + SoundUtils.playLocalSound(ev.getPlayer(), Sound.BLOCK_CHEST_OPEN, 1.0f, 1.0f); } ev.setCancelled(true); return; @@ -2783,7 +2840,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { m.addPotionEffect(new PotionEffect(PotionEffectType.UNLUCK,99,stackamt/2),true); GenericFunctions.ApplyDeathMark(m); } - player.playSound(m.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 1.0f, 1.0f); + //player.playSound(m.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 1.0f, 1.0f); + SoundUtils.playGlobalSound(m.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 1.0f, 1.0f); } } } @@ -2815,6 +2873,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //This is not allowed! We can't expand shops that are not ours. ev.getPlayer().sendMessage("There's a shop owned by "+ChatColor.LIGHT_PURPLE+shop.GetOwner()+ChatColor.WHITE+" right next to your chest! You cannot expand others' shops!"); ev.setCancelled(true); + return; } } } @@ -2833,14 +2892,17 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ev.getItemInHand().getItemMeta().getLore().get(3).contains(ChatColor.DARK_PURPLE+"ID#")) { //This is an item cube. ev.setCancelled(true); + return; } if (Artifact.isArtifact(ev.getItemInHand()) && !GenericFunctions.isArtifactEquip(ev.getItemInHand())) { ev.setCancelled(true); + return; } if (ItemSet.isSetItem(ev.getItemInHand())) { ev.setCancelled(true); + return; } } @@ -3041,7 +3103,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ev.getInventory().getResult().getType()!=Material.AIR && Artifact.isArtifact(ev.getInventory().getResult()) && GenericFunctions.isEquip(ev.getInventory().getResult())) { Player p = (Player)(Bukkit.getPlayer(ev.getWhoClicked().getName())); - p.playSound(p.getLocation(), Sound.BLOCK_ANVIL_USE, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.BLOCK_ANVIL_USE, 1.0f, 1.0f); return; } if (ArrowQuiver.isValidQuiver(ev.getCurrentItem())) { @@ -3096,11 +3158,14 @@ public class TwosideKeeper extends JavaPlugin implements Listener { Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { @Override public void run() { - b.getLocation().getWorld().playSound(b.getLocation(), Sound.BLOCK_CHORUS_FLOWER_DEATH, 1.0f, 1.0f); + SoundUtils.playGlobalSound(b.getLocation(), Sound.BLOCK_CHORUS_FLOWER_DEATH, 1.0f, 1.0f); b.breakNaturally(); } },1); - } + } else + if (fb.hasMetadata("DESTROY")) { + ev.setCancelled(true); + } } } @@ -3152,7 +3217,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); if (pd.weaponcharges>=100) { //Perform Barbarian's Rage! - p.playSound(p.getLocation(), Sound.ENTITY_GHAST_DEATH, 1.0f, 0.3f); + SoundUtils.playLocalSound(p, Sound.ENTITY_GHAST_DEATH, 1.0f, 0.3f); int rage_duration = (20*(pd.weaponcharges/10)); pd.rage_time=getServerTickTime() + rage_duration; pd.rage_amt=pd.weaponcharges; @@ -3262,7 +3327,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } } - p.playSound(p.getLocation(), Sound.ENTITY_VILLAGER_AMBIENT, 1.0f, 0.3f); + SoundUtils.playLocalSound(p, Sound.ENTITY_VILLAGER_AMBIENT, 1.0f, 0.3f); aPlugin.API.displayEndRodParticle(p.getLocation(), 0, 0f, 0f, 5, 20); if (hasFullSet) { aPlugin.API.sendCooldownPacket(p, ev.getItemDrop().getItemStack().getType(), GenericFunctions.GetModifiedCooldown(TwosideKeeper.MOCK_COOLDOWN/2,ev.getPlayer())); @@ -3390,7 +3455,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } CubeType cub = p.getOpenInventory().getTopInventory().getSize()==9?CubeType.NORMAL:CubeType.LARGE; - p.playSound(p.getLocation(), Sound.BLOCK_CHEST_CLOSE, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.BLOCK_CHEST_CLOSE, 1.0f, 1.0f); itemCube_saveConfig(id,itemcube_contents,cub); if (!pd.opened_another_cube) { ItemCubeWindow.removeAllItemCubeWindows(p); @@ -3740,7 +3805,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //The inventory we are viewing is the same as the item cube we have clicked on! //Stop this before the player does something dumb! //Player p = ((Player)ev.getWhoClicked()); - //p.playSound(p.getLocation(), Sound.BLOCK_NOTE_HARP, 0.4f, 0.2f); + //SoundUtils.playLocalSound(p, Sound.BLOCK_NOTE_HARP, 0.4f, 0.2f); ev.setCancelled(true); return; } @@ -3811,7 +3876,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { @Override public void run() { p.openInventory(Bukkit.getServer().createInventory(p, 27, "Item Cube #"+id)); - p.playSound(p.getLocation(),Sound.BLOCK_CHEST_OPEN,1.0f,1.0f); + SoundUtils.playLocalSound(p,Sound.BLOCK_CHEST_OPEN,1.0f,1.0f); } },10); } @@ -3909,7 +3974,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //The inventory we are viewing is the same as the item cube we have clicked on! //Stop this before the player does something dumb! //Player p = ((Player)ev.getWhoClicked()); - //p.playSound(p.getLocation(), Sound.BLOCK_NOTE_HARP, 0.4f, 0.2f); + //SoundUtils.playLocalSound(p, Sound.BLOCK_NOTE_HARP, 0.4f, 0.2f); ev.setCancelled(true); return; } else { @@ -3941,7 +4006,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {@Override public void run() {p.openInventory(temp); pd2.opened_another_cube=false; pd2.isViewingItemCube=true;}},1); - p.playSound(p.getLocation(),Sound.BLOCK_CHEST_OPEN,1.0f,1.0f); + SoundUtils.playLocalSound(p,Sound.BLOCK_CHEST_OPEN,1.0f,1.0f); return; } else { //ev.setCancelled(true); @@ -3952,7 +4017,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {@Override public void run() {p.openInventory(ItemCube.getViewingItemCubeInventory(idnumb, p)); pd2.opened_another_cube=false; pd2.isViewingItemCube=true;}},1); - p.playSound(p.getLocation(), Sound.BLOCK_CHEST_OPEN, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.BLOCK_CHEST_OPEN, 1.0f, 1.0f); return; } } @@ -4016,16 +4081,31 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //Grab all entities. Create monster structures for all monsters. Detect elites and leaders and set their status accordingly. if (TwosideKeeper.livingentitydata!=null) { - Entity[] entities = ev.getChunk().getEntities(); - for (int i=0;i0) { dmgdealt=0.0; } } - ev.getEntity().getWorld().playSound(ev.getEntity().getLocation(), Sound.ENCHANT_THORNS_HIT, 1.0f, 1.0f); + SoundUtils.playGlobalSound(ev.getEntity().getLocation(), Sound.ENCHANT_THORNS_HIT, 1.0f, 1.0f); CustomDamage.setupTrueDamage(ev); if (ev.getDamager() instanceof Player) { Player p = (Player)ev.getDamager(); @@ -4350,7 +4456,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { Player p = (Player)CustomDamage.getDamagerEntity(ev.getDamager()); PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); if (PlayerMode.isDefender(p) && p.isSneaking() && ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.SONGSTEEL,5) && pd.vendetta_amt>0.0) { //Deal Vendetta damage instead. - p.playSound(p.getLocation(), Sound.BLOCK_GLASS_BREAK, 1.0f, 0.5f); + SoundUtils.playLocalSound(p, Sound.BLOCK_GLASS_BREAK, 1.0f, 0.5f); GenericFunctions.removeNoDamageTick((LivingEntity)ev.getEntity(), ev.getDamager()); CustomDamage.ApplyDamage(pd.vendetta_amt, ev.getDamager(), (LivingEntity)ev.getEntity(), null, "Vendetta"); pd.vendetta_amt=0.0; @@ -4378,12 +4484,22 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } CustomDamage.setupTrueDamage(ev); ev.setDamage(DamageModifier.BASE, dmgdealt); - if (dmgdealt < 1) { - ev.setDamage(DamageModifier.BASE,dmgdealt); - } else { - ev.setDamage(DamageModifier.BASE,1d); - ((LivingEntity)ev.getEntity()).setHealth(Math.max(((LivingEntity)ev.getEntity()).getHealth() - (dmgdealt - 1d), 0.5)); - } + + EntityDamagedEvent event = new EntityDamagedEvent((LivingEntity)ev.getEntity(),ev.getDamager(),dmgdealt,ev.getCause().name(),CustomDamage.NONE); + Bukkit.getPluginManager().callEvent(event); + if (event.isCancelled()) { + dmgdealt=0; + ev.setDamage(DamageModifier.BASE,0d); + ev.setCancelled(true); + return; + } else { + if (dmgdealt < 1) { + ev.setDamage(DamageModifier.BASE,dmgdealt); + } else { + ev.setDamage(DamageModifier.BASE,1d); + ((LivingEntity)ev.getEntity()).setHealth(Math.max(((LivingEntity)ev.getEntity()).getHealth() - (dmgdealt - 1d), 0.5)); + } + } } else { ev.setCancelled(true); } @@ -4482,30 +4598,30 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public void run() { GenericFunctions.DealExplosionDamageToEntities(c.getLocation(), 16, 4); aPlugin.API.sendSoundlessExplosion(c.getLocation(), 4.0f); - c.getLocation().getWorld().playSound(c.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1.0f, 1.0f); + SoundUtils.playGlobalSound(c.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1.0f, 1.0f); }} ,10); } else if (c.getCustomName().contains("Deadly")) { log("Preparing to explode.",5); - c.getLocation().getWorld().playSound(c.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1.0f, 1.0f); + SoundUtils.playGlobalSound(c.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1.0f, 1.0f); Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { public void run() { GenericFunctions.DealExplosionDamageToEntities(c.getLocation(), 32, 3); aPlugin.API.sendSoundlessExplosion(c.getLocation(), 6.0f); - c.getLocation().getWorld().playSound(c.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1.0f, 1.0f); + SoundUtils.playGlobalSound(c.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1.0f, 1.0f); GenericFunctions.RandomlyCreateFire(c.getLocation(),3); }} ,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); + SoundUtils.playGlobalSound(c.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1.0f, 1.0f); Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { public void run() { GenericFunctions.DealExplosionDamageToEntities(c.getLocation(), 64, 4); aPlugin.API.sendSoundlessExplosion(c.getLocation(), 8.0f); - c.getLocation().getWorld().playSound(c.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1.0f, 1.0f); + SoundUtils.playGlobalSound(c.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1.0f, 1.0f); //c.getLocation().getWorld().createExplosion(c.getLocation().getX(),c.getLocation().getY(),c.getLocation().getZ(),8.0f,false,false); GenericFunctions.RandomlyCreateFire(c.getLocation(),4); }} @@ -4912,7 +5028,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { droplist.addAll(originaldroplist); break; case DEADLY: - m.getWorld().playSound(m.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1.0f, 1.0f); + SoundUtils.playGlobalSound(m.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1.0f, 1.0f); totalexp=ev.getDroppedExp()*8; ev.setDroppedExp((int)(totalexp*0.75)); final Monster mer = m; @@ -4943,7 +5059,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ,50); break; case HELLFIRE: - m.getWorld().playSound(m.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1.0f, 1.0f); + SoundUtils.playGlobalSound(m.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1.0f, 1.0f); totalexp=ev.getDroppedExp()*20; ev.setDroppedExp((int)(totalexp*0.75)); final Monster mer1 = m; @@ -4976,7 +5092,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ,50); break; case END: - m.getWorld().playSound(m.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1.0f, 1.0f); + SoundUtils.playGlobalSound(m.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1.0f, 1.0f); totalexp=ev.getDroppedExp()*40; ev.setDroppedExp((int)(totalexp*0.75)); final Monster mer4 = m; @@ -5024,7 +5140,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { 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); + log(" Drops "+"["+(drop.size()+originaldroplist.size())+"]: "+ChatColor.GOLD+ChatColor.stripColor(originaldroplist.toString())+ChatColor.WHITE+","+ChatColor.LIGHT_PURPLE+ChatColor.stripColor(drop.toString()),LOOT_DEBUG); } livingentitydata.remove(m.getUniqueId()); @@ -5181,7 +5297,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { lp.setReapplicationDelay(20); lp.setBasePotionData(new PotionData(PotionType.INSTANT_DAMAGE)); lp.setParticle(Particle.SMOKE_NORMAL); - p.playSound(p.getLocation(), Sound.ENTITY_SHULKER_SHOOT, 1.0f, 0.5f); + SoundUtils.playLocalSound(p, Sound.ENTITY_SHULKER_SHOOT, 1.0f, 0.5f); pd.last_shovelspell=getServerTickTime()+EARTHWAVE_COOLDOWN; aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), 300); aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), 300); @@ -5239,7 +5355,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { int shopID = TwosideShops.GetShopID(s); WorldShop shop = TwosideShops.LoadWorldShopData(shopID); String owner = shop.GetOwner(); - if (owner.equalsIgnoreCase(p.getName()) || p.isOp()) { + if (owner.equalsIgnoreCase(p.getName()) || p.isOp() || owner.equalsIgnoreCase("admin")) { //We are going to see if this shop had items in it. /*if (shop.GetAmount()>0) { //LEGACY CODE. //It did, we are going to release those items. @@ -5363,7 +5479,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (a.hasMetadata("DOUBLE_DAMAGE_ARR")) {item=Recipes.getArrowFromMeta("DOUBLE_DAMAGE_ARR"); specialarrow=true;} if (specialarrow) { ev.getItem().remove(); - ev.getPlayer().playSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f); + SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f); ev.setCancelled(true); AddToPlayerInventory(item, p); //ev.getItem().setItemStack(item); @@ -5372,7 +5488,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ItemStack collect = CustomItem.convertArrowEntityFromMeta(ev.getArrow()); if (collect!=null) { ev.getItem().remove(); - ev.getPlayer().playSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f); + SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f); AddToPlayerInventory(collect, p); ev.setCancelled(true); return; @@ -5424,7 +5540,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } if (AutoConsumeItem(p,ev.getItem().getItemStack())) { - ev.getPlayer().playSound(ev.getPlayer().getLocation(), Sound.ENTITY_GENERIC_EAT, 1.0f, 1.0f); + SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_GENERIC_EAT, 1.0f, 1.0f); ev.getItem().remove(); ev.setCancelled(true); return; @@ -5439,7 +5555,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (GenericFunctions.isValidArrow(ev.getItem().getItemStack())) { ev.setCancelled(true); ev.getItem().remove(); - ev.getPlayer().playSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f); + SoundUtils.playGlobalSound(ev.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f); AddToPlayerInventory(ev.getItem().getItemStack(), p); } } @@ -5474,7 +5590,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { !PlayerMode.isSlayer(p)) { p.getEquipment().setBoots(armor); p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item))); - p.playSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f); GenericFunctions.playProperEquipSound(p,armor.getType()); p.updateInventory(); return true; @@ -5485,7 +5601,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { !PlayerMode.isSlayer(p)) { p.getEquipment().setLeggings(armor); p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item))); - p.playSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f); GenericFunctions.playProperEquipSound(p,armor.getType()); p.updateInventory(); return true; @@ -5496,7 +5612,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { !PlayerMode.isSlayer(p)) { p.getEquipment().setChestplate(armor); p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item))); - p.playSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f); GenericFunctions.playProperEquipSound(p,armor.getType()); p.updateInventory(); return true; @@ -5507,7 +5623,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { !PlayerMode.isSlayer(p)) { p.getEquipment().setHelmet(armor); p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item))); - p.playSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f); GenericFunctions.playProperEquipSound(p,armor.getType()); p.updateInventory(); return true; @@ -5522,7 +5638,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { p.getInventory().setExtraContents(new ItemStack[]{armor}); } p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item))); - p.playSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f); GenericFunctions.playProperEquipSound(p,armor.getType()); p.updateInventory(); return true; @@ -5535,7 +5651,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { p.getInventory().setExtraContents(new ItemStack[]{armor}); } p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item))); - p.playSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f); GenericFunctions.playProperEquipSound(p,armor.getType()); p.updateInventory(); return true; @@ -5543,7 +5659,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (ArrowQuiver.isValidQuiver(armor) && p.getInventory().getExtraContents()[0]==null) { p.getInventory().setExtraContents(new ItemStack[]{armor}); p.sendMessage(ChatColor.DARK_AQUA+"Automatically equipped "+ChatColor.YELLOW+(item.getItemMeta().hasDisplayName()?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item))); - p.playSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f); GenericFunctions.playProperEquipSound(p,armor.getType()); p.updateInventory(); return true; @@ -5646,7 +5762,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (ArrowQuiver.isValidQuiver(item)) { boolean infinitearrow=false; int prevmode = ArrowQuiver.getArrowQuiverMode(((Player)arr.getShooter()).getInventory().getContents()[slot]); - int amtremaining = ArrowQuiver.getContents(ArrowQuiver.getID(((Player)arr.getShooter()).getInventory().getContents()[slot])).get(prevmode).clone().getAmount(); + List inv = ArrowQuiver.getContents(ArrowQuiver.getID(((Player)arr.getShooter()).getInventory().getContents()[slot])); + int amtremaining=0; + if (inv.size()>0) { + amtremaining = inv.get(prevmode).clone().getAmount(); + } if (ArrowQuiver.isQuiverEmpty(item)) { ((Player)arr.getShooter()).sendMessage(ChatColor.YELLOW+"Your quiver ran out of arrows! "+ChatColor.WHITE+"You will need to fill it up again!"); ev.setCancelled(true); @@ -5670,15 +5790,21 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ev.setCancelled(true); } } + final int amt = amtremaining; //((Player)arr.getShooter()).playSound(arr.getLocation(),Sound.ENTITY_ARROW_SHOOT,1.0f,1.0f); //ev.setProjectile(ArrowQuiver.getProjectileFromQuiver(((Player)arr.getShooter()).getEquipment().getItemInOffHand(), arr)); final ItemStack quiver = item.clone(); - Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {((Player)arr.getShooter()).getInventory().setItem(slot, quiver); - ArrowQuiver.updateQuiverLore(((Player)arr.getShooter()).getInventory().getContents()[slot]); - int currmode = ArrowQuiver.getArrowQuiverMode(((Player)arr.getShooter()).getInventory().getContents()[slot]); - int newamtremaining = ArrowQuiver.getContents(ArrowQuiver.getID(((Player)arr.getShooter()).getInventory().getContents()[slot])).get(currmode).getAmount(); - TwosideKeeper.log("prevmode: "+prevmode+", currmode: "+currmode+", remaining: "+amtremaining+", newremaining: "+newamtremaining, 5); - if (prevmode!=currmode || newamtremaining>amtremaining) { + Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> { + ((Player)arr.getShooter()).getInventory().setItem(slot, quiver); + ArrowQuiver.updateQuiverLore(((Player)arr.getShooter()).getInventory().getContents()[slot]); + int currmode = ArrowQuiver.getArrowQuiverMode(((Player)arr.getShooter()).getInventory().getContents()[slot]); + int newamtremaining = 0; + List newinv = ArrowQuiver.getContents(ArrowQuiver.getID(((Player)arr.getShooter()).getInventory().getContents()[slot])); + if (newinv.size()>0) { + newamtremaining = newinv.get(currmode).getAmount(); + } + TwosideKeeper.log("prevmode: "+prevmode+", currmode: "+currmode+", remaining: "+amt+", newremaining: "+newamtremaining, 5); + if (prevmode!=currmode || newamtremaining>amt) { String message = ChatColor.DARK_GRAY+"Now Firing "+ChatColor.YELLOW+GenericFunctions.UserFriendlyMaterialName(ArrowQuiver.getContents(ArrowQuiver.getID(((Player)arr.getShooter()).getInventory().getContents()[slot])).get(currmode))+ChatColor.GRAY+" ["+ArrowQuiver.getContents(ArrowQuiver.getID(((Player)arr.getShooter()).getInventory().getContents()[slot])).get(currmode).getAmount()+"]"; GenericFunctions.sendActionBarMessage((Player)arr.getShooter(), message, true); } @@ -5706,7 +5832,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } public static void ShootPiercingArrow(Projectile arr, Player p) { PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); - p.playSound(p.getLocation(), Sound.ENTITY_ARROW_SHOOT, 1.0f, 1.6f); + SoundUtils.playLocalSound(p, Sound.ENTITY_ARROW_SHOOT, 1.0f, 1.6f); pd.lastarrowwasinrangermode=true; Collection targets = aPlugin.API.rayTraceTargetEntities(p, 100); Location arrowloc = arr.getLocation().clone(); @@ -6410,6 +6536,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { getConfig().addDefault("ARTIFACT_RARITY", ARTIFACT_RARITY); getConfig().addDefault("SERVER_TYPE", SERVER_TYPE.GetValue()); getConfig().addDefault("LAST_ELITE_SPAWN", LAST_ELITE_SPAWN); + getConfig().addDefault("WORLD_SHOP_DIST", worldShopDistanceSquared); + getConfig().addDefault("WORLD_SHOP_MULT", worldShopPriceMult); getConfig().options().copyDefaults(true); saveConfig(); SERVERTICK = getConfig().getLong("SERVERTICK"); @@ -6443,6 +6571,8 @@ 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"); + worldShopDistanceSquared = getConfig().getDouble("WORLD_SHOP_DIST"); + worldShopPriceMult = getConfig().getDouble("WORLD_SHOP_MULT"); if (getConfig().contains("ELITE_LOCATION_X")) { int x = getConfig().getInt("ELITE_LOCATION_X"); int z = getConfig().getInt("ELITE_LOCATION_Z"); @@ -6674,14 +6804,14 @@ public class TwosideKeeper extends JavaPlugin implements Listener { * 058E:Clockwise portal */ bar+=ChatColor.DARK_PURPLE+""+Character.toString((char)0x25CA); - //bar+=ChatColor.DARK_PURPLE+""+"�"; + //bar+=ChatColor.DARK_PURPLE+""+"�"; } else if (inEnd) { /* 058D:Counter-clockwise portal * 058E:Clockwise portal */ bar+=ChatColor.DARK_BLUE+""+Character.toString((char)0x25CA); - //bar+=ChatColor.DARK_PURPLE+""+"�"; + //bar+=ChatColor.DARK_PURPLE+""+"�"; } return bar; @@ -7336,7 +7466,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public void run() { DecimalFormat df = new DecimalFormat("0.00"); if (l!=null && damager!=null) { - TwosideKeeper.log(GenericFunctions.GetEntityDisplayName(damager)+"->"+GenericFunctions.GetEntityDisplayName(l)+" dealt "+dmg+" damage."+ChatColor.AQUA+" HP: "+ChatColor.YELLOW+df.format(hp)+"->"+df.format(l.getHealth()), 2); + TwosideKeeper.log(GenericFunctions.GetEntityDisplayName(damager)+"->"+GenericFunctions.GetEntityDisplayName(l)+" dealt "+dmg+" damage."+ChatColor.AQUA+" HP: "+ChatColor.YELLOW+df.format(hp)+"->"+df.format(l.getHealth()), COMBAT_DEBUG); } } },1); @@ -7360,7 +7490,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } public static void breakdownItem(ItemStack item, Player p) { - p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); p.sendMessage(ChatColor.DARK_RED+"Your "+ChatColor.YELLOW+((item.hasItemMeta() && item.getItemMeta().hasDisplayName())?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item))+ChatColor.DARK_RED+" has broken!"); } } \ No newline at end of file diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java b/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java index ddf9ea8..1edc978 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java @@ -335,6 +335,9 @@ public final class TwosideKeeperAPI { public static boolean isWorldShop(Block b) { return WorldShop.shopSignExists(b); } + public static boolean isWorldShopSign(Block b) { + return WorldShop.isWorldShopSign(b); + } public static boolean hasPermissionToBreakWorldShopSign(Sign s, Player p) { return WorldShop.hasPermissionToBreakWorldShopSign(s,p); } diff --git a/src/sig/plugin/TwosideKeeper/WorldShopManager.java b/src/sig/plugin/TwosideKeeper/WorldShopManager.java index bafd96e..a5739c6 100644 --- a/src/sig/plugin/TwosideKeeper/WorldShopManager.java +++ b/src/sig/plugin/TwosideKeeper/WorldShopManager.java @@ -273,14 +273,16 @@ public class WorldShopManager { FileConfiguration workable = YamlConfiguration.loadConfiguration(config); //workable.set("recycling_center.count", nodes.size()); + int counter=0; for (int i=0;i4.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; + } + + 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", 2); + pd.storedbowxp=0; + } + + 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); + } + + 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; + } + } - pd.highwinder=ArtifactAbility.containsEnchantment(ArtifactAbility.HIGHWINDER, p.getEquipment().getItemInMainHand()); - if (pd.highwinder) { - pd.highwinderdmg=GenericFunctions.getAbilityValue(ArtifactAbility.HIGHWINDER, p.getEquipment().getItemInMainHand()); + 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()<=4) { + GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.SPEED,20,1,p); + } + } + if (ArtifactAbility.containsEnchantment(ArtifactAbility.SHADOWWALKER, p.getEquipment().getItemInMainHand()) && + p.isOnGround() && p.getLocation().getY()>=0 && p.getLocation().getY()<=255 && p.getLocation().add(0,0,0).getBlock().getLightLevel()<=4) { + GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.SPEED,20,1,p); + //log("Apply speed. The light level here is "+p.getLocation().add(0,-1,0).getBlock().getLightLevel(),2); + } + + //PopulatePlayerBlockList(p,15,15,2,5,false); + PopRandomLavaBlock(p); + GenericFunctions.sendActionBarMessage(p, ""); + GenericFunctions.AutoRepairItems(p); + + 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. + } + + //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)); + + if (PlayerMode.isBarbarian(p)) { + AutoConsumeFoods(p); + } } - 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; - } - - 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", 2); - pd.storedbowxp=0; - } - - 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); - } - - if (GenericFunctions.hasStealth(p)) {GenericFunctions.DamageRandomTool(p);} p.getAttribute(Attribute.GENERIC_ARMOR).setBaseValue(20*(1.0d-CustomDamage.CalculateDamageReduction(1,p,null))+subtractVanillaArmorBar(p.getEquipment().getArmorContents())); @@ -245,36 +301,6 @@ final class runServerHeartbeat implements Runnable { } } - if (p.getWorld().getName().equalsIgnoreCase("world_the_end")) { - if (pd.endnotification+72000=0 && p.getLocation().getY()<=255 && p.getLocation().add(0,0,0).getBlock().getLightLevel()<=4) { - GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.SPEED,20,1,p); - } - } - if (ArtifactAbility.containsEnchantment(ArtifactAbility.SHADOWWALKER, p.getEquipment().getItemInMainHand()) && - p.isOnGround() && p.getLocation().getY()>=0 && p.getLocation().getY()<=255 && p.getLocation().add(0,0,0).getBlock().getLightLevel()<=4) { - GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.SPEED,20,1,p); - //log("Apply speed. The light level here is "+p.getLocation().add(0,-1,0).getBlock().getLightLevel(),2); - } - if (ArtifactAbility.containsEnchantment(ArtifactAbility.COMBO, p.getEquipment().getItemInMainHand()) && pd.last_swordhit+40"); } MaintainMonsterData(); @@ -305,13 +325,59 @@ final class runServerHeartbeat implements Runnable { TwosideKeeper.TwosideSpleefGames.TickEvent(); } + private void PopRandomLavaBlock(Player p) { + if (p.getWorld().getName().equalsIgnoreCase("world_nether") && + TwosideKeeper.last_lava_plume_time+(TwosideKeeper.LAVA_PLUME_COOLDOWN/(Math.max(Bukkit.getOnlinePlayers().size(),1)))=0) { + final Block b = p.getLocation().add(randomx,yrel,randomz).getBlock(); + //Schedule this 3 seconds later. + if (b.getType()==Material.STATIONARY_LAVA) { + //TwosideKeeper.log("Block ("+b.getLocation()+") is type "+b.getType(), 0); + //CreateLavaPlumeParticles(b); + //Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, ()->{}, 20*3); + CreateLavaPlume(b); + break; + } else { + if (b.getType()==Material.AIR) { + yrel--; + } else { + break; + } + } + } + } + } + + private void CreateLavaPlumeParticles(Block b) { + //aPluginAPIWrapper.sendParticle(b.getLocation().add(0,5,0), EnumParticle.DRIP_LAVA, 0, 0, 0, 0.4f, 100); + /*for (int i=0;i<100;i++) { + aPluginAPIWrapper.sendParticle(b.getLocation().add(0,Math.random()*5,0), EnumParticle.DRIP_LAVA, (float)Math.random(),(float)Math.random(),(float)Math.random(), (float)Math.random(), 5); + }*/ + } + + private void CreateLavaPlume(final Block b) { + //FallingBlock fb = b.getWorld().spawnFallingBlock(b.getLocation().add(0,1,0), Material.REDSTONE_BLOCK, (byte)0); + TwosideKeeper.lavaplume_list.add(new LavaPlume(90,b.getLocation())); + /*fb.setMetadata("DESTROY", new FixedMetadataValue(TwosideKeeper.plugin,true)); + fb.setVelocity(new Vector(0,(float)((Math.random()*8)+2),0)); + for (Player pl : Bukkit.getOnlinePlayers()) { + GlowAPI.setGlowing(fb, GlowAPI.Color.YELLOW, pl); + }*/ + } + private void AutoConsumeFoods(Player p) { if (p.getFoodLevel()<20 && PlayerMode.getPlayerMode(p)==PlayerMode.BARBARIAN) { ItemStack[] contents = p.getInventory().getStorageContents(); for (int i=0;i data= TwosideKeeper.livingentitydata.keySet(); - TwosideKeeper.log("Size: "+TwosideKeeper.livingentitydata.size(), 2); + TwosideKeeper.log("Size: "+TwosideKeeper.livingentitydata.size(), 5); for (UUID id : data) { LivingEntityStructure ms = TwosideKeeper.livingentitydata.get(id); if (!ms.m.isValid()) { @@ -383,33 +449,33 @@ final class runServerHeartbeat implements Runnable { @Override public void run() { p.sendMessage(ChatColor.BLUE+" \"You DO NOT BELONG HERE.\""); - p.playSound(p.getLocation(), Sound.ENTITY_GHAST_SCREAM, 1.0f, 1.0f); - p.playSound(p.getLocation(), Sound.ENTITY_GHAST_AMBIENT, 1.0f, 1.0f); - p.playSound(p.getLocation(), Sound.ENTITY_GHAST_SHOOT, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_GHAST_SCREAM, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_GHAST_AMBIENT, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_GHAST_SHOOT, 1.0f, 1.0f); } },20); Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() { @Override public void run() { - p.playSound(p.getLocation().add(0,20,0), Sound.ENTITY_GHAST_WARN, 1.0f, 1.0f); - p.playSound(p.getLocation(), Sound.ENTITY_GHAST_AMBIENT, 1.0f, 1.0f); - p.playSound(p.getLocation(), Sound.ENTITY_GHAST_SHOOT, 1.0f, 1.0f); + SoundUtils.playLocalSound(p,p.getLocation().add(0,20,0), Sound.ENTITY_GHAST_WARN, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_GHAST_AMBIENT, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_GHAST_SHOOT, 1.0f, 1.0f); } },23); Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() { @Override public void run() { - p.playSound(p.getLocation().add(-10,0,-5), Sound.ENTITY_GHAST_SCREAM, 1.0f, 1.0f); - p.playSound(p.getLocation(), Sound.ENTITY_GHAST_AMBIENT, 1.0f, 1.0f); - p.playSound(p.getLocation(), Sound.ENTITY_GHAST_SHOOT, 1.0f, 1.0f); + SoundUtils.playLocalSound(p,p.getLocation().add(-10,0,-5), Sound.ENTITY_GHAST_SCREAM, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_GHAST_AMBIENT, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_GHAST_SHOOT, 1.0f, 1.0f); } },27); Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() { @Override public void run() { - p.playSound(p.getLocation().add(-10,0,-5), Sound.ENTITY_GHAST_SCREAM, 1.0f, 1.0f); - p.playSound(p.getLocation(), Sound.ENTITY_GHAST_AMBIENT, 1.0f, 1.0f); - p.playSound(p.getLocation(), Sound.ENTITY_GHAST_SHOOT, 1.0f, 1.0f); + SoundUtils.playLocalSound(p,p.getLocation().add(-10,0,-5), Sound.ENTITY_GHAST_SCREAM, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_GHAST_AMBIENT, 1.0f, 1.0f); + SoundUtils.playLocalSound(p, Sound.ENTITY_GHAST_SHOOT, 1.0f, 1.0f); } },30); Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {