Skip to content

Commit 0be7cdc

Browse files
authored
Merge pull request #2771 from BentoBoxWorld/develop
Release 3.10.1
2 parents 92308fd + ac65c5d commit 0be7cdc

File tree

3 files changed

+8
-19
lines changed

3 files changed

+8
-19
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
<!-- Do not change unless you want different name for local builds. -->
7676
<build.number>-LOCAL</build.number>
7777
<!-- This allows to change between versions. -->
78-
<build.version>3.10.0</build.version>
78+
<build.version>3.10.1</build.version>
7979
<sonar.organization>bentobox-world</sonar.organization>
8080
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
8181
<server.jars>${project.basedir}/lib</server.jars>

src/main/java/world/bentobox/bentobox/listeners/teleports/AbstractTeleportListener.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99

1010
import java.util.HashMap;
11-
import java.util.HashSet;
1211
import java.util.Map;
1312
import java.util.Objects;
1413
import java.util.Optional;
1514
import java.util.Set;
1615
import java.util.UUID;
16+
import java.util.concurrent.TimeUnit;
1717

1818
import org.bukkit.Bukkit;
1919
import org.bukkit.Location;
@@ -27,6 +27,7 @@
2727
import world.bentobox.bentobox.BentoBox;
2828
import world.bentobox.bentobox.api.addons.GameModeAddon;
2929
import world.bentobox.bentobox.database.objects.Island;
30+
import world.bentobox.bentobox.util.ExpiringSet;
3031
import world.bentobox.bentobox.util.Util;
3132

3233

@@ -42,8 +43,8 @@ public abstract class AbstractTeleportListener
4243
AbstractTeleportListener(@NonNull BentoBox bentoBox)
4344
{
4445
this.plugin = bentoBox;
45-
this.inPortal = new HashSet<>();
46-
this.inTeleport = new HashSet<>();
46+
this.inPortal = new ExpiringSet<UUID>(10, TimeUnit.SECONDS);
47+
this.inTeleport = new ExpiringSet<UUID>(10, TimeUnit.SECONDS);
4748
this.teleportOrigin = new HashMap<>();
4849
}
4950

@@ -378,7 +379,7 @@ protected boolean isPastingMissingIslands(World overWorld)
378379
/**
379380
* Set of entities that currently is inside portal.
380381
*/
381-
protected final Set<UUID> inPortal;
382+
protected final ExpiringSet<UUID> inPortal;
382383

383384
/**
384385
* Map that links entities origin of teleportation. Used for respawning.

src/main/java/world/bentobox/bentobox/listeners/teleports/EntityTeleportListener.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public EntityTeleportListener(@NonNull BentoBox bentoBox)
4848
super(bentoBox);
4949
}
5050

51-
5251
/**
5352
* This listener checks entity portal events and triggers appropriate methods to transfer
5453
* entities to the correct location in other dimension.
@@ -121,13 +120,10 @@ public void onEntityEnterPortal(EntityPortalEnterEvent event)
121120
Entity entity = event.getEntity();
122121
Material type = event.getLocation().getBlock().getType();
123122
UUID uuid = entity.getUniqueId();
124-
125-
if (this.inPortal.contains(uuid))
126-
{
127-
// Already in process.
123+
if (entity.getPortalCooldown() > 0) {
128124
return;
129125
}
130-
126+
131127
World fromWorld = event.getLocation().getWorld();
132128
World overWorld = Util.getWorld(fromWorld);
133129

@@ -142,8 +138,6 @@ public void onEntityEnterPortal(EntityPortalEnterEvent event)
142138
// Teleportation is disabled. Cancel processing.
143139
return;
144140
}
145-
146-
this.inPortal.add(uuid);
147141
// Add original world for respawning.
148142
this.teleportOrigin.put(uuid, fromWorld);
149143

@@ -176,12 +170,6 @@ public void onEntityEnterPortal(EntityPortalEnterEvent event)
176170
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
177171
public void onEntityExitPortal(EntityPortalExitEvent event)
178172
{
179-
if (!this.inPortal.contains(event.getEntity().getUniqueId()))
180-
{
181-
return;
182-
}
183-
184-
this.inPortal.remove(event.getEntity().getUniqueId());
185173
this.inTeleport.remove(event.getEntity().getUniqueId());
186174
this.teleportOrigin.remove(event.getEntity().getUniqueId());
187175
}

0 commit comments

Comments
 (0)