Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.staticfx.godBot.commands;
- import com.jagrosh.jdautilities.commandclient.Command;
- import com.jagrosh.jdautilities.commandclient.CommandEvent;
- import de.staticfx.godBot.DiscordBot;
- import net.dv8tion.jda.core.entities.Role;
- import net.dv8tion.jda.core.entities.TextChannel;
- import xyz.dodo.fortnite.Fortnite;
- import xyz.dodo.fortnite.entity.FortniteData;
- import xyz.dodo.fortnite.entity.League;
- import xyz.dodo.fortnite.entity.Stat;
- import java.util.List;
- import java.util.stream.Collectors;
- public class RankCommandExecuter extends Command {
- Fortnite fortnite = new Fortnite("8fdc1618-608d-4733-b581-d3141c189c57");
- public RankCommandExecuter() {
- this.name = "rank";
- this.aliases = new String[]{"rank1"};
- }
- List<Stat> stats = data.getLeague(League.Mode.life_time).getStats();
- String kdRatio = findStat(stats, "K/d");
- protected void execute(CommandEvent event) {
- Role role1 = DiscordBot.getInstance().getJda().getGuildById("556210184100249623").getRoleById("557260408575229978");
- Role role2 = DiscordBot.getInstance().getJda().getGuildById("556210184100249623").getRoleById("557260459858853891");
- Role role3 = DiscordBot.getInstance().getJda().getGuildById("556210184100249623").getRoleById("557260508462317588");
- // use camelCase
- String username = event.getMember().getNickname();
- String[] args = event.getArgs().split(" ");
- TextChannel textchanal = event.getGuild().getTextChannelsByName("skillgruppe-erhalten",true).get(0);
- if(event.getMember().getRoles().stream().filter(r -> r.getName().equalsIgnoreCase("xbox")).collect(Collectors.toList()).isEmpty()) {
- if(event.getMember().getRoles().stream().filter(r -> r.getName().equalsIgnoreCase("ps4")).collect(Collectors.toList()).isEmpty()) {
- if(event.getMember().getRoles().stream().filter(r -> r.getName().equalsIgnoreCase("pc")).collect(Collectors.toList()).isEmpty()) {
- event.reply(":warning:Whoop, sieht so aus als ob du deine Plattform noch nicht registriert hast " + event.getAuthor().getAsMention() + ".");
- return;
- }
- }
- }
- // pull out event.getMember().getroles().stream() to a variable
- String platform = "ps4";
- if(!(event.getMember().getRoles().stream().filter(r -> r.getName().equalsIgnoreCase("ps4")).collect(Collectors.toList()).isEmpty())) {
- platform = "ps4";
- } else if(!(event.getMember().getRoles().stream().filter(r -> r.getName().equalsIgnoreCase("xbox")).collect(Collectors.toList()).isEmpty())) {
- platform = "xbox";
- } else if(!(event.getMember().getRoles().stream().filter(r -> r.getName().equalsIgnoreCase("pc")).collect(Collectors.toList()).isEmpty())) {
- platform = "pc";
- }
- // now both platform and username are set
- FortniteData data = fortnite.getPlayerInfo(platform, username);
- if(!data.getResult().isOk()){
- System.out.println("do something - fetch failed")
- return;
- }
- List<Stat> stats = data.getLeague(League.Mode.life_time).getStats()
- String kdRatio = this.findStat(stats, "K/d");
- System.out.println("k/d ratio: " + kdRatio);
- }
- public String findStat(List<Stat> stats, String label){
- for(Stat stat : stats){
- if(stat.label.equals(label))
- return stat.value;
- }
- return "0";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement