Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.zeeveener.Test;
- import java.util.ArrayList;
- import java.util.List;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.block.Block;
- import org.bukkit.enchantments.Enchantment;
- import org.bukkit.entity.Item;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.block.BlockDamageEvent;
- import org.bukkit.event.block.BlockPlaceEvent;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.meta.ItemMeta;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.util.Vector;
- public class Main extends JavaPlugin implements Listener {
- private List<Location> plate = new ArrayList<Location>();
- public void onEnable() {
- getServer().getPluginManager().registerEvents(this, this);
- }
- public void onDisable() {
- }
- @EventHandler
- public void onInteract(PlayerInteractEvent e) {
- Player p = e.getPlayer();
- if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
- Bukkit.broadcastMessage("1");
- if (p.getItemInHand().getType().equals(Material.STONE_PLATE)) {
- Bukkit.broadcastMessage("2");
- if (true) {
- Bukkit.broadcastMessage("3");
- if (e.getClickedBlock() != null
- && e.getClickedBlock().getType() != null) {
- Bukkit.broadcastMessage("4");
- Location l = e.getClickedBlock().getLocation();
- plate.add(l.add(0, 1, 0));
- l.add(0, 1, 0).getBlock().setType(Material.STONE_PLATE);
- if (p.getItemInHand().getAmount() == 1) {
- p.setItemInHand(null);
- } else {
- p.getItemInHand().setAmount(
- p.getItemInHand().getAmount() - 1);
- }
- }
- }
- }
- } else if (e.getAction().equals(Action.RIGHT_CLICK_AIR)) {
- if (p.getItemInHand().getType().equals(Material.FIREBALL)) {
- if (true) {
- e.setCancelled(true);
- final Item i = p
- .getLocation()
- .getWorld()
- .dropItemNaturally(p.getLocation(),
- new ItemStack(Material.FIREBALL));
- i.setVelocity(new Vector(p.getVelocity().getX(), p
- .getVelocity().getY() + 4, p.getVelocity().getZ()));
- i.setVelocity(p.getLocation().getDirection());
- i.setPickupDelay(100000);
- if (p.getItemInHand().getAmount() == 1) {
- p.setItemInHand(null);
- } else {
- p.getItemInHand().setAmount(
- p.getItemInHand().getAmount() - 1);
- }
- Bukkit.getScheduler().runTaskLater(this, new Runnable() {
- public void run() {
- i.getWorld().createExplosion(i.getLocation(), 2,
- false);
- i.remove();
- }
- }, 100L);
- }
- }
- } else if (e.getAction().equals(Action.PHYSICAL)) {
- if (e.getClickedBlock().getType().equals(Material.STONE_PLATE)) {
- if (plate.contains(e.getClickedBlock().getLocation())) {
- if (true) {
- e.getClickedBlock().setType(Material.AIR);
- plate.remove(e.getClickedBlock().getLocation());
- e.getClickedBlock()
- .getWorld()
- .createExplosion(
- e.getClickedBlock().getLocation(), 2,
- false);
- }
- }
- }
- }
- }
- @EventHandler
- public void onPlace(BlockPlaceEvent e)
- {
- Player p = e.getPlayer();
- Block b = e.getBlock();
- if(b.getType().equals(Material.STONE_PLATE))
- {
- if(true)
- {
- plate.add(b.getLocation());
- p.sendMessage("You create a land mine! Punch it to remove it!");
- }
- }
- }
- @EventHandler
- public void onDe(BlockDamageEvent e)
- {
- Player p = e.getPlayer();
- Block b = e.getBlock();
- if(b.getType().equals(Material.STONE_PLATE))
- {
- if(plate.contains(e.getBlock().getLocation()))
- {
- if(true)
- {
- e.getBlock().setType(Material.AIR);
- plate.remove(e.getBlock().getLocation());
- p.sendMessage("You removed a land mine!");
- p.getInventory().addItem(setNameAndLore(Material.STONE_PLATE, 1, "&bLand Mine", Enchantment.WATER_WORKER, 10));
- }
- }
- }
- }
- public ItemStack setNameAndLore(Material material, int amount, String name, Enchantment enchant, int enchantamount, String... lore)
- {
- ItemStack item = new ItemStack(material, amount);
- item.addUnsafeEnchantment(enchant, enchantamount);
- ItemMeta meta = item.getItemMeta();
- meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
- ArrayList<String> lorez = new ArrayList<String>();
- for(String mylores : lore)
- {
- lorez.add(ChatColor.translateAlternateColorCodes('&', mylores));
- }
- meta.setLore(lorez);
- item.setItemMeta(meta);
- return item;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement