use of org.spongepowered.api.world.Location in project Skree by Skelril.
the class RespawnServiceImpl method getDefault.
@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();
}
use of org.spongepowered.api.world.Location in project Skree by Skelril.
the class RegionMarker method onBlockBreak.
@Listener
public void onBlockBreak(ChangeBlockEvent.Break event, @First Player player) {
Optional<RegionService> optService = Sponge.getServiceManager().provide(RegionService.class);
if (!optService.isPresent()) {
return;
}
RegionService service = optService.get();
for (Transaction<BlockSnapshot> block : event.getTransactions()) {
if (!block.isValid()) {
continue;
}
if (block.getOriginal().getState().getType() != this) {
continue;
}
Optional<Location<World>> optLoc = block.getOriginal().getLocation();
if (optLoc.isPresent()) {
Optional<Region> optRef = service.getMarkedRegion(optLoc.get());
if (optRef.isPresent()) {
Region ref = optRef.get();
if (ref.isMember(player)) {
ref.remPoint(new RegionPoint(optLoc.get().getPosition()));
player.sendMessage(Text.of(TextColors.YELLOW, "Region marker deleted!"));
}
}
}
}
}
use of org.spongepowered.api.world.Location in project Skree by Skelril.
the class RegionMaster method onBlockBreak.
@Listener
public void onBlockBreak(ChangeBlockEvent.Break event, @First Player player) {
Optional<RegionService> optService = Sponge.getServiceManager().provide(RegionService.class);
if (!optService.isPresent()) {
return;
}
RegionService service = optService.get();
for (Transaction<BlockSnapshot> block : event.getTransactions()) {
if (!block.isValid()) {
continue;
}
if (block.getOriginal().getState().getType() != this) {
continue;
}
Optional<Location<World>> optLoc = block.getOriginal().getLocation();
if (!optLoc.isPresent()) {
continue;
}
Optional<Region> optRef = service.getMarkedRegion(optLoc.get());
if (!optRef.isPresent()) {
continue;
}
Region ref = optRef.get();
if (!ref.getFullPoints().isEmpty()) {
block.setValid(false);
player.sendMessage(Text.of(TextColors.RED, "You must first delete all markers!"));
} else {
service.rem(optLoc.get());
player.sendMessage(Text.of(TextColors.YELLOW, "Region deleted!"));
}
}
}
use of org.spongepowered.api.world.Location in project Skree by Skelril.
the class PatientXInstance method spawnCreatures.
public void spawnCreatures() {
Zombie boss = getBoss().get();
Collection<Living> entities = getContained(Living.class);
if (entities.size() > 500) {
sendAttackBroadcast("Ring-a-round the rosie, a pocket full of posies...", AttackSeverity.NORMAL);
EntityHealthUtil.toFullHealth(boss);
for (Entity entity : entities) {
if (entity instanceof Player) {
entity.offer(Keys.HEALTH, 0D);
} else if (!entity.equals(boss)) {
entity.remove();
}
}
return;
}
double amt = getPlayers(PARTICIPANT).size() * difficulty;
Location l = getCenter();
for (int i = 0; i < amt; i++) {
Entity zombie = getRegion().getExtent().createEntity(EntityTypes.ZOMBIE, l.getPosition());
// TODO convert to Sponge Data API
((EntityZombie) zombie).setCanPickUpLoot(false);
((EntityZombie) zombie).setChild(true);
getRegion().getExtent().spawnEntity(zombie, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}
}
use of org.spongepowered.api.world.Location in project Skree by Skelril.
the class GoldRushInstance method findLeversAndFloodBlocks.
private void findLeversAndFloodBlocks() {
Vector3i min = flashMemoryRoom.getMinimumPoint();
Vector3i max = flashMemoryRoom.getMaximumPoint();
int minX = min.getX();
int minZ = min.getZ();
int minY = min.getY();
int maxX = max.getX();
int maxZ = max.getZ();
int maxY = max.getY();
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
for (int y = maxY; y >= minY; --y) {
BlockState state = getRegion().getExtent().getBlock(x, y, z);
if (state.getType() == BlockTypes.LEVER) {
Location<World> loc = new Location<>(getRegion().getExtent(), x, y, z);
loc.getExtent().setBlock(loc.getBlockPosition(), state.withTrait(BooleanTraits.LEVER_POWERED, false).orElse(state), Cause.source(SkreePlugin.container()).build());
leverBlocks.put(loc, !Probability.getChance(3));
for (int i = y; i < maxY; i++) {
BlockType type = getRegion().getExtent().getBlockType(x, i, z);
if (type == BlockTypes.AIR) {
floodBlocks.add(new Location<>(getRegion().getExtent(), x, i, z));
break;
}
}
// One lever a column only
break;
}
}
}
}
}
Aggregations