summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2013-05-18 23:27:41 +0100
committerKHobbits <rob@khobbits.co.uk>2013-05-18 23:27:41 +0100
commit9dc6e7ad1eaf1ddd84a39c875bccbd1c1ff25f47 (patch)
treeccc509dbac04972405c724392f76e4c2d5a60a19
parent293406a603184c87b7e7d40ee8ea5fa0c449da2a (diff)
downloadEssentials-9dc6e7ad1eaf1ddd84a39c875bccbd1c1ff25f47.tar
Essentials-9dc6e7ad1eaf1ddd84a39c875bccbd1c1ff25f47.tar.gz
Essentials-9dc6e7ad1eaf1ddd84a39c875bccbd1c1ff25f47.tar.lz
Essentials-9dc6e7ad1eaf1ddd84a39c875bccbd1c1ff25f47.tar.xz
Essentials-9dc6e7ad1eaf1ddd84a39c875bccbd1c1ff25f47.zip
Add indication of when kit's cannot be used yet, in the /kit output.
-rw-r--r--Essentials/src/com/earth2me/essentials/Kit.java73
-rw-r--r--Essentials/src/messages.properties3
-rw-r--r--Essentials/src/messages_cs.properties1
-rw-r--r--Essentials/src/messages_da.properties1
-rw-r--r--Essentials/src/messages_de.properties1
-rw-r--r--Essentials/src/messages_en.properties3
-rw-r--r--Essentials/src/messages_es.properties1
-rw-r--r--Essentials/src/messages_fi.properties1
-rw-r--r--Essentials/src/messages_fr.properties1
-rw-r--r--Essentials/src/messages_it.properties1
-rw-r--r--Essentials/src/messages_nl.properties1
-rw-r--r--Essentials/src/messages_pl.properties1
-rw-r--r--Essentials/src/messages_pt.properties1
-rw-r--r--Essentials/src/messages_ro.properties1
-rw-r--r--Essentials/src/messages_se.properties1
-rw-r--r--Essentials/src/messages_zh.properties1
-rw-r--r--Essentials/src/messages_zh_HK.properties1
-rw-r--r--Essentials/src/messages_zh_TW.properties1
18 files changed, 68 insertions, 26 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Kit.java b/Essentials/src/com/earth2me/essentials/Kit.java
index 2807a06ad..f093f9221 100644
--- a/Essentials/src/com/earth2me/essentials/Kit.java
+++ b/Essentials/src/com/earth2me/essentials/Kit.java
@@ -33,13 +33,20 @@ public class Kit
else if (user.isAuthorized("essentials.kits." + kitItem.toLowerCase(Locale.ENGLISH)))
{
String cost = "";
+ String name = capitalCase(kitItem);
BigDecimal costPrice = new Trade("kit-" + kitItem.toLowerCase(Locale.ENGLISH), ess).getCommandCost(user);
if (costPrice.signum() > 0)
{
cost = _("kitCost", Util.displayCurrency(costPrice, ess));
}
+ final Map<String, Object> kit = ess.getSettings().getKit(kitItem);
- list.append(" ").append(capitalCase(kitItem)).append(cost);
+ if (Kit.getNextUse(user, kitItem, kit) != 0)
+ {
+ name = _("kitDelay", name);
+ }
+
+ list.append(" ").append(name).append(cost);
}
}
return list.toString().trim();
@@ -53,55 +60,73 @@ public class Kit
public static void checkTime(final User user, final String kitName, final Map<String, Object> els) throws Exception
{
+ final Calendar time = new GregorianCalendar();
+ long nextUse = getNextUse(user, kitName, els);
+
+ if (nextUse == 0L)
+ {
+ user.setKitTimestamp(kitName, time.getTimeInMillis());
+ }
+ else if (nextUse < 0L)
+ {
+ user.sendMessage(_("kitOnce"));
+ throw new NoChargeException();
+ }
+ else
+ {
+ user.sendMessage(_("kitTimed", Util.formatDateDiff(nextUse)));
+ throw new NoChargeException();
+ }
+ }
+
+ public static long getNextUse(final User user, final String kitName, final Map<String, Object> els) throws Exception
+ {
if (user.isAuthorized("essentials.kit.exemptdelay"))
{
- return;
+ return 0L;
}
final Calendar time = new GregorianCalendar();
- // Take the current time, and remove the delay from it.
double delay = 0;
try
- {
- // Also make sure delay is valid
+ {
+ // Make sure delay is valid
delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0.0d;
}
catch (Exception e)
{
throw new Exception(_("kitError2"));
}
- final Calendar earliestTime = new GregorianCalendar();
- earliestTime.add(Calendar.SECOND, -(int)delay);
- earliestTime.add(Calendar.MILLISECOND, -(int)((delay * 1000.0) % 1000.0));
- // This value contains the most recent time a kit could have been used that would allow another use.
- final long earliestLong = earliestTime.getTimeInMillis();
// When was the last kit used?
final long lastTime = user.getKitTimestamp(kitName);
- if (lastTime < earliestLong || lastTime == 0L)
+ // When can be use the kit again?
+ final Calendar delayTime = new GregorianCalendar();
+ delayTime.setTimeInMillis(lastTime);
+ delayTime.add(Calendar.SECOND, (int)delay);
+ delayTime.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
+
+ if (lastTime == 0L || lastTime > time.getTimeInMillis())
{
- user.setKitTimestamp(kitName, time.getTimeInMillis());
+ // If we have no record of kit use, or its corrupted, give them benifit of the doubt.
+ return 0L;
}
- else if (lastTime > time.getTimeInMillis())
+ else if (delay < 0d)
{
- // 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.setKitTimestamp(kitName, time.getTimeInMillis());
+ // If the kit has a negative kit time, it can only be used once.
+ return -1;
}
- else if (earliestLong < 0L)
+ else if (delayTime.before(time))
{
- user.sendMessage(_("kitOnce"));
- throw new NoChargeException();
+ // If the kit was used in the past, but outside the delay time, it can be used.
+ return 0L;
}
else
{
- time.setTimeInMillis(lastTime);
- time.add(Calendar.SECOND, (int)delay);
- time.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
- user.sendMessage(_("kitTimed", Util.formatDateDiff(time.getTimeInMillis())));
- throw new NoChargeException();
+ // If the kit has been used recently, return the next time it can be used.
+ return delayTime.getTimeInMillis();
}
}
diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties
index 7f78033ab..80a703568 100644
--- a/Essentials/src/messages.properties
+++ b/Essentials/src/messages.properties
@@ -217,7 +217,7 @@ kickExempt=\u00a74You can not kick that person.
kickedAll=\u00a74Kicked all players from server.
kill=\u00a76Killed\u00a7c {0}\u00a76.
killExempt=\u00a74You can not kill {0}
-kitCost=\ ({0})
+kitCost=\ \u00a77\u00a7o({0})\u00a7r
kitError2=\u00a74That kit is improperly defined. Contact an administrator.
kitError=\u00a74There are no valid kits.
kitErrorHelp=\u00a74Perhaps an item is missing a quantity in the configuration?
@@ -540,3 +540,4 @@ years=years
youAreHealed=\u00a76You have been healed.
youHaveNewMail=\u00a76You have\u00a7c {0} \u00a76messages! Type \u00a7c/mail read\u00a76 to view your mail.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
+kitDelay=\u00a7m{0}\u00a7r
diff --git a/Essentials/src/messages_cs.properties b/Essentials/src/messages_cs.properties
index 94839e299..cd772c90f 100644
--- a/Essentials/src/messages_cs.properties
+++ b/Essentials/src/messages_cs.properties
@@ -544,3 +544,4 @@ years=roky
youAreHealed=\u00a77Byl jsi uzdraven.
youHaveNewMail=\u00a7cMas {0} zprav!\u00a7f Napis \u00a77/mail read\u00a7f aby jsi si precetl sve zpravy.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
+kitDelay=\u00a7m{0}\u00a7r
diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties
index 605d6b7d5..cebc5729b 100644
--- a/Essentials/src/messages_da.properties
+++ b/Essentials/src/messages_da.properties
@@ -540,3 +540,4 @@ years=\u00e5r
youAreHealed=\u00a77Du er blevet healed. Halleluja!
youHaveNewMail=\u00a7cDu har {0} flaskeposter!\u00a7f Type \u00a77/mail read for at se din flaskepost.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
+kitDelay=\u00a7m{0}\u00a7r
diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties
index 69f80fcb1..84e2ec1d1 100644
--- a/Essentials/src/messages_de.properties
+++ b/Essentials/src/messages_de.properties
@@ -540,3 +540,4 @@ years=Jahre
youAreHealed=\u00a77Du wurdest geheilt.
youHaveNewMail=\u00a7cDu hast {0} Nachrichten!\u00a7f Schreibe \u00a77/mail read\u00a7f um deine Nachrichten anzuzeigen.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
+kitDelay=\u00a7m{0}\u00a7r
diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties
index 7f78033ab..80a703568 100644
--- a/Essentials/src/messages_en.properties
+++ b/Essentials/src/messages_en.properties
@@ -217,7 +217,7 @@ kickExempt=\u00a74You can not kick that person.
kickedAll=\u00a74Kicked all players from server.
kill=\u00a76Killed\u00a7c {0}\u00a76.
killExempt=\u00a74You can not kill {0}
-kitCost=\ ({0})
+kitCost=\ \u00a77\u00a7o({0})\u00a7r
kitError2=\u00a74That kit is improperly defined. Contact an administrator.
kitError=\u00a74There are no valid kits.
kitErrorHelp=\u00a74Perhaps an item is missing a quantity in the configuration?
@@ -540,3 +540,4 @@ years=years
youAreHealed=\u00a76You have been healed.
youHaveNewMail=\u00a76You have\u00a7c {0} \u00a76messages! Type \u00a7c/mail read\u00a76 to view your mail.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
+kitDelay=\u00a7m{0}\u00a7r
diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties
index ebf960ce3..b5970a078 100644
--- a/Essentials/src/messages_es.properties
+++ b/Essentials/src/messages_es.properties
@@ -540,3 +540,4 @@ years=anos
youAreHealed=\u00a77Has sido curado.
youHaveNewMail=\u00a7cTienes {0} mensajes!\u00a7f Pon \u00a77/mail read\u00a7f para ver tus emails no leidos!.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
+kitDelay=\u00a7m{0}\u00a7r
diff --git a/Essentials/src/messages_fi.properties b/Essentials/src/messages_fi.properties
index ab964ab30..cbe17df53 100644
--- a/Essentials/src/messages_fi.properties
+++ b/Essentials/src/messages_fi.properties
@@ -540,3 +540,4 @@ years=vuosia
youAreHealed=\u00a77Sinut on parannettu.
youHaveNewMail=\u00a7cSinulla on {0} viesti(\u00e4)!\u00a7f Kirjoita \u00a77/mail read\u00a7f lukeaksesi viestit.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
+kitDelay=\u00a7m{0}\u00a7r
diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties
index 0e9276ea7..398a729aa 100644
--- a/Essentials/src/messages_fr.properties
+++ b/Essentials/src/messages_fr.properties
@@ -540,3 +540,4 @@ years=ann\u00e9es
youAreHealed=\u00a77Vous avez \u00e9t\u00e9 soign\u00e9.
youHaveNewMail=\u00a7cVous avez {0} message(s) ! \u00a7fEntrez \u00a77/mail read\u00a7f pour voir votre courrier.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
+kitDelay=\u00a7m{0}\u00a7r
diff --git a/Essentials/src/messages_it.properties b/Essentials/src/messages_it.properties
index 03624ba66..b20ce9b54 100644
--- a/Essentials/src/messages_it.properties
+++ b/Essentials/src/messages_it.properties
@@ -540,3 +540,4 @@ years=anni
youAreHealed=\u00a77Sei stato curato.
youHaveNewMail=\u00a7cHai {0} messaggi!\u00a7f digita \u00a77/mail read\u00a7f per consultare la tua mail.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
+kitDelay=\u00a7m{0}\u00a7r
diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties
index eec193047..453691ae4 100644
--- a/Essentials/src/messages_nl.properties
+++ b/Essentials/src/messages_nl.properties
@@ -540,3 +540,4 @@ years=jaren
youAreHealed=\u00a77Je bent genezen.
youHaveNewMail=\u00a7cJe hebt {0} berichten!\u00a7f Type \u00a77/mail read\u00a7f om je berichten te bekijken.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
+kitDelay=\u00a7m{0}\u00a7r
diff --git a/Essentials/src/messages_pl.properties b/Essentials/src/messages_pl.properties
index c681e7203..80bb0e6d8 100644
--- a/Essentials/src/messages_pl.properties
+++ b/Essentials/src/messages_pl.properties
@@ -540,3 +540,4 @@ years=lat
youAreHealed=\u00a77Zostales uleczony.
youHaveNewMail=\u00a77Masz\u00a7c {0} \u00a77wiadomosci! Wpisz \u00a7c/mail read\u00a77 aby je przeczytac.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
+kitDelay=\u00a7m{0}\u00a7r
diff --git a/Essentials/src/messages_pt.properties b/Essentials/src/messages_pt.properties
index a6442ea26..a9642f884 100644
--- a/Essentials/src/messages_pt.properties
+++ b/Essentials/src/messages_pt.properties
@@ -540,3 +540,4 @@ years=anos
youAreHealed=\u00a76Voc\u00c3\u00aa foi curado.
youHaveNewMail=\u00a76Voc\u00c3\u00aa tem\u00a7c {0} \u00a76mensagens! Digite \u00a7c/mail read\u00a76 para v\u00c3\u00aa-las.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
+kitDelay=\u00a7m{0}\u00a7r
diff --git a/Essentials/src/messages_ro.properties b/Essentials/src/messages_ro.properties
index 7f226df3b..f7cefc67f 100644
--- a/Essentials/src/messages_ro.properties
+++ b/Essentials/src/messages_ro.properties
@@ -540,3 +540,4 @@ years=ani
youAreHealed=\u00a76Ai fost vindecat.
youHaveNewMail=\u00a76Ai\u00a7c {0} \u00a76mesaje! scrie \u00a7c/mail read\u00a76 pentru a-ti vedea mesajele.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
+kitDelay=\u00a7m{0}\u00a7r
diff --git a/Essentials/src/messages_se.properties b/Essentials/src/messages_se.properties
index 75ae9767b..e8d989fcc 100644
--- a/Essentials/src/messages_se.properties
+++ b/Essentials/src/messages_se.properties
@@ -540,3 +540,4 @@ years=\u00e5r
youAreHealed=\u00a77Du har blivit l\u00e4kt.
youHaveNewMail=\u00a7cDu har {0} meddelanden!\u00a7f Skriv \u00a77/mail read\u00a7f f\u00f6r att l\u00e4sa dina meddelanden.
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
+kitDelay=\u00a7m{0}\u00a7r
diff --git a/Essentials/src/messages_zh.properties b/Essentials/src/messages_zh.properties
index 43158df54..548cd522f 100644
--- a/Essentials/src/messages_zh.properties
+++ b/Essentials/src/messages_zh.properties
@@ -541,3 +541,4 @@ years=\u5e74
youAreHealed=\u00a76\u4f60\u5df2\u88ab\u6cbb\u7597
youHaveNewMail=\u00a76\u4f60\u62e5\u6709 \u00a7c{0}\u00a76 \u6761\u6d88\u606f\uff01\u00a7r\u8f93\u5165 \u00a7c/mail read\u00a76 \u6765\u67e5\u770b
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
+kitDelay=\u00a7m{0}\u00a7r
diff --git a/Essentials/src/messages_zh_HK.properties b/Essentials/src/messages_zh_HK.properties
index f8719d98b..85d4a79ed 100644
--- a/Essentials/src/messages_zh_HK.properties
+++ b/Essentials/src/messages_zh_HK.properties
@@ -542,3 +542,4 @@ years=\u5e74
youAreHealed=\u00a76\u4f60\u5df2\u88ab\u6cbb\u7642
youHaveNewMail=\u00a76\u4f60\u64c1\u6709 \u00a7c{0}\u00a76 \u689d\u6d88\u606f\uff01\u00a7r\u8f38\u5165 \u00a7c/mail read\u00a76 \u4f86\u67e5\u770b
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
+kitDelay=\u00a7m{0}\u00a7r
diff --git a/Essentials/src/messages_zh_TW.properties b/Essentials/src/messages_zh_TW.properties
index 0c2dd97bc..c6a9115d2 100644
--- a/Essentials/src/messages_zh_TW.properties
+++ b/Essentials/src/messages_zh_TW.properties
@@ -542,3 +542,4 @@ years=\u5e74
youAreHealed=\u00a76\u4f60\u5df2\u88ab\u6cbb\u7642
youHaveNewMail=\u00a76\u4f60\u64c1\u6709 \u00a7c{0}\u00a76 \u689d\u6d88\u606f\uff01\u00a7r\u8f38\u5165 \u00a7c/mail read\u00a76 \u4f86\u67e5\u770b
whoisHunger=\u00a76 - Hunger:\u00a7r {0}/20 (+{1} saturation)
+kitDelay=\u00a7m{0}\u00a7r