Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.jobisingh;
- import java.util.HashMap;
- import java.util.HashSet;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.block.Block;
- 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.BlockPlaceEvent;
- import org.bukkit.event.player.PlayerInteractEvent;
- public class ListenerClass implements Listener {
- MainClass configgetter;
- public ListenerClass(MainClass plugin) {
- plugin.getServer().getPluginManager().registerEvents(this, plugin);
- configgetter = plugin;
- }
- // @EventHandler
- // public void onEvent(BlockPlaceEvent e) {
- //
- // Player player = e.getPlayer();
- //
- // e.setCancelled(true);
- //
- // }
- @EventHandler //you NEED to have @EventHandler before any event
- public void playerInteract(PlayerInteractEvent e){
- //this will be called automatically by bukkit whenever a player interacts
- Player player = e.getPlayer();
- Material block = player.getTargetBlock((HashSet<Byte>)null, 100).getType();
- if(block.equals(Material.WALL_SIGN) || block.equals(Material.SIGN) || block.equals(Material.SIGN_POST)) {
- if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
- //the player right-clicked a block
- Material m = e.getClickedBlock().getType(); //get the block type clicked
- if(m.equals(Material.WALL_SIGN) || m.equals(Material.SIGN) || m.equals(Material.SIGN_POST)){
- e.getPlayer().sendMessage("You Right Clicked A Sign!");
- Location location = e.getPlayer().getLocation();
- e.getPlayer().teleport((Location) configgetter.getConfig().get("LobbySpawn:"));
- //the block clicked was stone.
- }
- else {
- e.getPlayer().sendMessage("Error This is not suppose to execute");
- }
- }
- }
- }
- static HashMap<String, Integer> pointGetter = new HashMap<>();
- static HashMap<String, Location> locationGetter = new HashMap<>();
- static HashMap<String, Integer> pointGetter2 = new HashMap<>();
- static HashMap<String, Location> locationGetter2 = new HashMap<>();
- @EventHandler
- public void onWandLeftClick(PlayerInteractEvent e) {
- Player player = e.getPlayer();
- if(player.getInventory().getItemInHand().getItemMeta().getDisplayName().equals(ChatColor.GREEN + "§lPositionWand")) {
- Material block = player.getTargetBlock((HashSet<Byte>)null, 100).getType();
- if(e.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
- player.sendMessage("§1Server> §eSuccefully Set Point One!");
- int point1X = e.getClickedBlock().getLocation().getBlockX();
- int point1Y = e.getClickedBlock().getLocation().getBlockY();
- int point1Z = e.getClickedBlock().getLocation().getBlockZ();
- Location point1 = e.getClickedBlock().getLocation();
- pointGetter.put("point1X", point1X);
- pointGetter.put("point1Y", point1Y);
- pointGetter.put("point1Z", point1Z);
- locationGetter.put("point1", point1);
- }
- }
- }
- @EventHandler
- public void onWandRightClick(PlayerInteractEvent e) {
- Player player = e.getPlayer();
- if(player.getInventory().getItemInHand().getItemMeta().getDisplayName().equals(ChatColor.GREEN + "§lPositionWand")) {
- Material block = player.getTargetBlock((HashSet<Byte>)null, 100).getType();
- if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
- player.sendMessage("§1Server> §eSuccefully Set Point Two!");
- int point2X = e.getClickedBlock().getLocation().getBlockX();
- int point2Y = e.getClickedBlock().getLocation().getBlockY();
- int point2Z = e.getClickedBlock().getLocation().getBlockZ();
- Location point2 = e.getClickedBlock().getLocation();
- pointGetter2.put("point2X", point2X);
- pointGetter2.put("point2Y", point2Y);
- pointGetter2.put("point2Z", point2Z);
- locationGetter2.put("point2", point2);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement