use of com.skelril.skree.service.HighScoreService in project Skree by Skelril.
the class WildernessWorldWrapper method onBlockBreak.
@Listener
public void onBlockBreak(ChangeBlockEvent.Break event, @Named(NamedCause.SOURCE) Entity srcEnt) {
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
for (Transaction<BlockSnapshot> block : transactions) {
BlockSnapshot original = block.getOriginal();
Optional<Location<World>> optLoc = original.getLocation();
if (!optLoc.isPresent()) {
continue;
}
Optional<Integer> optLevel = getLevel(optLoc.get());
if (!optLevel.isPresent()) {
continue;
}
int level = optLevel.get();
Location<World> loc = optLoc.get();
BlockState state = original.getState();
BlockType type = state.getType();
// Prevent item dupe glitch by removing the position before subsequent breaks
markedOrePoints.remove(loc);
if (config.getDropAmplificationConfig().amplifies(state) && !original.getCreator().isPresent()) {
markedOrePoints.add(loc);
if (srcEnt instanceof Player) {
Optional<HighScoreService> optHighScores = Sponge.getServiceManager().provide(HighScoreService.class);
optHighScores.ifPresent(highScoreService -> highScoreService.update((Player) srcEnt, ScoreTypes.WILDERNESS_ORES_MINED, 1));
}
}
if (srcEnt instanceof Player && type.equals(BlockTypes.STONE) && Probability.getChance(Math.max(12, 250 - level))) {
Vector3d max = loc.getPosition().add(1, 1, 1);
Vector3d min = loc.getPosition().sub(1, 1, 1);
Extent world = loc.getExtent();
if (Probability.getChance(3)) {
Entity entity = world.createEntity(EntityTypes.SILVERFISH, loc.getPosition().add(.5, 0, .5));
world.spawnEntity(entity, Cause.source(SpawnCause.builder().type(SpawnTypes.BLOCK_SPAWNING).build()).build());
}
// Do this one tick later to guarantee no collision with transaction data
Task.builder().delayTicks(1).execute(() -> {
for (int x = min.getFloorX(); x <= max.getFloorX(); ++x) {
for (int z = min.getFloorZ(); z <= max.getFloorZ(); ++z) {
for (int y = min.getFloorY(); y <= max.getFloorY(); ++y) {
if (!world.containsBlock(x, y, z)) {
continue;
}
if (world.getBlockType(x, y, z) == BlockTypes.STONE) {
world.setBlockType(x, y, z, BlockTypes.MONSTER_EGG, BlockChangeFlag.NONE, Cause.source(SkreePlugin.container()).build());
}
}
}
}
}).submit(SkreePlugin.inst());
}
}
}
use of com.skelril.skree.service.HighScoreService in project Skree by Skelril.
the class CatacombsInstance method spawnWave.
public void spawnWave() {
wave += getSpeed();
if (wave % 5 == 0) {
spawnBossWave();
} else {
spawnNormalWave();
}
for (Player player : getPlayers(SPECTATOR)) {
player.sendTitle(Title.builder().title(Text.of(TextColors.RED, "Wave")).subtitle(Text.of(TextColors.RED, wave)).fadeIn(20).fadeOut(20).build());
}
Optional<HighScoreService> optHighScores = Sponge.getServiceManager().provide(HighScoreService.class);
if (optHighScores.isPresent()) {
HighScoreService highScores = optHighScores.get();
for (Player player : getPlayers(PARTICIPANT)) {
highScores.update(player, ScoreTypes.HIGHEST_CATACOMB_WAVE, wave);
}
}
}
use of com.skelril.skree.service.HighScoreService in project Skree by Skelril.
the class TempleOfFateInstance method rewardPlayer.
public void rewardPlayer(Player player) {
boolean participated = participants.containsKey(player);
long startTime = participants.get(player);
remove(player);
if (!participated) {
return;
}
int seconds = (int) TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - startTime);
Optional<HighScoreService> optHighScores = Sponge.getServiceManager().provide(HighScoreService.class);
optHighScores.ifPresent(highScoreService -> highScoreService.update(player, ScoreTypes.FASTEST_TEMPLE_OF_FATE_RUN, seconds));
for (ItemStack stack : dropTable.getDrops(Probability.getRandom(3))) {
player.getInventory().offer(stack);
}
}
Aggregations