diff --git a/.classpath b/.classpath
new file mode 100755
index 0000000..16c89cc
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2f7896d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+target/
diff --git a/.project b/.project
new file mode 100755
index 0000000..61658e3
--- /dev/null
+++ b/.project
@@ -0,0 +1,23 @@
+
+
+ CustomCrafting
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.eclipse.m2e.core.maven2Nature
+
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100755
index 0000000..d59e09c
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs
new file mode 100755
index 0000000..14b697b
--- /dev/null
+++ b/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/pom.xml b/pom.xml
new file mode 100755
index 0000000..fa26d5c
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,55 @@
+
+ 4.0.0
+ org.forkzone.mc
+ CustomCrafting
+ jar
+ 0.0.2-ALPHA
+ CustomCrafting
+
+
+ ${basedir}/src/main/java
+
+
+ .
+ true
+ ${basedir}/src/main/resources/
+
+ plugin.yml
+
+
+
+ .
+ false
+ ${basedir}/src/main/resources/
+
+ plugin.yml
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.8
+ 1.8
+
+
+
+
+
+
+ spigot-repo
+ https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+
+
+
+
+ org.bukkit
+ bukkit
+ 1.12.2-R0.1-SNAPSHOT
+ jar
+ provided
+
+
+
\ No newline at end of file
diff --git a/src/main/java/org/forkzone/mc/customcrafting/CustomCrafting.java b/src/main/java/org/forkzone/mc/customcrafting/CustomCrafting.java
new file mode 100755
index 0000000..2cd0c01
--- /dev/null
+++ b/src/main/java/org/forkzone/mc/customcrafting/CustomCrafting.java
@@ -0,0 +1,223 @@
+package org.forkzone.mc.customcrafting;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.NamespacedKey;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.ShapedRecipe;
+import org.bukkit.inventory.ShapelessRecipe;
+import org.bukkit.plugin.java.JavaPlugin;
+
+public final class CustomCrafting extends JavaPlugin
+{
+ private static final String PREFIX = "[CustomCrafting] ";
+ //ArrayList recipeList = new ArrayList();
+
+ private String[][][] getShapeArray(String shape)
+ {
+ String[][][] shape_array = new String[3][3][2];
+ String[] buffer = shape.split(";");
+
+ for(int i = 0; i < buffer.length; ++i)
+ {
+ String[] buffer_ = buffer[i].split(",");
+ for(int j = 0; j < buffer_.length; ++j)
+ {
+ String[] buffer__ = buffer_[j].split(":");
+
+ shape_array[i][j][0] = buffer__[0].toUpperCase();
+ shape_array[i][j][1] = buffer__.length > 1 ? buffer__[1] : "0";
+ }
+ }
+
+ return shape_array;
+ }
+
+ private String[][] getShapeArraySL(String shape)
+ {
+ ArrayList shape_array = new ArrayList();
+
+ String[] buffer = shape.split(",");
+ for(String buffer_ : buffer)
+ {
+ shape_array.add(getItemArray(buffer_));
+ }
+
+ return shape_array.toArray(new String[shape_array.size()][3]);
+ }
+
+ private String[] getItemArray(String item)
+ {
+ String[] item_array = new String[3];
+ String[] buffer_item = item.split("#");
+
+ String[] buffer_item_ = buffer_item[0].split(":");
+ item_array[0] = buffer_item_[0].toUpperCase();
+ item_array[1] = buffer_item_.length > 1 ? buffer_item_[1] : "0";
+ item_array[2] = buffer_item.length > 1 ? buffer_item[1] : "1";
+
+ return item_array;
+ }
+
+ private int toInt(String string)
+ {
+ return Integer.parseInt(string);
+ }
+
+ private short toShort(String string)
+ {
+ return Short.parseShort(string);
+ }
+
+ @SuppressWarnings("deprecation")
+ private void addNewRecipe(NamespacedKey name, String shape, String item, boolean shapeless)
+ {
+ String[] item_array = getItemArray(item);
+ if(Material.getMaterial(item_array[0]) == null)
+ {
+ getLogger().warning("Could not add \"" + name.getKey() + "\"");
+ getLogger().warning("Unknown: " + item_array[0]);
+ return;
+ }
+ else if(shapeless)
+ {
+ String[][] shape_array = getShapeArraySL(shape);
+ ShapelessRecipe recipe = new ShapelessRecipe(name, new ItemStack(Material.getMaterial(item_array[0]), toInt(item_array[2]), toShort(item_array[1])));
+
+ for(String[] ingredient_array : shape_array)
+ {
+ recipe.addIngredient(toInt(ingredient_array[2]), Material.getMaterial(ingredient_array[0]), toInt(ingredient_array[1]));
+ }
+
+ if(!Bukkit.getServer().addRecipe(recipe))
+ getLogger().warning("Something went wrong!");
+ }
+ else
+ {
+ String[][][] shape_array = getShapeArray(shape);
+
+ ShapedRecipe recipe = new ShapedRecipe(name, new ItemStack(Material.getMaterial(item_array[0]), toInt(item_array[2]), toShort(item_array[1])));
+
+ Map map = new HashMap();
+
+ int counter = 0;
+
+ String[] recipe_shape = new String[3];
+
+ for(int i = 0; i < shape_array.length; ++i)
+ {
+ recipe_shape[i] = "";
+ for(int j = 0; j < shape_array[i].length; ++j)
+ {
+ if(!map.containsKey(shape_array[i][j][0] + ":" + shape_array[i][j][1]))
+ {
+ if(shape_array[i][j][0].equalsIgnoreCase(" ") || shape_array[i][j][0].equalsIgnoreCase("0") || shape_array[i][j][0].equalsIgnoreCase("air"))
+ map.put(shape_array[i][j][0] + ":" + shape_array[i][j][1], ' ');
+ else
+ {
+ map.put(shape_array[i][j][0] + ":" + shape_array[i][j][1], (char)('a' + counter));
+ ++counter;
+ }
+ }
+ recipe_shape[i] += map.get(shape_array[i][j][0] + ":" + shape_array[i][j][1]);
+ }
+ }
+
+ recipe.shape(recipe_shape);
+
+ for (Map.Entry entry : map.entrySet())
+ {
+ if(!entry.getValue().equals(' '))
+ {
+ String[] buffer = entry.getKey().split(":");
+ recipe.setIngredient(entry.getValue(), Material.getMaterial(buffer[0]), toInt(buffer[1]));
+ }
+ }
+
+ if(!Bukkit.getServer().addRecipe(recipe))
+ getLogger().warning("Something went wrong!");
+ }
+ getLogger().info("Add Recipe \"" + name.getKey() + "\"");
+ }
+
+ private void readConfigAndAddRecipe()
+ {
+ for(String key : getConfig().getConfigurationSection("recipes").getKeys(false))
+ {
+ NamespacedKey nkey = new NamespacedKey(this, key);
+ //recipeList.add(nkey);
+ addNewRecipe(nkey, getConfig().getString("recipes." + key + ".shape"), getConfig().getString("recipes." + key + ".item"), getConfig().getBoolean("recipes." + key + ".shapeless"));
+ }
+ }
+
+ private void removeRecipe()
+ {
+ /*
+ Iterator iter = Bukkit.getServer().recipeIterator();
+ while(iter.hasNext())
+ {
+ Recipe r = iter.next();
+ if(r != null && r instanceof ShapedRecipe)
+ {
+ if(recipeList.contains(((ShapedRecipe) r).getKey()))
+ iter.remove();
+ }
+ else if(r != null && r instanceof ShapelessRecipe)
+ {
+ if(recipeList.contains(((ShapelessRecipe) r).getKey()))
+ iter.remove();
+ }
+ }
+ recipeList.clear();
+ */
+ Bukkit.getServer().resetRecipes();
+ }
+
+ @Override
+ public void onEnable()
+ {
+ saveDefaultConfig();
+ reloadConfig();
+ readConfigAndAddRecipe();
+ }
+
+ @Override
+ public void onDisable()
+ {
+ removeRecipe();
+ }
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
+ {
+ if(cmd.getName().equalsIgnoreCase("customcrafting"))
+ {
+ if(args.length == 1 && args[0].equalsIgnoreCase("reload") && sender.hasPermission("customcrafting.reload"))
+ {
+ reloadConfig();
+ removeRecipe();
+ readConfigAndAddRecipe();
+ sender.sendMessage(PREFIX + "reloaded!");
+ }
+ else if(sender.hasPermission("customcrafting.infolite") || sender.hasPermission("customcrafting.info"))
+ {
+ sender.sendMessage(PREFIX + "Plugin Information");
+ sender.sendMessage(PREFIX + "Name: " + getDescription().getName());
+ sender.sendMessage(PREFIX + "Author: " + String.join(", ", getDescription().getAuthors()));
+ if(sender.hasPermission("customcrafting.info"))
+ {
+ sender.sendMessage(PREFIX + "Version: " + getDescription().getVersion());
+ sender.sendMessage(PREFIX + "Arguments: reload");
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
new file mode 100755
index 0000000..ab9372d
--- /dev/null
+++ b/src/main/resources/config.yml
@@ -0,0 +1,13 @@
+recipes:
+ dirtyDiamond:
+ shapeless: false
+ shape: "dirt,dirt,dirt;dirt,coal,dirt;dirt,dirt,dirt"
+ item: "diamond:0#1"
+ quarzblocktoitem:
+ shapeless: true
+ shape: "quartz_block:-1#1"
+ item: "quartz:0#4"
+ notchapple:
+ shapeless: false
+ shape: "gold_block,gold_block,gold_block;gold_block,apple,gold_block;gold_block,gold_block,gold_block"
+ item: "golden_apple:1"
\ No newline at end of file
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
new file mode 100755
index 0000000..8d8122b
--- /dev/null
+++ b/src/main/resources/plugin.yml
@@ -0,0 +1,27 @@
+name: CustomCrafting
+main: org.forkzone.mc.customcrafting.CustomCrafting
+version: "${project.version}"
+description: Add possibility to add custom crafting receipts to the game.
+author: basman93
+commands:
+ customcrafting:
+ description: Shows the plugin version or reloads it
+ usage: / [arguments]
+ permission: customcrafting.infolite
+ aliases: cc
+permissions:
+ customcrafting.*:
+ description: Gives access to all CustomCrafting commands
+ children:
+ customcrafting.info: true
+ customcrafting.infolite: true
+ customcrafting.reload: true
+ customcrafting.info:
+ description: Allows to see the full information of this plugin
+ children:
+ customcrafting.infolite: true
+ customcrafting.infolite:
+ description: Allows to see the reduced information of this plugin
+ default: true
+ customcrafting.reload:
+ description: Allows to reload the plugin
\ No newline at end of file