2014-12-04 14:05:27 +01:00
|
|
|
package mineplex.game.clans;
|
|
|
|
|
|
|
|
import org.bukkit.Material;
|
2015-08-27 22:57:57 +02:00
|
|
|
import org.bukkit.entity.Player;
|
2014-12-04 14:05:27 +01:00
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventPriority;
|
|
|
|
import org.bukkit.event.inventory.PrepareItemCraftEvent;
|
|
|
|
import org.bukkit.inventory.CraftingInventory;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
import org.bukkit.inventory.ShapedRecipe;
|
2016-01-14 10:46:12 +01:00
|
|
|
import org.bukkit.material.SmoothBrick;
|
2014-12-04 14:05:27 +01:00
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
2016-01-14 10:46:12 +01:00
|
|
|
import mineplex.core.MiniPlugin;
|
|
|
|
import mineplex.core.common.util.C;
|
|
|
|
import mineplex.core.common.util.F;
|
|
|
|
import mineplex.core.common.util.UtilGear;
|
|
|
|
import mineplex.core.common.util.UtilServer;
|
|
|
|
import mineplex.core.itemstack.ItemStackFactory;
|
|
|
|
|
2014-12-04 14:05:27 +01:00
|
|
|
public class Recipes extends MiniPlugin
|
|
|
|
{
|
2015-08-27 22:57:57 +02:00
|
|
|
public Recipes(JavaPlugin plugin)
|
2014-12-04 14:05:27 +01:00
|
|
|
{
|
|
|
|
super("Recipes", plugin);
|
2015-08-26 23:56:28 +02:00
|
|
|
|
2015-08-27 22:57:57 +02:00
|
|
|
ItemStack boosterAxe = ItemStackFactory.Instance.CreateStack(Material.GOLD_AXE, (byte) 0, 1, "Booster Axe", false);
|
2015-08-26 23:56:28 +02:00
|
|
|
ShapedRecipe goldAxe = new ShapedRecipe(boosterAxe);
|
2014-12-04 14:05:27 +01:00
|
|
|
goldAxe.shape("#MM","#SM","#S#");
|
|
|
|
goldAxe.setIngredient('M', Material.GOLD_BLOCK);
|
|
|
|
goldAxe.setIngredient('S', Material.STICK);
|
|
|
|
UtilServer.getServer().addRecipe(goldAxe);
|
|
|
|
|
2015-08-27 22:57:57 +02:00
|
|
|
ItemStack powerAxe = ItemStackFactory.Instance.CreateStack(Material.DIAMOND_AXE, (byte) 0, 1, "Power Axe", false);
|
2015-08-26 23:56:28 +02:00
|
|
|
ShapedRecipe diamondAxe = new ShapedRecipe(powerAxe);
|
2014-12-04 14:05:27 +01:00
|
|
|
diamondAxe.shape("#MM","#SM","#S#");
|
|
|
|
diamondAxe.setIngredient('M', Material.DIAMOND_BLOCK);
|
|
|
|
diamondAxe.setIngredient('S', Material.STICK);
|
|
|
|
UtilServer.getServer().addRecipe(diamondAxe);
|
2016-01-14 10:46:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
ShapedRecipe bricks = new ShapedRecipe(new ItemStack(Material.SMOOTH_BRICK, 1));
|
|
|
|
bricks.shape("XX", "XX");
|
|
|
|
bricks.setIngredient('X', new SmoothBrick(Material.COBBLESTONE));
|
|
|
|
UtilServer.getServer().addRecipe(bricks);
|
|
|
|
|
|
|
|
|
2015-08-27 22:57:57 +02:00
|
|
|
ItemStack boosterSword = ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte) 0, 1, "Booster Sword", false);
|
2015-08-26 23:56:28 +02:00
|
|
|
ShapedRecipe goldSword = new ShapedRecipe(boosterSword);
|
2014-12-04 14:05:27 +01:00
|
|
|
goldSword.shape("M","M","S");
|
|
|
|
goldSword.setIngredient('M', Material.GOLD_BLOCK);
|
|
|
|
goldSword.setIngredient('S', Material.STICK);
|
|
|
|
UtilServer.getServer().addRecipe(goldSword);
|
|
|
|
|
2015-08-27 22:57:57 +02:00
|
|
|
ItemStack powerSword = ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, (byte) 0, 1, "Power Sword", false);
|
2015-08-26 23:56:28 +02:00
|
|
|
ShapedRecipe diamondSword = new ShapedRecipe(powerSword);
|
2014-12-04 14:05:27 +01:00
|
|
|
diamondSword.shape("M","M","S");
|
|
|
|
diamondSword.setIngredient('M', Material.DIAMOND_BLOCK);
|
|
|
|
diamondSword.setIngredient('S', Material.STICK);
|
|
|
|
UtilServer.getServer().addRecipe(diamondSword);
|
|
|
|
|
|
|
|
//Iron Door
|
|
|
|
ShapedRecipe ironDoor = new ShapedRecipe(new ItemStack(Material.IRON_DOOR, 1));
|
|
|
|
ironDoor.shape("I","I");
|
|
|
|
ironDoor.setIngredient('I', Material.IRON_INGOT);
|
|
|
|
UtilServer.getServer().addRecipe(ironDoor);
|
|
|
|
|
|
|
|
//Chain Helm
|
|
|
|
ShapedRecipe chainHelm = new ShapedRecipe(new ItemStack(Material.CHAINMAIL_HELMET, 1));
|
|
|
|
|
|
|
|
chainHelm.shape("SIS","I#I");
|
|
|
|
|
|
|
|
chainHelm.setIngredient('I', Material.IRON_INGOT);
|
|
|
|
chainHelm.setIngredient('S', Material.GOLD_INGOT);
|
|
|
|
|
|
|
|
UtilServer.getServer().addRecipe(chainHelm);
|
|
|
|
|
|
|
|
//Chain Chest
|
|
|
|
ShapedRecipe chainChest = new ShapedRecipe(new ItemStack(Material.CHAINMAIL_CHESTPLATE, 1));
|
|
|
|
|
|
|
|
chainChest.shape("I#I","SIS","ISI");
|
|
|
|
|
|
|
|
chainChest.setIngredient('I', Material.IRON_INGOT);
|
|
|
|
chainChest.setIngredient('S', Material.GOLD_INGOT);
|
|
|
|
|
|
|
|
UtilServer.getServer().addRecipe(chainChest);
|
|
|
|
|
|
|
|
//Chain Legs
|
|
|
|
ShapedRecipe chainLegs = new ShapedRecipe(new ItemStack(Material.CHAINMAIL_LEGGINGS, 1));
|
|
|
|
|
|
|
|
chainLegs.shape("ISI","S#S","I#I");
|
|
|
|
|
|
|
|
chainLegs.setIngredient('I', Material.IRON_INGOT);
|
|
|
|
chainLegs.setIngredient('S', Material.GOLD_INGOT);
|
|
|
|
|
|
|
|
UtilServer.getServer().addRecipe(chainLegs);
|
|
|
|
|
|
|
|
//Chain Boots
|
|
|
|
ShapedRecipe chainBoots = new ShapedRecipe(new ItemStack(Material.CHAINMAIL_BOOTS, 1));
|
|
|
|
|
|
|
|
chainBoots.shape("S#S","I#I");
|
|
|
|
|
|
|
|
chainBoots.setIngredient('I', Material.IRON_INGOT);
|
|
|
|
chainBoots.setIngredient('S', Material.GOLD_INGOT);
|
|
|
|
|
|
|
|
UtilServer.getServer().addRecipe(chainBoots);
|
|
|
|
|
|
|
|
//Chain Helm
|
|
|
|
ShapedRecipe chainHelm2 = new ShapedRecipe(new ItemStack(Material.CHAINMAIL_HELMET, 1));
|
|
|
|
|
|
|
|
chainHelm2.shape("SIS","I#I");
|
|
|
|
|
|
|
|
chainHelm2.setIngredient('I', Material.GOLD_INGOT);
|
|
|
|
chainHelm2.setIngredient('S', Material.IRON_INGOT);
|
|
|
|
|
|
|
|
UtilServer.getServer().addRecipe(chainHelm2);
|
|
|
|
|
|
|
|
//Chain Chest
|
|
|
|
ShapedRecipe chainChest2 = new ShapedRecipe(new ItemStack(Material.CHAINMAIL_CHESTPLATE, 1));
|
|
|
|
|
|
|
|
chainChest2.shape("I#I","SIS","ISI");
|
|
|
|
|
|
|
|
chainChest2.setIngredient('I', Material.GOLD_INGOT);
|
|
|
|
chainChest2.setIngredient('S', Material.IRON_INGOT);
|
|
|
|
|
|
|
|
UtilServer.getServer().addRecipe(chainChest2);
|
|
|
|
|
|
|
|
//Chain Legs
|
|
|
|
ShapedRecipe chainLegs2 = new ShapedRecipe(new ItemStack(Material.CHAINMAIL_LEGGINGS, 1));
|
|
|
|
|
|
|
|
chainLegs2.shape("ISI","S#S","I#I");
|
|
|
|
|
|
|
|
chainLegs2.setIngredient('I', Material.GOLD_INGOT);
|
|
|
|
chainLegs2.setIngredient('S', Material.IRON_INGOT);
|
|
|
|
|
|
|
|
UtilServer.getServer().addRecipe(chainLegs2);
|
|
|
|
|
|
|
|
//Chain Boots
|
|
|
|
ShapedRecipe chainBoots2 = new ShapedRecipe(new ItemStack(Material.CHAINMAIL_BOOTS, 1));
|
|
|
|
|
|
|
|
chainBoots2.shape("S#S","I#I");
|
|
|
|
|
|
|
|
chainBoots2.setIngredient('I', Material.GOLD_INGOT);
|
|
|
|
chainBoots2.setIngredient('S', Material.IRON_INGOT);
|
|
|
|
|
|
|
|
UtilServer.getServer().addRecipe(chainBoots2);
|
2016-03-10 03:47:48 +01:00
|
|
|
|
|
|
|
ShapedRecipe stonebrick = new ShapedRecipe(new ItemStack(Material.SMOOTH_BRICK, 1));
|
|
|
|
stonebrick.shape("SS#", "SS#");
|
|
|
|
stonebrick.setIngredient('S', Material.STONE);
|
|
|
|
UtilServer.getServer().addRecipe(stonebrick);
|
|
|
|
|
|
|
|
stonebrick = new ShapedRecipe(new ItemStack(Material.SMOOTH_BRICK, 1));
|
|
|
|
stonebrick.shape("#SS", "#SS");
|
|
|
|
stonebrick.setIngredient('S', Material.STONE);
|
|
|
|
UtilServer.getServer().addRecipe(stonebrick);
|
|
|
|
|
|
|
|
stonebrick = new ShapedRecipe(new ItemStack(Material.SMOOTH_BRICK, 1));
|
|
|
|
stonebrick.shape("###", "SS#", "SS#");
|
|
|
|
stonebrick.setIngredient('S', Material.STONE);
|
|
|
|
UtilServer.getServer().addRecipe(stonebrick);
|
|
|
|
|
|
|
|
stonebrick = new ShapedRecipe(new ItemStack(Material.SMOOTH_BRICK, 1));
|
|
|
|
stonebrick.shape("###", "#SS", "#SS");
|
|
|
|
stonebrick.setIngredient('S', Material.STONE);
|
|
|
|
UtilServer.getServer().addRecipe(stonebrick);
|
|
|
|
|
|
|
|
|
2014-12-04 14:05:27 +01:00
|
|
|
}
|
2015-08-27 22:57:57 +02:00
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
|
|
public void addLore(PrepareItemCraftEvent event)
|
|
|
|
{
|
|
|
|
if (event.getView().getPlayer() instanceof Player)
|
|
|
|
{
|
|
|
|
Player player = ((Player) event.getView().getPlayer());
|
|
|
|
CraftingInventory inv = (CraftingInventory)event.getInventory();
|
|
|
|
|
|
|
|
ItemStack itemStack = inv.getResult();
|
|
|
|
|
|
|
|
if (UtilGear.isWeapon(itemStack))
|
|
|
|
{
|
|
|
|
ItemStackFactory.Instance.addOwnerLore(itemStack, player.getName() + " Crafting");
|
|
|
|
inv.setResult(itemStack);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-12-04 14:05:27 +01:00
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.HIGH)
|
|
|
|
public void ReplaceDoor(PrepareItemCraftEvent event)
|
|
|
|
{
|
|
|
|
if (event.getRecipe().getResult() == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Material type = event.getRecipe().getResult().getType();
|
|
|
|
|
|
|
|
if (type != Material.WOOD_DOOR && type != Material.WOODEN_DOOR)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!(event.getInventory() instanceof CraftingInventory))
|
|
|
|
return;
|
|
|
|
|
|
|
|
CraftingInventory inv = (CraftingInventory)event.getInventory();
|
|
|
|
|
|
|
|
//Feedback
|
|
|
|
ItemStack result = ItemStackFactory.Instance.CreateStack(Material.IRON_DOOR);
|
|
|
|
inv.setResult(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.HIGH)
|
|
|
|
public void DenySword(PrepareItemCraftEvent event)
|
|
|
|
{
|
|
|
|
if (event.getRecipe().getResult() == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Material type = event.getRecipe().getResult().getType();
|
|
|
|
|
|
|
|
if (type != Material.DIAMOND_SWORD && type != Material.GOLD_SWORD &&
|
|
|
|
type != Material.DIAMOND_AXE && type != Material.GOLD_AXE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!(event.getInventory() instanceof CraftingInventory))
|
|
|
|
return;
|
|
|
|
|
|
|
|
CraftingInventory inv = (CraftingInventory)event.getInventory();
|
|
|
|
|
|
|
|
for (ItemStack cur : inv.getMatrix())
|
|
|
|
if (cur != null)
|
|
|
|
if (cur.getType() == Material.GOLD_BLOCK || cur.getType() == Material.DIAMOND_BLOCK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
String name = ItemStackFactory.Instance.GetName(event.getRecipe().getResult(), true);
|
|
|
|
String matName = "Gold";
|
|
|
|
if (type == Material.DIAMOND_AXE || type == Material.DIAMOND_SWORD)
|
|
|
|
matName = "Diamond";
|
|
|
|
|
|
|
|
//Feedback
|
|
|
|
ItemStack result = ItemStackFactory.Instance.CreateStack(36, (byte)0, 1, "§r" + C.cGray + "Recipe changed for " + F.item(name) + ".",
|
|
|
|
new String[] {C.cGray + "Use " + F.item(matName + " Blocks") + " instead of " + F.item(matName + " Ingots") + "."});
|
|
|
|
|
|
|
|
inv.setResult(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.HIGH)
|
|
|
|
public void DenyGeneral(PrepareItemCraftEvent event)
|
|
|
|
{
|
|
|
|
if (event.getRecipe().getResult() == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Material type = event.getRecipe().getResult().getType();
|
|
|
|
|
|
|
|
if (
|
|
|
|
type != Material.GOLDEN_APPLE &&
|
|
|
|
type != Material.GOLDEN_CARROT &&
|
|
|
|
type != Material.ENDER_CHEST &&
|
|
|
|
type != Material.ENCHANTMENT_TABLE &&
|
|
|
|
type != Material.BREWING_STAND &&
|
|
|
|
type != Material.TNT)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!(event.getInventory() instanceof CraftingInventory))
|
|
|
|
return;
|
|
|
|
|
|
|
|
CraftingInventory inv = (CraftingInventory)event.getInventory();
|
|
|
|
|
|
|
|
String name = ItemStackFactory.Instance.GetName(event.getRecipe().getResult(), true);
|
|
|
|
|
|
|
|
//Feedback
|
|
|
|
ItemStack result = ItemStackFactory.Instance.CreateStack(36, (byte)0, 1,
|
|
|
|
"§r" + C.cGray + "Crafting of " + F.item(name) + " is disabled.", new String[] {});
|
|
|
|
|
|
|
|
inv.setResult(result);
|
|
|
|
}
|
|
|
|
}
|