Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.23 KB | None | 0 0
  1.  
  2. Decompilers online
  3.  
  4. File Name: BootsJava7(1).jar, Done.
  5.  
  6. Java decompilers
  7. APK decompiler
  8. Download Jad
  9.  
  10. Decompilation Results
  11. Decompilation Results
  12. File Name: BootsJava7(1).jar
  13. Decompiler: CFR
  14. Job status: Done.
  15.  
  16.  
  17.  
  18. Twitter Facebook Google+ Stumbleupon LinkedIn
  19.  
  20. BootsJava7(1).jar me SwiftCoding Boots metrics.java
  21.  
  22. /*
  23. * Decompiled with CFR 0_110.
  24. *
  25. * Could not load the following classes:
  26. * org.bukkit.Bukkit
  27. * org.bukkit.Server
  28. * org.bukkit.configuration.InvalidConfigurationException
  29. * org.bukkit.configuration.file.YamlConfiguration
  30. * org.bukkit.configuration.file.YamlConfigurationOptions
  31. * org.bukkit.entity.Player
  32. * org.bukkit.plugin.Plugin
  33. * org.bukkit.plugin.PluginDescriptionFile
  34. * org.bukkit.scheduler.BukkitScheduler
  35. * org.bukkit.scheduler.BukkitTask
  36. */
  37. package me.SwiftCoding.Boots;
  38.  
  39. import java.io.BufferedReader;
  40. import java.io.ByteArrayOutputStream;
  41. import java.io.File;
  42. import java.io.IOException;
  43. import java.io.InputStream;
  44. import java.io.InputStreamReader;
  45. import java.io.OutputStream;
  46. import java.io.PrintStream;
  47. import java.io.Reader;
  48. import java.io.UnsupportedEncodingException;
  49. import java.lang.reflect.Method;
  50. import java.net.Proxy;
  51. import java.net.URL;
  52. import java.net.URLConnection;
  53. import java.net.URLEncoder;
  54. import java.util.Collection;
  55. import java.util.Collections;
  56. import java.util.HashSet;
  57. import java.util.LinkedHashSet;
  58. import java.util.Set;
  59. import java.util.UUID;
  60. import java.util.logging.Level;
  61. import java.util.zip.GZIPOutputStream;
  62. import org.bukkit.Bukkit;
  63. import org.bukkit.Server;
  64. import org.bukkit.configuration.InvalidConfigurationException;
  65. import org.bukkit.configuration.file.YamlConfiguration;
  66. import org.bukkit.configuration.file.YamlConfigurationOptions;
  67. import org.bukkit.entity.Player;
  68. import org.bukkit.plugin.Plugin;
  69. import org.bukkit.plugin.PluginDescriptionFile;
  70. import org.bukkit.scheduler.BukkitScheduler;
  71. import org.bukkit.scheduler.BukkitTask;
  72.  
  73. public class metrics {
  74. private static final int REVISION = 7;
  75. private static final String BASE_URL = "http://report.mcstats.org";
  76. private static final String REPORT_URL = "/plugin/%s";
  77. private static final int PING_INTERVAL = 15;
  78. private final Plugin plugin;
  79. private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet());
  80. private final YamlConfiguration configuration;
  81. private final File configurationFile;
  82. private final String guid;
  83. private final boolean debug;
  84. private final Object optOutLock = new Object();
  85. private volatile BukkitTask task = null;
  86.  
  87. public metrics(Plugin plugin) throws IOException {
  88. if (plugin == null) {
  89. throw new IllegalArgumentException("Plugin cannot be null");
  90. }
  91. this.plugin = plugin;
  92. this.configurationFile = this.getConfigFile();
  93. this.configuration = YamlConfiguration.loadConfiguration((File)this.configurationFile);
  94. this.configuration.addDefault("opt-out", (Object)false);
  95. this.configuration.addDefault("guid", (Object)UUID.randomUUID().toString());
  96. this.configuration.addDefault("debug", (Object)false);
  97. if (this.configuration.get("guid", (Object)null) == null) {
  98. this.configuration.options().header("http://mcstats.org").copyDefaults(true);
  99. this.configuration.save(this.configurationFile);
  100. }
  101. this.guid = this.configuration.getString("guid");
  102. this.debug = this.configuration.getBoolean("debug", false);
  103. }
  104.  
  105. public Graph createGraph(String name) {
  106. if (name == null) {
  107. throw new IllegalArgumentException("Graph name cannot be null");
  108. }
  109. Graph graph = new Graph(name, null);
  110. this.graphs.add(graph);
  111. return graph;
  112. }
  113.  
  114. public void addGraph(Graph graph) {
  115. if (graph == null) {
  116. throw new IllegalArgumentException("Graph cannot be null");
  117. }
  118. this.graphs.add(graph);
  119. }
  120.  
  121. public boolean start() {
  122. Object object = this.optOutLock;
  123. synchronized (object) {
  124. block6 : {
  125. block5 : {
  126. if (!this.isOptOut()) break block5;
  127. return false;
  128. }
  129. if (this.task == null) break block6;
  130. return true;
  131. }
  132. this.task = this.plugin.getServer().getScheduler().runTaskTimerAsynchronously(this.plugin, new Runnable(){
  133. private boolean firstPost;
  134.  
  135. @Override
  136. public void run() {
  137. block7 : {
  138. try {
  139. Object object = metrics.this.optOutLock;
  140. synchronized (object) {
  141. if (metrics.this.isOptOut() && metrics.this.task != null) {
  142. metrics.this.task.cancel();
  143. metrics.access$2(metrics.this, null);
  144. for (Graph graph : metrics.this.graphs) {
  145. graph.onOptOut();
  146. }
  147. }
  148. }
  149. metrics.this.postPlugin(!this.firstPost);
  150. this.firstPost = false;
  151. }
  152. catch (IOException e) {
  153. if (!metrics.this.debug) break block7;
  154. Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage());
  155. }
  156. }
  157. }
  158. }, 0, 18000);
  159. return true;
  160. }
  161. }
  162.  
  163. /*
  164. * Enabled aggressive block sorting
  165. * Enabled unnecessary exception pruning
  166. * Enabled aggressive exception aggregation
  167. */
  168. public boolean isOptOut() {
  169. Object object = this.optOutLock;
  170. synchronized (object) {
  171. try {
  172. this.configuration.load(this.getConfigFile());
  173. }
  174. catch (IOException ex) {
  175. if (this.debug) {
  176. Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
  177. }
  178. return true;
  179. }
  180. catch (InvalidConfigurationException ex) {
  181. if (this.debug) {
  182. Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
  183. }
  184. return true;
  185. }
  186. return this.configuration.getBoolean("opt-out", false);
  187. }
  188. }
  189.  
  190. public void enable() throws IOException {
  191. Object object = this.optOutLock;
  192. synchronized (object) {
  193. if (this.isOptOut()) {
  194. this.configuration.set("opt-out", (Object)false);
  195. this.configuration.save(this.configurationFile);
  196. }
  197. if (this.task == null) {
  198. this.start();
  199. }
  200. }
  201. }
  202.  
  203. public void disable() throws IOException {
  204. Object object = this.optOutLock;
  205. synchronized (object) {
  206. if (!this.isOptOut()) {
  207. this.configuration.set("opt-out", (Object)true);
  208. this.configuration.save(this.configurationFile);
  209. }
  210. if (this.task != null) {
  211. this.task.cancel();
  212. this.task = null;
  213. }
  214. }
  215. }
  216.  
  217. public File getConfigFile() {
  218. File pluginsFolder = this.plugin.getDataFolder().getParentFile();
  219. return new File(new File(pluginsFolder, "PluginMetrics"), "config.yml");
  220. }
  221.  
  222. private int getOnlinePlayers() {
  223. try {
  224. Method onlinePlayerMethod = Server.class.getMethod("getOnlinePlayers", new Class[0]);
  225. if (onlinePlayerMethod.getReturnType().equals(Collection.class)) {
  226. return ((Collection)onlinePlayerMethod.invoke((Object)Bukkit.getServer(), new Object[0])).size();
  227. }
  228. return ((Player[])onlinePlayerMethod.invoke((Object)Bukkit.getServer(), new Object[0])).length;
  229. }
  230. catch (Exception ex) {
  231. if (this.debug) {
  232. Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
  233. }
  234. return 0;
  235. }
  236. }
  237.  
  238. private void postPlugin(boolean isPing) throws IOException {
  239. PluginDescriptionFile description = this.plugin.getDescription();
  240. String pluginName = description.getName();
  241. boolean onlineMode = Bukkit.getServer().getOnlineMode();
  242. String pluginVersion = description.getVersion();
  243. String serverVersion = Bukkit.getVersion();
  244. int playersOnline = this.getOnlinePlayers();
  245. StringBuilder json = new StringBuilder(1024);
  246. json.append('{');
  247. metrics.appendJSONPair(json, "guid", this.guid);
  248. metrics.appendJSONPair(json, "plugin_version", pluginVersion);
  249. metrics.appendJSONPair(json, "server_version", serverVersion);
  250. metrics.appendJSONPair(json, "players_online", Integer.toString(playersOnline));
  251. String osname = System.getProperty("os.name");
  252. String osarch = System.getProperty("os.arch");
  253. String osversion = System.getProperty("os.version");
  254. String java_version = System.getProperty("java.version");
  255. int coreCount = Runtime.getRuntime().availableProcessors();
  256. if (osarch.equals("amd64")) {
  257. osarch = "x86_64";
  258. }
  259. metrics.appendJSONPair(json, "osname", osname);
  260. metrics.appendJSONPair(json, "osarch", osarch);
  261. metrics.appendJSONPair(json, "osversion", osversion);
  262. metrics.appendJSONPair(json, "cores", Integer.toString(coreCount));
  263. metrics.appendJSONPair(json, "auth_mode", onlineMode ? "1" : "0");
  264. metrics.appendJSONPair(json, "java_version", java_version);
  265. if (isPing) {
  266. metrics.appendJSONPair(json, "ping", "1");
  267. }
  268. if (this.graphs.size() > 0) {
  269. Set<Graph> set = this.graphs;
  270. synchronized (set) {
  271. json.append(',');
  272. json.append('\"');
  273. json.append("graphs");
  274. json.append('\"');
  275. json.append(':');
  276. json.append('{');
  277. boolean firstGraph = true;
  278. for (Graph graph : this.graphs) {
  279. StringBuilder graphJson = new StringBuilder();
  280. graphJson.append('{');
  281. for (Plotter plotter : graph.getPlotters()) {
  282. metrics.appendJSONPair(graphJson, plotter.getColumnName(), Integer.toString(plotter.getValue()));
  283. }
  284. graphJson.append('}');
  285. if (!firstGraph) {
  286. json.append(',');
  287. }
  288. json.append(metrics.escapeJSON(graph.getName()));
  289. json.append(':');
  290. json.append(graphJson);
  291. firstGraph = false;
  292. }
  293. json.append('}');
  294. }
  295. }
  296. json.append('}');
  297. URL url = new URL("http://report.mcstats.org" + String.format("/plugin/%s", metrics.urlEncode(pluginName)));
  298. URLConnection connection = this.isMineshafterPresent() ? url.openConnection(Proxy.NO_PROXY) : url.openConnection();
  299. byte[] uncompressed = json.toString().getBytes();
  300. byte[] compressed = metrics.gzip(json.toString());
  301. connection.addRequestProperty("User-Agent", "MCStats/7");
  302. connection.addRequestProperty("Content-Type", "application/json");
  303. connection.addRequestProperty("Content-Encoding", "gzip");
  304. connection.addRequestProperty("Content-Length", Integer.toString(compressed.length));
  305. connection.addRequestProperty("Accept", "application/json");
  306. connection.addRequestProperty("Connection", "close");
  307. connection.setDoOutput(true);
  308. if (this.debug) {
  309. System.out.println("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length);
  310. }
  311. OutputStream os = connection.getOutputStream();
  312. os.write(compressed);
  313. os.flush();
  314. BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
  315. String response = reader.readLine();
  316. os.close();
  317. reader.close();
  318. if (response == null || response.startsWith("ERR") || response.startsWith("7")) {
  319. if (response == null) {
  320. response = "null";
  321. } else if (response.startsWith("7")) {
  322. response = response.substring(response.startsWith("7,") ? 2 : 1);
  323. }
  324. throw new IOException(response);
  325. }
  326. if (response.equals("1") || response.contains("This is your first update this hour")) {
  327. Set<Graph> set = this.graphs;
  328. synchronized (set) {
  329. for (Graph graph : this.graphs) {
  330. for (Plotter plotter : graph.getPlotters()) {
  331. plotter.reset();
  332. }
  333. }
  334. }
  335. }
  336. }
  337.  
  338. public static byte[] gzip(String input) {
  339. ByteArrayOutputStream baos;
  340. block14 : {
  341. GZIPOutputStream gzos;
  342. baos = new ByteArrayOutputStream();
  343. gzos = null;
  344. try {
  345. try {
  346. gzos = new GZIPOutputStream(baos);
  347. gzos.write(input.getBytes("UTF-8"));
  348. }
  349. catch (IOException e) {
  350. e.printStackTrace();
  351. if (gzos != null) {
  352. try {
  353. gzos.close();
  354. }
  355. catch (IOException var5_4) {}
  356. }
  357. break block14;
  358. }
  359. }
  360. catch (Throwable var4_7) {
  361. if (gzos != null) {
  362. try {
  363. gzos.close();
  364. }
  365. catch (IOException var5_5) {
  366. // empty catch block
  367. }
  368. }
  369. throw var4_7;
  370. }
  371. if (gzos != null) {
  372. try {
  373. gzos.close();
  374. }
  375. catch (IOException var5_6) {
  376. // empty catch block
  377. }
  378. }
  379. }
  380. return baos.toByteArray();
  381. }
  382.  
  383. private boolean isMineshafterPresent() {
  384. try {
  385. Class.forName("mineshafter.MineServer");
  386. return true;
  387. }
  388. catch (Exception e) {
  389. return false;
  390. }
  391. }
  392.  
  393. private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException {
  394. boolean isValueNumeric = false;
  395. try {
  396. if (value.equals("0") || !value.endsWith("0")) {
  397. Double.parseDouble(value);
  398. isValueNumeric = true;
  399. }
  400. }
  401. catch (NumberFormatException e) {
  402. isValueNumeric = false;
  403. }
  404. if (json.charAt(json.length() - 1) != '{') {
  405. json.append(',');
  406. }
  407. json.append(metrics.escapeJSON(key));
  408. json.append(':');
  409. if (isValueNumeric) {
  410. json.append(value);
  411. } else {
  412. json.append(metrics.escapeJSON(value));
  413. }
  414. }
  415.  
  416. private static String escapeJSON(String text) {
  417. StringBuilder builder = new StringBuilder();
  418. builder.append('\"');
  419. int index = 0;
  420. while (index < text.length()) {
  421. char chr = text.charAt(index);
  422. switch (chr) {
  423. case '\"':
  424. case '\\': {
  425. builder.append('\\');
  426. builder.append(chr);
  427. break;
  428. }
  429. case '\b': {
  430. builder.append("\\b");
  431. break;
  432. }
  433. case '\t': {
  434. builder.append("\\t");
  435. break;
  436. }
  437. case '\n': {
  438. builder.append("\\n");
  439. break;
  440. }
  441. case '\r': {
  442. builder.append("\\r");
  443. break;
  444. }
  445. default: {
  446. if (chr < ' ') {
  447. String t = "000" + Integer.toHexString(chr);
  448. builder.append("\\u" + t.substring(t.length() - 4));
  449. break;
  450. }
  451. builder.append(chr);
  452. }
  453. }
  454. ++index;
  455. }
  456. builder.append('\"');
  457. return builder.toString();
  458. }
  459.  
  460. private static String urlEncode(String text) throws UnsupportedEncodingException {
  461. return URLEncoder.encode(text, "UTF-8");
  462. }
  463.  
  464. static /* synthetic */ void access$2(metrics metrics2, BukkitTask bukkitTask) {
  465. metrics2.task = bukkitTask;
  466. }
  467.  
  468. public static class Graph {
  469. private final String name;
  470. private final Set<Plotter> plotters;
  471.  
  472. private Graph(String name) {
  473. this.plotters = new LinkedHashSet<Plotter>();
  474. this.name = name;
  475. }
  476.  
  477. public String getName() {
  478. return this.name;
  479. }
  480.  
  481. public void addPlotter(Plotter plotter) {
  482. this.plotters.add(plotter);
  483. }
  484.  
  485. public void removePlotter(Plotter plotter) {
  486. this.plotters.remove(plotter);
  487. }
  488.  
  489. public Set<Plotter> getPlotters() {
  490. return Collections.unmodifiableSet(this.plotters);
  491. }
  492.  
  493. public int hashCode() {
  494. return this.name.hashCode();
  495. }
  496.  
  497. public boolean equals(Object object) {
  498. if (!(object instanceof Graph)) {
  499. return false;
  500. }
  501. Graph graph = (Graph)object;
  502. return graph.name.equals(this.name);
  503. }
  504.  
  505. protected void onOptOut() {
  506. }
  507.  
  508. /* synthetic */ Graph(String string, Graph graph) {
  509. Graph graph2;
  510. graph2(string);
  511. }
  512. }
  513.  
  514. public static abstract class Plotter {
  515. private final String name;
  516.  
  517. public Plotter() {
  518. this("Default");
  519. }
  520.  
  521. public Plotter(String name) {
  522. this.name = name;
  523. }
  524.  
  525. public abstract int getValue();
  526.  
  527. public String getColumnName() {
  528. return this.name;
  529. }
  530.  
  531. public void reset() {
  532. }
  533.  
  534. public int hashCode() {
  535. return this.getColumnName().hashCode();
  536. }
  537.  
  538. public boolean equals(Object object) {
  539. if (!(object instanceof Plotter)) {
  540. return false;
  541. }
  542. Plotter plotter = (Plotter)object;
  543. if (plotter.name.equals(this.name) && plotter.getValue() == this.getValue()) {
  544. return true;
  545. }
  546. return false;
  547. }
  548. }
  549.  
  550. }
  551.  
  552. Privacy Policy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement