Created
June 10, 2015 22:00
-
-
Save deanveloper/950c6a5b8a4cc032972c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.mcpz.splatoon.weapons; | |
import net.mcpz.pzcore.api.inventory.InteractiveItem; | |
import net.mcpz.splatoon.Splatoon; | |
import net.mcpz.splatoon.utils.TeamColor; | |
import org.bukkit.Material; | |
import org.bukkit.entity.EnderPearl; | |
import org.bukkit.entity.Player; | |
import org.bukkit.entity.Projectile; | |
import org.bukkit.entity.Snowball; | |
import org.bukkit.event.block.BlockPlaceEvent; | |
import org.bukkit.event.player.PlayerDropItemEvent; | |
import org.bukkit.event.player.PlayerInteractEvent; | |
import org.bukkit.metadata.FixedMetadataValue; | |
/** | |
* @author Dean (SideBySide) | |
*/ | |
public class SplatterGun extends InteractiveItem { | |
private final TeamColor team; | |
public SplatterGun(TeamColor team) { | |
super(team == TeamColor.ORANGE ? Material.GOLD_BARDING : Material.DIAMOND_BARDING); | |
this.team = team; | |
} | |
@Override | |
public void onHotbarClick(PlayerInteractEvent e) { | |
Player p = e.getPlayer(); | |
Projectile proj; | |
if(team == TeamColor.ORANGE) { | |
proj = p.getWorld().spawn(p.getEyeLocation().add(p.getEyeLocation().getDirection()), Snowball.class); | |
proj.setVelocity(p.getLocation().getDirection()); | |
proj.setMetadata("shooter", new FixedMetadataValue(Splatoon.getInstance(), p.getName())); | |
} else if (team == TeamColor.BLUE) { | |
proj = p.getWorld().spawn(p.getEyeLocation().add(p.getEyeLocation().getDirection()), EnderPearl.class); | |
proj.setVelocity(p.getLocation().getDirection()); | |
proj.setMetadata("shooter", new FixedMetadataValue(Splatoon.getInstance(), p.getName())); | |
} | |
} | |
@Override | |
public void onDrop(PlayerDropItemEvent e) { | |
e.setCancelled(true); | |
} | |
@Override | |
public void onPlace(BlockPlaceEvent e) { | |
//not possible | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment