Add Crafting tweaks.

master
dragontamerfred 2019-10-02 16:48:21 +02:00
parent 4f68824718
commit 36ded4ce9f
5 changed files with 92 additions and 17 deletions

View File

@ -8,8 +8,15 @@ A list of all the tweaks current present in this project.
Allows players to use the command `/toggletrample` to toggle their ability to trample farmland.
This tweak also disables crop trampling for villagers and iron golems to help with decorative villages.
### Crafting tweaks
Adds some extra crafting recipes to the game.
Currently included:
- 8 wood logs -> 4 chests
- 2 paper + 1 iron ingot -> 1 name tag
- 1 wool (any color) -> 4 string
- 3 leather + 2 string + 2 iron ingot -> 1 saddle
## Planned tweaks
- Crafting tweaks
- Dynamite
- Seed drop planting
- Sign editing

View File

@ -0,0 +1,50 @@
package nl.kallestruik.vanillatweaks.CraftingTweaks;
import nl.kallestruik.vanillatweaks.config;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.RecipeChoice;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.plugin.java.JavaPlugin;
public class CraftingTweaks {
public static void init(JavaPlugin plugin) {
RecipeChoice woodLog = new RecipeChoice.MaterialChoice(Material.OAK_LOG, Material.BIRCH_LOG, Material.SPRUCE_LOG, Material.JUNGLE_LOG, Material.ACACIA_LOG, Material.DARK_OAK_LOG);
RecipeChoice allWool = new RecipeChoice.MaterialChoice(Material.WHITE_WOOL, Material.BLACK_WOOL, Material.BLUE_WOOL, Material.BROWN_WOOL, Material.CYAN_WOOL, Material.GRAY_WOOL, Material.GREEN_WOOL, Material.LIGHT_BLUE_WOOL, Material.LIGHT_GRAY_WOOL, Material.LIME_WOOL, Material.MAGENTA_WOOL, Material.ORANGE_WOOL, Material.PINK_WOOL, Material.PURPLE_WOOL, Material.RED_WOOL, Material.YELLOW_WOOL);
// Better chest recipe
NamespacedKey chestKey = new NamespacedKey(plugin, "chest");
ShapedRecipe chestRecipe = new ShapedRecipe(chestKey, new ItemStack(Material.CHEST, 4));
chestRecipe.shape("WWW", "W W", "WWW");
chestRecipe.setIngredient('W', woodLog);
// Name tag recipe
NamespacedKey nametagKey = new NamespacedKey(plugin, "nametag");
ShapedRecipe nametagRecipe = new ShapedRecipe(nametagKey, new ItemStack(Material.NAME_TAG));
nametagRecipe.shape(" I", " P ", "P ");
nametagRecipe.setIngredient('I', Material.IRON_INGOT);
nametagRecipe.setIngredient('P', Material.PAPER);
// Wool > String recipe
NamespacedKey stringKey = new NamespacedKey(plugin, "string");
ShapelessRecipe stringRecipe = new ShapelessRecipe(stringKey, new ItemStack(Material.STRING, 4));
stringRecipe.addIngredient(allWool);
// Saddle
NamespacedKey saddleKey = new NamespacedKey(plugin, "saddle");
ShapedRecipe saddleRecipe = new ShapedRecipe(saddleKey, new ItemStack(Material.SADDLE));
saddleRecipe.shape("LLL", "S S", "I I");
saddleRecipe.setIngredient('L', Material.LEATHER);
saddleRecipe.setIngredient('S', Material.STRING);
saddleRecipe.setIngredient('I', Material.IRON_INGOT);
// Add recipes
if (config.CRAFTING_TWEAKS_BETTER_CHEST) plugin.getServer().addRecipe(chestRecipe);
if (config.CRAFTING_TWEAKS_NAME_TAG) plugin.getServer().addRecipe(nametagRecipe);
if (config.CRAFTING_TWEAKS_WOOL_TO_STRING) plugin.getServer().addRecipe(stringRecipe);
if (config.CRAFTING_TWEAKS_SADDLE) plugin.getServer().addRecipe(saddleRecipe);
}
}

View File

@ -1,5 +1,6 @@
package nl.kallestruik.vanillatweaks;
import nl.kallestruik.vanillatweaks.CraftingTweaks.CraftingTweaks;
import nl.kallestruik.vanillatweaks.ToggleTrample.CommandToggletrample;
import nl.kallestruik.vanillatweaks.ToggleTrample.TrampleHandler;
import org.bukkit.configuration.InvalidConfigurationException;
@ -15,22 +16,15 @@ public final class VanillaTweaks extends JavaPlugin {
// Config loading
config.load(new File(this.getDataFolder(), c.CONFIG_FILE_NAME));
/**
* Toggle trample
*
* Enable/disable your ability to trample crops with a simple command. Also stops villagers and iron golems
* from trampling your crops.
*/
TrampleHandler.loadTrampleEnabled(new File(this.getDataFolder(), c.TRAMPLE_ENABLED_FILE_NAME));
getServer().getPluginCommand("toggletrample").setExecutor(new CommandToggletrample());
getServer().getPluginManager().registerEvents(new TrampleHandler(), this);
if (config.TOGGLE_TRAMPLE_ENABLED) {
TrampleHandler.loadTrampleEnabled(new File(this.getDataFolder(), c.TRAMPLE_ENABLED_FILE_NAME));
getServer().getPluginCommand("toggletrample").setExecutor(new CommandToggletrample());
getServer().getPluginManager().registerEvents(new TrampleHandler(), this);
}
/**
* Crafting
*
* Add some extra crafting recipes to the game. Examples: 8 logs -> 4 chests, 1 wool -> 4 string,
* 8 stairs instead of 6, 2 paper + 1 iron -> name tag.
*/
if (config.CRAFTING_TWEAKS_ENABLED) {
CraftingTweaks.init(this);
}
/**
* Dynamite

View File

@ -9,6 +9,11 @@ import java.io.IOException;
public class config {
public static boolean TOGGLE_TRAMPLE_ENABLED;
public static boolean CRAFTING_TWEAKS_ENABLED;
public static boolean CRAFTING_TWEAKS_BETTER_CHEST;
public static boolean CRAFTING_TWEAKS_NAME_TAG;
public static boolean CRAFTING_TWEAKS_WOOL_TO_STRING;
public static boolean CRAFTING_TWEAKS_SADDLE;
public static void load(File file) throws IOException, InvalidConfigurationException {
if (!file.getParentFile().exists())
@ -20,5 +25,16 @@ public class config {
TOGGLE_TRAMPLE_ENABLED = config.getBoolean("toggle-trample.enabled");
CRAFTING_TWEAKS_ENABLED = config.getBoolean("crafting-tweaks.enabled");
CRAFTING_TWEAKS_BETTER_CHEST = config.getBoolean("crafting-tweaks.better-chest");
CRAFTING_TWEAKS_NAME_TAG = config.getBoolean("crafting-tweaks.name-tag");
CRAFTING_TWEAKS_WOOL_TO_STRING = config.getBoolean("crafting-tweaks.wool-to-string");
CRAFTING_TWEAKS_SADDLE = config.getBoolean("crafting-tweaks.saddle");
}
}

View File

@ -1,2 +1,10 @@
toggle-trample:
enabled: true
enabled: true
crafting-tweaks:
enabled: true
better-chest: true
name-tag: true
wool-to-string: true
saddle: true