mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-12-03 07:33:38 +01:00
Format and check for null section
This commit is contained in:
parent
d490bb8366
commit
81a33de33a
@ -11,7 +11,9 @@ import com.massivecraft.factions.zcore.fperms.gui.PermissableActionGUI;
|
||||
import com.massivecraft.factions.zcore.fperms.gui.PermissableRelationGUI;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class CmdPerm extends FCommand {
|
||||
|
||||
|
@ -7,7 +7,6 @@ import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import com.massivecraft.factions.zcore.util.TagReplacer;
|
||||
import com.massivecraft.factions.zcore.util.TagUtil;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public enum PermissableAction {
|
||||
BAN("ban"),
|
||||
@ -72,15 +73,21 @@ public enum PermissableAction {
|
||||
|
||||
// Utility method to build items for F Perm GUI
|
||||
public ItemStack buildItem(FPlayer fme, Permissable permissable) {
|
||||
final ConfigurationSection ACTION_CONFIG = P.p.getConfig().getConfigurationSection("fperm-gui.action");
|
||||
final ConfigurationSection section = P.p.getConfig().getConfigurationSection("fperm-gui.action");
|
||||
|
||||
String displayName = replacePlaceholers(ACTION_CONFIG.getString("placeholder-item.name"), fme, permissable);
|
||||
if (section == null) {
|
||||
P.p.log(Level.WARNING, "Attempted to build f perm GUI but config section not present.");
|
||||
P.p.log(Level.WARNING, "Copy your config, allow the section to generate, then copy it back to your old config.");
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
|
||||
String displayName = replacePlaceholers(section.getString("placeholder-item.name"), fme, permissable);
|
||||
List<String> lore = new ArrayList<>();
|
||||
|
||||
if (ACTION_CONFIG.getString("materials." + name().toLowerCase().replace('_', '-')) == null) {
|
||||
if (section.getString("materials." + name().toLowerCase().replace('_', '-')) == null) {
|
||||
return null;
|
||||
}
|
||||
Material material = Material.matchMaterial(ACTION_CONFIG.getString("materials." + name().toLowerCase().replace('_', '-')));
|
||||
Material material = Material.matchMaterial(section.getString("materials." + name().toLowerCase().replace('_', '-')));
|
||||
if (material == null) {
|
||||
material = Material.STAINED_CLAY;
|
||||
}
|
||||
@ -91,8 +98,9 @@ public enum PermissableAction {
|
||||
}
|
||||
DyeColor dyeColor = null;
|
||||
try {
|
||||
dyeColor = DyeColor.valueOf(ACTION_CONFIG.getString("access." + access.name().toLowerCase()));
|
||||
} catch (Exception exception) {}
|
||||
dyeColor = DyeColor.valueOf(section.getString("access." + access.name().toLowerCase()));
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
|
||||
ItemStack item = new ItemStack(material);
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
@ -101,7 +109,7 @@ public enum PermissableAction {
|
||||
item.setDurability(dyeColor.getWoolData());
|
||||
}
|
||||
|
||||
for (String loreLine : ACTION_CONFIG.getStringList("placeholder-item.lore")) {
|
||||
for (String loreLine : section.getStringList("placeholder-item.lore")) {
|
||||
lore.add(replacePlaceholers(loreLine, fme, permissable));
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ public class PermissableActionGUI implements InventoryHolder, PermissionGUI {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
buildSpecialItems();
|
||||
buildItems();
|
||||
}
|
||||
@ -195,7 +195,7 @@ public class PermissableActionGUI implements InventoryHolder, PermissionGUI {
|
||||
|
||||
List<Integer> dummySlots = ACTION_CONFIG.getIntegerList("dummy-items." + key);
|
||||
for (Integer slot : dummySlots) {
|
||||
if (slot+1 > guiSize || slot < 0) {
|
||||
if (slot + 1 > guiSize || slot < 0) {
|
||||
P.p.log(Level.WARNING, "Invalid slot: " + slot + " for dummy item: " + key);
|
||||
continue;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ public class PermissableRelationGUI implements InventoryHolder, PermissionGUI {
|
||||
|
||||
List<Integer> dummySlots = RELATION_CONFIG.getIntegerList("dummy-items." + key);
|
||||
for (Integer slot : dummySlots) {
|
||||
if (slot+1 > guiSize || slot < 0) {
|
||||
if (slot + 1 > guiSize || slot < 0) {
|
||||
P.p.log(Level.WARNING, "Invalid slot: " + slot + " for dummy item: " + key);
|
||||
continue;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.massivecraft.factions.zcore.fperms.gui;
|
||||
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
|
||||
public interface PermissionGUI {
|
||||
|
||||
|
@ -284,10 +284,10 @@ public abstract class MemoryBoard extends Board {
|
||||
Faction factionHere = getFactionAt(flocationHere);
|
||||
Relation relation = fplayer.getRelationTo(factionHere);
|
||||
if (factionHere.isWilderness()) {
|
||||
row.then("-") .color(ChatColor.GRAY);
|
||||
row.then("-").color(ChatColor.GRAY);
|
||||
// Check for claimat position and if so, let them claim at ;D
|
||||
if (fplayer.getPlayer().hasPermission(Permission.CLAIMAT.node)) {
|
||||
row.tooltip(TL.CLAIM_CLICK_TO_CLAIM.format(dx, dz))
|
||||
row.tooltip(TL.CLAIM_CLICK_TO_CLAIM.format(dx, dz))
|
||||
.command(String.format("/f claimat %s %d %d", flocation.getWorldName(), dx, dz));
|
||||
}
|
||||
} else if (factionHere.isSafeZone()) {
|
||||
|
Loading…
Reference in New Issue
Block a user