Compare commits
2 Commits
0.0.2-ALPH
...
0.0.3-ALPH
| Author | SHA1 | Date | |
|---|---|---|---|
| 275be9812e | |||
| 87e0f5b6bb |
@@ -1 +1,3 @@
|
|||||||
Bukkit Plugin
|
Bukkit Plugin
|
||||||
|
|
||||||
|
Download the Plugin here: [CustomCrafting 0.0.2-ALPHA](https://gitlab.com/basman93/CustomCrafting/uploads/b711ed3061aaaadaffe9f9dd954f1237/CustomCrafting-0.0.2-ALPHA.jar)
|
||||||
108
pom.xml
108
pom.xml
@@ -1,55 +1,55 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.forkzone.mc</groupId>
|
<groupId>org.forkzone.mc</groupId>
|
||||||
<artifactId>CustomCrafting</artifactId>
|
<artifactId>CustomCrafting</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>0.0.2-ALPHA</version>
|
<version>0.0.3-ALPHA</version>
|
||||||
<name>CustomCrafting</name>
|
<name>CustomCrafting</name>
|
||||||
<url></url>
|
<url></url>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
|
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<targetPath>.</targetPath>
|
<targetPath>.</targetPath>
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
<directory>${basedir}/src/main/resources/</directory>
|
<directory>${basedir}/src/main/resources/</directory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>plugin.yml</include>
|
<include>plugin.yml</include>
|
||||||
</includes>
|
</includes>
|
||||||
</resource>
|
</resource>
|
||||||
<resource>
|
<resource>
|
||||||
<targetPath>.</targetPath>
|
<targetPath>.</targetPath>
|
||||||
<filtering>false</filtering>
|
<filtering>false</filtering>
|
||||||
<directory>${basedir}/src/main/resources/</directory>
|
<directory>${basedir}/src/main/resources/</directory>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>plugin.yml</exclude>
|
<exclude>plugin.yml</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.12.2-R0.1-SNAPSHOT</version><!--change this value depending on the version or use LATEST-->
|
<version>1.12.2-R0.1-SNAPSHOT</version><!--change this value depending on the version or use LATEST-->
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@@ -1,223 +1,301 @@
|
|||||||
package org.forkzone.mc.customcrafting;
|
package org.forkzone.mc.customcrafting;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.FurnaceRecipe;
|
||||||
import org.bukkit.inventory.ShapedRecipe;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.ShapelessRecipe;
|
import org.bukkit.inventory.ShapedRecipe;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.inventory.ShapelessRecipe;
|
||||||
|
import org.bukkit.material.MaterialData;
|
||||||
public final class CustomCrafting extends JavaPlugin
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
{
|
|
||||||
private static final String PREFIX = "[CustomCrafting] ";
|
|
||||||
//ArrayList<NamespacedKey> recipeList = new ArrayList<NamespacedKey>();
|
/**
|
||||||
|
* CustomCrafting Plugin for Bukkit by basma93
|
||||||
private String[][][] getShapeArray(String shape)
|
*
|
||||||
{
|
* <P>Allows to add custom crafting recipes for the workbench or furnace
|
||||||
String[][][] shape_array = new String[3][3][2];
|
*
|
||||||
String[] buffer = shape.split(";");
|
* @author basman93
|
||||||
|
* @version 0.0.3
|
||||||
for(int i = 0; i < buffer.length; ++i)
|
*
|
||||||
{
|
*/
|
||||||
String[] buffer_ = buffer[i].split(",");
|
public final class CustomCrafting extends JavaPlugin
|
||||||
for(int j = 0; j < buffer_.length; ++j)
|
{
|
||||||
{
|
/** Prefix {@value} for chat messages */
|
||||||
String[] buffer__ = buffer_[j].split(":");
|
private static final String PREFIX = "[CustomCrafting] ";
|
||||||
|
|
||||||
shape_array[i][j][0] = buffer__[0].toUpperCase();
|
/** Version number to check if the configfile is uptodate */
|
||||||
shape_array[i][j][1] = buffer__.length > 1 ? buffer__[1] : "0";
|
private static final int CONFIG_VERSION = 1;
|
||||||
}
|
|
||||||
}
|
/**
|
||||||
|
* @param shape (required) raw shape string
|
||||||
return shape_array;
|
* @return returns the raw shape as an array:<br>
|
||||||
}
|
* first level are the rows of the recipe,<br>
|
||||||
|
* second level are the collums of the recipe,<br>
|
||||||
private String[][] getShapeArraySL(String shape)
|
* third level are the item ID's and Data values.
|
||||||
{
|
*/
|
||||||
ArrayList<String[]> shape_array = new ArrayList<String[]>();
|
private String[][][] getShapeArray(String shape)
|
||||||
|
{
|
||||||
String[] buffer = shape.split(",");
|
String[][][] shape_array = new String[3][3][2];
|
||||||
for(String buffer_ : buffer)
|
String[] buffer = shape.split(";");
|
||||||
{
|
|
||||||
shape_array.add(getItemArray(buffer_));
|
for(int i = 0; i < buffer.length; ++i)
|
||||||
}
|
{
|
||||||
|
String[] buffer_ = buffer[i].split(",");
|
||||||
return shape_array.toArray(new String[shape_array.size()][3]);
|
for(int j = 0; j < buffer_.length; ++j)
|
||||||
}
|
{
|
||||||
|
String[] buffer__ = buffer_[j].split(":");
|
||||||
private String[] getItemArray(String item)
|
|
||||||
{
|
shape_array[i][j][0] = buffer__[0].toUpperCase();
|
||||||
String[] item_array = new String[3];
|
shape_array[i][j][1] = buffer__.length > 1 ? buffer__[1] : "0";
|
||||||
String[] buffer_item = item.split("#");
|
}
|
||||||
|
}
|
||||||
String[] buffer_item_ = buffer_item[0].split(":");
|
|
||||||
item_array[0] = buffer_item_[0].toUpperCase();
|
return shape_array;
|
||||||
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;
|
* @param shape (required) raw shape string
|
||||||
}
|
* @return returns the raw shape as an array:<br>
|
||||||
|
* first level are the different items,<br>
|
||||||
private int toInt(String string)
|
* second level are the different attribute of the item:<br>
|
||||||
{
|
* <ol>
|
||||||
return Integer.parseInt(string);
|
* <li>Item ID</li>
|
||||||
}
|
* <li>Item data value</li>
|
||||||
|
* <li>Item amount</li>
|
||||||
private short toShort(String string)
|
* </ol>
|
||||||
{
|
*/
|
||||||
return Short.parseShort(string);
|
private String[][] getShapeArraySL(String shape)
|
||||||
}
|
{
|
||||||
|
ArrayList<String[]> shape_array = new ArrayList<String[]>();
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private void addNewRecipe(NamespacedKey name, String shape, String item, boolean shapeless)
|
String[] buffer = shape.split(",");
|
||||||
{
|
for(String buffer_ : buffer)
|
||||||
String[] item_array = getItemArray(item);
|
{
|
||||||
if(Material.getMaterial(item_array[0]) == null)
|
shape_array.add(getItemArray(buffer_));
|
||||||
{
|
}
|
||||||
getLogger().warning("Could not add \"" + name.getKey() + "\"");
|
|
||||||
getLogger().warning("Unknown: " + item_array[0]);
|
return shape_array.toArray(new String[shape_array.size()][3]);
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
else if(shapeless)
|
/**
|
||||||
{
|
* @param item (required) raw item string
|
||||||
String[][] shape_array = getShapeArraySL(shape);
|
* @return returns the raw shape as an array:<br>
|
||||||
ShapelessRecipe recipe = new ShapelessRecipe(name, new ItemStack(Material.getMaterial(item_array[0]), toInt(item_array[2]), toShort(item_array[1])));
|
* <ol>
|
||||||
|
* <li>Item ID</li>
|
||||||
for(String[] ingredient_array : shape_array)
|
* <li>Item data value</li>
|
||||||
{
|
* <li>Item amount</li>
|
||||||
recipe.addIngredient(toInt(ingredient_array[2]), Material.getMaterial(ingredient_array[0]), toInt(ingredient_array[1]));
|
* </ol>
|
||||||
}
|
*/
|
||||||
|
private String[] getItemArray(String item)
|
||||||
if(!Bukkit.getServer().addRecipe(recipe))
|
{
|
||||||
getLogger().warning("Something went wrong!");
|
String[] item_array = new String[3];
|
||||||
}
|
String[] buffer_item = item.split("#");
|
||||||
else
|
|
||||||
{
|
String[] buffer_item_ = buffer_item[0].split(":");
|
||||||
String[][][] shape_array = getShapeArray(shape);
|
item_array[0] = buffer_item_[0].toUpperCase();
|
||||||
|
item_array[1] = buffer_item_.length > 1 ? buffer_item_[1] : "0";
|
||||||
ShapedRecipe recipe = new ShapedRecipe(name, new ItemStack(Material.getMaterial(item_array[0]), toInt(item_array[2]), toShort(item_array[1])));
|
item_array[2] = buffer_item.length > 1 ? buffer_item[1] : "1";
|
||||||
|
|
||||||
Map<String, Character> map = new HashMap<String, Character>();
|
return item_array;
|
||||||
|
}
|
||||||
int counter = 0;
|
|
||||||
|
/** parse a string to a int */
|
||||||
String[] recipe_shape = new String[3];
|
private int toInt(String string)
|
||||||
|
{
|
||||||
for(int i = 0; i < shape_array.length; ++i)
|
return Integer.parseInt(string);
|
||||||
{
|
}
|
||||||
recipe_shape[i] = "";
|
|
||||||
for(int j = 0; j < shape_array[i].length; ++j)
|
/** parse a string to a short */
|
||||||
{
|
private short toShort(String string)
|
||||||
if(!map.containsKey(shape_array[i][j][0] + ":" + shape_array[i][j][1]))
|
{
|
||||||
{
|
return Short.parseShort(string);
|
||||||
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
|
/**
|
||||||
{
|
* Adds a custom furnace recipe to bukkit
|
||||||
map.put(shape_array[i][j][0] + ":" + shape_array[i][j][1], (char)('a' + counter));
|
* @param name (required) the name of the recipe
|
||||||
++counter;
|
* @param shape (required) the raw shape of the input item
|
||||||
}
|
* @param item (required) the raw shape of the output item
|
||||||
}
|
* @param xp (required) the xp the player will get for this
|
||||||
recipe_shape[i] += map.get(shape_array[i][j][0] + ":" + shape_array[i][j][1]);
|
*/
|
||||||
}
|
@SuppressWarnings("deprecation")
|
||||||
}
|
private void addNewFurnaceRecipe(String name, String shape, String item, float xp)
|
||||||
|
{
|
||||||
recipe.shape(recipe_shape);
|
String[] item_array = getItemArray(item);
|
||||||
|
if(Material.getMaterial(item_array[0]) == null)
|
||||||
for (Map.Entry<String, Character> entry : map.entrySet())
|
{
|
||||||
{
|
getLogger().warning("Could not add \"" + name + "\"");
|
||||||
if(!entry.getValue().equals(' '))
|
getLogger().warning("Unknown: " + item_array[0]);
|
||||||
{
|
return;
|
||||||
String[] buffer = entry.getKey().split(":");
|
}
|
||||||
recipe.setIngredient(entry.getValue(), Material.getMaterial(buffer[0]), toInt(buffer[1]));
|
|
||||||
}
|
String[] shape_array = getItemArray(shape);
|
||||||
}
|
if(Material.getMaterial(shape_array[0]) == null)
|
||||||
|
{
|
||||||
if(!Bukkit.getServer().addRecipe(recipe))
|
getLogger().warning("Could not add \"" + name + "\"");
|
||||||
getLogger().warning("Something went wrong!");
|
getLogger().warning("Unknown: " + shape_array[0]);
|
||||||
}
|
return;
|
||||||
getLogger().info("Add Recipe \"" + name.getKey() + "\"");
|
}
|
||||||
}
|
|
||||||
|
FurnaceRecipe recipe = new FurnaceRecipe(new ItemStack(Material.getMaterial(item_array[0]), toInt(item_array[2]), toShort(item_array[1])), new MaterialData(Material.getMaterial(shape_array[0]), (byte) 0), xp);
|
||||||
private void readConfigAndAddRecipe()
|
if(!Bukkit.getServer().addRecipe(recipe))
|
||||||
{
|
getLogger().warning("Something went wrong! Cannot add \"" + name + "\"");
|
||||||
for(String key : getConfig().getConfigurationSection("recipes").getKeys(false))
|
else
|
||||||
{
|
getLogger().info("Add Furnace Recipe \"" + name + "\"");
|
||||||
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"));
|
/**
|
||||||
}
|
* Adds a custom crafting recipe to bukkit
|
||||||
}
|
* @param name (required) the name of the recipe
|
||||||
|
* @param shape (required) the raw shape of the input item
|
||||||
private void removeRecipe()
|
* @param item (required) the raw shape of the output item
|
||||||
{
|
* @param shapeless (required) if the recipe is shapeless
|
||||||
/*
|
*/
|
||||||
Iterator<Recipe> iter = Bukkit.getServer().recipeIterator();
|
@SuppressWarnings("deprecation")
|
||||||
while(iter.hasNext())
|
private void addNewRecipe(NamespacedKey name, String shape, String item, boolean shapeless)
|
||||||
{
|
{
|
||||||
Recipe r = iter.next();
|
String[] item_array = getItemArray(item);
|
||||||
if(r != null && r instanceof ShapedRecipe)
|
if(Material.getMaterial(item_array[0]) == null)
|
||||||
{
|
{
|
||||||
if(recipeList.contains(((ShapedRecipe) r).getKey()))
|
getLogger().warning("Could not add \"" + name.getKey() + "\"");
|
||||||
iter.remove();
|
getLogger().warning("Unknown: " + item_array[0]);
|
||||||
}
|
return;
|
||||||
else if(r != null && r instanceof ShapelessRecipe)
|
}
|
||||||
{
|
else if(shapeless)
|
||||||
if(recipeList.contains(((ShapelessRecipe) r).getKey()))
|
{
|
||||||
iter.remove();
|
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])));
|
||||||
}
|
|
||||||
recipeList.clear();
|
for(String[] ingredient_array : shape_array)
|
||||||
*/
|
{
|
||||||
Bukkit.getServer().resetRecipes();
|
recipe.addIngredient(toInt(ingredient_array[2]), Material.getMaterial(ingredient_array[0]), toInt(ingredient_array[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
if(!Bukkit.getServer().addRecipe(recipe))
|
||||||
public void onEnable()
|
getLogger().warning("Something went wrong! Cannot add \"" + name.getKey() + "\"");
|
||||||
{
|
else
|
||||||
saveDefaultConfig();
|
getLogger().info("Add Recipe \"" + name.getKey() + "\"");
|
||||||
reloadConfig();
|
}
|
||||||
readConfigAndAddRecipe();
|
else
|
||||||
}
|
{
|
||||||
|
String[][][] shape_array = getShapeArray(shape);
|
||||||
@Override
|
ShapedRecipe recipe = new ShapedRecipe(name, new ItemStack(Material.getMaterial(item_array[0]), toInt(item_array[2]), toShort(item_array[1])));
|
||||||
public void onDisable()
|
Map<String, Character> map = new HashMap<String, Character>();
|
||||||
{
|
int counter = 0;
|
||||||
removeRecipe();
|
String[] recipe_shape = new String[3];
|
||||||
}
|
for(int i = 0; i < shape_array.length; ++i)
|
||||||
|
{
|
||||||
@Override
|
recipe_shape[i] = "";
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
|
for(int j = 0; j < shape_array[i].length; ++j)
|
||||||
{
|
{
|
||||||
if(cmd.getName().equalsIgnoreCase("customcrafting"))
|
if(!map.containsKey(shape_array[i][j][0] + ":" + shape_array[i][j][1]))
|
||||||
{
|
{
|
||||||
if(args.length == 1 && args[0].equalsIgnoreCase("reload") && sender.hasPermission("customcrafting.reload"))
|
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], ' ');
|
||||||
reloadConfig();
|
else
|
||||||
removeRecipe();
|
{
|
||||||
readConfigAndAddRecipe();
|
map.put(shape_array[i][j][0] + ":" + shape_array[i][j][1], (char)('a' + counter));
|
||||||
sender.sendMessage(PREFIX + "reloaded!");
|
++counter;
|
||||||
}
|
}
|
||||||
else if(sender.hasPermission("customcrafting.infolite") || sender.hasPermission("customcrafting.info"))
|
}
|
||||||
{
|
recipe_shape[i] += map.get(shape_array[i][j][0] + ":" + shape_array[i][j][1]);
|
||||||
sender.sendMessage(PREFIX + "Plugin Information");
|
}
|
||||||
sender.sendMessage(PREFIX + "Name: " + getDescription().getName());
|
}
|
||||||
sender.sendMessage(PREFIX + "Author: " + String.join(", ", getDescription().getAuthors()));
|
recipe.shape(recipe_shape);
|
||||||
if(sender.hasPermission("customcrafting.info"))
|
for (Map.Entry<String, Character> entry : map.entrySet())
|
||||||
{
|
{
|
||||||
sender.sendMessage(PREFIX + "Version: " + getDescription().getVersion());
|
if(!entry.getValue().equals(' '))
|
||||||
sender.sendMessage(PREFIX + "Arguments: reload");
|
{
|
||||||
}
|
String[] buffer = entry.getKey().split(":");
|
||||||
}
|
recipe.setIngredient(entry.getValue(), Material.getMaterial(buffer[0]), toInt(buffer[1]));
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
return false;
|
if(!Bukkit.getServer().addRecipe(recipe))
|
||||||
}
|
getLogger().warning("Something went wrong! Cannot add \"" + name.getKey() + "\"");
|
||||||
}
|
else
|
||||||
|
getLogger().info("Add Recipe \"" + name.getKey() + "\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* reads the configfile and adds every recipe found in it.
|
||||||
|
*/
|
||||||
|
private void readConfigAndAddRecipe()
|
||||||
|
{
|
||||||
|
for(String key : getConfig().getConfigurationSection("recipes").getKeys(false))
|
||||||
|
{
|
||||||
|
NamespacedKey nkey = new NamespacedKey(this, key);
|
||||||
|
addNewRecipe(nkey, getConfig().getString("recipes." + key + ".shape"), getConfig().getString("recipes." + key + ".item"), getConfig().getBoolean("recipes." + key + ".shapeless"));
|
||||||
|
}
|
||||||
|
|
||||||
|
for(String key : getConfig().getConfigurationSection("furnace_recipes").getKeys(false))
|
||||||
|
{
|
||||||
|
addNewFurnaceRecipe(key, getConfig().getString("furnace_recipes." + key + ".shape"), getConfig().getString("furnace_recipes." + key + ".item"), (float) getConfig().getDouble("furnace_recipes." + key + ".xp"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* removes the custom recipes from bukkit.
|
||||||
|
* At this moment its only possible to reset the recipes list to default.
|
||||||
|
*/
|
||||||
|
private void removeRecipe()
|
||||||
|
{
|
||||||
|
Bukkit.getServer().resetRecipes();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable()
|
||||||
|
{
|
||||||
|
saveDefaultConfig();
|
||||||
|
reloadConfig();
|
||||||
|
|
||||||
|
// Checks if the configfile is the required version, give out a warning otherwise.
|
||||||
|
if(getConfig().getInt("version", 0) < CONFIG_VERSION)
|
||||||
|
getLogger().warning("Please delete your configfile. Your configfile is outdated!");
|
||||||
|
|
||||||
|
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"))
|
||||||
|
{
|
||||||
|
removeRecipe();
|
||||||
|
saveDefaultConfig();
|
||||||
|
reloadConfig();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,13 +1,25 @@
|
|||||||
recipes:
|
#Do not edit the version number!
|
||||||
dirtyDiamond:
|
#INFO: xp by furnace_recipes don't work at this moment
|
||||||
shapeless: false
|
version: 1
|
||||||
shape: "dirt,dirt,dirt;dirt,coal,dirt;dirt,dirt,dirt"
|
recipes:
|
||||||
item: "diamond:0#1"
|
dirtyDiamond:
|
||||||
quarzblocktoitem:
|
shapeless: false
|
||||||
shapeless: true
|
shape: "dirt,dirt,dirt;dirt,coal,dirt;dirt,dirt,dirt"
|
||||||
shape: "quartz_block:-1#1"
|
item: "diamond:0#1"
|
||||||
item: "quartz:0#4"
|
quarzblocktoitem:
|
||||||
notchapple:
|
shapeless: true
|
||||||
shapeless: false
|
shape: "quartz_block:-1#1"
|
||||||
shape: "gold_block,gold_block,gold_block;gold_block,apple,gold_block;gold_block,gold_block,gold_block"
|
item: "quartz:0#4"
|
||||||
item: "golden_apple:1"
|
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"
|
||||||
|
furnace_recipes:
|
||||||
|
diamond_recycle:
|
||||||
|
shape: "diamond_sword"
|
||||||
|
item: "diamond:0#1"
|
||||||
|
xp: 0
|
||||||
|
breadfromwheat:
|
||||||
|
shape: "HAY_BLOCK"
|
||||||
|
item: "BREAD:0#3"
|
||||||
|
xp: 0
|
||||||
@@ -1,27 +1,27 @@
|
|||||||
name: CustomCrafting
|
name: CustomCrafting
|
||||||
main: org.forkzone.mc.customcrafting.CustomCrafting
|
main: org.forkzone.mc.customcrafting.CustomCrafting
|
||||||
version: "${project.version}"
|
version: "${project.version}"
|
||||||
description: Add possibility to add custom crafting receipts to the game.
|
description: Add possibility to add custom crafting recipts to the game.
|
||||||
author: basman93
|
author: basman93
|
||||||
commands:
|
commands:
|
||||||
customcrafting:
|
customcrafting:
|
||||||
description: Shows the plugin version or reloads it
|
description: Shows the plugin version or reloads it
|
||||||
usage: /<command> [arguments]
|
usage: /<command> [arguments]
|
||||||
permission: customcrafting.infolite
|
permission: customcrafting.infolite
|
||||||
aliases: cc
|
aliases: cc
|
||||||
permissions:
|
permissions:
|
||||||
customcrafting.*:
|
customcrafting.*:
|
||||||
description: Gives access to all CustomCrafting commands
|
description: Gives access to all CustomCrafting commands
|
||||||
children:
|
children:
|
||||||
customcrafting.info: true
|
customcrafting.info: true
|
||||||
customcrafting.infolite: true
|
customcrafting.infolite: true
|
||||||
customcrafting.reload: true
|
customcrafting.reload: true
|
||||||
customcrafting.info:
|
customcrafting.info:
|
||||||
description: Allows to see the full information of this plugin
|
description: Allows to see the full information of this plugin
|
||||||
children:
|
children:
|
||||||
customcrafting.infolite: true
|
customcrafting.infolite: true
|
||||||
customcrafting.infolite:
|
customcrafting.infolite:
|
||||||
description: Allows to see the reduced information of this plugin
|
description: Allows to see the reduced information of this plugin
|
||||||
default: true
|
default: true
|
||||||
customcrafting.reload:
|
customcrafting.reload:
|
||||||
description: Allows to reload the plugin
|
description: Allows to reload the plugin
|
||||||
Reference in New Issue
Block a user