mirror of
https://github.com/IHasName/CustomHeads.git
synced 2024-11-29 06:35:14 +01:00
Permission Issue Fix
Fixed Issue with the View Category Permission
This commit is contained in:
parent
ae369fac53
commit
3faa8e26ff
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>de.likewhat.customheads</groupId>
|
<groupId>de.likewhat.customheads</groupId>
|
||||||
<artifactId>CustomHeads</artifactId>
|
<artifactId>CustomHeads</artifactId>
|
||||||
<version>3.0.8</version>
|
<version>3.0.9</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -12,9 +12,9 @@ import de.likewhat.customheads.category.CustomHead;
|
|||||||
import de.likewhat.customheads.headwriter.HeadFontType;
|
import de.likewhat.customheads.headwriter.HeadFontType;
|
||||||
import de.likewhat.customheads.utils.FireworksBatteryHandler;
|
import de.likewhat.customheads.utils.FireworksBatteryHandler;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,7 +31,7 @@ public interface CustomHeadsAPI {
|
|||||||
* @param player Player to wrap (whether online or offline)
|
* @param player Player to wrap (whether online or offline)
|
||||||
* @return Wrapped Player Instance
|
* @return Wrapped Player Instance
|
||||||
*/
|
*/
|
||||||
CustomHeadsPlayer wrapPlayer(OfflinePlayer player);
|
CustomHeadsPlayer wrapPlayer(Player player);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will get the Texture from a Skull
|
* Will get the Texture from a Skull
|
||||||
|
@ -148,7 +148,7 @@ public class Category extends BaseCategory {
|
|||||||
category = new Category(
|
category = new Category(
|
||||||
categoryJson.get("id").getAsInt(),
|
categoryJson.get("id").getAsInt(),
|
||||||
Utils.format(categoryJson.get("name").getAsString()),
|
Utils.format(categoryJson.get("name").getAsString()),
|
||||||
"heads.viewCategory." + categoryJson.get("permission").getAsString(),
|
CategoryManager.VIEW_CATEGORY_PERMISSION_PREFIX + categoryJson.get("permission").getAsString(),
|
||||||
CustomHeads.hasEconomy() && categoryJson.has("price") ? categoryJson.get("price").getAsInt() : CustomHeads.getCategoryManager().getDefaultCategoryPrice(),
|
CustomHeads.hasEconomy() && categoryJson.has("price") ? categoryJson.get("price").getAsInt() : CustomHeads.getCategoryManager().getDefaultCategoryPrice(),
|
||||||
categoryJson.has("sub_categories") ? null :
|
categoryJson.has("sub_categories") ? null :
|
||||||
CustomHeads.getTagEditor().setTags(JsonToItem.convertFromJson(categoryJson.get("icon").toString()), "openCategory", "category#>" + categoryJson.get("id").getAsString(), "icon"));
|
CustomHeads.getTagEditor().setTags(JsonToItem.convertFromJson(categoryJson.get("icon").toString()), "openCategory", "category#>" + categoryJson.get("id").getAsString(), "icon"));
|
||||||
@ -214,7 +214,7 @@ public class Category extends BaseCategory {
|
|||||||
//Sub Category Info Header
|
//Sub Category Info Header
|
||||||
categoryObject.addProperty("id", Integer.parseInt(category.getId().contains(":") ? category.getId().split(":")[0] : category.getId()));
|
categoryObject.addProperty("id", Integer.parseInt(category.getId().contains(":") ? category.getId().split(":")[0] : category.getId()));
|
||||||
categoryObject.addProperty("name", category.getName());
|
categoryObject.addProperty("name", category.getName());
|
||||||
categoryObject.addProperty("permission", category.getPermission().replaceFirst("heads.viewCategory.", ""));
|
categoryObject.addProperty("permission", category.getPermission().replaceFirst(CategoryManager.VIEW_CATEGORY_PERMISSION_PREFIX, ""));
|
||||||
categoryObject.addProperty("fixed-icon", category.isFixedIcon());
|
categoryObject.addProperty("fixed-icon", category.isFixedIcon());
|
||||||
if (category.hasCategoryIcon()) {
|
if (category.hasCategoryIcon()) {
|
||||||
categoryObject.add("icon", new JsonParser().parse(JsonToItem.convertToJson(category.getCategoryIcon())));
|
categoryObject.add("icon", new JsonParser().parse(JsonToItem.convertToJson(category.getCategoryIcon())));
|
||||||
|
@ -6,6 +6,8 @@ import de.likewhat.customheads.utils.JsonFile;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.permissions.Permission;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@ -26,6 +28,8 @@ import java.util.logging.Level;
|
|||||||
@Getter
|
@Getter
|
||||||
public class CategoryManager {
|
public class CategoryManager {
|
||||||
|
|
||||||
|
public static final String VIEW_CATEGORY_PERMISSION_PREFIX = "heads.viewcategory.";
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private static boolean loaded;
|
private static boolean loaded;
|
||||||
private final HashMap<String, SubCategory> subCategories = new HashMap<>();
|
private final HashMap<String, SubCategory> subCategories = new HashMap<>();
|
||||||
@ -67,6 +71,9 @@ public class CategoryManager {
|
|||||||
CustomHeads.getInstance().getServer().getConsoleSender().sendMessage(CustomHeads.PREFIX_GENERAL + "Loading " + fileList.size() + " Categories from " + language + "/categories...");
|
CustomHeads.getInstance().getServer().getConsoleSender().sendMessage(CustomHeads.PREFIX_GENERAL + "Loading " + fileList.size() + " Categories from " + language + "/categories...");
|
||||||
long timestamp = System.currentTimeMillis();
|
long timestamp = System.currentTimeMillis();
|
||||||
CustomHeads.getHeadsConfig().reload();
|
CustomHeads.getHeadsConfig().reload();
|
||||||
|
|
||||||
|
Permission viewCategoryWildcard = Bukkit.getPluginManager().getPermission(VIEW_CATEGORY_PERMISSION_PREFIX + "*");
|
||||||
|
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||||
for (File file : fileList) {
|
for (File file : fileList) {
|
||||||
JsonFile jsf = new JsonFile(file);
|
JsonFile jsf = new JsonFile(file);
|
||||||
categoriesIgnored = CustomHeads.getHeadsConfig().get().getList("disabledCategories").size();
|
categoriesIgnored = CustomHeads.getHeadsConfig().get().getList("disabledCategories").size();
|
||||||
@ -83,11 +90,24 @@ public class CategoryManager {
|
|||||||
}
|
}
|
||||||
categories.put(category.getId(), category);
|
categories.put(category.getId(), category);
|
||||||
sourceFiles.put(category, file);
|
sourceFiles.put(category, file);
|
||||||
|
|
||||||
|
Permission categoryBasePermission = new Permission(category.getPermission()); // heads.view_category.<category-name>
|
||||||
|
Permission categoryAllHeadsPermission = new Permission(category.getPermission() + ".all_heads");
|
||||||
|
|
||||||
|
// Add Permissions from the Categories dynamically
|
||||||
|
pluginManager.addPermission(categoryBasePermission);
|
||||||
|
pluginManager.addPermission(categoryAllHeadsPermission);
|
||||||
|
|
||||||
|
// Add the Category Permissions as Parent from the View Category Permission
|
||||||
|
categoryBasePermission.addParent(viewCategoryWildcard, true);
|
||||||
|
categoryBasePermission.addParent(categoryAllHeadsPermission, true);
|
||||||
|
categoryAllHeadsPermission.addParent(viewCategoryWildcard, true);
|
||||||
|
|
||||||
categoriesLoaded++;
|
categoriesLoaded++;
|
||||||
if (category.hasSubCategories()) {
|
if (category.hasSubCategories()) {
|
||||||
for (SubCategory subCategory : category.getSubCategories()) {
|
for (SubCategory subCategory : category.getSubCategories()) {
|
||||||
if (subCategories.containsKey(subCategory.getId())) {
|
if (subCategories.containsKey(subCategory.getId())) {
|
||||||
CustomHeads.getInstance().getServer().getConsoleSender().sendMessage(CustomHeads.PREFIX_WARNING + file.getName() + ": §cAn Subcategory with ID " + subCategory.getId() + " (" + subCategories.get(subCategory.getId()).getName() + ") already exists.");
|
CustomHeads.getInstance().getServer().getConsoleSender().sendMessage(CustomHeads.PREFIX_WARNING + file.getName() + ": §cA Subcategory with ID " + subCategory.getId() + " (" + subCategories.get(subCategory.getId()).getName() + ") already exists.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
subCategories.put(subCategory.getId(), subCategory);
|
subCategories.put(subCategory.getId(), subCategory);
|
||||||
|
@ -9,6 +9,7 @@ import de.likewhat.customheads.category.SubCategory;
|
|||||||
import de.likewhat.customheads.headwriter.HeadFontType;
|
import de.likewhat.customheads.headwriter.HeadFontType;
|
||||||
import de.likewhat.customheads.headwriter.HeadWriter;
|
import de.likewhat.customheads.headwriter.HeadWriter;
|
||||||
import de.likewhat.customheads.utils.*;
|
import de.likewhat.customheads.utils.*;
|
||||||
|
import de.likewhat.customheads.utils.history.SearchHistory;
|
||||||
import de.likewhat.customheads.utils.reflection.helpers.ReflectionUtils;
|
import de.likewhat.customheads.utils.reflection.helpers.ReflectionUtils;
|
||||||
import de.likewhat.customheads.utils.reflection.helpers.Version;
|
import de.likewhat.customheads.utils.reflection.helpers.Version;
|
||||||
import de.likewhat.customheads.utils.updaters.FetchResult;
|
import de.likewhat.customheads.utils.updaters.FetchResult;
|
||||||
@ -424,7 +425,7 @@ public class CustomHeadsCommand implements CommandExecutor {
|
|||||||
OfflinePlayer phis = Bukkit.getOfflinePlayer(Utils.parseUUID(uuid));
|
OfflinePlayer phis = Bukkit.getOfflinePlayer(Utils.parseUUID(uuid));
|
||||||
if (phis.hasPlayedBefore() || phis.isOnline()) {
|
if (phis.hasPlayedBefore() || phis.isOnline()) {
|
||||||
if (hasPermission(player, "heads.view.history." + phis.getName()) || hasPermission(player, "heads.view.history.*") || (phis == player && CustomHeads.canSeeOwnHistory())) {
|
if (hasPermission(player, "heads.view.history." + phis.getName()) || hasPermission(player, "heads.view.history.*") || (phis == player && CustomHeads.canSeeOwnHistory())) {
|
||||||
player.openInventory(CustomHeads.getApi().wrapPlayer(phis).getSearchHistory().getInventory());
|
player.openInventory(new SearchHistory(player).getInventory());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.sendMessage(CustomHeads.getLanguageManager().HISTORY_NO_VIEW_PERMISSION);
|
player.sendMessage(CustomHeads.getLanguageManager().HISTORY_NO_VIEW_PERMISSION);
|
||||||
|
@ -61,6 +61,7 @@ public class InventoryListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CustomHeadsPlayer customHeadsPlayer = CustomHeads.getApi().wrapPlayer(player);
|
CustomHeadsPlayer customHeadsPlayer = CustomHeads.getApi().wrapPlayer(player);
|
||||||
|
List<Category> unlockedCategories = customHeadsPlayer.getUnlockedCategories(CustomHeads.hasEconomy() && !CustomHeads.keepCategoryPermissions());
|
||||||
ItemStack[] inventoryContent = event.getInventory().getContents();
|
ItemStack[] inventoryContent = event.getInventory().getContents();
|
||||||
for (int i = 0; i < inventoryContent.length; i++) {
|
for (int i = 0; i < inventoryContent.length; i++) {
|
||||||
if (inventoryContent[i] == null) continue;
|
if (inventoryContent[i] == null) continue;
|
||||||
@ -70,15 +71,18 @@ public class InventoryListener implements Listener {
|
|||||||
if (categoryArgs[0].equals("category")) {
|
if (categoryArgs[0].equals("category")) {
|
||||||
Category category = CustomHeads.getCategoryManager().getCategory(categoryArgs[1]);
|
Category category = CustomHeads.getCategoryManager().getCategory(categoryArgs[1]);
|
||||||
ItemStack nextIcon = category.nextIcon();
|
ItemStack nextIcon = category.nextIcon();
|
||||||
boolean bought = customHeadsPlayer.getUnlockedCategories(true).contains(category);
|
boolean bought = false;
|
||||||
|
if(CustomHeads.hasEconomy() && CustomHeads.categoriesBuyable()) {
|
||||||
|
bought = customHeadsPlayer.getUnlockedCategories(true).contains(category);
|
||||||
|
}
|
||||||
nextIcon = new ItemEditor(nextIcon)
|
nextIcon = new ItemEditor(nextIcon)
|
||||||
.setDisplayName(customHeadsPlayer.getUnlockedCategories(CustomHeads.hasEconomy() && !CustomHeads.keepCategoryPermissions()).contains(category) ? "§a" + nextIcon.getItemMeta().getDisplayName() : "§7" + ChatColor.stripColor(nextIcon.getItemMeta().getDisplayName()) + " " + CustomHeads.getLanguageManager().LOCKED)
|
.setDisplayName(unlockedCategories.contains(category) ? ("§a" + nextIcon.getItemMeta().getDisplayName()) : ("§7" + ChatColor.stripColor(nextIcon.getItemMeta().getDisplayName()) + " " + CustomHeads.getLanguageManager().LOCKED))
|
||||||
.addLoreLine(CustomHeads.hasEconomy() && CustomHeads.categoriesBuyable() ? bought || hasPermission(player, category.getPermission()) ? CustomHeads.getLanguageManager().ECONOMY_BOUGHT : Utils.getCategoryPriceFormatted(category, true) + "\n" + CustomHeads.getLanguageManager().ECONOMY_BUY_PROMPT : null)
|
.addLoreLine(CustomHeads.hasEconomy() && CustomHeads.categoriesBuyable() ? bought || hasPermission(player, category.getPermission()) ? CustomHeads.getLanguageManager().ECONOMY_BOUGHT : Utils.getCategoryPriceFormatted(category, true) + "\n" + CustomHeads.getLanguageManager().ECONOMY_BUY_PROMPT : null)
|
||||||
.addLoreLines(hasPermission(player, "heads.view.permissions") ? Arrays.asList(" ", "§7§oPermission: " + category.getPermission()) : null)
|
.addLoreLines(hasPermission(player, "heads.view.permissions") ? Arrays.asList(" ", "§7§oPermission: " + category.getPermission()) : null)
|
||||||
.getItem();
|
.getItem();
|
||||||
if (CustomHeads.hasEconomy()) {
|
if (CustomHeads.hasEconomy() && CustomHeads.categoriesBuyable()) {
|
||||||
if(!(CustomHeads.keepCategoryPermissions() && hasPermission(player, category.getPermission()))) {
|
if(!(CustomHeads.keepCategoryPermissions() && hasPermission(player, category.getPermission()))) {
|
||||||
if (!bought && CustomHeads.categoriesBuyable()) {
|
if (!bought) {
|
||||||
nextIcon = CustomHeads.getTagEditor().addTags(nextIcon, "buyCategory", category.getId());
|
nextIcon = CustomHeads.getTagEditor().addTags(nextIcon, "buyCategory", category.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -570,7 +574,7 @@ public class InventoryListener implements Listener {
|
|||||||
String[] id = itemTags.get(itemTags.indexOf("headID")+1).split(":");
|
String[] id = itemTags.get(itemTags.indexOf("headID")+1).split(":");
|
||||||
category = CustomHeads.getCategoryManager().getCategory(id[0]);
|
category = CustomHeads.getCategoryManager().getCategory(id[0]);
|
||||||
}
|
}
|
||||||
if (getHeadFromItem(event.getCurrentItem()) == null || (category != null && hasPermission(player, "heads.viewCategory." + category.getPermission().replaceFirst("heads.viewCategory.", "") + ".allheads")) || customHeadsPlayer.getUnlockedHeads().contains(getHeadFromItem(event.getCurrentItem())) || getHeadFromItem(event.getCurrentItem()).isFree()) {
|
if (getHeadFromItem(event.getCurrentItem()) == null || (category != null && hasPermission(player, category.getPermission() + ".allheads")) || customHeadsPlayer.getUnlockedHeads().contains(getHeadFromItem(event.getCurrentItem())) || getHeadFromItem(event.getCurrentItem()).isFree()) {
|
||||||
ItemEditor itemEditor = new ItemEditor(event.getCurrentItem());
|
ItemEditor itemEditor = new ItemEditor(event.getCurrentItem());
|
||||||
if (!CustomHeads.shouldGrabHeadToCursor() || event.getClick() == ClickType.SHIFT_LEFT) {
|
if (!CustomHeads.shouldGrabHeadToCursor() || event.getClick() == ClickType.SHIFT_LEFT) {
|
||||||
player.getInventory().addItem(TagEditor.clearTags(itemEditor.removeLoreLine(itemEditor.hasLore() ? itemEditor.getLore().size() - 1 : 0).getItem()));
|
player.getInventory().addItem(TagEditor.clearTags(itemEditor.removeLoreLine(itemEditor.hasLore() ? itemEditor.getLore().size() - 1 : 0).getItem()));
|
||||||
|
@ -26,6 +26,7 @@ import org.bukkit.block.BlockFace;
|
|||||||
import org.bukkit.block.Skull;
|
import org.bukkit.block.Skull;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Firework;
|
import org.bukkit.entity.Firework;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.FireworkMeta;
|
import org.bukkit.inventory.meta.FireworkMeta;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
@ -199,7 +200,7 @@ public void setSkull(Block block, String texture, BlockFace blockFace) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// API Impl
|
// API Impl
|
||||||
public CustomHeadsPlayer wrapPlayer(OfflinePlayer player) {
|
public CustomHeadsPlayer wrapPlayer(Player player) {
|
||||||
return PlayerWrapper.wrapPlayer(player);
|
return PlayerWrapper.wrapPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ import de.likewhat.customheads.utils.history.GetHistory;
|
|||||||
import de.likewhat.customheads.utils.history.SearchHistory;
|
import de.likewhat.customheads.utils.history.SearchHistory;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -39,9 +38,9 @@ public class PlayerWrapper implements CustomHeadsPlayer {
|
|||||||
@Getter private SearchHistory searchHistory;
|
@Getter private SearchHistory searchHistory;
|
||||||
@Getter private GetHistory getHistory;
|
@Getter private GetHistory getHistory;
|
||||||
|
|
||||||
private final OfflinePlayer player;
|
private final Player player;
|
||||||
|
|
||||||
private PlayerWrapper(OfflinePlayer player) {
|
private PlayerWrapper(Player player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
try {
|
try {
|
||||||
JsonObject dataRoot = CustomHeads.getPlayerDataFile().getJson().getAsJsonObject();
|
JsonObject dataRoot = CustomHeads.getPlayerDataFile().getJson().getAsJsonObject();
|
||||||
@ -82,8 +81,8 @@ public class PlayerWrapper implements CustomHeadsPlayer {
|
|||||||
WRAPPED_PLAYERS_CACHE.put(player.getUniqueId(), this);
|
WRAPPED_PLAYERS_CACHE.put(player.getUniqueId(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
static CustomHeadsPlayer wrapPlayer(OfflinePlayer player) {
|
static CustomHeadsPlayer wrapPlayer(Player player) {
|
||||||
return WRAPPED_PLAYERS_CACHE.containsKey(player.getUniqueId()) ? WRAPPED_PLAYERS_CACHE.get(player.getUniqueId()) : new PlayerWrapper(player);
|
return WRAPPED_PLAYERS_CACHE.getOrDefault(player.getUniqueId(), new PlayerWrapper(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearCache() {
|
public static void clearCache() {
|
||||||
@ -140,11 +139,11 @@ public class PlayerWrapper implements CustomHeadsPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<Category> getUnlockedCategories(boolean ignorePermission) {
|
public List<Category> getUnlockedCategories(boolean ignorePermission) {
|
||||||
return CustomHeads.getCategoryManager().getCategoryList().stream().filter(category -> (!ignorePermission && (Utils.hasPermission(player.getPlayer(), category.getPermission()) || Utils.hasPermission(player.getPlayer(), category.getPermission() + ".allheads"))) || unlockedCategories.contains(category)).collect(Collectors.toList());
|
return CustomHeads.getCategoryManager().getCategoryList().stream().filter(category -> (!ignorePermission && (Utils.hasPermission(player, category.getPermission()) || Utils.hasPermission(player, category.getPermission() + ".allheads"))) || unlockedCategories.contains(category)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player unwrap() {
|
public Player unwrap() {
|
||||||
return player.getPlayer();
|
return this.player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean unlockCategory(Category category) {
|
public boolean unlockCategory(Category category) {
|
||||||
|
@ -68,6 +68,8 @@ public class Utils {
|
|||||||
|
|
||||||
public static final String TEXT_JSON_FORMAT = "{\"text\":\"%s\"}";
|
public static final String TEXT_JSON_FORMAT = "{\"text\":\"%s\"}";
|
||||||
|
|
||||||
|
private static final HashMap<String, List<String>> PERMISSION_CACHE = new HashMap<>();
|
||||||
|
|
||||||
public static String getTextureFromProfile(GameProfile profile) {
|
public static String getTextureFromProfile(GameProfile profile) {
|
||||||
String value = "";
|
String value = "";
|
||||||
for (Property prop : profile.getProperties().get("textures")) {
|
for (Property prop : profile.getProperties().get("textures")) {
|
||||||
@ -311,7 +313,7 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasPermission(Player player, String permission) {
|
public static boolean hasPermission(Player player, String permission) {
|
||||||
return player.hasPermission(permission) || player.hasPermission("heads.admin") || player.hasPermission("heads.*") || player.isOp();
|
return player.isOp() || player.hasPermission("heads.admin") || player.hasPermission(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UUID parseUUID(String uuidStr) {
|
public static UUID parseUUID(String uuidStr) {
|
||||||
@ -402,7 +404,7 @@ public class Utils {
|
|||||||
inventory.setContent(categoryHeads.stream().map(customHead -> {
|
inventory.setContent(categoryHeads.stream().map(customHead -> {
|
||||||
boolean bought = customHeadsPlayer.getUnlockedHeads().contains(customHead);
|
boolean bought = customHeadsPlayer.getUnlockedHeads().contains(customHead);
|
||||||
ItemEditor itemEditor = new ItemEditor(customHead);
|
ItemEditor itemEditor = new ItemEditor(customHead);
|
||||||
return CustomHeads.hasEconomy() && CustomHeads.headsBuyable() ? (bought || hasPermission(player, "heads.unlockAllHeads." + baseCategory.getPermission().replaceFirst("heads.viewCategory.", ""))) ? CustomHeads.getTagEditor().addTags(itemEditor.addLoreLine(CustomHeads.getLanguageManager().ECONOMY_BOUGHT).getItem(), "wearable", "clonable") : CustomHeads.getTagEditor().addTags(itemEditor.addLoreLine(formatPrice(customHead.getPrice(), true)).getItem(), "buyHead", "buyHead#>" + customHead.getOriginCategory().getId() + ":" + customHead.getId()) : CustomHeads.getTagEditor().addTags(itemEditor.getItem(), "wearable", "clonable");
|
return CustomHeads.hasEconomy() && CustomHeads.headsBuyable() ? (bought || hasPermission(player, "heads.unlock-all-heads." + baseCategory.getPermission().replaceFirst("heads.viewCategory.", ""))) ? CustomHeads.getTagEditor().addTags(itemEditor.addLoreLine(CustomHeads.getLanguageManager().ECONOMY_BOUGHT).getItem(), "wearable", "clonable") : CustomHeads.getTagEditor().addTags(itemEditor.addLoreLine(formatPrice(customHead.getPrice(), true)).getItem(), "buyHead", "buyHead#>" + customHead.getOriginCategory().getId() + ":" + customHead.getId()) : CustomHeads.getTagEditor().addTags(itemEditor.getItem(), "wearable", "clonable");
|
||||||
}).collect(Collectors.toList()));
|
}).collect(Collectors.toList()));
|
||||||
inventory.setBarItem(1, Utils.getBackButton(backAction));
|
inventory.setBarItem(1, Utils.getBackButton(backAction));
|
||||||
inventory.setBarItem(3, CustomHeads.getTagEditor().setTags(new ItemEditor(Material.PAPER).setDisplayName(CustomHeads.getLanguageManager().ITEMS_INFO).setLore(CustomHeads.getLanguageManager().ITEMS_INFO_LORE).getItem(), "dec", "info-item", "blockMoving"));
|
inventory.setBarItem(3, CustomHeads.getTagEditor().setTags(new ItemEditor(Material.PAPER).setDisplayName(CustomHeads.getLanguageManager().ITEMS_INFO).setLore(CustomHeads.getLanguageManager().ITEMS_INFO_LORE).getItem(), "dec", "info-item", "blockMoving"));
|
||||||
|
@ -12,16 +12,19 @@ permissions:
|
|||||||
heads.*:
|
heads.*:
|
||||||
description: Gives all Permission for the Plugin
|
description: Gives all Permission for the Plugin
|
||||||
children:
|
children:
|
||||||
|
heads.use: true
|
||||||
heads.use.*: true
|
heads.use.*: true
|
||||||
heads.view.*: true
|
heads.view.*: true
|
||||||
heads.viewCategory.*: true
|
heads.viewcategory.*: true
|
||||||
heads.view.history.*: true
|
heads.view.history.*: true
|
||||||
default: op
|
default: op
|
||||||
heads.use:
|
heads.use:
|
||||||
default: op
|
default: op
|
||||||
heads.view.history:
|
heads.view.history:
|
||||||
default: op
|
default: op
|
||||||
heads.viewCategory:
|
heads.viewcategory:
|
||||||
|
default: op
|
||||||
|
heads.viewcategory.*:
|
||||||
default: op
|
default: op
|
||||||
heads.use.more:
|
heads.use.more:
|
||||||
default: op
|
default: op
|
||||||
|
Loading…
Reference in New Issue
Block a user