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"); updateNotifyPermission = plugin.getConfig().getString("Permission");
if (plugin.getConfig().getBoolean("NotifyUpdate")) { if (plugin.getConfig().getBoolean("NotifyUpdate")) {
currentVersion = plugin.getDescription().getVersion(); currentVersion = plugin.getDescription().getVersion();
Bukkit.getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable() { Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
public void run() { public void run() {
try { try {
UpdateChecker updateChecker = new UpdateChecker(); UpdateChecker updateChecker = new UpdateChecker();
@ -53,7 +53,7 @@ public class DisguiseListener implements Listener {
latestVersion = updateChecker.getLatestVersion(); latestVersion = updateChecker.getLatestVersion();
if (latestVersion != null) { if (latestVersion != null) {
latestVersion = "v" + latestVersion; latestVersion = "v" + latestVersion;
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { Bukkit.getScheduler().runTask(plugin, new Runnable() {
public void run() { public void run() {
for (Player p : Bukkit.getOnlinePlayers()) for (Player p : Bukkit.getOnlinePlayers())
if (p.hasPermission(updateNotifyPermission)) if (p.hasPermission(updateNotifyPermission))
@ -239,7 +239,7 @@ public class DisguiseListener implements Listener {
if (event.getExited() instanceof Player) { if (event.getExited() instanceof Player) {
final Disguise disguise = DisguiseAPI.getDisguise((Player) event.getExited(), event.getExited()); final Disguise disguise = DisguiseAPI.getDisguise((Player) event.getExited(), event.getExited());
if (disguise != null) { if (disguise != null) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { Bukkit.getScheduler().runTask(plugin, new Runnable() {
public void run() { public void run() {
DisguiseUtilities.setupFakeDisguise(disguise); DisguiseUtilities.setupFakeDisguise(disguise);
((Player) disguise.getEntity()).updateInventory(); ((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.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.comphenix.protocol.PacketType; import com.comphenix.protocol.PacketType;
@ -45,7 +46,7 @@ public abstract class Disguise {
private boolean keepDisguisePlayerLogout = DisguiseConfig.isKeepDisguiseOnPlayerLogout(); private boolean keepDisguisePlayerLogout = DisguiseConfig.isKeepDisguiseOnPlayerLogout();
private boolean modifyBoundingBox = DisguiseConfig.isModifyBoundingBox(); private boolean modifyBoundingBox = DisguiseConfig.isModifyBoundingBox();
private boolean replaceSounds = DisguiseConfig.isSoundEnabled(); private boolean replaceSounds = DisguiseConfig.isSoundEnabled();
private int taskId = -1; private BukkitTask task = null;
private Runnable velocityRunnable; private Runnable velocityRunnable;
private boolean velocitySent = DisguiseConfig.isVelocitySent(); private boolean velocitySent = DisguiseConfig.isVelocitySent();
private boolean viewSelfDisguise = DisguiseConfig.isViewDisguises(); private boolean viewSelfDisguise = DisguiseConfig.isViewDisguises();
@ -188,8 +189,8 @@ public abstract class Disguise {
} else { } else {
entity = null; entity = null;
watcher = getWatcher().clone(disguise); watcher = getWatcher().clone(disguise);
Bukkit.getScheduler().cancelTask(taskId); task.cancel();
taskId = -1; task = null;
} }
} }
} else { } else {
@ -404,9 +405,9 @@ public abstract class Disguise {
public void removeDisguise() { public void removeDisguise() {
if (disguiseInUse) { if (disguiseInUse) {
disguiseInUse = false; disguiseInUse = false;
if (taskId != -1) { if (task != null) {
Bukkit.getScheduler().cancelTask(taskId); task.cancel();
taskId = -1; task = null;
} }
HashMap<UUID, HashSet<TargetedDisguise>> disguises = DisguiseUtilities.getDisguises(); HashMap<UUID, HashSet<TargetedDisguise>> disguises = DisguiseUtilities.getDisguises();
// If this disguise has a entity set // 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!"); throw new RuntimeException("No entity is assigned to this disguise!");
} }
disguiseInUse = true; 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 // Stick the disguise in the disguises bin
DisguiseUtilities.addDisguise(entity.getUniqueId(), (TargetedDisguise) this); DisguiseUtilities.addDisguise(entity.getUniqueId(), (TargetedDisguise) this);
// Resend the disguised entity's packet // 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 // Add null so that if this is called again. I already know I'm doing something about it
gameProfiles.put(playerName, null); gameProfiles.put(playerName, null);
Bukkit.getScheduler().scheduleAsyncDelayedTask(libsDisguises, new Runnable() { Bukkit.getScheduler().runTaskAsynchronously(libsDisguises, new Runnable() {
public void run() { public void run() {
try { try {
final WrappedGameProfile gameProfile = lookupGameProfile(playerName); final WrappedGameProfile gameProfile = lookupGameProfile(playerName);
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { Bukkit.getScheduler().runTask(libsDisguises, new Runnable() {
public void run() { public void run() {
if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) { if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) {
gameProfiles.put(playerName, gameProfile); 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. // 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.. // Else its going to run in a infinite loop hue hue hue..
// At least until this disguise is discarded // At least until this disguise is discarded
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { Bukkit.getScheduler().runTask(libsDisguises, new Runnable() {
public void run() { public void run() {
if (DisguiseAPI.getDisguise(player, player) == disguise) { if (DisguiseAPI.getDisguise(player, player) == disguise) {
sendSelfDisguise(player, disguise); sendSelfDisguise(player, disguise);

View File

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