mirror of
https://github.com/BentoBoxWorld/Limits.git
synced 2024-09-27 14:12:57 +02:00
Fix NPEs
This commit is contained in:
parent
14c38869df
commit
3f1465d6ef
@ -171,8 +171,7 @@ public class Limits extends Addon {
|
||||
if (is == null) {
|
||||
return 0;
|
||||
}
|
||||
return getBlockLimitListener().getIsland(gm.getIslands().getIsland(gm.getOverWorld(), user).getUniqueId()).
|
||||
getBlockCount(m);
|
||||
return getBlockLimitListener().getIsland(gm.getIslands().getIsland(gm.getOverWorld(), user).getUniqueId()).getBlockCount(m);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,9 +104,13 @@ public class LimitTab implements Tab {
|
||||
Map<EntityGroup, Integer> groupmap = addon.getSettings().getGroupLimitDefinitions().stream().collect(Collectors.toMap(e -> e, e -> e.getLimit()));
|
||||
Map<String, EntityGroup> groupbyname = groupmap.keySet().stream().collect(Collectors.toMap(e -> e.getName(), e -> e));
|
||||
// Merge in any permission-based limits
|
||||
if (ibc != null) ibc.getEntityGroupLimits().entrySet().stream()
|
||||
if (ibc == null) {
|
||||
return;
|
||||
}
|
||||
ibc.getEntityGroupLimits().entrySet().stream()
|
||||
.filter(e -> groupbyname.containsKey(e.getKey()))
|
||||
.forEach(e -> groupmap.put(groupbyname.get(e.getKey()), e.getValue()));
|
||||
|
||||
ibc.getEntityGroupLimitsOffset().entrySet().forEach(o ->
|
||||
groupmap.put(groupbyname.get(o.getKey()), (groupmap.getOrDefault(o.getKey(), 0) + o.getValue())));
|
||||
groupmap.forEach((v, limit) -> {
|
||||
@ -186,7 +190,7 @@ public class LimitTab implements Tab {
|
||||
pib.icon(B2M.getOrDefault(en.getKey(), en.getKey()));
|
||||
|
||||
int count = ibc == null ? 0 : ibc.getBlockCounts().getOrDefault(en.getKey(), 0);
|
||||
int value = en.getValue() + ibc.getBlockLimitsOffset().getOrDefault(en.getKey(), 0);
|
||||
int value = en.getValue() + (ibc == null ? 0 : ibc.getBlockLimitsOffset().getOrDefault(en.getKey(), 0));
|
||||
String color = count >= value ? user.getTranslation("island.limits.max-color") : user.getTranslation("island.limits.regular-color");
|
||||
pib.description(color
|
||||
+ user.getTranslation("island.limits.block-limit-syntax",
|
||||
|
@ -20,6 +20,7 @@ import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
||||
import world.bentobox.bentobox.api.events.island.IslandEvent.Reason;
|
||||
import world.bentobox.bentobox.api.events.team.TeamSetownerEvent;
|
||||
@ -52,6 +53,7 @@ public class JoinListener implements Listener {
|
||||
*/
|
||||
public void checkPerms(Player player, String permissionPrefix, String islandId, String gameMode) {
|
||||
IslandBlockCount ibc = addon.getBlockLimitListener().getIsland(islandId);
|
||||
BentoBox.getInstance().logDebug("Check perms ibc == null? " + ibc == null);
|
||||
// Check permissions
|
||||
if (ibc != null) {
|
||||
// Clear permission limits
|
||||
@ -79,6 +81,8 @@ public class JoinListener implements Listener {
|
||||
}
|
||||
// Make an ibc if required
|
||||
if (ibc == null) {
|
||||
|
||||
BentoBox.getInstance().logDebug("Making new IBC");
|
||||
ibc = new IslandBlockCount(islandId, gameMode);
|
||||
}
|
||||
// Get the value
|
||||
@ -93,7 +97,9 @@ public class JoinListener implements Listener {
|
||||
runNullCheckAndSet(ibc, l);
|
||||
}
|
||||
// Check removed permissions
|
||||
|
||||
if (ibc == null) {
|
||||
BentoBox.getInstance().logDebug("IBC is still null");
|
||||
}
|
||||
// If any changes have been made then store it - don't make files unless they are needed
|
||||
if (ibc != null) addon.getBlockLimitListener().setIsland(islandId, ibc);
|
||||
}
|
||||
@ -163,6 +169,7 @@ public class JoinListener implements Listener {
|
||||
&& !e.getReason().equals(Reason.REGISTERED)) {
|
||||
return;
|
||||
}
|
||||
BentoBox.getInstance().logDebug("Island Event " + e.getReason());
|
||||
setOwnerPerms(e.getIsland(), e.getOwner());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user