diff options
author | snowleo <schneeleo@gmail.com> | 2011-08-21 21:44:58 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-08-21 21:44:58 +0200 |
commit | 256c9633706e7a8d087e21926871437320895057 (patch) | |
tree | b9daece60f7f7576d39348365b78877d77137287 | |
parent | 7b8c2a4575a49186ee5002e3a6723bf97cab879f (diff) | |
parent | d818f705adc30b5f515e49f88e23e870322f3eb3 (diff) | |
download | Essentials-stable-2.5.7.tar Essentials-stable-2.5.7.tar.gz Essentials-stable-2.5.7.tar.lz Essentials-stable-2.5.7.tar.xz Essentials-stable-2.5.7.zip |
Merge branch 'master' into releasestable-2.5.7
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Warps.java | 5 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandwarp.java | 46 | ||||
-rw-r--r-- | Essentials/src/messages.properties | 1 | ||||
-rw-r--r-- | Essentials/src/messages_da.properties | 1 | ||||
-rw-r--r-- | Essentials/src/messages_de.properties | 1 | ||||
-rw-r--r-- | Essentials/src/messages_en.properties | 1 | ||||
-rw-r--r-- | Essentials/src/messages_fr.properties | 1 | ||||
-rw-r--r-- | Essentials/src/messages_nl.properties | 1 | ||||
-rw-r--r-- | Essentials/src/plugin.yml | 2 | ||||
-rw-r--r-- | EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java | 8 |
10 files changed, 48 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<String> getWarpNames() + public Collection<String> getWarpNames() { - List<String> keys = new ArrayList<String>(); + final List<String> keys = new ArrayList<String>(); 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..17d55faee 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java @@ -5,10 +5,15 @@ 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.List; public class Commandwarp extends EssentialsCommand { + private final static int WARPS_PER_PAGE = 20; + public Commandwarp() { super("warp"); @@ -17,8 +22,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 +35,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<String> warpNameList = new ArrayList<String>(warps.getWarpNames()); + final Iterator<String> 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 +73,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: /<command> <warp> <player> + usage: /<command> [pagenumber|warp] <player> aliases: [ewarp,warps] weather: description: Setting the weather. 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() |