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

Fixing creative state check by permission node

This commit is contained in:
Zrips 2021-07-06 13:28:01 +03:00
parent 88ed269041
commit 281542d745
2 changed files with 12 additions and 7 deletions

View File

@ -30,6 +30,8 @@ import org.bukkit.permissions.PermissionAttachmentInfo;
import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobsPlayer;
import net.Zrips.CMILib.Logs.CMIDebug;
public class PermissionManager {
private final Map<String, Integer> permDelay = new HashMap<>();
@ -204,7 +206,9 @@ public class PermissionManager {
Map<String, Boolean> permissions = jPlayer.getPermissionsCache();
if (permissions == null || getDelay(perm) + jPlayer.getLastPermissionUpdate() < System.currentTimeMillis()) {
permissions = getAll(player);
if (permissions == null)
permissions = new HashMap<>();
permissions.put(perm, player.hasPermission(perm));
jPlayer.setPermissionsCache(permissions);
jPlayer.setLastPermissionUpdate(System.currentTimeMillis());
}

View File

@ -1494,7 +1494,7 @@ public final class JobsPaymentListener implements Listener {
Player player = (Player) human;
if (!player.isOnline() || event.getFoodLevel() <= player.getFoodLevel() )
if (!player.isOnline() || event.getFoodLevel() <= player.getFoodLevel())
return;
// check if in creative
@ -1728,12 +1728,13 @@ public final class JobsPaymentListener implements Listener {
}
public static boolean payIfCreative(Player player) {
if (!Jobs.getGCManager().payInCreative() && player.getGameMode() == GameMode.CREATIVE && !Jobs.getPermissionManager().hasPermission(Jobs.getPlayerManager().getJobsPlayer(player),
"jobs.paycreative")) {
return false;
}
if (Jobs.getGCManager().payInCreative() && player.getGameMode() == GameMode.CREATIVE)
return true;
return true;
if (player.getGameMode() == GameMode.CREATIVE && Jobs.getPermissionManager().hasPermission(Jobs.getPlayerManager().getJobsPlayer(player), "jobs.paycreative"))
return true;
return player.getGameMode() != GameMode.CREATIVE;
}
// Prevent item durability loss