From 8939fc09b3d3a7f57806075f0271505f6887562a Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 24 Jul 2013 13:57:53 -0400 Subject: [PATCH] Patch potential exploit relating to teleportation and acrobatics. --- .../com/gmail/nossr50/datatypes/player/McMMOPlayer.java | 9 +++++++++ .../java/com/gmail/nossr50/listeners/EntityListener.java | 5 +++++ .../java/com/gmail/nossr50/listeners/PlayerListener.java | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index 3f325b62e..c55fa2af6 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -84,6 +84,7 @@ public class McMMOPlayer { private int recentlyHurt; private int respawnATS; + private int teleportATS; private int chimeraWingLastUse; private Location teleportCommence; @@ -343,6 +344,14 @@ public class McMMOPlayer { respawnATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); } + public int getTeleportATS() { + return teleportATS; + } + + public void actualizeTeleportATS() { + teleportATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); + } + /* * Repair Anvil Placement */ diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index e74f3fe80..732a491ae 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -50,6 +50,7 @@ import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.CombatUtils; +import com.gmail.nossr50.util.skills.SkillUtils; public class EntityListener implements Listener { private final mcMMO plugin; @@ -221,6 +222,10 @@ public class EntityListener implements Listener { switch (cause) { case FALL: + if (SkillUtils.calculateTimeLeft((long) mcMMOPlayer.getTeleportATS() * Misc.TIME_CONVERSION_FACTOR, 5, player) > 0) { + return; + } + AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager(); if (acrobaticsManager.canRoll()) { diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 15a8f64e1..cc29d5366 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -24,6 +24,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; @@ -66,6 +67,12 @@ public class PlayerListener implements Listener { this.plugin = plugin; } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerTeleport(PlayerTeleportEvent event) { + UserManager.getPlayer(event.getPlayer()).actualizeTeleportATS(); + } + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerDeathLowest(PlayerDeathEvent event) { String deathMessage = event.getDeathMessage();