Require panel to have a world.

This commit is contained in:
tastybento 2024-01-13 08:01:49 -08:00
parent 4bfbe41956
commit cc7b1eba4c
2 changed files with 2 additions and 1 deletions

View File

@ -33,7 +33,7 @@ public class WorldToggleClick implements ClickHandler {
@Override
public boolean onClick(Panel panel, User user, ClickType click, int slot) {
World world = panel.getWorld().orElse(null);
World world = panel.getWorld().orElseThrow(); // The panel must have a world
String reqPerm = plugin.getIWM().getPermissionPrefix(world) + "admin.world.settings." + id;
if (!user.hasPermission(reqPerm)) {
user.sendMessage("general.errors.no-permission", TextVariables.PERMISSION, reqPerm);

View File

@ -77,6 +77,7 @@ public class WorldToggleClickTest {
// Panel
when(panel.getInventory()).thenReturn(mock(Inventory.class));
when(panel.getWorld()).thenReturn(Optional.of(world));
// User
// Sometimes use Mockito.withSettings().verboseLogging()