1
0
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:
MrMacor 2021-01-19 07:37:47 -08:00 committed by GitHub
parent 2ad3e54e4d
commit 9aa07160eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 28 deletions

View File

@ -881,35 +881,45 @@ 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
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))
data.add(jitem.getBoost(getJobsPlayer(player).getJobProgression(prog)));
}
}
// Check mainhand slot
if (Jobs.getGCManager().boostedItemsInMainHand) {
iih = Jobs.getNms().getItemInMainHand(player);
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;
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) {
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)));
}
}
return data;
}
public boolean containsItemBoostByNBT(ItemStack item) {
return item != null && Jobs.getReflections().hasNbtString(item, JobsItemBoost);
}

View File

@ -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,
@ -452,10 +452,16 @@ public class GeneralConfigManager {
addXpPlayer = c.get("add-xp-player", false);
if (Version.isCurrentEqualOrHigher(Version.v1_9_R1)) {
c.addComment("enable-boosted-items-in-offhand", "Do the jobs boost ignore the boosted items usage in off hand?");
boostedItemsInOffHand = c.get("enable-boosted-items-in-offhand", true);
c.addComment("enable-boosted-items-in-offhand", "Do the jobs boost ignore the boosted items usage in off hand?");
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);