-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b289da
commit a4272be
Showing
4 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/dev/emortal/velocity/party/commands/event/subs/DeleteSub.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |