:neofox_scream:
This commit is contained in:
parent
5fa692f476
commit
2ef56a1485
2 changed files with 31 additions and 5 deletions
|
|
@ -11,6 +11,7 @@ import de.iani.cubesideutils.bukkit.commands.exceptions.NoPermissionException;
|
|||
import de.iani.cubesideutils.bukkit.commands.exceptions.RequiresPlayerException;
|
||||
import de.iani.cubesideutils.commands.ArgsParser;
|
||||
import de.lunarakai.blockfox.BlockFoxPlugin;
|
||||
import de.lunarakai.blockfox.utils.HTMLUtils;
|
||||
import de.lunarakai.lunarutils.StringUtils;
|
||||
import de.lunarakai.lunarutils.chat.MessageUtils;
|
||||
import java.io.IOException;
|
||||
|
|
@ -69,11 +70,9 @@ public class TestRSSCommand extends SubCommand {
|
|||
Optional<String> optionaltest = items.getFirst().getComments();
|
||||
if(optionaltest.isPresent()) {
|
||||
Document parsedTest = Jsoup.parse(optionaltest.get());
|
||||
Elements elements = parsedTest.getElementsByTag("li");
|
||||
// todo: format html elements to readable string (for example new line at ul li)
|
||||
// todo: with current method ul li inside another ul li are duplicated
|
||||
for (Element element : elements) {
|
||||
MessageUtils.sendSimpleInfoMessage(player, "- " + element.text());
|
||||
List<String> list = HTMLUtils.formatHTMLList(parsedTest);
|
||||
for(String string: list) {
|
||||
MessageUtils.sendSimpleSuccessMessage(player, string);
|
||||
}
|
||||
} else {
|
||||
Optional<String> optionalDescription = items.getFirst().getDescription();
|
||||
|
|
|
|||
27
src/main/java/de/lunarakai/blockfox/utils/HTMLUtils.java
Normal file
27
src/main/java/de/lunarakai/blockfox/utils/HTMLUtils.java
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package de.lunarakai.blockfox.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
public class HTMLUtils {
|
||||
public static List<String> formatHTMLList(Document document) {
|
||||
// todo: format html elements to readable string (for example new line at ul li)
|
||||
// todo: with current method ul li inside another ul li are duplicated
|
||||
List<String> list = new ArrayList<>();
|
||||
Elements elements = document.select("ul");
|
||||
|
||||
for (Element element : elements) {
|
||||
|
||||
list.add("- " + element.html() + "\n");
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue