diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index 6043451..20265cd 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/sig/plugin/TwosideKeeper/CustomDamage.java b/src/sig/plugin/TwosideKeeper/CustomDamage.java index 9525b9b..5058b6c 100644 --- a/src/sig/plugin/TwosideKeeper/CustomDamage.java +++ b/src/sig/plugin/TwosideKeeper/CustomDamage.java @@ -1936,4 +1936,11 @@ public class CustomDamage { PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); return pd.lasthitdesc; } + + /*Returns the amount of cooldown reduction the player has. + * 0% meaning cooldowns are not reduced at all. 100% meaning cooldowns should be non-existent. + */ + public static double calculateCooldownReduction(Player p) { + return 0.0; + } } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java index 423a034..6e270d7 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java @@ -3647,4 +3647,34 @@ public class GenericFunctions { p.addPotionEffect(neweffect); } } + + public static boolean hasSlayerSetItemOnHotbar(Player p) { + for (int i=0;i<9;i++) { + if (i==9) { + i=40; + } + ItemStack item = p.getInventory().getContents()[i]; + ItemSet set = TwosideKeeperAPI.getItemSet(item); + if (set!=null && + (set==ItemSet.LORASYS || + set==ItemSet.GLADOMAIN || + set==ItemSet.MOONSHADOW)) { + return true; + } + } + return false; + } + + public static boolean WearingNoArmor(Player p) { + ItemStack[] armor = p.getEquipment().getArmorContents(); + boolean hasArmor=false; + for (int i=0;i0 && Math.random()<=0.5) { tierbonus=0; } - } + }*/ return tierbonus; } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/PlayerMode.java b/src/sig/plugin/TwosideKeeper/HelperStructures/PlayerMode.java index 32c3b3e..35e345a 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/PlayerMode.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/PlayerMode.java @@ -19,8 +19,8 @@ public enum PlayerMode { + ChatColor.WHITE+"->Dropping your weapon will perform a line drive. Enemies you charge through take x7 your base damage. This costs 5% of your durability (Unbreaking decreases this amount.)\n" + ChatColor.GRAY+"->Strikers have a 20% chance to dodge incoming attacks from any damage source while moving.\n" + ChatColor.WHITE+"->Hitting a target when they have not noticed you yet does x3 normal damage.\n"), - RANGER(ChatColor.GREEN,"R","Ranger", - ChatColor.GREEN+""+ChatColor.BOLD+"Ranger mode Perks: "+ChatColor.RESET+"\n" + RANGER(ChatColor.DARK_GREEN,"R","Ranger", + ChatColor.DARK_GREEN+""+ChatColor.BOLD+"Ranger mode Perks: "+ChatColor.RESET+"\n" + ChatColor.WHITE+"->Players are identified as 'Rangers' when they carry a bow in their main hand. Off-hand items are permitted, except for a shield. Can only be wearing leather armor, or no armor.\n" + ChatColor.GRAY+"->Left-clicking mobs will cause them to be knocked back extremely far, basically in headshot range, when walls permit.\n" + ChatColor.WHITE+"->Base Arrow Damage increases from x2->x4.\n" @@ -90,6 +90,9 @@ public enum PlayerMode { public static PlayerMode getPlayerMode(Player p) { PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); if (needsUpdating(pd)) { + if (isSlayer(p)) { + pd.lastmode=PlayerMode.SLAYER; + } else if (isStriker(p)) { pd.lastmode=PlayerMode.STRIKER; } else @@ -166,6 +169,24 @@ public enum PlayerMode { return false; } } + + public static boolean isSlayer(Player p) { + if (p!=null && !p.isDead()) { + PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + if (needsUpdating(pd)) { + if (p.getEquipment().getItemInMainHand()!=null && GenericFunctions.hasSlayerSetItemOnHotbar(p) && + GenericFunctions.WearingNoArmor(p)) { + return true; + } else { + return false; + } + } else { + return pd.lastmode==PlayerMode.SLAYER; + } + } else { + return false; + } + } String name=""; String desription=""; diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index 88e7426..8ad8924 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -6,8 +6,10 @@ import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Random; +import java.util.Set; import java.util.UUID; import org.apache.commons.lang.WordUtils; @@ -46,7 +48,9 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.TippedArrow; +import org.bukkit.entity.Vehicle; import org.bukkit.entity.Witch; +import org.bukkit.entity.minecart.HopperMinecart; import org.bukkit.event.Event.Result; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -174,6 +178,633 @@ import sig.plugin.TwosideKeeper.Logging.MysteriousEssenceLogger; public class TwosideKeeper extends JavaPlugin implements Listener { + private final class GivePlayerPurchasedItems implements Runnable { + private final Chest cc; + private final AsyncPlayerChatEvent ev; + private final ItemStack dropitem; + + private GivePlayerPurchasedItems(Chest cc, AsyncPlayerChatEvent ev, ItemStack dropitem) { + this.cc = cc; + this.ev = ev; + this.dropitem = dropitem; + } + + @Override + public void run() { + //ev.getPlayer().getWorld().dropItem(ev.getPlayer().getLocation(), dropitem).setPickupDelay(0); + GenericFunctions.giveItem(ev.getPlayer(), dropitem); + cc.getInventory().removeItem(dropitem); + } + } + + private final class CreateWorldPurchaseShop implements Runnable { + private final WorldShopSession current_session; + private final double amt; + private final DecimalFormat df; + private final AsyncPlayerChatEvent ev; + + private CreateWorldPurchaseShop(WorldShopSession current_session, double amt, DecimalFormat df, + AsyncPlayerChatEvent ev) { + this.current_session = current_session; + this.amt = amt; + this.df = df; + this.ev = ev; + } + + @Override + public void run() { + WorldShop newshop = TwosideShops.CreateWorldShop(current_session.GetSign(), current_session.getItem(), current_session.getAmt(), Double.parseDouble(df.format(amt)), ev.getPlayer().getName(),true); + TwosideShops.SaveWorldShopData(newshop); + WorldShop.spawnShopItem(current_session.GetSign().getLocation(), newshop); + notWorldShop.remove(WorldShop.getBlockShopSignAttachedTo(current_session.GetSign())); + TwosideShops.RemoveSession(ev.getPlayer()); + } + } + + private final class CreateWorldShop implements Runnable { + private final DecimalFormat df; + private final double amt; + private final AsyncPlayerChatEvent ev; + private final WorldShopSession current_session; + + private CreateWorldShop(DecimalFormat df, double amt, AsyncPlayerChatEvent ev, + WorldShopSession current_session) { + this.df = df; + this.amt = amt; + this.ev = ev; + this.current_session = current_session; + } + + @Override + public void run() { + WorldShop newshop = TwosideShops.CreateWorldShop(current_session.GetSign(), current_session.getItem(), current_session.getAmt(), Double.parseDouble(df.format(amt)), ev.getPlayer().getName()); + WorldShop.spawnShopItem(current_session.GetSign().getLocation(), newshop); + notWorldShop.remove(WorldShop.getBlockShopSignAttachedTo(current_session.GetSign())); + TwosideShops.SaveWorldShopData(newshop); + //RemoveItemAmount(ev.getPlayer(), current_session.getItem(), current_session.getAmt()); //We now handle items via chest. + TwosideShops.RemoveSession(ev.getPlayer()); + } + } + + private final class WriteAndSignCheck implements Runnable { + private final ItemStack finalcheck; + private final ItemStack check; + private final AsyncPlayerChatEvent ev; + + private WriteAndSignCheck(ItemStack finalcheck, ItemStack check, AsyncPlayerChatEvent ev) { + this.finalcheck = finalcheck; + this.check = check; + this.ev = ev; + } + + @Override + public void run() { + if (check.getAmount()>1) { + check.setAmount(check.getAmount()-1); + ev.getPlayer().getLocation().getWorld().dropItem(ev.getPlayer().getLocation(), finalcheck); + } else { + ev.getPlayer().getEquipment().setItemInMainHand(finalcheck); + } + } + } + + private final class ShutdownServerForUpdate implements Runnable { + @Override + public void run() { + if (Bukkit.getOnlinePlayers().size()==0 && restarting_server) { + Bukkit.savePlayers(); + aPlugin.API.discordSendRawItalicized("All players have disconnected. Server is shutting down..."); + for (int i=0;i=SERVERCHECKERTICKS) { //15 MINUTES (DEFAULT) + saveOurData(); + + //Advertisement messages could go here. + //MOTD: "Thanks for playing on Sig's Minecraft!\n*bCheck out http://z-gamers.net/mc for update info!\n*aReport any bugs you find at http://zgamers.domain.com/mc/" + getMOTD(); + getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('*', MOTD)); + habitat_data.increaseHabitationLevels(); + habitat_data.startinglocs.clear(); + for (int i=0;i=12000) { + Collection players = getServer().getOnlinePlayers(); + //Count the number of players sleeping. Compare to "sleepingplayers" count. + log("[DEBUG] Time: "+Bukkit.getWorld("world").getTime()+" Full Time: "+Bukkit.getWorld("world").getFullTime() + " SERVERTICKTIME: "+getServerTickTime(),4); + //This functionality only makes sense when two or more players are on. + int sleeping=0; + for (int i=0;i1) { + getServer().broadcastMessage(ChatColor.GOLD+""+sleepingPlayers+" Player"+(sleepingPlayers!=1?"s are":" is")+" in bed "+ChatColor.WHITE+"("+sleepingPlayers+"/"+(players.size()/2)+")"); + } + } + if (sleepingPlayers>=Math.max(players.size()/2,1)) { + //Make it the next day. + if (players.size()>1) { + getServer().broadcastMessage(ChatColor.GOLD+"Enough Players sleeping! It's now morning!"); + } + /*Bukkit.getWorld("world").setFullTime(Bukkit.getWorld("world").getFullTime()+10); + + SERVERTICK=getServerTickTime();*/ + long temptime = Bukkit.getWorld("world").getFullTime(); + Bukkit.getWorld("world").setTime(0); + time_passed+=temptime-Bukkit.getWorld("world").getFullTime(); + Bukkit.getWorld("world").setThundering(false); + /* + STARTTIME=Bukkit.getWorld("world").getFullTime(); + LASTSERVERCHECK=getServerTickTime();*/ + //Make sure we keep SERVERTICK in check. + sleepingPlayers=0; + } + } + + if (getServerTickTime()-LastClearStructureTime>=100) { + //Perform a clear of Monster Structure. + for(UUID id : monsterdata.keySet()) { + MonsterStructure mon = monsterdata.get(id); + Monster m = mon.m; + if (!m.isValid()) { + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, + () -> { + monsterdata.remove(id); + log("Removed one from Structure",5); + }, 1); + } + if (mon.isLeader || MonsterController.isZombieLeader(m)) { + //Make it glow red. + GenericFunctions.setGlowing(m, GlowAPI.Color.DARK_RED); + } + if (mon.isElite || MonsterController.getMonsterDifficulty(m)==MonsterDifficulty.ELITE) { + //Make it glow dark purple. + GenericFunctions.setGlowing(m, GlowAPI.Color.DARK_PURPLE); + boolean hasstruct = false; + for (int i=0;ipd.debuffcount) { + ItemStack[] equips = p.getEquipment().getArmorContents(); + double removechance = 0.0; + log("Debuffcount went up...",5); + for (int i1=0;i14.317) { + pd.velocity/=2; + } else { + pd.velocity=0; + } + if (pd.highwinder && pd.target!=null && !pd.target.isDead()) { + aPlugin.API.sendActionBarMessage(p, drawVelocityBar(pd.velocity,pd.highwinderdmg)); + } + 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<=getServerTickTime() && 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; + } + + p.getAttribute(Attribute.GENERIC_ARMOR).setBaseValue(20*(1.0d-CustomDamage.CalculateDamageReduction(1,p,null))+subtractVanillaArmorBar(p.getEquipment().getArmorContents())); + + if (pd.last_regen_time+HEALTH_REGENERATION_RATE<=getServerTickTime()) { + pd.last_regen_time=getServerTickTime(); + //See if this player needs to be healed. + if (p!=null && + !p.isDead() && //Um, don't heal them if they're dead...That's just weird. + p.getHealth()=16) { + + double totalregen = 1+(p.getMaxHealth()*0.05); + ItemStack[] equips = p.getEquipment().getArmorContents(); + double bonusregen = 0.0; + for (int i1=0;i1p.getMaxHealth())?p.getMaxHealth():p.getHealth()+totalregen); + + } + } + //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()) {log("Player is not dead.",5); setPlayerMaxHealth(p);} + p.getScoreboard().getTeam(p.getName().toLowerCase()).setSuffix(createHealthbar(((p.getHealth())/p.getMaxHealth())*100,p)); + p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(GenericFunctions.PlayerModePrefix(p)); + /*double old_weapondmg = pd.prev_weapondmg; + double old_buffdmg = pd.prev_buffdmg; + double old_partydmg = pd.prev_partydmg; + double old_armordef = pd.prev_armordef; + double store1=CalculateDamageReduction(1,p,p); + + double store2=old_weapondmg; + if (GenericFunctions.isWeapon(p.getEquipment().getItemInMainHand())) { + store2 = CalculateWeaponDamage(p,null); + } + if (store1!=pd.damagereduction || store2!=pd.damagedealt) { + log("Values: "+old_weapondmg+"," + +old_buffdmg+"," + +old_partydmg+"," + +old_armordef+"::"+pd.prev_weapondmg+"," + +pd.prev_buffdmg+"," + +pd.prev_partydmg+"," + +pd.prev_armordef,5); + pd.damagereduction = store1; + pd.damagedealt = store2; + DecimalFormat df = new DecimalFormat("0.0"); + if (((old_weapondmg != pd.prev_weapondmg && GenericFunctions.isWeapon(p.getEquipment().getItemInMainHand())) || + (old_armordef != pd.prev_armordef)) + && old_partydmg == pd.prev_partydmg && old_buffdmg == pd.prev_buffdmg) { + p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Base Damage: "+ChatColor.RESET+""+ChatColor.DARK_PURPLE+df.format(pd.damagedealt)+" "+ChatColor.GRAY+ChatColor.ITALIC+"Damage Reduction: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+Math.round((1.0-pd.damagereduction)*100)+"%"); + } + }*/ + for (int i3=0;i3=0 && p.getLocation().getY()<=255 && p.getLocation().add(0,0,0).getBlock().getLightLevel()<=4) { + p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,20,1)); + } + } + 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) { + p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,20,1)); + //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+400) { + DiscordMessageSender.sendToSpam(finalstring.toString()); + } + } + + private double subtractVanillaArmorBar(ItemStack[] armorContents) { + double lostamt = 0.0d; + for (int i=0;i0) { + if (p.hasPotionEffect(PotionEffectType.ABSORPTION)) { + int oldlv = GenericFunctions.getPotionEffectLevel(PotionEffectType.ABSORPTION, p)+1; + p.removePotionEffect(PotionEffectType.ABSORPTION); + p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION,599,(int)(absorption_amt/4)+oldlv)); + } else { + p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION,599,(int)(absorption_amt/4))); + } + } + } + } + } + + private final class ControlChargeZombies implements Runnable { + public void run(){ + //Control charge zombies.. + for (int i=0;i32) { + //This has to be removed... + chargezombies.remove(i); + i--; + } else { + //This is fine! Clear away blocks. + Monster m = cz.GetZombie(); + if (m.getTarget().getLocation().getY()>=m.getLocation().getY()+2 && + Math.abs(m.getTarget().getLocation().getX()-m.getLocation().getX())<1 && + Math.abs(m.getTarget().getLocation().getZ()-m.getLocation().getZ())<1) { + //This target is higher than we can reach... Let's pillar. + Random r = new Random(); + r.setSeed(m.getUniqueId().getMostSignificantBits()); + //Block type is chosen based on the seed. Will be cobblestone, dirt, or gravel. + if (m.getLocation().getBlock().getType()==Material.AIR && + m.getLocation().add(0,-1,0).getBlock().getType()!=Material.AIR && + !m.getLocation().add(0,-1,0).getBlock().isLiquid()) { + m.setVelocity(new Vector(0,0.5,0)); + if (m.getLocation().getWorld().getName().equalsIgnoreCase("world_nether")) { + m.getLocation().getBlock().setType(Material.NETHERRACK); + m.getLocation().getWorld().playSound(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); + }break; + case 1:{ + m.getLocation().getBlock().setType(Material.COBBLESTONE); + m.getLocation().getWorld().playSound(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); + }break; + } + } + } + } + cz.BreakBlocksAroundArea(1); + } + } + //Control elite monsters. + for (int i=0;i TEMPORARYABILITIES = new ArrayList(); + public static Set notWorldShop = new HashSet(); public static CustomItem HUNTERS_COMPASS; public static CustomItem UPGRADE_SHARD; @@ -493,71 +1125,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener { Loot.DefineLootChests(); } - getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){ - public void run(){ - for (Player p : Bukkit.getOnlinePlayers()) { - PlayerMode.getPlayerMode(p); - } - } - },0l,10l); + getServer().getScheduler().scheduleSyncRepeatingTask(this, new SetupPlayerMode(),0l,10l); - getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){ - public void run(){ - //Control charge zombies.. - for (int i=0;i32) { - //This has to be removed... - chargezombies.remove(i); - i--; - } else { - //This is fine! Clear away blocks. - Monster m = cz.GetZombie(); - if (m.getTarget().getLocation().getY()>=m.getLocation().getY()+2 && - Math.abs(m.getTarget().getLocation().getX()-m.getLocation().getX())<1 && - Math.abs(m.getTarget().getLocation().getZ()-m.getLocation().getZ())<1) { - //This target is higher than we can reach... Let's pillar. - Random r = new Random(); - r.setSeed(m.getUniqueId().getMostSignificantBits()); - //Block type is chosen based on the seed. Will be cobblestone, dirt, or gravel. - if (m.getLocation().getBlock().getType()==Material.AIR && - m.getLocation().add(0,-1,0).getBlock().getType()!=Material.AIR && - !m.getLocation().add(0,-1,0).getBlock().isLiquid()) { - m.setVelocity(new Vector(0,0.5,0)); - if (m.getLocation().getWorld().getName().equalsIgnoreCase("world_nether")) { - m.getLocation().getBlock().setType(Material.NETHERRACK); - m.getLocation().getWorld().playSound(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); - }break; - case 1:{ - m.getLocation().getBlock().setType(Material.COBBLESTONE); - m.getLocation().getWorld().playSound(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); - }break; - } - } - } - } - cz.BreakBlocksAroundArea(1); - } - } - //Control elite monsters. - for (int i=0;i0) { - if (p.hasPotionEffect(PotionEffectType.ABSORPTION)) { - int oldlv = GenericFunctions.getPotionEffectLevel(PotionEffectType.ABSORPTION, p)+1; - p.removePotionEffect(PotionEffectType.ABSORPTION); - p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION,599,(int)(absorption_amt/4)+oldlv)); - } else { - p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION,599,(int)(absorption_amt/4))); - } - } - } - } - },0l,600l); + getServer().getScheduler().scheduleSyncRepeatingTask(this, new ReapplyAbsorptionHeartsFromSet(),0l,600l); + //This is the constant timing method. - getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){ - @SuppressWarnings("deprecation") - public void run(){ - log("Server time passed: "+(Bukkit.getWorld("world").getFullTime()-STARTTIME)+". New Server Time: "+(Bukkit.getWorld("world").getFullTime()-STARTTIME+SERVERTICK),5); - //Bukkit.getWorld("world").setFullTime(Bukkit.getWorld("world").getFullTime()-10); //LEGACY CODE. - adjustServerTime(10); - //WORK IN PROGRESS: Lamp updating code TO GO HERE. - - sendAllLoggedMessagesToSpam(); - - //SAVE SERVER SETTINGS. - if (getServerTickTime()-LASTSERVERCHECK>=SERVERCHECKERTICKS) { //15 MINUTES (DEFAULT) - saveOurData(); - - //Advertisement messages could go here. - //MOTD: "Thanks for playing on Sig's Minecraft!\n*bCheck out http://z-gamers.net/mc for update info!\n*aReport any bugs you find at http://zgamers.domain.com/mc/" - getMOTD(); - getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('*', MOTD)); - habitat_data.increaseHabitationLevels(); - habitat_data.startinglocs.clear(); - for (int i=0;i=12000) { - Collection players = getServer().getOnlinePlayers(); - //Count the number of players sleeping. Compare to "sleepingplayers" count. - log("[DEBUG] Time: "+Bukkit.getWorld("world").getTime()+" Full Time: "+Bukkit.getWorld("world").getFullTime() + " SERVERTICKTIME: "+getServerTickTime(),4); - //This functionality only makes sense when two or more players are on. - int sleeping=0; - for (int i=0;i1) { - getServer().broadcastMessage(ChatColor.GOLD+""+sleepingPlayers+" Player"+(sleepingPlayers!=1?"s are":" is")+" in bed "+ChatColor.WHITE+"("+sleepingPlayers+"/"+(players.size()/2)+")"); - } - } - if (sleepingPlayers>=Math.max(players.size()/2,1)) { - //Make it the next day. - if (players.size()>1) { - getServer().broadcastMessage(ChatColor.GOLD+"Enough Players sleeping! It's now morning!"); - } - /*Bukkit.getWorld("world").setFullTime(Bukkit.getWorld("world").getFullTime()+10); - - SERVERTICK=getServerTickTime();*/ - long temptime = Bukkit.getWorld("world").getFullTime(); - Bukkit.getWorld("world").setTime(0); - time_passed+=temptime-Bukkit.getWorld("world").getFullTime(); - Bukkit.getWorld("world").setThundering(false); - /* - STARTTIME=Bukkit.getWorld("world").getFullTime(); - LASTSERVERCHECK=getServerTickTime();*/ - //Make sure we keep SERVERTICK in check. - sleepingPlayers=0; - } - } - - if (getServerTickTime()-LastClearStructureTime>=100) { - //Perform a clear of Monster Structure. - for(UUID id : monsterdata.keySet()) { - MonsterStructure mon = monsterdata.get(id); - Monster m = mon.m; - if (!m.isValid()) { - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, - () -> { - monsterdata.remove(id); - log("Removed one from Structure",5); - }, 1); - } - if (mon.isLeader || MonsterController.isZombieLeader(m)) { - //Make it glow red. - GenericFunctions.setGlowing(m, GlowAPI.Color.DARK_RED); - } - if (mon.isElite || MonsterController.getMonsterDifficulty(m)==MonsterDifficulty.ELITE) { - //Make it glow dark purple. - GenericFunctions.setGlowing(m, GlowAPI.Color.DARK_PURPLE); - boolean hasstruct = false; - for (int i=0;ipd.debuffcount) { - ItemStack[] equips = p.getEquipment().getArmorContents(); - double removechance = 0.0; - log("Debuffcount went up...",5); - for (int i1=0;i14.317) { - pd.velocity/=2; - } else { - pd.velocity=0; - } - if (pd.highwinder && pd.target!=null && !pd.target.isDead()) { - aPlugin.API.sendActionBarMessage(p, drawVelocityBar(pd.velocity,pd.highwinderdmg)); - } - 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<=getServerTickTime() && 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; - } - - p.getAttribute(Attribute.GENERIC_ARMOR).setBaseValue(20*(1.0d-CustomDamage.CalculateDamageReduction(1,p,null))+subtractVanillaArmorBar(p.getEquipment().getArmorContents())); - - if (pd.last_regen_time+HEALTH_REGENERATION_RATE<=getServerTickTime()) { - pd.last_regen_time=getServerTickTime(); - //See if this player needs to be healed. - if (p!=null && - !p.isDead() && //Um, don't heal them if they're dead...That's just weird. - p.getHealth()=16) { - - double totalregen = 1+(p.getMaxHealth()*0.05); - ItemStack[] equips = p.getEquipment().getArmorContents(); - double bonusregen = 0.0; - for (int i1=0;i1p.getMaxHealth())?p.getMaxHealth():p.getHealth()+totalregen); - - } - } - //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()) {log("Player is not dead.",5); setPlayerMaxHealth(p);} - p.getScoreboard().getTeam(p.getName().toLowerCase()).setSuffix(createHealthbar(((p.getHealth())/p.getMaxHealth())*100,p)); - p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(GenericFunctions.PlayerModePrefix(p)); - /*double old_weapondmg = pd.prev_weapondmg; - double old_buffdmg = pd.prev_buffdmg; - double old_partydmg = pd.prev_partydmg; - double old_armordef = pd.prev_armordef; - double store1=CalculateDamageReduction(1,p,p); - - double store2=old_weapondmg; - if (GenericFunctions.isWeapon(p.getEquipment().getItemInMainHand())) { - store2 = CalculateWeaponDamage(p,null); - } - if (store1!=pd.damagereduction || store2!=pd.damagedealt) { - log("Values: "+old_weapondmg+"," - +old_buffdmg+"," - +old_partydmg+"," - +old_armordef+"::"+pd.prev_weapondmg+"," - +pd.prev_buffdmg+"," - +pd.prev_partydmg+"," - +pd.prev_armordef,5); - pd.damagereduction = store1; - pd.damagedealt = store2; - DecimalFormat df = new DecimalFormat("0.0"); - if (((old_weapondmg != pd.prev_weapondmg && GenericFunctions.isWeapon(p.getEquipment().getItemInMainHand())) || - (old_armordef != pd.prev_armordef)) - && old_partydmg == pd.prev_partydmg && old_buffdmg == pd.prev_buffdmg) { - p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Base Damage: "+ChatColor.RESET+""+ChatColor.DARK_PURPLE+df.format(pd.damagedealt)+" "+ChatColor.GRAY+ChatColor.ITALIC+"Damage Reduction: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+Math.round((1.0-pd.damagereduction)*100)+"%"); - } - }*/ - for (int i3=0;i3=0 && p.getLocation().getY()<=255 && p.getLocation().add(0,0,0).getBlock().getLightLevel()<=4) { - p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,20,1)); - } - } - 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) { - p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,20,1)); - //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+400) { - DiscordMessageSender.sendToSpam(finalstring.toString()); - } - } - - private double subtractVanillaArmorBar(ItemStack[] armorContents) { - double lostamt = 0.0d; - for (int i=0;iChestplate->Leggings->Boots + [15:42:16 INFO]: Extra Contents (1 Item): + Index 0: Shield Slot + [15:42:16 INFO]: Storage Contents (36 Items): + Index 0-8: Hotbar + Index 9-35: Inventory + * + * log("Inventory Contents:",2); + ItemStack[] inv = p.getInventory().getContents(); + for (int i=0;i1) { - check.setAmount(check.getAmount()-1); - ev.getPlayer().getLocation().getWorld().dropItem(ev.getPlayer().getLocation(), finalcheck); - } else { - ev.getPlayer().getEquipment().setItemInMainHand(finalcheck); - } - } - },1); + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new WriteAndSignCheck(finalcheck, check, ev),1); } else { ev.getPlayer().sendMessage(ChatColor.YELLOW+"You are not holding a properly signed check!"); thisp.sendMessage(ChatColor.WHITE+" Cancelled out of Check signing."); @@ -1685,16 +1829,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { final double amt = Double.parseDouble(ev.getMessage()); if (amt>=0.01 && amt<=999999999999.99) { ev.getPlayer().sendMessage(ChatColor.DARK_BLUE+"Shop has been successfully created!"); - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { - @Override - public void run() { - WorldShop newshop = TwosideShops.CreateWorldShop(current_session.GetSign(), current_session.getItem(), current_session.getAmt(), Double.parseDouble(df.format(amt)), ev.getPlayer().getName()); - WorldShop.spawnShopItem(current_session.GetSign().getLocation(), newshop); - TwosideShops.SaveWorldShopData(newshop); - //RemoveItemAmount(ev.getPlayer(), current_session.getItem(), current_session.getAmt()); //We now handle items via chest. - TwosideShops.RemoveSession(ev.getPlayer()); - } - },1); + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new CreateWorldShop(df, amt, ev, current_session),1); } else { if (amt>999999999999.99) { ev.getPlayer().sendMessage("You cannot sell an item for that ridiculous amount."); @@ -1714,15 +1849,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { final double amt = Double.parseDouble(ev.getMessage()); if (amt>=0.01 && amt<=999999999999.99) { ev.getPlayer().sendMessage(ChatColor.DARK_BLUE+"Purchase Shop has been successfully created!"); - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { - @Override - public void run() { - WorldShop newshop = TwosideShops.CreateWorldShop(current_session.GetSign(), current_session.getItem(), current_session.getAmt(), Double.parseDouble(df.format(amt)), ev.getPlayer().getName(),true); - TwosideShops.SaveWorldShopData(newshop); - WorldShop.spawnShopItem(current_session.GetSign().getLocation(), newshop); - TwosideShops.RemoveSession(ev.getPlayer()); - } - },1); + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new CreateWorldPurchaseShop(current_session, amt, df, ev),1); } else { if (amt>999999999999.99) { @@ -1737,142 +1864,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener { TwosideShops.RemoveSession(ev.getPlayer()); } break; - case EDIT: - if (ev.getMessage().length()<=9 &&isNumeric(ev.getMessage()) && isInteger(ev.getMessage())) { - int amt = Integer.parseInt(ev.getMessage()); - DecimalFormat df = new DecimalFormat("0.00"); - WorldShop shop = TwosideShops.LoadWorldShopData(TwosideShops.GetShopID(current_session.GetSign())); - if (amt>=0) { - if (amt<=GenericFunctions.CountItems(ev.getPlayer(), shop.GetItem())) { - shop.UpdateAmount(shop.GetAmount()+amt); - RemoveItemAmount(ev.getPlayer(), shop.GetItem(), amt); - TwosideShops.SaveWorldShopData(shop); - WorldShopManager.UpdateSign(shop, TwosideShops.GetShopID(current_session.GetSign()), current_session.GetSign(),false); - ev.getPlayer().sendMessage("Added "+ChatColor.AQUA+amt+ChatColor.WHITE+" more "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" to your shop!"); - ev.getPlayer().sendMessage("Input how much each "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" will cost (Old value - "+ChatColor.YELLOW+"$"+df.format(shop.GetUnitPrice())+ChatColor.WHITE+"):"); - - current_session.SetSession(SessionState.UPDATE); - } else { - if (amt<=0) { - ev.getPlayer().sendMessage("You cannot add a non-existent amount of items."); - } else { - ev.getPlayer().sendMessage("You only have "+GenericFunctions.CountItems(ev.getPlayer(), shop.GetItem())+" of "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+"."); - } - TwosideShops.RemoveSession(ev.getPlayer()); - } - } else { - if (-amt<=shop.GetAmount()) { - //Take out these items from the shop. - amt*=-1; - shop.UpdateAmount(shop.GetAmount()-amt); - ItemStack drop = shop.GetItem(); - int dropAmt = amt; - //ev.getPlayer().getWorld().dropItemNaturally(ev.getPlayer().getLocation(), drop).setPickupDelay(0); - final Player p = ev.getPlayer(); - while (dropAmt>0) { - if (dropAmt>shop.GetItem().getMaxStackSize()) { - drop.setAmount(shop.GetItem().getMaxStackSize()); - final ItemStack dropitem = drop.clone(); - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { - @Override - public void run() { - p.getWorld().dropItem(p.getLocation(), dropitem).setPickupDelay(0); - } - },1); - dropAmt-=shop.GetItem().getMaxStackSize(); - } else { - drop.setAmount(dropAmt); - final ItemStack dropitem = drop.clone(); - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { - @Override - public void run() { - p.getWorld().dropItem(p.getLocation(), dropitem).setPickupDelay(0); - } - },1); - dropAmt=0; - } - } - log("Dropped shop item.",5); - //ev.getPlayer().getWorld().dropItemNaturally(ev.getPlayer().getLocation(), drop).setPickupDelay(0); - TwosideShops.SaveWorldShopData(shop); - WorldShopManager.UpdateSign(shop, TwosideShops.GetShopID(current_session.GetSign()), current_session.GetSign(),false); - - if (shop.GetAmount()>0) { - current_session.SetSession(SessionState.UPDATE); - ev.getPlayer().sendMessage("Input how much each "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" will cost (Old value - "+ChatColor.YELLOW+"$"+df.format(shop.GetUnitPrice())+ChatColor.WHITE+"):"); - } else { - ev.getPlayer().sendMessage(ChatColor.DARK_BLUE+"Shop successfully updated!"); - TwosideShops.RemoveSession(ev.getPlayer()); - } - } else { - ev.getPlayer().sendMessage("You only have "+shop.GetAmount()+" of "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" in the shop. Please try again."); - } - } - } else { - ev.getPlayer().sendMessage("That is not a valid number!"); - TwosideShops.RemoveSession(ev.getPlayer()); - } - break; - /*case BUY_EDIT: //LEGACY CODE. - if (ev.getMessage().length()<=9 && isNumeric(ev.getMessage()) && isInteger(ev.getMessage())) { - int amt = Integer.parseInt(ev.getMessage()); - DecimalFormat df = new DecimalFormat("0.00"); - WorldShop shop = TwosideShops.LoadWorldShopData(TwosideShops.GetShopID(current_session.GetSign())); - if (amt>=0) { //This means we want to add more to the amount. - shop.UpdateAmount(shop.GetAmount()+amt); - TwosideShops.SaveWorldShopData(shop); - TwosideShops.UpdateSign(shop, TwosideShops.GetShopID(current_session.GetSign()), current_session.GetSign(),true); - ev.getPlayer().sendMessage("Requested "+ChatColor.AQUA+amt+ChatColor.WHITE+" more "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" to your shop!"); - ev.getPlayer().sendMessage("Input how much you will pay for each "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" (Old value - "+ChatColor.YELLOW+"$"+df.format(shop.GetUnitPrice())+ChatColor.WHITE+":"); - - current_session.SetSession(SessionState.BUY_UPDATE); - } else { - if (-amt<=shop.GetStoredAmount()) { - //Take out these items from the shop. - amt*=-1; - shop.UpdateStoredAmount(shop.GetStoredAmount()-amt); - ItemStack drop = shop.GetItem(); - int dropAmt = amt; - //ev.getPlayer().getWorld().dropItemNaturally(ev.getPlayer().getLocation(), drop).setPickupDelay(0); - final Player p = ev.getPlayer(); - while (dropAmt>0) { - if (dropAmt>shop.GetItem().getMaxStackSize()) { - drop.setAmount(shop.GetItem().getMaxStackSize()); - final ItemStack dropitem = drop.clone(); - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { - @Override - public void run() { - p.getWorld().dropItemNaturally(p.getLocation(), dropitem).setPickupDelay(0); - } - },1); - dropAmt-=shop.GetItem().getMaxStackSize(); - } else { - drop.setAmount(dropAmt); - final ItemStack dropitem = drop.clone(); - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { - @Override - public void run() { - p.getWorld().dropItemNaturally(p.getLocation(), dropitem).setPickupDelay(0); - } - },1); - dropAmt=0; - } - } - log("Dropped shop item.",5); - //ev.getPlayer().getWorld().dropItemNaturally(ev.getPlayer().getLocation(), drop).setPickupDelay(0); - TwosideShops.SaveWorldShopData(shop); - TwosideShops.UpdateSign(shop, TwosideShops.GetShopID(current_session.GetSign()), current_session.GetSign(),true); - - TwosideShops.RemoveSession(p); - } else { - ev.getPlayer().sendMessage("You only have "+shop.GetStoredAmount()+" of "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" stored in the shop. Please try again."); - } - } - } else { - ev.getPlayer().sendMessage("That is not a valid number!"); - TwosideShops.RemoveSession(ev.getPlayer()); - } - break;*/ case UPDATE: if (isNumeric(ev.getMessage())) { double amt = Double.parseDouble(ev.getMessage()); @@ -1938,13 +1929,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (dropAmt>shop.GetItem().getMaxStackSize()) { shopItem.setAmount(shop.GetItem().getMaxStackSize()); final ItemStack dropitem = shopItem.clone(); - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { - @Override - public void run() { - ev.getPlayer().getWorld().dropItem(ev.getPlayer().getLocation(), dropitem).setPickupDelay(0); - cc.getInventory().removeItem(dropitem); - } - },1); + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new GivePlayerPurchasedItems(cc, ev, dropitem),1); dropAmt-=shop.GetItem().getMaxStackSize(); } else { shopItem.setAmount(dropAmt); @@ -2071,6 +2056,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ev.setCancelled(true); } + //if (ev.getMessage().matches("[0]")) //Bukkit.dispatchCommand(Bukkit.getConsoleSender(),"tellraw @a [\"\",{\"text\":\""+ChatColor.GREEN+"[Item]"+ChatColor.WHITE+"\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\""+(ev.getPlayer().getEquipment().getItemInMainHand().getType())+"\"}},{\"text\":\" "+ev.getMessage().substring(0, pos)+" \"}]"); } } @@ -2253,6 +2239,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } GenericFunctions.applyModeName(p.getEquipment().getItemInMainHand()); + p.updateInventory(); } } @@ -3408,7 +3395,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } pd.isViewingItemCube=false; } - if (ev.getInventory().getLocation()!=null) { + if (ev.getInventory().getHolder() instanceof Chest) { Block b = ev.getInventory().getLocation().getBlock(); if (b.getType()==Material.CHEST || b.getType()==Material.TRAPPED_CHEST) { //This is a valid shop. Now update the shop sign for it. @@ -5226,30 +5213,69 @@ public class TwosideKeeper extends JavaPlugin implements Listener { @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) public void onHopperSuction(InventoryMoveItemEvent ev) { Inventory source = ev.getSource(); - Location l = source.getLocation(); - //See if this block is a world shop. - if (WorldShop.grabShopSign(l.getBlock())!=null) { - //This is a world shop. DO NOT allow this to happen. - ev.setCancelled(true); - final Location l1=ev.getDestination().getLocation(); - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { - public void run() { - l1.getBlock().breakNaturally(); - }} - ,1); - } Inventory destination = ev.getDestination(); - l = destination.getLocation(); - //See if this block is a world shop. - if (WorldShop.grabShopSign(l.getBlock())!=null) { - //This is a world shop. DO NOT allow this to happen. - ev.setCancelled(true); - final Location l1=source.getLocation(); - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { - public void run() { - l1.getBlock().breakNaturally(); - }} - ,1); + if ((source.getHolder() instanceof HopperMinecart) || source.getLocation().getBlock().getType()==Material.HOPPER) { + //log("In here 1",2); + if (notWorldShop.contains(destination.getLocation().getBlock())) { + return; + } else { + Location l = destination.getLocation(); + //See if this block is a world shop. + if (WorldShop.grabShopSign(l.getBlock())!=null) { + //This is a world shop. DO NOT allow this to happen. + ev.setCancelled(true); + if (source.getHolder() instanceof HopperMinecart) { + HopperMinecart veh = (HopperMinecart)source.getHolder(); + if (veh.isValid()) { + veh.getWorld().dropItemNaturally(veh.getLocation(), new ItemStack(Material.HOPPER_MINECART)); + } + veh.remove(); + } else { + final Location l1=ev.getSource().getLocation(); + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + public void run() { + l1.getBlock().breakNaturally(); + }} + ,1); + } + } else { + notWorldShop.add(ev.getDestination().getLocation().getBlock()); + log("Added not world shop "+ev.getDestination().getLocation(),4); + } + } + } + if ((destination.getHolder() instanceof HopperMinecart) || destination.getLocation().getBlock().getType()==Material.HOPPER) { + //log("In here 2",2); + if (notWorldShop.contains(source.getLocation().getBlock())) { + return; + } else { + Location l = source.getLocation(); + //See if this block is a world shop. + if (WorldShop.grabShopSign(l.getBlock())!=null) { + //This is a world shop. DO NOT allow this to happen. + ev.setCancelled(true); + if (destination.getHolder() instanceof HopperMinecart) { + HopperMinecart veh = (HopperMinecart)destination.getHolder(); + if (veh.isValid()) { + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + public void run() { + veh.getWorld().dropItemNaturally(veh.getLocation(), new ItemStack(Material.HOPPER_MINECART)); + }},1); + } + veh.remove(); + } else { + final Location l1=ev.getDestination().getLocation(); + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + public void run() { + l1.getBlock().breakNaturally(); + }} + ,1); + } + } else { + notWorldShop.add(ev.getSource().getLocation().getBlock()); + log("Added not world shop "+ev.getSource().getLocation(),4); + } + } } } diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java b/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java index 980ab7f..8dcf773 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java @@ -356,4 +356,12 @@ public final class TwosideKeeperAPI { public static PlayerMode getPlayerMode(Player p) { return PlayerMode.getPlayerMode(p); } + /**Returns the amount of cooldown reduction the player has. + 0% meaning cooldowns are not reduced at all. 100% meaning cooldowns should be non-existent. + * @param p + * @return + */ + public double getCooldownReduction(Player p) { + return CustomDamage.calculateCooldownReduction(p); + } }