Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
fix: #853 helpコマンドが正常に動作しない不具合を修正 (#855)
Browse files Browse the repository at this point in the history
  • Loading branch information
book000 authored Jun 8, 2022
1 parent 0183f8d commit 9abf303
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/com/jaoafa/mymaid4/command/Cmd_Help.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,12 @@ void giveHelpBook(CommandContext<CommandSender> context) {
YamlConfiguration yaml = YamlConfiguration.loadConfiguration(file);
String strTitle = yaml.getString("title");
Component title = strTitle != null ? GsonComponentSerializer.gson().deserialize(strTitle) : Component.text().build();
String strAuthor = yaml.getString("author");
Component author = strAuthor != null ? GsonComponentSerializer.gson().deserialize(strAuthor) : Component.text().build();
List<Component> pages = yaml.getStringList("pages").stream()
.map(page -> GsonComponentSerializer.gson().deserialize(page))
.collect(Collectors.toList());
Book book = meta.title(title).pages(pages);
Book book = meta.title(title).author(author).pages(pages);

player.openBook(book);
}
Expand All @@ -120,13 +122,16 @@ void registerHelpBook(CommandContext<CommandSender> context) {
}
BookMeta meta = (BookMeta) item.getItemMeta();
Component componentTitle = meta.title();
Component componentAuthor = meta.author();
String title = componentTitle != null ? GsonComponentSerializer.gson().serialize(componentTitle) : null;
String author = componentAuthor != null ? GsonComponentSerializer.gson().serialize(componentAuthor) : null;
List<String> pages = meta.pages().stream()
.map(page -> GsonComponentSerializer.gson().serialize(page))
.collect(Collectors.toList());

YamlConfiguration yaml = new YamlConfiguration();
yaml.set("title", title);
yaml.set("author", author);
yaml.set("pages", pages);
try {
yaml.save(file);
Expand Down

0 comments on commit 9abf303

Please sign in to comment.