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

Datei anzeigen

@ -30,6 +30,7 @@ import com.comphenix.protocol.events.ListeningWhitelist;
import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.events.PacketListener; import com.comphenix.protocol.events.PacketListener;
import com.comphenix.protocol.utility.WrappedScheduler;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
@ -298,9 +299,9 @@ public class AsyncListenerHandler {
}); });
} }
@SuppressWarnings("deprecation")
private void scheduleAsync(Runnable runnable) { 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 // Begin hitting the server with glorious data
task = WrappedScheduler.runAsynchronously(plugin, new Runnable() { task = WrappedScheduler.runAsynchronouslyRepeat(plugin, new Runnable() {
private boolean firstPost = true; 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 plugin - the owner plugin.
* @param runnable - the task to run. * @param runnable - the task to run.
* @param firstDelay - the amount of time to wait until executing the task for the first time. * @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. * @param repeatDelay - the amount of time inbetween each execution. If less than zero, the task is only executed once.
* @return A cancel token. * @return A cancel token.
*/ */
public static TaskWrapper runAsynchronously(final Plugin plugin, Runnable runnable, long firstDelay, long repeatDelay) { public static TaskWrapper runAsynchronouslyRepeat(final Plugin plugin, Runnable runnable, long firstDelay, long repeatDelay) {
return runAsynchronously(plugin, plugin.getServer().getScheduler(), runnable, firstDelay, 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. * @param repeatDelay - the amount of time inbetween each execution. If less than zero, the task is only executed once.
* @return A cancel token. * @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 { try {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
final int taskID = scheduler.scheduleAsyncRepeatingTask(plugin, runnable, firstDelay, repeatDelay); final int taskID = scheduler.scheduleAsyncRepeatingTask(plugin, runnable, firstDelay, repeatDelay);