Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.elliot.chorusfood.listeners;
- import java.util.Random;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.Particle;
- import org.bukkit.Sound;
- import org.bukkit.World;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.event.player.PlayerItemConsumeEvent;
- import me.elliot.chorusfood.Main;
- public class eat implements Listener{
- @SuppressWarnings("unused")
- private static Main plugin;
- @SuppressWarnings("static-access")
- public eat (Main plugin){
- this.plugin = plugin;
- Bukkit.getPluginManager().registerEvents(this, plugin);
- }
- public void teleport(Player player) {
- Random rand = new Random();
- Location loc = player.getLocation();
- int X = 1;
- int Y = 1;
- int Z = 1;
- if (rand.nextInt(2)==1) {
- X = (int) (rand.nextInt(50));
- }
- else {
- X = (int) (-rand.nextInt(50));
- }
- if (rand.nextInt(2)==1) {
- Y = (int) (rand.nextInt(20));
- }
- else {
- Y = (int) (-rand.nextInt(10));
- }
- if (rand.nextInt(2)==1) {
- Z = (int) (rand.nextInt(50));
- }
- else {
- Z = (int) (-rand.nextInt(50));
- }
- World w = player.getWorld();
- w.spawnParticle(Particle.PORTAL,loc.getX(),loc.getY(),loc.getZ(),1000);
- player.teleport(new Location(player.getWorld(),loc.getX() + X,loc.getY() + Y,loc.getZ() + Z));
- w.playSound(player.getLocation(),Sound.ITEM_CHORUS_FRUIT_TELEPORT,1000000000000f,1f);
- w.spawnParticle(Particle.PORTAL,loc.getX(),loc.getY(),loc.getZ(),1000);
- }
- @EventHandler
- public void onConsume(PlayerItemConsumeEvent event) {
- Player player = event.getPlayer();
- teleport(player);
- }
- @EventHandler
- public void onInteract(PlayerInteractEvent event) {
- Player player = event.getPlayer();
- if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CAKE) {
- teleport(player);
- Bukkit.broadcastMessage("why");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement