Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Don't freeze current thread when sending chunks
Dieser Commit ist enthalten in:
Ursprung
0ea32b3318
Commit
c5ac3c9b3d
@ -29,6 +29,7 @@ import java.util.Map;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
||||||
@ -158,15 +159,18 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(final Runnable runnable) {
|
public void run(final Runnable runnable, boolean wait) {
|
||||||
try {
|
try {
|
||||||
Bukkit.getScheduler().callSyncMethod(Bukkit.getPluginManager().getPlugin("ViaVersion"), new Callable<Boolean>() {
|
Future f = Bukkit.getScheduler().callSyncMethod(Bukkit.getPluginManager().getPlugin("ViaVersion"), new Callable<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean call() throws Exception {
|
public Boolean call() throws Exception {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}).get(10, TimeUnit.SECONDS);
|
});
|
||||||
|
if(wait){
|
||||||
|
f.get(10, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("Failed to run task.");
|
System.out.println("Failed to run task.");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -68,7 +68,7 @@ public class ViaEncodeHandler extends MessageToByteEncoder {
|
|||||||
};
|
};
|
||||||
// Synced allows timings to work properly.
|
// Synced allows timings to work properly.
|
||||||
if (ViaVersion.getInstance().isSyncedChunks()) {
|
if (ViaVersion.getInstance().isSyncedChunks()) {
|
||||||
((ViaVersionPlugin) ViaVersion.getInstance()).run(chunks);
|
((ViaVersionPlugin) ViaVersion.getInstance()).run(chunks, false);
|
||||||
} else {
|
} else {
|
||||||
chunks.run();
|
chunks.run();
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren