Modify the about command
This commit is contained in:
		@@ -460,7 +460,7 @@ public class Stargate extends JavaPlugin {
 | 
			
		||||
    private void registerCommands() {
 | 
			
		||||
        PluginCommand stargateCommand = this.getCommand("stargate");
 | 
			
		||||
        if (stargateCommand != null) {
 | 
			
		||||
            stargateCommand.setExecutor(new CommandStarGate());
 | 
			
		||||
            stargateCommand.setExecutor(new CommandStarGate(this));
 | 
			
		||||
            stargateCommand.setTabCompleter(new StarGateTabCompleter());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,18 @@
 | 
			
		||||
package net.knarcraft.stargate.command;
 | 
			
		||||
 | 
			
		||||
import de.themoep.minedown.MineDown;
 | 
			
		||||
import net.knarcraft.stargate.Stargate;
 | 
			
		||||
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;
 | 
			
		||||
import org.bukkit.command.CommandExecutor;
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.io.InputStream;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This command represents the plugin's about command
 | 
			
		||||
 */
 | 
			
		||||
@@ -18,10 +24,14 @@ public class CommandAbout implements CommandExecutor {
 | 
			
		||||
 | 
			
		||||
        ChatColor textColor = ChatColor.GOLD;
 | 
			
		||||
        ChatColor highlightColor = ChatColor.GREEN;
 | 
			
		||||
        commandSender.sendMessage(textColor + "Stargate Plugin originally created by " + highlightColor +
 | 
			
		||||
                "Drakia" + textColor + ", and revived by " + highlightColor + "EpicKnarvik97");
 | 
			
		||||
        commandSender.sendMessage(textColor + "Go to " + highlightColor +
 | 
			
		||||
                "https://git.knarcraft.net/EpicKnarvik97/Stargate " + textColor + "for the official repository");
 | 
			
		||||
 | 
			
		||||
        try(InputStream inputStream = Stargate.class.getResourceAsStream("/messages/about.md")){
 | 
			
		||||
            String aboutMessageString = FileHelper.readStreamToString(inputStream);
 | 
			
		||||
            BaseComponent[] component = MineDown.parse(aboutMessageString);
 | 
			
		||||
            commandSender.spigot().sendMessage(component);
 | 
			
		||||
        } catch (IOException ioException){
 | 
			
		||||
            commandSender.sendMessage("Internal error");
 | 
			
		||||
        }
 | 
			
		||||
        String author = Stargate.getStargateConfig().getLanguageLoader().getString("author");
 | 
			
		||||
        if (!author.isEmpty()) {
 | 
			
		||||
            commandSender.sendMessage(textColor + "Language created by " + highlightColor + author);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										30
									
								
								src/main/java/net/knarcraft/stargate/utility/FileHelper.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/main/java/net/knarcraft/stargate/utility/FileHelper.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
			
		||||
package net.knarcraft.stargate.utility;
 | 
			
		||||
 | 
			
		||||
import java.io.BufferedReader;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.io.InputStream;
 | 
			
		||||
import java.io.InputStreamReader;
 | 
			
		||||
import java.nio.charset.Charset;
 | 
			
		||||
import java.nio.charset.StandardCharsets;
 | 
			
		||||
 | 
			
		||||
public class 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>
 | 
			
		||||
     */
 | 
			
		||||
    public static String readStreamToString(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();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										6
									
								
								src/main/resources/messages/about.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								src/main/resources/messages/about.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
			
		||||
Stargate Unified Legacy v. @version@ (maintained by [sgrewritten.org](https://sgrewritten.org)).
 | 
			
		||||
A Hmod transportation concept by [Dinnerbone](https://github.com/Dinnerbone) and [Sturmeh](https://github.com/Sturmeh). Ported to bukkit by Drakia(https://github.com/DrakiaXYZ).
 | 
			
		||||
Revived by [EpicKnarvik97](https://sgrewritten.org/knarvik), now incorporating features from all other Stargate forks.
 | 
			
		||||
 | 
			
		||||
For more information, visit [sgrewritten.org/legacy](https://sgrewritten.org/legacy)
 | 
			
		||||
For current versions, visit [sgrewritten.org/download](https://sgrewritten.org/download)
 | 
			
		||||
		Reference in New Issue
	
	Block a user