Advertisement
Guest User

but why though

a guest
Jul 6th, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.05 KB | None | 0 0
  1. package me.elliot.chorusfood.listeners;
  2.  
  3. import java.util.Random;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.Location;
  7. import org.bukkit.Material;
  8. import org.bukkit.Particle;
  9. import org.bukkit.Sound;
  10. import org.bukkit.World;
  11. import org.bukkit.entity.Player;
  12. import org.bukkit.event.EventHandler;
  13. import org.bukkit.event.Listener;
  14. import org.bukkit.event.block.Action;
  15. import org.bukkit.event.player.PlayerInteractEvent;
  16. import org.bukkit.event.player.PlayerItemConsumeEvent;
  17. import me.elliot.chorusfood.Main;
  18.  
  19. public class eat implements Listener{
  20.    
  21.     @SuppressWarnings("unused")
  22.     private static Main plugin;
  23.    
  24.     @SuppressWarnings("static-access")
  25.     public eat (Main plugin){
  26.         this.plugin = plugin;
  27.         Bukkit.getPluginManager().registerEvents(this, plugin);
  28.     }
  29.     public void teleport(Player player) {
  30.         Random rand = new Random();
  31.         Location loc = player.getLocation();
  32.         int X = 1;
  33.         int Y = 1;
  34.         int Z = 1;
  35.         if (rand.nextInt(2)==1) {
  36.             X = (int) (rand.nextInt(50));
  37.         }
  38.         else {
  39.             X = (int) (-rand.nextInt(50));
  40.         }
  41.         if  (rand.nextInt(2)==1) {
  42.             Y = (int) (rand.nextInt(20));
  43.         }
  44.         else {
  45.             Y = (int) (-rand.nextInt(10));
  46.         }
  47.         if (rand.nextInt(2)==1) {
  48.             Z = (int) (rand.nextInt(50));
  49.         }
  50.         else {
  51.             Z = (int) (-rand.nextInt(50));
  52.         }
  53.         World w = player.getWorld();
  54.         w.spawnParticle(Particle.PORTAL,loc.getX(),loc.getY(),loc.getZ(),1000);
  55.         player.teleport(new Location(player.getWorld(),loc.getX() + X,loc.getY() + Y,loc.getZ() + Z));
  56.         w.playSound(player.getLocation(),Sound.ITEM_CHORUS_FRUIT_TELEPORT,1000000000000f,1f);
  57.         w.spawnParticle(Particle.PORTAL,loc.getX(),loc.getY(),loc.getZ(),1000);    
  58.      } 
  59.     @EventHandler
  60.     public void onConsume(PlayerItemConsumeEvent event) {
  61.         Player player = event.getPlayer();
  62.         teleport(player);  
  63.     }
  64.     @EventHandler
  65.     public void onInteract(PlayerInteractEvent event) {
  66.     Player player = event.getPlayer();
  67.     if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CAKE) {
  68.         teleport(player);
  69.         Bukkit.broadcastMessage("why");
  70.         }
  71.     }
  72.  
  73.        
  74.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement