Skip to content

Commit

Permalink
Fixed a bug where #setButton(Integer, GUIButton) would cause a NullPo…
Browse files Browse the repository at this point in the history
…interException
  • Loading branch information
Sam Jakob Mearns committed Dec 18, 2017
1 parent a4b7f8b commit a9f0acb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions com/cloutteam/samjakob/gui/types/PaginatedGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import com.cloutteam.samjakob.gui.ItemBuilder;
import com.cloutteam.samjakob.gui.buttons.GUIButton;
import com.cloutteam.samjakob.gui.buttons.InventoryListenerGUI;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -68,10 +69,14 @@ public Inventory getInventory() {

// Add all items
int counter = 0;
for(int key = (currentPage * 45); key < items.keySet().size(); key++){
for(int key = (currentPage * 45); key <= Collections.max(items.keySet()); key++){
if(counter >= 45)
break;
inventory.setItem(counter, items.get(key).getItem());

if(items.containsKey(key)) {
inventory.setItem(counter, items.get(key).getItem());
}

counter++;
}

Expand Down

0 comments on commit a9f0acb

Please sign in to comment.