Use fancy new player#setPortalCooldown

As discussed in #13
- Also now using Paper repo (spigot repo was too slow to get CB with the
new portalCooldown API)
This commit is contained in:
RoboMWM
2016-10-02 01:00:54 -07:00
parent 035469052a
commit 35a67de339
5 changed files with 15 additions and 15 deletions
@@ -52,6 +52,6 @@ class CheckForPortalTrapTask extends BukkitRunnable
instance.portalReturnTaskMap.remove(player.getUniqueId());
return;
}
instance.rescuePlayerTrappedInPortal(player);
player.setPortalCooldown(0);
}
}
@@ -3609,6 +3609,7 @@ public class GriefPrevention extends JavaPlugin
!claim.isAdminClaim() && GriefPrevention.instance.config_pvp_noCombatInPlayerLandClaims;
}
/*
protected boolean isPlayerTrappedInPortal(Block block)
{
Material playerBlock = block.getType();
@@ -3662,14 +3663,13 @@ public class GriefPrevention extends JavaPlugin
}
}.runTaskLater(this, 600L);
}
*/
//remember where players teleport from (via portals) in case they're trapped at the destination
ConcurrentHashMap<UUID, Location> portalReturnMap = new ConcurrentHashMap<UUID, Location>();
//Track scheduled "rescues" so we can cancel them if the player happens to teleport elsewhere so we can cancel it.
ConcurrentHashMap<UUID, BukkitTask> portalReturnTaskMap = new ConcurrentHashMap<UUID, BukkitTask>();
public void startRescueTask(Player player, Location rescueLocation)
public void startRescueTask(Player player)
{
BukkitTask task = new CheckForPortalTrapTask(player, this).runTaskLater(GriefPrevention.instance, 600L);
portalReturnMap.put(player.getUniqueId(), rescueLocation);
//Cancel existing rescue task
if (portalReturnTaskMap.containsKey(player.getUniqueId()))
@@ -131,9 +131,6 @@ public class PlayerData
//this is an anti-bot strategy.
Location noChatLocation = null;
//last rescue location, if player was recently rescued (to undo if rescue was unnecessary)
Location portalTrappedLocation = null;
//ignore list
//true means invisible (admin-forced ignore), false means player-created ignore
public ConcurrentHashMap<UUID, Boolean> ignoredPlayers = new ConcurrentHashMap<UUID, Boolean>();
@@ -763,7 +763,7 @@ class PlayerEventHandler implements Listener
new IgnoreLoaderThread(playerID, playerData.ignoredPlayers).start();
//is he possibly stuck in a portal frame?
instance.rescuePlayerTrappedInPortal(player);
player.setPortalCooldown(0);
//if we're holding a logout message for this player, don't send that or this event's join message
if(GriefPrevention.instance.config_spam_logoutMessageDelaySeconds > 0)
@@ -978,11 +978,10 @@ class PlayerEventHandler implements Listener
if(!GriefPrevention.instance.claimsEnabledForWorld(event.getTo().getWorld())) return;
Player player = event.getPlayer();
if(event.getCause() == TeleportCause.NETHER_PORTAL)
{
//FEATURE: when players get trapped in a nether portal, send them back through to the other side
instance.startRescueTask(player, event.getFrom());
instance.startRescueTask(player);
//FEATURE: if the player teleporting doesn't have permission to build a nether portal and none already exists at the destination, cancel the teleportation
if(GriefPrevention.instance.config_claims_portalsRequirePermission)