1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-06 00:08:13 +01:00

Fix error when grindstone and stonecutter inventories not exists in old versions

Fixes #819
This commit is contained in:
montlikadani 2020-06-14 12:56:52 +02:00
parent daf56cd235
commit b5c1516177
2 changed files with 12 additions and 1 deletions

View File

@ -87,6 +87,7 @@ public class PermissionHandler {
for (JobConditions Condition : job.getConditions()) {
boolean ok = true;
for (String oneReq : Condition.getRequiredPerm()) {
if (!player.hasPermission(oneReq)) {
ok = false;
@ -98,6 +99,7 @@ public class PermissionHandler {
String jobName = oneReq.getKey();
int jobLevel = oneReq.getValue();
boolean found = false;
for (JobProgression oneJob : jPlayer.getJobProgression()) {
if (oneJob.getJob().getName().equalsIgnoreCase(jobName))
found = true;
@ -106,12 +108,14 @@ public class PermissionHandler {
break;
}
}
if (!found)
ok = false;
}
if (!ok)
continue;
for (Entry<String, Boolean> one : Condition.getPerformPerm().entrySet()) {
String perm = one.getKey();
boolean node = one.getValue();
@ -149,6 +153,7 @@ public class PermissionHandler {
for (JobConditions Condition : prog.getJob().getConditions()) {
boolean ok = true;
for (String oneReq : Condition.getRequiredPerm()) {
if (!player.hasPermission(oneReq)) {
ok = false;
@ -160,19 +165,24 @@ public class PermissionHandler {
String jobName = oneReq.getKey();
int jobLevel = oneReq.getValue();
boolean found = false;
for (JobProgression oneJob : jPlayer.getJobProgression()) {
if (oneJob.getJob().getName().equalsIgnoreCase(jobName))
found = true;
if (oneJob.getJob().getName().equalsIgnoreCase(jobName) && oneJob.getLevel() < jobLevel) {
ok = false;
break;
}
}
if (!found)
ok = false;
}
if (!ok)
continue;
for (Entry<String, Boolean> one : Condition.getPerformPerm().entrySet()) {
String perm = one.getKey();
boolean node = one.getValue();

View File

@ -813,7 +813,8 @@ public class JobsPaymentListener implements Listener {
Inventory inv = event.getInventory();
// must be anvil inventory
if (!(inv instanceof AnvilInventory) && !(inv instanceof GrindstoneInventory) && !(inv instanceof StonecutterInventory))
if (!(inv instanceof AnvilInventory) && (Version.isCurrentEqualOrHigher(Version.v1_14_R1)
&& !(inv instanceof GrindstoneInventory) && !(inv instanceof StonecutterInventory)))
return;
int slot = event.getSlot();