3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-19 14:30:16 +01:00

Rename platform task implementations

Dieser Commit ist enthalten in:
KennyTV 2021-04-29 17:46:29 +02:00
Ursprung 96b5051c75
Commit ab93e0877c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
12 geänderte Dateien mit 31 neuen und 42 gelöschten Zeilen

Datei anzeigen

@ -31,9 +31,9 @@ public interface PlatformTask<T> {
/**
* Returns the actual object represented by this task/task id.
* Null if task cannot be cancelled.
* Null if task cannot be instantly tracked.
*
* @return platform based object, or null if not cancellable
* @return platform based object, or null if not tracked/cancellable
*/
@Nullable T getObject();

Datei anzeigen

@ -115,17 +115,6 @@ public interface ViaPlatform<T> {
*/
PlatformTask runRepeatingSync(Runnable runnable, long ticks);
/**
* Cancels a task.
*
* @param task task to cancel
*/
default void cancelTask(PlatformTask task) {
if (task.getObject() != null) {
task.cancel();
}
}
/**
* Get the online players
*

Datei anzeigen

@ -30,7 +30,7 @@ import com.viaversion.viaversion.bukkit.classgenerator.ClassGenerator;
import com.viaversion.viaversion.bukkit.commands.BukkitCommandHandler;
import com.viaversion.viaversion.bukkit.commands.BukkitCommandSender;
import com.viaversion.viaversion.bukkit.listeners.ProtocolLibEnableListener;
import com.viaversion.viaversion.bukkit.platform.BukkitTaskId;
import com.viaversion.viaversion.bukkit.platform.BukkitViaTask;
import com.viaversion.viaversion.bukkit.platform.BukkitViaAPI;
import com.viaversion.viaversion.bukkit.platform.BukkitViaConfig;
import com.viaversion.viaversion.bukkit.platform.BukkitViaInjector;
@ -180,31 +180,31 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform<Player>
@Override
public PlatformTask runAsync(Runnable runnable) {
if (isPluginEnabled()) {
return new BukkitTaskId(getServer().getScheduler().runTaskAsynchronously(this, runnable));
return new BukkitViaTask(getServer().getScheduler().runTaskAsynchronously(this, runnable));
} else {
asyncQueuedTasks.add(runnable);
return new BukkitTaskId(null);
return new BukkitViaTask(null);
}
}
@Override
public PlatformTask runSync(Runnable runnable) {
if (isPluginEnabled()) {
return new BukkitTaskId(getServer().getScheduler().runTask(this, runnable));
return new BukkitViaTask(getServer().getScheduler().runTask(this, runnable));
} else {
queuedTasks.add(runnable);
return new BukkitTaskId(null);
return new BukkitViaTask(null);
}
}
@Override
public PlatformTask runSync(Runnable runnable, long ticks) {
return new BukkitTaskId(getServer().getScheduler().runTaskLater(this, runnable, ticks));
return new BukkitViaTask(getServer().getScheduler().runTaskLater(this, runnable, ticks));
}
@Override
public PlatformTask runRepeatingSync(Runnable runnable, long ticks) {
return new BukkitTaskId(getServer().getScheduler().runTaskTimer(this, runnable, 0, ticks));
return new BukkitViaTask(getServer().getScheduler().runTaskTimer(this, runnable, 0, ticks));
}
@Override

Datei anzeigen

@ -22,10 +22,10 @@ import com.viaversion.viaversion.api.platform.PlatformTask;
import org.bukkit.scheduler.BukkitTask;
import org.checkerframework.checker.nullness.qual.Nullable;
public class BukkitTaskId implements PlatformTask<BukkitTask> {
public class BukkitViaTask implements PlatformTask<BukkitTask> {
private final BukkitTask task;
public BukkitTaskId(@Nullable BukkitTask task) {
public BukkitViaTask(@Nullable BukkitTask task) {
this.task = task;
}

Datei anzeigen

@ -28,7 +28,7 @@ import com.viaversion.viaversion.api.platform.ViaPlatform;
import com.viaversion.viaversion.bungee.commands.BungeeCommand;
import com.viaversion.viaversion.bungee.commands.BungeeCommandHandler;
import com.viaversion.viaversion.bungee.commands.BungeeCommandSender;
import com.viaversion.viaversion.bungee.platform.BungeeTaskId;
import com.viaversion.viaversion.bungee.platform.BungeeViaTask;
import com.viaversion.viaversion.bungee.platform.BungeeViaAPI;
import com.viaversion.viaversion.bungee.platform.BungeeViaConfig;
import com.viaversion.viaversion.bungee.platform.BungeeViaInjector;
@ -113,7 +113,7 @@ public class BungeePlugin extends Plugin implements ViaPlatform<ProxiedPlayer>,
@Override
public PlatformTask runAsync(Runnable runnable) {
return new BungeeTaskId(getProxy().getScheduler().runAsync(this, runnable));
return new BungeeViaTask(getProxy().getScheduler().runAsync(this, runnable));
}
@Override
@ -123,12 +123,12 @@ public class BungeePlugin extends Plugin implements ViaPlatform<ProxiedPlayer>,
@Override
public PlatformTask runSync(Runnable runnable, long ticks) {
return new BungeeTaskId(getProxy().getScheduler().schedule(this, runnable, ticks * 50, TimeUnit.MILLISECONDS));
return new BungeeViaTask(getProxy().getScheduler().schedule(this, runnable, ticks * 50, TimeUnit.MILLISECONDS));
}
@Override
public PlatformTask runRepeatingSync(Runnable runnable, long ticks) {
return new BungeeTaskId(getProxy().getScheduler().schedule(this, runnable, 0, ticks * 50, TimeUnit.MILLISECONDS));
return new BungeeViaTask(getProxy().getScheduler().schedule(this, runnable, 0, ticks * 50, TimeUnit.MILLISECONDS));
}
@Override

Datei anzeigen

@ -20,10 +20,10 @@ package com.viaversion.viaversion.bungee.platform;
import com.viaversion.viaversion.api.platform.PlatformTask;
import net.md_5.bungee.api.scheduler.ScheduledTask;
public class BungeeTaskId implements PlatformTask<ScheduledTask> {
public class BungeeViaTask implements PlatformTask<ScheduledTask> {
private final ScheduledTask task;
public BungeeTaskId(ScheduledTask task) {
public BungeeViaTask(ScheduledTask task) {
this.task = task;
}

Datei anzeigen

@ -151,7 +151,7 @@ public class ViaManagerImpl implements ViaManager {
// Common tasks
mappingLoadingTask = Via.getPlatform().runRepeatingSync(() -> {
if (protocolManager.checkForMappingCompletion()) {
platform.cancelTask(mappingLoadingTask);
mappingLoadingTask.cancel();
mappingLoadingTask = null;
}
}, 10L);

Datei anzeigen

@ -29,7 +29,7 @@ import com.viaversion.viaversion.dump.PluginInfo;
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import com.viaversion.viaversion.sponge.commands.SpongeCommandHandler;
import com.viaversion.viaversion.sponge.commands.SpongeCommandSender;
import com.viaversion.viaversion.sponge.platform.SpongeTaskId;
import com.viaversion.viaversion.sponge.platform.SpongeViaTask;
import com.viaversion.viaversion.sponge.platform.SpongeViaAPI;
import com.viaversion.viaversion.sponge.platform.SpongeViaConfig;
import com.viaversion.viaversion.sponge.platform.SpongeViaInjector;
@ -128,7 +128,7 @@ public class SpongePlugin implements ViaPlatform<Player> {
@Override
public PlatformTask runAsync(Runnable runnable) {
return new SpongeTaskId(
return new SpongeViaTask(
Task.builder()
.execute(runnable)
.async()
@ -138,7 +138,7 @@ public class SpongePlugin implements ViaPlatform<Player> {
@Override
public PlatformTask runSync(Runnable runnable) {
return new SpongeTaskId(
return new SpongeViaTask(
Task.builder()
.execute(runnable)
.submit(this)
@ -147,7 +147,7 @@ public class SpongePlugin implements ViaPlatform<Player> {
@Override
public PlatformTask runSync(Runnable runnable, long ticks) {
return new SpongeTaskId(
return new SpongeViaTask(
Task.builder()
.execute(runnable)
.delayTicks(ticks)
@ -157,7 +157,7 @@ public class SpongePlugin implements ViaPlatform<Player> {
@Override
public PlatformTask runRepeatingSync(Runnable runnable, long ticks) {
return new SpongeTaskId(
return new SpongeViaTask(
Task.builder()
.execute(runnable)
.intervalTicks(ticks)

Datei anzeigen

@ -103,7 +103,7 @@ public class SpongeViaLoader implements ViaPlatformLoader {
public void unload() {
listeners.forEach(Sponge.getEventManager()::unregisterListeners);
listeners.clear();
tasks.forEach(Via.getPlatform()::cancelTask);
tasks.forEach(PlatformTask::cancel);
tasks.clear();
}
}

Datei anzeigen

@ -20,10 +20,10 @@ package com.viaversion.viaversion.sponge.platform;
import com.viaversion.viaversion.api.platform.PlatformTask;
import org.spongepowered.api.scheduler.Task;
public class SpongeTaskId implements PlatformTask<Task> {
public class SpongeViaTask implements PlatformTask<Task> {
private final Task task;
public SpongeTaskId(Task task) {
public SpongeViaTask(Task task) {
this.task = task;
}

Datei anzeigen

@ -39,7 +39,7 @@ import com.viaversion.viaversion.util.GsonUtil;
import com.viaversion.viaversion.util.VersionInfo;
import com.viaversion.viaversion.velocity.command.VelocityCommandHandler;
import com.viaversion.viaversion.velocity.command.VelocityCommandSender;
import com.viaversion.viaversion.velocity.platform.VelocityTaskId;
import com.viaversion.viaversion.velocity.platform.VelocityViaTask;
import com.viaversion.viaversion.velocity.platform.VelocityViaAPI;
import com.viaversion.viaversion.velocity.platform.VelocityViaConfig;
import com.viaversion.viaversion.velocity.platform.VelocityViaInjector;
@ -138,7 +138,7 @@ public class VelocityPlugin implements ViaPlatform<Player> {
@Override
public PlatformTask runSync(Runnable runnable, long ticks) {
return new VelocityTaskId(
return new VelocityViaTask(
PROXY.getScheduler()
.buildTask(this, runnable)
.delay(ticks * 50, TimeUnit.MILLISECONDS).schedule()
@ -147,7 +147,7 @@ public class VelocityPlugin implements ViaPlatform<Player> {
@Override
public PlatformTask runRepeatingSync(Runnable runnable, long ticks) {
return new VelocityTaskId(
return new VelocityViaTask(
PROXY.getScheduler()
.buildTask(this, runnable)
.repeat(ticks * 50, TimeUnit.MILLISECONDS).schedule()

Datei anzeigen

@ -20,10 +20,10 @@ package com.viaversion.viaversion.velocity.platform;
import com.velocitypowered.api.scheduler.ScheduledTask;
import com.viaversion.viaversion.api.platform.PlatformTask;
public class VelocityTaskId implements PlatformTask<ScheduledTask> {
public class VelocityViaTask implements PlatformTask<ScheduledTask> {
private final ScheduledTask task;
public VelocityTaskId(ScheduledTask task) {
public VelocityViaTask(ScheduledTask task) {
this.task = task;
}