Making A PlayEffect Private?

Discussion in 'Plugin Development' started by jb42300, Jul 4, 2014.

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

    jb42300

    Hi My Name is Josh,

    now i have 2 questions 1 is How Do I Make a Plyeffect Private? Like Only Hearing A Play Effect to Who ever activated it?
    My 2nd Queestion is Stoping A playeffect How would i do that Here is the codin im working With

    Code:java
    1. @EventHandler
    2. private void onInventoryClick(InventoryClickEvent e){
    3. final Player player = (Player) e.getWhoClicked();
    4. final Player player1 = (Player) e.getWhoClicked();
    5. if (!e.getInventory().getName().equalsIgnoreCase(inv.getName())) return;
    6. if (e.getCurrentItem().getItemMeta() == null) return;
    7. if (e.getCurrentItem().getItemMeta().getDisplayName().contains(ChatColor.GOLD + "13")) {
    8. e.setCancelled(true);
    9. e.getWhoClicked().getWorld().playEffect(player.getLocation(), Effect.RECORD_PLAY, Material.GOLD_RECORD);
    10. e.getWhoClicked().closeInventory();


    anyone?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  2. Offline

    Gamecube762

    1.) Play the effect to the player and not the world.
    2.) MC doesn't have a way to manage sounds, only to tell the client to start a sound.
     
  3. Offline

    jb42300

    Gamecube762 how do i get player cause it wont let me getplayer()
     
  4. Offline

    SuperOriginal

    First of all, why do you have player and player1? They are the same thing.


    To fix it just remove getWorld() from the line so it would look like
    Code:java
    1. e.getWhoClicked().playEffect(player.getLocation(), Effect.RECORD_PLAY, Material.GOLD_RECORD);


    Since e.getWhoClicked() returns a player.
     
  5. Offline

    jb42300

    SuperOriginal But the thing is if i do remove the getworld, playeffect is underlined in red :eek:
     
  6. Offline

    born2kill_

    You have to correct your parameters I think, I've never used Materials in effects
    First parameter would be the location, so p.getLocation(),
    second parameter would be the Effect, so Effect.RECORD_PLAY,
    and the last parameter would be the amount of the effect (I am unsure about this), but I always use 10.
    Also, the method playEffect for player is deprecated, so it will show a yellow line, you can add a @SuppressWarnings annotation to ignore it. This is deprecated because Bukkit will remove it soon, so you might need to change it in further updates.
     
  7. Offline

    jb42300

    born2kill_ well i need to play a sertain effect ;/ like a record
     
  8. Offline

    fireblast709

  9. Offline

    jb42300

    I Have
    Code:java
    1. e.getWhoClicked().playEffect(player.getLocation(), Effect.RECORD_PLAY, Material.GREEN_RECORD);

    And The .playEffect Is Underlined in red.
     
  10. Offline

    born2kill_

Thread Status:
Not open for further replies.

Share This Page