diff --git a/TFMXMLParser.iml b/TFMXMLParser.iml
new file mode 100644
index 0000000..56af9dc
--- /dev/null
+++ b/TFMXMLParser.iml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..f5fad00
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,43 @@
+
+
+ 4.0.0
+
+ ru.devsaider
+ TFMXMLParser
+ 1.0
+
+
+ 1.6.4
+ 1.0.13
+
+ 1.8
+ 1.8
+ UTF-8
+
+
+
+
+ org.slf4j
+ slf4j-api
+ ${slf4j.version}
+
+
+ ch.qos.logback
+ logback-classic
+ ${logback.version}
+
+
+
+ org.jsoup
+ jsoup
+ 1.7.2
+
+
+ org.apache.commons
+ commons-lang3
+ 3.4
+
+
+
\ No newline at end of file
diff --git a/src/main/java/ru/devsaider/tfmxml/SimpleFetchForm.form b/src/main/java/ru/devsaider/tfmxml/SimpleFetchForm.form
new file mode 100644
index 0000000..95b55e4
--- /dev/null
+++ b/src/main/java/ru/devsaider/tfmxml/SimpleFetchForm.form
@@ -0,0 +1,32 @@
+
+
diff --git a/src/main/java/ru/devsaider/tfmxml/SimpleFetchForm.java b/src/main/java/ru/devsaider/tfmxml/SimpleFetchForm.java
new file mode 100644
index 0000000..8900c85
--- /dev/null
+++ b/src/main/java/ru/devsaider/tfmxml/SimpleFetchForm.java
@@ -0,0 +1,49 @@
+package ru.devsaider.tfmxml;
+
+import org.apache.commons.lang3.StringUtils;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.StringSelection;
+import java.io.IOException;
+
+/**
+ * @author Ruslan Devsaider
+ */
+public class SimpleFetchForm {
+
+ private JButton OKButton;
+ private JPanel SimpleFetchForm;
+ private JTextField textField1;
+
+ public static void main(String[] args) {
+ JFrame frame = new JFrame("Devsaider's XML parser");
+ SimpleFetchForm sff = new SimpleFetchForm();
+
+ sff.OKButton.addActionListener((ae) -> {
+ try {
+ String finalXML;
+ String mapCodeRaw = sff.textField1.getText().replace("@", "");
+ if (StringUtils.isNumeric(mapCodeRaw) && (finalXML = XMLParser.fetchSingle(Integer.parseInt(mapCodeRaw))) != null) {
+ StringSelection selection = new StringSelection(finalXML);
+ Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
+ clipboard.setContents(selection, selection);
+
+ JOptionPane.showMessageDialog(null, "XML code was copied to your clipboard");
+ } else {
+ JOptionPane.showMessageDialog(null, "Invalid XML code");
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
+ frame.setLocationRelativeTo(null);
+ frame.setPreferredSize(new Dimension(300, 125));
+
+ frame.setContentPane(sff.SimpleFetchForm);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.pack();
+ frame.setVisible(true);
+ }
+}
diff --git a/src/main/java/ru/devsaider/tfmxml/XMLParser.java b/src/main/java/ru/devsaider/tfmxml/XMLParser.java
new file mode 100644
index 0000000..c0c70f4
--- /dev/null
+++ b/src/main/java/ru/devsaider/tfmxml/XMLParser.java
@@ -0,0 +1,68 @@
+package ru.devsaider.tfmxml;
+
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.URLDecoder;
+import java.util.Base64;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author Ruslan Devsaider
+ */
+
+public class XMLParser {
+ private final static Logger logger = LoggerFactory.getLogger(XMLParser.class);
+ private final static String CRYPT_KEY = "59A[XG^znsqsq8v{`Xhp3P9G";
+
+ public static void main(String[] args) throws IOException {
+ }
+
+ public static String fetchSingle(int mapCode) throws IOException {
+ Document doc = Jsoup.connect("http://api.micetigri.fr/maps/@" + String.valueOf(mapCode))
+ .userAgent("Devsaider XML parser/1.0")
+ .get();
+ String cryptedXML;
+ Pattern p = Pattern.compile("(?is)map:\"(.*?)\",");
+ Matcher m = p.matcher(doc.html());
+
+ if (m.find() && !(cryptedXML = URLDecoder.decode(m.group(1), "UTF-8")).equals("")) {
+ String finalXML = XMLParser.decrypt(cryptedXML, CRYPT_KEY);
+ File file = new File("cache/" + String.valueOf(mapCode) + ".xml");
+
+ // if file doesn't exists, then create it
+ if (!file.exists()) {
+ file.getParentFile().mkdir();
+ file.createNewFile();
+ }
+
+ FileWriter fw = new FileWriter(file.getAbsoluteFile());
+ BufferedWriter bw = new BufferedWriter(fw);
+ bw.write(finalXML);
+ bw.close();
+ return finalXML;
+ }
+
+ return null;
+ }
+
+ public static String decrypt(String cryptedXML, String key) throws IOException {
+ int c;
+ String finalXML = "";
+ byte[] str = Base64.getDecoder().decode(cryptedXML);
+ for (int i = 0; i < str.length; i++) {
+ c = str[i];
+ c -= key.charAt((i + 1) % key.length());
+ finalXML += (char) (c & 255);
+ }
+
+ return finalXML;
+ }
+}
diff --git a/src/main/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..8c8d862
--- /dev/null
+++ b/src/main/resources/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: ru.devsaider.tfmxml.SimpleFetchForm
+