mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-22 16:37:25 +00:00
Merge pull request #2914 from montlikadani/patch-5
Fix NPE when the user is null in the hidden players
This commit is contained in:
commit
b2c3b3a99f
2 changed files with 6 additions and 7 deletions
|
@ -40,7 +40,7 @@ public class PlayerList {
|
|||
for (User onlinePlayer : ess.getOnlineUsers()) {
|
||||
if (onlinePlayer.isHidden() || (user != null && !user.getBase().canSee(onlinePlayer.getBase()))) {
|
||||
playerHidden++;
|
||||
if (showHidden || user.getBase().canSee(onlinePlayer.getBase())) {
|
||||
if (showHidden || user != null && user.getBase().canSee(onlinePlayer.getBase())) {
|
||||
hiddenCount++;
|
||||
}
|
||||
}
|
||||
|
@ -56,8 +56,7 @@ public class PlayerList {
|
|||
|
||||
// Build the basic player list, divided by groups.
|
||||
public static Map<String, List<User>> getPlayerLists(final IEssentials ess, final User sender, final boolean showHidden) {
|
||||
Server server = ess.getServer();
|
||||
final Map<String, List<User>> playerList = new HashMap<String, List<User>>();
|
||||
final Map<String, List<User>> playerList = new HashMap<>();
|
||||
for (User onlineUser : ess.getOnlineUsers()) {
|
||||
if ((sender == null && !showHidden && onlineUser.isHidden()) || (sender != null && !showHidden && !sender.getBase().canSee(onlineUser.getBase()))) {
|
||||
continue;
|
||||
|
@ -76,7 +75,7 @@ public class PlayerList {
|
|||
// Handle the merging of groups
|
||||
public static List<User> getMergedList(final IEssentials ess, final Map<String, List<User>> playerList, final String groupName) {
|
||||
final Set<String> configGroups = ess.getSettings().getListGroupConfig().keySet();
|
||||
final List<User> users = new ArrayList<User>();
|
||||
final List<User> users = new ArrayList<>();
|
||||
for (String configGroup : configGroups) {
|
||||
if (configGroup.equalsIgnoreCase(groupName)) {
|
||||
String[] groupValues = ess.getSettings().getListGroupConfig().get(configGroup).toString().trim().split(" ");
|
||||
|
|
|
@ -24,10 +24,9 @@ public class Commandlightning extends EssentialsLoopCommand {
|
|||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
User user;
|
||||
if (sender.isPlayer()) {
|
||||
user = ess.getUser(sender.getPlayer());
|
||||
if ((args.length < 1 || user != null && !user.isAuthorized("essentials.lightning.others"))) {
|
||||
User user = ess.getUser(sender.getPlayer());
|
||||
if ((args.length < 1 || !user.isAuthorized("essentials.lightning.others"))) {
|
||||
user.getWorld().strikeLightning(user.getBase().getTargetBlock((Set<Material>) null, 600).getLocation());
|
||||
return;
|
||||
}
|
||||
|
@ -64,6 +63,7 @@ public class Commandlightning extends EssentialsLoopCommand {
|
|||
return super.getTabCompleteOptions(server, user, commandLabel, args);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
|
|
Loading…
Reference in a new issue