From c49e2b07d3321c38c42bb823d417d1bb479d3013 Mon Sep 17 00:00:00 2001 From: Tastybento Date: Mon, 2 Apr 2018 18:20:54 -0700 Subject: [PATCH] Fixed issues with panels not scaling in size correctly. --- plugin.yml | 5 ++++- .../java/us/tastybento/bskyblock/BSkyBlock.java | 3 ++- .../bskyblock/api/commands/CompositeCommand.java | 1 + .../api/panels/builders/PanelBuilder.java | 15 ++++++--------- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/plugin.yml b/plugin.yml index 21ca8796f..ca4ba2196 100755 --- a/plugin.yml +++ b/plugin.yml @@ -15,8 +15,11 @@ permissions: children: bskyblock.island.*: children: + bskyblock.island: + description: Allow island command usage + default: true bskyblock.island.create: - description: Allow island command usage + description: Allow island creation default: true bskyblock.island.home: description: Allow teleporting to player island diff --git a/src/main/java/us/tastybento/bskyblock/BSkyBlock.java b/src/main/java/us/tastybento/bskyblock/BSkyBlock.java index 46c79f435..685f5904f 100755 --- a/src/main/java/us/tastybento/bskyblock/BSkyBlock.java +++ b/src/main/java/us/tastybento/bskyblock/BSkyBlock.java @@ -65,7 +65,8 @@ public class BSkyBlock extends JavaPlugin { //settings.saveSettings(); settings = settings.loadSettings(); } catch (Exception e) { - getLogger().severe("Settings could not be loaded" + e.getMessage()); + getLogger().severe("Settings could not be loaded " + e.getMessage()); + e.printStackTrace(); } // Save a backup of settings to the database so it can be checked next time diff --git a/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java b/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java index 668564b58..af1d3dd21 100644 --- a/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java +++ b/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java @@ -154,6 +154,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi // Check perms, but only if this isn't the console if ((sender instanceof Player) && !sender.isOp() && !cmd.getPermission().isEmpty() && !sender.hasPermission(cmd.getPermission())) { user.sendMessage("general.errors.no-permission"); + user.sendRawMessage("You need " + cmd.getPermission()); return true; } // Fire an event to see if this command should be cancelled diff --git a/src/main/java/us/tastybento/bskyblock/api/panels/builders/PanelBuilder.java b/src/main/java/us/tastybento/bskyblock/api/panels/builders/PanelBuilder.java index 1a058dd17..dd6b800d5 100644 --- a/src/main/java/us/tastybento/bskyblock/api/panels/builders/PanelBuilder.java +++ b/src/main/java/us/tastybento/bskyblock/api/panels/builders/PanelBuilder.java @@ -69,15 +69,12 @@ public class PanelBuilder { return this; } + /** + * Get the next free slot number + * @return next slot number + */ public int nextSlot() { - if (items.isEmpty()) { - return 0; - } else { - for (int i = 0; i < (size != 0 ? size : 54); i++) { - if (!slotOccupied(i)) return i; - } - } - return 0; + return items.isEmpty() ? 0 : items.lastKey() + 1; } /** @@ -94,6 +91,6 @@ public class PanelBuilder { * @return Panel */ public Panel build() { - return new Panel(name, items, size, user, listener); + return new Panel(name, items, Math.max(size, items.lastKey()), user, listener); } }