2 Half working plugins

Discussion in 'Plugin Development' started by BrushPainter, Oct 11, 2014.

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

    BrushPainter

    http://pastebin.com/zVcxXgBK - Dice (Not doing anything when I right click the air while holding the dice, but the command works)

    http://pastebin.com/sr10gJK3 - Villager Bar (Not cancelling the event (villager menu), and it opens the villager menu instead of performing the command "bar", but the spawning of the villager works)
     
  2. Offline

    CraftCreeper6

    BrushPainter
    As for your first class, you don't register events.
    And your second class, I am not too sure about you being able to cancel the event, instead, close all inventorys before the player types the "bar" command.
     
    mine-care likes this.
  3. Offline

    Unica

    BrushPainter

    Code:java
    1. public void onEnable(){
    2. Bukkit.getPluginManager().registerEvents(this, this);
    3. }
    4.  
    5. @EventHandler
    6. public void onInteractEntity(PlayerInteractEntityEvent e){
    7. if(e.getRightClicked() instanceof Villager){
    8. e.getPlayer.peformCommand("Command");
    9. e.setCancelled(true);
    10. }
    11.  
    12. @EventHandler
    13. public void onInteract(PlayerInteractEvent e){
    14. ItemStack hand = e.getPlayer().getItemInHand();
    15. if(hand != null && hand.getType() != Material.AIR){
    16. if(hand.getType().equals(Material.STONE_BUTTON) && hand.getAmount() == 2){
    17. System.out.println("Debug: Works ;)");
    18. }
    19. }
    20. }
    21. }
     
  4. Offline

    mine-care

    Any perticular reason why not checking before casting?
    in dice: Player player = (Player) cs;



    in vilager Bar:
    1. Player player = (Player) event.getDamager();
    2. LivingEntity entity = (LivingEntity) event.getEntity();
    3. Villager zinc = (Villager) entity;
    soo(...)oo many erros could be thrown here if: damager is not player, entity is not LivingEntity, if it is living entity, then it may not be vilager. Use if checks before Casting

    And a question of intrest in Dice:
    what is : player.getPlayer() and why not player.getinventory?

    And as CraftCreeper6 said the problem is non registered event


    PS CraftCreeper6 i LOVE your sig! nice!
     
  5. Offline

    CraftCreeper6

  6. Offline

    mine-care

    =)
     
Thread Status:
Not open for further replies.

Share This Page