• Our Minecraft servers are offline but we will keep this forum online for any community communication. Site permissions for posting could change at a later date but will remain online.

Calling all coders :D

Joined
Nov 25, 2014
Messages
635
Reaction score
466
So I started coding a class in a super plugin for Launchpads, and I just want it to be improved. What I'm looking for is for it to launch a person 10 blocks into the air and like, 20-30 blocks in the direction the person is facing.

I also want for a sound of my choice to be inputted! I just don't know where to put the code for the sound. I know the code for it, I just don't know where to put it.

Code:
package me.XDBFplaysGamesX.MCTGA.listener;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
public class mctgaLaunchPads implements Listener {
        private ArrayList<Player> jumpers = new ArrayList<Player>();
      
        @EventHandler
        public void onPlayerMove(PlayerMoveEvent e) {
                if (e.getTo().getBlock().getRelative(BlockFace.DOWN).getType() == Material.STONE_PLATE) {
                        e.getPlayer().setVelocity(e.getPlayer().getLocation().getDirection().multiply(8));
                        e.getPlayer().setVelocity(new Vector(e.getPlayer().getVelocity().getX(), 1.0D, e.getPlayer().getVelocity().getZ()));
                        jumpers.add(e.getPlayer());
                }
        }
      
        @EventHandler
        public void onPlayerDamage(EntityDamageEvent e) {
                if (e.getEntity() instanceof Player) {
                        Player p = (Player) e.getEntity();
                        if (e.getCause() == DamageCause.FALL && jumpers.contains(p)) {
                                e.setDamage(0.0);
                                jumpers.remove(p);
                        }
                }
        }
}
 

Ceroria

Mockingjay
Joined
Aug 20, 2012
Messages
11,024
Reaction score
13,943
Ooh, Tiger performs a coder


When you said "launchpads" I thought you meant the EDM launchpads haha
 

arsenal

District 13
Joined
Jun 11, 2013
Messages
2,806
Reaction score
3,231
I highly suggest you use the Bukkit forums for this issue. That is full of people who know there stuff, and you will get proper help much quicker than on here. In the mean time this thread will be moved to Anything Minecraft as it does not have anything to do with MCGamer.
 

YourAverageTiger

i control this entire operation
Joined
Apr 18, 2014
Messages
1,416
Reaction score
1,888
I highly suggest you use comments in your code. Not only does it provide information for us looking at it, but it allows us to say that this is well written code.

To insert a comment, on a separate line, use //[Comment comment comment...] or
/*
Comment
lol
*\

Put the code to play the sound under the EventHandler for the change in velocity.

Message me through the forums if you have any more questions. If you find a bug, make sure to include a stack trace and a copy of your code and plugin.yml.
 
Joined
Nov 25, 2014
Messages
635
Reaction score
466
I highly suggest you use comments in your code. Not only does it provide information for us looking at it, but it allows us to say that this is well written code.

To insert a comment, on a separate line, use //[Comment comment comment...] or
/*
Comment
lol
*\

Put the code to play the sound under the EventHandler for the change in velocity.

Message me through the forums if you have any more questions. If you find a bug, make sure to include a stack trace and a copy of your code and plugin.yml.
I put comments in my classes, but I don't necessarily put it when it comes to Listeners, but I always put it in my command packages and such!

And which EventHandler? Can you pin-point which one? ;D
 

YourAverageTiger

i control this entire operation
Joined
Apr 18, 2014
Messages
1,416
Reaction score
1,888
if (e.getTo().getBlock().getRelative(BlockFace.DOWN).getType() == Material.STONE_PLATE) { e.getPlayer().setVelocity(e.getPlayer().getLocation().getDirection().multiply(8)); e.getPlayer().setVelocity(new Vector(e.getPlayer().getVelocity().getX(), 1.0D, e.getPlayer().getVelocity().getZ())); jumpers.add(e.getPlayer());
Put it with these.
 

Members online

No members online now.

Forum statistics

Threads
242,193
Messages
2,449,610
Members
523,972
Latest member
Atasci