mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-02 14:29:07 +01:00
parent
a8dd65cb4b
commit
b1b39a789d
@ -103,7 +103,7 @@ public class GeneralConfigManager {
|
||||
BossBarEnabled, BossBarShowOnEachAction, BossBarsMessageByDefault, ExploreCompact, DBCleaningJobsUse, DBCleaningUsersUse,
|
||||
DisabledWorldsUse, UseAsWhiteListWorldList, PaymentMethodsMoney, PaymentMethodsPoints, PaymentMethodsExp, MythicMobsEnabled,
|
||||
LoggingUse, payForCombiningItems, BlastFurnacesReassign = false, SmokerReassign = false, payForStackedEntities,
|
||||
payForEachVTradeItem, titleMessageMaxLevelReached;
|
||||
payForEachVTradeItem, titleMessageMaxLevelReached, allowEnchantingBoostedItems;
|
||||
|
||||
public ItemStack guiBackButton, guiNextButton, guiFiller;
|
||||
|
||||
@ -716,6 +716,9 @@ public class GeneralConfigManager {
|
||||
c.addComment("Economy.Enchant.PayForEnchantingOnAnvil", "Do you want to give money for enchanting items in anvil?");
|
||||
PayForEnchantingOnAnvil = c.get("Economy.Enchant.PayForEnchantingOnAnvil", false);
|
||||
|
||||
c.addComment("Economy.Enchant.AllowEnchantingBoostedItems", "Do you want to allow players to enchant their boosted items?");
|
||||
allowEnchantingBoostedItems = c.get("Economy.Enchant.AllowEnchantingBoostedItems", true);
|
||||
|
||||
c.addComment("Economy.Crafting.PayForEachCraft",
|
||||
"With this true, player will get money for all crafted items instead of each crafting action (like with old payment mechanic)",
|
||||
"By default its false, as you can make ALOT of money if prices kept from old payment mechanics");
|
||||
|
@ -45,36 +45,34 @@ public class JobItems {
|
||||
|
||||
public JobItems(String node, CMIMaterial mat, int amount, String name, List<String> lore, HashMap<Enchantment, Integer> enchants, BoostMultiplier boostMultiplier, List<Job> jobs) {
|
||||
mat = mat == null ? CMIMaterial.STONE : mat;
|
||||
try {
|
||||
this.enchants = enchants;
|
||||
item = mat.newItemStack();
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
this.enchants = enchants;
|
||||
item = mat.newItemStack();
|
||||
|
||||
if (name != null)
|
||||
meta.setDisplayName(CMIChatColor.translate(name));
|
||||
if (lore != null)
|
||||
meta.setLore(lore);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
|
||||
if (enchants != null) {
|
||||
if (mat == CMIMaterial.ENCHANTED_BOOK) {
|
||||
EnchantmentStorageMeta bookMeta = (EnchantmentStorageMeta) meta;
|
||||
for (Entry<Enchantment, Integer> oneEnch : enchants.entrySet()) {
|
||||
bookMeta.addStoredEnchant(oneEnch.getKey(), oneEnch.getValue(), true);
|
||||
}
|
||||
} else {
|
||||
for (Entry<Enchantment, Integer> oneEnchant : enchants.entrySet()) {
|
||||
meta.addEnchant(oneEnchant.getKey(), oneEnchant.getValue(), true);
|
||||
}
|
||||
if (name != null)
|
||||
meta.setDisplayName(CMIChatColor.translate(name));
|
||||
if (lore != null)
|
||||
meta.setLore(lore);
|
||||
|
||||
if (enchants != null) {
|
||||
if (mat == CMIMaterial.ENCHANTED_BOOK) {
|
||||
EnchantmentStorageMeta bookMeta = (EnchantmentStorageMeta) meta;
|
||||
for (Entry<Enchantment, Integer> oneEnch : enchants.entrySet()) {
|
||||
bookMeta.addStoredEnchant(oneEnch.getKey(), oneEnch.getValue(), true);
|
||||
}
|
||||
} else {
|
||||
for (Entry<Enchantment, Integer> oneEnchant : enchants.entrySet()) {
|
||||
meta.addEnchant(oneEnchant.getKey(), oneEnchant.getValue(), true);
|
||||
}
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
item.setAmount(amount);
|
||||
item = CMIReflections.setNbt(item, "JobsItemBoost", node);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
item.setItemMeta(meta);
|
||||
item.setAmount(amount);
|
||||
item = CMIReflections.setNbt(item, "JobsItemBoost", node);
|
||||
|
||||
this.node = node;
|
||||
this.boostMultiplier = boostMultiplier;
|
||||
setJobs(jobs);
|
||||
|
@ -19,6 +19,7 @@
|
||||
package com.gamingmesh.jobs.listeners;
|
||||
|
||||
import com.gamingmesh.jobs.CMILib.*;
|
||||
import com.gamingmesh.jobs.ItemBoostManager;
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.actions.*;
|
||||
import com.gamingmesh.jobs.api.JobsChunkChangeEvent;
|
||||
@ -950,6 +951,17 @@ public class JobsPaymentListener implements Listener {
|
||||
if (jPlayer == null)
|
||||
return;
|
||||
|
||||
if (!Jobs.getGCManager().allowEnchantingBoostedItems) {
|
||||
for (JobProgression prog : jPlayer.getJobProgression()) {
|
||||
for (JobItems jobItem : ItemBoostManager.getItemsByJob(prog.getJob())) {
|
||||
if (event.getItem().isSimilar(jobItem.getItemStack(jPlayer.getPlayer()))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<Enchantment, Integer> enchants = event.getEnchantsToAdd();
|
||||
for (Entry<Enchantment, Integer> oneEnchant : enchants.entrySet()) {
|
||||
Enchantment enchant = oneEnchant.getKey();
|
||||
@ -967,8 +979,8 @@ public class JobsPaymentListener implements Listener {
|
||||
|
||||
Jobs.action(jPlayer, new EnchantActionInfo(enchantName, level, ActionType.ENCHANT));
|
||||
}
|
||||
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.ENCHANT));
|
||||
|
||||
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.ENCHANT));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
|
Loading…
Reference in New Issue
Block a user