Help

Discussion in 'Plugin Development' started by Iervolino, May 24, 2013.

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

    Iervolino

  2. Offline

    caseif

    You don't seem to have registered your events in the onEnable(), or even have an onEnable() for that matter. Unless, of course, that's not the entire class, in which case the best advice I can give you is to debug.
     
  3. Offline

    Iervolino

    LOL, I registered this...
     
  4. Offline

    caseif

    Just making sure. It's actually quite a common mistake. Anyway, like I said, try debugging. Also, what exactly is your issue with this?
     
  5. Offline

    Iervolino

    Fixed..

    Code:
    public int cooldown2 = 30;
    public String PhantomCooldownMessage = ChatColor.RED + "Aguarde outros %s segundos para usar a habilidade novamente!";
    public int PhantomItemId = Material.FEATHER.getId();
    HashMap<String, Long> Phantom = new HashMap<String, Long>();
     
    @EventHandler
    public void onRightClick(PlayerInteractEvent event) {
    final Player player = event.getPlayer();
    if((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)){
    ItemStack item = event.getPlayer().getItemInHand();
    if (item.getTypeId() == PhantomItemId) {
    long lastUsed = 0;
    if (Phantom.containsKey(player.getName()))
        lastUsed = Phantom.get(player.getName());
    if (lastUsed + (1000 * cooldown2) > System.currentTimeMillis()) {
        event.getPlayer().sendMessage(
                String.format(PhantomCooldownMessage,
                        (-((System.currentTimeMillis() - (lastUsed + (1000 * cooldown2))) / 1000))));
    } else {   
        player.setAllowFlight(true);
        player.setFlying(true);
        player.sendMessage(ChatColor.GREEN + ChatColor.ITALIC.toString() + "Modo de voo ativado por 5 segundos!");
        player.playSound(player.getLocation(), Sound.NOTE_PIANO, 10, 0);
        Phantom.put(player.getName(), System.currentTimeMillis());
       
        getServer().getScheduler().scheduleSyncDelayedTask(this, new Thread(new Runnable()
        {
          public void run() {
            player.setAllowFlight(false);
            player.setFlying(false);
          }
        }), 100L);
    }
    }
    }
    }
     
  6. Offline

    ZeusAllMighty11

    The chances of you encountering the need to use the transient modifier are slim to none
     
  7. Offline

    Minnymin3

    The only case in coding bukkit plugins that ive had to use the transient modifier is when working with merchants.
     
Thread Status:
Not open for further replies.

Share This Page