SHARE
TWEET

Untitled

a guest Mar 19th, 2019 610 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package de.staticfx.godBot.commands;
  2.  
  3. import com.jagrosh.jdautilities.commandclient.Command;
  4. import com.jagrosh.jdautilities.commandclient.CommandEvent;
  5. import de.staticfx.godBot.DiscordBot;
  6. import net.dv8tion.jda.core.entities.Role;
  7. import net.dv8tion.jda.core.entities.TextChannel;
  8. import xyz.dodo.fortnite.Fortnite;
  9. import xyz.dodo.fortnite.entity.FortniteData;
  10. import xyz.dodo.fortnite.entity.League;
  11. import xyz.dodo.fortnite.entity.Stat;
  12.  
  13. import java.util.List;
  14. import java.util.stream.Collectors;
  15.  
  16. public class RankCommandExecuter extends Command {
  17.     Fortnite fortnite = new Fortnite("8fdc1618-608d-4733-b581-d3141c189c57");
  18.    
  19.     public RankCommandExecuter() {
  20.         this.name = "rank";
  21.         this.aliases = new String[]{"rank1"};
  22.     }
  23.  
  24.     List<Stat> stats = data.getLeague(League.Mode.life_time).getStats();
  25.     String kdRatio = findStat(stats, "K/d");
  26.  
  27.     protected void execute(CommandEvent event) {
  28.         Role role1 = DiscordBot.getInstance().getJda().getGuildById("556210184100249623").getRoleById("557260408575229978");
  29.         Role role2 = DiscordBot.getInstance().getJda().getGuildById("556210184100249623").getRoleById("557260459858853891");
  30.         Role role3 = DiscordBot.getInstance().getJda().getGuildById("556210184100249623").getRoleById("557260508462317588");
  31.         // use camelCase
  32.         String username = event.getMember().getNickname();
  33.         String[] args = event.getArgs().split(" ");
  34.         TextChannel textchanal = event.getGuild().getTextChannelsByName("skillgruppe-erhalten",true).get(0);
  35.         if(event.getMember().getRoles().stream().filter(r -> r.getName().equalsIgnoreCase("xbox")).collect(Collectors.toList()).isEmpty()) {
  36.             if(event.getMember().getRoles().stream().filter(r -> r.getName().equalsIgnoreCase("ps4")).collect(Collectors.toList()).isEmpty()) {
  37.                 if(event.getMember().getRoles().stream().filter(r -> r.getName().equalsIgnoreCase("pc")).collect(Collectors.toList()).isEmpty()) {
  38.                     event.reply(":warning:Whoop, sieht so aus als ob du deine Plattform noch nicht registriert hast " + event.getAuthor().getAsMention() + ".");
  39.                     return;
  40.                 }
  41.             }
  42.         }
  43.  
  44.         // pull out event.getMember().getroles().stream() to a variable
  45.         String platform = "ps4";
  46.         if(!(event.getMember().getRoles().stream().filter(r -> r.getName().equalsIgnoreCase("ps4")).collect(Collectors.toList()).isEmpty())) {
  47.             platform = "ps4";
  48.         } else if(!(event.getMember().getRoles().stream().filter(r -> r.getName().equalsIgnoreCase("xbox")).collect(Collectors.toList()).isEmpty())) {
  49.             platform = "xbox";
  50.         } else if(!(event.getMember().getRoles().stream().filter(r -> r.getName().equalsIgnoreCase("pc")).collect(Collectors.toList()).isEmpty())) {
  51.             platform = "pc";
  52.         }
  53.  
  54.         // now both platform and username are set
  55.         FortniteData data = fortnite.getPlayerInfo(platform, username);
  56.         if(!data.getResult().isOk()){
  57.             System.out.println("do something - fetch failed")
  58.             return;
  59.         }
  60.  
  61.  
  62.         List<Stat> stats = data.getLeague(League.Mode.life_time).getStats()
  63.         String kdRatio = this.findStat(stats, "K/d");
  64.         System.out.println("k/d ratio: " + kdRatio);
  65.     }
  66.     public String findStat(List<Stat> stats, String label){
  67.         for(Stat stat : stats){
  68.             if(stat.label.equals(label))
  69.                 return stat.value;
  70.         }
  71.  
  72.         return "0";
  73.     }
  74.  
  75. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top