Created
February 3, 2013 09:44
-
-
Save EduardoRFS/4701085 to your computer and use it in GitHub Desktop.
Smith.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.smith; | |
import org.bukkit.Material; | |
import org.bukkit.block.Chest; | |
import org.bukkit.command.Command; | |
import org.bukkit.command.CommandSender; | |
import org.bukkit.event.EventHandler; | |
import org.bukkit.event.Listener; | |
import org.bukkit.event.player.PlayerInteractEvent; | |
import org.bukkit.inventory.ItemStack; | |
import org.bukkit.plugin.java.JavaPlugin; | |
public class Smith extends JavaPlugin implements Listener{ | |
@Override | |
public void onEnable(){ | |
this.getServer().getPluginManager().registerEvents(this, this); | |
} | |
@Override | |
public void onDisable(){ | |
} | |
public boolean reparar=false; | |
@Override | |
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){ | |
if(cmd.getName().equalsIgnoreCase("reparar")){ | |
reparar=true; | |
return true; | |
} | |
return false; | |
} | |
@EventHandler | |
public void onChestInteract(PlayerInteractEvent pie){ | |
if(pie.getClickedBlock().getState() instanceof Chest){ | |
Chest chest=(Chest)pie.getClickedBlock().getState(); | |
if(chest.getBlockInventory().contains(278)){ | |
if(reparar){ | |
chest.getBlockInventory().remove(278); | |
chest.getBlockInventory().addItem(new ItemStack(Material.DIAMOND_PICKAXE)); | |
pie.getPlayer().sendMessage("ChestDIAMOND"); | |
} else { | |
pie.getPlayer().sendMessage("Reparar false"); | |
} | |
} | |
pie.getPlayer().sendMessage("Chest"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment