Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package nl.Matthijs.Mattie.Sacrifice;
- import java.util.logging.Logger;
- import org.bukkit.ChatColor;
- import org.bukkit.Material;
- import org.bukkit.Server;
- import org.bukkit.World;
- import org.bukkit.block.Block;
- import org.bukkit.block.BlockFace;
- import org.bukkit.block.Sign;
- import org.bukkit.entity.Player;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.event.player.PlayerListener;
- import org.bukkit.inventory.ItemStack;
- public class SacrificePlayerListener extends PlayerListener
- {
- private final Sacrifice plugin;
- private final Server server;
- final Logger logger = Logger.getLogger("Minecraft");
- private Material m = Material.IRON_BLOCK;
- public SacrificePlayerListener(Sacrifice instance)
- {
- this.plugin = instance;
- this.server = plugin.getServer();
- }
- public void onPlayerInteract(PlayerInteractEvent event)
- {
- if ((event.getAction() != Action.LEFT_CLICK_BLOCK) && (event.getAction() != Action.RIGHT_CLICK_BLOCK))
- {
- return;
- }
- Block b = event.getClickedBlock();
- if (b.getType() == Material.SIGN_POST)
- {
- Sign s = (Sign) b.getState();
- if (b.getType() == Material.SIGN_POST)
- {
- System.out.println("line0: " + s.getLine(0));
- System.out.println("line1: " + s.getLine(1));
- System.out.println("line2: " + s.getLine(2));
- System.out.println("line3: " + s.getLine(3));
- if (!s.getLine(1).equalsIgnoreCase("[offer]"))
- {
- return;
- }
- // else if (!s.getLine(2).equalsIgnoreCase("day") || !s.getLine(2).equalsIgnoreCase("night"))
- // {
- // return;
- // }
- else
- {
- b = event.getClickedBlock();
- World w = b.getWorld();
- long time = w.getTime();
- time -= time % 24000L;
- Player p = event.getPlayer();
- Block north = b.getRelative(BlockFace.NORTH);
- Block east = b.getRelative(BlockFace.EAST);
- Block south = b.getRelative(BlockFace.SOUTH);
- Block west = b.getRelative(BlockFace.WEST);
- Block down = b.getRelative(BlockFace.DOWN);
- Block up = b.getRelative(BlockFace.UP);
- if (north.getType() == m && east.getType() == m && south.getType() == m && west.getType() == m)
- {
- if (down.getType() == Material.GOLD_BLOCK)
- {
- ItemStack i = p.getItemInHand();
- int aantal = i.getAmount();
- if (aantal == 0)
- {
- p.setHealth(0);
- server.broadcastMessage(ChatColor.RED + "Player: " + p.getDisplayName() + ChatColor.RED + " probeerde zojuist NIETS te offeren -> STERRUF!");
- }
- else
- {
- Block boven = event.getClickedBlock().getRelative(BlockFace.UP);
- boven.setTypeId(0);
- up.setType(Material.AIR);
- up.setTypeId(0);
- p.sendMessage("OK GEFELICITEERD U BENT GEOFFERT!");
- server.broadcastMessage("Player: " + p.getDisplayName() + " heeft zojuist " + aantal + " " + i.getType() + " geofferd!");
- i.setAmount(0);
- p.setItemInHand(null);
- Block b5 = up;
- System.out.println("up: " + b5.getType());
- if (s.getLine(2).equalsIgnoreCase("night"))
- {
- w.setTime(time + 37700L);
- return;
- }
- else
- {
- w.setTime(time + 24000L);
- return;
- }
- }
- }
- }
- }
- }
- }
- System.out.println(event.getEventName() + "\n" + event.getAction());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment