Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Java by Fear ( 9 years ago )
package com.FearsNet.HoloGuide;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import net.md_5.bungee.api.ChatColor;

import java.sql.Time;
import java.text.DecimalFormat;
import java.util.concurrent.TimeUnit;
import java.time.Duration;
import de.Herbystar.TTA.TTA_Methods;

import com.gmail.filoghost.holographicdisplays.api.Hologram;
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
import com.gmail.filoghost.holographicdisplays.api.line.TextLine;

public class HoloGuide extends JavaPlugin {
 
  
    @Override
    public void onEnable() {
       
    }
   
    @Override
    public void onDisable() {
       
    }
   
    @Override
    public boolean onCommand(CommandSender sender,
            Command command,
            String label,
            String[] args) {
     Plugin plugin1 = getServer().getPluginManager().getPlugin("HoloGuide");
     DecimalFormat df = new DecimalFormat("###.##");
     //df.format(xx)
     String playerString = sender.getName();
     Player player = Bukkit.getPlayer(playerString);
     //Location playerLoc = Bukkit.getPlayer(player).getLocation();
     Location playerLoc = player.getLocation();
     //
     //float loc1 = .getPitch();
     double pitch = ((playerLoc.getPitch() + 90) * Math.PI) / 180;
  double yaw  = ((playerLoc.getYaw() + 90)  * Math.PI) / 180;
  double x = Math.sin(pitch) * Math.cos(yaw);
  double y = Math.sin(pitch) * Math.sin(yaw);
  double z = Math.cos(pitch);
  //raw yaw is direction in 360deg, pitch in -90 - 90 deg
  // +-10deg yaw ideal for hologram height trim -- close range
  // +-13-15deg yaw ideal for hologram height trim long range
  String x1 = String.valueOf(x);
  String y1 = String.valueOf(y);
  String z1 = String.valueOf(z);
  
  if (command.getName().equalsIgnoreCase("hwpt")) {
   // sender.sendMessage(args[0] + " " + args[1]);
   // TTA_Methods.sendActionBar(player, args[0]);
   int ti = Integer.parseInt(args[1]);
   double time = (ti) * 20;
   //double time2 = (args[1]) != null? 100 : time;
   String time5 = args[1];
   if (time5 == null || time5.equals("null")) {
       time5 = "100";
   }
   int time6 = Integer.parseInt(time5);
   sender.sendMessage(time + " <time> time6) {
               //TTA_Methods.sendActionBar(player, "test", 30);
               //test1.delete();
               //test.delete();
               cancel();
              }
             }
   }.runTaskTimer(plugin1, 1L, 1L);
   return true;
        }
  
        if (command.getName().equalsIgnoreCase("hwp")) {
            sender.sendMessage(ChatColor.BOLD + "!");
            sender.sendMessage(ChatColor.GOLD + " " + playerLoc + ChatColor.DARK_RED + "\n x = " + x1 + ChatColor.DARK_BLUE + "\n y = " + y1 + ChatColor.DARK_GREEN + "\n z = " + z1 + ChatColor.AQUA + "\n" + player);
            sender.sendMessage(ChatColor.GREEN + String.valueOf(df.format(x)));
            sender.sendMessage(ChatColor.GREEN + String.valueOf(df.format(y)));
            sender.sendMessage(ChatColor.GREEN + String.valueOf(df.format(z)));
            ////Hologram test = HologramsAPI.createHologram(plugin1, playerLoc);
            ////TextLine textLine = test.appendTextLine("A hologram line");
            ////final Hologram test1 = HologramsAPI.createHologram(plugin1, playerLoc.add(0.0, 3.0, 0.0));
            ////test1.appendTextLine("Chat > Message");
            //try {
   // TimeUnit.SECONDS.sleep(5);
   //} catch (InterruptedException e) {
   // // TODO Auto-generated catch block
   // e.printStackTrace();
   //}
            //test.delete();
            //test1.delete();
            new BukkitRunnable() {
             int ticksRun;
             @Override
             public void run() {
              ticksRun++;
              double pitch5 = ((playerLoc.getPitch() + 90) * Math.PI) / 180;
              double z5 = Math.cos(pitch5);
              //TTA_Methods.sendActionBar(player, ChatColor.GREEN + String.valueOf(df.format(z5)));
              Location playerLoc2 = player.getLocation();
              TTA_Methods.sendActionBar(player, ChatColor.GREEN + String.valueOf(df.format(Math.cos(((playerLoc2.getPitch() + 90) * Math.PI) / 180))) + " -- " + String.valueOf(df.format(Math.cos((playerLoc2.getYaw() + 90)  * Math.PI) / 180)) + " -- " + String.valueOf(df.format(Math.cos(((playerLoc2.getPitch() + 90) * Math.PI) / 180))));
              //test1.teleport(player.getLocation().add(0.0, 3.0, 0.0));
              if (ticksRun > 100) {
               //TTA_Methods.sendActionBar(player, "test", 30);
               //test1.delete();
               //test.delete();
               cancel();
              }
             }
            }.runTaskTimer(plugin1, 1L, 1L);
            
            return true;
        }
        return false;
    }
        
    /*public boolean onCommand(CommandSender sender, Command command, String label, String[] args, double x, double y, double z, String x1, String y1, String z1) {
     Player p = (Player) sender;
  Vector direction = p.getLocation().getDirection();
  Vector loc1 = new Vector();
  Location player_location1 = p.getLocation();
  double pitch = ((player_location1.getPitch() + 90) * Math.PI) / 180;
  double yaw  = ((player_location1.getYaw() + 90)  * Math.PI) / 180;
  x = Math.sin(pitch) * Math.cos(yaw);
  y = Math.sin(pitch) * Math.sin(yaw);
  z = Math.cos(pitch);
  x1 = String.valueOf(x);
  y1 = String.valueOf(y);
  z1 = String.valueOf(z);
  // x2 
  // y2
  // z2
  String str1 = direction.toString();
        if (command.getName().equalsIgnoreCase("hwp")) {
            sender.sendMessage(str1 + "\n x " + x1 + " y " + y1 + " z " + z1);
            sender.sendMessage(x1);
            sender.sendMessage(y1);
            sender.sendMessage(z1);
            sender.sendMessage(str1);
            return true;
        }
        return false;
    }    */
    
}

 

Revise this Paste

Your Name: Code Language: