Skip to content

Commit

Permalink
GH-911 Fix typo in afk config, fix permission check order, add consta…
Browse files Browse the repository at this point in the history
…nt for permission for afk permission. (#911)

* fixed bypass check order, typo in AfkPlaceholderSetup, fixed placeholder formatting

* Add constant for permission.

* revert rtp changes (my bad)

* Fix.
  • Loading branch information
vLuckyyy authored Feb 14, 2025
1 parent 7d1b07b commit 2de51a9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
)
class AfkCommand {

private static final String AFK_BYPASS_PERMISSION = "eternalcore.afk.bypass";

private final NoticeService noticeService;
private final PluginConfiguration pluginConfiguration;
private final AfkService afkService;
Expand All @@ -38,10 +40,15 @@ class AfkCommand {
}

@Execute
@DescriptionDocs(description = "Marks you as AFK, if player has eternalcore.afk.bypass permission, eternalcore will be ignore afk delay")
@DescriptionDocs(description = "Marks you as AFK, if player has eternalcore.afk.bypass permission, eternalcore will ignore afk delay")
void execute(@Context Player player) {
UUID uuid = player.getUniqueId();

if (player.hasPermission(AFK_BYPASS_PERMISSION)) {
this.afkService.switchAfk(uuid, AfkReason.COMMAND);
return;
}

if (this.delay.hasDelay(uuid)) {
Duration time = this.delay.getDurationToExpire(uuid);

Expand All @@ -56,11 +63,6 @@ void execute(@Context Player player) {
}

this.afkService.switchAfk(uuid, AfkReason.COMMAND);

if (player.hasPermission("eternalcore.afk.bypass")) {
return;
}

this.delay.markDelay(uuid, this.pluginConfiguration.afk.getAfkDelay());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
import java.util.Optional;

@Controller
class AftPlaceholderSetup {
class AfkPlaceholderSetup {

private final TranslationManager translationManager;

@Inject
AftPlaceholderSetup(TranslationManager translationManager) {
AfkPlaceholderSetup(TranslationManager translationManager) {
this.translationManager = translationManager;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import com.eternalcode.core.notice.NoticeService;
import com.eternalcode.core.user.User;
import com.eternalcode.core.user.UserManager;
import java.util.HashMap;
import java.util.Optional;
import org.jetbrains.annotations.ApiStatus;

import java.time.Duration;
import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

Expand Down Expand Up @@ -126,5 +126,4 @@ private void sendAfkNotification(UUID playerUniqueId, boolean afk) {
.placeholder("{PLAYER}", this.userManager.getUser(playerUniqueId).map(User::getName))
.send();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import com.eternalcode.core.feature.vanish.VanishService;
import com.eternalcode.core.injector.annotations.Inject;
import com.eternalcode.core.injector.annotations.component.Task;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.bukkit.Server;
import org.bukkit.entity.Player;

import java.util.UUID;

@Task(delay = 1L, period = 1L, unit = TimeUnit.MINUTES)
class AfkTask implements Runnable {

Expand Down Expand Up @@ -55,5 +54,4 @@ void markAllInactivePlayers() {
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ public class PLAfkMessages implements AfkMessages {

@Description("# {PLAYER} - Gracz ")
public Notice afkOn = Notice.chat("<green>► <white>{PLAYER} jest AFK!");

@Description("# {PLAYER} - Gracz ")
public Notice afkOff = Notice.chat("<green>► <white>{PLAYER} już nie jest AFK!");

@Description({" ", "# {TIME} - Czas po którym gracz może użyć komendy"})
public Notice afkDelay = Notice.chat("<red>► <dark_red>Możesz użyć tej komendy dopiero po <dark_red>{TIME}!");

@Description({" "})
public String afkKickReason = "<red>Zostałeś wyrzucone z powodu braku aktywności!";
public String afkKickReason = "<red>Zostałeś wyrzucony z powodu braku aktywności!";

@Description({" ", "# Używane w %eternalcore_afk_formatted% do wskazania statusu AFK"})
public String afkEnabledPlaceholder = "<red><b>AFK";
public String afkDisabledPlaceholder = "";

public String afkDisabledPlaceholder = "";
}

0 comments on commit 2de51a9

Please sign in to comment.