1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-25 12:05:16 +01:00

Added option to jobs shop to hide icon if a player there are no enough points

This commit is contained in:
montlikadani 2019-09-25 19:08:48 +02:00
parent 6dfd0d94e8
commit f894a6aa09
3 changed files with 33 additions and 18 deletions

View File

@ -205,6 +205,11 @@ public class ShopManager {
ShopItem item = ls.get(i);
if (item.isHideIfNoEnoughPoints() && item.getRequiredTotalLevels() != -1 &&
Jobs.getPlayerManager().getJobsPlayer(player).getTotalLevels() < item.getRequiredTotalLevels()) {
continue;
}
ArrayList<String> Lore = new ArrayList<>();
CMIMaterial mat = CMIMaterial.get(item.getIconMaterial());
@ -344,15 +349,13 @@ public class ShopManager {
continue;
}
if (NameSection.isInt("Icon.Amount"))
Sitem.setIconAmount(NameSection.getInt("Icon.Amount"));
Sitem.setIconAmount(NameSection.getInt("Icon.Amount", 1));
if (NameSection.isString("Icon.Name"))
Sitem.setIconName(ChatColor.translateAlternateColorCodes('&', NameSection.getString("Icon.Name")));
if (NameSection.isList("Icon.Lore")) {
List<String> lore = new ArrayList<>();
if (!NameSection.getStringList("Icon.Lore").isEmpty())
for (String eachLine : NameSection.getStringList("Icon.Lore")) {
lore.add(ChatColor.translateAlternateColorCodes('&', eachLine));
}
@ -365,11 +368,14 @@ public class ShopManager {
if (NameSection.isBoolean("Icon.CustomHead.UseCurrentPlayer"))
Sitem.setCustomHeadOwner(NameSection.getBoolean("Icon.CustomHead.UseCurrentPlayer"));
if (NameSection.isBoolean("Icon.HideIfThereIsNoEnoughPoints")) {
Sitem.setHideIfThereIsNoEnoughPoints(NameSection.getBoolean("Icon.HideIfThereIsNoEnoughPoints"));
}
if (NameSection.isBoolean("Icon.HideWithoutPermission"))
Sitem.setHideWithoutPerm(NameSection.getBoolean("Icon.HideWithoutPermission"));
if (NameSection.isList("RequiredPermission")) {
if (!NameSection.getStringList("RequiredPermission").isEmpty())
if (NameSection.isList("RequiredPermission") && !NameSection.getStringList("RequiredPermission").isEmpty()) {
Sitem.setRequiredPerm(NameSection.getStringList("RequiredPermission"));
}
@ -396,7 +402,6 @@ public class ShopManager {
if (NameSection.isList("PerformCommands")) {
List<String> cmd = new ArrayList<>();
if (!NameSection.getStringList("PerformCommands").isEmpty())
for (String eachLine : NameSection.getStringList("PerformCommands")) {
cmd.add(ChatColor.translateAlternateColorCodes('&', eachLine));
}
@ -423,22 +428,20 @@ public class ShopManager {
continue;
}
int amount = 1;
if (itemSection.isInt("Amount"))
amount = itemSection.getInt("Amount");
int amount = itemSection.getInt("Amount", 1);
String name = null;
if (itemSection.isString("Name"))
name = ChatColor.translateAlternateColorCodes('&', itemSection.getString("Name"));
List<String> lore = new ArrayList<>();
if (itemSection.contains("Lore") && !itemSection.getStringList("Lore").isEmpty())
if (itemSection.contains("Lore"))
for (String eachLine : itemSection.getStringList("Lore")) {
lore.add(ChatColor.translateAlternateColorCodes('&', eachLine));
}
HashMap<Enchantment, Integer> enchants = new HashMap<>();
if (itemSection.contains("Enchants") && !itemSection.getStringList("Enchants").isEmpty())
if (itemSection.contains("Enchants"))
for (String eachLine : itemSection.getStringList("Enchants")) {
if (!eachLine.contains("="))

View File

@ -19,6 +19,8 @@ public class ShopItem {
private List<String> IconLore = new ArrayList<>();
private boolean HideWithoutPerm = false;
private boolean hideNoEnoughPoint = false;
private int RequiredTotalLevels = -1;
private List<String> RequiredPerm = new ArrayList<>();
@ -84,6 +86,14 @@ public class ShopItem {
return RequiredPerm;
}
public void setHideIfThereIsNoEnoughPoints(boolean hideNoEnoughPoint) {
this.hideNoEnoughPoint = hideNoEnoughPoint;
}
public boolean isHideIfNoEnoughPoints() {
return hideNoEnoughPoint;
}
public void setHideWithoutPerm(boolean HideWithoutPerm) {
this.HideWithoutPerm = HideWithoutPerm;
}

View File

@ -16,6 +16,8 @@ Items:
- "&eAnd one tasty apple!"
# (Optional - default: false) Hides icon if player don't have permission to get this item
HideWithoutPermission: true
# (Optional - default: false) Hides icon if player don't have enough point levels to get this icon
HideIfThereIsNoEnoughPoints: false
# (Optional) When you want to use Player Head material with skin then use this
#CustomHead:
# PlayerName: playerName