Skip to content

Commit

Permalink
Use method lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
EsotericEnderman committed Aug 10, 2024
1 parent 89a4574 commit 7f90dab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,13 @@ public GiveCustomItemCommand(TemplatePaperPlugin plugin) {

String[] customItemIds = Stream.of(CustomItem.values()).map((customItem) -> customItem.name()).toArray(String[]::new);

Argument<CustomItem> customItemArgument = new CustomArgument<CustomItem, String>(new StringArgument(customItemArgumentNodeName), new CustomArgumentInfoParser<>() {
@Override
public CustomItem apply(CustomArgumentInfo<String> info) throws CustomArgumentException {
String input = info.currentInput();

try {
return CustomItem.valueOf(input);
} catch (IllegalArgumentException exception) {
throw CustomArgumentException.fromAdventureComponent(plugin.getLanguageManager().getMessage(Message.UNKNOWN_CUSTOM_ITEM, info.sender(), input));
}
Argument<CustomItem> customItemArgument = new CustomArgument<CustomItem, String>(new StringArgument(customItemArgumentNodeName), (CustomArgumentInfo<String> info) -> {
String input = info.currentInput();

try {
return CustomItem.valueOf(input);
} catch (IllegalArgumentException exception) {
throw CustomArgumentException.fromAdventureComponent(plugin.getLanguageManager().getMessage(Message.UNKNOWN_CUSTOM_ITEM, info.sender(), input));
}
}).includeSuggestions(ArgumentSuggestions.strings(customItemIds));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,13 @@ public SpawnCustomEntityCommand(TemplatePaperPlugin plugin) {

String[] customEntityIds = Stream.of(CustomEntity.values()).map((customEntity) -> customEntity.name()).toArray(String[]::new);

Argument<CustomEntity> customEntityArgument = new CustomArgument<CustomEntity, String>(new StringArgument(customEntityArgumentNodeName), new CustomArgumentInfoParser<>() {
@Override
public CustomEntity apply(CustomArgumentInfo<String> info) throws CustomArgumentException {
String input = info.currentInput();

try {
return CustomEntity.valueOf(input);
} catch (IllegalArgumentException exception) {
throw CustomArgumentException.fromAdventureComponent(plugin.getLanguageManager().getMessage(Message.UNKNOWN_CUSTOM_ENTITY, info.sender(), input));
}
Argument<CustomEntity> customEntityArgument = new CustomArgument<CustomEntity, String>(new StringArgument(customEntityArgumentNodeName), (CustomArgumentInfo<String> info) -> {
String input = info.currentInput();

try {
return CustomEntity.valueOf(input);
} catch (IllegalArgumentException exception) {
throw CustomArgumentException.fromAdventureComponent(plugin.getLanguageManager().getMessage(Message.UNKNOWN_CUSTOM_ENTITY, info.sender(), input));
}
}).includeSuggestions(ArgumentSuggestions.strings(customEntityIds));

Expand Down

0 comments on commit 7f90dab

Please sign in to comment.