mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-09-02 18:20:11 +02:00
Fix /is level
showing gaps
This commit is contained in:
parent
c60f6d9c8a
commit
fac0997c97
|
@ -1,6 +1,7 @@
|
||||||
package me.goodandevil.skyblock.menus;
|
package me.goodandevil.skyblock.menus;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.lang3.text.WordUtils;
|
import org.apache.commons.lang3.text.WordUtils;
|
||||||
|
@ -10,6 +11,7 @@ import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
@ -33,8 +35,6 @@ import me.goodandevil.skyblock.utils.NumberUtil;
|
||||||
import me.goodandevil.skyblock.utils.item.MaterialUtil;
|
import me.goodandevil.skyblock.utils.item.MaterialUtil;
|
||||||
import me.goodandevil.skyblock.utils.item.SkullUtil;
|
import me.goodandevil.skyblock.utils.item.SkullUtil;
|
||||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil;
|
import me.goodandevil.skyblock.utils.item.nInventoryUtil;
|
||||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEvent;
|
|
||||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEventHandler;
|
|
||||||
import me.goodandevil.skyblock.utils.version.Materials;
|
import me.goodandevil.skyblock.utils.version.Materials;
|
||||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||||
|
|
||||||
|
@ -192,7 +192,31 @@ public class Levelling {
|
||||||
Island island = islandManager.getIsland(player);
|
Island island = islandManager.getIsland(player);
|
||||||
IslandLevel level = island.getLevel();
|
IslandLevel level = island.getLevel();
|
||||||
|
|
||||||
Map<String, Integer> islandMaterials = level.getMaterials();
|
Map<String, Integer> testIslandMaterials = level.getMaterials();
|
||||||
|
Map<String, Integer> islandMaterials = new HashMap<>();
|
||||||
|
|
||||||
|
Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "levelling.yml"));
|
||||||
|
|
||||||
|
// Filter out ItemStacks that can't be displayed in the inventory
|
||||||
|
Inventory testInventory = Bukkit.createInventory(null, 9);
|
||||||
|
for (String materialName : testIslandMaterials.keySet()) {
|
||||||
|
if (mainConfig.getFileConfiguration().getString("Materials." + materialName + ".Points") == null)
|
||||||
|
continue;
|
||||||
|
if (mainConfig.getFileConfiguration().getInt("Materials." + materialName + ".Points") <= 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Materials materials = Materials.fromString(materialName);
|
||||||
|
ItemStack is = materials.parseItem();
|
||||||
|
is.setAmount(testIslandMaterials.get(materialName));
|
||||||
|
is.setType(MaterialUtil.correctMaterial(is.getType()));
|
||||||
|
|
||||||
|
if (is == null || is.getItemMeta() == null) continue;
|
||||||
|
testInventory.clear();
|
||||||
|
testInventory.setItem(0, is);
|
||||||
|
if (testInventory.getItem(0) != null) {
|
||||||
|
islandMaterials.put(materialName, testIslandMaterials.get(materialName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int playerMenuPage = playerData.getPage(), nextEndIndex = islandMaterials.size() - playerMenuPage * 36;
|
int playerMenuPage = playerData.getPage(), nextEndIndex = islandMaterials.size() - playerMenuPage * 36;
|
||||||
|
|
||||||
|
@ -238,8 +262,6 @@ public class Levelling {
|
||||||
endIndex = index >= islandMaterials.size() ? islandMaterials.size() - 1 : index + 36,
|
endIndex = index >= islandMaterials.size() ? islandMaterials.size() - 1 : index + 36,
|
||||||
inventorySlot = 17;
|
inventorySlot = 17;
|
||||||
|
|
||||||
Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "levelling.yml"));
|
|
||||||
|
|
||||||
for (; index < endIndex; index++) {
|
for (; index < endIndex; index++) {
|
||||||
if (islandMaterials.size() > index) {
|
if (islandMaterials.size() > index) {
|
||||||
String material = (String) islandMaterials.keySet().toArray()[index];
|
String material = (String) islandMaterials.keySet().toArray()[index];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user