Library [1.8] ParticleEffect v1.7

Discussion in 'Resources' started by DarkBladee12, Jun 20, 2013.

Thread Status:
Not open for further replies.
  1. How would i remove a particle effect?
     
  2. Offline

    DarkBladee12

    someguyonthestreet A particle effect is only temporary so it will disappear after a certain time!
     
  3. DarkBladee12
    Well this is my code and i want to remove the particle using a command but i dont know how.

    Code:
    Code:java
    1. if (args[0].equalsIgnoreCase("water")) {
    2. Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    3. public void run() {
    4. for (Player player : Bukkit.getServer().getOnlinePlayers()) {
    5. ParticleEffect.DRIP_WATER.display(player.getLocation().add(0, 2, 0), 15, 0, 0, 0, 10, 10);
    6. }
    7. }
    8. }, 0, 20);
    9. }
     
  4. Offline

    DarkBladee12

    someguyonthestreet Well just put the id of the task (Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(...) returns the id as an Integer)
    along with the name of the player that issued the command in a HashMap and use Bukkit.getServer().getScheduler().cancelTask(ID) to cancel the task and remove the player's name from the HashMap again!
     
  5. DarkBladee12
    Not working...
    Code:java
    1. if (args[0].equalsIgnoreCase("happy")) {
    2.  
    3. Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    4. public void run() {
    5.  
    6. for (Player player : Bukkit.getServer().getOnlinePlayers()) {
    7.  
    8. ParticleEffect.HEART.display(player.getLocation().add(0, 2, 0), 15, 0, 0, 0, 10, 10);
    9. }
    10. }
    11. }, 0, 20);
    12.  
    13. if (!happy.contains(player.getName())) {
    14. Bukkit.getServer().getScheduler().cancelAllTasks();
    15. }
    16. }
     
  6. Offline

    LCastr0

    He didn't mean that
    In your first scheduler, do something like
    Code:java
    1. int s = -1;
    2. s = Bukkit.getServer().getScheduler().schedule[...]

    Then, when the player runs the command, you stop the runnable
    Code:java
    1. Bukkit.getServer().getScheduler().cancelTask(s);

    (s being the int that you changed up there)
     
    DarkBladee12 likes this.
  7. Offline

    DarkBladee12

    The new version of ParticleEffect is now finished, the gists on GitHub have been updated. You dont need different ParticleEffect classes for older versions of Bukkit now! The structure of it has changed a bit and the documentation has been improved. (ReflectionUtils is now documented too) I've also made a small plugin which allows you to display all kinds of particle effects ingame with commands. (However it is currently awaiting approval on DBO)
     
  8. Offline

    oasis9

    DarkBladee12 I am, but it isn't working. I don't get any errors, but I can't see any particles. I've created a particle halo plugin for 1.7 using the snippet for 1.7, but the 1.6- doesn't work. I'll try again to make sure, but it simply isn't working.
     
  9. Offline

    DarkBladee12

    oasis9 try out the new version of the ParticleEffect and the ReflectionUtils class!
     
  10. Offline

    videogame_mom

    Hey guys, I just started to use this library and I was wondering how I could have only the player who executed the command get the effect. Because when I run a command with ParticleEffect, every online is getting the effect.

    I need help, the code is fine, just need to know how to do it. '

    Thanks
    This is an example of one of the effects:

    Code:
            String PE = args[0];
            if(PE.equalsIgnoreCase("Hearts")){
            Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
                    public void run(){
                        for(Player player : Bukkit.getOnlinePlayers()){
                            ParticleEffect.HEART.display(0, 0, 0, 10, 10, player.getLocation().add(0, 2, 0), 15);
           
                        }
                    }
                }, 0, 5);
            }
     
  11. Offline

    DarkBladee12

    videogame_mom you're currently using the method with the range parameter (last parameter of the method) which sends the particle effects to all players in the specified range. If you want to send the particle effect to specific players you need to replace the range with a List<Player> which contains the players that should receive the particle effect.
     
  12. Offline

    oasis9

    DarkBladee12 Waahooo! It works! Thanks for doing this, could never have done it on my own! :D
     
  13. Code:
    @EventHandler
    public void onInventoryClick(InventoryClickEvent e) {
    if (!e.getInventory().getName().equalsIgnoreCase(inv.getName())) return;
    if (e.getCurrentItem().getItemMeta() == null) return;
    if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Hogwarts")) {
    e.getWhoClicked().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.FIREWORK_BLAST, 1, 1); // Sound effect where the player apparates away
    e.setCancelled(true);
    e.getWhoClicked().closeInventory();
    World w = e.getWhoClicked().getWorld();
    float ya = 180;
    float pi = 0;
    Player player = (Player) e.getWhoClicked();
    Location loc = new Location(w, 233.5, 48, 359, ya, pi);
    System.out.println(loc.getYaw() + " " + loc.getPitch());
    e.getWhoClicked().teleport(new Location(w, 233.5, 48, 359, ya, pi));
    ParticleEffect.ANGRY_VILLAGER.display(0, 0, 0, 1, 10, player.getLocation().add(0, 2, 0), 16) ;
    e.getWhoClicked().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.FIREWORK_BLAST, 1, 1); // Sound effect where the player apparates to
    player.sendMessage(ChatColor.GREEN + "You apparated to" + ChatColor.GOLD + " Hogwarts" + ChatColor.GREEN + "!");
    }
    
    Does this mean
    That when a player teleports, the effect will appear at that spot, and only at that spot, but everybody will be able to see it?

    Code:
     ParticleEffect.EXPLODE.display(0, 0, 0, 1, 25, player.getLocation().add(0, 1, 0), 2); 
    Instead of keeping them where I spawned them, the particles fly about 5-10 blocks into each side on a ridiculous speed. What am I doing wrong?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Oct 29, 2015
  14. Offline

    DarkBladee12

    DeCraftingKingHRPG try using a lower speed value like 0.1!

    DeCraftingKingHRPG yes it will appear at the spot where the player teleported to and is shown to all players in a radius of 16 blocks!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Oct 29, 2015
    DeCraftingKingHRPG likes this.
  15. Offline

    ChipDev

    400 posts <3
     
  16. Thank you!
     
  17. Offline

    Jaaakee224

    DarkBladee12
    I have a plugin that displays the Angry Effects higher than they should, where would I look?
     
  18. Offline

    DarkBladee12

    Jaaakee224 decrease the offsetY value or set it to 0.
     
  19. Offline

    Jaaakee224

    DarkBladee12 Check the code I PM'd you. What would I do?
     
  20. Offline

    au2001

    DarkBladee12 Is there a way to change the particle color, I really need that :p
    e.g. blue or red FIREWORKS_SPARK
     
  21. Offline

    DarkBladee12

    au2001 that's not possible with the API atm :/
     
  22. DarkBladee12 I saw custom colored swirly effects on a couple servers how is that done?
     
  23. Offline

    au2001

    DarkBladee12 :( Please add that
    Btw, I love your API :D it saved my life ;)

    CatzFuriousSpeed If you're talking about bubble, that's easy but else, I don't have any idea how to make this, I hope DarkBladee12 knows how and will implement it :D
     
  24. Offline

    DarkBladee12

    CatzFuriousSpeed if they had all the same color it was probably done with the playEffect(...) method.
     
  25. Offline

    RingOfStorms

    DarkBladee12 likes this.
  26. Offline

    DarkBladee12

    RingOfStorms thanks for notifying me about this possibility, i'll add methods for it to the library soon! ;)
     
    RingOfStorms likes this.
  27. Offline

    StaticJava

    This library doesn't seem to work for me. No errors, but particles just don't display...Is it updated?
     
  28. Offline

    Jaaakee224

  29. Offline

    StaticJava

    I fixed this by enabling Particles in my video options... :p
     
  30. Offline

    Jaaakee224

    StaticJava
    Haha, can you share some of your code? I want to see what is wrong with my code. I might be displaying it wrong with the new version. I'm not sure if it's the server, client, or the plugin.
     
Thread Status:
Not open for further replies.

Share This Page