mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 22:16:08 +00:00
Internalize PAPI hook, cache SavedUser data
This commit is contained in:
1 parent
d4be673581
commit
15227ee702
14 files changed
+193
-67
No files matched your search
@@ -64,11 +64,14 @@ public class RtpCommand extends Command {
|
||||
return;
|
||||
}
|
||||
|
||||
final SavedUser user = plugin.getDatabase().getUserData(teleporter.getUuid())
|
||||
plugin.editUserData(teleporter, (SavedUser user) -> {
|
||||
|
||||
});
|
||||
final SavedUser user = plugin.getSavedUser(teleporter)
|
||||
.orElseThrow(() -> new IllegalStateException("No user data found for " + teleporter.getUsername()));
|
||||
final Instant currentTime = Instant.now();
|
||||
if (executor.equals(teleporter) && !currentTime.isAfter(user.getRtpCooldown()) &&
|
||||
!executor.hasPermission(getPermission("bypass_cooldown"))) {
|
||||
!executor.hasPermission(getPermission("bypass_cooldown"))) {
|
||||
plugin.getLocales().getLocale("error_rtp_cooldown",
|
||||
Long.toString(currentTime.until(user.getRtpCooldown(), ChronoUnit.MINUTES) + 1))
|
||||
.ifPresent(executor::sendMessage);
|
||||
@@ -101,8 +104,8 @@ public class RtpCommand extends Command {
|
||||
return;
|
||||
}
|
||||
|
||||
user.setRtpCooldown(Instant.now().plus(plugin.getSettings().getRtpCooldownLength(), ChronoUnit.MINUTES));
|
||||
plugin.getDatabase().updateUserData(user);
|
||||
plugin.editUserData(teleporter, (SavedUser saved) -> saved.setRtpCooldown(Instant.now()
|
||||
.plus(plugin.getSettings().getRtpCooldownLength(), ChronoUnit.MINUTES)));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user