@@ -7,18 +7,19 @@

package com.onarandombox.MultiverseCore.utils;

import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;

import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Vehicle;
import org.bukkit.util.Vector;

import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;

public class LocationManipulation {
private static Map<String, Integer> orientationInts = new HashMap<String, Integer>();

static {
orientationInts.put("n", 180);
orientationInts.put("ne", 225);
@@ -35,6 +36,7 @@ public class LocationManipulation {
* Convert a Location into a Colon separated string to allow us to store it in text.
*
* @param location
*
* @return
*/
public static String locationToString(Location location) {
@@ -56,6 +58,7 @@ public static String locationToString(Location location) {
* @param zStr
* @param yawStr
* @param pitchStr
*
* @return
*/
public Location stringToLocation(World world, String xStr, String yStr, String zStr, String yawStr, String pitchStr) {
@@ -70,7 +73,9 @@ public Location stringToLocation(World world, String xStr, String yStr, String z

/**
* Returns a colored string with the coords
*
* @param l
*
* @return
*/
public static String strCoords(Location l) {
@@ -85,9 +90,12 @@ public static String strCoords(Location l) {
result += ChatColor.WHITE + "Y: " + ChatColor.GOLD + df.format(l.getYaw()) + " ";
return result;
}

/**
* Converts a location to a printable readable formatted string including pitch/yaw
*
* @param l
*
* @return
*/
public static String strCoordsRaw(Location l) {
@@ -107,6 +115,7 @@ public static String strCoordsRaw(Location l) {
* Return the NESW Direction a Location is facing.
*
* @param location
*
* @return
*/
public static String getDirection(Location location) {
@@ -134,9 +143,12 @@ else if (r < 337.5)

return dir;
}

/**
* Returns the float yaw position for the given cardianl direction
*
* @param orientation
*
* @return
*/
public static float getYaw(String orientation) {
@@ -148,9 +160,12 @@ public static float getYaw(String orientation) {
}
return 0;
}

/**
* Returns a speed float from a given vector.
*
* @param v
*
* @return
*/
public static float getSpeed(Vector v) {
@@ -159,10 +174,13 @@ public static float getSpeed(Vector v) {

// X, Y, Z
// -W/+E,0, -N/+S

/**
* Returns a translated vector from the given direction
*
* @param v
* @param direction
*
* @return
*/
public static Vector getTranslatedVector(Vector v, String direction) {
@@ -196,6 +214,7 @@ public static Vector getTranslatedVector(Vector v, String direction) {
* Returns the next Location that an entity is traveling at
*
* @param v
*
* @return
*/
public static Location getNextBlock(Vehicle v) {
@@ -36,22 +36,24 @@ public void setCooldown(int milliseconds) {

/**
* Sends a message to the specified sender if the cooldown has passed.
* @param sender The person/console to send the message to.
* @param message The message to send.
*
* @param sender The person/console to send the message to.
* @param message The message to send.
* @param ignoreCooldown If true this message will always be sent. Useful for things like menus
*
* @return true if the message was sent, false if not.
*/
public boolean sendMessage(CommandSender sender, String message, boolean ignoreCooldown) {
if(!(sender instanceof Player) || ignoreCooldown) {
if (!(sender instanceof Player) || ignoreCooldown) {
sender.sendMessage(message);
return true;
}
if(!this.sentList.containsKey(sender.getName())) {
if (!this.sentList.containsKey(sender.getName())) {
sender.sendMessage(message);
this.sentList.put(sender.getName(), new Date());
return true;
} else {
if(this.sentList.get(sender.getName()).after(new Date((new Date()).getTime() + this.cooldown))){
if (this.sentList.get(sender.getName()).after(new Date((new Date()).getTime() + this.cooldown))) {
sender.sendMessage(message);
this.sentList.put(sender.getName(), new Date());
return true;
@@ -61,17 +63,17 @@ public boolean sendMessage(CommandSender sender, String message, boolean ignoreC
}

public boolean sendMessages(CommandSender sender, String[] messages, boolean ignoreCooldown) {
if(!(sender instanceof Player) || ignoreCooldown) {
if (!(sender instanceof Player) || ignoreCooldown) {

this.sendMessages(sender, messages);
return true;
}
if(!this.sentList.containsKey(sender.getName())) {
if (!this.sentList.containsKey(sender.getName())) {
this.sendMessages(sender, messages);
this.sentList.put(sender.getName(), new Date());
return true;
} else {
if(this.sentList.get(sender.getName()).after(new Date((new Date()).getTime() + this.cooldown))){
if (this.sentList.get(sender.getName()).after(new Date((new Date()).getTime() + this.cooldown))) {
this.sendMessages(sender, messages);
this.sentList.put(sender.getName(), new Date());
return true;
@@ -86,7 +88,7 @@ public boolean sendMessage(CommandSender sender, String message) {

public boolean sendMessages(CommandSender sender, String[] messages) {
boolean success = true;
for(String s : messages) {
for (String s : messages) {
success = (!(!this.sendMessage(sender, s, true) && success));
}
return success;
@@ -7,15 +7,14 @@

package com.onarandombox.MultiverseCore.utils;

import java.util.logging.Level;

import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.destination.CannonDestination;
import org.bukkit.Location;
import org.bukkit.TravelAgent;
import org.bukkit.entity.Player;

import com.onarandombox.MultiverseCore.MultiverseCore;
import java.util.logging.Level;

public class MVTravelAgent implements TravelAgent {
private MVDestination destination;
@@ -16,6 +16,7 @@ public class PermissionTools {
public PermissionTools(MultiverseCore plugin) {
this.plugin = plugin;
}

public void addToParentPerms(String permString) {
String permStringChopped = permString.replace(".*", "");

@@ -62,6 +63,7 @@ private void addToRootPermission(String rootPerm, String permStringChopped) {
* If the given permission was 'multiverse.core.tp.self', this would return 'multiverse.core.tp.*'.
*
* @param separatedPermissionString The array of a dot separated perm string.
*
* @return The dot separated parent permission string.
*/
private String getParentPerm(String[] separatedPermissionString) {
@@ -10,8 +10,6 @@
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
import com.onarandombox.MultiverseCore.utils.BlockSafety;
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Minecart;
@@ -88,6 +88,7 @@ public void checkUpdate() {
* Convert the given Version String to a Normalised Version String so we can compare it.
*
* @param version
*
* @return
*/
public static String normalisedVersion(String version) {
@@ -14,7 +14,7 @@
*/

@Deprecated
public class DebugLog extends com.onarandombox.MultiverseCore.utils.DebugLog{
public class DebugLog extends com.onarandombox.MultiverseCore.utils.DebugLog {
public DebugLog(String logger, String file) {
super(logger, file);
}
@@ -8,11 +8,6 @@
package com.onarandombox.utils;

import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.utils.MVDestination;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;

/**
* Dummy class to make old MV Plugins not explode.