diff options
author | KHobbits <rob@khobbits.co.uk> | 2011-08-22 18:45:46 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2011-08-22 18:45:46 +0100 |
commit | 1138e322926d3ae6cb6afdd47ce6de75f5b0099e (patch) | |
tree | 19bdf978b504d547ab142667df76f8ab5578df29 | |
parent | c0d21b6044724de6f22f8924fa129a640e505faf (diff) | |
parent | d818f705adc30b5f515e49f88e23e870322f3eb3 (diff) | |
download | Essentials-1138e322926d3ae6cb6afdd47ce6de75f5b0099e.tar Essentials-1138e322926d3ae6cb6afdd47ce6de75f5b0099e.tar.gz Essentials-1138e322926d3ae6cb6afdd47ce6de75f5b0099e.tar.lz Essentials-1138e322926d3ae6cb6afdd47ce6de75f5b0099e.tar.xz Essentials-1138e322926d3ae6cb6afdd47ce6de75f5b0099e.zip |
Merge branch 'master' of github.com:essentials/Essentials
-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 29ea5f50e..93bea8f26 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -330,6 +330,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 c73371f89..eb34951ea 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -330,6 +330,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 58cf40708..cd6888c26 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -330,6 +330,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 c226901fb..a2a7bf32b 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -330,6 +330,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 51cc63509..de388e2ad 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -330,6 +330,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 7e5b6e31f..c9d3d7f4b 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -330,6 +330,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 d8a772a3a..5d180763f 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() |