mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-02 14:29:07 +01:00
Inform about blockprotection only if payment is possible for it.
This commit is contained in:
parent
02a3c4cd65
commit
05e9184b9c
@ -95,7 +95,6 @@ import com.gamingmesh.jobs.stuff.RawMessage;
|
||||
import com.gamingmesh.jobs.stuff.TabComplete;
|
||||
import com.gamingmesh.jobs.stuff.VersionChecker;
|
||||
import com.gamingmesh.jobs.stuff.CMIScoreboardManager;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
import com.gamingmesh.jobs.tasks.BufferedPaymentThread;
|
||||
import com.gamingmesh.jobs.tasks.DatabaseSaveThread;
|
||||
|
||||
@ -879,7 +878,7 @@ public class Jobs extends JavaPlugin {
|
||||
int numjobs = progression.size();
|
||||
// no job
|
||||
|
||||
if (!isBpOk(jPlayer.getPlayer(), info, block, true))
|
||||
if (!isBpOk(jPlayer, info, block, true))
|
||||
return;
|
||||
|
||||
if (numjobs == 0) {
|
||||
@ -894,62 +893,62 @@ public class Jobs extends JavaPlugin {
|
||||
Double income = jobinfo.getIncome(1, numjobs);
|
||||
Double pointAmount = jobinfo.getPoints(1, numjobs);
|
||||
|
||||
if (income != 0D || pointAmount != 0D) {
|
||||
if (income == 0D && pointAmount == 0D)
|
||||
return;
|
||||
|
||||
Boost boost = pManager.getFinalBonus(jPlayer, Jobs.getNoneJob());
|
||||
Boost boost = pManager.getFinalBonus(jPlayer, Jobs.getNoneJob());
|
||||
|
||||
// Calculate income
|
||||
// Calculate income
|
||||
|
||||
if (income != 0D) {
|
||||
income = income + (income * boost.getFinal(CurrencyType.MONEY));
|
||||
if (GconfigManager.useMinimumOveralPayment && income > 0) {
|
||||
double maxLimit = income * GconfigManager.MinimumOveralPaymentLimit;
|
||||
if (income < maxLimit) {
|
||||
income = maxLimit;
|
||||
}
|
||||
if (income != 0D) {
|
||||
income = income + (income * boost.getFinal(CurrencyType.MONEY));
|
||||
if (GconfigManager.useMinimumOveralPayment && income > 0) {
|
||||
double maxLimit = income * GconfigManager.MinimumOveralPaymentLimit;
|
||||
if (income < maxLimit) {
|
||||
income = maxLimit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate points
|
||||
// Calculate points
|
||||
|
||||
if (pointAmount != 0D) {
|
||||
pointAmount = pointAmount + (pointAmount * boost.getFinal(CurrencyType.POINTS));
|
||||
if (GconfigManager.useMinimumOveralPoints && pointAmount > 0) {
|
||||
double maxLimit = pointAmount * GconfigManager.MinimumOveralPaymentLimit;
|
||||
if (pointAmount < maxLimit) {
|
||||
pointAmount = maxLimit;
|
||||
}
|
||||
if (pointAmount != 0D) {
|
||||
pointAmount = pointAmount + (pointAmount * boost.getFinal(CurrencyType.POINTS));
|
||||
if (GconfigManager.useMinimumOveralPoints && pointAmount > 0) {
|
||||
double maxLimit = pointAmount * GconfigManager.MinimumOveralPaymentLimit;
|
||||
if (pointAmount < maxLimit) {
|
||||
pointAmount = maxLimit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!jPlayer.isUnderLimit(CurrencyType.MONEY, income)) {
|
||||
income = 0D;
|
||||
if (GconfigManager.getLimit(CurrencyType.MONEY).getStopWith().contains(CurrencyType.POINTS))
|
||||
pointAmount = 0D;
|
||||
}
|
||||
|
||||
if (!jPlayer.isUnderLimit(CurrencyType.POINTS, pointAmount)) {
|
||||
if (!jPlayer.isUnderLimit(CurrencyType.MONEY, income)) {
|
||||
income = 0D;
|
||||
if (GconfigManager.getLimit(CurrencyType.MONEY).getStopWith().contains(CurrencyType.POINTS))
|
||||
pointAmount = 0D;
|
||||
if (GconfigManager.getLimit(CurrencyType.POINTS).getStopWith().contains(CurrencyType.MONEY))
|
||||
income = 0D;
|
||||
}
|
||||
}
|
||||
|
||||
if (income == 0D && pointAmount == 0D)
|
||||
return;
|
||||
if (!jPlayer.isUnderLimit(CurrencyType.POINTS, pointAmount)) {
|
||||
pointAmount = 0D;
|
||||
if (GconfigManager.getLimit(CurrencyType.POINTS).getStopWith().contains(CurrencyType.MONEY))
|
||||
income = 0D;
|
||||
}
|
||||
|
||||
if (info.getType() == ActionType.BREAK && block != null)
|
||||
Jobs.getBpManager().remove(block);
|
||||
if (income == 0D && pointAmount == 0D)
|
||||
return;
|
||||
|
||||
if (pointAmount != 0D)
|
||||
jPlayer.setSaved(false);
|
||||
if (info.getType() == ActionType.BREAK && block != null)
|
||||
Jobs.getBpManager().remove(block);
|
||||
|
||||
Jobs.getEconomy().pay(jPlayer, income, pointAmount, 0.0);
|
||||
if (pointAmount != 0D)
|
||||
jPlayer.setSaved(false);
|
||||
|
||||
if (GconfigManager.LoggingUse) {
|
||||
HashMap<CurrencyType, Double> amounts = new HashMap<CurrencyType, Double>();
|
||||
amounts.put(CurrencyType.MONEY, income);
|
||||
loging.recordToLog(jPlayer, info, amounts);
|
||||
}
|
||||
Jobs.getEconomy().pay(jPlayer, income, pointAmount, 0.0);
|
||||
|
||||
if (GconfigManager.LoggingUse) {
|
||||
HashMap<CurrencyType, Double> amounts = new HashMap<CurrencyType, Double>();
|
||||
amounts.put(CurrencyType.MONEY, income);
|
||||
loging.recordToLog(jPlayer, info, amounts);
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -1101,7 +1100,7 @@ public class Jobs extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isBpOk(Player player, ActionInfo info, Block block, boolean inform) {
|
||||
private static boolean isBpOk(JobsPlayer player, ActionInfo info, Block block, boolean inform) {
|
||||
if (block == null || !getGCManager().useBlockProtection)
|
||||
return true;
|
||||
|
||||
@ -1126,7 +1125,8 @@ public class Jobs extends JavaPlugin {
|
||||
if (time > System.currentTimeMillis() || bp.isPaid() && bp.getAction() != DBAction.DELETE) {
|
||||
int sec = Math.round((time - System.currentTimeMillis()) / 1000L);
|
||||
if (inform) {
|
||||
getActionBar().send(player, getLanguage().getMessage("message.blocktimer", "[time]", sec));
|
||||
if (player.canGetPaid(info))
|
||||
getActionBar().send(player.getPlayer(), getLanguage().getMessage("message.blocktimer", "[time]", sec));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -1151,7 +1151,8 @@ public class Jobs extends JavaPlugin {
|
||||
if (time > System.currentTimeMillis() || bp.isPaid() && bp.getAction() != DBAction.DELETE) {
|
||||
int sec = Math.round((time - System.currentTimeMillis()) / 1000L);
|
||||
if (inform) {
|
||||
getActionBar().send(player, getLanguage().getMessage("message.blocktimer", "[time]", sec));
|
||||
if (player.canGetPaid(info))
|
||||
getActionBar().send(player.getPlayer(), getLanguage().getMessage("message.blocktimer", "[time]", sec));
|
||||
}
|
||||
getBpManager().add(block, cd);
|
||||
return false;
|
||||
|
@ -12,7 +12,6 @@ import com.gamingmesh.jobs.commands.JobCommand;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.RawMessage;
|
||||
import com.gamingmesh.jobs.stuff.TimeManage;
|
||||
|
||||
public class archive implements Cmd {
|
||||
|
||||
|
@ -766,4 +766,36 @@ public class JobsPlayer {
|
||||
public void setLastPermissionUpdate(Long lastPermissionUpdate) {
|
||||
this.lastPermissionUpdate = lastPermissionUpdate;
|
||||
}
|
||||
|
||||
public boolean canGetPaid(ActionInfo info) {
|
||||
|
||||
List<JobProgression> progression = getJobProgression();
|
||||
int numjobs = progression.size();
|
||||
|
||||
if (numjobs == 0) {
|
||||
if (Jobs.getNoneJob() == null)
|
||||
return false;
|
||||
JobInfo jobinfo = Jobs.getNoneJob().getJobInfo(info, 1);
|
||||
if (jobinfo == null)
|
||||
return false;
|
||||
Double income = jobinfo.getIncome(1, numjobs);
|
||||
Double points = jobinfo.getPoints(1, numjobs);
|
||||
if (income == 0D && points == 0D)
|
||||
return false;
|
||||
}
|
||||
|
||||
for (JobProgression prog : progression) {
|
||||
int level = prog.getLevel();
|
||||
JobInfo jobinfo = prog.getJob().getJobInfo(info, level);
|
||||
if (jobinfo == null)
|
||||
continue;
|
||||
Double income = jobinfo.getIncome(level, numjobs);
|
||||
Double pointAmount = jobinfo.getPoints(level, numjobs);
|
||||
Double expAmount = jobinfo.getExperience(level, numjobs);
|
||||
if (income != 0D || pointAmount != 0D || expAmount != 0D)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -514,8 +514,6 @@ public class JobsPaymentListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
Debug.D("Crafted item " + resultStack.getType().name() + " " + resultStack.getAmount());
|
||||
|
||||
// If we need to pay only by each craft action we will skip calculation how much was crafted
|
||||
if (!Jobs.getGCManager().PayForEachCraft) {
|
||||
if (resultStack.hasItemMeta() && resultStack.getItemMeta().hasDisplayName())
|
||||
|
Loading…
Reference in New Issue
Block a user