@@ -121,14 +121,18 @@ private void updateProgress(UUID uuid, int speed, int progress, Location source,
121
121
122
122
PaperLib .teleportAsync (p , destination ).thenAccept (teleported -> {
123
123
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
+ });
132
136
}
133
137
});
134
138
}
0 commit comments