Library [1.8] ParticleEffect v1.7

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

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

    DarkBladee12

    Julian13loco Well, you can check if the HashMap contains the player name and send him this message instead of starting a new task!

    gal0511 What do you mean exactly? You don't add effects to players with this lib, you just specify which players see the effect!

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

    Julian13loco

    DarkBladee12 looks like this

    code:

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel,
    String[] args) {


    PluginManager pm = getServer().getPluginManager();
    pm.registerEvents(new listeners(), this);

    Map<String, Integer> slime = new HashMap<String, Integer>();
    if (cmd.getName().equalsIgnoreCase("Slime")) {
    final Player p = (Player) sender;
    if (p.hasPermission("dgm.slime")) {

    final int slimetask = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable()

    {

    @Override
    public void run() {
    ParticleEffect.SLIME.display(p.getLocation(), 0.5f, 0.5f, 0.5f, 1, 10);


    }

    }, 0, 1L);
    slime.put(p.getName(), slimetask);

    if(slime.containsKey(p.getName())) {
    p.sendMessage(ChatColor.RED + "Particle already running!");
    }
    }

    }
     
  3. Offline

    gal0511Dev

    Well thats what im doing with it xD
    http://prntscr.com/3nqqmv
     
  4. Offline

    DarkBladee12

    gal0511 I assume you're using a BukkitRunnable or a scheduler for this. Just store the task in a HashMap (key is the player name) and cancel it, or store the task id in the HashMap and cancel it by id!

    Julian13loco You'd have to put that if clause before you start the task and put a return under the message!

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

    frogman6102

    Code:java
    1. @EventHandler
    2. public void pShoot(PlayerInteractEvent event){
    3. Player p = event.getPlayer();
    4. if(event.getAction() == Action.RIGHT_CLICK_AIR){
    5. if(event.getPlayer().getItemInHand().getType().equals(Material.BLAZE_ROD)){
    6. if(event.getPlayer().getInventory().containsAtLeast(new ItemStack(Material.EGG), 1)){
    7. ParticleEffect.CLOUD.display(p.getLocation(), 0, 0, 0, 10, 10);
    8. event.getPlayer().launchProjectile(Egg.class);
    9. }else{
    10. event.getPlayer().sendMessage(ChatColor.BLUE + "You do not have any ammunition!");
    11. return;
    12. }
    13. }else{
    14. return;
    15. }
    16. }else{
    17. return;
    18. }


    DarkBladee12
    I tried to use your library and it won't work for me?
    The rest of the event works just not the effect? I get no errors in my code and none in my console?
     
  6. Offline

    DarkBladee12

    frogman6102 I think that the effect is very hard to notice at speed 10, try to decrease it or increase the amount so you'd be able to see the effect! ;)
     
  7. Offline

    Julian13loco

    DarkBladee12 i have another way to do what I want but I don't now what i need to do?

    this my code:

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel,
    String[] args) {


    PluginManager pm = getServer().getPluginManager();
    pm.registerEvents(new listeners(), this);

    Map<String, Integer> slime = new HashMap<String, Integer>();
    if(sender instanceof Player) {
    if (cmd.getName().equalsIgnoreCase("Slime")) {
    final Player p = (Player) sender;
    if (p.hasPermission("dgm.slime")) {

    Bukkit.getScheduler().cancelAllTasks();

    final int slimetask = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable()

    {

    @Override
    public void run() {
    ParticleEffect.SLIME.display(p.getLocation(), 0.5f, 0.5f, 0.5f, 1, 10);


    }

    }, 0, 1L);
    slime.put(p.getName(), slimetask);

    }
    }

    }

    I need to change the cancelalltasks for 1 player. So if i do the command he cancelled all te running tasks for ONE player not for the hole server.
     
  8. Offline

    frogman6102

    DarkBladee12
    Still doesn't work?
    Is there any plugins I have to install in my server for this to work?
     
  9. Offline

    Julian13loco

    frogman6102 you can set a repeating task on it and on a projectilehitevent the repeating task cancelled
     
  10. Offline

    DarkBladee12

    frogman6102 No you don't have to install any other plugins, try out another effect or increase the offset values! Because currently they're all set to 0 in your code, which causes the clouds to spawn inside the player's feet.
     
  11. Offline

    Julian13loco

    DarkBladee12 did you know how i can set that if i do /disable he cancelled all the running task of ONE player?
     
  12. Offline

    synquall

    Is there any way of showing the particles without the sound? Kinda annoying.
     
  13. Offline

    mine-care

    Wow! that is AWESOME! Please tell me that, I found a server where some random colored squares are falling under you, when you move, What effect is it or how do i change da color?
    ThankS!!
     
  14. Offline

    DarkBladee12

    mine-care this is most likely the block crack or block dust effect! The color is determined by the block id ;)

    synquall What are you talking about? This only displays effects and doesn't play sounds...

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

    ocomobock

    Some reason only a couple of these particles are working for me. FIREWORKS_SPARK and LARGE_EXPLODE. If I try the other ones they just don't appear
     
  16. Offline

    Julian13loco

    @DarkBladee12 Can you help me I have fixed that you can't do the command again I use a cancelalltasks for that but its for the hole server is there a way to set that for ONE player, so if i do /lava it cancel all task for ONE player

    code:java

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel,
    String[] args) {


    PluginManager pm = getServer().getPluginManager();
    pm.registerEvents(new listeners(), this);

    Map<String, Integer> slime = new HashMap<String, Integer>();
    if(sender instanceof Player) {
    if (cmd.getName().equalsIgnoreCase("Slime")) {
    final Player p = (Player) sender;
    if (p.hasPermission("dgm.slime")) {

    Bukkit.getScheduler().cancelAllTasks(); //this need change to ONE player!

    final int slimetask = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable()

    {

    @Override
    public void run() {
    ParticleEffect.SLIME.display(p.getLocation(), 0.5f, 0.5f, 0.5f, 1, 10);


    }

    }, 0, 1L);
    slime.put(p.getName(), slimetask);

    }
    }

    }
     
  17. Offline

    synquall

    Whoops, my bad! I previously used something like this, it had sounds and I thought it was the same one.

    Thanks.
     
  18. Offline

    DarkBladee12

    Julian13loco Why do you cancel all tasks then? You save the task of a player in the HashMap, so you just have to retrieve it from there and add an if-clause which checks if a task id is already stored for this player and cancel the task with this specific id then. Here's an example:

    Code:java
    1. private final Map<String, Integer> map = new HashMap<String, Integer>();
    2.  
    3. private void toggleParticles(final Player player, final ParticleEffect effect) {
    4. String name = player.getName();
    5. if(map.containsKey(name)) {
    6. Bukkit.getScheduler().cancelTask(map.get(name));
    7. map.remove(name);
    8. } else {
    9. int task = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    10. @Override
    11. public void run() {
    12. effect.display(player.getLocation(), 0.5F, 0.5F, 0.5F, 1, 10);
    13. }
    14. }, 0, 1);
    15. map.put(name, task);
    16. }
    17. }
     
  19. Offline

    Julian13loco

    DarkBladee12 that's not what I mean but I have found it i need to change bukkit.getSchudeler().cancalAllTasks to
    p.getServer().getScheduler().cancelAllTasks. Thanks for your help!
     
  20. Offline

    Jaaakee224

    I made this :D
     
    MrDplugins likes this.
  21. Offline

    DarkBladee12

  22. Offline

    Jaaakee224

    DarkBladee12 Is it possible to make the note particle different colors?
     
  23. Offline

    TheRoflcopter

    Hey, whenever i try to use the effect "FLAME", the particles go flying off everywhere, even after setting the off-sets. When i use other particles, like "SLIME", everything works just fine.
     
  24. Offline

    DarkBladee12

    TheRoflcopter try decreasing the speed!

    Jaaakee224 Just use a higher speed value than 0, for example 1 and every note should have a random color ;)

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

    Jaaakee224

    DarkBladee12 When I increased the speed it makes the smoke/flame/snowball particles shoot everywhere.
     
  26. Offline

    MrDplugins

    The speed only changes the color for the effects Note and RedDust the rest shoots everywhere due to the velocity they are flying/spawning at.
     
  27. Offline

    DarkBladee12

    Jaaakee224 Well increase the speed only for the NOTE particle effects! Btw you don't need it to set like 1, 2 or 10, because everything that is not 0 like 0.01 will work too!
     
  28. Offline

    Jaaakee224

    MrDplugins DarkBladee12 Yes I know that, but look at my code and you will understand. The last line of code displays the effect that the player selected. I used this so I don't need to have that line of code for every effect I have.
    Code:java
    1. @EventHandler
    2. public void onMove(PlayerMoveEvent event) {
    3. if ((!this.disabling) &&
    4. (event.getFrom() != event.getTo()) &&
    5. (this.effects.containsKey(event.getPlayer().getName()))) {
    6. Location l = event.getPlayer().getLocation();
    7. Location spawnLoc = new Location(l.getWorld(), l.getX(), l.getY() + 2.5D, l.getZ());
    8. ((ParticleEffect)this.effects.get(event.getPlayer().getName())).display(spawnLoc, 0.3F, 0.3F, 0.3F, 1.0F, this.amount);
     
  29. Offline

    DarkBladee12

    Jaaakee224 Just change it up to something like this:

    Code:java
    1. @EventHandler
    2. public void onMove(PlayerMoveEvent event) {
    3. if ((!this.disabling) && (event.getFrom() != event.getTo()) && (this.effects.containsKey(event.getPlayer().getName()))) {
    4. Location l = event.getPlayer().getLocation();
    5. Location spawnLoc = new Location(l.getWorld(), l.getX(), l.getY() + 2.5D, l.getZ());
    6. ParticleEffect effect = (ParticleEffect) this.effects.get(event.getPlayer().getName());
    7. float speed = effect == ParticleEffect.NOTE ? 0.1F : 1.0F;
    8. effect.display(spawnLoc, 0.3F, 0.3F, 0.3F, speed, this.amount);
    9. }
    10. }
     
  30. Offline

    coco5843

Thread Status:
Not open for further replies.

Share This Page