diff --git a/Server/src/org/crandor/game/content/skill/free/crafting/limestone/ChiselLimestonePulse.java b/Server/src/org/crandor/game/content/skill/free/crafting/limestone/ChiselLimestonePulse.java new file mode 100644 index 000000000..6160320b4 --- /dev/null +++ b/Server/src/org/crandor/game/content/skill/free/crafting/limestone/ChiselLimestonePulse.java @@ -0,0 +1,70 @@ +package org.crandor.game.content.skill.free.crafting.limestone; + +import org.crandor.game.content.skill.SkillPulse; +import org.crandor.game.content.skill.Skills; +import org.crandor.game.node.entity.player.Player; +import org.crandor.game.node.item.Item; +import org.crandor.game.world.update.flag.context.Animation; + +/** + * + * The skill pulse for chiseling a limestone into a limestone brick. + * + * @author Jamix77 + * + */ +public class ChiselLimestonePulse extends SkillPulse { + + /** + * Represents the chisel item. + */ + private static final Item CHISEL = new Item(1755); + + /** + * Represents the ticks passed. + */ + private int ticks; + + public ChiselLimestonePulse(Player player, Item node) { + super(player, node); + this.resetAnimation= false; + } + + @Override + public boolean checkRequirements() { + if (!player.getInventory().containsItem(CHISEL)) { + return false; + } + if (!player.getInventory().containsItem(new Item(3211))) { + return false; + } + if (player.getSkills().getLevel(Skills.CRAFTING) < 12) { + player.getPacketDispatch().sendMessage("You need a crafting level of 12 to make limestone bricks."); + return false; + } + return true; + } + + @Override + public void animate() { + if (ticks % 5 == 0 || ticks < 1) { + player.getAudioManager().send(2586); + player.animate(Animation.create(4470)); + } + } + + @Override + public boolean reward() { + if (++ticks % 2 != 0) { + return false; + } + if (player.getInventory().remove(new Item(3211))) { + + player.getInventory().add(new Item(3420)); + + player.getSkills().addExperience(Skills.CRAFTING, 6, true); + } + return !player.getInventory().containsItem(new Item(3211)); + } + +} diff --git a/Server/src/plugin/skill/crafting/ChiselLimestonePlugin.java b/Server/src/plugin/skill/crafting/ChiselLimestonePlugin.java new file mode 100644 index 000000000..35bf7b9f4 --- /dev/null +++ b/Server/src/plugin/skill/crafting/ChiselLimestonePlugin.java @@ -0,0 +1,38 @@ +package plugin.skill.crafting; + +import org.crandor.game.content.skill.free.crafting.limestone.ChiselLimestonePulse; +import org.crandor.game.interaction.NodeUsageEvent; +import org.crandor.game.interaction.UseWithHandler; +import org.crandor.game.node.entity.player.Player; +import org.crandor.game.node.item.Item; +import org.crandor.plugin.InitializablePlugin; +import org.crandor.plugin.Plugin; + +/** + * The plugin that starts the chisel limestone cutting pulse. + * @author Jamix77 + */ +@InitializablePlugin +public final class ChiselLimestonePlugin extends UseWithHandler { + + /** + * Constructs a new {@code GemCutPlugin} {@Code Object} + */ + public ChiselLimestonePlugin() { + super(3211); + } + + @Override + public Plugin newInstance(Object arg) throws Throwable { + addHandler(1755, ITEM_TYPE, this); + return null; + } + + @Override + public boolean handle(NodeUsageEvent event) { + final Player player = event.getPlayer(); + player.getPulseManager().run(new ChiselLimestonePulse(player, new Item(3211))); + return true; + } + +}