本文整理汇总了Java中org.spongepowered.api.util.RespawnLocation类的典型用法代码示例。如果您正苦于以下问题:Java RespawnLocation类的具体用法?Java RespawnLocation怎么用?Java RespawnLocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RespawnLocation类属于org.spongepowered.api.util包,在下文中一共展示了RespawnLocation类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getDefault
import org.spongepowered.api.util.RespawnLocation; //导入依赖的package包/类
@Override
public Location<World> getDefault(Player target) {
WorldService service = Sponge.getServiceManager().provideUnchecked(WorldService.class);
Optional<Map<UUID, RespawnLocation>> optRespawnLocations = target.get(Keys.RESPAWN_LOCATIONS);
if (optRespawnLocations.isPresent()) {
BuildWorldWrapper buildWrapper = service.getEffectWrapper(BuildWorldWrapper.class).get();
UUID buildWorldId = buildWrapper.getPrimaryWorld().getUniqueId();
RespawnLocation targetLocation = optRespawnLocations.get().get(buildWorldId);
if (targetLocation != null) {
Optional<Location<World>> optLocation = targetLocation.asLocation();
if (optLocation.isPresent()) {
return optLocation.get();
}
}
}
return service.getEffectWrapper(MainWorldWrapper.class).get().getPrimaryWorld().getSpawnLocation();
}
开发者ID:Skelril,项目名称:Skree,代码行数:21,代码来源:RespawnServiceImpl.java
示例2: commandBed
import org.spongepowered.api.util.RespawnLocation; //导入依赖的package包/类
private CompletableFuture<Boolean> commandBed(final EPlayer player) {
Optional<Map<UUID, RespawnLocation>> spawn = player.get(Keys.RESPAWN_LOCATIONS);
if (spawn.isPresent()){
player.sendMessage(spawn.get().toString());
} else {
player.sendMessage("En attente d'implémentation");
}
return CompletableFuture.completedFuture(true);
}
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:10,代码来源:EEBed.java
示例3: serializeRespawnLocationTo
import org.spongepowered.api.util.RespawnLocation; //导入依赖的package包/类
private static DataView serializeRespawnLocationTo(DataView dataView, RespawnLocation respawnLocation) {
final Vector3d position = respawnLocation.getPosition();
return dataView
.set(RESPAWN_LOCATIONS_X, position.getX())
.set(RESPAWN_LOCATIONS_Y, position.getY())
.set(RESPAWN_LOCATIONS_Z, position.getZ())
.set(RESPAWN_LOCATIONS_FORCED, respawnLocation.isForced());
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:9,代码来源:UserStore.java
示例4: deserializeRespawnLocation
import org.spongepowered.api.util.RespawnLocation; //导入依赖的package包/类
private static RespawnLocation deserializeRespawnLocation(DataView dataView, UUID worldUUID, double x, double y, double z) {
boolean forced = dataView.getInt(RESPAWN_LOCATIONS_FORCED).orElse(0) > 0;
return RespawnLocation.builder()
.world(worldUUID)
.position(new Vector3d(x, y, z))
.forceSpawn(forced)
.build();
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:9,代码来源:UserStore.java
示例5: setBedSpawnLocation
import org.spongepowered.api.util.RespawnLocation; //导入依赖的package包/类
@Override
public void setBedSpawnLocation(Location location, boolean force) {
org.spongepowered.api.world.Location<?> spongeLoc = LocationConverter.of(location);
//noinspection ConstantConditions
if (force || spongeLoc.getBlockType() == BlockTypes.BED) {
UUID worldId = location.getWorld().getUID();
getHandle().get(Keys.RESPAWN_LOCATIONS).get()
.put(location.getWorld().getUID(), RespawnLocation.builder().position(VectorConverter.create3d(location)).world(worldId).build());
}
}
开发者ID:LapisBlue,项目名称:Pore,代码行数:11,代码来源:PorePlayer.java
示例6: RespawnLocationView
import org.spongepowered.api.util.RespawnLocation; //导入依赖的package包/类
public RespawnLocationView(RespawnLocation value) {
super(value);
loc = value.asLocation().orElse(null);
}
开发者ID:Valandur,项目名称:Web-API,代码行数:6,代码来源:RespawnLocationView.java
示例7: serializeValues
import org.spongepowered.api.util.RespawnLocation; //导入依赖的package包/类
@Override
public void serializeValues(T player, SimpleValueContainer valueContainer, DataView dataView) {
valueContainer.remove(Keys.IS_SPRINTING);
valueContainer.remove(Keys.IS_SNEAKING);
valueContainer.remove(LanternKeys.ACTIVE_HAND);
final DataView abilities = dataView.createView(ABILITIES);
abilities.set(FLYING, (byte) (valueContainer.remove(Keys.IS_FLYING).orElse(false) ? 1 : 0));
abilities.set(FLYING_SPEED, valueContainer.remove(Keys.FLYING_SPEED).orElse(0.1).floatValue());
abilities.set(CAN_FLY, (byte) (valueContainer.remove(Keys.CAN_FLY).orElse(false) ? 1 : 0));
final DataView spongeData = getOrCreateView(dataView, DataQueries.EXTENDED_SPONGE_DATA);
spongeData.set(FIRST_DATE_PLAYED, valueContainer.remove(Keys.FIRST_DATE_PLAYED).orElse(Instant.now()).toEpochMilli());
spongeData.set(LAST_DATE_PLAYED, valueContainer.remove(Keys.LAST_DATE_PLAYED).orElse(Instant.now()).toEpochMilli());
spongeData.set(UNIQUE_ID, player.getUniqueId().toString());
spongeData.set(Queries.CONTENT_VERSION, 1);
final Map<UUID, RespawnLocation> respawnLocations = valueContainer.remove(Keys.RESPAWN_LOCATIONS).get();
final List<DataView> respawnLocationViews = new ArrayList<>();
for (RespawnLocation respawnLocation : respawnLocations.values()) {
Lantern.getWorldManager().getWorldDimensionId(respawnLocation.getWorldUniqueId()).ifPresent(dimensionId -> {
// Overworld respawn location is saved in the root container
if (dimensionId == 0) {
serializeRespawnLocationTo(dataView, respawnLocation);
} else {
respawnLocationViews.add(serializeRespawnLocationTo(DataContainer.createNew(DataView.SafetyMode.NO_DATA_CLONED), respawnLocation)
.set(RESPAWN_LOCATIONS_DIMENSION, dimensionId));
}
});
}
dataView.set(RESPAWN_LOCATIONS, respawnLocationViews);
dataView.set(GAME_MODE, ((LanternGameMode) valueContainer.remove(Keys.GAME_MODE).orElse(GameModes.NOT_SET)).getInternalId());
dataView.set(SELECTED_ITEM_SLOT, player.getInventory().getHotbar().getSelectedSlotIndex());
dataView.set(SCORE, valueContainer.remove(LanternKeys.SCORE).get());
// Serialize the player inventory
dataView.set(INVENTORY, serializePlayerInventory(player.getInventory()));
// Serialize the ender chest inventory
dataView.set(ENDER_CHEST_INVENTORY, serializeEnderChest(player.getEnderChestInventory()));
final DataView recipeBook = dataView.createView(RECIPE_BOOK);
recipeBook.set(RECIPE_BOOK_FILTER_ACTIVE, (byte) (valueContainer.remove(LanternKeys.RECIPE_BOOK_FILTER_ACTIVE).orElse(false) ? 1 : 0));
recipeBook.set(RECIPE_BOOK_GUI_OPEN, (byte) (valueContainer.remove(LanternKeys.RECIPE_BOOK_GUI_OPEN).orElse(false) ? 1 : 0));
valueContainer.remove(LanternKeys.OPEN_ADVANCEMENT_TREE).ifPresent(o -> {
if (o.isPresent()) {
dataView.set(OPEN_ADVANCEMENT_TREE, o.get().getId());
}
});
super.serializeValues(player, valueContainer, dataView);
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:50,代码来源:UserStore.java
注:本文中的org.spongepowered.api.util.RespawnLocation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论