Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-563 LiteCommands 2.8.9 -> 3x. #563

Merged
merged 21 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/HOW_USE_DI.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public class UserListener implements Listener {
```
#### 6. Command
```java
@Route(name = "example") // <- marks a class that will be registered as a command.
@Command(name = "example") // <- marks a class that will be registered as a command.
public class UserCommand {

private final UserService exampleService;
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/eternalcode-java-test.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

dependencies {
testImplementation("dev.rollczi.litecommands:core:2.8.9")
testImplementation("dev.rollczi:litecommands-core:3.0.3")
testImplementation("org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT")
testImplementation("net.dzikoysk:cdn:1.14.4")
testImplementation("org.panda-lang:expressible-junit:1.3.6")
Expand Down
3 changes: 2 additions & 1 deletion eternalcore-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ eternalShadow {
library("com.zaxxer:HikariCP:5.1.0")

// command framework & skull library
library("dev.rollczi.litecommands:bukkit-adventure:2.8.9")
library("dev.rollczi:litecommands-bukkit:3.2.0")
library("dev.rollczi:litecommands-adventure-platform:3.1.2")
library("dev.rollczi:liteskullapi:1.3.0")
libraryRelocate(
"dev.rollczi.litecommands",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import com.eternalcode.core.injector.bean.processor.BeanProcessorFactory;
import com.eternalcode.core.injector.scan.DependencyScanner;
import com.eternalcode.core.injector.scan.DependencyScannerFactory;
import com.eternalcode.core.publish.Publisher;
import com.eternalcode.core.publish.event.EternalInitializeEvent;
import com.eternalcode.core.publish.event.EternalShutdownEvent;
import com.eternalcode.core.publish.Publisher;
import net.dzikoysk.cdn.entity.Contextual;
import org.bukkit.Server;
vLuckyyy marked this conversation as resolved.
Show resolved Hide resolved
import org.bukkit.plugin.Plugin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
import com.eternalcode.core.configuration.ConfigurationManager;
import com.eternalcode.core.injector.annotations.Inject;
import com.google.common.base.Stopwatch;
import dev.rollczi.litecommands.command.async.Async;
import dev.rollczi.litecommands.command.execute.Execute;
import dev.rollczi.litecommands.command.permission.Permission;
import dev.rollczi.litecommands.command.route.Route;
import dev.rollczi.litecommands.annotations.async.Async;
import dev.rollczi.litecommands.annotations.context.Context;
import dev.rollczi.litecommands.annotations.execute.Execute;
import dev.rollczi.litecommands.annotations.permission.Permission;
import dev.rollczi.litecommands.annotations.command.Command;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;

import java.util.concurrent.TimeUnit;

@Route(name = "eternalcore")
@Command(name = "eternalcore")
@Permission("eternalcore.eternalcore")
class EternalCoreCommand {

Expand All @@ -30,9 +31,9 @@ class EternalCoreCommand {
}

@Async
@Execute(route = "reload")
@Execute(name = "reload")
@DescriptionDocs(description = "Reloads EternalCore configuration")
void reload(Audience audience) {
void reload(@Context Audience audience) {
long millis = this.reload();
Component message = this.miniMessage.deserialize(RELOAD_MESSAGE.formatted(millis));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
import com.eternalcode.core.injector.annotations.Inject;
import com.eternalcode.core.notice.NoticeBroadcast;
import com.eternalcode.core.notice.NoticeService;
import dev.rollczi.litecommands.argument.joiner.Joiner;
import dev.rollczi.litecommands.command.execute.Execute;
import dev.rollczi.litecommands.command.permission.Permission;
import dev.rollczi.litecommands.command.route.Route;
import dev.rollczi.litecommands.annotations.context.Context;
import dev.rollczi.litecommands.annotations.join.Join;
import dev.rollczi.litecommands.annotations.execute.Execute;
import dev.rollczi.litecommands.annotations.permission.Permission;
import dev.rollczi.litecommands.annotations.command.Command;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

@Route(name = "adminchat", aliases = "ac")
@Command(name = "adminchat", aliases = "ac")
@Permission("eternalcore.adminchat")
class AdminChatCommand {

Expand All @@ -25,9 +26,9 @@ class AdminChatCommand {
this.server = server;
}

@Execute(min = 1)
@Execute
@DescriptionDocs(description = "Sends a message to all staff members with eternalcore.adminchat.spy permissions", arguments = "<message>")
void execute(CommandSender sender, @Joiner String message) {
void execute(@Context CommandSender sender, @Join String message) {
NoticeBroadcast notice = this.noticeService.create()
.console()
.notice(translation -> translation.adminChat().format())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
import com.eternalcode.core.injector.annotations.Inject;
import com.eternalcode.core.notice.NoticeService;
import com.eternalcode.core.util.DurationUtil;
import dev.rollczi.litecommands.command.execute.Execute;
import dev.rollczi.litecommands.command.permission.Permission;
import dev.rollczi.litecommands.command.route.Route;
import dev.rollczi.litecommands.annotations.context.Context;
import dev.rollczi.litecommands.annotations.execute.Execute;
import dev.rollczi.litecommands.annotations.permission.Permission;
import dev.rollczi.litecommands.annotations.command.Command;
import org.bukkit.entity.Player;

import java.time.Duration;
import java.util.UUID;

@Route(name = "afk")
@Command(name = "afk")
@Permission("eternalcore.afk")
@FeatureDocs(
name = "Afk",
Expand All @@ -39,7 +40,7 @@ class AfkCommand {

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

if (this.delay.hasDelay(uuid)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import com.eternalcode.annotations.scan.command.DescriptionDocs;
import com.eternalcode.core.injector.annotations.Inject;
import com.eternalcode.core.notice.NoticeService;
import dev.rollczi.litecommands.command.execute.Execute;
import dev.rollczi.litecommands.command.permission.Permission;
import dev.rollczi.litecommands.command.route.Route;
import dev.rollczi.litecommands.annotations.context.Context;
import dev.rollczi.litecommands.annotations.execute.Execute;
import dev.rollczi.litecommands.annotations.permission.Permission;
import dev.rollczi.litecommands.annotations.command.Command;
import org.bukkit.entity.Player;

@Route(name = "automessage", aliases = { "automsg" })
@Command(name = "automessage", aliases = { "automsg" })
@Permission("eternalcore.automessage")
class AutoMessageCommand {

Expand All @@ -23,7 +24,7 @@ class AutoMessageCommand {

@Execute
@DescriptionDocs(description = "Toggles the display of automatic messages.")
void execute(Player player) {
void execute(@Context Player player) {
this.autoMessageService.switchReceiving(player.getUniqueId()).then(receiving -> {
if (receiving) {
this.noticeService.player(player.getUniqueId(), messages -> messages.autoMessage().enabled());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@
import com.eternalcode.core.notice.Notice;
import com.eternalcode.core.notice.NoticeService;
import com.eternalcode.core.viewer.Viewer;
import dev.rollczi.litecommands.argument.Arg;
import dev.rollczi.litecommands.command.execute.Execute;
import dev.rollczi.litecommands.command.permission.Permission;
import dev.rollczi.litecommands.command.route.Route;
import dev.rollczi.litecommands.shared.EstimatedTemporalAmountParser;
import dev.rollczi.litecommands.annotations.argument.Arg;
import dev.rollczi.litecommands.annotations.context.Context;
import dev.rollczi.litecommands.annotations.execute.Execute;
import dev.rollczi.litecommands.annotations.permission.Permission;
import dev.rollczi.litecommands.annotations.command.Command;
import java.util.function.Supplier;

import dev.rollczi.litecommands.time.DurationParser;
import org.bukkit.command.CommandSender;

import java.time.Duration;

@Route(name = "chat")
@Command(name = "chat")
@Permission("eternalcore.chat")
class ChatManagerCommand {

Expand All @@ -31,9 +32,9 @@ class ChatManagerCommand {
this.clear = create(settings);
}

@Execute(route = "clear", aliases = "cc")
@Execute(name = "clear", aliases = "cc")
@DescriptionDocs(description = "Clears chat")
void clear(CommandSender sender) {
void clear(@Context CommandSender sender) {
this.noticeService.create()
.staticNotice(this.clear.get())
.notice(translation -> translation.chat().cleared())
Expand All @@ -42,9 +43,9 @@ void clear(CommandSender sender) {
.send();
}

@Execute(route = "on")
@Execute(name = "on")
@DescriptionDocs(description = "Enables chat")
void enable(Viewer viewer, CommandSender sender) {
void enable(@Context Viewer viewer, @Context CommandSender sender) {
if (this.chatManager.getChatSettings().isChatEnabled()) {
this.noticeService.viewer(viewer, translation -> translation.chat().alreadyEnabled());
return;
Expand All @@ -59,9 +60,9 @@ void enable(Viewer viewer, CommandSender sender) {
.send();
}

@Execute(route = "off")
@Execute(name = "off")
@DescriptionDocs(description = "Disables chat")
void disable(Viewer viewer, CommandSender sender) {
void disable(@Context Viewer viewer, @Context CommandSender sender) {
if (!this.chatManager.getChatSettings().isChatEnabled()) {
this.noticeService.viewer(viewer, translation -> translation.chat().alreadyDisabled());
return;
Expand All @@ -76,24 +77,42 @@ void disable(Viewer viewer, CommandSender sender) {
.send();
}

@Execute(route = "slowmode", required = 1)
@Execute(name = "slowmode")
@DescriptionDocs(description = "Sets slowmode for chat", arguments = "<time>")
void slowmode(Viewer viewer, @Arg Duration duration) {
void slowmode(@Context Viewer viewer, @Arg Duration duration) {
if (duration.isNegative()) {
this.noticeService.viewer(viewer, translation -> translation.argument().numberBiggerThanOrEqualZero());

return;
}

if (duration.isZero()) {
this.noticeService.create()
.notice(translation -> translation.chat().slowModeOff())
.placeholder("{PLAYER}", viewer.getName())
.onlinePlayers()
.send();

this.chatManager.getChatSettings().setChatDelay(duration);
return;
}

this.chatManager.getChatSettings().setChatDelay(duration);

this.noticeService.create()
.notice(translation -> translation.chat().slowModeSet())
.placeholder("{SLOWMODE}", EstimatedTemporalAmountParser.TIME_UNITS.format(duration))
.viewer(viewer)
.placeholder("{SLOWMODE}", DurationParser.TIME_UNITS.format(duration))
.onlinePlayers()
.send();
}

@Execute(name = "slowmode 0")
@DescriptionDocs(description = "Disable SlowMode for chat")
void slowmodeOff(@Context Viewer viewer) {
Duration noSlowMode = Duration.ZERO;
this.slowmode(viewer, noSlowMode);
}

private static Supplier<Notice> create(ChatSettings settings) {
return () -> Notice.chat("<newline>".repeat(Math.max(0, settings.linesToClear())));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import com.eternalcode.core.injector.annotations.Inject;
import com.eternalcode.core.notice.NoticeService;
import com.eternalcode.core.notice.NoticeTextType;
import dev.rollczi.litecommands.argument.Arg;
import dev.rollczi.litecommands.argument.joiner.Joiner;
import dev.rollczi.litecommands.command.execute.Execute;
import dev.rollczi.litecommands.command.permission.Permission;
import dev.rollczi.litecommands.command.route.Route;
import dev.rollczi.litecommands.annotations.argument.Arg;
import dev.rollczi.litecommands.annotations.join.Join;
import dev.rollczi.litecommands.annotations.execute.Execute;
import dev.rollczi.litecommands.annotations.permission.Permission;
import dev.rollczi.litecommands.annotations.command.Command;

@Route(name = "alert", aliases = { "broadcast", "bc" })
@Command(name = "alert", aliases = { "broadcast", "bc" })
@Permission("eternalcore.alert")
class AlertCommand {

Expand All @@ -21,9 +21,9 @@ class AlertCommand {
this.noticeService = noticeService;
}

@Execute(min = 2)
@Execute
@DescriptionDocs(description = "Sends alert to all players with specified notice type and messages", arguments = "<type> <message>")
void execute(@Arg NoticeTextType type, @Joiner String text) {
void execute(@Arg NoticeTextType type, @Join String text) {
this.noticeService.create()
.notice(type, translation -> translation.chat().alertMessageFormat())
.placeholder("{BROADCAST}", text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
import com.eternalcode.core.injector.annotations.Inject;
import com.eternalcode.core.notice.NoticeService;
import com.eternalcode.core.viewer.Viewer;
import dev.rollczi.litecommands.argument.Arg;
import dev.rollczi.litecommands.command.execute.Execute;
import dev.rollczi.litecommands.command.permission.Permission;
import dev.rollczi.litecommands.command.route.Route;
import dev.rollczi.litecommands.annotations.argument.Arg;
import dev.rollczi.litecommands.annotations.context.Context;
import dev.rollczi.litecommands.annotations.execute.Execute;
import dev.rollczi.litecommands.annotations.permission.Permission;
import dev.rollczi.litecommands.annotations.command.Command;
import org.bukkit.entity.Player;

@Route(name = "feed")
@Command(name = "feed")
class FeedCommand {

private final NoticeService noticeService;
Expand All @@ -20,10 +21,10 @@ class FeedCommand {
this.noticeService = noticeService;
}

@Execute(required = 0)
@Execute
@Permission("eternalcore.feed")
@DescriptionDocs(description = "Feed yourself")
void execute(Player player) {
void execute(@Context Player player) {
this.feed(player);

this.noticeService.create()
Expand All @@ -32,10 +33,10 @@ void execute(Player player) {
.send();
}

@Execute(required = 1)
@Execute
@Permission("eternalcore.feed.other")
@DescriptionDocs(description = "Feed other player", arguments = "<player>")
void execute(Viewer viewer, @Arg Player target) {
void execute(@Context Viewer viewer, @Arg Player target) {
this.feed(target);

this.noticeService.create()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
import com.eternalcode.core.injector.annotations.Inject;
import com.eternalcode.core.notice.NoticeService;
import com.eternalcode.core.viewer.Viewer;
import dev.rollczi.litecommands.argument.Arg;
import dev.rollczi.litecommands.command.execute.Execute;
import dev.rollczi.litecommands.command.permission.Permission;
import dev.rollczi.litecommands.command.route.Route;
import dev.rollczi.litecommands.annotations.argument.Arg;
import dev.rollczi.litecommands.annotations.context.Context;
import dev.rollczi.litecommands.annotations.execute.Execute;
import dev.rollczi.litecommands.annotations.permission.Permission;
import dev.rollczi.litecommands.annotations.command.Command;
import org.bukkit.entity.Player;

@Route(name = "fly")
@Command(name = "fly")
class FlyCommand {

private final NoticeService noticeService;
Expand All @@ -20,10 +21,10 @@ class FlyCommand {
this.noticeService = noticeService;
}

@Execute(required = 0)
@Execute
@Permission("eternalcore.fly")
@DescriptionDocs(description = "Toggle fly mode")
void execute(Player player) {
void execute(@Context Player player) {
player.setAllowFlight(!player.getAllowFlight());

this.noticeService.create()
Expand All @@ -33,10 +34,10 @@ void execute(Player player) {
.send();
}

@Execute(required = 1)
@Execute
@Permission("eternalcore.fly.other")
@DescriptionDocs(description = "Toggle fly mode for specified player", arguments = "<player>")
void execute(Viewer viewer, @Arg Player target) {
void execute(@Context Viewer viewer, @Arg Player target) {
target.setAllowFlight(!target.getAllowFlight());

this.noticeService.create()
Expand Down
Loading