Merge branch 'master' of github.com:khobbits/Essentials

This commit is contained in:
okamosy 2011-08-22 22:55:55 +01:00
commit dfdf49ac35
10 changed files with 48 additions and 19 deletions

View File

@ -2,6 +2,7 @@ package com.earth2me.essentials;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -35,9 +36,9 @@ public class Warps implements IConf
return warpPoints.isEmpty(); 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()) for (StringIgnoreCase stringIgnoreCase : warpPoints.keySet())
{ {
keys.add(stringIgnoreCase.getString()); keys.add(stringIgnoreCase.getString());

View File

@ -5,10 +5,15 @@ import org.bukkit.Server;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.Util; import com.earth2me.essentials.Util;
import com.earth2me.essentials.Warps; import com.earth2me.essentials.Warps;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class Commandwarp extends EssentialsCommand public class Commandwarp extends EssentialsCommand
{ {
private final static int WARPS_PER_PAGE = 20;
public Commandwarp() public Commandwarp()
{ {
super("warp"); super("warp");
@ -17,8 +22,7 @@ public class Commandwarp extends EssentialsCommand
@Override @Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{ {
if (args.length == 0 || args[0].matches("[0-9]+"))
if (args.length == 0)
{ {
if (!user.isAuthorized("essentials.warp.list")) if (!user.isAuthorized("essentials.warp.list"))
{ {
@ -31,24 +35,34 @@ public class Commandwarp extends EssentialsCommand
{ {
throw new Exception(Util.i18n("noWarpsDefined")); throw new Exception(Util.i18n("noWarpsDefined"));
} }
StringBuilder sb = new StringBuilder(); final List<String> warpNameList = new ArrayList<String>(warps.getWarpNames());
int i = 0; final Iterator<String> iterator = warpNameList.iterator();
for (String warpName : warps.getWarpNames()) 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)) iterator.remove();
{
if (i++ > 0) sb.append(", ");
sb.append(warpName);
}
} }
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(", ");
sb.append(warpName);
} }
sb.append(warpNameList.get(i + warpPage));
} }
user.sendMessage(sb.toString()); user.sendMessage(sb.toString());
return; return;
@ -59,7 +73,7 @@ public class Commandwarp extends EssentialsCommand
if (args.length == 2 && user.isAuthorized("essentials.warp.otherplayers")) if (args.length == 2 && user.isAuthorized("essentials.warp.otherplayers"))
{ {
otherUser = ess.getUser(server.getPlayer(args[1])); otherUser = ess.getUser(server.getPlayer(args[1]));
if(otherUser == null) if (otherUser == null)
{ {
user.sendMessage(Util.i18n("playerNotFound")); user.sendMessage(Util.i18n("playerNotFound"));
return; return;

View File

@ -330,6 +330,7 @@ voiceSilenced = \u00a77Your voice has been silenced
warpDeleteError = Problem deleting the warp file. warpDeleteError = Problem deleting the warp file.
warpListPermission = \u00a7cYou do not have Permission to list that warps. warpListPermission = \u00a7cYou do not have Permission to list that warps.
warpNotExist = That warp does not exist. warpNotExist = That warp does not exist.
warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}.
warpSet = \u00a77Warp {0} set. warpSet = \u00a77Warp {0} set.
warpUsePermission = \u00a7cYou do not have Permission to use that warp. warpUsePermission = \u00a7cYou do not have Permission to use that warp.
warpingTo = \u00a77Warping to {0}. warpingTo = \u00a77Warping to {0}.

View File

@ -330,6 +330,7 @@ voiceSilenced = \u00a77Din stemme er blevet d\u00e6mpet
warpDeleteError = Problem ved sletning af warp filen. warpDeleteError = Problem ved sletning af warp filen.
warpListPermission = \u00a7cDu har ikke tilladelse til at liste de warps. warpListPermission = \u00a7cDu har ikke tilladelse til at liste de warps.
warpNotExist = Den warp eksisterer ikke. warpNotExist = Den warp eksisterer ikke.
warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}.
warpSet = \u00a77Warp {0} sat. warpSet = \u00a77Warp {0} sat.
warpUsePermission = \u00a7cDu har ikke tilladelse til at benytte den warp. warpUsePermission = \u00a7cDu har ikke tilladelse til at benytte den warp.
warpingTo = \u00a77Warper til {0}. warpingTo = \u00a77Warper til {0}.

View File

@ -330,6 +330,7 @@ voiceSilenced = \u00a77Du bist stumm
warpDeleteError = Fehler beim L\u00f6schen der Warp-Datei. warpDeleteError = Fehler beim L\u00f6schen der Warp-Datei.
warpListPermission = \u00a7cDu hast keine Berechtigung, die Warp-Punkte anzuzeigen. warpListPermission = \u00a7cDu hast keine Berechtigung, die Warp-Punkte anzuzeigen.
warpNotExist = Warp-Punkt existiert nicht. warpNotExist = Warp-Punkt existiert nicht.
warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}.
warpSet = \u00a77Warp-Punkt {0} wurde erstellt. warpSet = \u00a77Warp-Punkt {0} wurde erstellt.
warpUsePermission = \u00a7cDu hast keinen Zugriff f\u00fcr diesen Warp-Punkt. warpUsePermission = \u00a7cDu hast keinen Zugriff f\u00fcr diesen Warp-Punkt.
warpingTo = \u00a77Teleportiere zu Warp-Punkt {0}. warpingTo = \u00a77Teleportiere zu Warp-Punkt {0}.

View File

@ -330,6 +330,7 @@ voiceSilenced = \u00a77Your voice has been silenced
warpDeleteError = Problem deleting the warp file. warpDeleteError = Problem deleting the warp file.
warpListPermission = \u00a7cYou do not have Permission to list that warps. warpListPermission = \u00a7cYou do not have Permission to list that warps.
warpNotExist = That warp does not exist. warpNotExist = That warp does not exist.
warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}.
warpSet = \u00a77Warp {0} set. warpSet = \u00a77Warp {0} set.
warpUsePermission = \u00a7cYou do not have Permission to use that warp. warpUsePermission = \u00a7cYou do not have Permission to use that warp.
warpingTo = \u00a77Warping to {0}. warpingTo = \u00a77Warping to {0}.

View File

@ -330,6 +330,7 @@ voiceSilenced = \u00a77Votre voix a \u00e9t\u00e9 r\u00e9duite au silence
warpDeleteError = Probl\u00e8me concernant la suppression du fichier warp. warpDeleteError = Probl\u00e8me concernant la suppression du fichier warp.
warpListPermission = \u00a7cVous n''avez pas la permission d''afficher la liste des warps. warpListPermission = \u00a7cVous n''avez pas la permission d''afficher la liste des warps.
warpNotExist = Ce warp n''existe pas. 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. warpSet = \u00a77Le warp {0} a \u00e9t\u00e9 cr\u00e9\u00e9.
warpUsePermission = \u00a7cVous n''avez pas la permission d''utiliser ce warp. warpUsePermission = \u00a7cVous n''avez pas la permission d''utiliser ce warp.
warpingTo = \u00a77T\u00e9l\u00e9portation au warp {0}. warpingTo = \u00a77T\u00e9l\u00e9portation au warp {0}.

View File

@ -330,6 +330,7 @@ voiceSilenced = \u00a77Je kan niet meer praten
warpDeleteError = Fout bij het verwijderen van het warp bestand. warpDeleteError = Fout bij het verwijderen van het warp bestand.
warpListPermission = \u00a7cJe hebt geen toegang om die warp te maken. warpListPermission = \u00a7cJe hebt geen toegang om die warp te maken.
warpNotExist = Die warp bestaat niet. warpNotExist = Die warp bestaat niet.
warpsCount = \u00a77There are {0} warps. Showing page {1} of {2}.
warpSet = \u00a77Warp {0} ingesteld. warpSet = \u00a77Warp {0} ingesteld.
warpUsePermission = \u00a7cOnbevoegd om die warp te gebruiken. warpUsePermission = \u00a7cOnbevoegd om die warp te gebruiken.
warpingTo = \u00a77Aan het warpen naar {0}. warpingTo = \u00a77Aan het warpen naar {0}.

View File

@ -348,7 +348,7 @@ commands:
aliases: [eunlimited,ul,unl,eul,eunl] aliases: [eunlimited,ul,unl,eul,eunl]
warp: warp:
description: List all warps or warp to the specified location. description: List all warps or warp to the specified location.
usage: /<command> <warp> <player> usage: /<command> [pagenumber|warp] <player>
aliases: [ewarp,warps] aliases: [ewarp,warps]
weather: weather:
description: Setting the weather. description: Setting the weather.

View File

@ -190,6 +190,14 @@ public class EssentialsProtect extends JavaPlugin implements IConf, IProtect
{ {
storage.onPluginDeactivation(); storage.onPluginDeactivation();
} }
// Sleep for a second to allow the database to close.
try
{
Thread.sleep(1000);
}
catch (InterruptedException ex)
{
}
} }
public IEssentials getEssentials() public IEssentials getEssentials()