Archiviert
13
0

Don't call deprecated methods.

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2013-01-13 11:41:32 +01:00
Ursprung f416d1ba3d
Commit 37a9fc6a98
4 geänderte Dateien mit 24 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -25,6 +25,7 @@ import com.comphenix.protocol.error.ErrorReporter;
import com.comphenix.protocol.metrics.Updater;
import com.comphenix.protocol.metrics.Updater.UpdateResult;
import com.comphenix.protocol.metrics.Updater.UpdateType;
import com.comphenix.protocol.utility.WrappedScheduler;
/**
* Handles the "protocol" administration command.
@ -64,10 +65,9 @@ class CommandProtocol extends CommandBase {
return true;
}
@SuppressWarnings("deprecation")
public void checkVersion(final CommandSender sender) {
// Perform on an async thread
plugin.getServer().getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable() {
WrappedScheduler.runAsynchronouslyOnce(plugin, new Runnable() {
@Override
public void run() {
try {
@ -77,15 +77,14 @@ class CommandProtocol extends CommandBase {
getReporter().reportDetailed(this, "Cannot check updates for ProtocolLib.", e, sender);
}
}
});
}, 0L);
updateFinished();
}
@SuppressWarnings("deprecation")
public void updateVersion(final CommandSender sender) {
// Perform on an async thread
plugin.getServer().getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable() {
WrappedScheduler.runAsynchronouslyOnce(plugin, new Runnable() {
@Override
public void run() {
try {
@ -95,7 +94,7 @@ class CommandProtocol extends CommandBase {
getReporter().reportDetailed(this, "Cannot update ProtocolLib.", e, sender);
}
}
});
}, 0L);
updateFinished();
}

Datei anzeigen

@ -30,6 +30,7 @@ import com.comphenix.protocol.events.ListeningWhitelist;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.events.PacketListener;
import com.comphenix.protocol.utility.WrappedScheduler;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
@ -298,9 +299,9 @@ public class AsyncListenerHandler {
});
}
@SuppressWarnings("deprecation")
private void scheduleAsync(Runnable runnable) {
filterManager.getScheduler().scheduleAsyncDelayedTask(listener.getPlugin(), runnable);
// Handle deprecation
WrappedScheduler.runAsynchronouslyRepeat(listener.getPlugin(), filterManager.getScheduler(), runnable, 0L, -1L);
}
/**

Datei anzeigen

@ -239,7 +239,7 @@ public class Metrics {
}
// Begin hitting the server with glorious data
task = WrappedScheduler.runAsynchronously(plugin, new Runnable() {
task = WrappedScheduler.runAsynchronouslyRepeat(plugin, new Runnable() {
private boolean firstPost = true;

Datei anzeigen

@ -21,15 +21,26 @@ public class WrappedScheduler {
}
/**
* Schedule a given task for asynchronous execution.
* Schedule a given task for a single asynchronous execution.
* @param plugin - the owner plugin.
* @param runnable - the task to run.
* @param firstDelay - the amount of time to wait until executing the task.
* @return A cancel token.
*/
public static TaskWrapper runAsynchronouslyOnce(final Plugin plugin, Runnable runnable, long firstDelay) {
return runAsynchronouslyRepeat(plugin, plugin.getServer().getScheduler(), runnable, firstDelay, -1L);
}
/**
* Schedule a given task for multiple asynchronous executions.
* @param plugin - the owner plugin.
* @param runnable - the task to run.
* @param firstDelay - the amount of time to wait until executing the task for the first time.
* @param repeatDelay - the amount of time inbetween each execution. If less than zero, the task is only executed once.
* @return A cancel token.
*/
public static TaskWrapper runAsynchronously(final Plugin plugin, Runnable runnable, long firstDelay, long repeatDelay) {
return runAsynchronously(plugin, plugin.getServer().getScheduler(), runnable, firstDelay, repeatDelay);
public static TaskWrapper runAsynchronouslyRepeat(final Plugin plugin, Runnable runnable, long firstDelay, long repeatDelay) {
return runAsynchronouslyRepeat(plugin, plugin.getServer().getScheduler(), runnable, firstDelay, repeatDelay);
}
/**
@ -41,7 +52,7 @@ public class WrappedScheduler {
* @param repeatDelay - the amount of time inbetween each execution. If less than zero, the task is only executed once.
* @return A cancel token.
*/
public static TaskWrapper runAsynchronously(final Plugin plugin, final BukkitScheduler scheduler, Runnable runnable, long firstDelay, long repeatDelay) {
public static TaskWrapper runAsynchronouslyRepeat(final Plugin plugin, final BukkitScheduler scheduler, Runnable runnable, long firstDelay, long repeatDelay) {
try {
@SuppressWarnings("deprecation")
final int taskID = scheduler.scheduleAsyncRepeatingTask(plugin, runnable, firstDelay, repeatDelay);