mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-26 04:25:15 +01:00
Improved player inventory item boost logic (#1062)
This adds two new configuration options to generalConfig. They're modelled after "enable-boosted-items-in-offhand", called "enable-boosted-items-in-mainhand" and "enable-boosted-armor-items". As the name suggests, the former determines if boosted items in your main hand count towards your overall jobs items bonus, and the latter does the same for armor.
This commit is contained in:
parent
2ad3e54e4d
commit
9aa07160eb
@ -881,34 +881,44 @@ public class PlayerManager {
|
||||
if (player == null || prog == null)
|
||||
return data;
|
||||
|
||||
ItemStack iih = Jobs.getNms().getItemInMainHand(player);
|
||||
JobItems jitem = getJobsItemByNbt(iih);
|
||||
if (jitem != null && jitem.getJobs().contains(prog))
|
||||
data.add(jitem.getBoost(getJobsPlayer(player).getJobProgression(prog)));
|
||||
ItemStack iih;
|
||||
List<JobItems> jitems = new ArrayList<>();
|
||||
|
||||
// Lets check offhand
|
||||
// Check mainhand slot
|
||||
if (Jobs.getGCManager().boostedItemsInMainHand) {
|
||||
iih = Jobs.getNms().getItemInMainHand(player);
|
||||
|
||||
if (iih != null) {
|
||||
jitems.add(getJobsItemByNbt(iih));
|
||||
}
|
||||
}
|
||||
|
||||
// Check offhand slot
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_9_R1) && Jobs.getGCManager().boostedItemsInOffHand) {
|
||||
iih = CMIReflections.getItemInOffHand(player);
|
||||
|
||||
if (iih != null) {
|
||||
jitem = getJobsItemByNbt(iih);
|
||||
if (jitem != null && jitem.getJobs().contains(prog))
|
||||
jitems.add(getJobsItemByNbt(iih));
|
||||
}
|
||||
}
|
||||
|
||||
// Check armor slots
|
||||
if (Jobs.getGCManager().boostedArmorItems) {
|
||||
for (ItemStack oneArmor : player.getInventory().getArmorContents()) {
|
||||
if (oneArmor != null && oneArmor.getType() != org.bukkit.Material.AIR) {
|
||||
jitems.add(getJobsItemByNbt(oneArmor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (JobItems jitem : jitems) {
|
||||
if (jitem != null && jitem.getJobs().contains(prog)) {
|
||||
data.add(jitem.getBoost(getJobsPlayer(player).getJobProgression(prog)));
|
||||
}
|
||||
}
|
||||
|
||||
for (ItemStack oneArmor : player.getInventory().getArmorContents()) {
|
||||
if (oneArmor == null || oneArmor.getType() == org.bukkit.Material.AIR)
|
||||
continue;
|
||||
|
||||
JobItems armorboost = getJobsItemByNbt(oneArmor);
|
||||
if (armorboost == null || !armorboost.getJobs().contains(prog))
|
||||
continue;
|
||||
|
||||
data.add(armorboost.getBoost(getJobsPlayer(player).getJobProgression(prog)));
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean containsItemBoostByNBT(ItemStack item) {
|
||||
return item != null && Jobs.getReflections().hasNbtString(item, JobsItemBoost);
|
||||
|
@ -91,7 +91,7 @@ public class GeneralConfigManager {
|
||||
SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useSilkTouchProtection, UseCustomNames,
|
||||
PreventSlimeSplit, PreventMagmaCubeSplit, PreventHopperFillUps, PreventBrewingStandFillUps,
|
||||
BrowseUseNewLook, payExploringWhenGliding = false, disablePaymentIfMaxLevelReached, disablePaymentIfRiding,
|
||||
boostedItemsInOffHand = false, preventCropResizePayment, payItemDurabilityLoss,
|
||||
boostedItemsInOffHand = false, boostedItemsInMainHand, boostedArmorItems, preventCropResizePayment, payItemDurabilityLoss,
|
||||
applyToNegativeIncome, useMinimumOveralPayment, useMinimumOveralPoints, useBreederFinder,
|
||||
CancelCowMilking, fixAtMaxLevel, TitleChangeChat, TitleChangeActionBar, LevelChangeChat,
|
||||
LevelChangeActionBar, SoundLevelupUse, SoundTitleChangeUse, UseServerAccount, EmptyServerAccountChat,
|
||||
@ -456,6 +456,12 @@ public class GeneralConfigManager {
|
||||
boostedItemsInOffHand = c.get("enable-boosted-items-in-offhand", true);
|
||||
}
|
||||
|
||||
c.addComment("enable-boosted-items-in-mainhand", "Do the jobs boost ignore the boosted items usage in main hand?");
|
||||
boostedItemsInMainHand = c.get("enable-boosted-items-in-mainhand", true);
|
||||
|
||||
c.addComment("enable-boosted-armor-items", "Do the jobs boost ignore the boosted items usage in armor slots?");
|
||||
boostedArmorItems = c.get("enable-boosted-armor-items", true);
|
||||
|
||||
c.addComment("prevent-crop-resize-payment", "Do you want to prevent crop resizing payment when placing more cactus?",
|
||||
"This option is only related to: sugar_cane, cactus, kelp, bamboo");
|
||||
preventCropResizePayment = c.get("prevent-crop-resize-payment", false);
|
||||
|
Loading…
Reference in New Issue
Block a user