diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index a5c726f..1856283 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/plugin.yml b/src/plugin.yml index 79c706d..a326e0c 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: TwosideKeeper main: sig.plugin.TwosideKeeper.TwosideKeeper -version: 3.11.1f +version: 3.11.1g loadbefore: [aPlugin] commands: money: diff --git a/src/sig/plugin/TwosideKeeper/CustomDamage.java b/src/sig/plugin/TwosideKeeper/CustomDamage.java index 150cb9d..6496d06 100644 --- a/src/sig/plugin/TwosideKeeper/CustomDamage.java +++ b/src/sig/plugin/TwosideKeeper/CustomDamage.java @@ -2029,11 +2029,15 @@ public class CustomDamage { if (TwosideKeeper.chargezombies.size()<16) { addChargeZombieToList(m); } - addToCustomStructures(m); + addToCustomStructures(m,true); addMonsterToTargetList(m,p); } - + public static void addToCustomStructures(LivingEntity m) { + addToCustomStructures(m,false); + } + + public static void addToCustomStructures(LivingEntity m, boolean alreadyExisting) { removeStraySpiderMinions(m); @@ -2042,17 +2046,18 @@ public class CustomDamage { if (addBlazeToList(m)) {return;} if (addWitherToList(m)) {return;} - - if (m instanceof Skeleton) { - if (Math.random()<=0.5) { - if (addKnighttoList(m)) {return;} else { - addSniperSkeletontoList(m); - } - } else { - if (addSniperSkeletontoList(m)) {return;} else { - addKnighttoList(m); - } - } + if (!alreadyExisting) { + if (m instanceof Skeleton) { + if (Math.random()<=0.5) { + if (addKnighttoList(m)) {return;} else { + addSniperSkeletontoList(m); + } + } else { + if (addSniperSkeletontoList(m)) {return;} else { + addKnighttoList(m); + } + } + } } if (addChallengeZombieToList(m)) {return;} @@ -2487,6 +2492,9 @@ public class CustomDamage { if (ItemSet.HasSetBonusBasedOnSetBonusCount(p, ItemSet.VIXEN, 4)) { p.setHealth(Math.min(p.getHealth()+(p.getMaxHealth()*0.1), p.getMaxHealth())); } + if (PlayerMode.getPlayerMode(p)==PlayerMode.DEFENDER) { + GenericFunctions.HealEntity(p, p.getMaxHealth()*0.05); + } return true; } return false; diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java index ec58867..c5de1c4 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java @@ -82,6 +82,7 @@ import sig.plugin.TwosideKeeper.Recipes; import sig.plugin.TwosideKeeper.Room; import sig.plugin.TwosideKeeper.TwosideKeeper; import sig.plugin.TwosideKeeper.TwosideKeeperAPI; +import sig.plugin.TwosideKeeper.aPluginAPIWrapper; import sig.plugin.TwosideKeeper.runServerHeartbeat; import sig.plugin.TwosideKeeper.Boss.EliteGuardian; import sig.plugin.TwosideKeeper.Boss.EliteZombie; @@ -271,7 +272,7 @@ public class GenericFunctions { public static ItemStack addHardenedItemBreaks(ItemStack item, int breaks, boolean addname) { if (isHardenedItem(item)) { //We can just modify the amount of breaks. - TwosideKeeper.log("We got here.",2); + //TwosideKeeper.log("We got here.",2); return modifyBreaks(item, getHardenedItemBreaks(item)+breaks,false); } else { //We need to add a new line in regards to making this item hardened. Two lines if it's armor. @@ -2591,7 +2592,7 @@ public class GenericFunctions { int mendinglv = item.getEnchantmentLevel(Enchantment.MENDING); int infinitylv = item.getEnchantmentLevel(Enchantment.ARROW_INFINITE); //TwosideKeeper.log("["+TwosideKeeper.getServerTickTime()+"] Testing Mending...", 1); - if (mendinglv>0 && Math.random()<=0.00048828125*(isHarvestingTool(item)?0.75:1d)) { + if (mendinglv>0 && Math.random()<=0.00048828125*(isHarvestingTool(item)?0.75:1d)*(aPluginAPIWrapper.isAFK(p)?5d:1d)) { //TwosideKeeper.log("Knockoff!", 0); mendinglv--; if (mendinglv>0) { @@ -2601,7 +2602,7 @@ public class GenericFunctions { } p.sendMessage(ChatColor.DARK_AQUA+"A level of "+ChatColor.YELLOW+"Mending"+ChatColor.DARK_AQUA+" has been knocked off of your "+((item.hasItemMeta() && item.getItemMeta().hasDisplayName())?item.getItemMeta().getDisplayName():UserFriendlyMaterialName(item))); } - if (infinitylv>0 && Math.random()<=0.0015*(isHarvestingTool(item)?0.75:1d)) { + if (infinitylv>0 && Math.random()<=0.0015*(isHarvestingTool(item)?0.75:1d)*(aPluginAPIWrapper.isAFK(p)?5d:1d)) { infinitylv--; if (infinitylv>0) { item.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, infinitylv); diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/PlayerMode.java b/src/sig/plugin/TwosideKeeper/HelperStructures/PlayerMode.java index 968ad46..2021e56 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/PlayerMode.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/PlayerMode.java @@ -63,8 +63,8 @@ public enum PlayerMode { + ChatColor.WHITE+"->Barbarians deal 20% more damage for every 20% of an enemy's missing health.\n" + ChatColor.GRAY+"->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.WHITE+"->Barbarians do not instantly take full damage when hit. Instead, the HP is stored in a 'Damage Pool' and distributed every second.\n" - + ChatColor.GRAY+"->If Barbarians have points in their 'Damage Pool', they will take up to 15 damage (+3% of their damage pool) every second. The amount taken goes down by wearing Barbarian gear.\n" - + ChatColor.WHITE+"->When a monster is killed by a Barbarian, the amount of remaining damage in their Damage Pool is divided by 4.\n" + + ChatColor.GRAY+"->If Barbarians have points in their 'Damage Pool', they will take up to 15 damage (+2% of their damage pool) every second. The amount taken goes down by wearing Barbarian gear.\n" + + ChatColor.WHITE+"->When a monster is killed by a Barbarian, the amount of remaining damage in their Damage Pool is divided by 75%. If an ally kills one, the damage pool is divided by 33%\n" + ChatColor.GRAY+"->Extra health from Lifestealing that is not used for healing your health will heal up your Damage Pool instead." + ChatColor.WHITE+"->Barbarians automatically consume Rotten Flesh and Spider Eyes that are picked up. Each one heals for 1% of their health. Rotten Flesh and Spider Eyes in a Barbarian's inventory will automatically be consumed as the Barbarian gets hungry.\n" + ChatColor.GRAY+"->Barbarians build up Weapon Charges in two ways: +1 Charge for attacking an enemy with the main hand weapon and +2 Charges for taking damage.\n" diff --git a/src/sig/plugin/TwosideKeeper/PVP.java b/src/sig/plugin/TwosideKeeper/PVP.java index dd0b0b6..828c2e9 100644 --- a/src/sig/plugin/TwosideKeeper/PVP.java +++ b/src/sig/plugin/TwosideKeeper/PVP.java @@ -250,6 +250,7 @@ public class PVP { case FIGHTING:{ removeInactivePlayers(); if (conditionsToWin() || notEnoughPlayers()) { + computeWinner(); announceWinner(); return false; } @@ -258,6 +259,18 @@ public class PVP { return true; } + private void computeWinner() { + if (scorematch) { + if (team1score>team2score) { + for (String s : getPlayersInTeam(2)) { + + } + } else { + + } + } + } + private boolean conditionsToWin() { if (scorematch) { return (team1score>=scorelimit || team2score>=scorelimit); diff --git a/src/sig/plugin/TwosideKeeper/PlayerStructure.java b/src/sig/plugin/TwosideKeeper/PlayerStructure.java index 8ee08cd..0508e24 100644 --- a/src/sig/plugin/TwosideKeeper/PlayerStructure.java +++ b/src/sig/plugin/TwosideKeeper/PlayerStructure.java @@ -263,6 +263,24 @@ public class PlayerStructure { public boolean dpstrackinglocked=false; public boolean inParkourChallengeRoom=false; public String rewards=""; + public int actionsPerMinute; //Number of actions made in the past minute. + public int distancePerMinute; //Amount of distance covered in the past minute. + public int actionRecords=0; //Number of "bad" actions stored on record. + public int moveRecords; //Number of move records. + public List durability = new ArrayList(); //Durability amounts used when AFK detecting. + public Location leashedLoc; //Last used leash location for AFK detection. + public long lastLocationChange=0; + public int afkLength = 60; + public boolean isAFKState = false; + public int unafkLength = 0; + + //Prevent Automatic AFK moving the camera just to avoid the system. + public long lastAdjustmentReading = 0; //When the last adjustment reading started. + public int adjustmentReading = 0; //Number of adjustments this timing session. + public int readingBroken = 0; //Number of readings broken. + public double averageAdjustmentsMade = 0; //Avg Number of adjustments made. + public int averageAdjustmentsMadeCount = 0; //Stored number of adjustments used in average. + public boolean tooConsistentAdjustments = false; //Adjustments are too consistent. //Needs the instance of the player object to get all other info. Only to be called at the beginning. @SuppressWarnings("deprecation") @@ -324,6 +342,7 @@ public class PlayerStructure { this.equipweapons=true; this.equiparmor=true; this.customtitle = new AdvancedTitle(p); + this.lastLocationChange = TwosideKeeper.getServerTickTime(); //Set defaults first, in case this is a new user. loadConfig(); //p.getInventory().addItem(new ItemStack(Material.PORTAL)); @@ -495,6 +514,10 @@ public class PlayerStructure { workable.set("lastparkourDailyChallenge", lastparkourDailyChallenge); workable.set("rewards", rewards); workable.set("isFirstReward", isFirstReward); + workable.set("afkLength", afkLength); + workable.set("averageAdjustmentsMadeCount", averageAdjustmentsMadeCount); + workable.set("averageAdjustmentsMade", averageAdjustmentsMade); + workable.set("tooConsistentAdjustments", tooConsistentAdjustments); int buffcounter=0; for (String key : buffs.keySet()) { Buff b = buffs.get(key); @@ -607,6 +630,10 @@ public class PlayerStructure { workable.addDefault("lastparkourDailyChallenge", lastparkourDailyChallenge); workable.addDefault("rewards", rewards); workable.addDefault("isFirstReward", isFirstReward); + workable.addDefault("afkLength",afkLength); + workable.addDefault("averageAdjustmentsMadeCount",averageAdjustmentsMadeCount); + workable.addDefault("averageAdjustmentsMade",averageAdjustmentsMade); + workable.addDefault("tooConsistentAdjustments",tooConsistentAdjustments); workable.options().copyDefaults(); @@ -676,6 +703,10 @@ public class PlayerStructure { this.lastparkourDailyChallenge = workable.getLong("lastparkourDailyChallenge"); this.rewards = workable.getString("rewards"); this.isFirstReward = workable.getBoolean("isFirstReward"); + this.afkLength = workable.getInt("afkLength"); + this.averageAdjustmentsMadeCount = workable.getInt("averageAdjustmentsMadeCount"); + this.averageAdjustmentsMade = workable.getDouble("averageAdjustmentsMade"); + this.tooConsistentAdjustments = workable.getBoolean("tooConsistentAdjustments"); String tempworld = workable.getString("restartloc_world"); if (!workable.getString("instanceloc_world").equalsIgnoreCase("null")) { locBeforeInstance = new Location( @@ -744,4 +775,26 @@ public class PlayerStructure { public static int getPlayerNegativeHash(Player p) { return Math.min(p.getUniqueId().hashCode(), -p.getUniqueId().hashCode()); } + + public static void addToActionQueue(Player p, String action) { + //Actions: + /* BREAK - Break a block. + * PLACE - Place a block. + * FISH - Use fishing rod. + * INTERACT - Interact. + */ + PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + if (pd.leashedLoc.getWorld().equals(p.getLocation().getWorld()) && p.getLocation().distanceSquared(pd.leashedLoc)<9) { + pd.actionRecords++; + } else { + pd.actionRecords=1; + } + } + + public static double getAFKMultiplier(Player p) { //Returns how harsh the AFK'ing multiplier is on a player. + PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + double mult = 1; + mult += Math.min(Math.pow(pd.actionRecords, 1.25)-1,1000); + return mult; + } } diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index 4611c67..4c081f5 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -819,6 +819,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ed.setVelocity(p.getLocation().getDirection().multiply(2.0f)); ed.teleport(ed.getLocation().setDirection(p.getLocation().getDirection())); }*/ + SetupAndModifyDurabilities(p); + TwosideKeeper.HeartbeatLogger.AddEntry(ChatColor.LIGHT_PURPLE+"Anti-AFK Modifiers", (int)(System.nanoTime()-totaltime));totaltime=System.nanoTime(); } TwosideKeeper.HeartbeatLogger.AddEntry("Player Cycle Handling", (int)(System.nanoTime()-time));time=System.nanoTime(); for (TemporaryLava tl : temporary_lava_list) { @@ -969,7 +971,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener { TwosideKeeper.log("WARNING! Structure Handling took longer than 1 tick! "+((int)(System.nanoTime()-totaltime)/1000000d)+"ms", 0); } TwosideKeeper.HeartbeatLogger.AddEntry(ChatColor.LIGHT_PURPLE+"Total Structure Handling", (int)(System.nanoTime()-totaltime));totaltime=System.nanoTime(); - } private boolean NotifyBufferLimit(String operation, long totaltime) { @@ -1039,7 +1040,59 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } } + + public static void SetupAndModifyDurabilities(Player p) { + PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + if (aPluginAPIWrapper.isAFK(p)) { + pd.actionRecords++; + if (pd.durability.size()!=9) { + PopulateDurabilityValues(p); + } else { + //See if durability values are different. If so, multiply the difference. + List diff = GetDifferences(p); + for (int i=0;i<9;i++) { + if (diff.get(i)>0) { + aPlugin.API.damageItem(p, p.getInventory().getItem(i), (int)(diff.get(i)*PlayerStructure.getAFKMultiplier(p))); + TwosideKeeper.log(" Damaged item slot"+i+" an extra "+((int)(diff.get(i)*PlayerStructure.getAFKMultiplier(p)))+" damage due to AFK state.", 2); + } + } + PopulateDurabilityValues(p); + } + } else { + if (pd.actionRecords>0) { + pd.actionRecords--; + } + } + } + private static List GetDifferences(Player p) { + PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + List diffs = new ArrayList(); + for (int i=0;i<9;i++) { + ItemStack item = p.getInventory().getItem(i); + if (ItemUtils.isValidItem(item) && GenericFunctions.isEquip(item)) { + diffs.add(item.getDurability()-pd.durability.get(i)); + if (item.getDurability()-pd.durability.get(i)>0) { + TwosideKeeper.log("Difference dected in item slot #"+i+" for Player "+p.getName(), 2); + } + } else { + diffs.add(0); + } + } + return diffs; + } + private static void PopulateDurabilityValues(Player p) { + PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + pd.durability.clear(); + for (int i=0;i<9;i++) { + ItemStack item = p.getInventory().getItem(i); + if (ItemUtils.isValidItem(item) && GenericFunctions.isEquip(item)) { + pd.durability.add((int)item.getDurability()); + } else { + pd.durability.add(0); + } + } + } public static double GetNaturalRegen(Player p) { PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); if (PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER) { @@ -1287,7 +1340,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { /*MonsterTemplate newtemp = new MonsterTemplate(new File(filesave+"/monsterdata/KingSlime.md")); int newint = (int)newtemp.getValue("timeToLive"); log(Integer.toString(newint),0);*/ - log(" This is here to change the file size if necessary Kappa Kappa Kappa No Copy-pasterino Kappachino Lulu c: Please update version number. lololol cy@ storm is boosted. This is nice.",5); + log(" This is here to change the file size if necessary Kappa Kappa Kappa No Copy-pasterino Kappachino Lulu c: Please update version number. lololol cy@ storm is boosted. This is nice.",5); } private static void InitializeBotCommands() { @@ -1529,7 +1582,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { sender.sendMessage("Individual Structures for player "+ChatColor.YELLOW+pl.getName()+ChatColor.RESET+":"); sender.sendMessage(ChatColor.WHITE+Display("OPE",pd.openeditemcube.size())+Display("DAM",pd.damagedata.breakdownlist.size())+Display("DEA",pd.deathloot.size())); sender.sendMessage(ChatColor.WHITE+Display("HIT",pd.hitlist.size())+Display("ITE",pd.itemcubelist.size())+Display("LAS",pd.lasteffectlist.size())); - sender.sendMessage(ChatColor.WHITE+Display("BLO",pd.blockscanlist.size())); + sender.sendMessage(ChatColor.WHITE+Display("BLO",pd.blockscanlist.size())+Display("AFK",pd.afkLength)+Display("UAFK",pd.unafkLength)); + sender.sendMessage(ChatColor.WHITE+Display("AAVG",(int)pd.averageAdjustmentsMade)+Display("AVGC",(int)pd.averageAdjustmentsMadeCount)+Display("ACT",pd.actionRecords)); } else { sender.sendMessage("Could not find player "+ChatColor.YELLOW+args[0]+ChatColor.RESET+"!"); } @@ -2356,6 +2410,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener { Bukkit.getPlayer(args[1]).sendMessage(ChatColor.GREEN+"You have been given a Daily Challenge Token."); } }break; + case "DAMAGEEQUIP":{ + aPlugin.API.damageItem(p, p.getInventory().getItem(Integer.parseInt(args[1])), 100); + }break; case "CHALLENGEREWARDS":{ ChallengeReward.provideAwards(); }break; @@ -3943,6 +4000,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } final Player p = ev.getPlayer(); + + PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + pd.adjustmentReading++; + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { @Override public void run() { @@ -3966,7 +4027,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if ((ev.getAction()==Action.LEFT_CLICK_AIR || ev.getAction()==Action.LEFT_CLICK_BLOCK) && p.isSneaking() && PlayerMode.getPlayerMode(p)==PlayerMode.BARBARIAN) { - PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + //PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); if (pd.weaponcharges>=30) { SoundUtils.playGlobalSound(p.getLocation(), Sound.BLOCK_WOOD_BUTTON_CLICK_ON, 3.0f, 0.6f); //Apply 10 strikes across the field. @@ -3988,7 +4049,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if ((ev.getAction()==Action.RIGHT_CLICK_AIR || ev.getAction()==Action.RIGHT_CLICK_BLOCK) && p.isSneaking() && PlayerMode.getPlayerMode(p)==PlayerMode.BARBARIAN) { - PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + //PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); if (pd.weaponcharges>=30) { //Apply Sweep Up Attack. pd.weaponcharges-=30; @@ -4028,7 +4089,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //Check for a Hunter's Compass right-click. if ((ev.getAction()==Action.RIGHT_CLICK_AIR || ev.getAction()==Action.RIGHT_CLICK_BLOCK) && GenericFunctions.isHunterCompass(p.getEquipment().getItemInMainHand())) { - PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + //PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); if (pd.lastrightclick+100<=getServerTickTime()) { pd.lastrightclick=getServerTickTime(); p.sendMessage("Calibrating "+p.getEquipment().getItemInMainHand().getItemMeta().getDisplayName()+ChatColor.WHITE+"..."); @@ -4087,7 +4148,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //Rotate Bow Modes. GenericFunctions.logAndRemovePotionEffectFromEntity(PotionEffectType.SLOW,p); BowMode mode = GenericFunctions.getBowMode(p); - PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + //PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); if (pd.lastbowmodeswitch+4TwosideKeeper.getServerTickTime()) && pd.nameoflastdailysign.equalsIgnoreCase(s.getLine(1)))) { new DPSChallengeRoom(p,new DPSRoom(32,32)); @@ -5644,10 +5705,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener { @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) public void togglesprint(PlayerToggleSprintEvent ev) { //log("Toggled: "+ev.isSprinting(),2); + PlayerStructure pd = PlayerStructure.GetPlayerStructure(ev.getPlayer()); if (ev.isSprinting()) { - PlayerStructure pd = PlayerStructure.GetPlayerStructure(ev.getPlayer()); pd.lastsprintcheck=getServerTickTime(); } + pd.adjustmentReading++; } @SuppressWarnings("deprecation") @@ -7039,7 +7101,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } } - CustomDamage.addToCustomStructures(m); + CustomDamage.addToCustomStructures(m,true); } } @@ -7862,6 +7924,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public void expEvent(PlayerExpChangeEvent ev) { double val = Math.random(); Player p = ev.getPlayer(); + SetupAndModifyDurabilities(p); log("ExpChange event: "+val,5); int amt = ev.getAmount(); int testamt = amt; @@ -7869,7 +7932,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { testamt=500; } ev.setAmount((int)(ev.getAmount()+(ev.getAmount()*(ItemSet.GetTotalBaseAmount(ev.getPlayer(), ItemSet.ALUSTINE)/100d)))); - + if (ItemSet.HasSetBonusBasedOnSetBonusCount(p, ItemSet.ALUSTINE, 5)) { if (Math.random()<=Math.min((ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.ALUSTINE, 5, 4)/20d),1)) { PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); @@ -8002,7 +8065,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } if (ev.getTarget() instanceof Player && ev.getEntity() instanceof LivingEntity) { - CustomDamage.addToCustomStructures((LivingEntity)ev.getEntity()); + CustomDamage.addToCustomStructures((LivingEntity)ev.getEntity(),true); CustomMonster cm = CustomMonster.getCustomMonster((LivingEntity)ev.getEntity()); if (cm!=null && cm instanceof HellfireGhast) { HellfireGhast hg = (HellfireGhast)cm; @@ -8316,6 +8379,18 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } + for (Player pl : PartyManager.getPartyMembers(p)) { + if (!pl.equals(p)) { + if (PlayerMode.getPlayerMode(pl)==PlayerMode.BARBARIAN) { + PlayerStructure pdd = PlayerStructure.GetPlayerStructure(pl); + pdd.damagepool/=1.5; + } else + if (PlayerMode.getPlayerMode(pl)==PlayerMode.DEFENDER) { + GenericFunctions.HealEntity(pl, pl.getMaxHealth()*0.05); + } + } + } + if (isSlayer) { int restore_amt = 2; if (ItemSet.meetsSlayerSwordConditions(ItemSet.LORASYS, 18, 2, p)) { @@ -8861,9 +8936,17 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (ev.getPlayer().isOnGround()) { PlayerStructure pd = (PlayerStructure)playerdata.get(ev.getPlayer().getUniqueId()); pd.velocity = new Vector(ev.getFrom().getX(),0,ev.getFrom().getZ()).distanceSquared(new Vector(ev.getTo().getX(),0,ev.getTo().getZ())); + if (pd.velocity>=2) { + pd.adjustmentReading++; + } if (pd.highwinder && pd.target!=null && !pd.target.isDead() && pd.lasthighwinderhit+15=2) { + PlayerStructure pd = (PlayerStructure)playerdata.get(ev.getPlayer().getUniqueId()); + pd.adjustmentReading++; + } } if (ItemSet.HasSetBonusBasedOnSetBonusCount(ev.getPlayer(), ItemSet.DANCER, 4)) { PlayerStructure pd = (PlayerStructure)playerdata.get(ev.getPlayer().getUniqueId()); @@ -8881,18 +8964,12 @@ public class TwosideKeeper extends JavaPlugin implements Listener { @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) public void onFishEvent(PlayerFishEvent ev) { - if (ev.getState().equals(State.CAUGHT_FISH)) { - Player p = ev.getPlayer(); - if (p!=null) { - /*if (GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand()) && - GenericFunctions.isArtifactWeapon(p.getEquipment().getItemInMainHand())) { - AwakenedArtifact.addPotentialEXP(p.getEquipment().getItemInMainHand(), 12, p); - }*/ - if (GenericFunctions.isWeapon(p.getEquipment().getItemInMainHand())) { - GenericFunctions.RemovePermEnchantmentChance(p.getEquipment().getItemInMainHand(), p); - } - } - } + Player p = ev.getPlayer(); + if (p!=null) { + if (GenericFunctions.isWeapon(p.getEquipment().getItemInMainHand())) { + GenericFunctions.RemovePermEnchantmentChance(p.getEquipment().getItemInMainHand(), p); + } + } } @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) diff --git a/src/sig/plugin/TwosideKeeper/aPluginAPIWrapper.java b/src/sig/plugin/TwosideKeeper/aPluginAPIWrapper.java index 37be02f..e7e9e00 100644 --- a/src/sig/plugin/TwosideKeeper/aPluginAPIWrapper.java +++ b/src/sig/plugin/TwosideKeeper/aPluginAPIWrapper.java @@ -1,6 +1,7 @@ package sig.plugin.TwosideKeeper; import org.bukkit.Location; +import org.bukkit.entity.Player; import net.minecraft.server.v1_9_R1.EnumParticle; @@ -8,4 +9,24 @@ public class aPluginAPIWrapper { public static void sendParticle(Location loc, EnumParticle particle, float dx, float dy, float dz, float v, int particleCount) { utils.NMSUtils.sendParticle(loc,particle,dx,dy,dz,v,particleCount); } + + public static boolean isAFK(Player p) { + return aPlugin.API.isAFK(p) || !playerIsActive(p); + } + + public static boolean playerIsActive(Player p) { + PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + if (pd.lastLocationChange+(20*pd.afkLength)>Player "+p.getName()+" has been detected as AFK.", 2); + } + return false; + } + if (pd.isAFKState) { + pd.isAFKState=false; + TwosideKeeper.log(">>Player "+p.getName()+" is no longer AFK.", 2); + } + return true; + } } diff --git a/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java b/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java index 4e17b96..09e0e5d 100644 --- a/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java +++ b/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java @@ -300,6 +300,7 @@ final public class runServerHeartbeat implements Runnable { updateCustomTitle(p, pd); TwosideKeeper.HeartbeatLogger.AddEntry("Update Custom Title", (int)(System.nanoTime()-time));time=System.nanoTime(); } + CheckPlayerLocationAndActionQueue(p); TwosideKeeper.HeartbeatLogger.AddEntry(ChatColor.BOLD+"->Not AFK Functions"+ChatColor.RESET, (int)(System.nanoTime()-notafktime)); ModifyArmorBar(p); @@ -392,6 +393,58 @@ final public class runServerHeartbeat implements Runnable { TwosideKeeper.HeartbeatLogger.AddEntry(ChatColor.LIGHT_PURPLE+"Total Server Heartbeat", (int)(System.nanoTime()-totaltime));totaltime=System.nanoTime(); } + private void CheckPlayerLocationAndActionQueue(Player p) { + PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); + if (pd.leashedLoc==null) { + pd.leashedLoc = p.getLocation().clone(); + pd.lastLocationChange = TwosideKeeper.getServerTickTime(); + } else { + if (p.getWorld().equals(pd.leashedLoc.getWorld())) { + if (PlayerUtils.PlayerIsInCombat(p) || p.getLocation().distanceSquared(pd.leashedLoc)>9 || Math.abs(p.getLocation().getDirection().getX()-pd.leashedLoc.getDirection().getX())>=0.05 || Math.abs(p.getLocation().getDirection().getZ()-pd.leashedLoc.getDirection().getZ())>=0.05) { + pd.leashedLoc = p.getLocation().clone(); + pd.lastLocationChange = TwosideKeeper.getServerTickTime(); + pd.adjustmentReading++; + pd.unafkLength = Math.min(pd.unafkLength+1, 60); + if (pd.unafkLength==60) { + pd.afkLength = Math.min(pd.afkLength+1, 60); + //TwosideKeeper.log("AFK Length: "+pd.afkLength, 2); + } + } else { + pd.unafkLength = Math.max(pd.unafkLength-1,1); + if (pd.isAFKState) { + pd.afkLength = Math.max(pd.afkLength-1,1); + //TwosideKeeper.log("AFK Length: "+pd.afkLength, 2); + //TwosideKeeper.log(p.getName()+" has been detected as AFK. Multiplier: "+PlayerStructure.getAFKMultiplier(p), 2); + } + } + } else { + pd.leashedLoc = p.getLocation().clone(); + } + } + if (pd.lastAdjustmentReading+(20*60) "+pd.adjustmentReading, 2); + if (Math.abs(pd.adjustmentReading-pd.averageAdjustmentsMade)<=2 && pd.averageAdjustmentsMadeCount>=10) { //Too consistent. + pd.readingBroken++; + if (pd.readingBroken>=3) { + pd.tooConsistentAdjustments=true; + } + } else { + pd.readingBroken=0; + pd.tooConsistentAdjustments=false; + } + pd.averageAdjustmentsMade = ((double)pd.averageAdjustmentsMadeCount*pd.averageAdjustmentsMade + pd.adjustmentReading)/(double)(pd.averageAdjustmentsMadeCount+1); + pd.averageAdjustmentsMadeCount = Math.min(pd.averageAdjustmentsMadeCount+1, 10); + pd.adjustmentReading=0; + } + } + private void managePVPSessions() { for (PVP session : TwosideKeeper.pvpsessions) { if (!session.runTick()) {