Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-16 16:10:07 +01:00
fix: "synchronise" wrapping bukkit Player on the main thread
Dieser Commit ist enthalten in:
Ursprung
f93ad596c6
Commit
aaf33aa8a7
@ -21,6 +21,7 @@ package com.sk89q.worldedit.bukkit;
|
|||||||
|
|
||||||
import com.fastasyncworldedit.bukkit.BukkitPermissionAttachmentManager;
|
import com.fastasyncworldedit.bukkit.BukkitPermissionAttachmentManager;
|
||||||
import com.fastasyncworldedit.bukkit.FaweBukkit;
|
import com.fastasyncworldedit.bukkit.FaweBukkit;
|
||||||
|
import com.fastasyncworldedit.core.util.TaskManager;
|
||||||
import com.fastasyncworldedit.core.util.UpdateNotification;
|
import com.fastasyncworldedit.core.util.UpdateNotification;
|
||||||
import com.fastasyncworldedit.core.Fawe;
|
import com.fastasyncworldedit.core.Fawe;
|
||||||
import com.fastasyncworldedit.core.util.WEManager;
|
import com.fastasyncworldedit.core.util.WEManager;
|
||||||
@ -91,6 +92,7 @@ import java.nio.file.Paths;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.sk89q.worldedit.internal.anvil.ChunkDeleter.DELCHUNKS_FILE_NAME;
|
import static com.sk89q.worldedit.internal.anvil.ChunkDeleter.DELCHUNKS_FILE_NAME;
|
||||||
@ -565,14 +567,15 @@ public class WorldEditPlugin extends JavaPlugin {
|
|||||||
//FAWE start - Use cache over returning a direct BukkitPlayer
|
//FAWE start - Use cache over returning a direct BukkitPlayer
|
||||||
BukkitPlayer wePlayer = getCachedPlayer(player);
|
BukkitPlayer wePlayer = getCachedPlayer(player);
|
||||||
if (wePlayer == null) {
|
if (wePlayer == null) {
|
||||||
synchronized (player) {
|
Supplier<BukkitPlayer> task = () -> {
|
||||||
wePlayer = getCachedPlayer(player);
|
BukkitPlayer bukkitPlayer = getCachedPlayer(player);
|
||||||
if (wePlayer == null) {
|
if (bukkitPlayer == null) {
|
||||||
wePlayer = new BukkitPlayer(this, player);
|
bukkitPlayer = new BukkitPlayer(this, player);
|
||||||
player.setMetadata("WE", new FixedMetadataValue(this, wePlayer));
|
player.setMetadata("WE", new FixedMetadataValue(this, bukkitPlayer));
|
||||||
return wePlayer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return bukkitPlayer;
|
||||||
|
};
|
||||||
|
TaskManager.taskManager().sync(task);
|
||||||
}
|
}
|
||||||
return wePlayer;
|
return wePlayer;
|
||||||
//FAWE end
|
//FAWE end
|
||||||
@ -588,11 +591,12 @@ public class WorldEditPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BukkitPlayer reCachePlayer(Player player) {
|
BukkitPlayer reCachePlayer(Player player) {
|
||||||
synchronized (player) {
|
Supplier<BukkitPlayer> task = () -> {
|
||||||
BukkitPlayer wePlayer = new BukkitPlayer(this, player);
|
BukkitPlayer wePlayer = new BukkitPlayer(this, player);
|
||||||
player.setMetadata("WE", new FixedMetadataValue(this, wePlayer));
|
player.setMetadata("WE", new FixedMetadataValue(this, wePlayer));
|
||||||
return wePlayer;
|
return wePlayer;
|
||||||
}
|
};
|
||||||
|
return TaskManager.taskManager().sync(task);
|
||||||
}
|
}
|
||||||
//FAWE end
|
//FAWE end
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren