Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.snipars;
- import java.util.Random;
- import org.bukkit.Location;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.scheduler.BukkitRunnable;
- import org.bukkit.util.Vector;
- public class EventHandle extends JavaPlugin {
- public static EventHandle getInstance(){
- return instance;
- }
- private final int delay = 20;
- private final int period = 5;
- private static EventHandle instance;
- @Override
- public void onEnable(){
- instance = this;
- new PlayerListener(this);
- createTimer();
- }
- @Override
- public void onDisable(){
- }
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
- if (cmd.getName().equalsIgnoreCase("test") && sender instanceof Player){
- Player player = (Player) sender;
- player.sendMessage("test");
- return true;
- }
- //Helix using offsets
- else if (cmd.getName().equalsIgnoreCase("b") && sender instanceof Player){
- final Player player = (Player) sender;
- final Location location = player.getLocation();
- final Vector d = player.getEyeLocation().getDirection().normalize();
- new BukkitRunnable(){
- double t = 0;
- public void run(){
- t = t + Math.PI/4;
- double x, y, z;
- location.add(d);
- double xx = 0;
- double xy = -d.getZ();
- double xz = d.getY();
- double yx = -d.getZ();
- double yy = 0;
- double yz = d.getX();
- double zx = -d.getY();
- double zy = d.getX();
- double zz = 0;
- x = Math.cos(t)*(xx + xy + xz);
- y = Math.sin(t)*(yx + yy + yz);
- z = Math.cos(t)*(zx + zy + zz);
- location.add(x, y, z);
- ParticleEffect.FLAME.display(location, 0, 0, 0, 0, 1);
- //player.sendMessage(""+location.getX()+" "+location.getY()+" "+location.getZ());
- if(t > Math.PI*16){
- this.cancel();
- }
- }
- }.runTaskTimer(EventHandle.getInstance(), 0, 2);
- return true;
- }
- else if (cmd.getName().equalsIgnoreCase("run") && sender instanceof Player){
- final Player player = (Player) sender;
- new BukkitRunnable(){
- double t = 0;
- public void run(){
- t = t + Math.PI/80;
- Random rand = new Random();
- double randomNum = rand.nextDouble();
- double x = 0.3* Math.cos(t);
- double y = 0;
- double z = 0.3* Math.sin(t);
- player.setVelocity(new Vector(x,y,z));
- if(t > 100){
- this.cancel();
- }
- }
- }.runTaskTimer(EventHandle.getInstance(), 0, 1);
- return true;
- }
- return false;
- }
- public void createTimer(){
- new BukkitRunnable(){
- public void run(){
- }
- }.runTaskTimer(this, delay, period);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement