Skip to content

Commit

Permalink
feat: continue event implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakShearman committed Mar 15, 2024
1 parent 2b289da commit a4272be
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {
annotationProcessor("com.velocitypowered:velocity-api:3.2.0-SNAPSHOT")
implementation("net.kyori:adventure-text-minimessage:4.14.0")

implementation("dev.emortal.api:common-proto-sdk:1797f88")
implementation("dev.emortal.api:common-proto-sdk:15284aa")
implementation("dev.emortal.api:agones-sdk:1.0.7")
implementation("dev.emortal.api:live-config-parser:8f566b9")
implementation("dev.emortal.api:module-system:1.0.0")
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/dev/emortal/velocity/lang/ChatMessages.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ public interface ChatMessages {
};
Args1<EventData> EVENT_CREATED = event -> green("Event created:").appendNewline().append(EVENT_VALUE.get(event));
Args1<String> ERROR_EVENT_ALREADY_EXISTS = id -> red("And event with the ID '" + id + "' already exists");
Args1<String> EVENT_DELETED = id -> green("Event '" + id + "' deleted");
Args0 CURRENT_EVENT_DELETED = () -> green("Ongoing event deleted");
Args0 ERROR_NO_CURRENT_EVENT_DELETE = () -> green("There is no ongoing event to delete. Use /event delete <id> to delete by ID.");
Args1<String> ERROR_EVENT_NOT_FOUND = id -> red("Event not found with id '" + id + "'");

Args1<String> ROLE_CREATED = role -> green("Role " + role + " created");
Args4<String, Integer, Integer, Component> ROLE_DESCRIPTION = (id, priority, permissions, displayName) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import dev.emortal.velocity.command.EmortalCommand;
import dev.emortal.velocity.lang.ChatMessages;
import dev.emortal.velocity.party.commands.event.subs.CreateSub;
import dev.emortal.velocity.party.commands.event.subs.DeleteSub;
import dev.emortal.velocity.party.commands.event.subs.ListSub;

public class EventCommand extends EmortalCommand {
Expand All @@ -26,6 +27,11 @@ public EventCommand(PartyService partyService) {
super.addSyntax(this::createUsage, literal("create"), literal("help"));
super.addSyntax(new CreateSub(partyService), literal("create"), argument("id", StringArgumentType.word()),
argument("showTime", StringArgumentType.word()), argument("startTime", StringArgumentType.word()));

// Delete
DeleteSub deleteSub = new DeleteSub(partyService);
super.addSyntax(deleteSub, literal("delete"));
super.addSyntax(deleteSub, literal("delete"), argument("id", StringArgumentType.word()));
}

private void createUsage(CommandContext<CommandSource> context) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package dev.emortal.velocity.party.commands.event.subs;

import com.velocitypowered.api.command.CommandSource;
import dev.emortal.api.service.party.DeleteEventResult;
import dev.emortal.api.service.party.PartyService;
import dev.emortal.velocity.command.ArgumentProvider;
import dev.emortal.velocity.command.EmortalCommandExecutor;
import dev.emortal.velocity.lang.ChatMessages;
import org.jetbrains.annotations.NotNull;

public class DeleteSub implements EmortalCommandExecutor {

private final @NotNull PartyService partyService;

public DeleteSub(@NotNull PartyService partyService) {
this.partyService = partyService;
}

@Override
public void execute(@NotNull CommandSource source, @NotNull ArgumentProvider arguments) {
String id;
if (arguments.hasArgument("id")) id = arguments.getArgument("id", String.class);
else id = null;

DeleteEventResult result = this.partyService.deleteEvent(id);
switch (result) {
case SUCCESS -> {
if (id == null) ChatMessages.CURRENT_EVENT_DELETED.send(source);
else ChatMessages.EVENT_DELETED.send(source, id);
}
case NO_CURRENT_EVENT -> ChatMessages.ERROR_NO_CURRENT_EVENT_DELETE.send(source);
case NOT_FOUND -> ChatMessages.ERROR_EVENT_NOT_FOUND.send(source, id);
}
}
}

0 comments on commit a4272be

Please sign in to comment.