Updates dependencies, and removes some redundant code
This commit is contained in:
		@@ -1,9 +1,9 @@
 | 
			
		||||
package net.knarcraft.stargate.command;
 | 
			
		||||
 | 
			
		||||
import de.themoep.minedown.MineDown;
 | 
			
		||||
import net.knarcraft.knarlib.util.FileHelper;
 | 
			
		||||
import net.knarcraft.stargate.Stargate;
 | 
			
		||||
import net.knarcraft.stargate.config.Message;
 | 
			
		||||
import net.knarcraft.stargate.utility.FileHelper;
 | 
			
		||||
import net.md_5.bungee.api.ChatColor;
 | 
			
		||||
import net.md_5.bungee.api.chat.BaseComponent;
 | 
			
		||||
import org.bukkit.command.Command;
 | 
			
		||||
@@ -13,6 +13,7 @@ import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.io.InputStream;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This command represents the plugin's about command
 | 
			
		||||
@@ -26,9 +27,11 @@ public class CommandAbout implements CommandExecutor {
 | 
			
		||||
        ChatColor textColor = ChatColor.GOLD;
 | 
			
		||||
        ChatColor highlightColor = ChatColor.GREEN;
 | 
			
		||||
 | 
			
		||||
        try (InputStream inputStream = Stargate.class.getResourceAsStream("/messages/about.md")) {
 | 
			
		||||
 | 
			
		||||
        try (InputStream inputStream = FileHelper.getInputStreamForInternalFile("/messages/about.md")) {
 | 
			
		||||
            if (inputStream != null) {
 | 
			
		||||
                String aboutMessageString = FileHelper.readStreamToString(inputStream);
 | 
			
		||||
                List<String> lines = FileHelper.readLines(FileHelper.getBufferedReaderFromInputStream(inputStream));
 | 
			
		||||
                String aboutMessageString = String.join("\n", lines);
 | 
			
		||||
                BaseComponent[] component = MineDown.parse(aboutMessageString);
 | 
			
		||||
                commandSender.spigot().sendMessage(component);
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,36 +0,0 @@
 | 
			
		||||
package net.knarcraft.stargate.utility;
 | 
			
		||||
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
import java.io.BufferedReader;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.io.InputStream;
 | 
			
		||||
import java.io.InputStreamReader;
 | 
			
		||||
import java.nio.charset.StandardCharsets;
 | 
			
		||||
 | 
			
		||||
public final class FileHelper {
 | 
			
		||||
 | 
			
		||||
    private FileHelper() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Converts the stream directly into a string, includes the newline character
 | 
			
		||||
     *
 | 
			
		||||
     * @param stream <p> The stream to read from </p>
 | 
			
		||||
     * @return <p> A String of the file read </p>
 | 
			
		||||
     * @throws IOException <p>If unable to read the stream</p>
 | 
			
		||||
     */
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static String readStreamToString(@NotNull InputStream stream) throws IOException {
 | 
			
		||||
        InputStreamReader inputStreamReader = new InputStreamReader(stream, StandardCharsets.UTF_8);
 | 
			
		||||
        BufferedReader reader = new BufferedReader(inputStreamReader);
 | 
			
		||||
        String line = reader.readLine();
 | 
			
		||||
        StringBuilder lines = new StringBuilder();
 | 
			
		||||
        while (line != null) {
 | 
			
		||||
            lines.append(line).append("\n");
 | 
			
		||||
            line = reader.readLine();
 | 
			
		||||
        }
 | 
			
		||||
        return lines.toString();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user