Skip to content

Commit a7432dc

Browse files
Check for Optional#ifPresent()
1 parent f7e5e5c commit a7432dc

File tree

1 file changed

+12
-9
lines changed
  • src/main/java/world/bentobox/bentobox/api/flags/clicklisteners

1 file changed

+12
-9
lines changed

src/main/java/world/bentobox/bentobox/api/flags/clicklisteners/CycleClick.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public CycleClick(String id, int minRank, int maxRank) {
6262
public boolean onClick(Panel panel, User user2, ClickType click, int slot) {
6363
if (panel.getWorld().isEmpty()) {
6464
plugin.logError("Panel " + panel.getName()
65-
+ " has no world associated with it. Please report this bug to the author.");
65+
+ " has no world associated with it. Please report this bug to the author.");
6666
return true;
6767
}
6868
// This click listener is used with TabbedPanel and SettingsTabs only
@@ -73,14 +73,17 @@ public boolean onClick(Panel panel, User user2, ClickType click, int slot) {
7373
this.user = user2;
7474
changeOccurred = false;
7575
// Permission prefix
76-
String prefix = plugin.getIWM().getPermissionPrefix(Util.getWorld(panel.getWorld().get()));
77-
String reqPerm = prefix + "settings." + id;
78-
String allPerms = prefix + "settings.*";
79-
if (!user.hasPermission(reqPerm) && !user.hasPermission(allPerms)
80-
&& !user.isOp() && !user.hasPermission(prefix + "admin.settings")) {
81-
user.sendMessage("general.errors.no-permission", TextVariables.PERMISSION, reqPerm);
82-
user.getPlayer().playSound(user.getLocation(), Sound.BLOCK_METAL_HIT, 1F, 1F);
83-
return true;
76+
String prefix = "";
77+
if (panel.getWorld().isPresent()) {
78+
prefix = plugin.getIWM().getPermissionPrefix(Util.getWorld(panel.getWorld().get()));
79+
String reqPerm = prefix + "settings." + id;
80+
String allPerms = prefix + "settings.*";
81+
if (!user.hasPermission(reqPerm) && !user.hasPermission(allPerms)
82+
&& !user.isOp() && !user.hasPermission(prefix + "admin.settings")) {
83+
user.sendMessage("general.errors.no-permission", TextVariables.PERMISSION, reqPerm);
84+
user.getPlayer().playSound(user.getLocation(), Sound.BLOCK_METAL_HIT, 1F, 1F);
85+
return true;
86+
}
8487
}
8588
// Left-clicking increases the rank required
8689
// Right-clicking decreases the rank required

0 commit comments

Comments
 (0)