Modify the about command
This commit is contained in:
		
							
								
								
									
										26
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								pom.xml
									
									
									
									
									
								
							@@ -4,7 +4,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    <groupId>net.knarcraft</groupId>
 | 
					    <groupId>net.knarcraft</groupId>
 | 
				
			||||||
    <artifactId>Stargate</artifactId>
 | 
					    <artifactId>Stargate</artifactId>
 | 
				
			||||||
    <version>0.11.5.5</version>
 | 
					    <version>0.11.5.6</version>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <licenses>
 | 
					    <licenses>
 | 
				
			||||||
        <license>
 | 
					        <license>
 | 
				
			||||||
@@ -39,6 +39,10 @@
 | 
				
			|||||||
            <id>papermc</id>
 | 
					            <id>papermc</id>
 | 
				
			||||||
            <url>https://repo.papermc.io/repository/maven-public/</url>
 | 
					            <url>https://repo.papermc.io/repository/maven-public/</url>
 | 
				
			||||||
        </repository>
 | 
					        </repository>
 | 
				
			||||||
 | 
					        <repository>
 | 
				
			||||||
 | 
					            <id>minebench-repo</id>
 | 
				
			||||||
 | 
					            <url>https://repo.minebench.de/</url>
 | 
				
			||||||
 | 
					        </repository>
 | 
				
			||||||
    </repositories>
 | 
					    </repositories>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <dependencies>
 | 
					    <dependencies>
 | 
				
			||||||
@@ -96,6 +100,18 @@
 | 
				
			|||||||
            <version>3.0.1</version>
 | 
					            <version>3.0.1</version>
 | 
				
			||||||
            <scope>compile</scope>
 | 
					            <scope>compile</scope>
 | 
				
			||||||
        </dependency>
 | 
					        </dependency>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>net.kyori</groupId>
 | 
				
			||||||
 | 
					            <artifactId>adventure-platform-bukkit</artifactId>
 | 
				
			||||||
 | 
					            <version>4.3.2</version>
 | 
				
			||||||
 | 
					            <scope>compile</scope>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
 | 
					        <dependency>
 | 
				
			||||||
 | 
					            <groupId>de.themoep</groupId>
 | 
				
			||||||
 | 
					            <artifactId>minedown</artifactId>
 | 
				
			||||||
 | 
					            <version>1.7.1-SNAPSHOT</version>
 | 
				
			||||||
 | 
					            <scope>compile</scope>
 | 
				
			||||||
 | 
					        </dependency>
 | 
				
			||||||
    </dependencies>
 | 
					    </dependencies>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <build>
 | 
					    <build>
 | 
				
			||||||
@@ -120,6 +136,7 @@
 | 
				
			|||||||
                        <includes>
 | 
					                        <includes>
 | 
				
			||||||
                            <include>org.bstats:*</include>
 | 
					                            <include>org.bstats:*</include>
 | 
				
			||||||
                            <include>net.knarcraft:knarlib</include>
 | 
					                            <include>net.knarcraft:knarlib</include>
 | 
				
			||||||
 | 
					                            <include>de.themoep:minedown</include>
 | 
				
			||||||
                        </includes>
 | 
					                        </includes>
 | 
				
			||||||
                    </artifactSet>
 | 
					                    </artifactSet>
 | 
				
			||||||
                </configuration>
 | 
					                </configuration>
 | 
				
			||||||
@@ -139,6 +156,13 @@
 | 
				
			|||||||
                                    <pattern>net.knarcraft</pattern>
 | 
					                                    <pattern>net.knarcraft</pattern>
 | 
				
			||||||
                                    <shadedPattern>net.knarcraft</shadedPattern>
 | 
					                                    <shadedPattern>net.knarcraft</shadedPattern>
 | 
				
			||||||
                                </relocation>
 | 
					                                </relocation>
 | 
				
			||||||
 | 
					                                <relocation>
 | 
				
			||||||
 | 
					                                    <pattern>net.kyori</pattern>
 | 
				
			||||||
 | 
					                                </relocation>
 | 
				
			||||||
 | 
					                                <relocation>
 | 
				
			||||||
 | 
					                                    <pattern>de.themoep.minedown</pattern>
 | 
				
			||||||
 | 
					                                    <shadedPattern>net.knarcraft.stargate.minedown</shadedPattern>
 | 
				
			||||||
 | 
					                                </relocation>
 | 
				
			||||||
                            </relocations>
 | 
					                            </relocations>
 | 
				
			||||||
                            <filters>
 | 
					                            <filters>
 | 
				
			||||||
                                <filter>
 | 
					                                <filter>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -460,7 +460,7 @@ public class Stargate extends JavaPlugin {
 | 
				
			|||||||
    private void registerCommands() {
 | 
					    private void registerCommands() {
 | 
				
			||||||
        PluginCommand stargateCommand = this.getCommand("stargate");
 | 
					        PluginCommand stargateCommand = this.getCommand("stargate");
 | 
				
			||||||
        if (stargateCommand != null) {
 | 
					        if (stargateCommand != null) {
 | 
				
			||||||
            stargateCommand.setExecutor(new CommandStarGate());
 | 
					            stargateCommand.setExecutor(new CommandStarGate(this));
 | 
				
			||||||
            stargateCommand.setTabCompleter(new StarGateTabCompleter());
 | 
					            stargateCommand.setTabCompleter(new StarGateTabCompleter());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,12 +1,18 @@
 | 
				
			|||||||
package net.knarcraft.stargate.command;
 | 
					package net.knarcraft.stargate.command;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import de.themoep.minedown.MineDown;
 | 
				
			||||||
import net.knarcraft.stargate.Stargate;
 | 
					import net.knarcraft.stargate.Stargate;
 | 
				
			||||||
 | 
					import net.knarcraft.stargate.utility.FileHelper;
 | 
				
			||||||
import net.md_5.bungee.api.ChatColor;
 | 
					import net.md_5.bungee.api.ChatColor;
 | 
				
			||||||
 | 
					import net.md_5.bungee.api.chat.BaseComponent;
 | 
				
			||||||
import org.bukkit.command.Command;
 | 
					import org.bukkit.command.Command;
 | 
				
			||||||
import org.bukkit.command.CommandExecutor;
 | 
					import org.bukkit.command.CommandExecutor;
 | 
				
			||||||
import org.bukkit.command.CommandSender;
 | 
					import org.bukkit.command.CommandSender;
 | 
				
			||||||
import org.jetbrains.annotations.NotNull;
 | 
					import org.jetbrains.annotations.NotNull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.IOException;
 | 
				
			||||||
 | 
					import java.io.InputStream;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * This command represents the plugin's about command
 | 
					 * This command represents the plugin's about command
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@@ -18,10 +24,14 @@ public class CommandAbout implements CommandExecutor {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        ChatColor textColor = ChatColor.GOLD;
 | 
					        ChatColor textColor = ChatColor.GOLD;
 | 
				
			||||||
        ChatColor highlightColor = ChatColor.GREEN;
 | 
					        ChatColor highlightColor = ChatColor.GREEN;
 | 
				
			||||||
        commandSender.sendMessage(textColor + "Stargate Plugin originally created by " + highlightColor +
 | 
					
 | 
				
			||||||
                "Drakia" + textColor + ", and revived by " + highlightColor + "EpicKnarvik97");
 | 
					        try(InputStream inputStream = Stargate.class.getResourceAsStream("/messages/about.md")){
 | 
				
			||||||
        commandSender.sendMessage(textColor + "Go to " + highlightColor +
 | 
					            String aboutMessageString = FileHelper.readStreamToString(inputStream);
 | 
				
			||||||
                "https://git.knarcraft.net/EpicKnarvik97/Stargate " + textColor + "for the official repository");
 | 
					            BaseComponent[] component = MineDown.parse(aboutMessageString);
 | 
				
			||||||
 | 
					            commandSender.spigot().sendMessage(component);
 | 
				
			||||||
 | 
					        } catch (IOException ioException){
 | 
				
			||||||
 | 
					            commandSender.sendMessage("Internal error");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        String author = Stargate.getStargateConfig().getLanguageLoader().getString("author");
 | 
					        String author = Stargate.getStargateConfig().getLanguageLoader().getString("author");
 | 
				
			||||||
        if (!author.isEmpty()) {
 | 
					        if (!author.isEmpty()) {
 | 
				
			||||||
            commandSender.sendMessage(textColor + "Language created by " + highlightColor + author);
 | 
					            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