mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 04:20:41 +00:00
Minor TP and timer tweaks.
This commit is contained in:
parent
f48871ff29
commit
dfc62bca76
4 changed files with 56 additions and 42 deletions
|
@ -225,7 +225,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
|||
final MetricsStarter metricsStarter = new MetricsStarter(this);
|
||||
if (metricsStarter.getStart() != null && metricsStarter.getStart() == true)
|
||||
{
|
||||
getScheduler().runTaskLaterAsynchronously(this, metricsStarter, 1);
|
||||
runTaskLaterAsynchronously(metricsStarter, 1);
|
||||
}
|
||||
else if (metricsStarter.getStart() != null && metricsStarter.getStart() == false)
|
||||
{
|
||||
|
|
|
@ -52,8 +52,10 @@ public class EssentialsTimer implements Runnable
|
|||
skip1--;
|
||||
continue;
|
||||
}
|
||||
if (count % 10 == 0) {
|
||||
if (System.nanoTime() - startTime > maxTime / 2) {
|
||||
if (count % 10 == 0)
|
||||
{
|
||||
if (System.nanoTime() - startTime > maxTime / 2)
|
||||
{
|
||||
skip1 = count - 1;
|
||||
break;
|
||||
}
|
||||
|
@ -81,8 +83,10 @@ public class EssentialsTimer implements Runnable
|
|||
skip2--;
|
||||
continue;
|
||||
}
|
||||
if (count % 10 == 0) {
|
||||
if (System.nanoTime() - startTime > maxTime) {
|
||||
if (count % 10 == 0)
|
||||
{
|
||||
if (System.nanoTime() - startTime > maxTime)
|
||||
{
|
||||
skip2 = count - 1;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ public class Teleport implements Runnable, ITeleport
|
|||
private long initZ;
|
||||
private Target teleportTarget;
|
||||
private boolean respawn;
|
||||
private boolean canMove;
|
||||
private Trade chargeFor;
|
||||
private final IEssentials ess;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
@ -80,6 +81,10 @@ public class Teleport implements Runnable, ITeleport
|
|||
this.chargeFor = chargeFor;
|
||||
this.cause = cause;
|
||||
this.respawn = respawn;
|
||||
|
||||
this.canMove = user.isAuthorized("essentials.teleport.timer.move");
|
||||
|
||||
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -91,24 +96,33 @@ public class Teleport implements Runnable, ITeleport
|
|||
cancel(false);
|
||||
return;
|
||||
}
|
||||
if (teleportUser == null || !teleportUser.isOnline() || teleportUser.getLocation() == null)
|
||||
|
||||
if (teleportUser == null || !teleportUser.isOnline())
|
||||
{
|
||||
cancel(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!user.isAuthorized("essentials.teleport.timer.move")
|
||||
&& (Math.round(teleportUser.getLocation().getX() * MOVE_CONSTANT) != initX
|
||||
|| Math.round(teleportUser.getLocation().getY() * MOVE_CONSTANT) != initY
|
||||
|| Math.round(teleportUser.getLocation().getZ() * MOVE_CONSTANT) != initZ
|
||||
final Location currLocation = teleportUser.getLocation();
|
||||
if (currLocation == null)
|
||||
{
|
||||
cancel(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!canMove
|
||||
&& (Math.round(currLocation.getX() * MOVE_CONSTANT) != initX
|
||||
|| Math.round(currLocation.getY() * MOVE_CONSTANT) != initY
|
||||
|| Math.round(currLocation.getZ() * MOVE_CONSTANT) != initZ
|
||||
|| teleportUser.getHealth() < health))
|
||||
{
|
||||
// user moved, cancel teleport
|
||||
cancel(true);
|
||||
return;
|
||||
}
|
||||
|
||||
health = teleportUser.getHealth(); // in case user healed, then later gets injured
|
||||
long now = System.currentTimeMillis();
|
||||
final long now = System.currentTimeMillis();
|
||||
if (now > started + tpdelay)
|
||||
{
|
||||
try
|
||||
|
@ -283,8 +297,6 @@ public class Teleport implements Runnable, ITeleport
|
|||
cancel(false);
|
||||
warnUser(user, delay);
|
||||
initTimer((long)(delay * 1000.0), target, chargeFor, cause);
|
||||
|
||||
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
|
||||
}
|
||||
|
||||
//The teleportToMe function is a wrapper used to handle teleporting players to them, like /tphere
|
||||
|
@ -312,7 +324,6 @@ public class Teleport implements Runnable, ITeleport
|
|||
cancel(false);
|
||||
warnUser(otherUser, delay);
|
||||
initTimer((long)(delay * 1000.0), otherUser, target, chargeFor, cause, false);
|
||||
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
|
||||
}
|
||||
|
||||
private void warnUser(final IUser user, final double delay)
|
||||
|
@ -346,7 +357,6 @@ public class Teleport implements Runnable, ITeleport
|
|||
cancel(false);
|
||||
warnUser(user, delay);
|
||||
initTimer((long)(delay * 1000.0), user, null, chargeFor, cause, true);
|
||||
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
|
||||
}
|
||||
|
||||
public void respawn(TeleportCause cause) throws Exception
|
||||
|
|
|
@ -33,7 +33,7 @@ public class MetricsListener implements Listener
|
|||
player.sendMessage("To opt out, run /essentials opt-out");
|
||||
ess.getLogger().log(Level.INFO, "[Metrics] Admin join - Starting 5 minute opt-out period.");
|
||||
ess.getSettings().setMetricsEnabled(true);
|
||||
ess.getScheduler().runTaskLaterAsynchronously(ess, starter, 5 * 1200);
|
||||
ess.runTaskLaterAsynchronously(starter, 5 * 1200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue