本文整理汇总了Java中org.spongepowered.api.world.WorldBorder类的典型用法代码示例。如果您正苦于以下问题:Java WorldBorder类的具体用法?Java WorldBorder怎么用?Java WorldBorder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WorldBorder类属于org.spongepowered.api.world包,在下文中一共展示了WorldBorder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: randomLocation
import org.spongepowered.api.world.WorldBorder; //导入依赖的package包/类
private Optional<Location<World>> randomLocation(Player player, int searchDiameter){
Location<World> playerLocation = player.getLocation();
//Adding world border support, otherwise you could murder players by using a location within the border.
WorldBorder border = player.getWorld().getWorldBorder();
Vector3d center = border.getCenter();
double diameter = Math.min(border.getDiameter(), searchDiameter);
double radius = border.getDiameter() / 2;
Random rand = new Random();
int x = (int) (rand.nextInt((int) (center.getX()+diameter)) - radius);
int y = rand.nextInt(256);
int z = rand.nextInt((int) (rand.nextInt((int) (center.getZ()+diameter)) - radius));
Location<World> randLocation = new Location<World>(playerLocation.getExtent(), x, y, z);
TeleportHelper teleportHelper = Sponge.getGame().getTeleportHelper();
return teleportHelper.getSafeLocation(randLocation);
}
开发者ID:hsyyid,项目名称:EssentialCmds,代码行数:17,代码来源:RTPExecutor.java
示例2: info
import org.spongepowered.api.world.WorldBorder; //导入依赖的package包/类
@Command(desc = "Shows information about the world border", alias = "get")
public void info(CommandSource context, @Default World world)
{
WorldBorder border = world.getWorldBorder();
double diameter = border.getDiameter();
i18n.send(context, POSITIVE, "The world border in {world} is currently {} blocks wide", world,
diameter);
long secondsRemaining = border.getTimeRemaining() / 1000;
if (secondsRemaining != 0)
{
double newDiameter = border.getNewDiameter();
if (newDiameter < diameter)
{
i18n.send(context, POSITIVE, "Currently shrinking to {} blocks wide over {} seconds",
newDiameter, secondsRemaining);
}
else
{
i18n.send(context, POSITIVE, "Currently growing to {} blocks wide over {} seconds",
newDiameter, secondsRemaining);
}
}
i18n.send(context, POSITIVE, "Warnings will show within {} seconds or {} blocks from the border", border.getWarningTime(), border.getWarningDistance());
i18n.send(context, POSITIVE, "When more than {} blocks outside the border players will take {} damage per block per second", border.getDamageThreshold(), border.getDamageAmount());
}
开发者ID:CubeEngine,项目名称:modules-main,代码行数:26,代码来源:BorderCommands.java
示例3: join
import org.spongepowered.api.world.WorldBorder; //导入依赖的package包/类
@Listener
public void join(final ClientConnectionEvent.Login event)
{
Transform<World> playerLoc = event.getToTransform();
WorldBorder border = playerLoc.getExtent().getWorldBorder();
Vector3d center = border.getCenter();
double radius = border.getDiameter() / 2;
double minX = center.getX() - radius;
double maxX = center.getX() + radius;
double minZ = center.getZ() - radius;
double maxZ = center.getZ() + radius;
double playerX = playerLoc.getLocation().getPosition().getX();
double playerZ = playerLoc.getLocation().getPosition().getZ();
if (playerX > maxX || playerX < minX || playerZ > maxZ || playerZ < minZ)
{
event.setToTransform(event.getToTransform().setLocation(playerLoc.getExtent().getSpawnLocation()));
}
}
开发者ID:CubeEngine,项目名称:modules-main,代码行数:20,代码来源:SpawnFixListener.java
示例4: CachedWorldBorder
import org.spongepowered.api.world.WorldBorder; //导入依赖的package包/类
public CachedWorldBorder(WorldBorder border) {
super(null);
this.center = border.getCenter().clone();
this.diameter = border.getDiameter();
this.damageAmount = border.getDamageAmount();
this.damageThreshold = border.getDamageThreshold();
this.newDiameter = border.getNewDiameter();
this.timeRemaining = border.getTimeRemaining();
this.warningDistance = border.getWarningDistance();
this.warningTime = border.getWarningTime();
}
开发者ID:Valandur,项目名称:Web-API,代码行数:13,代码来源:CachedWorldBorder.java
示例5: from
import org.spongepowered.api.world.WorldBorder; //导入依赖的package包/类
@Override
public WorldBorder.Builder from(WorldBorder border) {
this.diameter = border.getDiameter();
this.center = border.getCenter();
this.warningTime = border.getWarningTime();
this.warningDistance = border.getWarningDistance();
this.damageThreshold = border.getDamageThreshold();
this.damageAmount = border.getDamageAmount();
return this;
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:11,代码来源:LanternWorldBorderBuilder.java
示例6: build
import org.spongepowered.api.world.WorldBorder; //导入依赖的package包/类
@Override
public WorldBorder build() throws IllegalStateException {
final LanternWorldBorder border = new LanternWorldBorder();
border.setCenter(this.center.getX(), this.center.getZ());
border.setDamageAmount(this.damageAmount);
border.setDamageThreshold(this.damageThreshold);
border.setDiameter(this.diameter);
border.setWarningDistance(this.warningDistance);
border.setWarningTime(this.warningTime);
return border;
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:12,代码来源:LanternWorldBorderBuilder.java
示例7: reset
import org.spongepowered.api.world.WorldBorder; //导入依赖的package包/类
@Override
public WorldBorder.Builder reset() {
this.center = Vector3d.ZERO;
this.damageAmount = 0;
this.damageThreshold = 0;
this.diameter = 0;
this.warningDistance = 0;
this.warningTime = 0;
return this;
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:11,代码来源:LanternWorldBorderBuilder.java
示例8: execute
import org.spongepowered.api.world.WorldBorder; //导入依赖的package包/类
@Override
public void execute(SurvivalGame survivalGame) throws TextMessageException {
Integer xMin = null;
Integer xMax = null;
Integer zMin = null;
Integer zMax = null;
for (Vector3d spawn : survivalGame.getConfig().getSpawnPoints()) {
if (xMin == null) {
xMin = spawn.getFloorX();
} else {
xMin = Math.min(xMin, spawn.getFloorX());
}
if (xMax == null) {
xMax = spawn.getFloorX();
} else {
xMax = Math.max(xMax, spawn.getFloorX());
}
if (zMin == null) {
zMin = spawn.getFloorZ();
} else {
zMin = Math.min(zMin, spawn.getFloorZ());
}
if (zMax == null) {
zMax = spawn.getFloorZ();
} else {
zMax = Math.max(zMax, spawn.getFloorZ());
}
}
if (xMin != null) {
String worldName =
getOrThrow(survivalGame.getConfig().getWorldName(), CommandKeys.WORLD_NAME);
World world = getOrThrow(Sponge.getServer().getWorld(worldName), CommandKeys.WORLD);
WorldBorder worldBorder = world.getWorldBorder();
double diameter = Double.max(abs(xMax - xMin), abs(zMax - zMin));
worldBorder.setDiameter(diameter);
}
}
开发者ID:m0pt0pmatt,项目名称:SurvivalGames,代码行数:39,代码来源:CreateDeathmatchBorderTask.java
示例9: execute
import org.spongepowered.api.world.WorldBorder; //导入依赖的package包/类
@Override
public void execute(SurvivalGame survivalGame) throws TextMessageException {
String worldName =
getOrThrow(survivalGame.getConfig().getWorldName(), CommandKeys.WORLD_NAME);
World world = getOrThrow(Sponge.getServer().getWorld(worldName), CommandKeys.WORLD);
WorldBorder worldBorder = world.getWorldBorder();
Vector3d center =
getOrThrow(survivalGame.getConfig().getCenterVector(), CommandKeys.CENTER_VECTOR);
worldBorder.setCenter(center.getX(), center.getZ());
Vector3d lesserBoundaryVector =
getOrThrow(
survivalGame.getConfig().getBlockArea().getLesserBoundary(),
CommandKeys.LESSER_BOUNDARY);
Vector3d greaterBoundaryVector =
getOrThrow(
survivalGame.getConfig().getBlockArea().getGreaterBoundary(),
CommandKeys.GREATER_BOUNDARY);
double diameter =
Double.max(
abs(greaterBoundaryVector.getX() - lesserBoundaryVector.getX()),
abs(greaterBoundaryVector.getZ() - lesserBoundaryVector.getZ()));
double xMiddle = lesserBoundaryVector.getX() + (diameter / 2);
double zMiddle = lesserBoundaryVector.getZ() + (diameter / 2);
worldBorder.setCenter(xMiddle, zMiddle);
worldBorder.setDiameter(diameter);
worldBorder.setWarningDistance(0);
}
开发者ID:m0pt0pmatt,项目名称:SurvivalGames,代码行数:34,代码来源:CreateWorldBorderTask.java
示例10: of
import org.spongepowered.api.world.WorldBorder; //导入依赖的package包/类
public static PoreWorldBorder of(WorldBorder handle, PoreWorld world) {
PoreWorldBorder wb = WrapperConverter.of(PoreWorldBorder.class, handle);
if (wb != null && wb.world == null) { // not very efficient but I'm not sure there's a cleaner solution
wb.world = world;
}
return wb;
}
开发者ID:LapisBlue,项目名称:Pore,代码行数:8,代码来源:PoreWorldBorder.java
示例11: getWorldBorder
import org.spongepowered.api.world.WorldBorder; //导入依赖的package包/类
@Override
public Optional<WorldBorder> getWorldBorder() {
return this.player.getWorldBorder();
}
开发者ID:EverCraft,项目名称:EverAPI,代码行数:5,代码来源:PlayerSponge.java
示例12: setWorldBorder
import org.spongepowered.api.world.WorldBorder; //导入依赖的package包/类
@Override
public void setWorldBorder(WorldBorder border, Cause cause) {
this.player.setWorldBorder(border, cause);
}
开发者ID:EverCraft,项目名称:EverAPI,代码行数:5,代码来源:PlayerSponge.java
示例13: Builder
import org.spongepowered.api.world.WorldBorder; //导入依赖的package包/类
public Builder(World world, WorldBorder worldBorder) {
this(world, worldBorder.getCenter(), worldBorder.getNewDiameter());
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:4,代码来源:LanternChunkPreGenerateTask.java
示例14: center
import org.spongepowered.api.world.WorldBorder; //导入依赖的package包/类
@Override
public WorldBorder.Builder center(double x, double z) {
this.center = new Vector3d(x, 0, z);
return this;
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:6,代码来源:LanternWorldBorderBuilder.java
示例15: warningTime
import org.spongepowered.api.world.WorldBorder; //导入依赖的package包/类
@Override
public WorldBorder.Builder warningTime(int time) {
this.warningTime = time;
return this;
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:6,代码来源:LanternWorldBorderBuilder.java
示例16: warningDistance
import org.spongepowered.api.world.WorldBorder; //导入依赖的package包/类
@Override
public WorldBorder.Builder warningDistance(int distance) {
this.warningDistance = distance;
return this;
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:6,代码来源:LanternWorldBorderBuilder.java
示例17: damageThreshold
import org.spongepowered.api.world.WorldBorder; //导入依赖的package包/类
@Override
public WorldBorder.Builder damageThreshold(double distance) {
this.damageThreshold = distance;
return this;
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:6,代码来源:LanternWorldBorderBuilder.java
示例18: damageAmount
import org.spongepowered.api.world.WorldBorder; //导入依赖的package包/类
@Override
public WorldBorder.Builder damageAmount(double damage) {
this.damageAmount = damage;
return this;
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:6,代码来源:LanternWorldBorderBuilder.java
示例19: getWorldBorder
import org.spongepowered.api.world.WorldBorder; //导入依赖的package包/类
@Override
public Optional<WorldBorder> getWorldBorder() {
return Optional.ofNullable(this.worldBorder);
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:LanternPlayer.java
示例20: getWorldBorder
import org.spongepowered.api.world.WorldBorder; //导入依赖的package包/类
@Override public WorldBorder getWorldBorder() {
return null;
}
开发者ID:InspireNXE,项目名称:Pulse,代码行数:4,代码来源:ServerWorld.java
注:本文中的org.spongepowered.api.world.WorldBorder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论