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