1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-01 23:13:48 +01:00

Add option to pay for each vtrade items

Closes #571
This commit is contained in:
montlikadani 2020-09-28 19:40:17 +02:00
parent de21c1857a
commit ae53a1227b
4 changed files with 27 additions and 26 deletions

View File

@ -102,7 +102,7 @@ public class GeneralConfigManager {
hideJobsInfoWithoutPermission, UseTaxes, TransferToServerAccount, TakeFromPlayersPayment, AutoJobJoinUse, AllowDelevel, hideJobsInfoWithoutPermission, UseTaxes, TransferToServerAccount, TakeFromPlayersPayment, AutoJobJoinUse, AllowDelevel,
BossBarEnabled, BossBarShowOnEachAction, BossBarsMessageByDefault, ExploreCompact, DBCleaningJobsUse, DBCleaningUsersUse, BossBarEnabled, BossBarShowOnEachAction, BossBarsMessageByDefault, ExploreCompact, DBCleaningJobsUse, DBCleaningUsersUse,
DisabledWorldsUse, UseAsWhiteListWorldList, PaymentMethodsMoney, PaymentMethodsPoints, PaymentMethodsExp, MythicMobsEnabled, DisabledWorldsUse, UseAsWhiteListWorldList, PaymentMethodsMoney, PaymentMethodsPoints, PaymentMethodsExp, MythicMobsEnabled,
LoggingUse, payForCombiningItems, BlastFurnacesReassign, SmokerReassign, payForStackedEntities; LoggingUse, payForCombiningItems, BlastFurnacesReassign, SmokerReassign, payForStackedEntities, payForEachVTradeItem;
public ItemStack guiBackButton, guiNextButton, guiFiller; public ItemStack guiBackButton, guiNextButton, guiFiller;
@ -754,6 +754,8 @@ public class GeneralConfigManager {
"With this true, player will get money for all crafted items instead of each crafting action (like with old payment mechanic)", "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"); "By default its false, as you can make ALOT of money if prices kept from old payment mechanics");
PayForEachCraft = c.get("Economy.Crafting.PayForEachCraft", false); PayForEachCraft = c.get("Economy.Crafting.PayForEachCraft", false);
c.addComment("Economy.VTrade.payForEachTradeItem", "With this true, player will get money for all trade items instead of each trade action");
payForEachVTradeItem = c.get("Economy.VTrade.payForEachTradeItem", false);
c.addComment("Economy.Crafting.PayForCombiningItems", "true - if players tries to combine (repair) 2 same items, like armor or weapon " c.addComment("Economy.Crafting.PayForCombiningItems", "true - if players tries to combine (repair) 2 same items, like armor or weapon "
+ "do they get income for it?"); + "do they get income for it?");
payForCombiningItems = c.get("Economy.Crafting.PayForCombiningItems", true); payForCombiningItems = c.get("Economy.Crafting.PayForCombiningItems", true);

View File

@ -20,9 +20,7 @@ public class Quest {
private Integer minLvl = null; private Integer minLvl = null;
private Integer maxLvl = null; private Integer maxLvl = null;
private final List<String> rewardCmds = new ArrayList<>(); private final List<String> rewardCmds = new ArrayList<>(), rewards = new ArrayList<>(), area = new ArrayList<>();
private final List<String> rewards = new ArrayList<>();
private final List<String> area = new ArrayList<>();
private boolean stopped = false; private boolean stopped = false;

View File

@ -88,24 +88,18 @@ public class QuestProgression {
} }
public void processQuest(JobsPlayer jPlayer, ActionInfo action) { public void processQuest(JobsPlayer jPlayer, ActionInfo action) {
if (quest.isStopped()) { if (quest.isStopped() || !quest.hasAction(action.getType()))
return;
}
if (!quest.hasAction(action.getType()))
return; return;
if (!quest.getObjectives().containsKey(action.getType()) || !quest.getObjectives().get(action.getType()).containsKey(action.getNameWithSub()) && !quest.getObjectives().get(action.getType()) if (!quest.getObjectives().containsKey(action.getType()) || !quest.getObjectives().get(action.getType()).containsKey(action.getNameWithSub()) && !quest.getObjectives().get(action.getType())
.containsKey(action.getName())) .containsKey(action.getName()))
return; return;
if (!quest.getRestrictedAreas().isEmpty()) { for (String area : quest.getRestrictedAreas()) {
for (String area : quest.getRestrictedAreas()) { for (Entry<String, RestrictedArea> a : Jobs.getRestrictedAreaManager().getRestrictedAres().entrySet()) {
for (Entry<String, RestrictedArea> a : Jobs.getRestrictedAreaManager().getRestrictedAres().entrySet()) { if (quest.getRestrictedAreas().contains(a.getKey()) && a.getKey().equalsIgnoreCase(area)
if (quest.getRestrictedAreas().contains(a.getKey()) && a.getKey().equalsIgnoreCase(area) && a.getValue().inRestrictedArea(jPlayer.getPlayer().getLocation())) {
&& a.getValue().inRestrictedArea(jPlayer.getPlayer().getLocation())) { return;
return;
}
} }
} }
} }
@ -121,14 +115,8 @@ public class QuestProgression {
} }
if (objective != null) { if (objective != null) {
Integer old = done.get(objective); Integer old = done.getOrDefault(objective, 0);
if (old == null) done.put(objective, old < objective.getAmount() ? old + 1 : objective.getAmount());
old = 0;
if (old < objective.getAmount())
done.put(objective, old + 1);
else {
done.put(objective, objective.getAmount());
}
} }
} }

View File

@ -162,6 +162,19 @@ public class JobsPaymentListener implements Listener {
if (jPlayer == null) if (jPlayer == null)
return; return;
if (!Jobs.getGCManager().payForEachVTradeItem) {
ItemStack currentItem = event.getCurrentItem();
if (resultStack.hasItemMeta() && resultStack.getItemMeta().hasDisplayName()) {
Jobs.action(jPlayer, new ItemNameActionInfo(CMIChatColor.stripColor(resultStack.getItemMeta()
.getDisplayName()), ActionType.VTRADE));
} else if (currentItem != null) {
Jobs.action(jPlayer, new ItemActionInfo(currentItem, ActionType.VTRADE));
}
return;
}
// Checking how much player traded // Checking how much player traded
ItemStack toCraft = event.getCurrentItem(); ItemStack toCraft = event.getCurrentItem();
ItemStack toStore = event.getCursor(); ItemStack toStore = event.getCursor();
@ -718,14 +731,14 @@ public class JobsPaymentListener implements Listener {
// HACK! The API doesn't allow us to easily determine the resulting number of // HACK! The API doesn't allow us to easily determine the resulting number of
// crafted items, so we're forced to compare the inventory before and after. // crafted items, so we're forced to compare the inventory before and after.
private Integer schedulePostDetection(final HumanEntity player, final ItemStack compareItem, final JobsPlayer jPlayer, final ItemStack resultStack, final ActionType type) { private void schedulePostDetection(final HumanEntity player, final ItemStack compareItem, final JobsPlayer jPlayer, final ItemStack resultStack, final ActionType type) {
final ItemStack[] preInv = player.getInventory().getContents(); final ItemStack[] preInv = player.getInventory().getContents();
// Clone the array. The content may (was for me) be mutable. // Clone the array. The content may (was for me) be mutable.
for (int i = 0; i < preInv.length; i++) { for (int i = 0; i < preInv.length; i++) {
preInv[i] = preInv[i] != null ? preInv[i].clone() : null; preInv[i] = preInv[i] != null ? preInv[i].clone() : null;
} }
return Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
final ItemStack[] postInv = player.getInventory().getContents(); final ItemStack[] postInv = player.getInventory().getContents();