From 61903355cd4817055ab2144097284ccac0861664 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Tue, 27 Nov 2012 18:25:24 +0000 Subject: Fix kit timers, kit times more than 25 years will be treated as single use. --- Essentials/src/com/earth2me/essentials/Kit.java | 11 ++++++++--- Essentials/src/messages.properties | 1 + Essentials/src/messages_cs.properties | 1 + Essentials/src/messages_da.properties | 1 + Essentials/src/messages_de.properties | 1 + Essentials/src/messages_en.properties | 1 + Essentials/src/messages_es.properties | 1 + Essentials/src/messages_fi.properties | 1 + Essentials/src/messages_fr.properties | 1 + Essentials/src/messages_it.properties | 1 + Essentials/src/messages_nl.properties | 1 + Essentials/src/messages_pl.properties | 1 + Essentials/src/messages_pt.properties | 1 + Essentials/src/messages_se.properties | 1 + 14 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Kit.java b/Essentials/src/com/earth2me/essentials/Kit.java index 476aaea97..89965e589 100644 --- a/Essentials/src/com/earth2me/essentials/Kit.java +++ b/Essentials/src/com/earth2me/essentials/Kit.java @@ -37,7 +37,7 @@ public class Kit } - public static void checkTime(final User user, final String kitName, final Map els) throws NoChargeException + public static void checkTime(final User user, final String kitName, final Map els) throws Exception { if (user.isAuthorized("essentials.kit.exemptdelay")) { return; @@ -46,7 +46,7 @@ public class Kit final Calendar time = new GregorianCalendar(); // Take the current time, and remove the delay from it. - final double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0L; + final double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0.0d; final Calendar earliestTime = new GregorianCalendar(); earliestTime.add(Calendar.SECOND, -(int)delay); earliestTime.add(Calendar.MILLISECOND, -(int)((delay * 1000.0) % 1000.0)); @@ -56,7 +56,7 @@ public class Kit // When was the last kit used? final long lastTime = user.getKitTimestamp(kitName); - if (lastTime < earliestLong) + if (lastTime < earliestLong || lastTime == 0L) { user.setKitTimestamp(kitName, time.getTimeInMillis()); } @@ -66,6 +66,11 @@ public class Kit // If this happens, let's give the user the benifit of the doubt. user.setKitTimestamp(kitName, time.getTimeInMillis()); } + else if (earliestLong < 0L) + { + user.sendMessage(_("kitOnce")); + throw new NoChargeException(); + } else { time.setTimeInMillis(lastTime); diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index c7170ae0b..a75198a62 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -462,3 +462,4 @@ invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} +kitOnce=\u00a74You can't use that kit again. diff --git a/Essentials/src/messages_cs.properties b/Essentials/src/messages_cs.properties index 6eef42338..be5ca4dfd 100644 --- a/Essentials/src/messages_cs.properties +++ b/Essentials/src/messages_cs.properties @@ -465,3 +465,4 @@ invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} +kitOnce=\u00a74You can't use that kit again. diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 45329febb..8a6fe98be 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -462,3 +462,4 @@ invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} +kitOnce=\u00a74You can't use that kit again. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index b8f087cd7..7535d3cc7 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -462,3 +462,4 @@ invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} +kitOnce=\u00a74You can't use that kit again. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index c7170ae0b..a75198a62 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -462,3 +462,4 @@ invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} +kitOnce=\u00a74You can't use that kit again. diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties index a2dec7c90..e3d5bac59 100644 --- a/Essentials/src/messages_es.properties +++ b/Essentials/src/messages_es.properties @@ -462,3 +462,4 @@ invalidWarpName=\u00a74Nombre de warp invalido userUnknown=\u00a74Peligro: El jugador '\u00a7c{0}\u00a74' Nunca a ingresado a este servidor. teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} +kitOnce=\u00a74You can't use that kit again. diff --git a/Essentials/src/messages_fi.properties b/Essentials/src/messages_fi.properties index ff9df7257..0b8fbeb63 100644 --- a/Essentials/src/messages_fi.properties +++ b/Essentials/src/messages_fi.properties @@ -462,3 +462,4 @@ invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} +kitOnce=\u00a74You can't use that kit again. diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index fb858afe2..2505ed700 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -462,3 +462,4 @@ invalidWarpName=\u00a74Nom de warp invalide userUnknown=\u00a74Attention : Le joueur '\u00a7c{0}\u00a74' n'est jamais venu sur ce serveur. teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} +kitOnce=\u00a74You can't use that kit again. diff --git a/Essentials/src/messages_it.properties b/Essentials/src/messages_it.properties index 901433e83..272a1d574 100644 --- a/Essentials/src/messages_it.properties +++ b/Essentials/src/messages_it.properties @@ -462,3 +462,4 @@ invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} +kitOnce=\u00a74You can't use that kit again. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index aeaa048b4..03a141a73 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -462,3 +462,4 @@ invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} +kitOnce=\u00a74You can't use that kit again. diff --git a/Essentials/src/messages_pl.properties b/Essentials/src/messages_pl.properties index 094a22663..7487679d8 100644 --- a/Essentials/src/messages_pl.properties +++ b/Essentials/src/messages_pl.properties @@ -462,3 +462,4 @@ invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} +kitOnce=\u00a74You can't use that kit again. diff --git a/Essentials/src/messages_pt.properties b/Essentials/src/messages_pt.properties index 513bf2f4d..3e24ee5b0 100644 --- a/Essentials/src/messages_pt.properties +++ b/Essentials/src/messages_pt.properties @@ -462,3 +462,4 @@ invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} +kitOnce=\u00a74You can't use that kit again. diff --git a/Essentials/src/messages_se.properties b/Essentials/src/messages_se.properties index 75d175330..7a8115ab8 100644 --- a/Essentials/src/messages_se.properties +++ b/Essentials/src/messages_se.properties @@ -462,3 +462,4 @@ invalidWarpName=\u00a74Invalid warp name userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server. teleportationEnabledFor=\u00a76Teleportation enabled for {0} teleportationDisabledFor=\u00a76Teleportation disabled for {0} +kitOnce=\u00a74You can't use that kit again. -- cgit v1.2.3