Bukkit command cleanup/fixes

This commit is contained in:
dfsek
2021-03-10 03:03:04 -07:00
parent 513c6a647f
commit a584ac2401
4 changed files with 21 additions and 2 deletions

View File

@@ -53,4 +53,15 @@ public interface TerraPlugin extends LoaderRegistrar {
default String getVersion() {
return "@VERSION@";
}
/**
* Runs a task that may or may not be thread safe, depending on platform.
* <p>
* Allows platforms to define what code is safe to be run asynchronously.
*
* @param task Task to be run.
*/
default void runPossiblyUnsafeTask(Runnable task) {
task.run();
}
}

View File

@@ -69,7 +69,7 @@ public class BiomeLocateCommand implements CommandTemplate {
if(location != null) {
sender.sendMessage(String.format("The nearest %s is at [%d, ~, %d] (%.1f blocks away)", biome.getID().toLowerCase(Locale.ROOT), location.getBlockX(), location.getBlockZ(), location.add(new Vector3(0, player.getLocation().getY(), 0)).distance(player.getLocation().toVector())));
if(teleport) {
player.setLocation(new Location(player.getWorld(), location.getX(), player.getLocation().getY(), location.getZ()));
main.runPossiblyUnsafeTask(() -> player.setLocation(new Location(player.getWorld(), location.getX(), player.getLocation().getY(), location.getZ())));
}
} else LangUtil.send("command.biome.unable-to-locate", sender);
}, main), "Biome Location Thread").start();