Skip to content

Commit 397f194

Browse files
Fixed two synchronization issues
1 parent fd10f2e commit 397f194

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java

+12-8
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,18 @@ private void updateProgress(UUID uuid, int speed, int progress, Location source,
121121

122122
PaperLib.teleportAsync(p, destination).thenAccept(teleported -> {
123123
if (teleported.booleanValue()) {
124-
if (resistance) {
125-
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 600, 20));
126-
SlimefunPlugin.getLocalization().sendMessage(p, "machines.TELEPORTER.invulnerability");
127-
}
128-
129-
destination.getWorld().spawnParticle(Particle.PORTAL, new Location(destination.getWorld(), destination.getX(), destination.getY() + 1, destination.getZ()), progress * 2, 0.2F, 0.8F, 0.2F);
130-
destination.getWorld().playSound(destination, Sound.BLOCK_BEACON_ACTIVATE, 1F, 1F);
131-
teleporterUsers.remove(uuid);
124+
// This needs to run on the main Thread so we force it, as the
125+
// async teleportation might happen on a seperate Thread.
126+
Slimefun.runSync(() -> {
127+
if (resistance) {
128+
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 600, 20));
129+
SlimefunPlugin.getLocalization().sendMessage(p, "machines.TELEPORTER.invulnerability");
130+
}
131+
132+
destination.getWorld().spawnParticle(Particle.PORTAL, new Location(destination.getWorld(), destination.getX(), destination.getY() + 1, destination.getZ()), progress * 2, 0.2F, 0.8F, 0.2F);
133+
destination.getWorld().playSound(destination, Sound.BLOCK_BEACON_ACTIVATE, 1F, 1F);
134+
teleporterUsers.remove(uuid);
135+
});
132136
}
133137
});
134138
}

src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/ElevatorPlate.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public void open(Player p, Block b) {
138138
Location destination = new Location(player.getWorld(), block.getX() + 0.5, block.getY() + 0.4, block.getZ() + 0.5, yaw, player.getEyeLocation().getPitch());
139139
PaperLib.teleportAsync(player, destination).thenAccept(teleported -> {
140140
if (teleported.booleanValue()) {
141-
player.sendTitle(ChatColor.WHITE + ChatColors.color(floor), " ", 20, 60, 20);
141+
Slimefun.runSync(() -> player.sendTitle(ChatColor.WHITE + ChatColors.color(floor), " ", 20, 60, 20));
142142
}
143143
});
144144
})));

0 commit comments

Comments
 (0)