mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-29 04:18:07 +01:00
Optimize permission check
This commit is contained in:
parent
e2b9f370af
commit
86c94786cf
@ -53,7 +53,9 @@ public class PermissionManager {
|
||||
jobs_maxblastfurnaces_AMOUNT(remade("jobs.maxblastfurnaces.%AMOUNT%"), 30),
|
||||
jobs_maxsmokers_AMOUNT(remade("jobs.maxsmokers.%AMOUNT%"), 30),
|
||||
jobs_maxbrewingstands_AMOUNT(remade("jobs.maxbrewingstands.%AMOUNT%"), 30),
|
||||
jobs_world_WORLDNAME(remade("jobs.world.%WORLDNAME%"), 2);
|
||||
jobs_world_WORLDNAME(remade("jobs.world.%WORLDNAME%"), 2),
|
||||
jobs_maxquest_JOBNAME_AMOUNT(remade("jobs.maxquest.%JOBNAME%.%AMOUNT%"), 30),
|
||||
jobs_maxquest_all_AMOUNT(remade("jobs.maxquest.all.%AMOUNT%"), 30);
|
||||
|
||||
private int reload;
|
||||
private List<String> perms;
|
||||
@ -93,7 +95,7 @@ public class PermissionManager {
|
||||
}
|
||||
|
||||
private int getDelay(String perm) {
|
||||
return permDelay.getOrDefault(perm, 1);
|
||||
return permDelay.getOrDefault(perm, 1000);
|
||||
}
|
||||
|
||||
public PermissionManager() {
|
||||
@ -165,7 +167,11 @@ public class PermissionManager {
|
||||
double amount = Double.NEGATIVE_INFINITY;
|
||||
|
||||
permissionInfo permInfo = jPlayer.getPermissionsCache(perm);
|
||||
|
||||
if (force || getDelay(perm) + permInfo.getTime() < System.currentTimeMillis()) {
|
||||
|
||||
CMIDebug.c("get", force, getDelay(perm) + permInfo.getTime() < System.currentTimeMillis(), getDelay(perm), permInfo.getTime(), perm);
|
||||
|
||||
Map<String, Boolean> perms = getAll(player, perm);
|
||||
for (Map.Entry<String, Boolean> permission : perms.entrySet()) {
|
||||
if (!permission.getKey().startsWith(perm) || !permission.getValue())
|
||||
@ -176,7 +182,7 @@ public class PermissionManager {
|
||||
if (amount == Double.NEGATIVE_INFINITY)
|
||||
amount = 0D;
|
||||
amount += temp;
|
||||
}else if (temp > amount)
|
||||
} else if (temp > amount)
|
||||
amount = temp;
|
||||
} catch (NumberFormatException ex) {
|
||||
Jobs.getPluginLogger().log(java.util.logging.Level.WARNING, ex.getLocalizedMessage());
|
||||
|
@ -167,7 +167,6 @@ public class boost implements Cmd {
|
||||
|
||||
if (job.getBoost().getTime(curr) != null && job.getBoost().isValid(curr)) {
|
||||
rm.addHover(CMITimeManager.to24hourShort(job.getBoost().getTime(curr) - System.currentTimeMillis()));
|
||||
CMIDebug.c(job.getBoost().getTime(curr) - System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
if (split.length > 1)
|
||||
|
@ -36,7 +36,7 @@ public class entitylist implements Cmd {
|
||||
msg.append(c2);
|
||||
}
|
||||
|
||||
msg.append(CMIText.firstToUpperCase(type.name()));
|
||||
msg.append(CMIText.everyFirstToUpperCase(type.name()));
|
||||
}
|
||||
|
||||
CMIMessages.sendMessage(sender, msg.toString());
|
||||
|
@ -157,23 +157,24 @@ public class QuestProgression {
|
||||
}
|
||||
}
|
||||
|
||||
boolean completed = isCompleted();
|
||||
|
||||
Job questJob = quest.getJob();
|
||||
if (questJob != null) {
|
||||
if (questJob != null && completed) {
|
||||
int maxQuest = jPlayer.getPlayerMaxQuest(questJob.getName());
|
||||
if (maxQuest > 0 && jPlayer.getDoneQuests() >= maxQuest) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isCompleted() &&
|
||||
objective != null) {
|
||||
if (!completed && objective != null) {
|
||||
Integer old = done.getOrDefault(objective, 0);
|
||||
done.put(objective, old < objective.getAmount() ? old + 1 : objective.getAmount());
|
||||
}
|
||||
|
||||
jPlayer.setSaved(false);
|
||||
|
||||
if (!isCompleted() || !player.isOnline() || givenReward)
|
||||
if (!completed || !player.isOnline() || givenReward)
|
||||
return;
|
||||
|
||||
givenReward = true;
|
||||
|
@ -531,9 +531,9 @@ public class JobsListener implements Listener {
|
||||
|
||||
Chunk from = event.getFrom().getChunk();
|
||||
Chunk to = event.getTo().getChunk();
|
||||
if (from != to) {
|
||||
plugin.getServer().getPluginManager().callEvent(new JobsChunkChangeEvent(event.getPlayer(), from, to));
|
||||
}
|
||||
// if (from != to) {
|
||||
// plugin.getServer().getPluginManager().callEvent(new JobsChunkChangeEvent(event.getPlayer(), from, to));
|
||||
// }
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
|
Loading…
Reference in New Issue
Block a user