diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index eadc45b..e8dc94e 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 eef5ca1..669a6d0 100644 --- a/src/sig/plugin/TwosideKeeper/CustomDamage.java +++ b/src/sig/plugin/TwosideKeeper/CustomDamage.java @@ -726,101 +726,106 @@ public class CustomDamage { private static double modifyFateBasedOnHolidayTreats(Player p, double damage) { PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); - if (pd.lastcandyconsumed+40{ - if (!p.isDead()) { - SoundUtils.playLocalSound(p, Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 0.6f); - p.setHealth(Math.min(p.getHealth()+(0.1*p.getMaxHealth()), p.getMaxHealth())); - p.sendMessage(ChatColor.GREEN+" "+Math.round(p.getMaxHealth()*0.1)+ChatColor.WHITE+" health has been restored!"); - } - },10); - consumed=true;break; - } else - if (Christmas.isLargeCandyItem(item)) { - //TwosideKeeper.log(ChatColor.AQUA+"You prepare to eat a "+GenericFunctions.UserFriendlyMaterialName(item), 0); - p.sendMessage(ChatColor.AQUA+"You munch on a "+GenericFunctions.UserFriendlyMaterialName(item)); - RemoveOneItem(p.getInventory(),item,i); - Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, ()->{ - if (!p.isDead()) { - SoundUtils.playLocalSound(p, Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 0.6f); - p.setHealth(Math.min(p.getHealth()+(0.5*p.getMaxHealth()), p.getMaxHealth())); - p.sendMessage(ChatColor.GREEN+" "+Math.round(p.getMaxHealth()*0.5)+ChatColor.WHITE+" health has been restored!"); - } - },10); - consumed=true;break; - } else - if (Christmas.isSourCandyItem(item)) { - //TwosideKeeper.log(ChatColor.AQUA+"You prepare to eat a "+GenericFunctions.UserFriendlyMaterialName(item), 0); - p.sendMessage(ChatColor.AQUA+"You munch on a "+GenericFunctions.UserFriendlyMaterialName(item)); - RemoveOneItem(p.getInventory(),item,i); - Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, ()->{ - if (!p.isDead()) { + } + } else + if (p.getHealth()-damage{ + if (!p.isDead()) { + SoundUtils.playLocalSound(p, Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 0.6f); + p.setHealth(Math.min(p.getHealth()+(0.1*p.getMaxHealth()), p.getMaxHealth())); + p.sendMessage(ChatColor.GREEN+" "+Math.round(p.getMaxHealth()*0.1)+ChatColor.WHITE+" health has been restored!"); + } + },10); + consumed=true;break; + } else + if (Christmas.isLargeCandyItem(item)) { + //TwosideKeeper.log(ChatColor.AQUA+"You prepare to eat a "+GenericFunctions.UserFriendlyMaterialName(item), 0); + p.sendMessage(ChatColor.AQUA+"You munch on a "+GenericFunctions.UserFriendlyMaterialName(item)); + RemoveOneItem(p.getInventory(),item,i); + Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, ()->{ + if (!p.isDead()) { + SoundUtils.playLocalSound(p, Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 0.6f); + p.setHealth(Math.min(p.getHealth()+(0.5*p.getMaxHealth()), p.getMaxHealth())); + p.sendMessage(ChatColor.GREEN+" "+Math.round(p.getMaxHealth()*0.5)+ChatColor.WHITE+" health has been restored!"); + } + },10); + consumed=true;break; + } else + if (Christmas.isSourCandyItem(item)) { + //TwosideKeeper.log(ChatColor.AQUA+"You prepare to eat a "+GenericFunctions.UserFriendlyMaterialName(item), 0); + p.sendMessage(ChatColor.AQUA+"You munch on a "+GenericFunctions.UserFriendlyMaterialName(item)); + RemoveOneItem(p.getInventory(),item,i); + Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, ()->{ + if (!p.isDead()) { + SoundUtils.playLocalSound(p, Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 0.6f); + GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.REGENERATION, 400, 4, p, true); + p.sendMessage(ChatColor.GREEN+" You feel a rejuvenating feeling inside of you."); + } + },10); + consumed=true;break; + } else + if (Christmas.isMysteryFlavorLollipopItem(item)) { + //TwosideKeeper.log(ChatColor.AQUA+"You prepare to eat a "+GenericFunctions.UserFriendlyMaterialName(item), 0); + p.sendMessage(ChatColor.AQUA+"You munch on a "+GenericFunctions.UserFriendlyMaterialName(item)); + RemoveOneItem(p.getInventory(),item,i); + Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, ()->{ + if (!p.isDead()) { + if (Bukkit.getOnlinePlayers().size()>1) { + GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.CONFUSION, 60, 4, p, true); + TeleportToARandomPlayer(p); + SoundUtils.playLocalSound(p, Sound.BLOCK_PORTAL_TRAVEL, 1.0f, 0.6f); + p.sendMessage(ChatColor.YELLOW+" You suddenly become disoriented."); + } else { SoundUtils.playLocalSound(p, Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 0.6f); - GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.REGENERATION, 400, 4, p, true); - p.sendMessage(ChatColor.GREEN+" You feel a rejuvenating feeling inside of you."); - } - },10); - consumed=true;break; - } else - if (Christmas.isMysteryFlavorLollipopItem(item)) { - //TwosideKeeper.log(ChatColor.AQUA+"You prepare to eat a "+GenericFunctions.UserFriendlyMaterialName(item), 0); - p.sendMessage(ChatColor.AQUA+"You munch on a "+GenericFunctions.UserFriendlyMaterialName(item)); - RemoveOneItem(p.getInventory(),item,i); - Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, ()->{ - if (!p.isDead()) { - if (Bukkit.getOnlinePlayers().size()>1) { - GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.CONFUSION, 60, 4, p, true); - TeleportToARandomPlayer(p); - SoundUtils.playLocalSound(p, Sound.BLOCK_PORTAL_TRAVEL, 1.0f, 0.6f); - p.sendMessage(ChatColor.YELLOW+" You suddenly become disoriented."); - } else { - SoundUtils.playLocalSound(p, Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 0.6f); - double randompct = Math.random(); - p.setHealth(Math.min(p.getHealth()+(randompct*p.getMaxHealth()), p.getMaxHealth())); - p.sendMessage(ChatColor.GREEN+" "+Math.round(p.getMaxHealth()*randompct)+ChatColor.WHITE+" health has been restored!"); - } + double randompct = Math.random(); + p.setHealth(Math.min(p.getHealth()+(randompct*p.getMaxHealth()), p.getMaxHealth())); + p.sendMessage(ChatColor.GREEN+" "+Math.round(p.getMaxHealth()*randompct)+ChatColor.WHITE+" health has been restored!"); } - },10); - consumed=true;break; - } + } + },10); + consumed=true;break; } } } - if (consumed) { - SoundUtils.playLocalSound(p, Sound.ENTITY_GENERIC_EAT, 1.0f, 1.0f); - pd.lastcandyconsumed=TwosideKeeper.getServerTickTime(); - } + } + if (consumed) { + SoundUtils.playLocalSound(p, Sound.ENTITY_GENERIC_EAT, 1.0f, 1.0f); + pd.lastcandyconsumed=TwosideKeeper.getServerTickTime(); + aPlugin.API.sendCooldownPacket(p, Material.GOLDEN_CARROT, 40); + aPlugin.API.sendCooldownPacket(p, Material.RAW_FISH, 40); + } + if (consumed2) { + SoundUtils.playLocalSound(p, Sound.ENTITY_GENERIC_EAT, 1.0f, 1.0f); + pd.lastrevivecandyconsumed=TwosideKeeper.getServerTickTime(); + aPlugin.API.sendCooldownPacket(p, Material.GOLDEN_APPLE, 200); } return damage; } diff --git a/src/sig/plugin/TwosideKeeper/PlayerStructure.java b/src/sig/plugin/TwosideKeeper/PlayerStructure.java index ee580f4..3b7824d 100644 --- a/src/sig/plugin/TwosideKeeper/PlayerStructure.java +++ b/src/sig/plugin/TwosideKeeper/PlayerStructure.java @@ -136,6 +136,7 @@ public class PlayerStructure { public long lastabsorptionhealthgiven = TwosideKeeper.getServerTickTime(); public long ignoretargetarmor = TwosideKeeper.getServerTickTime(); public long lastcandyconsumed = TwosideKeeper.getServerTickTime(); + public long lastrevivecandyconsumed = TwosideKeeper.getServerTickTime(); public long icewandused = TwosideKeeper.getServerTickTime(); public PlayerMode playermode_on_death=PlayerMode.NORMAL;