Skip to content

Commit 316f0f8

Browse files
Jakubk15Copilot
andauthored
GH-1129 Replace @context annotation with @sender where possible (#1129)
* Replace @context annotation with @sender where possible * Update eternalcore-core/src/main/java/com/eternalcode/core/feature/sudo/SudoCommand.java Co-authored-by: Copilot <[email protected]> * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> * Update TeleportToPositionCommand.java * Replace all occurences of @sender Viewer and @sender Audience --------- Co-authored-by: Copilot <[email protected]>
1 parent 5cd81f5 commit 316f0f8

File tree

83 files changed

+318
-335
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+318
-335
lines changed

eternalcore-api-example/src/main/java/com/eternalcode/example/feature/afk/ApiAfkCommand.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
import com.eternalcode.core.feature.afk.AfkService;
66
import dev.rollczi.litecommands.annotations.argument.Arg;
77
import dev.rollczi.litecommands.annotations.command.Command;
8-
import dev.rollczi.litecommands.annotations.context.Context;
8+
import dev.rollczi.litecommands.annotations.context.Sender;
99
import dev.rollczi.litecommands.annotations.execute.Execute;
10-
import org.bukkit.entity.Player;
11-
1210
import java.time.Instant;
1311
import java.time.ZoneId;
1412
import java.time.format.DateTimeFormatter;
1513
import java.util.UUID;
14+
import org.bukkit.entity.Player;
1615

1716
@Command(name = "api afk")
1817
public class ApiAfkCommand {
@@ -28,14 +27,14 @@ public ApiAfkCommand(AfkService afkService) {
2827
}
2928

3029
@Execute(name = "isafk")
31-
void execute(@Context Player player, @Arg Player target) {
30+
void execute(@Sender Player player, @Arg Player target) {
3231
boolean afk = this.afkService.isAfk(target.getUniqueId());
3332
String message = "Player %s is %s afk, used via eternalcore api bridge!";
3433
player.sendMessage(String.format(message, target.getName(), afk ? "now" : "not"));
3534
}
3635

3736
@Execute(name = "setafk")
38-
void executeSetAfk(@Context Player player, @Arg Player target) {
37+
void executeSetAfk(@Sender Player player, @Arg Player target) {
3938
Afk afk = this.afkService.markAfk(target.getUniqueId(), AfkReason.COMMAND);
4039

4140
AfkReason afkReason = afk.getAfkReason();
@@ -53,14 +52,14 @@ void executeSetAfk(@Context Player player, @Arg Player target) {
5352
}
5453

5554
@Execute(name = "removeafk")
56-
void executeRemoveAfk(@Context Player player, @Arg Player target) {
55+
void executeRemoveAfk(@Sender Player player, @Arg Player target) {
5756
this.afkService.clearAfk(target.getUniqueId());
5857
String message = "You have removed %s from afk via eternalcore api bridge!";
5958
player.sendMessage(String.format(message, target.getName()));
6059
}
6160

6261
@Execute(name = "addinteraction")
63-
void executeMarkInteraction(@Context Player player, @Arg Player target, @Arg int interactions) {
62+
void executeMarkInteraction(@Sender Player player, @Arg Player target, @Arg int interactions) {
6463
for (int i = 0; i < interactions; i++) {
6564
this.afkService.markInteraction(target.getUniqueId());
6665
}
@@ -71,7 +70,7 @@ void executeMarkInteraction(@Context Player player, @Arg Player target, @Arg int
7170
}
7271

7372
@Execute(name = "demo")
74-
void executeDemo(@Context Player player) {
73+
void executeDemo(@Sender Player player) {
7574
player.showDemoScreen();
7675
}
7776

eternalcore-api-example/src/main/java/com/eternalcode/example/feature/home/ApiHomeCommand.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.eternalcode.core.feature.home.HomeService;
44
import dev.rollczi.litecommands.annotations.argument.Arg;
55
import dev.rollczi.litecommands.annotations.command.Command;
6-
import dev.rollczi.litecommands.annotations.context.Context;
6+
import dev.rollczi.litecommands.annotations.context.Sender;
77
import dev.rollczi.litecommands.annotations.execute.Execute;
88
import org.bukkit.Location;
99
import org.bukkit.entity.Player;
@@ -18,13 +18,13 @@ public ApiHomeCommand(HomeService homeService) {
1818
}
1919

2020
@Execute(name = "set")
21-
void executeSet(@Context Player player, @Arg("homeName") String homeName) {
21+
void executeSet(@Sender Player player, @Arg("homeName") String homeName) {
2222
this.homeService.createHome(player.getUniqueId(), homeName, player.getLocation());
2323
player.sendMessage("Home set!");
2424
}
2525

2626
@Execute(name = "teleport")
27-
void executeTeleport(@Context Player player, @Arg("homeName") String homeName) {
27+
void executeTeleport(@Sender Player player, @Arg("homeName") String homeName) {
2828
Location location = this.homeService.getHome(player.getUniqueId(), homeName)
2929
.map(home -> home.getLocation())
3030
.orElse(null);
@@ -39,13 +39,13 @@ void executeTeleport(@Context Player player, @Arg("homeName") String homeName) {
3939
}
4040

4141
@Execute(name = "delete")
42-
void executeDelete(@Context Player player, @Arg("homeName") String homeName) {
42+
void executeDelete(@Sender Player player, @Arg("homeName") String homeName) {
4343
this.homeService.deleteHome(player.getUniqueId(), homeName);
4444
player.sendMessage("Home deleted!");
4545
}
4646

4747
@Execute(name = "list")
48-
void executeList(@Context Player player) {
48+
void executeList(@Sender Player player) {
4949
player.sendMessage("Your homes:");
5050
this.homeService.getHomes(player.getUniqueId())
5151
.forEach(home -> player.sendMessage(home.getName()));

eternalcore-api-example/src/main/java/com/eternalcode/example/feature/ignore/ApiIgnoreCommand.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.eternalcode.core.feature.ignore.IgnoreService;
44
import dev.rollczi.litecommands.annotations.argument.Arg;
55
import dev.rollczi.litecommands.annotations.command.Command;
6-
import dev.rollczi.litecommands.annotations.context.Context;
6+
import dev.rollczi.litecommands.annotations.context.Sender;
77
import dev.rollczi.litecommands.annotations.execute.Execute;
88
import org.bukkit.entity.Player;
99

@@ -17,27 +17,27 @@ public ApiIgnoreCommand(IgnoreService ignoreService) {
1717
}
1818

1919
@Execute(name = "ignore")
20-
void executeIgnore(@Context Player player, @Arg Player target) {
20+
void executeIgnore(@Sender Player player, @Arg Player target) {
2121
this.ignoreService.ignore(player.getUniqueId(), target.getUniqueId());
2222
String message = "You have ignored %s via eternalcore api bridge!";
2323
player.sendMessage(String.format(message, target.getName()));
2424
}
2525

2626
@Execute(name = "unignore")
27-
void executeUnignore(@Context Player player, @Arg Player target) {
27+
void executeUnignore(@Sender Player player, @Arg Player target) {
2828
this.ignoreService.unIgnore(player.getUniqueId(), target.getUniqueId());
2929
String message = "You have unignored %s via eternalcore api bridge!";
3030
player.sendMessage(String.format(message, target.getName()));
3131
}
3232

3333
@Execute(name = "ignoreall")
34-
void executeIgnoreAll(@Context Player player) {
34+
void executeIgnoreAll(@Sender Player player) {
3535
this.ignoreService.ignoreAll(player.getUniqueId());
3636
player.sendMessage("You have ignored all players via eternalcore api bridge!");
3737
}
3838

3939
@Execute(name = "unignoreall")
40-
void executeUnignoreAll(@Context Player player) {
40+
void executeUnignoreAll(@Sender Player player) {
4141
this.ignoreService.unIgnoreAll(player.getUniqueId());
4242
player.sendMessage("You have unignored all players via eternalcore api bridge!");
4343
}

eternalcore-api-example/src/main/java/com/eternalcode/example/feature/jail/ApiJailCommand.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.eternalcode.core.feature.jail.JailService;
44
import dev.rollczi.litecommands.annotations.command.Command;
5-
import dev.rollczi.litecommands.annotations.context.Context;
5+
import dev.rollczi.litecommands.annotations.context.Sender;
66
import dev.rollczi.litecommands.annotations.execute.Execute;
77
import org.bukkit.entity.Player;
88

@@ -19,7 +19,7 @@ public ApiJailCommand(JailService jailService) {
1919
* This method allows jailed player to buy freedom for 1 exp.
2020
*/
2121
@Execute(name = "buy freedom")
22-
void executeBuyFreedom(@Context Player player) {
22+
void executeBuyFreedom(@Sender Player player) {
2323
if (!this.jailService.isPlayerJailed(player.getUniqueId())) {
2424
player.sendMessage("You are not jailed!");
2525
return;

eternalcore-api-example/src/main/java/com/eternalcode/example/feature/randomteleport/ApiRandomTeleportCommand.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.eternalcode.core.feature.randomteleport.RandomTeleportService;
44
import dev.rollczi.litecommands.annotations.argument.Arg;
55
import dev.rollczi.litecommands.annotations.command.Command;
6-
import dev.rollczi.litecommands.annotations.context.Context;
6+
import dev.rollczi.litecommands.annotations.context.Sender;
77
import dev.rollczi.litecommands.annotations.execute.Execute;
88
import java.util.concurrent.CompletableFuture;
99
import org.bukkit.Location;
@@ -20,7 +20,7 @@ public ApiRandomTeleportCommand(RandomTeleportService randomTeleportService) {
2020
}
2121

2222
@Execute(name = "safe-random-location")
23-
void execute(@Context Player player, @Arg int attempts) {
23+
void execute(@Sender Player player, @Arg int attempts) {
2424
World world = player.getWorld();
2525

2626
CompletableFuture<Location> safeRandomLocation =
@@ -30,7 +30,7 @@ void execute(@Context Player player, @Arg int attempts) {
3030
}
3131

3232
@Execute(name = "safe-random-location-with-radius")
33-
void execute(@Context Player player, @Arg int radius, @Arg int attempts) {
33+
void execute(@Sender Player player, @Arg int radius, @Arg int attempts) {
3434
World world = player.getWorld();
3535

3636
CompletableFuture<Location> safeRandomLocation =
@@ -40,12 +40,12 @@ void execute(@Context Player player, @Arg int radius, @Arg int attempts) {
4040
}
4141

4242
@Execute(name = "teleport")
43-
void execute(@Context Player player, @Arg Player target) {
43+
void execute(@Sender Player player, @Arg Player target) {
4444
this.randomTeleportService.teleport(target);
4545
}
4646

4747
@Execute(name = "teleport")
48-
void execute(@Context Player player, @Arg Player target, @Arg World world) {
48+
void execute(@Sender Player player, @Arg Player target, @Arg World world) {
4949
this.randomTeleportService.teleport(target, world);
5050
}
5151
}

eternalcore-api-example/src/main/java/com/eternalcode/example/feature/spawn/ApiSpawnCommand.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.eternalcode.core.feature.spawn.SpawnService;
44
import dev.rollczi.litecommands.annotations.argument.Arg;
55
import dev.rollczi.litecommands.annotations.command.Command;
6-
import dev.rollczi.litecommands.annotations.context.Context;
6+
import dev.rollczi.litecommands.annotations.context.Sender;
77
import dev.rollczi.litecommands.annotations.execute.Execute;
88
import org.bukkit.entity.Player;
99

@@ -17,20 +17,20 @@ public ApiSpawnCommand(SpawnService spawnService) {
1717
}
1818

1919
@Execute(name = "set")
20-
void execute(@Context Player player) {
20+
void execute(@Sender Player player) {
2121
this.spawnService.setSpawnLocation(player.getLocation());
2222
player.sendMessage("You have set the spawn location via EternalCore developer api bridge, congratulations!");
2323
}
2424

2525
@Execute(name = "teleport")
26-
void executeTeleport(@Context Player player, @Arg Player target) {
26+
void executeTeleport(@Sender Player player, @Arg Player target) {
2727
this.spawnService.teleportToSpawn(target);
2828
String message = "You have teleported %s to the spawn location via EternalCore developer api bridge, congratulations!";
2929
player.sendMessage(String.format(message, target.getName()));
3030
}
3131

3232
@Execute(name = "spawnlocation")
33-
void executeSpawnLocation(@Context Player player) {
33+
void executeSpawnLocation(@Sender Player player) {
3434
player.sendMessage("The spawn location is set at: " + this.spawnService.getSpawnLocation());
3535
}
3636
}

eternalcore-core/src/main/java/com/eternalcode/core/EternalCoreCommand.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
package com.eternalcode.core;
22

33
import com.eternalcode.annotations.scan.command.DescriptionDocs;
4-
import com.eternalcode.commons.scheduler.Scheduler;
54
import com.eternalcode.core.configuration.ConfigurationManager;
65
import com.eternalcode.core.injector.annotations.Inject;
76
import com.eternalcode.core.publish.Publisher;
87
import com.eternalcode.core.publish.event.EternalReloadEvent;
98
import com.google.common.base.Stopwatch;
109
import dev.rollczi.litecommands.annotations.async.Async;
11-
import dev.rollczi.litecommands.annotations.context.Context;
10+
import dev.rollczi.litecommands.annotations.command.Command;
11+
import dev.rollczi.litecommands.annotations.context.Sender;
1212
import dev.rollczi.litecommands.annotations.execute.Execute;
1313
import dev.rollczi.litecommands.annotations.permission.Permission;
14-
import dev.rollczi.litecommands.annotations.command.Command;
14+
import java.util.concurrent.TimeUnit;
1515
import net.kyori.adventure.audience.Audience;
1616
import net.kyori.adventure.text.Component;
1717
import net.kyori.adventure.text.minimessage.MiniMessage;
1818

19-
import java.time.Duration;
20-
import java.util.concurrent.TimeUnit;
21-
2219
@Command(name = "eternalcore")
2320
@Permission("eternalcore.eternalcore")
2421
class EternalCoreCommand {
@@ -39,7 +36,7 @@ class EternalCoreCommand {
3936
@Async
4037
@Execute(name = "reload")
4138
@DescriptionDocs(description = "Reloads EternalCore configuration")
42-
void reload(@Context Audience audience) {
39+
void reload(@Sender Audience audience) {
4340
long millis = this.reload();
4441
Component message = this.miniMessage.deserialize(RELOAD_MESSAGE.formatted(millis));
4542

eternalcore-core/src/main/java/com/eternalcode/core/feature/afk/AfkCommand.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import com.eternalcode.core.notice.NoticeService;
1010
import com.eternalcode.core.util.DurationUtil;
1111
import dev.rollczi.litecommands.annotations.command.Command;
12-
import dev.rollczi.litecommands.annotations.context.Context;
12+
import dev.rollczi.litecommands.annotations.context.Sender;
1313
import dev.rollczi.litecommands.annotations.execute.Execute;
1414
import dev.rollczi.litecommands.annotations.permission.Permission;
1515
import java.time.Duration;
@@ -42,7 +42,7 @@ class AfkCommand {
4242

4343
@Execute
4444
@DescriptionDocs(description = "Toggles AFK status for the player.")
45-
void execute(@Context Player player) {
45+
void execute(@Sender Player player) {
4646
UUID uuid = player.getUniqueId();
4747

4848
if (player.hasPermission(AFK_BYPASS_PERMISSION)) {

eternalcore-core/src/main/java/com/eternalcode/core/feature/automessage/AutoMessageCommand.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.eternalcode.core.injector.annotations.Inject;
55
import com.eternalcode.core.notice.NoticeService;
66
import dev.rollczi.litecommands.annotations.command.Command;
7-
import dev.rollczi.litecommands.annotations.context.Context;
7+
import dev.rollczi.litecommands.annotations.context.Sender;
88
import dev.rollczi.litecommands.annotations.execute.Execute;
99
import dev.rollczi.litecommands.annotations.permission.Permission;
1010
import org.bukkit.entity.Player;
@@ -24,7 +24,7 @@ class AutoMessageCommand {
2424

2525
@Execute
2626
@DescriptionDocs(description = "Toggles the display of automatic messages.")
27-
void execute(@Context Player player) {
27+
void execute(@Sender Player player) {
2828
this.autoMessageService.switchReceiving(player.getUniqueId()).thenAccept(receiving -> {
2929
if (receiving) {
3030
this.noticeService.player(player.getUniqueId(), messages -> messages.autoMessage().enabled());

eternalcore-core/src/main/java/com/eternalcode/core/feature/burn/BurnCommand.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
import com.eternalcode.core.notice.NoticeService;
66
import dev.rollczi.litecommands.annotations.argument.Arg;
77
import dev.rollczi.litecommands.annotations.command.Command;
8-
import dev.rollczi.litecommands.annotations.context.Context;
8+
import dev.rollczi.litecommands.annotations.context.Sender;
99
import dev.rollczi.litecommands.annotations.execute.Execute;
1010
import dev.rollczi.litecommands.annotations.permission.Permission;
11-
import org.bukkit.entity.Player;
12-
1311
import java.util.Optional;
12+
import org.bukkit.entity.Player;
1413

1514
@Command(name = "burn", aliases = {"ignite"})
1615
@Permission("eternalcore.burn")
@@ -26,14 +25,14 @@ public BurnCommand(NoticeService noticeService) {
2625

2726
@Execute
2827
@DescriptionDocs(description = "Burns yourself for a specified amount of ticks.", arguments = "[ticks]")
29-
void self(@Context Player sender, @Arg Optional<Integer> ticks) {
28+
void self(@Sender Player sender, @Arg Optional<Integer> ticks) {
3029
this.burn(sender, sender, ticks);
3130
}
3231

3332
@Execute
3433
@Permission("eternalcore.burn.other")
3534
@DescriptionDocs(description = "Burns target for a specified amount of ticks.", arguments = "<target> [ticks]")
36-
void other(@Context Player sender, @Arg Player target, @Arg Optional<Integer> ticks) {
35+
void other(@Sender Player sender, @Arg Player target, @Arg Optional<Integer> ticks) {
3736
this.burn(sender, target, ticks);
3837
}
3938

0 commit comments

Comments
 (0)