2014-03-28 23:07:48 +01:00
|
|
|
package com.gmail.nossr50.runnables.skills;
|
|
|
|
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.Sound;
|
2014-04-01 15:36:40 +02:00
|
|
|
import org.bukkit.Statistic;
|
2014-03-28 23:07:48 +01:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
|
|
|
|
|
|
|
import com.gmail.nossr50.mcMMO;
|
|
|
|
import com.gmail.nossr50.util.HolidayManager;
|
|
|
|
import com.gmail.nossr50.util.Misc;
|
|
|
|
|
|
|
|
public class AprilTask extends BukkitRunnable {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
if (!mcMMO.getHolidayManager().isAprilFirst()) {
|
|
|
|
this.cancel();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
2014-04-01 15:36:40 +02:00
|
|
|
int random = Misc.getRandom().nextInt(40) + 11;
|
2014-03-28 23:07:48 +01:00
|
|
|
int betterRandom = Misc.getRandom().nextInt(2000);
|
|
|
|
if (betterRandom == 0) {
|
|
|
|
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
|
|
|
player.sendMessage(unknown("superskill") + " skill increased by 1. Total (" + unknown("12") + ")");
|
|
|
|
fireworksShow(player);
|
|
|
|
}
|
|
|
|
|
2014-04-01 15:36:40 +02:00
|
|
|
for (Statistic statistic : mcMMO.getHolidayManager().movementStatistics) {
|
|
|
|
if (player.getStatistic(statistic) > 0 && player.getStatistic(statistic) % random == 0) {
|
|
|
|
mcMMO.getHolidayManager().levelUpApril(player, HolidayManager.FakeSkillType.getByStatistic(statistic));
|
2014-03-28 23:07:48 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void fireworksShow(final Player player) {
|
|
|
|
final int firework_amount = 10;
|
|
|
|
for (int i = 0; i < firework_amount; i++) {
|
|
|
|
int delay = (int) (Misc.getRandom().nextDouble() * 3 * Misc.TICK_CONVERSION_FACTOR) + 4;
|
|
|
|
mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
mcMMO.getHolidayManager().spawnFireworks(player);
|
|
|
|
}
|
|
|
|
}, delay);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private String unknown(String string) {
|
|
|
|
return ChatColor.MAGIC + string + ChatColor.RESET + ChatColor.YELLOW;
|
|
|
|
}
|
|
|
|
}
|