本文整理汇总了Java中org.bukkit.WorldBorder.getSize方法的典型用法代码示例。如果您正苦于以下问题:Java WorldBorder.getSize方法的具体用法?Java WorldBorder.getSize怎么用?Java WorldBorder.getSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.WorldBorder
的用法示例。
在下文中一共展示了WorldBorder.getSize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isInsideBorder
import org.bukkit.WorldBorder; //导入方法依赖的package包/类
/**
* Checks if the given location is inside the world border of his world.
*
* @param location The location.
*
* @return The result of the check.
*/
public static boolean isInsideBorder(Location location)
{
World world = location.getWorld();
WorldBorder border = world.getWorldBorder();
Double borderRadius = border.getSize() / 2;
Double xMin = border.getCenter().getX() - borderRadius;
Double xMax = border.getCenter().getX() + borderRadius;
Double zMin = border.getCenter().getZ() - borderRadius;
Double zMax = border.getCenter().getZ() + borderRadius;
Double x = location.getX();
Double z = location.getZ();
return (x > xMin && x < xMax) && (z > zMin && z < zMax);
}
示例2: canCast
import org.bukkit.WorldBorder; //导入方法依赖的package包/类
public boolean canCast(Location location) {
if (location == null) return true;
if (!hasCastPermission(mage.getCommandSender())) return false;
Entity entity = mage.getEntity();
if (disguiseRestricted && entity != null && entity instanceof Player && controller.isDisguised(entity)) return false;
Boolean regionPermission = controller.getRegionCastPermission(mage.getPlayer(), this, location);
if (regionPermission != null && regionPermission == true) return true;
Boolean personalPermission = controller.getPersonalCastPermission(mage.getPlayer(), this, location);
if (personalPermission != null && personalPermission == true) return true;
if (regionPermission != null && regionPermission == false) return false;
if (requiresBuildPermission() && !hasBuildPermission(location.getBlock())) return false;
if (requiresBreakPermission() && !hasBreakPermission(location.getBlock())) return false;
if (worldBorderRestricted)
{
WorldBorder border = location.getWorld().getWorldBorder();
double borderSize = border.getSize() / 2 - border.getWarningDistance();
Location offset = location.subtract(border.getCenter());
if (offset.getX() < -borderSize || offset.getX() > borderSize || offset.getZ() < -borderSize || offset.getZ() > borderSize) return false;
}
return !pvpRestricted || bypassPvpRestriction || mage.isPVPAllowed(location);
}
示例3: run
import org.bukkit.WorldBorder; //导入方法依赖的package包/类
@Override
public void run() {
plugin.getServer().getOnlinePlayers().forEach(p ->
Lang.sendMessage(p, "messages.game.shrinking")
);
times--;
WorldBorder wb = battles.getWorld().getWorldBorder();
double newSize = wb.getSize() - amount;
if(newSize > 0) {
wb.setSize(newSize, shrinkTime);
}
if(times <= 0) cancel();
}
示例4: isInsideBorder
import org.bukkit.WorldBorder; //导入方法依赖的package包/类
public static boolean isInsideBorder(Location location) {
WorldBorder border = location.getWorld().getWorldBorder();
Location center = border.getCenter();
double radius = border.getSize() / 2d;
return Math.abs(location.getX() - center.getX()) < radius &&
Math.abs(location.getZ() - center.getZ()) < radius;
}
示例5: clampToBorder
import org.bukkit.WorldBorder; //导入方法依赖的package包/类
public static boolean clampToBorder(Location location) {
WorldBorder border = location.getWorld().getWorldBorder();
Location center = border.getCenter();
double radius = border.getSize() / 2d;
double xMin = center.getX() - radius;
double xMax = center.getX() + radius;
double zMin = center.getZ() - radius;
double zMax = center.getZ() + radius;
boolean moved = false;
if(location.getX() < xMin) {
location.setX(xMin);
moved = true;
}
if(location.getX() > xMax) {
location.setX(xMax);
moved = true;
}
if(location.getZ() < zMin) {
location.setZ(zMin);
moved = true;
}
if(location.getZ() > zMax) {
location.setZ(zMax);
moved = true;
}
return moved;
}
示例6: getProperty
import org.bukkit.WorldBorder; //导入方法依赖的package包/类
public static Number getProperty(WorldBorder border, BorderProperty borderProperty) {
switch (borderProperty) {
case DIAMETER: return border.getSize();
case DAMAGE_AMOUNT: return border.getDamageAmount();
case DAMAGE_BUFFER: return border.getDamageBuffer();
case WARNING_DISTANCE: return border.getWarningDistance();
case WARNING_TIME: return border.getWarningTime();
}
throw new IllegalArgumentException("Illegal BorderProperty: " + borderProperty);
}
示例7: handleWorldBorder
import org.bukkit.WorldBorder; //导入方法依赖的package包/类
@Nonnull
private static String handleWorldBorder(WorldBorder border) {
return "[size=" + border.getSize() + " " +
"center=" + border.getCenter().getBlockX() + "," + border.getCenter().getBlockY() + "," + border.getCenter().getBlockZ() + " " +
"dmgAmt=" + border.getDamageAmount() + "]";
}