F Perm GUI (#1045)
This commit is contained in:
@@ -1,8 +1,17 @@
|
||||
package com.massivecraft.factions.struct;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.zcore.fperms.Permissable;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public enum Role implements Permissable {
|
||||
ADMIN(3, TL.ROLE_ADMIN),
|
||||
@@ -13,6 +22,8 @@ public enum Role implements Permissable {
|
||||
public final int value;
|
||||
public final String nicename;
|
||||
public final TL translation;
|
||||
private final ConfigurationSection RELATION_CONFIG = P.p.getConfig().getConfigurationSection("fperm-gui.relation");
|
||||
|
||||
|
||||
Role(final int value, final TL translation) {
|
||||
this.value = value;
|
||||
@@ -93,4 +104,44 @@ public enum Role implements Permissable {
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
// Utility method to build items for F Perm GUI
|
||||
@Override
|
||||
public ItemStack buildItem() {
|
||||
final ConfigurationSection RELATION_CONFIG = P.p.getConfig().getConfigurationSection("fperm-gui.relation");
|
||||
|
||||
String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", ""));
|
||||
List<String> lore = new ArrayList<>();
|
||||
|
||||
Material material = Material.matchMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase()));
|
||||
if (material == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack item = new ItemStack(material);
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
|
||||
for (String loreLine : RELATION_CONFIG.getStringList("placeholder-item.lore")) {
|
||||
lore.add(replacePlaceholders(loreLine));
|
||||
}
|
||||
|
||||
itemMeta.setDisplayName(displayName);
|
||||
itemMeta.setLore(lore);
|
||||
item.setItemMeta(itemMeta);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public String replacePlaceholders(String string) {
|
||||
string = ChatColor.translateAlternateColorCodes('&', string);
|
||||
|
||||
String permissableName = nicename.substring(0, 1).toUpperCase() + nicename.substring(1);
|
||||
|
||||
string = string.replace("{relation-color}", ChatColor.GREEN.toString());
|
||||
string = string.replace("{relation}", permissableName);
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user