mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-26 04:25:15 +01:00
Add optional requirement for jobs shop items by RequiredTotalLevels
This commit is contained in:
parent
75a5ff8c53
commit
6e9da41829
@ -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);
|
||||
|
@ -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");
|
||||
|
||||
|
@ -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<String, Integer> RequiredJobs = new HashMap<String, Integer>();
|
||||
for (String one : NameSection.getStringList("RequiredJobLevels")) {
|
||||
|
@ -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"));
|
||||
|
@ -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<String> IconLore = new ArrayList<String>();
|
||||
|
||||
private boolean HideWithoutPerm = false;
|
||||
|
||||
private List<String> RequiredPerm = new ArrayList<String>();
|
||||
private HashMap<String, Integer> RequiredJobs = new HashMap<String, Integer>();
|
||||
|
||||
private List<String> Commands = new ArrayList<String>();
|
||||
|
||||
private List<JobItems> items = new ArrayList<JobItems>();
|
||||
|
||||
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<JobItems> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public List<JobItems> getitems() {
|
||||
return this.items;
|
||||
}
|
||||
|
||||
public void setCommands(List<String> Commands) {
|
||||
this.Commands = Commands;
|
||||
}
|
||||
|
||||
public List<String> getCommands() {
|
||||
return this.Commands;
|
||||
}
|
||||
|
||||
public void setRequiredJobs(HashMap<String, Integer> RequiredJobs) {
|
||||
this.RequiredJobs = RequiredJobs;
|
||||
}
|
||||
|
||||
public HashMap<String, Integer> getRequiredJobs() {
|
||||
return this.RequiredJobs;
|
||||
}
|
||||
|
||||
public void setRequiredPerm(List<String> RequiredPerm) {
|
||||
this.RequiredPerm = RequiredPerm;
|
||||
}
|
||||
|
||||
public List<String> getRequiredPerm() {
|
||||
return this.RequiredPerm;
|
||||
}
|
||||
|
||||
public void setHideWithoutPerm(boolean HideWithoutPerm) {
|
||||
this.HideWithoutPerm = HideWithoutPerm;
|
||||
}
|
||||
|
||||
public boolean isHideWithoutPerm() {
|
||||
return this.HideWithoutPerm;
|
||||
}
|
||||
|
||||
public void setIconLore(List<String> IconLore) {
|
||||
this.IconLore = IconLore;
|
||||
}
|
||||
|
||||
public List<String> 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<String> IconLore = new ArrayList<String>();
|
||||
|
||||
private boolean HideWithoutPerm = false;
|
||||
private int RequiredTotalLevels = -1;
|
||||
|
||||
private List<String> RequiredPerm = new ArrayList<String>();
|
||||
private HashMap<String, Integer> RequiredJobs = new HashMap<String, Integer>();
|
||||
|
||||
private List<String> Commands = new ArrayList<String>();
|
||||
|
||||
private List<JobItems> items = new ArrayList<JobItems>();
|
||||
|
||||
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<JobItems> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public List<JobItems> getitems() {
|
||||
return this.items;
|
||||
}
|
||||
|
||||
public void setCommands(List<String> Commands) {
|
||||
this.Commands = Commands;
|
||||
}
|
||||
|
||||
public List<String> getCommands() {
|
||||
return this.Commands;
|
||||
}
|
||||
|
||||
public void setRequiredJobs(HashMap<String, Integer> RequiredJobs) {
|
||||
this.RequiredJobs = RequiredJobs;
|
||||
}
|
||||
|
||||
public HashMap<String, Integer> getRequiredJobs() {
|
||||
return this.RequiredJobs;
|
||||
}
|
||||
|
||||
public void setRequiredPerm(List<String> RequiredPerm) {
|
||||
this.RequiredPerm = RequiredPerm;
|
||||
}
|
||||
|
||||
public List<String> getRequiredPerm() {
|
||||
return this.RequiredPerm;
|
||||
}
|
||||
|
||||
public void setHideWithoutPerm(boolean HideWithoutPerm) {
|
||||
this.HideWithoutPerm = HideWithoutPerm;
|
||||
}
|
||||
|
||||
public boolean isHideWithoutPerm() {
|
||||
return this.HideWithoutPerm;
|
||||
}
|
||||
|
||||
public void setIconLore(List<String> IconLore) {
|
||||
this.IconLore = IconLore;
|
||||
}
|
||||
|
||||
public List<String> 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;
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user