mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-01 14:07:46 +01:00
Null checks
This commit is contained in:
parent
11f02fb947
commit
85ef892f0e
@ -129,12 +129,12 @@ public class ManagedFile
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
String hash = reader.readLine();
|
String hash = reader.readLine();
|
||||||
if (hash.matches("#[a-f0-9]{32}"))
|
if (hash != null && hash.matches("#[a-f0-9]{32}"))
|
||||||
{
|
{
|
||||||
hash = hash.substring(1);
|
hash = hash.substring(1);
|
||||||
bais.reset();
|
bais.reset();
|
||||||
final String versionline = reader.readLine();
|
final String versionline = reader.readLine();
|
||||||
if (versionline.matches("#version: .+"))
|
if (versionline != null && versionline.matches("#version: .+"))
|
||||||
{
|
{
|
||||||
final String versioncheck = versionline.substring(10);
|
final String versioncheck = versionline.substring(10);
|
||||||
if (!versioncheck.equalsIgnoreCase(version))
|
if (!versioncheck.equalsIgnoreCase(version))
|
||||||
|
@ -101,6 +101,9 @@ public class Commandhelp extends EssentialsCommand
|
|||||||
while (bufferedReader.ready())
|
while (bufferedReader.ready())
|
||||||
{
|
{
|
||||||
final String line = bufferedReader.readLine();
|
final String line = bufferedReader.readLine();
|
||||||
|
if (line == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
retval.add(line.replace('&', '§'));
|
retval.add(line.replace('&', '§'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ public class Commandwarp extends EssentialsCommand
|
|||||||
{
|
{
|
||||||
if (args.length < 2 || args[0].matches("[0-9]+"))
|
if (args.length < 2 || args[0].matches("[0-9]+"))
|
||||||
{
|
{
|
||||||
warpList(null, args);
|
warpList(sender, args);
|
||||||
throw new NoChargeException();
|
throw new NoChargeException();
|
||||||
}
|
}
|
||||||
User otherUser = ess.getUser(server.getPlayer(args[1]));
|
User otherUser = ess.getUser(server.getPlayer(args[1]));
|
||||||
@ -68,7 +68,7 @@ public class Commandwarp extends EssentialsCommand
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void warpList(User user, String[] args) throws Exception
|
private void warpList(CommandSender sender, String[] args) throws Exception
|
||||||
{
|
{
|
||||||
Warps warps = ess.getWarps();
|
Warps warps = ess.getWarps();
|
||||||
if (warps.isEmpty())
|
if (warps.isEmpty())
|
||||||
@ -77,13 +77,13 @@ public class Commandwarp extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
final List<String> warpNameList = new ArrayList<String>(warps.getWarpNames());
|
final List<String> warpNameList = new ArrayList<String>(warps.getWarpNames());
|
||||||
|
|
||||||
if (user != null)
|
if (sender instanceof User)
|
||||||
{
|
{
|
||||||
final Iterator<String> iterator = warpNameList.iterator();
|
final Iterator<String> iterator = warpNameList.iterator();
|
||||||
while (iterator.hasNext())
|
while (iterator.hasNext())
|
||||||
{
|
{
|
||||||
final String warpName = iterator.next();
|
final String warpName = iterator.next();
|
||||||
if (ess.getSettings().getPerWarpPermission() && !user.isAuthorized("essentials.warp." + warpName))
|
if (ess.getSettings().getPerWarpPermission() && !((User)sender).isAuthorized("essentials.warp." + warpName))
|
||||||
{
|
{
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
@ -100,11 +100,11 @@ public class Commandwarp extends EssentialsCommand
|
|||||||
|
|
||||||
if (warpNameList.size() > WARPS_PER_PAGE)
|
if (warpNameList.size() > WARPS_PER_PAGE)
|
||||||
{
|
{
|
||||||
user.sendMessage(Util.format("warpsCount", warpNameList.size(), page, (int)Math.ceil(warpNameList.size() / (double)WARPS_PER_PAGE)));
|
sender.sendMessage(Util.format("warpsCount", warpNameList.size(), page, (int)Math.ceil(warpNameList.size() / (double)WARPS_PER_PAGE)));
|
||||||
user.sendMessage(warpList);
|
sender.sendMessage(warpList);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
user.sendMessage(Util.format("warps", warpList));
|
sender.sendMessage(Util.format("warps", warpList));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user