mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-02-04 22:41:33 +01:00
Move the teleport timer to an async task.
This commit is contained in:
parent
18811122b3
commit
4672e51806
@ -804,6 +804,12 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials
|
||||
return this.getScheduler().runTaskLaterAsynchronously(this, run, delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BukkitTask runTaskTimerAsynchronously(final Runnable run, final long delay, final long period)
|
||||
{
|
||||
return this.getScheduler().runTaskTimerAsynchronously(this, run, delay, period);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleSyncDelayedTask(final Runnable run)
|
||||
{
|
||||
|
@ -64,11 +64,13 @@ public interface IEssentials extends Plugin
|
||||
|
||||
BukkitTask runTaskLaterAsynchronously(Runnable run, long delay);
|
||||
|
||||
BukkitTask runTaskTimerAsynchronously(Runnable run, long delay, long period);
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run);
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run, long delay);
|
||||
|
||||
int scheduleSyncRepeatingTask(final Runnable run, long delay, long period);
|
||||
int scheduleSyncRepeatingTask(Runnable run, long delay, long period);
|
||||
|
||||
TNTExplodeListener getTNTListener();
|
||||
|
||||
@ -76,7 +78,7 @@ public interface IEssentials extends Plugin
|
||||
|
||||
AlternativeCommandsHandler getAlternativeCommandsHandler();
|
||||
|
||||
void showError(final CommandSource sender, final Throwable exception, final String commandLabel);
|
||||
void showError(CommandSource sender, Throwable exception, String commandLabel);
|
||||
|
||||
IItemDb getItemDb();
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class TimedTeleport implements Runnable
|
||||
this.timer_respawn = respawn;
|
||||
this.timer_canMove = user.isAuthorized("essentials.teleport.timer.move");
|
||||
|
||||
timer_task = ess.scheduleSyncRepeatingTask(this, 20, 20);
|
||||
timer_task = ess.runTaskTimerAsynchronously(this, 20, 20).getTaskId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -63,7 +63,7 @@ public class TimedTeleport implements Runnable
|
||||
return;
|
||||
}
|
||||
|
||||
IUser teleportUser = ess.getUser(this.timer_teleportee);
|
||||
final IUser teleportUser = ess.getUser(this.timer_teleportee);
|
||||
|
||||
if (teleportUser == null || !teleportUser.getBase().isOnline())
|
||||
{
|
||||
@ -89,6 +89,12 @@ public class TimedTeleport implements Runnable
|
||||
return;
|
||||
}
|
||||
|
||||
ess.scheduleSyncDelayedTask(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
|
||||
timer_health = teleportUser.getBase().getHealth(); // in case user healed, then later gets injured
|
||||
final long now = System.currentTimeMillis();
|
||||
if (now > timer_started + timer_delay)
|
||||
@ -109,6 +115,9 @@ public class TimedTeleport implements Runnable
|
||||
{
|
||||
cancelTimer(false);
|
||||
teleportUser.sendMessage(tl("teleportationCommencing"));
|
||||
|
||||
try
|
||||
{
|
||||
if (timer_chargeFor != null)
|
||||
{
|
||||
timer_chargeFor.isAffordableFor(teleportOwner);
|
||||
@ -128,10 +137,16 @@ public class TimedTeleport implements Runnable
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ess.showError(teleportOwner.getSource(), ex, "\\ teleport");
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ess.showError(teleportOwner.getSource(), ex, "\\ teleport");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//If we need to cancelTimer a pending teleportPlayer call this method
|
||||
|
Loading…
Reference in New Issue
Block a user