use of org.spongepowered.api.world.World in project Skree by Skelril.
the class ZoneRelativePositionListener method onBlockInteract.
@Listener
public void onBlockInteract(InteractBlockEvent.Secondary event, @First Player player) {
Optional<Location<World>> optLocation = event.getTargetBlock().getLocation();
if (!optLocation.isPresent()) {
return;
}
Location<World> location = optLocation.get();
Optional<T> optInst = getApplicable(location);
if (!optInst.isPresent()) {
return;
}
T inst = optInst.get();
Vector3i minPoint = inst.getRegion().getMinimumPoint();
Vector3i clickedPoint = location.getBlockPosition();
Vector3i offset = clickedPoint.sub(minPoint);
player.sendMessage(Text.of("Offset: ", offset));
}
use of org.spongepowered.api.world.World in project Skree by Skelril.
the class InstanceWorldWrapper method onLogin.
@Listener
public void onLogin(ClientConnectionEvent.Join event, @Getter("getTargetEntity") Player player) {
if (!isApplicable(player)) {
return;
}
Optional<WorldService> optWorldService = Sponge.getServiceManager().provide(WorldService.class);
if (!optWorldService.isPresent()) {
return;
}
WorldService worldService = optWorldService.get();
Collection<World> worlds = worldService.getEffectWrapper(MainWorldWrapper.class).get().getWorlds();
player.setLocation(worlds.iterator().next().getSpawnLocation());
}
use of org.spongepowered.api.world.World in project Skree by Skelril.
the class MainWorldWrapper method run.
@Override
public void run() {
PotionEffect speedEffect = PotionEffect.builder().duration(3 * 20).amplifier(5).particles(false).potionType(PotionEffectTypes.SPEED).build();
for (World world : getWorlds()) {
for (Entity entity : world.getEntities(p -> p.getType().equals(EntityTypes.PLAYER))) {
if (entity.get(Keys.GAME_MODE).orElse(GameModes.CREATIVE) != GameModes.SURVIVAL) {
continue;
}
List<PotionEffect> potionEffects = entity.getOrElse(Keys.POTION_EFFECTS, new ArrayList<>(1));
potionEffects.add(speedEffect);
entity.offer(Keys.POTION_EFFECTS, potionEffects);
}
}
}
use of org.spongepowered.api.world.World in project Skree by Skelril.
the class RegionManager method cleanup.
public int cleanup() {
Optional<World> optWorld = Sponge.getServer().getWorld(worldName);
int total = 0;
if (optWorld.isPresent()) {
World world = optWorld.get();
for (CachedRegion region : regionList) {
List<RegionPoint> toRemove = new ArrayList<>();
for (RegionPoint point : region.getFullPoints()) {
BlockType type = world.getBlockType(point.toInt());
if (type != CustomBlockTypes.REGION_MASTER && type != CustomBlockTypes.REGION_MARKER) {
++total;
toRemove.add(point);
}
}
region.remPoint(toRemove);
}
}
return total;
}
use of org.spongepowered.api.world.World in project Skree by Skelril.
the class DropClearServiceImpl method onItemSpawn.
@Listener(order = Order.POST)
public void onItemSpawn(SpawnEntityEvent event) {
long spawnedCount = event.getEntities().stream().filter(DropClearServiceImpl.CHECK_PREDICATE).count();
World targetWorld = event.getTargetWorld();
long newCount = entityCount.merge(targetWorld, spawnedCount, (a, b) -> a + b);
if (newCount > autoAmt) {
checkedCleanup(targetWorld);
}
}
Aggregations