diff --git a/Essentials/src/com/earth2me/essentials/Kits.java b/Essentials/src/com/earth2me/essentials/Kits.java index 730e63c2f..806266d32 100644 --- a/Essentials/src/com/earth2me/essentials/Kits.java +++ b/Essentials/src/com/earth2me/essentials/Kits.java @@ -7,7 +7,6 @@ import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.commands.NoChargeException; import com.earth2me.essentials.settings.Kit; import com.earth2me.essentials.storage.AsyncStorageObjectHolder; -import com.earth2me.essentials.user.UserData; import com.earth2me.essentials.user.UserData.TimestampType; import com.earth2me.essentials.utils.DateUtil; import java.io.File; @@ -18,8 +17,6 @@ import org.bukkit.inventory.ItemStack; public class Kits extends AsyncStorageObjectHolder implements IKits { - - public Kits(final IEssentials ess) { super(ess, com.earth2me.essentials.settings.Kits.class); @@ -66,8 +63,8 @@ public class Kits extends AsyncStorageObjectHolder itemList = kit.getItems(); - user.giveItems(itemList, true); + final List itemList = kit.getItems(); + user.giveItems(itemList, true); } @Override @@ -93,42 +90,49 @@ public class Kits extends AsyncStorageObjectHolder time.getTimeInMillis()) + { + // This is to make sure time didn't get messed up on last kit use. + // If this happens, let's give the user the benifit of the doubt. + user.setTimestamp(TimestampType.KIT, time.getTimeInMillis()); } else { - final Calendar future = new GregorianCalendar(); - future.setTimeInMillis(lastTime); - future.add(Calendar.SECOND, (int)delay); - future.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0)); - user.sendMessage(_("kitTimed", DateUtil.formatDateDiff(future.getTimeInMillis()))); + time.setTimeInMillis(lastTime); + time.add(Calendar.SECOND, (int)delay); + time.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0)); + user.sendMessage(_("kitTimed", DateUtil.formatDateDiff(time.getTimeInMillis()))); throw new NoChargeException(); } } diff --git a/Essentials/src/com/earth2me/essentials/Teleport.java b/Essentials/src/com/earth2me/essentials/Teleport.java index 0f3a8eebf..0a97fbc5b 100644 --- a/Essentials/src/com/earth2me/essentials/Teleport.java +++ b/Essentials/src/com/earth2me/essentials/Teleport.java @@ -1,11 +1,10 @@ package com.earth2me.essentials; -import com.earth2me.essentials.economy.Trade; -import com.earth2me.essentials.utils.Util; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IEssentials; import com.earth2me.essentials.api.ITeleport; import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.economy.Trade; import com.earth2me.essentials.permissions.Permissions; import com.earth2me.essentials.user.CooldownException; import com.earth2me.essentials.user.UserData.TimestampType; @@ -137,6 +136,7 @@ public class Teleport implements Runnable, ITeleport this.ess = ess; } + @Override public void respawn(final Trade chargeFor, TeleportCause cause) throws Exception { final Player player = user.getBase(); @@ -146,6 +146,7 @@ public class Teleport implements Runnable, ITeleport teleport(new Target(pre.getRespawnLocation()), chargeFor, cause); } + @Override public void warp(String warp, Trade chargeFor, TeleportCause cause) throws Exception { final Location loc = ess.getWarps().getWarp(warp); @@ -196,11 +197,13 @@ public class Teleport implements Runnable, ITeleport teleport(new Target(loc), chargeFor, TeleportCause.PLUGIN); } + @Override public void teleport(Location loc, Trade chargeFor, TeleportCause cause) throws Exception { teleport(new Target(loc), chargeFor, cause); } + @Override public void teleport(Entity entity, Trade chargeFor, TeleportCause cause) throws Exception { teleport(new Target(entity), chargeFor, cause); @@ -208,14 +211,14 @@ public class Teleport implements Runnable, ITeleport private void teleport(Target target, Trade chargeFor, TeleportCause cause) throws Exception { - double delay = ess.getRanks().getTeleportDelay(user); + double tDelay = ess.getRanks().getTeleportDelay(user); if (chargeFor != null) { chargeFor.isAffordableFor(user); } cooldown(true); - if (delay <= 0 || Permissions.TELEPORT_TIMER_BYPASS.isAuthorized(user)) + if (tDelay <= 0 || Permissions.TELEPORT_TIMER_BYPASS.isAuthorized(user)) { cooldown(false); now(target, cause); @@ -228,10 +231,10 @@ public class Teleport implements Runnable, ITeleport cancel(); Calendar c = new GregorianCalendar(); - c.add(Calendar.SECOND, (int)delay); - c.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0)); + c.add(Calendar.SECOND, (int)tDelay); + c.add(Calendar.MILLISECOND, (int)((tDelay * 1000.0) % 1000.0)); user.sendMessage(_("dontMoveMessage", DateUtil.formatDateDiff(c.getTimeInMillis()))); - initTimer((long)(delay * 1000.0), target, chargeFor, cause); + initTimer((long)(tDelay * 1000.0), target, chargeFor, cause); teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10); } @@ -243,6 +246,7 @@ public class Teleport implements Runnable, ITeleport user.getBase().teleport(LocationUtil.getSafeDestination(target.getLocation()), cause); } + @Override public void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception { if (cooldown) @@ -259,6 +263,7 @@ public class Teleport implements Runnable, ITeleport now(new Target(loc), cause); } + @Override public void now(Entity entity, boolean cooldown, TeleportCause cause) throws Exception { if (cooldown) @@ -268,6 +273,7 @@ public class Teleport implements Runnable, ITeleport now(new Target(entity), cause); } + @Override public void back(Trade chargeFor) throws Exception { user.acquireReadLock(); @@ -281,6 +287,7 @@ public class Teleport implements Runnable, ITeleport } } + @Override public void back() throws Exception { user.acquireReadLock(); @@ -294,6 +301,7 @@ public class Teleport implements Runnable, ITeleport } } + @Override public void home(Location loc, Trade chargeFor) throws Exception { teleport(new Target(loc), chargeFor, TeleportCause.COMMAND);