1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 05:55:27 +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,18 +349,16 @@ 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));
}
for (String eachLine : NameSection.getStringList("Icon.Lore")) {
lore.add(ChatColor.translateAlternateColorCodes('&', eachLine));
}
Sitem.setIconLore(lore);
}
@ -365,12 +368,15 @@ 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())
Sitem.setRequiredPerm(NameSection.getStringList("RequiredPermission"));
if (NameSection.isList("RequiredPermission") && !NameSection.getStringList("RequiredPermission").isEmpty()) {
Sitem.setRequiredPerm(NameSection.getStringList("RequiredPermission"));
}
if (NameSection.isInt("RequiredTotalLevels"))
@ -396,10 +402,9 @@ 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));
}
for (String eachLine : NameSection.getStringList("PerformCommands")) {
cmd.add(ChatColor.translateAlternateColorCodes('&', eachLine));
}
Sitem.setCommands(cmd);
}
@ -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