aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/RoomData.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/RoomData.java')
-rw-r--r--app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/RoomData.java133
1 files changed, 0 insertions, 133 deletions
diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/RoomData.java b/app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/RoomData.java
deleted file mode 100644
index 3799180..0000000
--- a/app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/RoomData.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package com.example.wiimmterfaceandroid.wiimmfi;
-
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.nodes.Element;
-import org.jsoup.select.Elements;
-
-import java.io.IOException;
-import java.util.ArrayList;
-
-public class RoomData {
- String roomHeader;
- String playerLink;
- String friendCode;
- ArrayList<Player> players = new ArrayList<>();
-
- public RoomData (ArrayList<Player> players, String playerLink, String friendCode) {
- this.friendCode = friendCode;
- getPlayerLink();
- Document doc = null;
-
- if (this.playerLink == null) {
- System.out.println("The player link is null for some reason");
- } else {
-
- try {
- doc = Jsoup.connect("https://wiimmfi.de/" + this.playerLink).get();
- } catch (IOException e) {
- e.printStackTrace();
- }
- Element table = doc.select("table").get(0);
- Elements rows = table.select("tr");
-
- for (int i = 0; i < rows.size(); i++) {
- Element row = rows.get(i);
- Elements colPlayers = row.select("td");
- Elements colHeader = row.select("th");
-
- if (colHeader.size() > 0) {
- if (!colHeader.get(0).text().equals("friend code")) {
- roomHeader = colHeader.get(0).text();
- }
- }
- if (colPlayers.size() > 0) {
-
- Player currentPlayer = new Player();
- for (int j = 0; j < colPlayers.size(); j++) {
- System.out.println("Player Data: " + colPlayers.get(j).text());
- switch (j) {
- case 0:
- currentPlayer.friendCode = colPlayers.get(0).text();
- break;
- case 1:
- currentPlayer.role = colPlayers.get(1).text().split(" ")[1];
- currentPlayer.rosterNumber = colPlayers.get(1).text().split(" ")[0].replaceAll("\\s", "");
- break;
- case 2:
- currentPlayer.loginRegion = colPlayers.get(2).text();
- break;
- case 3:
- currentPlayer.roomMatch = colPlayers.get(3).text();
- break;
- case 4:
- currentPlayer.world = colPlayers.get(4).text();
- break;
- case 5:
- currentPlayer.connFail = colPlayers.get(5).text();
- break;
- case 6:
- currentPlayer.vr = colPlayers.get(6).text();
- break;
- case 7:
- currentPlayer.br = colPlayers.get(7).text();
- break;
- case 8:
- currentPlayer.miiName = colPlayers.get(8).text();
- break;
- }
- }
- if (currentPlayer.friendCode.equals(friendCode)) {
- currentPlayer.watching = true;
- }
- players.add(currentPlayer);
- }
-
- }
- }
- }
-
- public void getPlayerLink() {
- try {
- Document doc = null;
-
- doc = Jsoup.connect("https://wiimmfi.de/stats/mkw").get();
- Element table = doc.select("table").get(0);
- Elements rows = table.select("tr");
-
- for (int i = 0; i < rows.size(); i++) {
- Element row = rows.get(i);
- Elements colPlayers = row.select("td");
- Elements colHeader = row.select("th");
-
-
- if (colPlayers.size() > 0) {
-
- String data = colPlayers.get(0).select("a").toString();
-// System.out.println(data);
- if (data.contains(friendCode)) {
- System.out.println("Found friend code");
- playerLink = data.split("\"")[3];
- System.out.println("Player link: " + playerLink);
- break;
- }
- }
- }
-
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public ArrayList<Player> getPlayers() { return players; }
-
- public String getRoomHeader() { return this.roomHeader; }
-
- public RoomData refresh() {
- players.clear();
- roomHeader = "";
- RoomData returningData = new RoomData(players, playerLink, friendCode);
- return returningData;
- }
-}
-