Use new-style runTask methods

This commit is contained in:
riking 2014-06-13 23:19:23 -07:00
parent 4c14e6b72a
commit c1b5780d77
4 changed files with 15 additions and 14 deletions

View File

@ -45,7 +45,7 @@ public class DisguiseListener implements Listener {
updateNotifyPermission = plugin.getConfig().getString("Permission");
if (plugin.getConfig().getBoolean("NotifyUpdate")) {
currentVersion = plugin.getDescription().getVersion();
Bukkit.getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable() {
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
public void run() {
try {
UpdateChecker updateChecker = new UpdateChecker();
@ -53,7 +53,7 @@ public class DisguiseListener implements Listener {
latestVersion = updateChecker.getLatestVersion();
if (latestVersion != null) {
latestVersion = "v" + latestVersion;
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
Bukkit.getScheduler().runTask(plugin, new Runnable() {
public void run() {
for (Player p : Bukkit.getOnlinePlayers())
if (p.hasPermission(updateNotifyPermission))
@ -239,7 +239,7 @@ public class DisguiseListener implements Listener {
if (event.getExited() instanceof Player) {
final Disguise disguise = DisguiseAPI.getDisguise((Player) event.getExited(), event.getExited());
if (disguise != null) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
Bukkit.getScheduler().runTask(plugin, new Runnable() {
public void run() {
DisguiseUtilities.setupFakeDisguise(disguise);
((Player) disguise.getEntity()).updateInventory();

View File

@ -25,6 +25,7 @@ import org.bukkit.entity.Horse.Variant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
import com.comphenix.protocol.PacketType;
@ -45,7 +46,7 @@ public abstract class Disguise {
private boolean keepDisguisePlayerLogout = DisguiseConfig.isKeepDisguiseOnPlayerLogout();
private boolean modifyBoundingBox = DisguiseConfig.isModifyBoundingBox();
private boolean replaceSounds = DisguiseConfig.isSoundEnabled();
private int taskId = -1;
private BukkitTask task = null;
private Runnable velocityRunnable;
private boolean velocitySent = DisguiseConfig.isVelocitySent();
private boolean viewSelfDisguise = DisguiseConfig.isViewDisguises();
@ -188,8 +189,8 @@ public abstract class Disguise {
} else {
entity = null;
watcher = getWatcher().clone(disguise);
Bukkit.getScheduler().cancelTask(taskId);
taskId = -1;
task.cancel();
task = null;
}
}
} else {
@ -404,9 +405,9 @@ public abstract class Disguise {
public void removeDisguise() {
if (disguiseInUse) {
disguiseInUse = false;
if (taskId != -1) {
Bukkit.getScheduler().cancelTask(taskId);
taskId = -1;
if (task != null) {
task.cancel();
task = null;
}
HashMap<UUID, HashSet<TargetedDisguise>> disguises = DisguiseUtilities.getDisguises();
// If this disguise has a entity set
@ -657,7 +658,7 @@ public abstract class Disguise {
throw new RuntimeException("No entity is assigned to this disguise!");
}
disguiseInUse = true;
taskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, velocityRunnable, 1, 1);
task = Bukkit.getScheduler().runTaskTimer(plugin, velocityRunnable, 1, 1);
// Stick the disguise in the disguises bin
DisguiseUtilities.addDisguise(entity.getUniqueId(), (TargetedDisguise) this);
// Resend the disguised entity's packet

View File

@ -387,11 +387,11 @@ public class DisguiseUtilities {
}
// Add null so that if this is called again. I already know I'm doing something about it
gameProfiles.put(playerName, null);
Bukkit.getScheduler().scheduleAsyncDelayedTask(libsDisguises, new Runnable() {
Bukkit.getScheduler().runTaskAsynchronously(libsDisguises, new Runnable() {
public void run() {
try {
final WrappedGameProfile gameProfile = lookupGameProfile(playerName);
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
Bukkit.getScheduler().runTask(libsDisguises, new Runnable() {
public void run() {
if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) {
gameProfiles.put(playerName, gameProfile);
@ -647,7 +647,7 @@ public class DisguiseUtilities {
// If it is, then this method will be run again in one tick. Which is when it should be constructed.
// Else its going to run in a infinite loop hue hue hue..
// At least until this disguise is discarded
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
Bukkit.getScheduler().runTask(libsDisguises, new Runnable() {
public void run() {
if (DisguiseAPI.getDisguise(player, player) == disguise) {
sendSelfDisguise(player, disguise);

View File

@ -909,7 +909,7 @@ public class PacketsManager {
if (clickedItem != null && clickedItem.getType() != Material.AIR) {
// Rather than predict the clients actions
// Lets just update the entire inventory..
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
Bukkit.getScheduler().runTask(libsDisguises, new Runnable() {
public void run() {
event.getPlayer().updateInventory();
}