Version 1.4.0 merge from development. #6
			
				
			
		
		
		
	
							
								
								
									
										15
									
								
								pom.xml
								
								
								
								
							
							
						
						
									
										15
									
								
								pom.xml
								
								
								
								
							| 
						 | 
				
			
			@ -46,27 +46,32 @@
 | 
			
		|||
    <packaging>jar</packaging>
 | 
			
		||||
 | 
			
		||||
    <repositories>
 | 
			
		||||
        <repository>
 | 
			
		||||
            <id>jcenter</id>
 | 
			
		||||
            <url>http://jcenter.bintray.com</url>
 | 
			
		||||
        </repository>
 | 
			
		||||
        <repository>
 | 
			
		||||
            <id>jitpack.io</id>
 | 
			
		||||
            <url>https://jitpack.io</url>
 | 
			
		||||
        </repository>
 | 
			
		||||
        <repository>
 | 
			
		||||
            <id>jcenter</id>
 | 
			
		||||
            <url>http://jcenter.bintray.com</url>
 | 
			
		||||
        </repository>
 | 
			
		||||
    </repositories>
 | 
			
		||||
 | 
			
		||||
    <dependencies>
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>com.github.austinv11</groupId>
 | 
			
		||||
            <artifactId>Discord4J</artifactId>
 | 
			
		||||
            <version>2.8.3</version>
 | 
			
		||||
            <version>2.8.4</version>
 | 
			
		||||
        </dependency>
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>com.sedmelluq</groupId>
 | 
			
		||||
            <artifactId>lavaplayer</artifactId>
 | 
			
		||||
            <version>1.2.39</version>
 | 
			
		||||
        </dependency>
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>com.github.andrewlalis</groupId>
 | 
			
		||||
            <artifactId>TengwarTranslatorLibrary</artifactId>
 | 
			
		||||
            <version>1.1</version>
 | 
			
		||||
        </dependency>
 | 
			
		||||
    </dependencies>
 | 
			
		||||
 | 
			
		||||
</project>
 | 
			
		||||
| 
						 | 
				
			
			@ -2,6 +2,7 @@ package handiebot.command;
 | 
			
		|||
 | 
			
		||||
import handiebot.command.commands.admin.QuitCommand;
 | 
			
		||||
import handiebot.command.commands.admin.SetPrefixCommand;
 | 
			
		||||
import handiebot.command.commands.misc.TengwarCommand;
 | 
			
		||||
import handiebot.command.commands.music.*;
 | 
			
		||||
import handiebot.command.commands.support.HelpCommand;
 | 
			
		||||
import handiebot.command.commands.support.InfoCommand;
 | 
			
		||||
| 
						 | 
				
			
			@ -39,6 +40,7 @@ public class Commands {
 | 
			
		|||
        commands.add(new InfoCommand());
 | 
			
		||||
        commands.add(new SetPrefixCommand());
 | 
			
		||||
        commands.add(new QuitCommand());
 | 
			
		||||
        commands.add(new TengwarCommand());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,57 @@
 | 
			
		|||
package handiebot.command.commands.misc;
 | 
			
		||||
 | 
			
		||||
import handiebot.command.CommandContext;
 | 
			
		||||
import handiebot.command.types.ContextCommand;
 | 
			
		||||
import net.agspace.TengwarImageGenerator;
 | 
			
		||||
import net.agspace.Translator;
 | 
			
		||||
 | 
			
		||||
import java.io.FileNotFoundException;
 | 
			
		||||
 | 
			
		||||
import static handiebot.HandieBot.resourceBundle;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Andrew Lalis
 | 
			
		||||
 */
 | 
			
		||||
public class TengwarCommand extends ContextCommand {
 | 
			
		||||
 | 
			
		||||
    public TengwarCommand() {
 | 
			
		||||
        super("tengwar",
 | 
			
		||||
                "<translateTo|translateFrom> <TEXT>",
 | 
			
		||||
                resourceBundle.getString("commands.command.tengwar.description"),
 | 
			
		||||
                0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute(CommandContext context) {
 | 
			
		||||
        if (context.getArgs().length == 0){
 | 
			
		||||
            context.getChannel().sendMessage(this.getUsage(context.getGuild()));
 | 
			
		||||
        } else if (context.getArgs().length >= 2){
 | 
			
		||||
            String input = readTextFromArgs(context.getArgs());
 | 
			
		||||
            if (context.getArgs()[0].equalsIgnoreCase("translateTo")){
 | 
			
		||||
                String result = Translator.translateToTengwar(input);
 | 
			
		||||
                try {
 | 
			
		||||
                    context.getChannel().sendFile(TengwarImageGenerator.generateImage(result,
 | 
			
		||||
                            500,
 | 
			
		||||
                            24f,
 | 
			
		||||
                            false,
 | 
			
		||||
                            false,
 | 
			
		||||
                            System.getProperty("user.home")+"/.handiebot/tengwarTemp.png"));
 | 
			
		||||
                } catch (FileNotFoundException e) {
 | 
			
		||||
                    e.printStackTrace();
 | 
			
		||||
                }
 | 
			
		||||
            } else if (context.getArgs()[0].equalsIgnoreCase("translateFrom")){
 | 
			
		||||
                context.getChannel().sendMessage(Translator.translateToEnglish(input));
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            context.getChannel().sendMessage(this.getUsage(context.getGuild()));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private String readTextFromArgs(String[] args){
 | 
			
		||||
        StringBuilder sb = new StringBuilder();
 | 
			
		||||
        for (int i = 1; i < args.length; i++){
 | 
			
		||||
            sb.append(args[i]).append(' ');
 | 
			
		||||
        }
 | 
			
		||||
        return sb.toString().trim();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,5 @@
 | 
			
		|||
/**
 | 
			
		||||
 * @author Andrew Lalis
 | 
			
		||||
 * Contains miscellaneous commands that do not belong in a group.
 | 
			
		||||
 */
 | 
			
		||||
package handiebot.command.commands.misc;
 | 
			
		||||
| 
						 | 
				
			
			@ -90,6 +90,8 @@ commands.command.shuffle.description=Sets shuffling.
 | 
			
		|||
commands.command.skip.description=Skips the current song.
 | 
			
		||||
#Stop
 | 
			
		||||
commands.command.stop.description=Stops playing music.
 | 
			
		||||
#Tengwar translator
 | 
			
		||||
commands.command.tengwar.description=Translates text to tengwar, or decodes tengwar text back into human readable form.
 | 
			
		||||
#Music Player
 | 
			
		||||
player.setRepeat=Set repeat to {0}
 | 
			
		||||
player.setShuffle=Set shuffle to {0}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -99,4 +99,5 @@ trackSchedule.trackStarted=Started audio track: {0}
 | 
			
		|||
trackSchedule.nowPlaying=Now playing: **{0}** {1}\
 | 
			
		||||
{2}
 | 
			
		||||
player.playQueueEmpty=There's nothing in the queue to play.
 | 
			
		||||
commands.command.tengwar.description=Translates text to tengwar, or decodes tengwar text back into human readable form.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue