diff --git a/.idea/ClojureProjectResolveSettings.xml b/.idea/ClojureProjectResolveSettings.xml
new file mode 100644
index 00000000..df470b16
--- /dev/null
+++ b/.idea/ClojureProjectResolveSettings.xml
@@ -0,0 +1,6 @@
+
+
+
+ IDE
+
+
\ No newline at end of file
diff --git a/.idea/CodeMetropolis-sz10.iml b/.idea/CodeMetropolis-sz10.iml
new file mode 100644
index 00000000..d6ebd480
--- /dev/null
+++ b/.idea/CodeMetropolis-sz10.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 00000000..919ce1f1
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 00000000..a55e7a17
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/dbnavigator.xml b/.idea/dbnavigator.xml
new file mode 100644
index 00000000..a1144bb3
--- /dev/null
+++ b/.idea/dbnavigator.xml
@@ -0,0 +1,458 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000..aa345419
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 00000000..dd03e277
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..35eb1ddf
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 00000000..6a0cbfe5
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,84 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1647969322929
+
+
+ 1647969322929
+
+
+
+
\ No newline at end of file
diff --git a/demo-sz10 b/demo-sz10
new file mode 100644
index 00000000..e69de29b
diff --git a/sources/integration/spigot-plugin/src/main/java/codemetropolis/integration/spigot/plugin/Plugin.java b/sources/integration/spigot-plugin/src/main/java/codemetropolis/integration/spigot/plugin/Plugin.java
index d98dde0b..133c7b65 100644
--- a/sources/integration/spigot-plugin/src/main/java/codemetropolis/integration/spigot/plugin/Plugin.java
+++ b/sources/integration/spigot-plugin/src/main/java/codemetropolis/integration/spigot/plugin/Plugin.java
@@ -4,4 +4,15 @@
public class Plugin extends JavaPlugin {
+
+ @Override
+ public void onEnable() {
+ //Plugin startup
+ System.out.println("[CodeMetropolis] Your teleport plugin has started");
+ //Message in the Spigot server runner terminal, tells the user the plugin has successfully started
+ getCommand("tpToBuilding").setExecutor(new Teleport());
+ //Teleport command executor
+ }
+
+
}
diff --git a/sources/integration/spigot-plugin/src/main/java/codemetropolis/integration/spigot/plugin/TeleportToBuildingPlugin/CrunchifyGetPropertyValues.java b/sources/integration/spigot-plugin/src/main/java/codemetropolis/integration/spigot/plugin/TeleportToBuildingPlugin/CrunchifyGetPropertyValues.java
new file mode 100644
index 00000000..cb2d43d1
--- /dev/null
+++ b/sources/integration/spigot-plugin/src/main/java/codemetropolis/integration/spigot/plugin/TeleportToBuildingPlugin/CrunchifyGetPropertyValues.java
@@ -0,0 +1,49 @@
+package codemetropolis.integration.spigot.plugin;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.Properties;
+
+
+/**
+ * @author Crunchify.com
+ * @source https://crunchify.com/java-properties-file-how-to-read-config-properties-values-in-java/
+ * This file gets the path of the XML file from config.properties
+ */
+public class CrunchifyGetPropertyValues {
+ String result = "";
+ InputStream inputStream;
+
+ public String getPropValues() throws IOException {
+
+ try {
+ Properties prop = new Properties();
+ String propFileName = "config.properties";
+
+ inputStream = getClass().getClassLoader().getResourceAsStream(propFileName);
+
+ if (inputStream != null) {
+ prop.load(inputStream);
+ } else {
+ throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath");
+ }
+
+ Date time = new Date(System.currentTimeMillis());
+
+ // get the property value and print it out
+ String url = prop.getProperty("url");
+
+
+ result = url;
+ System.out.println(result + " <=\n");
+ } catch (Exception e) {
+ System.out.println("Exception: " + e);
+ } finally {
+ inputStream.close();
+ }
+ return result;
+
+ }
+}
\ No newline at end of file
diff --git a/sources/integration/spigot-plugin/src/main/java/codemetropolis/integration/spigot/plugin/TeleportToBuildingPlugin/Teleport.java b/sources/integration/spigot-plugin/src/main/java/codemetropolis/integration/spigot/plugin/TeleportToBuildingPlugin/Teleport.java
new file mode 100644
index 00000000..31fb39be
--- /dev/null
+++ b/sources/integration/spigot-plugin/src/main/java/codemetropolis/integration/spigot/plugin/TeleportToBuildingPlugin/Teleport.java
@@ -0,0 +1,162 @@
+package codemetropolis.integration.spigot.plugin;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.Scanner;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import java.io.File;
+public class Teleport implements CommandExecutor {
+ //Class of teleport command
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ //Actions of the command
+
+ if(sender instanceof Player){
+ Player player = (Player) sender;
+ //Teleporting action can only happen to Players
+
+ if(args.length == 0){
+ player.sendMessage(ChatColor.RED + "Invalid Argument");
+ player.sendMessage(ChatColor.BLUE + "Usage: '/tptobuilding' + Name of preferred building");
+ //If the user does not provide arguments, alert messages appear in the chat
+
+ }else if(args.length >= 1){
+ try {
+ String conc = "";
+ for(int i = 0; i < args.length; i++) {
+ System.out.println(args[i]);
+ conc += (i != 0 ? " " + args[i] : args[i]);
+ }
+ fun(conc, player);
+ //Concatenating arguments given by user
+
+ }catch(Exception e) {
+ //Block of code to handle errors
+ }
+ }
+ }
+ return true;
+ }
+
+ public static void fun(String s, Player player) throws Exception {
+ //Method for getting coordinates from XML file (Coordinates needed to achieve teleport)
+
+ CrunchifyGetPropertyValues properties = new CrunchifyGetPropertyValues();
+ System.out.println(properties.getPropValues() + " ");
+ //Gets the path of the XML file which contains the coordinates
+
+ try {
+ Document document = getDocument(properties.getPropValues());
+ String xpathExpression = "/buildables/buildable[contains(@name, '" + s + "')]/position/@x";
+ //Using XPath expressions, a String variable is created containing the String given by the user command and the node names we are looking for inside the XML file (in this case the 'x' coordinate node)
+ String wxpathExpression = "/buildables/buildable/@id";
+ //Using XPath expressions, a String variable is created containing the node name we are looking for inside the XML file (in this case the 'id' node)
+
+ List evaluatedArray = new ArrayList();
+ //Array is created to store String of coordinates
+ List coordinateList = new ArrayList();
+ //Array is created to store final coordinates
+ evaluatedArray = evaluateXPath(document, wxpathExpression);
+ //Call of evaluateXPath method on the XML file
+ int found = 0;
+ //An int variable is created to indicate if the user's string was found in the XML
+ while (!evaluatedArray.isEmpty()) {
+
+ List temp = new ArrayList();
+ //A temporary array is created to store coordinates
+ temp = evaluateXPath(document, xpathExpression);
+ //Coordinates are loaded into the temporary array
+
+ if (!temp.isEmpty()) {
+ //Loops through the coordinates, cutting useless characters, leaving coordinate numbers and adding them to the final coordinateList
+ coordinateList.add(temp.get(0));
+ //Puts x coordinate number into final coordinate list
+ coordinateList.add(evaluateXPath(document, (xpathExpression.split("\\@x", 2)[0] + "@y")).get(0));
+ //Puts y coordinate number into final coordinate list, splitting off any unwanted characters
+ coordinateList.add(evaluateXPath(document, (xpathExpression.split("\\@x", 2)[0] + "@z")).get(0));
+ //Puts z coordinate number into final coordinate list, splitting off any unwanted characters
+ World world = player.getWorld();
+ //Gets which world the player is in currently (imporart for the location of the teleport)
+ Location loc = new Location(world, Double.parseDouble(temp.get(0))-3, Double.parseDouble(evaluateXPath(document, (xpathExpression.split("\\@x", 2)[0] + "@y")).get(0)), Double.parseDouble(evaluateXPath(document, (xpathExpression.split("\\@x", 2)[0] + "@z")).get(0))+4, -90, -30);
+ //A location variable is created, which gets the x,y,z coordinates.
+ player.teleport(loc);
+ //Teleport action to the preferred location is executed
+ found = 1;
+ //A correct building was found, the teleport was succesful, no further action needed
+ break;
+ }
+
+ xpathExpression = xpathExpression.split("\\[contains\\(\\@", 2)[0] + "/children/buildable[contains(@" + xpathExpression.split("\\[contains\\(\\@", 2)[1];
+ wxpathExpression = wxpathExpression.split("\\/\\@", 2)[0] + "/children/buildable/@" + wxpathExpression.split("\\/\\@", 2)[1];
+ evaluatedArray = evaluateXPath(document, wxpathExpression);
+ }
+ if (found == 0) {
+ player.sendMessage(ChatColor.RED + "Invalid Argument: Cannot find specific building");
+ //If a correct building name was NOT found in the XML, the teleport was NOT succesful, the user gets an alert chat message
+ }
+ }catch(Exception e){
+ player.sendMessage(ChatColor.DARK_PURPLE + (properties.getPropValues()));
+ player.sendMessage(ChatColor.RED + ("Path of the XML file is incorrect. Please check the 'config.properties' file"));
+ //If the path of the XML file was set up incorrectly in the config file, the user gets alerting chat messages
+ }
+ }
+
+ private static List evaluateXPath(Document document, String xpathExpression) throws Exception
+ {
+ // Create XPathFactory object
+ XPathFactory xpathFactory = XPathFactory.newInstance();
+
+ // Create XPath object
+ XPath xpath = xpathFactory.newXPath();
+
+ List values = new ArrayList<>();
+ try
+ {
+ // Create XPathExpression object
+ XPathExpression expr = xpath.compile(xpathExpression);
+
+ // Evaluate expression result on XML document
+ NodeList nodes = (NodeList) expr.evaluate(document, XPathConstants.NODESET);
+
+ for (int i = 0; i < nodes.getLength(); i++) {
+ values.add(nodes.item(i).getNodeValue());
+ }
+
+ } catch (XPathExpressionException e) {
+ e.printStackTrace();
+ }
+ return values;
+ }
+
+ private static Document getDocument(String fileName) throws Exception
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document doc = builder.parse(fileName);
+ return doc;
+ }
+}
diff --git a/sources/integration/spigot-plugin/src/main/resources/config.properties b/sources/integration/spigot-plugin/src/main/resources/config.properties
new file mode 100644
index 00000000..d441e13b
--- /dev/null
+++ b/sources/integration/spigot-plugin/src/main/resources/config.properties
@@ -0,0 +1 @@
+url=C:\\examplePath\\placingToRendering.xml
diff --git a/sources/integration/spigot-plugin/src/main/resources/plugin.yml b/sources/integration/spigot-plugin/src/main/resources/plugin.yml
index e50b50bf..0ca6b72f 100644
--- a/sources/integration/spigot-plugin/src/main/resources/plugin.yml
+++ b/sources/integration/spigot-plugin/src/main/resources/plugin.yml
@@ -3,3 +3,5 @@ main: codemetropolis.integration.spigot.plugin.Plugin
version: 0.1
api-version: 1.16
commands:
+ tpToBuilding:
+ description: Teleport Player To Specific Building