Java 类org.bukkit.util.NumberConversions 实例源码
项目:mcMMOExtras
文件:PlayerData.java
private String formatMessage(String lastSkill, int level, int exp, int requiredExp, float gained, int percent) {
ChatColor color = ChatColor.GOLD;
String colorPath = "bar.color." + lastSkill.toLowerCase();
if (plugin.getConfig().isSet(colorPath)) {
//specific color for a skill type
String configColor = plugin.getConfig().getString(colorPath);
//filter the color char; otherwise we won't detect the color
color = ChatColor.getByChar(configColor.replace("&", ""));
}
//custom variable replacement
String format = plugin.getConfig().getString("bar.format")
.replace("@skill", lastSkill)
.replace("@level", Integer.toString(level))
.replace("@nextLevel", Integer.toString(level + 1))
.replace("@exp", Integer.toString(exp))
.replace("@remainingExp", Integer.toString(requiredExp - exp))
.replace("@gainedExp", Integer.toString(NumberConversions.round(gained)))
.replace("@reqExp", Integer.toString(requiredExp))
.replace("@percent", Integer.toString(percent));
return color + format;
}
项目:CraftFX
文件:SlotData.java
@Override
public void onDataHolderUpdate() {
final DataHolder holder = getHolder().get();
if (holder instanceof ConfigDataHolder) {
final ConfigDataHolder h = (ConfigDataHolder) holder;
if (h.getConfig().isList("slots")) {
final List<?> list = h.getConfig().getList("slots");
final Set<Integer> ints = new HashSet<>();
for (Object o : list) {
if (o instanceof String) {
ints.addAll(parseSlots((String) o));
} else {
int i = NumberConversions.toInt(o);
if (i < 0 || i > 36) continue;
ints.add(i);
}
}
slots = fromCollection(ints);
return;
}
}
final Optional<String> opt = holder.get("slots", String.class);
opt.ifPresent(s -> slots = fromCollection(parseSlots(s)));
}
项目:CraftFX
文件:PlayerArgumentProvider.java
private Map<String, Integer> getSelectorParams(String selector) {
Matcher m = SELECTOR_PARAMS_CAPTURE.matcher(selector);
Map<String, Integer> result = Maps.newHashMap();
if (m.find() && m.group(1) != null) {
String args = m.group(1);
m = SELECTOR_PARAMS_UNNAMED.matcher(args);
if (m.find()) {
result.put("x", NumberConversions.toInt(m.group(1)));
result.put("y", NumberConversions.toInt(m.group(2)));
result.put("z", NumberConversions.toInt(m.group(3)));
result.put("r", NumberConversions.toInt(m.group(4)));
return result;
}
m = SELECTOR_PARAMS_SEPARATOR.matcher(args);
while (m.find()) {
result.put(m.group(1), NumberConversions.toInt(m.group(2)));
}
}
return result;
}
项目:CraftFX
文件:PotionEffectUtil.java
public static List<PotionEffect> getPotionEffects(
List<String> identifiers) throws IllegalArgumentException {
List<PotionEffect> potionEffectList = Lists.newArrayList();
for (String identifier : identifiers) {
String[] split = identifier.replaceAll("\\s+", "_").split("\\W");
if (split.length < 3) {
throw new IllegalArgumentException(
"Missing argument: potion effect, duration or amplifier");
}
PotionEffectType type = PotionEffectType.getByName(EnumUtil.enumify(split[0]));
if (type == null) {
throw new IllegalArgumentException(
"Potion effect '" + split[0] + "' is not a valid type.");
}
int duration = (int) TimeUtil.parseString(split[1]);
int amplifier = NumberConversions.toInt(split[2]);
potionEffectList.add(new PotionEffect(type, duration, amplifier));
}
return potionEffectList;
}
项目:StorageSign
文件:StorageSign.java
public StorageSign(ItemStack item) {
String[] str = item.getItemMeta().getLore().get(0).split(" ");
if(str[0].matches("Empty")) isEmpty = true;
else {
mat = getMaterial(str[0].split(":")[0]);
if(mat == Material.ENCHANTED_BOOK){
damage = NumberConversions.toShort(str[0].split(":")[2]);
ench = Enchantment.getByName(str[0].split(":")[1]);//旧仕様も
if(ench == null) ench = Enchantment.getById(NumberConversions.toInt(str[0].split(":")[1]));
}
else if(mat == Material.POTION || mat == Material.SPLASH_POTION || mat == Material.LINGERING_POTION){
PotionInfo pi = new PotionInfo(mat, str[0].split(":"));
mat = pi.getMaterial();
damage = pi.getDamage();
pot = pi.getPotionType();
}else if(str[0].contains(":")) damage = NumberConversions.toShort(str[0].split(":")[1]);
amount = NumberConversions.toInt(str[1]);
}
stack = item.getAmount();
}
项目:StorageSign
文件:StorageSign.java
public StorageSign(Sign sign) {
String[] line2 = sign.getLine(1).trim().split(":");
mat = getMaterial(line2[0]);
isEmpty = mat == null || mat == Material.AIR;
if(line2.length == 2) damage = NumberConversions.toShort(line2[1]);
if(mat == Material.ENCHANTED_BOOK){
damage = NumberConversions.toShort(line2[2]);
ench = Enchantment.getById(NumberConversions.toInt(line2[1]));
}
else if(mat == Material.POTION || mat == Material.SPLASH_POTION || mat == Material.LINGERING_POTION){
PotionInfo pi = new PotionInfo(mat, line2);
mat = pi.getMaterial();
damage = pi.getDamage();
pot = pi.getPotionType();
}
amount = NumberConversions.toInt(sign.getLine(2));
isEmpty = amount == 0;
stack = 1;
}
项目:ScoreboardStats
文件:BukkitVariables.java
@Override
public void register() {
register("health").scoreSupply(player -> NumberConversions.round(player.getHealth()));
register("lifetime").scoreSupply(player -> player.getTicksLived() / (20 * MINUTE_TO_SECOND));
register("no_damage_ticks").scoreSupply(player -> player.getNoDamageTicks() / (20 * MINUTE_TO_SECOND));
register("last_damage").scoreSupply(player -> (int) (player.getLastDamage()));
register("exp").scoreSupply(Player::getTotalExperience);
register("xp_to_level").scoreSupply(Player::getExpToLevel);
register("helmet").scoreSupply(player -> calculateDurability(player.getInventory().getHelmet()));
register("boots").scoreSupply(player -> calculateDurability(player.getInventory().getBoots()));
register("leggings").scoreSupply(player -> calculateDurability(player.getInventory().getLeggings()));
register("chestplate").scoreSupply(player -> calculateDurability(player.getInventory().getChestplate()));
register("chestplate").scoreSupply(player -> (int) player.getWorld().getTime());
}
项目:DynamicAC
文件:Utilities.java
public static double fixXAxis(double x) {
/* For Z axis, just use Math.round(xaxis); */
double touchedX = x;
double rem = touchedX - Math.round(touchedX) + 0.01D;
if (rem < 0.30D) {
touchedX = NumberConversions.floor(x) - 1;
}
return touchedX;
}
项目:GameBoxx
文件:Cuboid.java
public static Cuboid deserialize(Map<String, Object> args) {
World world = Bukkit.getWorld((String)args.get("world"));
if (world == null) {
throw new IllegalArgumentException("unknown world");
}
return new Cuboid(world, NumberConversions.toInt(args.get("minX")), NumberConversions.toInt(args.get("minY")), NumberConversions.toInt(args.get("minZ")),
NumberConversions.toInt(args.get("minX")), NumberConversions.toInt(args.get("minY")), NumberConversions.toInt(args.get("minZ")));
}
项目:Thermos-Bukkit
文件:Location.java
/**
* Sets the {@link #getYaw() yaw} and {@link #getPitch() pitch} to point
* in the direction of the vector.
*/
public Location setDirection(Vector vector) {
/*
* Sin = Opp / Hyp
* Cos = Adj / Hyp
* Tan = Opp / Adj
*
* x = -Opp
* z = Adj
*/
final double _2PI = 2 * Math.PI;
final double x = vector.getX();
final double z = vector.getZ();
if (x == 0 && z == 0) {
pitch = vector.getY() > 0 ? -90 : 90;
return this;
}
double theta = Math.atan2(-x, z);
yaw = (float) Math.toDegrees((theta + _2PI) % _2PI);
double x2 = NumberConversions.square(x);
double z2 = NumberConversions.square(z);
double xz = Math.sqrt(x2 + z2);
pitch = (float) Math.toDegrees(Math.atan(-vector.getY() / xz));
return this;
}
项目:Thermos-Bukkit
文件:Location.java
/**
* Get the squared distance between this location and another.
*
* @see Vector
* @param o The other location
* @return the distance
* @throws IllegalArgumentException for differing worlds
*/
public double distanceSquared(Location o) {
if (o == null) {
throw new IllegalArgumentException("Cannot measure distance to a null location");
} else if (o.getWorld() == null || getWorld() == null) {
throw new IllegalArgumentException("Cannot measure distance to a null world");
} else if (o.getWorld() != getWorld()) {
throw new IllegalArgumentException("Cannot measure distance between " + getWorld().getName() + " and " + o.getWorld().getName());
}
return NumberConversions.square(x - o.x) + NumberConversions.square(y - o.y) + NumberConversions.square(z - o.z);
}
项目:Janitor
文件:UtilCheat.java
public static double fixXAxis(double x) {
double touchedX = x;
double rem = touchedX - (double)Math.round(touchedX) + 0.01;
if (rem < 0.3) {
touchedX = NumberConversions.floor((double)x) - 1;
}
return touchedX;
}
项目:CauldronGit
文件:Location.java
/**
* Sets the {@link #getYaw() yaw} and {@link #getPitch() pitch} to point
* in the direction of the vector.
*/
public Location setDirection(Vector vector) {
/*
* Sin = Opp / Hyp
* Cos = Adj / Hyp
* Tan = Opp / Adj
*
* x = -Opp
* z = Adj
*/
final double _2PI = 2 * Math.PI;
final double x = vector.getX();
final double z = vector.getZ();
if (x == 0 && z == 0) {
pitch = vector.getY() > 0 ? -90 : 90;
return this;
}
double theta = Math.atan2(-x, z);
yaw = (float) Math.toDegrees((theta + _2PI) % _2PI);
double x2 = NumberConversions.square(x);
double z2 = NumberConversions.square(z);
double xz = Math.sqrt(x2 + z2);
pitch = (float) Math.toDegrees(Math.atan(-vector.getY() / xz));
return this;
}
项目:CauldronGit
文件:Location.java
/**
* Get the squared distance between this location and another.
*
* @see Vector
* @param o The other location
* @return the distance
* @throws IllegalArgumentException for differing worlds
*/
public double distanceSquared(Location o) {
if (o == null) {
throw new IllegalArgumentException("Cannot measure distance to a null location");
} else if (o.getWorld() == null || getWorld() == null) {
throw new IllegalArgumentException("Cannot measure distance to a null world");
} else if (o.getWorld() != getWorld()) {
throw new IllegalArgumentException("Cannot measure distance between " + getWorld().getName() + " and " + o.getWorld().getName());
}
return NumberConversions.square(x - o.x) + NumberConversions.square(y - o.y) + NumberConversions.square(z - o.z);
}
项目:AdvancedAchievements
文件:AchieveDistanceRunnable.java
/**
* Calculates the difference between the player's last location and his current one.
*
* @param player
* @param previousLocation
* @return difference
*/
private int getDistanceDifference(Player player, Location previousLocation) {
// Distance difference since last runnable; ignore the vertical axis or not.
double difference;
if (configIgnoreVerticalDistance) {
difference = Math.sqrt(NumberConversions.square(previousLocation.getX() - player.getLocation().getX())
+ NumberConversions.square(previousLocation.getZ() - player.getLocation().getZ()));
} else {
difference = previousLocation.distance(player.getLocation());
}
return (int) difference;
}
项目:AntiCheat-COMPAT
文件:Utilities.java
/**
* Fixes a player's X position to determine the block they are on, even if they're on the edge
*
* @param x player's x position
* @return fixed x position
*/
public static double fixXAxis(double x) {
/* For Z axis, just use Math.round(xaxis); */
double touchedX = x;
double rem = touchedX - Math.round(touchedX) + 0.01D;
if (rem < 0.30D) {
touchedX = NumberConversions.floor(x) - 1;
}
return touchedX;
}
项目:Cauldron
文件:Location.java
/**
* Sets the {@link #getYaw() yaw} and {@link #getPitch() pitch} to point
* in the direction of the vector.
*/
public Location setDirection(Vector vector) {
/*
* Sin = Opp / Hyp
* Cos = Adj / Hyp
* Tan = Opp / Adj
*
* x = -Opp
* z = Adj
*/
final double _2PI = 2 * Math.PI;
final double x = vector.getX();
final double z = vector.getZ();
if (x == 0 && z == 0) {
pitch = vector.getY() > 0 ? -90 : 90;
return this;
}
double theta = Math.atan2(-x, z);
yaw = (float) Math.toDegrees((theta + _2PI) % _2PI);
double x2 = NumberConversions.square(x);
double z2 = NumberConversions.square(z);
double xz = Math.sqrt(x2 + z2);
pitch = (float) Math.toDegrees(Math.atan(-vector.getY() / xz));
return this;
}
项目:Cauldron
文件:Location.java
/**
* Get the squared distance between this location and another.
*
* @see Vector
* @param o The other location
* @return the distance
* @throws IllegalArgumentException for differing worlds
*/
public double distanceSquared(Location o) {
if (o == null) {
throw new IllegalArgumentException("Cannot measure distance to a null location");
} else if (o.getWorld() == null || getWorld() == null) {
throw new IllegalArgumentException("Cannot measure distance to a null world");
} else if (o.getWorld() != getWorld()) {
throw new IllegalArgumentException("Cannot measure distance between " + getWorld().getName() + " and " + o.getWorld().getName());
}
return NumberConversions.square(x - o.x) + NumberConversions.square(y - o.y) + NumberConversions.square(z - o.z);
}
项目:Cauldron
文件:Location.java
/**
* Sets the {@link #getYaw() yaw} and {@link #getPitch() pitch} to point
* in the direction of the vector.
*/
public Location setDirection(Vector vector) {
/*
* Sin = Opp / Hyp
* Cos = Adj / Hyp
* Tan = Opp / Adj
*
* x = -Opp
* z = Adj
*/
final double _2PI = 2 * Math.PI;
final double x = vector.getX();
final double z = vector.getZ();
if (x == 0 && z == 0) {
pitch = vector.getY() > 0 ? -90 : 90;
return this;
}
double theta = Math.atan2(-x, z);
yaw = (float) Math.toDegrees((theta + _2PI) % _2PI);
double x2 = NumberConversions.square(x);
double z2 = NumberConversions.square(z);
double xz = Math.sqrt(x2 + z2);
pitch = (float) Math.toDegrees(Math.atan(-vector.getY() / xz));
return this;
}
项目:Cauldron
文件:Location.java
/**
* Get the squared distance between this location and another.
*
* @see Vector
* @param o The other location
* @return the distance
* @throws IllegalArgumentException for differing worlds
*/
public double distanceSquared(Location o) {
if (o == null) {
throw new IllegalArgumentException("Cannot measure distance to a null location");
} else if (o.getWorld() == null || getWorld() == null) {
throw new IllegalArgumentException("Cannot measure distance to a null world");
} else if (o.getWorld() != getWorld()) {
throw new IllegalArgumentException("Cannot measure distance between " + getWorld().getName() + " and " + o.getWorld().getName());
}
return NumberConversions.square(x - o.x) + NumberConversions.square(y - o.y) + NumberConversions.square(z - o.z);
}
项目:Cauldron
文件:Location.java
/**
* Sets the {@link #getYaw() yaw} and {@link #getPitch() pitch} to point
* in the direction of the vector.
*/
public Location setDirection(Vector vector) {
/*
* Sin = Opp / Hyp
* Cos = Adj / Hyp
* Tan = Opp / Adj
*
* x = -Opp
* z = Adj
*/
final double _2PI = 2 * Math.PI;
final double x = vector.getX();
final double z = vector.getZ();
if (x == 0 && z == 0) {
pitch = vector.getY() > 0 ? -90 : 90;
return this;
}
double theta = Math.atan2(-x, z);
yaw = (float) Math.toDegrees((theta + _2PI) % _2PI);
double x2 = NumberConversions.square(x);
double z2 = NumberConversions.square(z);
double xz = Math.sqrt(x2 + z2);
pitch = (float) Math.toDegrees(Math.atan(-vector.getY() / xz));
return this;
}
项目:Cauldron
文件:Location.java
/**
* Get the squared distance between this location and another.
*
* @see Vector
* @param o The other location
* @return the distance
* @throws IllegalArgumentException for differing worlds
*/
public double distanceSquared(Location o) {
if (o == null) {
throw new IllegalArgumentException("Cannot measure distance to a null location");
} else if (o.getWorld() == null || getWorld() == null) {
throw new IllegalArgumentException("Cannot measure distance to a null world");
} else if (o.getWorld() != getWorld()) {
throw new IllegalArgumentException("Cannot measure distance between " + getWorld().getName() + " and " + o.getWorld().getName());
}
return NumberConversions.square(x - o.x) + NumberConversions.square(y - o.y) + NumberConversions.square(z - o.z);
}
项目:Almura-API
文件:Location.java
/**
* Get the squared distance between this location and another.
*
* @see Vector
* @param o The other location
* @return the distance
* @throws IllegalArgumentException for differing worlds
*/
public double distanceSquared(Location o) {
if (o == null) {
throw new IllegalArgumentException("Cannot measure distance to a null location");
} else if (o.getWorld() == null || getWorld() == null) {
throw new IllegalArgumentException("Cannot measure distance to a null world");
} else if (o.getWorld() != getWorld()) {
throw new IllegalArgumentException("Cannot measure distance between " + getWorld().getName() + " and " + o.getWorld().getName());
}
return NumberConversions.square(x - o.x) + NumberConversions.square(y - o.y) + NumberConversions.square(z - o.z);
}
项目:SpigotSource
文件:PlayerConnection.java
public void a(PacketPlayInUseItem packetplayinuseitem) {
PlayerConnectionUtils.ensureMainThread(packetplayinuseitem, this, this.player.x());
if (this.player.dead) return; // CraftBukkit
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
EnumHand enumhand = packetplayinuseitem.c();
ItemStack itemstack = this.player.b(enumhand);
BlockPosition blockposition = packetplayinuseitem.a();
EnumDirection enumdirection = packetplayinuseitem.b();
this.player.resetIdleTimer();
if (blockposition.getY() >= this.minecraftServer.getMaxBuildHeight() - 1 && (enumdirection == EnumDirection.UP || blockposition.getY() >= this.minecraftServer.getMaxBuildHeight())) {
ChatMessage chatmessage = new ChatMessage("build.tooHigh", new Object[] { Integer.valueOf(this.minecraftServer.getMaxBuildHeight())});
chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage));
} else if (this.teleportPos == null && this.player.e((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && !this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) {
// CraftBukkit start - Check if we can actually do something over this large a distance
Location eyeLoc = this.getPlayer().getEyeLocation();
double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ());
if (reachDistance > (this.getPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED)) {
return;
}
// CraftBukkit end
this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, blockposition, enumdirection, packetplayinuseitem.d(), packetplayinuseitem.e(), packetplayinuseitem.f());
}
this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(worldserver, blockposition));
this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(worldserver, blockposition.shift(enumdirection)));
itemstack = this.player.b(enumhand);
if (itemstack != null && itemstack.count == 0) {
this.player.a(enumhand, (ItemStack) null);
itemstack = null;
}
}
项目:Spigot-API
文件:Location.java
/**
* Sets the {@link #getYaw() yaw} and {@link #getPitch() pitch} to point
* in the direction of the vector.
*/
public Location setDirection(Vector vector) {
/*
* Sin = Opp / Hyp
* Cos = Adj / Hyp
* Tan = Opp / Adj
*
* x = -Opp
* z = Adj
*/
final double _2PI = 2 * Math.PI;
final double x = vector.getX();
final double z = vector.getZ();
if (x == 0 && z == 0) {
pitch = vector.getY() > 0 ? -90 : 90;
return this;
}
double theta = Math.atan2(-x, z);
yaw = (float) Math.toDegrees((theta + _2PI) % _2PI);
double x2 = NumberConversions.square(x);
double z2 = NumberConversions.square(z);
double xz = Math.sqrt(x2 + z2);
pitch = (float) Math.toDegrees(Math.atan(-vector.getY() / xz));
return this;
}
项目:Spigot-API
文件:Location.java
/**
* Get the squared distance between this location and another.
*
* @see Vector
* @param o The other location
* @return the distance
* @throws IllegalArgumentException for differing worlds
*/
public double distanceSquared(Location o) {
if (o == null) {
throw new IllegalArgumentException("Cannot measure distance to a null location");
} else if (o.getWorld() == null || getWorld() == null) {
throw new IllegalArgumentException("Cannot measure distance to a null world");
} else if (o.getWorld() != getWorld()) {
throw new IllegalArgumentException("Cannot measure distance between " + getWorld().getName() + " and " + o.getWorld().getName());
}
return NumberConversions.square(x - o.x) + NumberConversions.square(y - o.y) + NumberConversions.square(z - o.z);
}
项目:Demigods3
文件:DemigodsLocation.java
public double distance(DemigodsLocation location) {
if (location != null) {
double squared = NumberConversions.square(X - location.X) + NumberConversions.square(Y - location.Y) + NumberConversions.square(Z = location.Z);
return Math.sqrt(squared);
}
throw new NullPointerException("Cannot measure distance to a null location.");
}
项目:CraftFX
文件:SlotData.java
private Set<Integer> parseSlots(String str) {
final String[] parts = str.split(", ?");
final Set<Integer> ints = new HashSet<>();
handSlot = false;
loop:
for (String s : parts) {
s = s.toLowerCase();
switch (s) {
case "all":
ints.addAll(ALL_SLOTS);
break loop;
case "armor":
ints.addAll(ARMOR_SLOTS);
break;
case "hotbar":
ints.addAll(HOTBAR_SLOTS);
break;
case "hand":
handSlot = true;
break;
default:
int i = NumberConversions.toInt(s);
if (i < 0 || i > 36) break;
ints.add(i);
break;
}
}
return ints;
}
项目:CraftFX
文件:TimeUtil.java
/**
* Parses a String into a time. Value is returned in milliseconds.
*/
public static long parseString(String message) {
Matcher m = TIME_PATTERN.matcher(message);
long time = 0;
while (m.find()) {
double num = NumberConversions.toDouble(m.group(1));
String suffix = m.group(2).toLowerCase();
switch (suffix) {
case "y":
time += 3.15569e10 * num;
break;
case "w":
time += 6.048e8 * num;
break;
case "d":
time += 8.64e7 * num;
break;
case "h":
time += 3.6e6 * num;
break;
case "m":
time += 6e4 * num;
break;
case "t":
time += 50L * num;
break;
case "ms":
time += num;
break;
default:
// default to seconds
time += 1e3 * num;
break;
}
}
return time;
}
项目:ScoreboardStats
文件:BukkitGlobalVariables.java
@Override
public void register() {
register("tps")
.scoreSupply(() -> NumberConversions.round(TicksPerSecondTask.getLastTicks()));
register("online")
.scoreSupply(() -> Bukkit.getOnlinePlayers().size())
.eventScore(PlayerJoinEvent.class, () -> Bukkit.getOnlinePlayers().size())
.eventScore(PlayerQuitEvent.class, () -> Bukkit.getOnlinePlayers().size() - 1);
register("max_player")
.scoreSupply(Bukkit::getMaxPlayers)
.constant();
}
项目:ScoreboardStats
文件:CraftconomyVariables.java
@Override
public void register() {
if (Common.isInitialized()) {
for (String currencyName : currencyManager.getCurrencyNames()) {
register("money_" + currencyName)
.scoreSupply(player -> {
Currency currency = currencyManager.getCurrency(currencyName);
double balance = accountManager.getAccount(player.getWorld().getName(), false)
.getBalance(player.getWorld().getName(), currencyName);
return NumberConversions.round(balance);
});
}
}
}
项目:ScoreboardStats
文件:PlayerStats.java
/**
* Get the current kill-death-ratio rounded
*
* @return the kill death ratio rounded to an integer
*/
public int getKdr() {
//We can't divide by zero
if (deaths == 0) {
return kills;
} else {
//Triggers float division to have decimals
return NumberConversions.round(kills / (float) deaths);
}
}
项目:Bukkit-JavaDoc
文件:Location.java
/**
* Sets the {@link #getYaw() yaw} and {@link #getPitch() pitch} to point
* in the direction of the vector.
*/
public Location setDirection(Vector vector) {
/*
* Sin = Opp / Hyp
* Cos = Adj / Hyp
* Tan = Opp / Adj
*
* x = -Opp
* z = Adj
*/
final double _2PI = 2 * Math.PI;
final double x = vector.getX();
final double z = vector.getZ();
if (x == 0 && z == 0) {
pitch = vector.getY() > 0 ? -90 : 90;
return this;
}
double theta = Math.atan2(-x, z);
yaw = (float) Math.toDegrees((theta + _2PI) % _2PI);
double x2 = NumberConversions.square(x);
double z2 = NumberConversions.square(z);
double xz = Math.sqrt(x2 + z2);
pitch = (float) Math.toDegrees(Math.atan(-vector.getY() / xz));
return this;
}
项目:Bukkit-JavaDoc
文件:Location.java
/**
* Get the squared distance between this location and another.
*
* @see Vector
* @param o The other location
* @return the distance
* @throws IllegalArgumentException for differing worlds
*/
public double distanceSquared(Location o) {
if (o == null) {
throw new IllegalArgumentException("Cannot measure distance to a null location");
} else if (o.getWorld() == null || getWorld() == null) {
throw new IllegalArgumentException("Cannot measure distance to a null world");
} else if (o.getWorld() != getWorld()) {
throw new IllegalArgumentException("Cannot measure distance between " + getWorld().getName() + " and " + o.getWorld().getName());
}
return NumberConversions.square(x - o.x) + NumberConversions.square(y - o.y) + NumberConversions.square(z - o.z);
}
项目:Uranium
文件:CraftMinecart.java
@Deprecated
public int _INVALID_getDamage() {
return NumberConversions.ceil(getDamage());
}
项目:Uranium
文件:CraftLivingEntity.java
@Deprecated
public int _INVALID_getLastDamage() {
return NumberConversions.ceil(getLastDamage());
}
项目:Uranium
文件:CraftLivingEntity.java
@Deprecated
public int _INVALID_getHealth() {
return NumberConversions.ceil(getHealth());
}
项目:Uranium
文件:CraftLivingEntity.java
@Deprecated
public int _INVALID_getMaxHealth() {
return NumberConversions.ceil(getMaxHealth());
}
项目:Uranium
文件:CraftEnderDragonPart.java
@Deprecated
public int _INVALID_getHealth() {
return NumberConversions.ceil(getHealth());
}
项目:Uranium
文件:CraftEnderDragonPart.java
@Deprecated
public int _INVALID_getMaxHealth() {
return NumberConversions.ceil(getMaxHealth());
}