Event Wont Register!

Discussion in 'Plugin Development' started by candyfloss20, Jun 1, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    candyfloss20

    So i've got this code by when i click the block nothing happens no even a error the console:

    Code:java
    1. package com.xcraft.CTF.Teams;
    2.  
    3. import com.xcraft.CTF.CTFCore;
    4. import org.bukkit.Bukkit;
    5. import org.bukkit.Material;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.event.EventHandler;
    8. import org.bukkit.event.Listener;
    9. import org.bukkit.event.block.Action;
    10. import org.bukkit.event.player.PlayerInteractEvent;
    11. import org.bukkit.inventory.ItemStack;
    12.  
    13. public class JoinTeam implements Listener {
    14.  
    15. @EventHandler
    16. public void onJoin(PlayerInteractEvent event) {
    17. Player player = event.getPlayer();
    18.  
    19. if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
    20. if (event.getClickedBlock() == new ItemStack(Material.REDSTONE_ORE)) {
    21. if (!(CTFCore.redteam.contains(player.getName()))) {
    22. CTFCore.redteam.add(player.getName());
    23. player.sendMessage(CTFCore.TEAM + "Joined Team: §Red");
    24. Bukkit.broadcastMessage(CTFCore.TAG + player.getName() + " §1Joined §rRed §1Team");
    25. } else {
    26. player.sendMessage(CTFCore.TEAM + "You are already on the red team!");
    27. }
    28. }
    29. }
    30. }
    31.  
    32. }
    33.  
     
  2. You're getting the itemstack (something you would see in an inventory) instead of the block. Get the block.
     
  3. Offline

    AmShaegar

    if (event.getClickedBlock().getType() == Material.REDSTONE_ORE) {
     
  4. Looks good ^-^
     
  5. Offline

    Konkz

    I noticed when you right click Redstone Ore (as a block) it will "light up" therefore it will be a different block, I had that problem few months ago.
     
    AoH_Ruthless and ZodiacTheories like this.
  6. Offline

    candyfloss20

    Thanks it worked!
    Konkz you are right if you click the block it will work but then play the effect having to wait for effect to stop for it to work again might just use red wool or clay
     
  7. Offline

    Konkz

    Just check if block is redstone_ore or redstone ore light (Need to get its dmg. value I think)
     
  8. don't you need this??
    Code:
    public void onEnable(){
    Bukkit.getPluginManager().registerEvents(this, this);
    }
     
    candyfloss20 likes this.
  9. Offline

    candyfloss20

    No :) i can do that
     
Thread Status:
Not open for further replies.

Share This Page