-
-
Notifications
You must be signed in to change notification settings - Fork 21
GH-1213 Remove usage of panda-utilities and panda expressible. #1213
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
Conversation
vLuckyyy
commented
Oct 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request removes the usage of panda-utilities and panda-expressible libraries from the project. The changes involve updating the Versions.kt file, removing dependencies in build.gradle.kts files, and replacing usages of panda-utilities with standard Java/Bukkit alternatives in several Java files. The code has been reviewed and suggestions have been made to improve code clarity and maintainability.
eternalcore-core/src/main/java/com/eternalcode/core/feature/teleport/TeleportTask.java
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/litecommand/argument/GameModeArgument.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/util/MaterialUtil.java
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/litecommand/argument/GameModeArgument.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/litecommand/argument/GameModeArgument.java
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/litecommand/argument/GameModeArgument.java
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/litecommand/argument/GameModeArgument.java
Show resolved
Hide resolved
|
Dodam jeszcze od siebie male co nieco odnosnie organizacji i kodu shared ktory moze potem sie przydac: Mozna zarysowac takie flow tzw. final class ParserPipeline<INPUT, OUTPUT> {
private final Function<INPUT, ParseResult<OUTPUT>> parser;
private ParserPipeline(Function<INPUT, ParseResult<OUTPUT>> parser) {
this.parser = parser;
}
public static <INPUT, OUTPUT> ParserPipeline<INPUT, OUTPUT> of() {
return new ParserPipeline<>(input -> ParseResult.failure(null));
}
public ParserPipeline<INPUT, OUTPUT> thenTry(Function<INPUT, ParseResult<OUTPUT>> nextParser) {
return new ParserPipeline<>(input -> {
ParseResult<OUTPUT> currentResult = this.parser.apply(input);
if (currentResult.isSuccess()) {
return currentResult;
}
return nextParser.apply(input);
});
}
public ParserPipeline<INPUT, OUTPUT> thenTryIf(Predicate<INPUT> condition, Function<INPUT, ParseResult<OUTPUT>> nextParser) {
return new ParserPipeline<>(input -> {
ParseResult<OUTPUT> currentResult = this.parser.apply(input);
if (currentResult.isSuccess()) {
return currentResult;
}
if (condition.test(input)) {
return nextParser.apply(input);
}
return ParseResult.failure(null);
});
}
public ParserPipeline<INPUT, OUTPUT> thenMap(Function<INPUT, OUTPUT> mapper) {
return new ParserPipeline<>(input -> {
ParseResult<OUTPUT> currentResult = this.parser.apply(input);
if (currentResult.isSuccess()) {
return currentResult;
}
try {
OUTPUT result = mapper.apply(input);
return ParseResult.success(result);
} catch (Exception e) {
return ParseResult.failure(null);
}
});
}
public Function<INPUT, ParseResult<OUTPUT>> build() {
return this.parser;
}
public Function<INPUT, ParseResult<OUTPUT>> buildWithFinalFailure(Function<INPUT, ParseResult<OUTPUT>> finalFailure) {
return input -> {
ParseResult<OUTPUT> result = this.parser.apply(input);
if (result.isSuccess()) {
return result;
}
return finalFailure.apply(input);
};
}
public Function<INPUT, ParseResult<OUTPUT>> buildWithFinalFailure(Supplier<ParseResult<OUTPUT>> finalFailure) {
return input -> {
ParseResult<OUTPUT> result = this.parser.apply(input);
if (result.isSuccess()) {
return result;
}
return finalFailure.get();
};
}
}Finalna klasa: @LiteArgument(type = GameMode.class)
class GameModeArgument extends AbstractViewerArgument<GameMode> {
private final GameModeArgumentSettings gameModeArgumentSettings;
private final Function<String, ParseResult<GameMode>> gameModeParser;
@Inject
GameModeArgument(TranslationManager translationManager, GameModeArgumentSettings gameModeArgumentSettings) {
super(translationManager);
this.gameModeArgumentSettings = gameModeArgumentSettings;
this.gameModeParser = createGameModeParser();
}
@Override
public ParseResult<GameMode> parse(Invocation<CommandSender> invocation, String argument, Translation translation) {
// walidacja jezeli lc robi to zbedne
if (argument == null || argument.trim().isEmpty()) {
return ParseResult.failure(translation.player().gameModeNotCorrect());
}
String normalizedInput = argument.trim().toUpperCase(Locale.ROOT);
return gameModeParser.apply(normalizedInput);
}
@Override
public SuggestionResult suggest(
Invocation<CommandSender> invocation,
Argument<GameMode> argument,
SuggestionContext context
) {
return this.gameModeArgumentSettings.getAvailableAliases()
.stream()
.collect(SuggestionResult.collector());
}
private Function<String, ParseResult<GameMode>> createGameModeParser() {
return ParserPipeline.of()
.thenTry(this::parseDirectGameMode)
.thenTry(this::parseFromAliases)
.buildWithFinalFailure(input -> ParseResult.failure(translation.player().gameModeNotCorrect()));
}
private ParseResult<GameMode> parseDirectGameMode(String normalizedInput) {
try {
GameMode gameMode = GameMode.valueOf(normalizedInput);
return ParseResult.success(gameMode);
} catch (IllegalArgumentException exception) {
return ParseResult.failure(null);
}
}
private ParseResult<GameMode> parseFromAliases(String normalizedInput) {
// naprawa case inconsistency
GameMode gameMode = this.gameModeArgumentSettings.getByAlias(normalizedInput);
if (gameMode != null) {
return ParseResult.success(gameMode);
}
return ParseResult.failure(null);
}
} |
eternalcore-core/src/main/java/com/eternalcode/core/feature/teleport/TeleportTask.java
Show resolved
Hide resolved
# Conflicts: # eternalcore-core/src/main/java/com/eternalcode/core/feature/fullserverbypass/FullServerBypassController.java # eternalcore-core/src/main/java/com/eternalcode/core/litecommand/argument/GameModeArgument.java
|
Proof of working. 2025-10-20.20-25-48.mp4 |
