diff --git a/com/gamingmesh/jobs/config/GeneralConfigManager.java b/com/gamingmesh/jobs/config/GeneralConfigManager.java index 66c4e89e..8042de72 100644 --- a/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -827,8 +827,10 @@ public class GeneralConfigManager { c.getW().addComment("JobsBrowse.ShowPenaltyBonus", "Do you want to show GUI when performing /jobs join command"); JobsGUIOpenOnJoin = c.get("JobsGUI.OpenOnJoin", true); - guiBackButton = new ItemStack(Material.getMaterial(c.get("JobsGUI.BackButton.Material", "JACK_O_LANTERN")), 1, (byte) c.get("JobsGUI.BackButton.Data", 0)); - guiFiller = new ItemStack(Material.getMaterial(c.get("JobsGUI.Filler.Material", "STAINED_GLASS_PANE")), 1, (byte) c.get("JobsGUI.Filler.Data", 15)); + Material tmat = Material.getMaterial(c.get("JobsGUI.BackButton.Material", "JACK_O_LANTERN")); + guiBackButton = new ItemStack(tmat == null ? Material.JACK_O_LANTERN : tmat, 1, (byte) c.get("JobsGUI.BackButton.Data", 0)); + tmat = Material.getMaterial(c.get("JobsGUI.Filler.Material", "STAINED_GLASS_PANE")); + guiFiller = new ItemStack(tmat == null ? Material.STAINED_GLASS_PANE : tmat, 1, (byte) c.get("JobsGUI.Filler.Data", 15)); c.getW().addComment("Schedule.Boost.Enable", "Do you want to enable scheduler for global boost"); useGlobalBoostScheduler = c.get("Schedule.Boost.Enable", false); diff --git a/com/gamingmesh/jobs/config/LanguageManager.java b/com/gamingmesh/jobs/config/LanguageManager.java index ef6b4a1a..5ed31723 100644 --- a/com/gamingmesh/jobs/config/LanguageManager.java +++ b/com/gamingmesh/jobs/config/LanguageManager.java @@ -190,12 +190,14 @@ public class LanguageManager { c.get("command.shop.info.price", "&ePrice: &6%price%"); c.get("command.shop.info.reqJobs", "&eRequired jobs:"); c.get("command.shop.info.reqJobsList", " &6%jobsname%&e: &e%level% lvl"); + c.get("command.shop.info.reqTotalLevel", "&6Required total level: &e%totalLevel%"); c.get("command.shop.info.cantOpen", "&cCan't open this page"); c.get("command.shop.info.NoPermForItem", "&cYou don't have required permissions for this item!"); c.get("command.shop.info.NoPermToBuy", "&cNo permissions to buy this item"); c.get("command.shop.info.NoJobReqForitem", "&cYou don't have required job (&6%jobname%&e) with required (&6%joblevel%&e) level"); c.get("command.shop.info.NoPoints", "&cYou don't have enough points"); + c.get("command.shop.info.NoTotalLevel", "&cTotal jobs level is too low (%totalLevel%)"); c.get("command.shop.info.Paid", "&eYou have paid &6%amount% &efor this item"); c.get("command.shop.info.reqJobsList", " &6%jobsname%&e: &e%level% lvl"); diff --git a/com/gamingmesh/jobs/config/ShopManager.java b/com/gamingmesh/jobs/config/ShopManager.java index b444ca03..456de793 100644 --- a/com/gamingmesh/jobs/config/ShopManager.java +++ b/com/gamingmesh/jobs/config/ShopManager.java @@ -106,6 +106,12 @@ public class ShopManager { player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoPoints")); return; } + + if (item.getRequiredTotalLevels() != -1 && Jobs.getPlayerManager().getJobsPlayer(player).getTotalLevels() < item.getRequiredTotalLevels()) { + player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoTotalLevel", "%totalLevel%", Jobs.getPlayerManager().getJobsPlayer(player).getTotalLevels())); + return; + } + } for (String one : item.getCommands()) { @@ -282,6 +288,11 @@ public class ShopManager { } } + if (item.getRequiredTotalLevels() != -1) { + Lore.add(Jobs.getLanguage().getMessage("command.shop.info.reqTotalLevel", + "%totalLevel%", (Jobs.getPlayerManager().getJobsPlayer(player).getTotalLevels() < item.getRequiredTotalLevels() ? ChatColor.DARK_RED + "" : "") + item.getRequiredTotalLevels())); + } + meta.setLore(Lore); GUIitem.setItemMeta(meta); GuiInv.setItem(i, GUIitem); @@ -364,6 +375,9 @@ public class ShopManager { if (NameSection.isList("RequiredPermission")) Sitem.setRequiredPerm(NameSection.getStringList("RequiredPermission")); + if (NameSection.isInt("RequiredTotalLevels")) + Sitem.setRequiredTotalLevels(NameSection.getInt("RequiredTotalLevels")); + if (NameSection.isList("RequiredJobLevels")) { HashMap RequiredJobs = new HashMap(); for (String one : NameSection.getStringList("RequiredJobLevels")) { diff --git a/com/gamingmesh/jobs/container/JobsPlayer.java b/com/gamingmesh/jobs/container/JobsPlayer.java index c94cf48a..5426eaf7 100644 --- a/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/com/gamingmesh/jobs/container/JobsPlayer.java @@ -79,6 +79,14 @@ public class JobsPlayer { this.player = Bukkit.getPlayer(userName); } + public int getTotalLevels() { + int i = 0; + for (JobProgression job : progression) { + i += job.getLevel(); + } + return i; + } + public PaymentData getPaymentLimit() { if (paymentLimits == null) { paymentLimits = Jobs.getJobsDAO().getPlayersLimits(this); @@ -96,7 +104,7 @@ public class JobsPlayer { if (!limit.isEnabled()) return true; PaymentData data = getPaymentLimit(); - + if (data.IsReachedLimit(type, this.limits.get(type))) { if (player.isOnline() && !data.isInformed() && !data.isReseted()) { player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.reached" + type.getName().toLowerCase() + "limit")); diff --git a/com/gamingmesh/jobs/container/ShopItem.java b/com/gamingmesh/jobs/container/ShopItem.java index 737ce602..29cb7071 100644 --- a/com/gamingmesh/jobs/container/ShopItem.java +++ b/com/gamingmesh/jobs/container/ShopItem.java @@ -1,136 +1,145 @@ -package com.gamingmesh.jobs.container; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -public class ShopItem { - - private String NodeName = null; - - private double price = 0D; - - private int slot = -1; - private int page = -1; - - private int IconId = 1; - private int IconData = 0; - private int IconAmount = 1; - private String IconName = null; - private List IconLore = new ArrayList(); - - private boolean HideWithoutPerm = false; - - private List RequiredPerm = new ArrayList(); - private HashMap RequiredJobs = new HashMap(); - - private List Commands = new ArrayList(); - - private List items = new ArrayList(); - - public ShopItem(String NodeName, double price, int IconId) { - this.NodeName = NodeName; - this.price = price; - this.IconId = IconId; - } - - public void setPage(Integer page) { - this.page = page; - } - - public int getPage() { - return this.page; - } - - public void setSlot(Integer slot) { - this.slot = slot; - } - - public int getSlot() { - return this.slot; - } - - public void setitems(List items) { - this.items = items; - } - - public List getitems() { - return this.items; - } - - public void setCommands(List Commands) { - this.Commands = Commands; - } - - public List getCommands() { - return this.Commands; - } - - public void setRequiredJobs(HashMap RequiredJobs) { - this.RequiredJobs = RequiredJobs; - } - - public HashMap getRequiredJobs() { - return this.RequiredJobs; - } - - public void setRequiredPerm(List RequiredPerm) { - this.RequiredPerm = RequiredPerm; - } - - public List getRequiredPerm() { - return this.RequiredPerm; - } - - public void setHideWithoutPerm(boolean HideWithoutPerm) { - this.HideWithoutPerm = HideWithoutPerm; - } - - public boolean isHideWithoutPerm() { - return this.HideWithoutPerm; - } - - public void setIconLore(List IconLore) { - this.IconLore = IconLore; - } - - public List getIconLore() { - return this.IconLore; - } - - public String getNodeName() { - return this.NodeName; - } - - public int getIconId() { - return this.IconId; - } - - public int getIconData() { - return this.IconData; - } - - public void setIconData(int IconData) { - this.IconData = IconData; - } - - public double getPrice() { - return this.price; - } - - public void setIconAmount(int IconAmount) { - this.IconAmount = IconAmount; - } - - public int getIconAmount() { - return this.IconAmount; - } - - public void setIconName(String IconName) { - this.IconName = IconName; - } - - public String getIconName() { - return this.IconName; - } -} +package com.gamingmesh.jobs.container; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class ShopItem { + + private String NodeName = null; + + private double price = 0D; + + private int slot = -1; + private int page = -1; + + private int IconId = 1; + private int IconData = 0; + private int IconAmount = 1; + private String IconName = null; + private List IconLore = new ArrayList(); + + private boolean HideWithoutPerm = false; + private int RequiredTotalLevels = -1; + + private List RequiredPerm = new ArrayList(); + private HashMap RequiredJobs = new HashMap(); + + private List Commands = new ArrayList(); + + private List items = new ArrayList(); + + public ShopItem(String NodeName, double price, int IconId) { + this.NodeName = NodeName; + this.price = price; + this.IconId = IconId; + } + + public void setPage(Integer page) { + this.page = page; + } + + public int getPage() { + return this.page; + } + + public void setSlot(Integer slot) { + this.slot = slot; + } + + public int getSlot() { + return this.slot; + } + + public void setitems(List items) { + this.items = items; + } + + public List getitems() { + return this.items; + } + + public void setCommands(List Commands) { + this.Commands = Commands; + } + + public List getCommands() { + return this.Commands; + } + + public void setRequiredJobs(HashMap RequiredJobs) { + this.RequiredJobs = RequiredJobs; + } + + public HashMap getRequiredJobs() { + return this.RequiredJobs; + } + + public void setRequiredPerm(List RequiredPerm) { + this.RequiredPerm = RequiredPerm; + } + + public List getRequiredPerm() { + return this.RequiredPerm; + } + + public void setHideWithoutPerm(boolean HideWithoutPerm) { + this.HideWithoutPerm = HideWithoutPerm; + } + + public boolean isHideWithoutPerm() { + return this.HideWithoutPerm; + } + + public void setIconLore(List IconLore) { + this.IconLore = IconLore; + } + + public List getIconLore() { + return this.IconLore; + } + + public String getNodeName() { + return this.NodeName; + } + + public int getIconId() { + return this.IconId; + } + + public int getIconData() { + return this.IconData; + } + + public void setIconData(int IconData) { + this.IconData = IconData; + } + + public double getPrice() { + return this.price; + } + + public void setIconAmount(int IconAmount) { + this.IconAmount = IconAmount; + } + + public int getIconAmount() { + return this.IconAmount; + } + + public void setIconName(String IconName) { + this.IconName = IconName; + } + + public String getIconName() { + return this.IconName; + } + + public int getRequiredTotalLevels() { + return RequiredTotalLevels; + } + + public void setRequiredTotalLevels(int requiredTotalLevels) { + RequiredTotalLevels = requiredTotalLevels; + } +} diff --git a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 3e8f1951..e8e92545 100644 --- a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -84,7 +84,6 @@ import com.gamingmesh.jobs.container.FastPayment; import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.stuff.ChatColor; -import com.gamingmesh.jobs.stuff.Debug; import com.google.common.base.Objects; public class JobsPaymentListener implements Listener {