mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-16 13:11:19 +01:00
Shop can be used with Vault economy.
Point price is optional for shop items Price renamed to pointPrice, old format still works
This commit is contained in:
parent
edb1d5d2e7
commit
2165e1fe68
@ -1,5 +1,9 @@
|
|||||||
package com.gamingmesh.jobs.commands.list;
|
package com.gamingmesh.jobs.commands.list;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -15,47 +19,48 @@ public class clearownership implements Cmd {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
||||||
JobsPlayer jPlayer = null;
|
JobsPlayer jPlayer = null;
|
||||||
String location = null;
|
String location = null;
|
||||||
|
|
||||||
for (String one : args) {
|
for (String one : args) {
|
||||||
|
|
||||||
if (!one.contains(":") && jPlayer == null && !sender.getName().equalsIgnoreCase(one) && Jobs.hasPermission(sender, "jobs.command.admin.clearownership", true)) {
|
if (!one.contains(":") && jPlayer == null && !sender.getName().equalsIgnoreCase(one) && Jobs.hasPermission(sender, "jobs.command.admin.clearownership", true)) {
|
||||||
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
|
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
|
||||||
if (jPlayer != null)
|
if (jPlayer != null)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (one.contains(":") && location == null) {
|
if (one.contains(":") && location == null) {
|
||||||
location = one;
|
location = one;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jPlayer==null && sender instanceof Player)
|
if (jPlayer == null && sender instanceof Player)
|
||||||
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
|
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
|
||||||
|
|
||||||
if (jPlayer == null) {
|
if (jPlayer == null) {
|
||||||
if (args.length >= 1)
|
if (args.length >= 1)
|
||||||
CMIMessages.sendMessage(sender, LC.info_NoInformation);
|
CMIMessages.sendMessage(sender, LC.info_NoInformation);
|
||||||
else
|
else
|
||||||
Jobs.getCommandManager().sendUsage(sender, "clearownership");
|
Jobs.getCommandManager().sendUsage(sender, "clearownership");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final JobsPlayer jp = jPlayer;
|
final UUID uuid = jPlayer.getUniqueId();
|
||||||
final java.util.Map<BlockTypes, Integer> amounts = new java.util.WeakHashMap<>();
|
final Map<BlockTypes, Integer> amounts = new WeakHashMap<>();
|
||||||
for (BlockTypes type : BlockTypes.values()) {
|
|
||||||
|
|
||||||
if (location == null)
|
String l = location;
|
||||||
plugin.getBlockOwnerShip(type).ifPresent(ownerShip -> amounts.put(type, ownerShip.clear(jp.getUniqueId())));
|
|
||||||
else {
|
|
||||||
String l = location;
|
|
||||||
plugin.getBlockOwnerShip(type).ifPresent(ownerShip -> amounts.put(type, ownerShip.remove(jp.getUniqueId(), l)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.clearownership.output.cleared", "[furnaces]", amounts.getOrDefault(BlockTypes.FURNACE, 0), "[brewing]", amounts.getOrDefault(
|
for (BlockTypes type : BlockTypes.values()) {
|
||||||
BlockTypes.BREWING_STAND, 0), "[smoker]", amounts.getOrDefault(BlockTypes.SMOKER, 0), "[blast]", amounts.getOrDefault(BlockTypes.BLAST_FURNACE, 0)));
|
if (location == null)
|
||||||
return true;
|
plugin.getBlockOwnerShip(type).ifPresent(ownerShip -> amounts.put(type, ownerShip.clear(uuid)));
|
||||||
|
else {
|
||||||
|
plugin.getBlockOwnerShip(type).ifPresent(ownerShip -> amounts.put(type, ownerShip.remove(uuid, l)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.clearownership.output.cleared", "[furnaces]", amounts.getOrDefault(BlockTypes.FURNACE, 0), "[brewing]", amounts.getOrDefault(
|
||||||
|
BlockTypes.BREWING_STAND, 0), "[smoker]", amounts.getOrDefault(BlockTypes.SMOKER, 0), "[blast]", amounts.getOrDefault(BlockTypes.BLAST_FURNACE, 0)));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,8 +301,11 @@ public class LanguageManager {
|
|||||||
c.get("command.shop.help.info", "Opens special jobs shop.");
|
c.get("command.shop.help.info", "Opens special jobs shop.");
|
||||||
c.get("command.shop.help.args", "");
|
c.get("command.shop.help.args", "");
|
||||||
c.get("command.shop.info.title", "&e------- &8Jobs shop &e-------");
|
c.get("command.shop.info.title", "&e------- &8Jobs shop &e-------");
|
||||||
c.get("command.shop.info.currentPoints", "&eYou have: &6%currentpoints%");
|
|
||||||
c.get("command.shop.info.price", "&ePrice: &6%price%");
|
c.get("command.shop.info.haveColor", "&2");
|
||||||
|
c.get("command.shop.info.pointsPrice", "&ePoint cost: &c%currentpoints%&e/&6%price%");
|
||||||
|
c.get("command.shop.info.moneyPrice", "&eMoney cost: &c%currentbalance%&e/&6%price%");
|
||||||
|
|
||||||
c.get("command.shop.info.reqJobs", "&eRequired jobs:");
|
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.reqJobsList", " &6%jobsname%&e: &e%level% lvl");
|
||||||
c.get("command.shop.info.reqTotalLevel", "&6Required total level: &e%totalLevel%");
|
c.get("command.shop.info.reqTotalLevel", "&6Required total level: &e%totalLevel%");
|
||||||
@ -312,8 +315,9 @@ public class LanguageManager {
|
|||||||
c.get("command.shop.info.cantOpen", "&cCan't open this page");
|
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.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.NoPermToBuy", "&cNo permissions to buy this item");
|
||||||
c.get("command.shop.info.NoJobReqForitem", "&cYou don't have the required job (&6%jobname%&e) with required (&6%joblevel%&e) level");
|
c.get("command.shop.info.NoJobReqForitem", "&cYou don't have the required job (&6%jobname%&c) with required (&6%joblevel%&c) level");
|
||||||
c.get("command.shop.info.NoPoints", "&cYou don't have enough points");
|
c.get("command.shop.info.NoPoints", "&cYou don't have enough points");
|
||||||
|
c.get("command.shop.info.NoMoney", "&cYou don't have enough money");
|
||||||
c.get("command.shop.info.NoTotalLevel", "&cTotal jobs level is too low (%totalLevel%)");
|
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.Paid", "&eYou have paid &6%amount% &efor this item");
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ import net.Zrips.CMILib.GUI.GUIManager.GUIClickType;
|
|||||||
import net.Zrips.CMILib.GUI.GUIManager.GUIRows;
|
import net.Zrips.CMILib.GUI.GUIManager.GUIRows;
|
||||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||||
import net.Zrips.CMILib.Locale.LC;
|
import net.Zrips.CMILib.Locale.LC;
|
||||||
|
import net.Zrips.CMILib.Messages.CMIMessages;
|
||||||
import net.Zrips.CMILib.Version.Version;
|
import net.Zrips.CMILib.Version.Version;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@ -47,426 +48,455 @@ public class ShopManager {
|
|||||||
private final List<ShopItem> list = new ArrayList<>();
|
private final List<ShopItem> list = new ArrayList<>();
|
||||||
|
|
||||||
public List<ShopItem> getShopItemList() {
|
public List<ShopItem> getShopItemList() {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ShopItem> getItemsByPage(int page) {
|
private List<ShopItem> getItemsByPage(int page) {
|
||||||
List<ShopItem> ls = new ArrayList<>();
|
List<ShopItem> ls = new ArrayList<>();
|
||||||
for (ShopItem one : list) {
|
for (ShopItem one : list) {
|
||||||
if (one.getPage() == page)
|
if (one.getPage() == page)
|
||||||
ls.add(one);
|
ls.add(one);
|
||||||
}
|
}
|
||||||
return ls;
|
return ls;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static GUIRows getGuiSize(List<ShopItem> ls, @Deprecated int page) {
|
private static GUIRows getGuiSize(List<ShopItem> ls, @Deprecated int page) {
|
||||||
GUIRows guiSize = GUIRows.r6;
|
GUIRows guiSize = GUIRows.r6;
|
||||||
int size = ls.size();
|
int size = ls.size();
|
||||||
|
|
||||||
if (size <= 9)
|
if (size <= 9)
|
||||||
guiSize = GUIRows.r1;
|
guiSize = GUIRows.r1;
|
||||||
else if (size <= 18)
|
else if (size <= 18)
|
||||||
guiSize = GUIRows.r2;
|
guiSize = GUIRows.r2;
|
||||||
else if (size <= 27)
|
else if (size <= 27)
|
||||||
guiSize = GUIRows.r3;
|
guiSize = GUIRows.r3;
|
||||||
else if (size <= 36)
|
else if (size <= 36)
|
||||||
guiSize = GUIRows.r4;
|
guiSize = GUIRows.r4;
|
||||||
else if (size <= 45)
|
else if (size <= 45)
|
||||||
guiSize = GUIRows.r5;
|
guiSize = GUIRows.r5;
|
||||||
|
|
||||||
if (Jobs.getShopManager().getShopItemList().size() > 45)
|
|
||||||
guiSize = GUIRows.r6;
|
|
||||||
|
|
||||||
return guiSize;
|
if (Jobs.getShopManager().getShopItemList().size() > 45)
|
||||||
|
guiSize = GUIRows.r6;
|
||||||
|
|
||||||
|
return guiSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getPrevButtonSlot(int guiSize, int page) {
|
private static int getPrevButtonSlot(int guiSize, int page) {
|
||||||
return page > 1 ? guiSize - 9 : -1;
|
return page > 1 ? guiSize - 9 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getNextButtonSlot(int guiSize, int page) {
|
private int getNextButtonSlot(int guiSize, int page) {
|
||||||
return !getItemsByPage(page + 1).isEmpty() ? guiSize - 1 : -1;
|
return !getItemsByPage(page + 1).isEmpty() ? guiSize - 1 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean openShopGui(Player player, int page) {
|
public boolean openShopGui(Player player, int page) {
|
||||||
List<ShopItem> ls = getItemsByPage(page);
|
List<ShopItem> ls = getItemsByPage(page);
|
||||||
if (ls.isEmpty()) {
|
if (ls.isEmpty()) {
|
||||||
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.cantOpen"));
|
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.cantOpen"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GUIRows guiSize = getGuiSize(ls, page);
|
GUIRows guiSize = getGuiSize(ls, page);
|
||||||
|
|
||||||
CMIGui gui = new CMIGui(player);
|
CMIGui gui = new CMIGui(player);
|
||||||
gui.setInvSize(guiSize);
|
gui.setInvSize(guiSize);
|
||||||
gui.setTitle(Jobs.getLanguage().getMessage("command.shop.info.title"));
|
gui.setTitle(Jobs.getLanguage().getMessage("command.shop.info.title"));
|
||||||
|
|
||||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||||
|
|
||||||
double points = (int) (jPlayer.getPointsData().getCurrentPoints() * 100.0) / 100.0;
|
double points = (int) (jPlayer.getPointsData().getCurrentPoints() * 100.0) / 100.0;
|
||||||
|
|
||||||
for (int i = 0; i < ls.size(); i++) {
|
double balance = Jobs.getEconomy().getEconomy().getBalance(player);
|
||||||
ShopItem item = ls.get(i);
|
|
||||||
List<String> lore = new ArrayList<>();
|
|
||||||
CMIMaterial mat = CMIMaterial.get(item.getIconMaterial());
|
|
||||||
|
|
||||||
if (item.isHideWithoutPerm()) {
|
for (int i = 0; i < ls.size(); i++) {
|
||||||
for (String onePerm : item.getRequiredPerm()) {
|
ShopItem item = ls.get(i);
|
||||||
if (!player.hasPermission(onePerm)) {
|
List<String> lore = new ArrayList<>();
|
||||||
mat = CMIMaterial.STONE_BUTTON;
|
CMIMaterial mat = CMIMaterial.get(item.getIconMaterial());
|
||||||
lore.add(Jobs.getLanguage().getMessage("command.shop.info.NoPermToBuy"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.isHideIfNoEnoughPoints() && item.getRequiredTotalLevels() != -1 &&
|
if (item.isHideWithoutPerm()) {
|
||||||
jPlayer.getTotalLevels() < item.getRequiredTotalLevels()) {
|
for (String onePerm : item.getRequiredPerm()) {
|
||||||
mat = CMIMaterial.STONE_BUTTON;
|
if (!player.hasPermission(onePerm)) {
|
||||||
lore.add(Jobs.getLanguage().getMessage("command.shop.info.NoPoints"));
|
mat = CMIMaterial.STONE_BUTTON;
|
||||||
}
|
lore.add(Jobs.getLanguage().getMessage("command.shop.info.NoPermToBuy"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mat == CMIMaterial.NONE)
|
if (item.isHideIfNoEnoughPoints() && item.getRequiredTotalLevels() != -1 &&
|
||||||
mat = CMIMaterial.STONE_BUTTON;
|
jPlayer.getTotalLevels() < item.getRequiredTotalLevels()) {
|
||||||
|
mat = CMIMaterial.STONE_BUTTON;
|
||||||
|
lore.add(Jobs.getLanguage().getMessage("command.shop.info.NoPoints"));
|
||||||
|
}
|
||||||
|
|
||||||
ItemStack guiItem = mat.newItemStack();
|
if (mat == CMIMaterial.NONE)
|
||||||
ItemMeta meta = guiItem.getItemMeta();
|
mat = CMIMaterial.STONE_BUTTON;
|
||||||
if (meta == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
guiItem.setAmount(item.getIconAmount());
|
ItemStack guiItem = mat.newItemStack();
|
||||||
|
ItemMeta meta = guiItem.getItemMeta();
|
||||||
|
if (meta == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (item.getIconName() != null)
|
guiItem.setAmount(item.getIconAmount());
|
||||||
meta.setDisplayName(item.getIconName());
|
|
||||||
|
|
||||||
lore.addAll(item.getIconLore());
|
if (item.getIconName() != null)
|
||||||
|
meta.setDisplayName(item.getIconName());
|
||||||
|
|
||||||
lore.add(Jobs.getLanguage().getMessage("command.shop.info.currentPoints", "%currentpoints%", points));
|
lore.addAll(item.getIconLore());
|
||||||
lore.add(Jobs.getLanguage().getMessage("command.shop.info.price", "%price%", item.getPrice()));
|
|
||||||
|
|
||||||
if (!item.getRequiredJobs().isEmpty()) {
|
if (item.getPointPrice() > 0) {
|
||||||
lore.add(Jobs.getLanguage().getMessage("command.shop.info.reqJobs"));
|
String color = item.getPointPrice() >= points ? "" : Jobs.getLanguage().getMessage("command.shop.info.haveColor");
|
||||||
|
lore.add(Jobs.getLanguage().getMessage("command.shop.info.pointsPrice", "%currentpoints%", color + points, "%price%", item.getPointPrice()));
|
||||||
|
}
|
||||||
|
|
||||||
for (Entry<String, Integer> one : item.getRequiredJobs().entrySet()) {
|
if (item.getVaultPrice() > 0) {
|
||||||
Job job = Jobs.getJob(one.getKey());
|
String color = item.getVaultPrice() >= balance ? "" : Jobs.getLanguage().getMessage("command.shop.info.haveColor");
|
||||||
if (job == null) {
|
lore.add(Jobs.getLanguage().getMessage("command.shop.info.moneyPrice", "%currentbalance%", color + Jobs.getEconomy().getEconomy().format(balance), "%price%", item.getVaultPrice()));
|
||||||
continue;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
String jobColor = "";
|
if (!item.getRequiredJobs().isEmpty()) {
|
||||||
String levelColor = "";
|
lore.add(Jobs.getLanguage().getMessage("command.shop.info.reqJobs"));
|
||||||
|
|
||||||
JobProgression prog = jPlayer.getJobProgression(job);
|
for (Entry<String, Integer> one : item.getRequiredJobs().entrySet()) {
|
||||||
if (prog == null) {
|
Job job = Jobs.getJob(one.getKey());
|
||||||
jobColor = Jobs.getLanguage().getMessage("command.shop.info.reqJobsColor");
|
if (job == null) {
|
||||||
levelColor = Jobs.getLanguage().getMessage("command.shop.info.reqJobsLevelColor");
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prog != null && prog.getLevel() < one.getValue())
|
String jobColor = "";
|
||||||
levelColor = Jobs.getLanguage().getMessage("command.shop.info.reqJobsLevelColor");
|
String levelColor = "";
|
||||||
|
|
||||||
lore.add(Jobs.getLanguage().getMessage("command.shop.info.reqJobsList", "%jobsname%",
|
JobProgression prog = jPlayer.getJobProgression(job);
|
||||||
jobColor + one.getKey(), "%level%", levelColor + one.getValue()));
|
if (prog == null) {
|
||||||
}
|
jobColor = Jobs.getLanguage().getMessage("command.shop.info.reqJobsColor");
|
||||||
}
|
levelColor = Jobs.getLanguage().getMessage("command.shop.info.reqJobsLevelColor");
|
||||||
|
}
|
||||||
|
|
||||||
if (item.getRequiredTotalLevels() != -1) {
|
if (prog != null && prog.getLevel() < one.getValue())
|
||||||
lore.add(Jobs.getLanguage().getMessage("command.shop.info.reqTotalLevel",
|
levelColor = Jobs.getLanguage().getMessage("command.shop.info.reqJobsLevelColor");
|
||||||
"%totalLevel%", (jPlayer.getTotalLevels() < item.getRequiredTotalLevels()
|
|
||||||
? Jobs.getLanguage().getMessage("command.shop.info.reqTotalLevelColor") : "") + item.getRequiredTotalLevels()));
|
|
||||||
}
|
|
||||||
|
|
||||||
meta.setLore(lore);
|
lore.add(Jobs.getLanguage().getMessage("command.shop.info.reqJobsList", "%jobsname%",
|
||||||
|
jobColor + one.getKey(), "%level%", levelColor + one.getValue()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (item.getCustomHead() != null) {
|
if (item.getRequiredTotalLevels() != -1) {
|
||||||
guiItem = CMIMaterial.PLAYER_HEAD.newItemStack(item.getIconAmount());
|
lore.add(Jobs.getLanguage().getMessage("command.shop.info.reqTotalLevel",
|
||||||
|
"%totalLevel%", (jPlayer.getTotalLevels() < item.getRequiredTotalLevels()
|
||||||
|
? Jobs.getLanguage().getMessage("command.shop.info.reqTotalLevelColor") : "") + item.getRequiredTotalLevels()));
|
||||||
|
}
|
||||||
|
|
||||||
SkullMeta skullMeta = (SkullMeta) guiItem.getItemMeta();
|
meta.setLore(lore);
|
||||||
if (skullMeta == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (item.getIconName() != null)
|
if (item.getCustomHead() != null) {
|
||||||
skullMeta.setDisplayName(item.getIconName());
|
guiItem = CMIMaterial.PLAYER_HEAD.newItemStack(item.getIconAmount());
|
||||||
|
|
||||||
skullMeta.setLore(lore);
|
SkullMeta skullMeta = (SkullMeta) guiItem.getItemMeta();
|
||||||
|
if (skullMeta == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (item.isHeadOwner()) {
|
if (item.getIconName() != null)
|
||||||
Util.setSkullOwner(skullMeta, jPlayer.getPlayer());
|
skullMeta.setDisplayName(item.getIconName());
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
Util.setSkullOwner(skullMeta, Bukkit.getOfflinePlayer(UUID.fromString(item.getCustomHead())));
|
|
||||||
} catch (IllegalArgumentException ex) {
|
|
||||||
Util.setSkullOwner(skullMeta, Bukkit.getOfflinePlayer(item.getCustomHead()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
guiItem.setItemMeta(skullMeta);
|
skullMeta.setLore(lore);
|
||||||
} else
|
|
||||||
guiItem.setItemMeta(meta);
|
|
||||||
|
|
||||||
gui.addButton(new CMIGuiButton(i, guiItem) {
|
if (item.isHeadOwner()) {
|
||||||
@Override
|
Util.setSkullOwner(skullMeta, jPlayer.getPlayer());
|
||||||
public void click(GUIClickType type) {
|
} else {
|
||||||
for (String onePerm : item.getRequiredPerm()) {
|
try {
|
||||||
if (!player.hasPermission(onePerm)) {
|
Util.setSkullOwner(skullMeta, Bukkit.getOfflinePlayer(UUID.fromString(item.getCustomHead())));
|
||||||
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoPermForItem"));
|
} catch (IllegalArgumentException ex) {
|
||||||
return;
|
Util.setSkullOwner(skullMeta, Bukkit.getOfflinePlayer(item.getCustomHead()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Entry<String, Integer> oneJob : item.getRequiredJobs().entrySet()) {
|
guiItem.setItemMeta(skullMeta);
|
||||||
Job tempJob = Jobs.getJob(oneJob.getKey());
|
} else
|
||||||
if (tempJob == null)
|
guiItem.setItemMeta(meta);
|
||||||
continue;
|
|
||||||
|
|
||||||
JobProgression playerJob = jPlayer.getJobProgression(tempJob);
|
CMIGuiButton button = new CMIGuiButton(i, guiItem) {
|
||||||
if (playerJob == null || playerJob.getLevel() < oneJob.getValue()) {
|
@Override
|
||||||
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoJobReqForitem",
|
public void click(GUIClickType type) {
|
||||||
"%jobname%", tempJob.getName(),
|
for (String onePerm : item.getRequiredPerm()) {
|
||||||
"%joblevel%", oneJob.getValue()));
|
if (!player.hasPermission(onePerm)) {
|
||||||
return;
|
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoPermForItem"));
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (jPlayer.getPointsData().getCurrentPoints() < item.getPrice()) {
|
for (Entry<String, Integer> oneJob : item.getRequiredJobs().entrySet()) {
|
||||||
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoPoints"));
|
Job tempJob = Jobs.getJob(oneJob.getKey());
|
||||||
return;
|
if (tempJob == null)
|
||||||
}
|
continue;
|
||||||
|
|
||||||
int totalLevels = jPlayer.getTotalLevels();
|
JobProgression playerJob = jPlayer.getJobProgression(tempJob);
|
||||||
if (item.getRequiredTotalLevels() != -1 && totalLevels < item.getRequiredTotalLevels()) {
|
if (playerJob == null || playerJob.getLevel() < oneJob.getValue()) {
|
||||||
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoTotalLevel", "%totalLevel%", totalLevels));
|
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoJobReqForitem",
|
||||||
return;
|
"%jobname%", tempJob.getName(),
|
||||||
}
|
"%joblevel%", oneJob.getValue()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (player.getInventory().firstEmpty() == -1) {
|
if (item.getPointPrice() > 0 && jPlayer.getPointsData().getCurrentPoints() < item.getPointPrice()) {
|
||||||
player.sendMessage(Jobs.getLanguage().getMessage("message.crafting.fullinventory"));
|
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoPoints"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String one : item.getCommands()) {
|
if (item.getVaultPrice() > 0 && jPlayer.getBalance() < item.getVaultPrice()) {
|
||||||
if (one.isEmpty())
|
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoMoney"));
|
||||||
continue;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (one.toLowerCase().startsWith("msg "))
|
int totalLevels = jPlayer.getTotalLevels();
|
||||||
player.sendMessage(one.substring(4, one.length()).replace("[player]", player.getName()));
|
if (item.getRequiredTotalLevels() != -1 && totalLevels < item.getRequiredTotalLevels()) {
|
||||||
else
|
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoTotalLevel", "%totalLevel%", totalLevels));
|
||||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[player]", player.getName()));
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (JobItems one : item.getitems()) {
|
if (player.getInventory().firstEmpty() == -1) {
|
||||||
GiveItem.giveItemForPlayer(player, one.getItemStack(player));
|
player.sendMessage(Jobs.getLanguage().getMessage("message.crafting.fullinventory"));
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
jPlayer.getPointsData().takePoints(item.getPrice());
|
for (String one : item.getCommands()) {
|
||||||
Jobs.getJobsDAO().savePoints(jPlayer);
|
if (one.isEmpty())
|
||||||
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.Paid", "%amount%", item.getPrice()));
|
continue;
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack item = new ItemStack(Material.ARROW);
|
if (one.toLowerCase().startsWith("msg "))
|
||||||
ItemMeta meta = item.getItemMeta();
|
player.sendMessage(one.substring(4, one.length()).replace("[player]", player.getName()));
|
||||||
if (meta == null)
|
else
|
||||||
return false;
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[player]", player.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
int prevSlot = getPrevButtonSlot(guiSize.getFields(), page);
|
for (JobItems one : item.getitems()) {
|
||||||
if (prevSlot != -1 && page > 1) {
|
GiveItem.giveItemForPlayer(player, one.getItemStack(player));
|
||||||
meta.setDisplayName(LC.info_prevPage.getLocale());
|
}
|
||||||
item.setItemMeta(meta);
|
|
||||||
|
|
||||||
gui.addButton(new CMIGuiButton(prevSlot, item) {
|
if (item.getPointPrice() > 0) {
|
||||||
@Override
|
jPlayer.getPointsData().takePoints(item.getPointPrice());
|
||||||
public void click(GUIClickType type) {
|
Jobs.getJobsDAO().savePoints(jPlayer);
|
||||||
openShopGui(player, page - 1);
|
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.Paid", "%amount%", item.getPointPrice()));
|
||||||
}
|
}
|
||||||
});
|
if (item.getVaultPrice() > 0) {
|
||||||
}
|
jPlayer.withdraw(item.getPointPrice());
|
||||||
|
player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.Paid", "%amount%", Jobs.getEconomy().getEconomy().format(item.getVaultPrice())));
|
||||||
|
}
|
||||||
|
openShopGui(player, page);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
button.hideItemFlags();
|
||||||
|
gui.addButton(button);
|
||||||
|
}
|
||||||
|
|
||||||
int nextSlot = getNextButtonSlot(guiSize.getFields(), page);
|
ItemStack item = new ItemStack(Material.ARROW);
|
||||||
if (nextSlot != -1 && !getItemsByPage(page + 1).isEmpty()) {
|
ItemMeta meta = item.getItemMeta();
|
||||||
meta.setDisplayName(LC.info_nextPage.getLocale());
|
if (meta == null)
|
||||||
item.setItemMeta(meta);
|
return false;
|
||||||
gui.addButton(new CMIGuiButton(nextSlot, item) {
|
|
||||||
@Override
|
|
||||||
public void click(GUIClickType type) {
|
|
||||||
openShopGui(player, page + 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
gui.fillEmptyButtons();
|
int prevSlot = getPrevButtonSlot(guiSize.getFields(), page);
|
||||||
gui.open();
|
if (prevSlot != -1 && page > 1) {
|
||||||
return true;
|
meta.setDisplayName(LC.info_prevPage.getLocale());
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
|
||||||
|
gui.addButton(new CMIGuiButton(prevSlot, item) {
|
||||||
|
@Override
|
||||||
|
public void click(GUIClickType type) {
|
||||||
|
openShopGui(player, page - 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
int nextSlot = getNextButtonSlot(guiSize.getFields(), page);
|
||||||
|
if (nextSlot != -1 && !getItemsByPage(page + 1).isEmpty()) {
|
||||||
|
meta.setDisplayName(LC.info_nextPage.getLocale());
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
gui.addButton(new CMIGuiButton(nextSlot, item) {
|
||||||
|
@Override
|
||||||
|
public void click(GUIClickType type) {
|
||||||
|
openShopGui(player, page + 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
gui.fillEmptyButtons();
|
||||||
|
gui.open();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load() {
|
public void load() {
|
||||||
list.clear();
|
list.clear();
|
||||||
|
|
||||||
YamlConfiguration f = YamlConfiguration.loadConfiguration(new File(Jobs.getFolder(), "shopItems.yml"));
|
YamlConfiguration f = YamlConfiguration.loadConfiguration(new File(Jobs.getFolder(), "shopItems.yml"));
|
||||||
ConfigurationSection confCategory = f.getConfigurationSection("Items");
|
ConfigurationSection confCategory = f.getConfigurationSection("Items");
|
||||||
if (confCategory == null)
|
if (confCategory == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
java.util.Set<String> categories = confCategory.getKeys(false);
|
java.util.Set<String> categories = confCategory.getKeys(false);
|
||||||
if (categories.isEmpty()) {
|
if (categories.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int y = 1;
|
int y = 1;
|
||||||
|
|
||||||
for (String category : new ArrayList<>(categories)) {
|
for (String category : new ArrayList<>(categories)) {
|
||||||
ConfigurationSection nameSection = confCategory.getConfigurationSection(category);
|
ConfigurationSection nameSection = confCategory.getConfigurationSection(category);
|
||||||
if (nameSection == null) {
|
if (nameSection == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nameSection.isDouble("Price")) {
|
double pointPrice = nameSection.getDouble("Price", nameSection.getDouble("pointPrice", 0D));
|
||||||
Jobs.getPluginLogger().severe("Shop item " + category + " has an invalid Price property. Skipping!");
|
double vaultPrice = nameSection.getDouble("vaultPrice", 0D);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ShopItem sItem = new ShopItem(category, nameSection.getDouble("Price"));
|
ShopItem sItem = new ShopItem(category);
|
||||||
|
|
||||||
if (nameSection.isString("Icon.Id"))
|
if (pointPrice <= 0 && vaultPrice <= 0) {
|
||||||
sItem.setIconMaterial(nameSection.getString("Icon.Id"));
|
CMIMessages.consoleMessage("&eShop item " + category + " has an invalid Price property. Skipping!");
|
||||||
else {
|
continue;
|
||||||
Jobs.getPluginLogger().severe("Shop item " + category + " has an invalid Icon name property. Skipping!");
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
sItem.setIconAmount(nameSection.getInt("Icon.Amount", 1));
|
sItem.setPointPrice(pointPrice);
|
||||||
sItem.setIconName(CMIChatColor.translate(nameSection.getString("Icon.Name")));
|
sItem.setVaultPrice(vaultPrice);
|
||||||
|
|
||||||
List<String> lore = nameSection.getStringList("Icon.Lore");
|
if (nameSection.isString("Icon.Id"))
|
||||||
for (int b = 0; b < lore.size(); b++) {
|
sItem.setIconMaterial(nameSection.getString("Icon.Id"));
|
||||||
lore.set(b, CMIChatColor.translate(lore.get(b)));
|
else {
|
||||||
}
|
Jobs.getPluginLogger().severe("Shop item " + category + " has an invalid Icon name property. Skipping!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
sItem.setIconLore(lore);
|
sItem.setIconAmount(nameSection.getInt("Icon.Amount", 1));
|
||||||
|
sItem.setIconName(CMIChatColor.translate(nameSection.getString("Icon.Name")));
|
||||||
|
|
||||||
if (nameSection.isString("Icon.CustomHead.PlayerName"))
|
List<String> lore = nameSection.getStringList("Icon.Lore");
|
||||||
sItem.setCustomHead(nameSection.getString("Icon.CustomHead.PlayerName"));
|
for (int b = 0; b < lore.size(); b++) {
|
||||||
|
lore.set(b, CMIChatColor.translate(lore.get(b)));
|
||||||
|
}
|
||||||
|
|
||||||
sItem.setCustomHeadOwner(nameSection.getBoolean("Icon.CustomHead.UseCurrentPlayer", true));
|
sItem.setIconLore(lore);
|
||||||
sItem.setHideIfThereIsNoEnoughPoints(nameSection.getBoolean("Icon.HideIfThereIsNoEnoughPoints"));
|
|
||||||
sItem.setHideWithoutPerm(nameSection.getBoolean("Icon.HideWithoutPermission"));
|
|
||||||
sItem.setRequiredPerm(nameSection.getStringList("RequiredPermission"));
|
|
||||||
|
|
||||||
if (nameSection.isInt("RequiredTotalLevels"))
|
if (nameSection.isString("Icon.CustomHead.PlayerName"))
|
||||||
sItem.setRequiredTotalLevels(nameSection.getInt("RequiredTotalLevels"));
|
sItem.setCustomHead(nameSection.getString("Icon.CustomHead.PlayerName"));
|
||||||
|
|
||||||
if (nameSection.isList("RequiredJobLevels")) {
|
sItem.setCustomHeadOwner(nameSection.getBoolean("Icon.CustomHead.UseCurrentPlayer", true));
|
||||||
Map<String, Integer> requiredJobs = new HashMap<>();
|
sItem.setHideIfThereIsNoEnoughPoints(nameSection.getBoolean("Icon.HideIfThereIsNoEnoughPoints"));
|
||||||
|
sItem.setHideWithoutPerm(nameSection.getBoolean("Icon.HideWithoutPermission"));
|
||||||
|
sItem.setRequiredPerm(nameSection.getStringList("RequiredPermission"));
|
||||||
|
|
||||||
for (String one : nameSection.getStringList("RequiredJobLevels")) {
|
if (nameSection.isInt("RequiredTotalLevels"))
|
||||||
String[] split = one.split("-", 2);
|
sItem.setRequiredTotalLevels(nameSection.getInt("RequiredTotalLevels"));
|
||||||
if (split.length == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
int lvl = 1;
|
if (nameSection.isList("RequiredJobLevels")) {
|
||||||
if (split.length > 1) {
|
Map<String, Integer> requiredJobs = new HashMap<>();
|
||||||
try {
|
|
||||||
lvl = Integer.parseInt(split[1]);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
requiredJobs.put(split[0], lvl);
|
for (String one : nameSection.getStringList("RequiredJobLevels")) {
|
||||||
}
|
String[] split = one.split("-", 2);
|
||||||
sItem.setRequiredJobs(requiredJobs);
|
if (split.length == 0)
|
||||||
}
|
continue;
|
||||||
|
|
||||||
List<String> performCommands = nameSection.getStringList("PerformCommands");
|
int lvl = 1;
|
||||||
for (int k = 0; k < performCommands.size(); k++) {
|
if (split.length > 1) {
|
||||||
performCommands.set(k, CMIChatColor.translate(performCommands.get(k)));
|
try {
|
||||||
}
|
lvl = Integer.parseInt(split[1]);
|
||||||
sItem.setCommands(performCommands);
|
} catch (NumberFormatException e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ConfigurationSection itemsSection = nameSection.getConfigurationSection("GiveItems");
|
requiredJobs.put(split[0], lvl);
|
||||||
if (itemsSection != null) {
|
}
|
||||||
List<JobItems> items = new ArrayList<>();
|
sItem.setRequiredJobs(requiredJobs);
|
||||||
|
}
|
||||||
|
|
||||||
for (String oneItemName : itemsSection.getKeys(false)) {
|
List<String> performCommands = nameSection.getStringList("PerformCommands");
|
||||||
ConfigurationSection itemSection = itemsSection.getConfigurationSection(oneItemName);
|
for (int k = 0; k < performCommands.size(); k++) {
|
||||||
if (itemSection == null)
|
performCommands.set(k, CMIChatColor.translate(performCommands.get(k)));
|
||||||
continue;
|
}
|
||||||
|
sItem.setCommands(performCommands);
|
||||||
|
|
||||||
String id = null;
|
ConfigurationSection itemsSection = nameSection.getConfigurationSection("GiveItems");
|
||||||
if (itemSection.isString("Id"))
|
if (itemsSection != null) {
|
||||||
id = itemSection.getString("Id");
|
List<JobItems> items = new ArrayList<>();
|
||||||
else {
|
|
||||||
Jobs.getPluginLogger().severe("Shop item " + category + " has an invalid GiveItems item id property. Skipping!");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int amount = itemSection.getInt("Amount", 1);
|
for (String oneItemName : itemsSection.getKeys(false)) {
|
||||||
String name = CMIChatColor.translate(itemSection.getString("Name"));
|
ConfigurationSection itemSection = itemsSection.getConfigurationSection(oneItemName);
|
||||||
|
if (itemSection == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
List<String> giveLore = itemSection.getStringList("Lore");
|
String id = null;
|
||||||
for (int v = 0; v < giveLore.size(); v++) {
|
if (itemSection.isString("Id"))
|
||||||
giveLore.set(v, CMIChatColor.translate(giveLore.get(v)));
|
id = itemSection.getString("Id");
|
||||||
}
|
else {
|
||||||
|
Jobs.getPluginLogger().severe("Shop item " + category + " has an invalid GiveItems item id property. Skipping!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Map<Enchantment, Integer> enchants = new HashMap<>();
|
int amount = itemSection.getInt("Amount", 1);
|
||||||
for (String eachLine : itemSection.getStringList("Enchants")) {
|
String name = CMIChatColor.translate(itemSection.getString("Name"));
|
||||||
String[] split = eachLine.split("=", 2);
|
|
||||||
if (split.length == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Enchantment ench = CMIEnchantment.getEnchantment(split[0]);
|
List<String> giveLore = itemSection.getStringList("Lore");
|
||||||
if (ench == null)
|
for (int v = 0; v < giveLore.size(); v++) {
|
||||||
continue;
|
giveLore.set(v, CMIChatColor.translate(giveLore.get(v)));
|
||||||
|
}
|
||||||
|
|
||||||
Integer level = 1;
|
Map<Enchantment, Integer> enchants = new HashMap<>();
|
||||||
if (split.length > 1) {
|
for (String eachLine : itemSection.getStringList("Enchants")) {
|
||||||
try {
|
String[] split = eachLine.split("=", 2);
|
||||||
level = Integer.parseInt(split[1]);
|
if (split.length == 0)
|
||||||
} catch (NumberFormatException e) {
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enchants.put(ench, level);
|
Enchantment ench = CMIEnchantment.getEnchantment(split[0]);
|
||||||
}
|
if (ench == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
Object potionData = null;
|
Integer level = 1;
|
||||||
if (itemSection.contains("potion-type")) {
|
if (split.length > 1) {
|
||||||
PotionType type;
|
try {
|
||||||
try {
|
level = Integer.parseInt(split[1]);
|
||||||
type = PotionType.valueOf(itemSection.getString("potion-type", "speed").toUpperCase());
|
} catch (NumberFormatException e) {
|
||||||
} catch (IllegalArgumentException ex) {
|
continue;
|
||||||
type = PotionType.SPEED;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Version.isCurrentEqualOrHigher(Version.v1_10_R1)) {
|
enchants.put(ench, level);
|
||||||
potionData = new PotionData(type);
|
}
|
||||||
} else {
|
|
||||||
potionData = new Potion(type, 1, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
items.add(new JobItems(oneItemName.toLowerCase(), id == null ? CMIMaterial.STONE : CMIMaterial.get(id), amount, name, giveLore,
|
Object potionData = null;
|
||||||
enchants, new BoostMultiplier(), new ArrayList<>(), potionData, null));
|
if (itemSection.contains("potion-type")) {
|
||||||
}
|
PotionType type;
|
||||||
sItem.setitems(items);
|
try {
|
||||||
}
|
type = PotionType.valueOf(itemSection.getString("potion-type", "speed").toUpperCase());
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
type = PotionType.SPEED;
|
||||||
|
}
|
||||||
|
|
||||||
i++;
|
if (Version.isCurrentEqualOrHigher(Version.v1_10_R1)) {
|
||||||
|
potionData = new PotionData(type);
|
||||||
|
} else {
|
||||||
|
potionData = new Potion(type, 1, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (i > 45) {
|
items.add(new JobItems(oneItemName.toLowerCase(), id == null ? CMIMaterial.STONE : CMIMaterial.get(id), amount, name, giveLore,
|
||||||
i = 1;
|
enchants, new BoostMultiplier(), new ArrayList<>(), potionData, null));
|
||||||
y++;
|
}
|
||||||
}
|
sItem.setitems(items);
|
||||||
|
}
|
||||||
|
|
||||||
sItem.setSlot(i);
|
i++;
|
||||||
sItem.setPage(y);
|
|
||||||
list.add(sItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!list.isEmpty())
|
if (i > 45) {
|
||||||
Jobs.consoleMsg("&eLoaded &6" + list.size() + " &eshop items");
|
i = 1;
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
|
||||||
|
sItem.setSlot(i);
|
||||||
|
sItem.setPage(y);
|
||||||
|
list.add(sItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!list.isEmpty())
|
||||||
|
Jobs.consoleMsg("&eLoaded &6" + list.size() + " &eshop items");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -381,7 +381,7 @@ public class JobsPlayer {
|
|||||||
boostCounter.put(jobName, counterList);
|
boostCounter.put(jobName, counterList);
|
||||||
return boost;
|
return boost;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Double getPlayerBoostNew(String jobName, CurrencyType type) {
|
private Double getPlayerBoostNew(String jobName, CurrencyType type) {
|
||||||
Double v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost." + jobName + "." + type.getName(), true, false);
|
Double v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost." + jobName + "." + type.getName(), true, false);
|
||||||
Double boost = v1;
|
Double boost = v1;
|
||||||
@ -1467,4 +1467,16 @@ public class JobsPlayer {
|
|||||||
blockOwnerShipInform = new HashSet<String>();
|
blockOwnerShipInform = new HashSet<String>();
|
||||||
this.blockOwnerShipInform.add(location);
|
this.blockOwnerShipInform.add(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getBalance() {
|
||||||
|
if (this.isOnline())
|
||||||
|
return Jobs.getEconomy().getEconomy().getBalance(this.getPlayer());
|
||||||
|
return Jobs.getEconomy().getEconomy().getBalance(this.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean withdraw(double amount) {
|
||||||
|
if (this.isOnline())
|
||||||
|
return Jobs.getEconomy().getEconomy().withdrawPlayer(this.getPlayer(), amount);
|
||||||
|
return Jobs.getEconomy().getEconomy().withdrawPlayer(this.getName(), amount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,16 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class ShopItem {
|
public class ShopItem {
|
||||||
|
|
||||||
private double price = 0D;
|
private double pointPrice = 0D;
|
||||||
|
private double vaultPrice = 0D;
|
||||||
|
|
||||||
private int slot = -1, page = -1, iconAmount = 1;
|
private int slot = -1;
|
||||||
|
private int page = -1;
|
||||||
|
private int iconAmount = 1;
|
||||||
|
|
||||||
private String nodeName, iconMaterial, iconName;
|
private String nodeName;
|
||||||
|
private String iconMaterial;
|
||||||
|
private String iconName;
|
||||||
|
|
||||||
private boolean hideWithoutPerm = false;
|
private boolean hideWithoutPerm = false;
|
||||||
private boolean hideNoEnoughPoint = false;
|
private boolean hideNoEnoughPoint = false;
|
||||||
@ -20,154 +25,172 @@ public class ShopItem {
|
|||||||
|
|
||||||
private Map<String, Integer> requiredJobs = new HashMap<>();
|
private Map<String, Integer> requiredJobs = new HashMap<>();
|
||||||
|
|
||||||
private final List<String> iconLore = new ArrayList<>(), requiredPerm = new ArrayList<>(), commands = new ArrayList<>();
|
private final List<String> iconLore = new ArrayList<>();
|
||||||
|
private final List<String> requiredPerm = new ArrayList<>();
|
||||||
|
private final List<String> commands = new ArrayList<>();
|
||||||
private final List<JobItems> items = new ArrayList<>();
|
private final List<JobItems> items = new ArrayList<>();
|
||||||
|
|
||||||
private String playerName;
|
private String playerName;
|
||||||
private boolean useCurrentPlayer = false;
|
private boolean useCurrentPlayer = false;
|
||||||
|
|
||||||
public ShopItem(String nodeName, double price) {
|
public ShopItem(String nodeName) {
|
||||||
this.nodeName = nodeName;
|
this.nodeName = nodeName;
|
||||||
this.price = price;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPage(Integer page) {
|
public void setPage(Integer page) {
|
||||||
this.page = page;
|
this.page = page;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPage() {
|
public int getPage() {
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSlot(Integer slot) {
|
public void setSlot(Integer slot) {
|
||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSlot() {
|
public int getSlot() {
|
||||||
return slot;
|
return slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setitems(List<JobItems> items) {
|
public void setitems(List<JobItems> items) {
|
||||||
this.items.clear();
|
this.items.clear();
|
||||||
|
|
||||||
if (items != null)
|
if (items != null)
|
||||||
this.items.addAll(items);
|
this.items.addAll(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<JobItems> getitems() {
|
public List<JobItems> getitems() {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCommands(List<String> commands) {
|
public void setCommands(List<String> commands) {
|
||||||
this.commands.clear();
|
this.commands.clear();
|
||||||
|
|
||||||
if (commands != null)
|
if (commands != null)
|
||||||
this.commands.addAll(commands);
|
this.commands.addAll(commands);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getCommands() {
|
public List<String> getCommands() {
|
||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRequiredJobs(Map<String, Integer> requiredJobs) {
|
public void setRequiredJobs(Map<String, Integer> requiredJobs) {
|
||||||
this.requiredJobs = requiredJobs;
|
this.requiredJobs = requiredJobs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Integer> getRequiredJobs() {
|
public Map<String, Integer> getRequiredJobs() {
|
||||||
return requiredJobs;
|
return requiredJobs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRequiredPerm(List<String> requiredPerm) {
|
public void setRequiredPerm(List<String> requiredPerm) {
|
||||||
this.requiredPerm.clear();
|
this.requiredPerm.clear();
|
||||||
|
|
||||||
if (requiredPerm != null)
|
if (requiredPerm != null)
|
||||||
this.requiredPerm.addAll(requiredPerm);
|
this.requiredPerm.addAll(requiredPerm);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getRequiredPerm() {
|
public List<String> getRequiredPerm() {
|
||||||
return requiredPerm;
|
return requiredPerm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHideIfThereIsNoEnoughPoints(boolean hideNoEnoughPoint) {
|
public void setHideIfThereIsNoEnoughPoints(boolean hideNoEnoughPoint) {
|
||||||
this.hideNoEnoughPoint = hideNoEnoughPoint;
|
this.hideNoEnoughPoint = hideNoEnoughPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHideIfNoEnoughPoints() {
|
public boolean isHideIfNoEnoughPoints() {
|
||||||
return hideNoEnoughPoint;
|
return hideNoEnoughPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHideWithoutPerm(boolean hideWithoutPerm) {
|
public void setHideWithoutPerm(boolean hideWithoutPerm) {
|
||||||
this.hideWithoutPerm = hideWithoutPerm;
|
this.hideWithoutPerm = hideWithoutPerm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHideWithoutPerm() {
|
public boolean isHideWithoutPerm() {
|
||||||
return hideWithoutPerm;
|
return hideWithoutPerm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIconLore(List<String> iconLore) {
|
public void setIconLore(List<String> iconLore) {
|
||||||
this.iconLore.clear();
|
this.iconLore.clear();
|
||||||
|
|
||||||
if (iconLore != null)
|
if (iconLore != null)
|
||||||
this.iconLore.addAll(iconLore);
|
this.iconLore.addAll(iconLore);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getIconLore() {
|
public List<String> getIconLore() {
|
||||||
return iconLore;
|
return iconLore;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNodeName() {
|
public String getNodeName() {
|
||||||
return nodeName;
|
return nodeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIconMaterial() {
|
public String getIconMaterial() {
|
||||||
return iconMaterial;
|
return iconMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIconMaterial(String iconMaterial) {
|
public void setIconMaterial(String iconMaterial) {
|
||||||
this.iconMaterial = iconMaterial;
|
this.iconMaterial = iconMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public double getPrice() {
|
public double getPrice() {
|
||||||
return price;
|
return getPointPrice();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getPointPrice() {
|
||||||
|
return pointPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIconAmount(int iconAmount) {
|
public void setIconAmount(int iconAmount) {
|
||||||
this.iconAmount = iconAmount;
|
this.iconAmount = iconAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getIconAmount() {
|
public int getIconAmount() {
|
||||||
return iconAmount;
|
return iconAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIconName(String iconName) {
|
public void setIconName(String iconName) {
|
||||||
this.iconName = iconName;
|
this.iconName = iconName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIconName() {
|
public String getIconName() {
|
||||||
return iconName;
|
return iconName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRequiredTotalLevels() {
|
public int getRequiredTotalLevels() {
|
||||||
return requiredTotalLevels;
|
return requiredTotalLevels;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRequiredTotalLevels(int requiredTotalLevels) {
|
public void setRequiredTotalLevels(int requiredTotalLevels) {
|
||||||
this.requiredTotalLevels = requiredTotalLevels;
|
this.requiredTotalLevels = requiredTotalLevels;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCustomHead() {
|
public String getCustomHead() {
|
||||||
return playerName;
|
return playerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCustomHead(String playerName) {
|
public void setCustomHead(String playerName) {
|
||||||
this.playerName = playerName;
|
this.playerName = playerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHeadOwner() {
|
public boolean isHeadOwner() {
|
||||||
return useCurrentPlayer;
|
return useCurrentPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCustomHeadOwner(boolean useCurrentPlayer) {
|
public void setCustomHeadOwner(boolean useCurrentPlayer) {
|
||||||
this.useCurrentPlayer = useCurrentPlayer;
|
this.useCurrentPlayer = useCurrentPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getVaultPrice() {
|
||||||
|
return vaultPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVaultPrice(double currencyPrice) {
|
||||||
|
this.vaultPrice = currencyPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPointPrice(double pointPrice) {
|
||||||
|
this.pointPrice = pointPrice;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,36 +23,51 @@ import org.bukkit.OfflinePlayer;
|
|||||||
public class BlackholeEconomy implements Economy {
|
public class BlackholeEconomy implements Economy {
|
||||||
@Override
|
@Override
|
||||||
public boolean depositPlayer(OfflinePlayer offlinePlayer, double money) {
|
public boolean depositPlayer(OfflinePlayer offlinePlayer, double money) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean withdrawPlayer(OfflinePlayer offlinePlayer, double money) {
|
public boolean withdrawPlayer(OfflinePlayer offlinePlayer, double money) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String format(double money) {
|
public String format(double money) {
|
||||||
return String.format("$%.2f", money);
|
return String.format("$%.2f", money);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasMoney(OfflinePlayer offlinePlayer, double money) {
|
public boolean hasMoney(OfflinePlayer offlinePlayer, double money) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasMoney(String PlayerName, double money) {
|
public boolean hasMoney(String PlayerName, double money) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean withdrawPlayer(String PlayerName, double money) {
|
public boolean withdrawPlayer(String PlayerName, double money) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean depositPlayer(String PlayerName, double money) {
|
public boolean depositPlayer(String PlayerName, double money) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getBalance(OfflinePlayer offlinePlayer) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getBalance(String PlayerName) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFormatedBalance(OfflinePlayer offlinePlayer) {
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,4 +34,10 @@ public interface Economy {
|
|||||||
boolean withdrawPlayer(String PlayerName, double money);
|
boolean withdrawPlayer(String PlayerName, double money);
|
||||||
|
|
||||||
boolean depositPlayer(String PlayerName, double money);
|
boolean depositPlayer(String PlayerName, double money);
|
||||||
|
|
||||||
|
double getBalance(OfflinePlayer offlinePlayer);
|
||||||
|
|
||||||
|
double getBalance(String PlayerName);
|
||||||
|
|
||||||
|
String getFormatedBalance(OfflinePlayer offlinePlayer);
|
||||||
}
|
}
|
||||||
|
@ -25,42 +25,57 @@ public class VaultEconomy implements Economy {
|
|||||||
private net.milkbowl.vault.economy.Economy vault;
|
private net.milkbowl.vault.economy.Economy vault;
|
||||||
|
|
||||||
public VaultEconomy(net.milkbowl.vault.economy.Economy vault) {
|
public VaultEconomy(net.milkbowl.vault.economy.Economy vault) {
|
||||||
this.vault = vault;
|
this.vault = vault;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean depositPlayer(OfflinePlayer offlinePlayer, double money) {
|
public boolean depositPlayer(OfflinePlayer offlinePlayer, double money) {
|
||||||
return vault.depositPlayer(offlinePlayer, money).transactionSuccess();
|
return vault.depositPlayer(offlinePlayer, money).transactionSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean depositPlayer(String PlayerName, double money) {
|
public boolean depositPlayer(String PlayerName, double money) {
|
||||||
return vault.depositPlayer(PlayerName, money).transactionSuccess();
|
return vault.depositPlayer(PlayerName, money).transactionSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean withdrawPlayer(OfflinePlayer offlinePlayer, double money) {
|
public boolean withdrawPlayer(OfflinePlayer offlinePlayer, double money) {
|
||||||
return vault.withdrawPlayer(offlinePlayer, money).transactionSuccess();
|
return vault.withdrawPlayer(offlinePlayer, money).transactionSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean withdrawPlayer(String PlayerName, double money) {
|
public boolean withdrawPlayer(String PlayerName, double money) {
|
||||||
return vault.withdrawPlayer(PlayerName, money).transactionSuccess();
|
return vault.withdrawPlayer(PlayerName, money).transactionSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasMoney(OfflinePlayer offlinePlayer, double money) {
|
public boolean hasMoney(OfflinePlayer offlinePlayer, double money) {
|
||||||
return offlinePlayer.getName() != null && vault.has(offlinePlayer, money);
|
return offlinePlayer.getName() != null && vault.has(offlinePlayer, money);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasMoney(String PlayerName, double money) {
|
public boolean hasMoney(String PlayerName, double money) {
|
||||||
return vault.has(PlayerName, money);
|
return vault.has(PlayerName, money);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String format(double money) {
|
public String format(double money) {
|
||||||
return vault.format(money);
|
return vault.format(money);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getBalance(OfflinePlayer offlinePlayer) {
|
||||||
|
return vault.getBalance(offlinePlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getBalance(String PlayerName) {
|
||||||
|
return vault.getBalance(PlayerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFormatedBalance(OfflinePlayer offlinePlayer) {
|
||||||
|
return format(getBalance(offlinePlayer));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
Items:
|
Items:
|
||||||
SuperPickAxe:
|
SuperPickAxe:
|
||||||
# (REQUIRED) Item price in Jobs Points
|
# (Optional) Item price in Jobs Points
|
||||||
Price: 10000.0
|
pointPrice: 10000.0
|
||||||
|
# (Optional) Item price in Vault economy currency.
|
||||||
|
# Atleast one type of currency needs to be defined
|
||||||
|
vaultPrice: 10000.0
|
||||||
Icon:
|
Icon:
|
||||||
# (REQUIRED) Icon item
|
# (REQUIRED) Icon item
|
||||||
Id: diamond_pickaxe
|
Id: diamond_pickaxe
|
||||||
@ -66,7 +69,7 @@ Items:
|
|||||||
# (Required) Item name
|
# (Required) Item name
|
||||||
Id: apple
|
Id: apple
|
||||||
WoodenShovel:
|
WoodenShovel:
|
||||||
Price: 100.0
|
pointPrice: 100.0
|
||||||
Icon:
|
Icon:
|
||||||
Id: wooden_shovel
|
Id: wooden_shovel
|
||||||
Name: "&eWooden shovel"
|
Name: "&eWooden shovel"
|
||||||
@ -79,7 +82,7 @@ Items:
|
|||||||
- "msg &eThanks [player] for buying this shovel!"
|
- "msg &eThanks [player] for buying this shovel!"
|
||||||
- "give [player] wooden_shovel 1"
|
- "give [player] wooden_shovel 1"
|
||||||
LureEnchantBook:
|
LureEnchantBook:
|
||||||
Price: 100.0
|
pointPrice: 100.0
|
||||||
Icon:
|
Icon:
|
||||||
Id: enchanted_book
|
Id: enchanted_book
|
||||||
Name: "&eEnchant book"
|
Name: "&eEnchant book"
|
||||||
@ -98,7 +101,7 @@ Items:
|
|||||||
Enchants:
|
Enchants:
|
||||||
- LURE=3
|
- LURE=3
|
||||||
Elytra:
|
Elytra:
|
||||||
Price: 100000.0
|
pointPrice: 100000.0
|
||||||
Icon:
|
Icon:
|
||||||
Id: elytra
|
Id: elytra
|
||||||
Name: "&eAngel wings"
|
Name: "&eAngel wings"
|
||||||
|
Loading…
Reference in New Issue
Block a user