Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hostadam committed Jan 3, 2025
1 parent 42bfd96 commit 2722ef8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
30 changes: 17 additions & 13 deletions src/main/java/com/github/hostadam/menu/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ public abstract class Menu {

private int page = 1, maxPages = 1;

public Menu(JavaPlugin plugin, MenuTemplate template) {
public Menu(JavaPlugin plugin, Player player, MenuTemplate template) {
this.plugin = plugin;
this.player = player;
this.menuTemplate = template;
this.size = template.getInventoryRows() * 9;
this.inventory = Bukkit.createInventory(null, this.size, template.getInventoryTitle());
Expand Down Expand Up @@ -168,18 +169,21 @@ public boolean click(InventoryClickEvent event) {
MenuItem button = this.buttons.get(event.getRawSlot());
if(button != null) {
event.setCancelled(true);
if(button.getClickEvent() != null) button.getClickEvent().accept(event);
if(button.isPaginated()) {
switch(button.getType()) {
case NEXT_PAGE:
this.nextPage();
break;
case PREVIOUS_PAGE:
this.previousPage();
break;
case BACK_TO_MAIN_PAGE:
this.mainPage();
break;

if(button.getPermission().isEmpty() || this.player.hasPermission(button.getPermission())) {
if(button.getClickEvent() != null) button.getClickEvent().accept(event);
if(button.isPaginated()) {
switch(button.getType()) {
case NEXT_PAGE:
this.nextPage();
break;
case PREVIOUS_PAGE:
this.previousPage();
break;
case BACK_TO_MAIN_PAGE:
this.mainPage();
break;
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/github/hostadam/utils/ItemBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ public ItemStack build() {
}

public static ItemBuilder fromConfig(ConfigurationSection section) {
if(section == null) return null;
Material material = Material.getMaterial(section.getString("material").toUpperCase());
int amount = section.getInt("amount", 1);
ItemBuilder builder = new ItemBuilder(material)
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/com/github/hostadam/utils/TimeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ public static String format(long duration) {
return "Permanent";
}

if(duration == -2) {
return "Seasonal";
}

int sec = (int) (duration / 1000) % 60 ;
int min = (int) ((duration / (1000*60)) % 60);
int hour = (int) ((duration / (1000*60*60)) % 24);
Expand Down

0 comments on commit 2722ef8

Please sign in to comment.