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

12
pom.xml
View File

@ -7,10 +7,14 @@
<groupId>me.ryanhamshire</groupId> <groupId>me.ryanhamshire</groupId>
<artifactId>GriefPrevention</artifactId> <artifactId>GriefPrevention</artifactId>
<version>15.2.4</version> <version>15.2.4</version>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<repositories> <repositories>
<repository> <repository>
<id>spigot-repo</id> <id>paper-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> <url>https://repo.destroystokyo.com/repository/maven-public/</url>
</repository> </repository>
<repository> <repository>
<id>worldedit-worldguard-repo</id> <id>worldedit-worldguard-repo</id>
@ -48,8 +52,8 @@
<dependencies> <dependencies>
<!--Bukkit API--> <!--Bukkit API-->
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>com.destroystokyo.paper</groupId>
<artifactId>bukkit</artifactId> <artifactId>paper-api</artifactId>
<version>1.10.2-R0.1-SNAPSHOT</version> <version>1.10.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>

View File

@ -52,6 +52,6 @@ class CheckForPortalTrapTask extends BukkitRunnable
instance.portalReturnTaskMap.remove(player.getUniqueId()); instance.portalReturnTaskMap.remove(player.getUniqueId());
return; return;
} }
instance.rescuePlayerTrappedInPortal(player); player.setPortalCooldown(0);
} }
} }

View File

@ -3609,6 +3609,7 @@ public class GriefPrevention extends JavaPlugin
!claim.isAdminClaim() && GriefPrevention.instance.config_pvp_noCombatInPlayerLandClaims; !claim.isAdminClaim() && GriefPrevention.instance.config_pvp_noCombatInPlayerLandClaims;
} }
/*
protected boolean isPlayerTrappedInPortal(Block block) protected boolean isPlayerTrappedInPortal(Block block)
{ {
Material playerBlock = block.getType(); Material playerBlock = block.getType();
@ -3662,14 +3663,13 @@ public class GriefPrevention extends JavaPlugin
} }
}.runTaskLater(this, 600L); }.runTaskLater(this, 600L);
} }
*/
//remember where players teleport from (via portals) in case they're trapped at the destination //Track scheduled "rescues" so we can cancel them if the player happens to teleport elsewhere so we can cancel it.
ConcurrentHashMap<UUID, Location> portalReturnMap = new ConcurrentHashMap<UUID, Location>();
ConcurrentHashMap<UUID, BukkitTask> portalReturnTaskMap = new ConcurrentHashMap<UUID, BukkitTask>(); 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); BukkitTask task = new CheckForPortalTrapTask(player, this).runTaskLater(GriefPrevention.instance, 600L);
portalReturnMap.put(player.getUniqueId(), rescueLocation);
//Cancel existing rescue task //Cancel existing rescue task
if (portalReturnTaskMap.containsKey(player.getUniqueId())) if (portalReturnTaskMap.containsKey(player.getUniqueId()))

View File

@ -131,9 +131,6 @@ public class PlayerData
//this is an anti-bot strategy. //this is an anti-bot strategy.
Location noChatLocation = null; Location noChatLocation = null;
//last rescue location, if player was recently rescued (to undo if rescue was unnecessary)
Location portalTrappedLocation = null;
//ignore list //ignore list
//true means invisible (admin-forced ignore), false means player-created ignore //true means invisible (admin-forced ignore), false means player-created ignore
public ConcurrentHashMap<UUID, Boolean> ignoredPlayers = new ConcurrentHashMap<UUID, Boolean>(); public ConcurrentHashMap<UUID, Boolean> ignoredPlayers = new ConcurrentHashMap<UUID, Boolean>();

View File

@ -763,7 +763,7 @@ class PlayerEventHandler implements Listener
new IgnoreLoaderThread(playerID, playerData.ignoredPlayers).start(); new IgnoreLoaderThread(playerID, playerData.ignoredPlayers).start();
//is he possibly stuck in a portal frame? //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 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) if(GriefPrevention.instance.config_spam_logoutMessageDelaySeconds > 0)
@ -978,11 +978,10 @@ class PlayerEventHandler implements Listener
if(!GriefPrevention.instance.claimsEnabledForWorld(event.getTo().getWorld())) return; if(!GriefPrevention.instance.claimsEnabledForWorld(event.getTo().getWorld())) return;
Player player = event.getPlayer(); Player player = event.getPlayer();
if(event.getCause() == TeleportCause.NETHER_PORTAL) if(event.getCause() == TeleportCause.NETHER_PORTAL)
{ {
//FEATURE: when players get trapped in a nether portal, send them back through to the other side //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 //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) if(GriefPrevention.instance.config_claims_portalsRequirePermission)