Fix rankup gui
This commit is contained in:
@@ -52,7 +52,8 @@ public class Gui implements InventoryHolder {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack[] items = new ItemStack[config.getInt("rows", 1) * 9];
|
||||
Integer rows = Gui.getInt(config, "rows");
|
||||
ItemStack[] items = new ItemStack[(rows == null ? 1 : rows) * 9];
|
||||
|
||||
ItemStack fill = getItem(plugin, plugin.getSection(oldRank, basePath + ".fill"), player,
|
||||
oldRank, rank);
|
||||
@@ -167,6 +168,19 @@ public class Gui implements InventoryHolder {
|
||||
}
|
||||
}
|
||||
|
||||
public static Integer getInt(ConfigurationSection section, String key) {
|
||||
String string = section.getString(key);
|
||||
if (string == null) {
|
||||
return null;
|
||||
} else {
|
||||
try {
|
||||
return Integer.parseInt(string);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void open(Player player) {
|
||||
player.openInventory(inventory);
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ public class RanksGui {
|
||||
ConfigurationSection basePath = plugin.getMessages().getConfigurationSection("rankup.ranksgui");
|
||||
|
||||
String title = get(ConfigurationSection::getString, "title", playerPath, basePath, "Ranks");
|
||||
int rows = get(this::getInt, "rows", playerPath, basePath, 3);
|
||||
int offset = get(this::getInt, "offset", playerPath, basePath, 10);
|
||||
int width = get(this::getInt, "width", playerPath, basePath, 7);
|
||||
int rows = get(Gui::getInt, "rows", playerPath, basePath, 3);
|
||||
int offset = get(Gui::getInt, "offset", playerPath, basePath, 10);
|
||||
int width = get(Gui::getInt, "width", playerPath, basePath, 7);
|
||||
|
||||
inventory = Bukkit.createInventory(null, rows * 9, Colour.translate(title));
|
||||
|
||||
@@ -87,18 +87,6 @@ public class RanksGui {
|
||||
player.openInventory(inventory);
|
||||
}
|
||||
|
||||
private Integer getInt(ConfigurationSection section, String key) {
|
||||
String string = section.getString(key);
|
||||
if (string == null) {
|
||||
return null;
|
||||
} else {
|
||||
try {
|
||||
return Integer.parseInt(string);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private <T> T get(BiFunction<ConfigurationSection, String, T> fun, String path, ConfigurationSection primary, ConfigurationSection secondary, T def) {
|
||||
T get = null;
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import sh.okx.rankup.providers.TestEconomyProvider;
|
||||
import sh.okx.rankup.hook.GroupProvider;
|
||||
@@ -76,7 +77,7 @@ public abstract class RankupTest {
|
||||
}
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
MockBukkit.unmock();
|
||||
System.clearProperty("RANKUP_TEST");
|
||||
|
||||
Reference in New Issue
Block a user