diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java index 831c88527..66c45d001 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java @@ -23,6 +23,7 @@ import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.SkillUtils; import com.google.common.collect.ImmutableList; public class PtpCommand implements TabExecutor { @@ -54,11 +55,11 @@ public class PtpCommand implements TabExecutor { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName()); Player player = mcMMOPlayer.getPlayer(); - int ptpCooldown = Config.getInstance().getPTPCommandCooldown(); long recentlyHurt = mcMMOPlayer.getRecentlyHurt(); + int recentlyhurt_cooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown(); - if (((recentlyHurt * Misc.TIME_CONVERSION_FACTOR) + (ptpCooldown * Misc.TIME_CONVERSION_FACTOR)) > System.currentTimeMillis()) { - player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", ptpCooldown)); + if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)) { + player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player))); return true; } @@ -71,6 +72,14 @@ public class PtpCommand implements TabExecutor { return true; } + int ptpCooldown = Config.getInstance().getPTPCommandCooldown(); + long lastTeleport = mcMMOPlayer.getLastTeleport(); + + if (!SkillUtils.cooldownOver(lastTeleport * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player)) { + player.sendMessage(ChatColor.RED + "You need to wait before you can use this again! " + ChatColor.YELLOW + "(" + SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player) + ")"); //TODO Locale! + return true; + } + sendTeleportRequest(sender, player, args[0]); return true; diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 4e21c7c51..482e6fce0 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -121,6 +121,7 @@ public class Config extends AutoUpdateConfigLoader { public boolean getChimaeraPreventUseUnderground() { return config.getBoolean("Items.Chimaera_Wing.Prevent_Use_Underground", true); } public int getChimaeraCooldown() { return config.getInt("Items.Chimaera_Wing.Cooldown", 240); } public int getChimaeraWarmup() { return config.getInt("Items.Chimaera_Wing.Warmup", 5); } + public int getChimaeraRecentlyHurtCooldown() { return config.getInt("Items.Chimaera_Wing.RecentlyHurt_Cooldown", 60); } /* Particles */ public boolean getAbilityActivationEffectEnabled() { return config.getBoolean("Particles.Ability_Activation", true); } @@ -144,6 +145,7 @@ public class Config extends AutoUpdateConfigLoader { /* Party Teleport Settings */ public int getPTPCommandCooldown() { return config.getInt("Commands.ptp.Cooldown", 120); } public int getPTPCommandWarmup() { return config.getInt("Commands.ptp.Warmup", 5); } + public int getPTPCommandRecentlyHurtCooldown() { return config.getInt("Commands.ptp.RecentlyHurt_Cooldown", 60); } public int getPTPCommandTimeout() { return config.getInt("Commands.ptp.Request_Timeout", 300); } public boolean getPTPCommandConfirmRequired() { return config.getBoolean("Commands.ptp.Confirm_Required", true); } public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); } diff --git a/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java b/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java index 74adb516e..a544039cf 100644 --- a/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java +++ b/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java @@ -45,8 +45,10 @@ public class ChimaeraWingWarmup extends BukkitRunnable { return; } - if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, 60, player)) { - player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, 60, player))); + int recentlyhurt_cooldown = Config.getInstance().getChimaeraRecentlyHurtCooldown(); + + if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)) { + player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player))); return; } diff --git a/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java b/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java index 3376200ad..d2ab59679 100644 --- a/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java +++ b/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java @@ -6,6 +6,7 @@ import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import com.gmail.nossr50.commands.party.teleport.PtpCommand; +import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.party.PartyManager; @@ -47,8 +48,10 @@ public class TeleportationWarmup extends BukkitRunnable { return; } - if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, 60, teleportingPlayer)) { - teleportingPlayer.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, 60, teleportingPlayer))); + int recentlyhurt_cooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown(); + + if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, teleportingPlayer)) { + teleportingPlayer.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, teleportingPlayer))); return; } diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index 7906dcefc..7b4d477f5 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -46,20 +46,22 @@ public final class ChimaeraWing { location = player.getLocation(); int amount = inHand.getAmount(); long recentlyHurt = mcMMOPlayer.getRecentlyHurt(); - long lastChimaeraWing = mcMMOPlayer.getLastTeleport(); + long lastTeleport = mcMMOPlayer.getLastTeleport(); if (Permissions.chimaeraWing(player) && ItemUtils.isChimaeraWing(inHand)) { if (mcMMOPlayer.getTeleportCommenceLocation() != null) { return; } - if (Config.getInstance().getChimaeraCooldown() > 0 && !SkillUtils.cooldownOver(lastChimaeraWing * Misc.TIME_CONVERSION_FACTOR, Config.getInstance().getChimaeraCooldown(), player)) { - player.sendMessage(ChatColor.RED + "You need to wait before you can use this again! " + ChatColor.YELLOW + "(" + SkillUtils.calculateTimeLeft(lastChimaeraWing * Misc.TIME_CONVERSION_FACTOR, Config.getInstance().getChimaeraCooldown(), player) + ")"); //TODO Locale! + if (Config.getInstance().getChimaeraCooldown() > 0 && !SkillUtils.cooldownOver(lastTeleport * Misc.TIME_CONVERSION_FACTOR, Config.getInstance().getChimaeraCooldown(), player)) { + player.sendMessage(ChatColor.RED + "You need to wait before you can use this again! " + ChatColor.YELLOW + "(" + SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, Config.getInstance().getChimaeraCooldown(), player) + ")"); //TODO Locale! return; } - if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, 60, player)) { - player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, 60, player))); + int recentlyhurt_cooldown = Config.getInstance().getChimaeraRecentlyHurtCooldown(); + + if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)) { + player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player))); return; } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c21d013f2..6ef98f377 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -80,6 +80,7 @@ Items: Enabled: true Cooldown: 240 Warmup: 5 + RecentlyHurt_Cooldown: 60 Prevent_Use_Underground: true Use_Cost: 1 Recipe_Cost: 5 @@ -357,6 +358,7 @@ Commands: ptp: Cooldown: 120 Warmup: 5 + RecentlyHurt_Cooldown: 60 Confirm_Required: true Request_Timeout: 300 # If true, require players to have a mcmmo.commands.ptp.world.[WorldName] permission