Command block messages should be sent on the main thread as it causes a block update (#1796)

- Fixes #1786
This commit is contained in:
Jordan 2022-06-13 22:42:26 +01:00 committed by GitHub
parent f8583fb7cb
commit 97ab47c90b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import com.fastasyncworldedit.core.util.TaskManager;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.AbstractNonPlayerActor; import com.sk89q.worldedit.extension.platform.AbstractNonPlayerActor;
import com.sk89q.worldedit.extension.platform.Locatable; import com.sk89q.worldedit.extension.platform.Locatable;
@ -69,38 +70,63 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements
@Override @Override
@Deprecated @Deprecated
public void printRaw(String msg) { public void printRaw(String msg) {
for (String part : msg.split("\n")) { //FAWE start - ensure executed on main thread
sender.sendMessage(part); TaskManager.taskManager().sync(() -> {
} for (String part : msg.split("\n")) {
sender.sendMessage(part);
}
return null;
});
//FAWE end
} }
@Override @Override
@Deprecated @Deprecated
public void print(String msg) { public void print(String msg) {
for (String part : msg.split("\n")) { //FAWE start - ensure executed on main thread
print(TextComponent.of(part, TextColor.LIGHT_PURPLE)); TaskManager.taskManager().sync(() -> {
} for (String part : msg.split("\n")) {
print(TextComponent.of(part, TextColor.LIGHT_PURPLE));
}
return null;
});
//FAWE end
} }
@Override @Override
@Deprecated @Deprecated
public void printDebug(String msg) { public void printDebug(String msg) {
for (String part : msg.split("\n")) { //FAWE start - ensure executed on main thread
print(TextComponent.of(part, TextColor.GRAY)); TaskManager.taskManager().sync(() -> {
} for (String part : msg.split("\n")) {
print(TextComponent.of(part, TextColor.GRAY));
}
return null;
});
//FAWE end
} }
@Override @Override
@Deprecated @Deprecated
public void printError(String msg) { public void printError(String msg) {
for (String part : msg.split("\n")) { //FAWE start - ensure executed on main thread
print(TextComponent.of(part, TextColor.RED)); TaskManager.taskManager().sync(() -> {
} for (String part : msg.split("\n")) {
print(TextComponent.of(part, TextColor.RED));
}
return null;
});
//FAWE end
} }
@Override @Override
public void print(Component component) { public void print(Component component) {
TextAdapter.sendMessage(sender, WorldEditText.format(component, getLocale())); //FAWE start - ensure executed on main thread
TaskManager.taskManager().sync(() -> {
TextAdapter.sendMessage(sender, WorldEditText.format(component, getLocale()));
return null;
});
//FAWE end
} }
@Override @Override