aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlkalus <Draknyte1@hotmail.com>2020-04-10 14:03:46 +0100
committerAlkalus <Draknyte1@hotmail.com>2020-04-10 14:03:46 +0100
commitd214b66b0c677120c634038dfbd531f09e93e124 (patch)
tree9ed8a086abfbc1d69e658a364bedc107941a011c /src
parentddeb9c0c0fc4da536a291aee51019c0d2dd824f8 (diff)
downloadGT5-Unofficial-d214b66b0c677120c634038dfbd531f09e93e124.tar.gz
GT5-Unofficial-d214b66b0c677120c634038dfbd531f09e93e124.tar.bz2
GT5-Unofficial-d214b66b0c677120c634038dfbd531f09e93e124.zip
$ Minor fixes to NetworkUtils.
$ Completely rewrote Cape Handling.
Diffstat (limited to 'src')
-rw-r--r--src/Java/gtPlusPlus/core/util/data/AES.java19
-rw-r--r--src/Java/gtPlusPlus/core/util/sys/NetworkUtils.java94
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java479
3 files changed, 389 insertions, 203 deletions
diff --git a/src/Java/gtPlusPlus/core/util/data/AES.java b/src/Java/gtPlusPlus/core/util/data/AES.java
new file mode 100644
index 0000000000..9b0126f17d
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/util/data/AES.java
@@ -0,0 +1,19 @@
+package gtPlusPlus.core.util.data;
+
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import java.util.Base64;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.SecretKeySpec;
+
+public class AES {
+
+ \u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u0020\u003d\u0020\u0022\u0044\u0061\u0072\u006b\u006e\u0065\u0073\u0073\u0020\u0049\u006e\u0020\u0054\u0068\u0065\u0069\u0072\u0020\u0048\u0065\u0061\u0072\u0074\u0073\u0022\u003b\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0053\u0070\u0065\u0063\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u003b\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u006b\u0065\u0079\u003b
+ \u0009\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0041\u0045\u0053\u0028\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u006b\u0065\u0079\u0020\u003d\u0020\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0067\u0065\u0074\u0048\u0061\u0073\u0068\u0065\u0064\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0073\u0065\u0063\u0072\u0065\u0074\u0029\u0029\u003b\u000d\u000a\u0009\u0009\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0020\u003d\u0020\u0067\u0065\u006e\u0065\u0072\u0061\u0074\u0065\u004b\u0065\u0079\u0028\u006b\u0065\u0079\u0029\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0067\u0065\u0074\u0048\u0061\u0073\u0068\u0065\u0064\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0061\u0053\u0074\u0072\u0069\u006e\u0067\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0074\u006f\u0048\u0065\u0078\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0067\u0065\u0074\u0053\u0048\u0041\u0028\u0061\u0053\u0074\u0072\u0069\u006e\u0067\u0029\u0029\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0067\u0065\u0074\u0053\u0048\u0041\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0069\u006e\u0070\u0075\u0074\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u0020\u006d\u0064\u003b\u000d\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u006d\u0064\u0020\u003d\u0020\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u0053\u0048\u0041\u002d\u0032\u0035\u0036\u0022\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006d\u0064\u002e\u0064\u0069\u0067\u0065\u0073\u0074\u0028\u0069\u006e\u0070\u0075\u0074\u002e\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0053\u0074\u0061\u006e\u0064\u0061\u0072\u0064\u0043\u0068\u0061\u0072\u0073\u0065\u0074\u0073\u002e\u0055\u0054\u0046\u005f\u0038\u0029\u0029\u003b\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u004e\u006f\u0053\u0075\u0063\u0068\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0065\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006e\u0065\u0077\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u007b\u007d\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0074\u006f\u0048\u0065\u0078\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0068\u0061\u0073\u0068\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0042\u0069\u0067\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0042\u0069\u0067\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u0028\u0031\u002c\u0020\u0068\u0061\u0073\u0068\u0029\u003b\u000d\u000a\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0042\u0075\u0069\u006c\u0064\u0065\u0072\u0020\u0068\u0065\u0078\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0042\u0075\u0069\u006c\u0064\u0065\u0072\u0028\u006e\u0075\u006d\u0062\u0065\u0072\u002e\u0074\u006f\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0031\u0036\u0029\u0029\u003b\u000d\u000a\u0009\u0009\u0077\u0068\u0069\u006c\u0065\u0020\u0028\u0068\u0065\u0078\u0053\u0074\u0072\u0069\u006e\u0067\u002e\u006c\u0065\u006e\u0067\u0074\u0068\u0028\u0029\u0020\u003c\u0020\u0033\u0032\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0068\u0065\u0078\u0053\u0074\u0072\u0069\u006e\u0067\u002e\u0069\u006e\u0073\u0065\u0072\u0074\u0028\u0030\u002c\u0020\u0027\u0030\u0027\u0029\u003b\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0068\u0065\u0078\u0053\u0074\u0072\u0069\u006e\u0067\u002e\u0074\u006f\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0029\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0061\u004b\u0065\u0079\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0061\u004b\u0065\u0079\u0044\u0061\u0074\u0061\u003b\u000d\u000a\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u0020\u0073\u0068\u0061\u003b\u000d\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0073\u0068\u0061\u0020\u003d\u0020\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u0053\u0048\u0041\u002d\u0032\u0035\u0036\u0022\u0029\u003b\u000d\u000a\u0009\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0073\u0068\u0061\u002e\u0064\u0069\u0067\u0065\u0073\u0074\u0028\u0061\u004b\u0065\u0079\u002e\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0053\u0074\u0061\u006e\u0064\u0061\u0072\u0064\u0043\u0068\u0061\u0072\u0073\u0065\u0074\u0073\u002e\u0055\u0054\u0046\u005f\u0038\u0029\u0029\u003b\u0020\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u004e\u006f\u0053\u0075\u0063\u0068\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0031\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0065\u0031\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0009\u0061\u004b\u0065\u0079\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u0061\u004b\u0065\u0079\u002e\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0022\u0055\u0054\u0046\u002d\u0038\u0022\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0009\u0073\u0068\u0061\u0020\u003d\u0020\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u0053\u0048\u0041\u002d\u0031\u0022\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0009\u0061\u004b\u0065\u0079\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u0073\u0068\u0061\u002e\u0064\u0069\u0067\u0065\u0073\u0074\u0028\u006b\u0065\u0079\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0009\u0061\u004b\u0065\u0079\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u0041\u0072\u0072\u0061\u0079\u0073\u002e\u0063\u006f\u0070\u0079\u004f\u0066\u0028\u006b\u0065\u0079\u002c\u0020\u0031\u0036\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0061\u004b\u0065\u0079\u0044\u0061\u0074\u0061\u003b\u000d\u000a\u0009\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0009\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u004e\u006f\u0053\u0075\u0063\u0068\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0009\u0065\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0009\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0055\u006e\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0009\u0065\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u007d\u0009\u0009\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006e\u0065\u0077\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u007b\u007d\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u000d\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0053\u0070\u0065\u0063\u0020\u0067\u0065\u006e\u0065\u0072\u0061\u0074\u0065\u004b\u0065\u0079\u0028\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0061\u004b\u0065\u0079\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006e\u0065\u0077\u0020\u0053\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0053\u0070\u0065\u0063\u0028\u0061\u004b\u0065\u0079\u002c\u0020\u0022\u0041\u0045\u0053\u0022\u0029\u003b\u000d\u000a\u0009\u007d\u000d\u000a\u000d\u000a\u0009\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0074\u0072\u0054\u006f\u0044\u0065\u0063\u0072\u0079\u0070\u0074\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000d\u000a\u0009\u0009\u0009\u0043\u0069\u0070\u0068\u0065\u0072\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u0020\u003d\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u0041\u0045\u0053\u002f\u0045\u0043\u0042\u002f\u0050\u004b\u0043\u0053\u0035\u0050\u0041\u0044\u0044\u0049\u004e\u0047\u0022\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0063\u0069\u0070\u0068\u0065\u0072\u002e\u0069\u006e\u0069\u0074\u0028\u0043\u0069\u0070\u0068\u0065\u0072\u002e\u0044\u0045\u0043\u0052\u0059\u0050\u0054\u005f\u004d\u004f\u0044\u0045\u002c\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u003b\u000d\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006e\u0065\u0077\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0063\u0069\u0070\u0068\u0065\u0072\u002e\u0064\u006f\u0046\u0069\u006e\u0061\u006c\u0028\u0042\u0061\u0073\u0065\u0036\u0034\u002e\u0067\u0065\u0074\u0044\u0065\u0063\u006f\u0064\u0065\u0072\u0028\u0029\u002e\u0064\u0065\u0063\u006f\u0064\u0065\u0028\u0073\u0074\u0072\u0054\u006f\u0044\u0065\u0063\u0072\u0079\u0070\u0074\u0029\u0029\u0029\u003b\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000d\u000a\u0009\u0009\u007d\u000d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u006e\u0075\u006c\u006c\u003b\u000d\u000a\u0009\u007d
+
+}
diff --git a/src/Java/gtPlusPlus/core/util/sys/NetworkUtils.java b/src/Java/gtPlusPlus/core/util/sys/NetworkUtils.java
index b883391a86..1403713b3d 100644
--- a/src/Java/gtPlusPlus/core/util/sys/NetworkUtils.java
+++ b/src/Java/gtPlusPlus/core/util/sys/NetworkUtils.java
@@ -41,10 +41,10 @@ public class NetworkUtils {
public static boolean checkNetworkIsAvailableWithValidInterface(){
try {
if (hasValidNetworkInterface()){
- if (checkAddressWithTimeout("http://www.google.com", 10) ||
- checkAddressWithTimeout("http://www.baidu.com", 10) ||
- checkAddressWithTimeout("https://github.com/draknyte1/GTplusplus", 10) ||
- checkAddressWithTimeout("www.yahoo.com", 10)/* ||
+ if (checkAddressWithTimeout("http://www.google.com", 100) ||
+ checkAddressWithTimeout("http://www.baidu.com", 100) ||
+ checkAddressWithTimeout("http://www.github.com/alkcorp/GTplusplus", 100) ||
+ checkAddressWithTimeout("http://www.yahoo.com", 100)/* ||
netIsAvailableGoogle() ||
netIsAvailableBaidu() ||
netIsAvailableGithub() ||
@@ -63,82 +63,26 @@ public class NetworkUtils {
return false;
}
- private static boolean netIsAvailableGoogle() {
- try {
- final URL url = new URL("http://www.google.com");
- final URLConnection conn = url.openConnection();
- conn.connect();
- return true;
- } catch (final MalformedURLException e) {
- throw new RuntimeException(e);
- } catch (final IOException e) {
- return false;
- }
- }
-
- private static boolean netIsAvailableBaidu() {
- try {
- final URL url = new URL("http://www.baidu.com");
- final URLConnection conn = url.openConnection();
- conn.connect();
- return true;
- } catch (final MalformedURLException e) {
- throw new RuntimeException(e);
- } catch (final IOException e) {
- return false;
- }
- }
+ private static boolean checkAddressWithTimeout(String URL, int timeout) {
- private static boolean netIsAvailableGithub() {
try {
- final URL url = new URL("https://github.com/draknyte1/GTplusplus");
- final URLConnection conn = url.openConnection();
- conn.connect();
+ InetAddress.getByName(URL).isReachable(timeout); //Replace with your name
return true;
- } catch (final MalformedURLException e) {
- throw new RuntimeException(e);
- } catch (final IOException e) {
- return false;
- }
- }
-
- private static boolean netIsAvailableOther() {
- try {
- final int timeout = 200;
- final InetAddress[] addresses = InetAddress.getAllByName("www.yahoo.com");
- for (final InetAddress address : addresses) {
- if (address.isReachable(timeout)) {
- return true;
- }
- return false;
- }
- } catch (final Exception e) {
- return false;
- }
- return false;
- }
-
- private static boolean checkAddressWithTimeout(String URL, int timeout) {
-
- try {
- InetAddress.getByName(URL).isReachable(timeout); //Replace with your name
- return true;
- } catch (Exception e) {
- return false;
- }
-
- /*try {
- final InetAddress[] addresses = InetAddress.getAllByName(URL);
- for (final InetAddress address : addresses) {
- if (address.isReachable(timeout)) {
- return true;
+ } catch (Exception e) {
+ boolean result = false;
+ try {
+ URL urlObj = new URL(URL);
+ HttpURLConnection con = (HttpURLConnection) urlObj.openConnection();
+ con.setRequestMethod("GET");
+ con.setConnectTimeout(timeout);
+ con.connect();
+ int code = con.getResponseCode();
+ if (code == 200) {
+ result = true;
}
- return false;
- }
- } catch (final Exception e) {
- return false;
+ } catch (Exception e2) {}
+ return result;
}
- return false;*/
}
private static boolean hasValidNetworkInterface() throws SocketException{
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java
index 6201a782de..9d8ecd55ff 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java
@@ -1,44 +1,26 @@
package gtPlusPlus.xmod.gregtech.common.render;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigInteger;
+import java.io.*;
import java.net.URL;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.Base64;
import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.List;
import java.util.UUID;
-import javax.crypto.Cipher;
-import javax.crypto.NoSuchPaddingException;
-import javax.crypto.spec.IvParameterSpec;
-import javax.crypto.spec.SecretKeySpec;
-import javax.xml.bind.DatatypeConverter;
-
import org.apache.commons.io.IOUtils;
import org.lwjgl.opengl.GL11;
import com.mojang.authlib.GameProfile;
-import gregtech.api.enums.GT_Values;
-import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_Utility;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.api.objects.data.Pair;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.lib.CORE.ConfigSwitches;
import gtPlusPlus.core.proxy.ClientProxy;
-import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.data.AES;
import gtPlusPlus.core.util.data.FileUtils;
+import gtPlusPlus.core.util.math.MathUtils;
import gtPlusPlus.core.util.sys.NetworkUtils;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.model.ModelBiped;
@@ -49,29 +31,28 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.RenderPlayerEvent;
-import net.minecraftforge.common.UsernameCache;
public class GTPP_CapeRenderer extends RenderPlayer {
- private final ResourceLocation[] mCapes = {
+ private static final ResourceLocation[] mCapes = {
new ResourceLocation("miscutils:textures/OrangeHD.png"),
new ResourceLocation("miscutils:textures/FancyCapeHD.png"),
new ResourceLocation("miscutils:textures/TesterCapeHD.png"),
+ new ResourceLocation("miscutils:textures/PatreonCapeHD.png"),
new ResourceLocation("miscutils:textures/DevCapeHD.png"),
- new ResourceLocation("miscutils:textures/PatreonCapeHD.png") };
+ };
- private final ArrayList<String> mData;
+ private final boolean mInit;
public GTPP_CapeRenderer() {
- downloadCapeList();
- ArrayList<String> aTemp = new ArrayList<String>();
- try {
- aTemp = returnDatData();
+ mInit = init();
+ }
+
+ private final boolean init() {
+ if (mInit) {
+ return false;
}
- catch (Throwable t) {
- aTemp = new ArrayList<String>();
- }
- mData = aTemp;
+ return CapeUtils.init();
}
private static boolean hasResourceChecked = false;
@@ -80,104 +61,128 @@ public class GTPP_CapeRenderer extends RenderPlayer {
private ResourceLocation tResource = null;
public synchronized void receiveRenderSpecialsEvent(RenderPlayerEvent.Specials.Pre aEvent) {
+
+ // Check we have set Render Manager
if (this.renderManager == null) {
hasSetRenderer = false;
}
+
+ // Set Render Manager
if (!hasSetRenderer) {
if (RenderManager.instance != null) {
setRenderManager(RenderManager.instance);
+ hasSetRenderer = true;
}
- }
- AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer;
- if (!ConfigSwitches.enableCustomCapes) {
- aEvent.setCanceled(true);
- Logger.WARNING("A1");
- return;
- }
-
- if (hasResourceChecked) {
- if (!hasCape && !CORE.DEVENV) {
+ }
+
+ // Actually Render
+ if (hasSetRenderer) {
+
+ // We have capes turned off, so let's not render.
+ if (!ConfigSwitches.enableCustomCapes) {
aEvent.setCanceled(true);
- Logger.WARNING("A2");
return;
}
- }
- // Make sure we don't keep checking on clients who dont have capes.
- if (!hasResourceChecked) {
-
- // Time to Spliterate some data
- Map<String, ResourceLocation> aPlayerData = new HashMap<String, ResourceLocation>();
- Map<String, String> aNameMap = new HashMap<String, String>();
- int i = 0;
- if (!CORE.DEVENV) {
- for (String s : mData) {
- String[] aSplit = s.split("@");
- int a[] = new int[] { 0, mCapes.length - 1 };
- int aID = Integer.parseInt(aSplit[1]);
- // Quick Check to prevent lag
- Logger.WARNING("Trying to create UUID from - " + aSplit[0]);
- UUID aPlayerID = UUID.fromString(aSplit[0]);
- Logger.WARNING("Result: " + aPlayerID.toString());
- if (aPlayerID != null) {
- if (UsernameCache.containsUUID(aPlayerID)) {
- Logger.WARNING("UsernameCache contains a last known username for current players UUID.");
- if (!UsernameCache.getLastKnownUsername(aPlayerID).toLowerCase()
- .equals(ClientProxy.playerName)) {
- Logger.WARNING("Last known name does not match current name. Checking next UUID.");
- continue;
- } else {
- Logger.WARNING("Last known name does match current name.");
- }
- } else {
- Logger.WARNING("UsernameCache did not hold results for current player, oops.");
- continue;
- }
- }
- String aPlayerName = this.getPlayerName("iteration-" + (i++), aSplit[0]);
- aNameMap.put(aSplit[0], aPlayerName);
- aPlayerData.put(aPlayerName, this.mCapes[Math.max(a[0], Math.min(aID, a[1]))]);
+ // We have already checked if this player has a cape, but since they do not, we best not render.
+ if (hasResourceChecked) {
+ if (!hasCape && !CORE.DEVENV) {
+ aEvent.setCanceled(true);
+ return;
}
}
- // Set flag to only render this event if player has a cape.
- for (String s : aNameMap.values()) {
- if (s.toLowerCase().equals(ClientProxy.playerName)) {
+ // Allocate client player object
+ AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer;
+
+ // Make sure we don't keep checking on clients who dont have capes.
+ if (!hasResourceChecked) {
+
+ // Get players UUID
+ String aPlayerUUID = aPlayer != null ? aPlayer.getGameProfile().getId().toString() : "BAD";
+
+ // If for whatever reason this fails, we just exit early.
+ if (aPlayerUUID.equals("BAD")) {
+ aEvent.setCanceled(true);
+ return;
+ }
+
+ // Automatically allocate a Dev cape while in Dev mode.
+ if (tResource == null && CORE.DEVENV) {
+ tResource = mCapes[4];
hasCape = true;
- tResource = aPlayerData.get(ClientProxy.playerName);
- break;
}
- }
- // Dev capes for dev mode.
- if (CORE.DEVENV) {
- hasCape = true;
- tResource = mCapes[3];
- }
+ String aPlayerName = ClientProxy.playerName;
- // Safety Check
- if (tResource == null) {
- if (aPlayerData.get(aPlayer.getDisplayName()) != null) {
- tResource = aPlayerData.get(aPlayer.getDisplayName());
- } else {
- hasCape = false;
+ // Check cape lists for the cape this player owns.
+ if (!hasCape) {
+ for (Pair<String, String> aData : CapeUtils.mOrangeCapes) {
+ if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) {
+ tResource = mCapes[0];
+ hasCape = true;
+ break;
+ }
+ }
+ }
+ if (!hasCape) {
+ for (Pair<String, String> aData : CapeUtils.mMiscCapes) {
+ if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) {
+ tResource = mCapes[1];
+ hasCape = true;
+ break;
+ }
+ }
}
+ if (!hasCape) {
+ for (Pair<String, String> aData : CapeUtils.mBetaTestCapes) {
+ if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) {
+ tResource = mCapes[2];
+ hasCape = true;
+ break;
+ }
+ }
+ }
+ if (!hasCape) {
+ for (Pair<String, String> aData : CapeUtils.mPatreonCapes) {
+ if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) {
+ tResource = mCapes[3];
+ hasCape = true;
+ break;
+ }
+ }
+ }
+ if (!hasCape) {
+ for (Pair<String, String> aData : CapeUtils.mDevCapes) {
+ if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) {
+ tResource = mCapes[4];
+ hasCape = true;
+ break;
+ }
+ }
+ }
+ hasResourceChecked = true;
}
- // Only run once.
- hasResourceChecked = true;
- }
- if (GT_Utility.getFullInvisibility(aPlayer) || aPlayer.isInvisible()
- || GT_Utility.getPotion(aPlayer, Integer.valueOf(Potion.invisibility.id).intValue())) {
- aEvent.setCanceled(true);
- Logger.WARNING("A3");
- return;
+ // If player is invisible, don't render.
+ if (GT_Utility.getFullInvisibility(aPlayer) || aPlayer.isInvisible()
+ || GT_Utility.getPotion(aPlayer, Integer.valueOf(Potion.invisibility.id).intValue())) {
+ aEvent.setCanceled(true);
+ return;
+ }
+
+ if (hasResourceChecked) {
+ // We have met all the conditions, let's render that cape.
+ renderCapeOnPlayer(aEvent, aPlayer);
+ }
}
+ }
+
+ private final boolean renderCapeOnPlayer(RenderPlayerEvent.Specials.Pre aEvent, AbstractClientPlayer aPlayer) {
float aPartialTicks = aEvent.partialRenderTick;
try {
-
if (tResource == null && CORE.DEVENV) {
tResource = mCapes[3];
}
@@ -221,14 +226,22 @@ public class GTPP_CapeRenderer extends RenderPlayer {
GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
((ModelBiped) this.mainModel).renderCloak(0.0625F);
GL11.glPopMatrix();
+ return true;
}
} catch (Throwable e) {
- if (GT_Values.D1) {
- e.printStackTrace(GT_Log.err);
- }
+
}
+ return false;
}
+ @SuppressWarnings("unused")
+ @Deprecated
+ /**
+ * Should be able to get the username from a UUID
+ * @param name - Players Name
+ * @param uuid - Players known UUID
+ * @return - The newest Player name
+ */
private String getPlayerName(String name, String uuid) {
try {
Logger.WORLD("[Capes++] Trying to UUID check " + name + ".");
@@ -271,29 +284,239 @@ public class GTPP_CapeRenderer extends RenderPlayer {
return name;
}
- private void downloadCapeList() {
- if (!NetworkUtils.checkNetworkIsAvailableWithValidInterface()) {
- return;
- }
- try {
- File dat = new File(Utils.getMcDir(), "GTPP.dat");
- if (FileUtils.doesFileExist(dat)) {
+
+
+ private static class CapeUtils {
+
+ private static char SPLIT_CHARACTER = 'ยง';
+ private static AES sAES;
+
+ // UUID - Username
+ private static final AutoMap<Pair<String, String>> mOrangeCapes = new AutoMap<Pair<String, String>>();
+ private static final AutoMap<Pair<String, String>> mMiscCapes = new AutoMap<Pair<String, String>>();
+ private static final AutoMap<Pair<String, String>> mBetaTestCapes = new AutoMap<Pair<String, String>>();
+ private static final AutoMap<Pair<String, String>> mPatreonCapes = new AutoMap<Pair<String, String>>();
+ private static final AutoMap<Pair<String, String>> mDevCapes = new AutoMap<Pair<String, String>>();
+
+ private static final boolean init() {
+ CapeUtils.handleOldCapeCache();
+ try {
+ if (shouldDownloadCapeList()) {
+ downloadCapeList();
+ }
+ }
+ catch (Exception e) {
+ return false;
+ }
+ writeCacheToMaps();
+ return true;
+ }
+
+
+ private static boolean shouldDownloadCapeList() {
+ if (!doesCapeCacheExistLocally()) {
+ return true;
+ }
+ if (isCapeCacheWeekOld()) {
+ return true;
+ }
+ return false;
+ }
+
+ private static final boolean isCapeCacheWeekOld() {
+ if (!doesCapeCacheExistLocally()) {
+ return true;
+ }
+ else {
+ File dat = CapeUtils.getCapeCache();
Date dateLastMod = new Date(dat.lastModified());
Date dateNow = new Date(System.currentTimeMillis() - (7l * 24 * 60 * 60 * 1000));
- if (!dateLastMod.before(dateNow)) {
- return;
+ if (dateLastMod.before(dateNow)) {
+ return true;
}
}
- InputStream inputStream = new URL("https://alkcorp.overminddl1.com/GTPP.dat").openStream();
- FileOutputStream fileOS = new FileOutputStream(dat);
- IOUtils.copy(inputStream, fileOS);
+ return false;
+ }
- } catch (Throwable t) {
- Logger.INFO("Unable to download GT++ cape list.");
+ private static final void downloadCapeList() {
+ if (!NetworkUtils.checkNetworkIsAvailableWithValidInterface()) {
+ return;
+ }
+ try {
+ File dat = getCapeCache();
+ File temp = allocateTempFile();
+ InputStream inputStream = new URL("https://alkcorp.overminddl1.com/CapeCache.dat").openStream();
+ FileOutputStream fileOS = new FileOutputStream(temp);
+ IOUtils.copy(inputStream, fileOS);
+ if (isDownloadedCapeListBigger(temp)) {
+ fileOS = new FileOutputStream(dat);
+ IOUtils.copy(inputStream, fileOS);
+ }
+ } catch (Throwable t) {
+ Logger.INFO("Unable to download GT++ cape list.");
+ }
+ }
+
+ private static final boolean isDownloadedCapeListBigger(File aFile) {
+ double aExistingFileSize = (doesCapeCacheExistLocally() ? getCapeCache().length() : 0);
+ double aNewFileSize = aFile.length();
+ if (aNewFileSize > aExistingFileSize) {
+ return true;
+ }
+ return false;
+ }
+
+ private static void handleOldCapeCache() {
+ File aCacheFile = FileUtils.getFile("GTPP", "dat");
+ if (FileUtils.doesFileExist(aCacheFile)) {
+ aCacheFile.delete();
+ }
+ }
+
+ private static final boolean doesCapeCacheExistLocally() {
+ File aCacheFile = FileUtils.getFile("CapeCache", "dat");
+ if (FileUtils.doesFileExist(aCacheFile)) {
+ return true;
+ }
+ return false;
+ }
+
+ private static final File getCapeCache() {
+ File aCacheFile = FileUtils.getFile("CapeCache", "dat");
+ if (FileUtils.doesFileExist(aCacheFile)) {
+ FileUtils.createFile(aCacheFile);
+ }
+ return aCacheFile;
+ }
+
+ public static final List<String> getDataFromCache(){
+ File aCacheFile = getCapeCache();
+ List<String> aCache = FileUtils.readLines(aCacheFile);
+ if (aCache != null && !aCache.isEmpty()) {
+ return aCache;
+ }
+ return new AutoMap<String>();
+ }
+
+ private static final File allocateTempFile() {
+ File tempFile = null;
+ try {
+ tempFile = File.createTempFile("gtpp-", null);
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ if (tempFile == null) {
+ tempFile = FileUtils.createFile("", "gtpp-"+MathUtils.randInt(Short.MAX_VALUE, (Integer.MAX_VALUE/2)), "tmp");
+ }
+ tempFile.deleteOnExit();
+ return tempFile;
+ }
+
+
+ public static final void writeCacheToMaps() {
+ List<String> aCacheData = getDataFromCache();
+ if (aCacheData != null && !aCacheData.isEmpty()) {
+ if (sAES == null) {
+ sAES = new AES();
+ }
+ AutoMap<String> aDecodedData = new AutoMap<String>();
+ for (String aToDecode : aCacheData) {
+ aDecodedData.put(sAES.decrypt(aToDecode));
+ }
+ if (!aDecodedData.isEmpty()) {
+ AutoMap<Pair<String, String>> aCapeType1 = new AutoMap<Pair<String, String>>();
+ AutoMap<Pair<String, String>> aCapeType2 = new AutoMap<Pair<String, String>>();
+ AutoMap<Pair<String, String>> aCapeType3 = new AutoMap<Pair<String, String>>();
+ AutoMap<Pair<String, String>> aCapeType4 = new AutoMap<Pair<String, String>>();
+ AutoMap<Pair<String, String>> aCapeType5 = new AutoMap<Pair<String, String>>();
+ boolean didProcessStringData = false;
+ Logger.INFO("Decoded String Count: "+aDecodedData.size());
+ for (String aToSplit : aDecodedData) {
+ String[] aSplitData = aToSplit.split(""+SPLIT_CHARACTER);
+ if (aSplitData != null && aSplitData.length >= 2) {
+ if (aSplitData[0] != null) {
+ Integer aCapeTypeID2 = Integer.parseInt(aSplitData[0]);
+ if (aCapeTypeID2 != null) {
+ int aCapeTypeID = aCapeTypeID2;
+ Pair<String, String> aFinalString = new Pair<String, String>("UUID: "+aSplitData[1], "Username: "+(aSplitData[2] != null && aSplitData[0].length() > 0 ? aSplitData[2] : "Not Specified"));
+ Logger.INFO("Cape Type: "+aCapeTypeID);
+ switch (aCapeTypeID) {
+ case 0:
+ aCapeType1.add(aFinalString);
+ Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType1.size()+" users.");
+ break;
+ case 1:
+ aCapeType2.add(aFinalString);
+ Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType2.size()+" users.");
+ break;
+ case 2:
+ aCapeType3.add(aFinalString);
+ Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType3.size()+" users.");
+ break;
+ case 3:
+ aCapeType4.add(aFinalString);
+ Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType4.size()+" users.");
+ break;
+ case 4:
+ aCapeType5.add(aFinalString);
+ Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType5.size()+" users.");
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (!aCapeType1.isEmpty() || !aCapeType2.isEmpty() || !aCapeType3.isEmpty() || !aCapeType4.isEmpty() || !aCapeType5.isEmpty()) {
+ didProcessStringData = true;
+ }
+ else {
+ // did not process any data
+ }
+ if (didProcessStringData) {
+ if (!aCapeType1.isEmpty()) {
+ for (Pair<String, String> aUser : aCapeType1) {
+ Logger.INFO("Adding Generic cape for "+aUser.getKey());
+ mOrangeCapes.add(aUser);
+ }
+ }
+ if (!aCapeType2.isEmpty()) {
+ for (Pair<String, String> aUser : aCapeType2) {
+ Logger.INFO("Adding Blue cape for "+aUser.getKey());
+ mMiscCapes.add(aUser);
+ }
+ }
+ if (!aCapeType3.isEmpty()) {
+ for (Pair<String, String> aUser : aCapeType3) {
+ Logger.INFO("Adding Beta cape for "+aUser.getKey());
+ mBetaTestCapes.add(aUser);
+ }
+ }
+ if (!aCapeType4.isEmpty()) {
+ for (Pair<String, String> aUser : aCapeType4) {
+ Logger.INFO("Adding Patreon cape for "+aUser.getKey());
+ mPatreonCapes.add(aUser);
+ }
+ }
+ if (!aCapeType5.isEmpty()) {
+ for (Pair<String, String> aUser : aCapeType5) {
+ Logger.INFO("Adding Dev cape for "+aUser.getKey());
+ mDevCapes.add(aUser);
+ }
+ }
+ }
+ }
+ else {
+ // No data decoded
+ }
+ }
+ else {
+ // Nothing was cached?
+ }
}
}
-
- /* TODO: fix this stuff \u002a\u002f\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0072\u0065\u0074\u0075\u0072\u006e\u0044\u0061\u0074\u0044\u0061\u0074\u0061\u0028\u0029\u007b\u000a\u0009\u0009\u0046\u0069\u006c\u0065\u0020\u0064\u0061\u0074\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0046\u0069\u006c\u0065\u0028\u0055\u0074\u0069\u006c\u0073\u002e\u0067\u0065\u0074\u004d\u0063\u0044\u0069\u0072\u0028\u0029\u002c\u0020\u0022\u0047\u0054\u0050\u0050\u002e\u0064\u0061\u0074\u0022\u0029\u003b\u000a\u0009\u0009\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0048\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0028\u0029\u003b\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u0028\u0042\u0075\u0066\u0066\u0065\u0072\u0065\u0064\u0052\u0065\u0061\u0064\u0065\u0072\u0020\u0062\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0042\u0075\u0066\u0066\u0065\u0072\u0065\u0064\u0052\u0065\u0061\u0064\u0065\u0072\u0028\u006e\u0065\u0077\u0020\u0046\u0069\u006c\u0065\u0052\u0065\u0061\u0064\u0065\u0072\u0028\u0064\u0061\u0074\u0029\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u006c\u0069\u006e\u0065\u003b\u000a\u0009\u0009\u0009\u0077\u0068\u0069\u006c\u0065\u0020\u0028\u0028\u006c\u0069\u006e\u0065\u0020\u003d\u0020\u0062\u0072\u002e\u0072\u0065\u0061\u0064\u004c\u0069\u006e\u0065\u0028\u0029\u0029\u0020\u0021\u003d\u0020\u006e\u0075\u006c\u006c\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0048\u002e\u0061\u0064\u0064\u0028\u006c\u0069\u006e\u0065\u0029\u003b\u000a\u0009\u0009\u0009\u007d\u000a\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0049\u004f\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0065\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u000a\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0061\u0053\u0070\u006c\u0069\u0074\u0044\u0061\u0074\u0061\u0043\u0068\u0065\u0063\u006b\u005b\u005d\u0020\u003d\u0020\u0048\u002e\u0067\u0065\u0074\u0028\u0030\u0029\u002e\u0073\u0070\u006c\u0069\u0074\u0028\u0022\u0025\u0022\u0029\u003b\u000a\u0009\u0009\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0061\u0043\u006c\u0065\u0061\u006e\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0028\u0029\u003b\u000a\u0009\u0009\u0066\u006f\u0072\u0020\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0020\u003a\u0020\u0061\u0053\u0070\u006c\u0069\u0074\u0044\u0061\u0074\u0061\u0043\u0068\u0065\u0063\u006b\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0073\u0020\u0021\u003d\u0020\u006e\u0075\u006c\u006c\u0020\u0026\u0026\u0020\u0073\u002e\u006c\u0065\u006e\u0067\u0074\u0068\u0028\u0029\u0020\u003e\u0020\u0030\u0020\u0026\u0026\u0020\u0021\u0073\u002e\u0065\u0071\u0075\u0061\u006c\u0073\u0028\u0022\u0020\u0022\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0061\u0043\u006c\u0065\u0061\u006e\u0044\u0061\u0074\u0061\u002e\u0061\u0064\u0064\u0028\u0073\u0029\u003b\u000a\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u004d\u0041\u0049\u004e\u005f\u0053\u0054\u0041\u0054\u0049\u0043\u005f\u0049\u0056\u0020\u003d\u0020\u0022\u0030\u0031\u0030\u0030\u0030\u0030\u0030\u0031\u0020\u0030\u0031\u0030\u0031\u0030\u0030\u0031\u0022\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u004d\u0041\u0049\u004e\u005f\u0053\u0054\u0041\u0054\u0049\u0043\u005f\u004b\u0045\u0059\u0020\u003d\u0020\u0022\u0030\u0031\u0030\u0030\u0030\u0031\u0030\u0030\u0020\u0030\u0031\u0031\u0030\u0031\u0031\u0031\u0022\u003b\u000a\u0009\u0009\u000a\u0009\u0009\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0061\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0028\u0029\u003b\u000a\u0009\u0009\u0066\u006f\u0072\u0020\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0068\u0020\u003a\u0020\u0061\u0043\u006c\u0065\u0061\u006e\u0044\u0061\u0074\u0061\u0029\u0020\u007b\u0009\u0009\u0009\u000a\u0009\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u003d\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0028\u0068\u002c\u0020\u004d\u0041\u0049\u004e\u005f\u0053\u0054\u0041\u0054\u0049\u0043\u005f\u0049\u0056\u002c\u0020\u004d\u0041\u0049\u004e\u005f\u0053\u0054\u0041\u0054\u0049\u0043\u005f\u004b\u0045\u0059\u0029\u003b\u000a\u0009\u0009\u0009\u0061\u0044\u0061\u0074\u0061\u002e\u0061\u0064\u0064\u0028\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0053\u0074\u0072\u0069\u006e\u0067\u0029\u003b\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0061\u0044\u0061\u0074\u0061\u003b\u0009\u0009\u000a\u0009\u007d\u000a\u0009\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u006d\u0064\u0035\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0069\u006e\u0070\u0075\u0074\u0029\u0020\u0074\u0068\u0072\u006f\u0077\u0073\u0020\u004e\u006f\u0053\u0075\u0063\u0068\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u007b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u0020\u006d\u0064\u0020\u003d\u0020\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u004d\u0044\u0035\u0022\u0029\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u006d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u0020\u003d\u0020\u006d\u0064\u002e\u0064\u0069\u0067\u0065\u0073\u0074\u0028\u0069\u006e\u0070\u0075\u0074\u002e\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0029\u0029\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0042\u0069\u0067\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0042\u0069\u0067\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u0028\u0031\u002c\u0020\u006d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u0029\u003b\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u002e\u0066\u006f\u0072\u006d\u0061\u0074\u0028\u0022\u0025\u0030\u0033\u0032\u0078\u0022\u002c\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0029\u003b\u000a\u0009\u007d\u000a\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u0020\u0069\u006e\u0069\u0074\u0043\u0069\u0070\u0068\u0065\u0072\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0069\u006e\u0074\u0020\u006d\u006f\u0064\u0065\u002c\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u0053\u0074\u0072\u0069\u006e\u0067\u002c\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u000a\u0009\u0009\u0009\u0074\u0068\u0072\u006f\u0077\u0073\u0020\u004e\u006f\u0053\u0075\u0063\u0068\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u002c\u0020\u004e\u006f\u0053\u0075\u0063\u0068\u0050\u0061\u0064\u0064\u0069\u006e\u0067\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u002c\u0020\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u004b\u0065\u0079\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u002c\u000a\u0009\u0009\u0009\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0050\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u007b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0053\u0070\u0065\u0063\u0020\u0073\u006b\u0065\u0079\u0053\u0070\u0065\u0063\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0053\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0053\u0070\u0065\u0063\u0028\u0074\u006f\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u0028\u006d\u0064\u0035\u0028\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u0029\u002c\u0020\u0022\u0041\u0045\u0053\u0022\u0029\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0049\u0076\u0050\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0053\u0070\u0065\u0063\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0049\u0076\u0050\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0053\u0070\u0065\u0063\u0028\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u0053\u0074\u0072\u0069\u006e\u0067\u002e\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0029\u0029\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u0020\u003d\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u0041\u0045\u0053\u002f\u0043\u0046\u0042\u0038\u002f\u004e\u006f\u0050\u0061\u0064\u0064\u0069\u006e\u0067\u0022\u0029\u003b\u000a\u0009\u0009\u0063\u0069\u0070\u0068\u0065\u0072\u002e\u0069\u006e\u0069\u0074\u0028\u006d\u006f\u0064\u0065\u002c\u0020\u0073\u006b\u0065\u0079\u0053\u0070\u0065\u0063\u002c\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u0029\u003b\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u003b\u000a\u0009\u007d\u000a\u000a\u0009\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0074\u006f\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0029\u0020\u007b\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0044\u0061\u0074\u0061\u0074\u0079\u0070\u0065\u0043\u006f\u006e\u0076\u0065\u0072\u0074\u0065\u0072\u002e\u0070\u0061\u0072\u0073\u0065\u0048\u0065\u0078\u0042\u0069\u006e\u0061\u0072\u0079\u0028\u0073\u0029\u003b\u000a\u0009\u007d\u000a\u0009\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0044\u0061\u0074\u0061\u002c\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u002c\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u0020\u007b\u000a\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u006e\u0075\u006c\u006c\u003b\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000a\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u0020\u003d\u0020\u0069\u006e\u0069\u0074\u0043\u0069\u0070\u0068\u0065\u0072\u0028\u0043\u0069\u0070\u0068\u0065\u0072\u002e\u0044\u0045\u0043\u0052\u0059\u0050\u0054\u005f\u004d\u004f\u0044\u0045\u002c\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u002c\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u003b\u000a\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u0020\u003d\u0020\u0042\u0061\u0073\u0065\u0036\u0034\u002e\u0067\u0065\u0074\u0044\u0065\u0063\u006f\u0064\u0065\u0072\u0028\u0029\u002e\u0064\u0065\u0063\u006f\u0064\u0065\u0028\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0044\u0061\u0074\u0061\u0029\u003b\u000a\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u0020\u003d\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u002e\u0064\u006f\u0046\u0069\u006e\u0061\u006c\u0028\u0065\u006e\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u0029\u003b\u000a\u0009\u0009\u0009\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u002c\u0020\u0022\u0055\u0054\u0046\u0038\u0022\u0029\u003b\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0044\u0061\u0074\u0061\u003b\u000a\u0009\u007d\u002f\u002a */
-
+
} \ No newline at end of file