-
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.
Implemented /mute, /ban, /unmute und /unban commands
API: Change return type of punishing methods to CompletableFuture<...>, thus exceptions are no longer swallowed and be easily checked by a handler. MiniMessage is now being used to serialize reasons when sending over messaging channels Fixed some smaller issues
- Loading branch information
Showing
22 changed files
with
482 additions
and
55 deletions.
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
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
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
necrify-common/src/main/java/de/jvstvshd/necrify/common/commands/NecrifyUserParser.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 de.jvstvshd.necrify.common.commands; | ||
|
||
import de.jvstvshd.necrify.api.user.NecrifyUser; | ||
import de.jvstvshd.necrify.api.user.UserManager; | ||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
import org.incendo.cloud.context.CommandContext; | ||
import org.incendo.cloud.context.CommandInput; | ||
import org.incendo.cloud.parser.ArgumentParseResult; | ||
import org.incendo.cloud.parser.ArgumentParser; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class NecrifyUserParser implements ArgumentParser.FutureArgumentParser<NecrifyUser, NecrifyUser> { | ||
|
||
private final UserManager userManager; | ||
|
||
public NecrifyUserParser(UserManager userManager) { | ||
this.userManager = userManager; | ||
} | ||
|
||
@Override | ||
public @NonNull CompletableFuture<@NonNull ArgumentParseResult<NecrifyUser>> parseFuture(@NonNull CommandContext<NecrifyUser> commandContext, @NonNull CommandInput commandInput) { | ||
var target = commandInput.peekString(); | ||
return userManager.loadOrCreateUser(target).handle((necrifyUser, throwable) -> { | ||
if (throwable != null) { | ||
return ArgumentParseResult.failure(throwable); | ||
} | ||
if (necrifyUser.isPresent()) { | ||
commandInput.readString(); | ||
return ArgumentParseResult.success(necrifyUser.get()); | ||
} | ||
return ArgumentParseResult.failure(new UserNotFoundParseException(NecrifyUser.class, commandContext, target)); | ||
}); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...-common/src/main/java/de/jvstvshd/necrify/common/commands/UserNotFoundParseException.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,20 @@ | ||
package de.jvstvshd.necrify.common.commands; | ||
|
||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
import org.incendo.cloud.caption.Caption; | ||
import org.incendo.cloud.context.CommandContext; | ||
import org.incendo.cloud.exception.parsing.ParserException; | ||
|
||
public class UserNotFoundParseException extends ParserException { | ||
|
||
private final String playerName; | ||
|
||
public UserNotFoundParseException(@NonNull Class<?> argumentParser, @NonNull CommandContext<?> context, String playerName) { | ||
super(argumentParser, context, Caption.of("")); | ||
this.playerName = playerName; | ||
} | ||
|
||
public String playerName() { | ||
return playerName; | ||
} | ||
} |
Oops, something went wrong.