Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.Mouamle.Rutials;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.World.Environment;
- import org.bukkit.block.Block;
- import org.bukkit.entity.ArmorStand;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.util.EulerAngle;
- public class Altar implements Listener{
- EulerAngle CoreHand = EulerAngle.ZERO.add(300, 0, 0);
- @EventHandler
- public void onInteractEvent(PlayerInteractEvent event) {
- if (event.getAction() == org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK ) {
- if ( event.getClickedBlock().getType() == Material.ENDER_STONE ){
- if ( event.getItem().getType() == Material.NETHER_STAR){
- // Player and Core variables
- Player p = event.getPlayer();
- Block Core = event.getClickedBlock();
- // Core X, Y, Z
- int CoreX = Core.getX();
- int CoreY = Core.getY();
- int CoreZ = Core.getZ();
- // Core Location
- // Location CoreLocation = Core.getLocation();
- // Check the area for the altar and Summoning the altar
- if( Bukkit.getWorldType().equals(Environment.NETHER) ||
- p.getWorld().getBlockAt(CoreX + 3, CoreY, CoreZ).getType() != Material.AIR ||
- p.getWorld().getBlockAt(CoreX, CoreY, CoreZ + 3).getType() != Material.AIR ||
- p.getWorld().getBlockAt(CoreX - 3, CoreY, CoreZ).getType() != Material.AIR ||
- p.getWorld().getBlockAt(CoreX, CoreY, CoreZ - 3).getType() != Material.AIR ||
- p.getWorld().getBlockAt(CoreX, CoreY + 1, CoreZ).getType() != Material.AIR ||
- p.getWorld().getBlockAt(CoreX, CoreY - 1, CoreZ).getType() == Material.AIR
- ){p.sendMessage(ChatColor.RED + "Can't summon the altar here!");}else{
- p.getWorld().getBlockAt(CoreX, CoreY, CoreZ + 3).setType(Material.OBSIDIAN);
- p.getWorld().getBlockAt(CoreX, CoreY, CoreZ - 3).setType(Material.OBSIDIAN);
- p.getWorld().getBlockAt(CoreX + 3, CoreY, CoreZ).setType(Material.OBSIDIAN);
- p.getWorld().getBlockAt(CoreX - 3, CoreY, CoreZ).setType(Material.OBSIDIAN);
- p.getWorld().getBlockAt(CoreX, CoreY, CoreZ).setType(Material.AIR);
- p.sendMessage( ChatColor.GREEN + "Sucssufly summon the altar!");
- Location CoreL = Core.getLocation();
- ItemStack Sword = new ItemStack(Material.DIAMOND_SWORD);
- Location CorNewL = CoreL.add(0.75, 0, 0).subtract(0, 0.25, 0);
- ArmorStand CoreStand = p.getWorld().spawn(CorNewL, ArmorStand.class);
- CoreStand.setBasePlate(false);
- CoreStand.setGravity(false);
- CoreStand.setArms(true);
- CoreStand.setRightArmPose(CoreHand);
- CoreStand.setItemInHand(Sword);
- p.getWorld().getBlockAt(CoreX, CoreY, CoreZ).setType(Material.ENDER_STONE);
- }
- //set.getBlockAt(CoreX +3 , CoreY, CoreZ);
- }else if ( event.getItem().getType() == Material.NETHER_BRICK_ITEM ){
- Player p = event.getPlayer();
- Block Core = event.getClickedBlock();
- // Core X, Y, Z
- int CoreX = Core.getX();
- int CoreY = Core.getY();
- int CoreZ = Core.getZ();
- if (p.getWorld().getBlockAt(CoreX, CoreY, CoreZ + 3).getType() == Material.OBSIDIAN &&
- p.getWorld().getBlockAt(CoreX, CoreY, CoreZ - 3).getType() == Material.OBSIDIAN &&
- p.getWorld().getBlockAt(CoreX + 3, CoreY, CoreZ).getType() == Material.OBSIDIAN &&
- p.getWorld().getBlockAt(CoreX - 3, CoreY, CoreZ).getType() == Material.OBSIDIAN
- ){
- p.getWorld().getBlockAt(CoreX, CoreY, CoreZ).setType(Material.AIR);
- p.getWorld().getBlockAt(CoreX, CoreY, CoreZ + 3).setType(Material.AIR);
- p.getWorld().getBlockAt(CoreX, CoreY, CoreZ - 3).setType(Material.AIR);
- p.getWorld().getBlockAt(CoreX + 3, CoreY, CoreZ).setType(Material.AIR);
- p.getWorld().getBlockAt(CoreX - 3, CoreY, CoreZ).setType(Material.AIR);
- p.sendMessage(ChatColor.GREEN + "Sucssufly remove the altar");
- }else{
- p.sendMessage(ChatColor.RED + "I can't see any altar here!");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement