From af248a1d2eda2bf2a3dc24a8b7cf7af8fb21e596 Mon Sep 17 00:00:00 2001 From: snowleo Date: Sun, 21 Aug 2011 21:27:22 +0200 Subject: Wait 1 second after deactivation of protect to allow the database to close. --- .../src/com/earth2me/essentials/protect/EssentialsProtect.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java index bae792d06..fa1fadad6 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java @@ -190,6 +190,14 @@ public class EssentialsProtect extends JavaPlugin implements IConf, IProtect { storage.onPluginDeactivation(); } + // Sleep for a second to allow the database to close. + try + { + Thread.sleep(1000); + } + catch (InterruptedException ex) + { + } } public IEssentials getEssentials() -- cgit v1.2.3 From 1ac033a60e9f5e619ff977cffd842fc33562f51f Mon Sep 17 00:00:00 2001 From: snowleo Date: Sun, 21 Aug 2011 21:27:36 +0200 Subject: Pages for /warp command --- Essentials/src/com/earth2me/essentials/Warps.java | 5 ++- .../earth2me/essentials/commands/Commandwarp.java | 47 ++++++++++++++-------- Essentials/src/messages.properties | 1 + Essentials/src/messages_da.properties | 1 + Essentials/src/messages_de.properties | 1 + Essentials/src/messages_en.properties | 1 + Essentials/src/messages_fr.properties | 1 + Essentials/src/messages_nl.properties | 1 + Essentials/src/plugin.yml | 2 +- 9 files changed, 41 insertions(+), 19 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Warps.java b/Essentials/src/com/earth2me/essentials/Warps.java index b1d27e0b2..adf665f2a 100644 --- a/Essentials/src/com/earth2me/essentials/Warps.java +++ b/Essentials/src/com/earth2me/essentials/Warps.java @@ -2,6 +2,7 @@ package com.earth2me.essentials; import java.io.File; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -35,9 +36,9 @@ public class Warps implements IConf return warpPoints.isEmpty(); } - public Iterable getWarpNames() + public Collection getWarpNames() { - List keys = new ArrayList(); + final List keys = new ArrayList(); for (StringIgnoreCase stringIgnoreCase : warpPoints.keySet()) { keys.add(stringIgnoreCase.getString()); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java index 50a8ff0cf..722d5a2ec 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java @@ -5,10 +5,16 @@ import org.bukkit.Server; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; import com.earth2me.essentials.Warps; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; public class Commandwarp extends EssentialsCommand { + private final static int WARPS_PER_PAGE = 20; + public Commandwarp() { super("warp"); @@ -17,8 +23,7 @@ public class Commandwarp extends EssentialsCommand @Override public void run(Server server, User user, String commandLabel, String[] args) throws Exception { - - if (args.length == 0) + if (args.length == 0 || args[0].matches("[0-9]+")) { if (!user.isAuthorized("essentials.warp.list")) { @@ -31,24 +36,34 @@ public class Commandwarp extends EssentialsCommand { throw new Exception(Util.i18n("noWarpsDefined")); } - StringBuilder sb = new StringBuilder(); - int i = 0; - for (String warpName : warps.getWarpNames()) + final List warpNameList = new ArrayList(warps.getWarpNames()); + final Iterator iterator = warpNameList.iterator(); + while (iterator.hasNext()) { - if (ess.getSettings().getPerWarpPermission()) + final String warpName = iterator.next(); + if (ess.getSettings().getPerWarpPermission() && !user.isAuthorized("essentials.warp." + warpName)) { - if (user.isAuthorized("essentials.warp." + warpName)) - { - if (i++ > 0) sb.append(", "); - sb.append(warpName); - } + iterator.remove(); } - else + } + int page = 1; + if (args.length > 0) + { + page = Integer.parseInt(args[0]); + } + if (warpNameList.size() > WARPS_PER_PAGE) + { + user.sendMessage(Util.format("warpsCount", warpNameList.size(), page, (int)Math.ceil(warpNameList.size() / (double)WARPS_PER_PAGE))); + } + final int warpPage = (page - 1) * WARPS_PER_PAGE; + final StringBuilder sb = new StringBuilder(); + for (int i = 0; i < Math.min(warpNameList.size() - warpPage, WARPS_PER_PAGE); i++) + { + if (i > 0) { - if (i++ > 0) sb.append(", "); - sb.append(warpName); + sb.append(", "); } - + sb.append(warpNameList.get(i + warpPage)); } user.sendMessage(sb.toString()); return; @@ -59,7 +74,7 @@ public class Commandwarp extends EssentialsCommand if (args.length == 2 && user.isAuthorized("essentials.warp.otherplayers")) { otherUser = ess.getUser(server.getPlayer(args[1])); - if(otherUser == null) + if (otherUser == null) { user.sendMessage(Util.i18n("playerNotFound")); return; diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 964060099..3a9dd2d23 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -325,6 +325,7 @@ voiceSilenced = \u00a77Your voice has been silenced warpDeleteError = Problem deleting the warp file. warpListPermission = \u00a7cYou do not have Permission to list that warps. warpNotExist = That warp does not exist. +warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}. warpSet = \u00a77Warp {0} set. warpUsePermission = \u00a7cYou do not have Permission to use that warp. warpingTo = \u00a77Warping to {0}. diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index a94a04a33..870f24c5a 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -325,6 +325,7 @@ voiceSilenced = \u00a77Din stemme er blevet d\u00e6mpet warpDeleteError = Problem ved sletning af warp filen. warpListPermission = \u00a7cDu har ikke tilladelse til at liste de warps. warpNotExist = Den warp eksisterer ikke. +warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}. warpSet = \u00a77Warp {0} sat. warpUsePermission = \u00a7cDu har ikke tilladelse til at benytte den warp. warpingTo = \u00a77Warper til {0}. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index 1360bc3cc..31c9c3eb2 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -325,6 +325,7 @@ voiceSilenced = \u00a77Du bist stumm warpDeleteError = Fehler beim L\u00f6schen der Warp-Datei. warpListPermission = \u00a7cDu hast keine Berechtigung, die Warp-Punkte anzuzeigen. warpNotExist = Warp-Punkt existiert nicht. +warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}. warpSet = \u00a77Warp-Punkt {0} wurde erstellt. warpUsePermission = \u00a7cDu hast keinen Zugriff f\u00fcr diesen Warp-Punkt. warpingTo = \u00a77Teleportiere zu Warp-Punkt {0}. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 0673d41ed..057d06869 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -325,6 +325,7 @@ voiceSilenced = \u00a77Your voice has been silenced warpDeleteError = Problem deleting the warp file. warpListPermission = \u00a7cYou do not have Permission to list that warps. warpNotExist = That warp does not exist. +warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}. warpSet = \u00a77Warp {0} set. warpUsePermission = \u00a7cYou do not have Permission to use that warp. warpingTo = \u00a77Warping to {0}. diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index ea5af2d44..da166c8d9 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -325,6 +325,7 @@ voiceSilenced = \u00a77Votre voix a \u00e9t\u00e9 r\u00e9duite au silence warpDeleteError = Probl\u00e8me concernant la suppression du fichier warp. warpListPermission = \u00a7cVous n''avez pas la permission d''afficher la liste des warps. warpNotExist = Ce warp n''existe pas. +warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}. warpSet = \u00a77Le warp {0} a \u00e9t\u00e9 cr\u00e9\u00e9. warpUsePermission = \u00a7cVous n''avez pas la permission d''utiliser ce warp. warpingTo = \u00a77T\u00e9l\u00e9portation au warp {0}. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index 3dbb00a74..173698b1f 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -325,6 +325,7 @@ voiceSilenced = \u00a77Je kan niet meer praten warpDeleteError = Fout bij het verwijderen van het warp bestand. warpListPermission = \u00a7cJe hebt geen toegang om die warp te maken. warpNotExist = Die warp bestaat niet. +warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}. warpSet = \u00a77Warp {0} ingesteld. warpUsePermission = \u00a7cOnbevoegd om die warp te gebruiken. warpingTo = \u00a77Aan het warpen naar {0}. diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index 1acef22e8..2406c337d 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -348,7 +348,7 @@ commands: aliases: [eunlimited,ul,unl,eul,eunl] warp: description: List all warps or warp to the specified location. - usage: / + usage: / [pagenumber|warp] aliases: [ewarp,warps] weather: description: Setting the weather. -- cgit v1.2.3 From d818f705adc30b5f515e49f88e23e870322f3eb3 Mon Sep 17 00:00:00 2001 From: snowleo Date: Sun, 21 Aug 2011 21:30:01 +0200 Subject: Cleanup --- Essentials/src/com/earth2me/essentials/commands/Commandwarp.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java index 722d5a2ec..17d55faee 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java @@ -7,7 +7,6 @@ import com.earth2me.essentials.Util; import com.earth2me.essentials.Warps; import java.util.ArrayList; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; -- cgit v1.2.3