use of com.skelril.skree.service.ModifierService in project Skree by Skelril.
the class ModifierNotifier method onPlayerJoin.
@Listener
public void onPlayerJoin(ClientConnectionEvent.Join event) {
Optional<ModifierService> optService = Sponge.getServiceManager().provide(ModifierService.class);
if (!optService.isPresent()) {
return;
}
ModifierService service = optService.get();
List<String> messages = new ArrayList<>();
for (Map.Entry<String, Long> entry : service.getActiveModifiers().entrySet()) {
String friendlyName = StringUtils.capitalize(entry.getKey().replace("_", " ").toLowerCase());
String friendlyTime = PrettyText.date(entry.getValue());
messages.add(" - " + friendlyName + " till " + friendlyTime);
}
if (messages.isEmpty())
return;
messages.sort(String.CASE_INSENSITIVE_ORDER);
messages.add(0, "\n\nThe following donation perks are enabled:");
Player player = event.getTargetEntity();
Task.builder().execute(() -> {
for (String message : messages) {
player.sendMessage(Text.of(TextColors.GOLD, message));
}
}).delay(1, TimeUnit.SECONDS).submit(SkreePlugin.inst());
}
use of com.skelril.skree.service.ModifierService in project Skree by Skelril.
the class ArrowFishingHandler method onProjectileTickEvent.
@Listener
public void onProjectileTickEvent(ProjectileTickEvent event) {
Projectile projectile = event.getTargetEntity();
if (!(projectile instanceof Arrow) || Probability.getChance(3)) {
return;
}
Location<World> loc = projectile.getLocation();
if (MultiTypeRegistry.isWater(loc.getBlockType()) && checkVelocity(projectile.getVelocity())) {
ProjectileSource source = projectile.getShooter();
double modifier = 1;
if (source instanceof Living) {
modifier = 50;
}
Optional<ModifierService> optService = Sponge.getServiceManager().provide(ModifierService.class);
int rolls = 1;
if (optService.isPresent() && optService.get().isActive(UBER_ARROW_FISHING)) {
if (source instanceof Living) {
rolls = 15;
} else {
rolls = 5;
}
}
new ItemDropper(loc).dropStacks(dropTable.getDrops(rolls, modifier), SpawnTypes.DROPPED_ITEM);
}
}
Aggregations