2013-01-11 22:31:21 +01:00
|
|
|
package com.gmail.nossr50.util;
|
|
|
|
|
2018-07-24 04:13:57 +02:00
|
|
|
import com.gmail.nossr50.commands.skills.AprilCommand;
|
2019-04-01 19:16:43 +02:00
|
|
|
import com.gmail.nossr50.config.Config;
|
2019-01-14 06:48:38 +01:00
|
|
|
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
2020-04-01 15:40:29 +02:00
|
|
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
2019-01-13 08:54:53 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
2019-01-14 06:48:38 +01:00
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
2018-07-24 04:13:57 +02:00
|
|
|
import com.gmail.nossr50.mcMMO;
|
2019-01-14 06:48:38 +01:00
|
|
|
import com.gmail.nossr50.util.player.NotificationManager;
|
2018-07-24 04:13:57 +02:00
|
|
|
import com.gmail.nossr50.util.player.UserManager;
|
2019-01-13 04:08:54 +01:00
|
|
|
import com.gmail.nossr50.util.sounds.SoundManager;
|
|
|
|
import com.gmail.nossr50.util.sounds.SoundType;
|
2018-07-24 04:13:57 +02:00
|
|
|
import com.google.common.collect.ImmutableList;
|
2019-04-01 19:04:45 +02:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.Color;
|
|
|
|
import org.bukkit.Statistic;
|
2013-01-11 22:31:21 +01:00
|
|
|
import org.bukkit.command.CommandSender;
|
2014-03-28 23:07:48 +01:00
|
|
|
import org.bukkit.command.PluginCommand;
|
2013-01-11 22:31:21 +01:00
|
|
|
import org.bukkit.entity.Player;
|
2014-04-01 15:36:40 +02:00
|
|
|
import org.bukkit.event.player.PlayerStatisticIncrementEvent;
|
2013-01-14 00:20:41 +01:00
|
|
|
|
2018-07-24 04:13:57 +02:00
|
|
|
import java.io.*;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.regex.Pattern;
|
2013-01-11 22:31:21 +01:00
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
public final class HolidayManager {
|
2020-07-13 20:39:03 +02:00
|
|
|
private final ArrayList<String> hasCelebrated;
|
|
|
|
private final int currentYear;
|
2014-03-28 23:07:48 +01:00
|
|
|
private static final int START_YEAR = 2011;
|
2013-01-11 22:31:21 +01:00
|
|
|
|
2013-10-18 17:18:29 +02:00
|
|
|
private static final List<Color> ALL_COLORS;
|
|
|
|
private static final List<ChatColor> ALL_CHAT_COLORS;
|
|
|
|
private static final List<ChatColor> CHAT_FORMATS;
|
|
|
|
|
2014-03-28 23:07:48 +01:00
|
|
|
public enum FakeSkillType {
|
|
|
|
MACHO,
|
|
|
|
JUMPING,
|
|
|
|
THROWING,
|
|
|
|
WRECKING,
|
|
|
|
CRAFTING,
|
|
|
|
WALKING,
|
|
|
|
SWIMMING,
|
|
|
|
FALLING,
|
|
|
|
CLIMBING,
|
|
|
|
FLYING,
|
|
|
|
DIVING,
|
|
|
|
PIGGY,
|
|
|
|
UNKNOWN;
|
|
|
|
|
|
|
|
public static FakeSkillType getByName(String skillName) {
|
|
|
|
for (FakeSkillType type : values()) {
|
|
|
|
if (type.name().equalsIgnoreCase(skillName)) {
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2014-04-01 15:36:40 +02:00
|
|
|
|
|
|
|
public static FakeSkillType getByStatistic(Statistic statistic) {
|
|
|
|
switch (statistic) {
|
|
|
|
case DAMAGE_TAKEN:
|
|
|
|
return FakeSkillType.MACHO;
|
|
|
|
case JUMP:
|
|
|
|
return FakeSkillType.JUMPING;
|
|
|
|
case DROP:
|
|
|
|
return FakeSkillType.THROWING;
|
|
|
|
case MINE_BLOCK:
|
|
|
|
case BREAK_ITEM:
|
|
|
|
return FakeSkillType.WRECKING;
|
|
|
|
case CRAFT_ITEM:
|
|
|
|
return FakeSkillType.CRAFTING;
|
|
|
|
case WALK_ONE_CM:
|
|
|
|
return FakeSkillType.WALKING;
|
|
|
|
case SWIM_ONE_CM:
|
|
|
|
return FakeSkillType.SWIMMING;
|
|
|
|
case FALL_ONE_CM:
|
|
|
|
return FakeSkillType.FALLING;
|
|
|
|
case CLIMB_ONE_CM:
|
|
|
|
return FakeSkillType.CLIMBING;
|
|
|
|
case FLY_ONE_CM:
|
|
|
|
return FakeSkillType.FLYING;
|
2018-07-24 04:13:57 +02:00
|
|
|
case WALK_UNDER_WATER_ONE_CM:
|
2014-04-01 15:36:40 +02:00
|
|
|
return FakeSkillType.DIVING;
|
|
|
|
case PIG_ONE_CM:
|
|
|
|
return FakeSkillType.PIGGY;
|
|
|
|
default:
|
|
|
|
return FakeSkillType.UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
2014-03-28 23:07:48 +01:00
|
|
|
}
|
|
|
|
|
2014-04-01 15:36:40 +02:00
|
|
|
public final Set<Statistic> movementStatistics = EnumSet.of(
|
|
|
|
Statistic.WALK_ONE_CM, Statistic.SWIM_ONE_CM, Statistic.FALL_ONE_CM,
|
2018-07-24 04:13:57 +02:00
|
|
|
Statistic.CLIMB_ONE_CM, Statistic.FLY_ONE_CM, Statistic.WALK_UNDER_WATER_ONE_CM,
|
2014-04-01 15:36:40 +02:00
|
|
|
Statistic.PIG_ONE_CM);
|
|
|
|
|
2013-10-18 17:18:29 +02:00
|
|
|
static {
|
|
|
|
List<Color> colors = new ArrayList<Color>();
|
|
|
|
List<ChatColor> chatColors = new ArrayList<ChatColor>();
|
|
|
|
List<ChatColor> chatFormats = new ArrayList<ChatColor>();
|
|
|
|
|
|
|
|
for (ChatColor color : ChatColor.values()) {
|
|
|
|
if (color.isColor()) {
|
|
|
|
chatColors.add(color);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
chatFormats.add(color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-01 19:04:45 +02:00
|
|
|
// for (DyeColor color : DyeColor.values()) {
|
|
|
|
// colors.add(color.getFireworkColor());
|
|
|
|
// }
|
2013-10-18 17:18:29 +02:00
|
|
|
|
|
|
|
Collections.shuffle(chatColors, Misc.getRandom());
|
|
|
|
Collections.shuffle(colors, Misc.getRandom());
|
|
|
|
Collections.shuffle(chatFormats, Misc.getRandom());
|
|
|
|
|
|
|
|
ALL_CHAT_COLORS = ImmutableList.copyOf(chatColors);
|
|
|
|
ALL_COLORS = ImmutableList.copyOf(colors);
|
|
|
|
CHAT_FORMATS = ImmutableList.copyOf(chatFormats);
|
|
|
|
}
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
// This gets called onEnable
|
2014-01-12 12:08:47 +01:00
|
|
|
public HolidayManager() {
|
2014-01-19 11:49:30 +01:00
|
|
|
currentYear = Calendar.getInstance().get(Calendar.YEAR);
|
2014-01-12 12:08:47 +01:00
|
|
|
|
2014-01-19 11:49:30 +01:00
|
|
|
File anniversaryFile = new File(mcMMO.getFlatFileDirectory(), "anniversary." + currentYear + ".yml");
|
2013-01-11 22:31:21 +01:00
|
|
|
|
|
|
|
if (!anniversaryFile.exists()) {
|
|
|
|
try {
|
|
|
|
anniversaryFile.createNewFile();
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
catch (IOException ex) {
|
2013-02-13 04:18:47 +01:00
|
|
|
mcMMO.p.getLogger().severe(ex.toString());
|
2013-01-11 22:31:21 +01:00
|
|
|
}
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-01-11 22:31:21 +01:00
|
|
|
hasCelebrated = new ArrayList<String>();
|
|
|
|
|
|
|
|
try {
|
|
|
|
hasCelebrated.clear();
|
2014-01-12 12:08:47 +01:00
|
|
|
BufferedReader reader = new BufferedReader(new FileReader(anniversaryFile.getPath()));
|
2013-01-11 22:31:21 +01:00
|
|
|
String line = reader.readLine();
|
|
|
|
|
|
|
|
while (line != null) {
|
|
|
|
hasCelebrated.add(line);
|
|
|
|
line = reader.readLine();
|
|
|
|
}
|
|
|
|
|
|
|
|
reader.close();
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
catch (Exception ex) {
|
2013-02-13 04:18:47 +01:00
|
|
|
mcMMO.p.getLogger().severe(ex.toString());
|
2013-01-11 22:31:21 +01:00
|
|
|
}
|
2014-01-12 12:08:47 +01:00
|
|
|
|
|
|
|
cleanupFiles();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void cleanupFiles() {
|
|
|
|
File FlatFileDir = new File(mcMMO.getFlatFileDirectory());
|
|
|
|
File legacy = new File(FlatFileDir, "anniversary.yml");
|
|
|
|
List<File> toDelete = new ArrayList<File>();
|
|
|
|
|
|
|
|
if (legacy.exists()) {
|
|
|
|
toDelete.add(legacy);
|
|
|
|
}
|
|
|
|
|
|
|
|
Pattern pattern = Pattern.compile("anniversary\\.(?:.+)\\.yml");
|
|
|
|
|
|
|
|
for (String fileName : FlatFileDir.list()) {
|
2014-01-19 11:49:30 +01:00
|
|
|
if (!pattern.matcher(fileName).matches() || fileName.equals("anniversary." + currentYear + ".yml")) {
|
2014-01-12 12:08:47 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
File file = new File(FlatFileDir, fileName);
|
|
|
|
|
|
|
|
if (file.isDirectory()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
toDelete.add(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (File file : toDelete) {
|
2014-01-19 11:49:30 +01:00
|
|
|
if (file.delete()) {
|
|
|
|
mcMMO.p.debug("Deleted: " + file.getName());
|
|
|
|
}
|
2014-01-12 12:08:47 +01:00
|
|
|
}
|
2013-01-11 22:31:21 +01:00
|
|
|
}
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
// This gets called onDisable
|
2014-01-12 12:08:47 +01:00
|
|
|
public void saveAnniversaryFiles() {
|
2014-01-18 16:58:49 +01:00
|
|
|
mcMMO.p.debug("Saving anniversary files...");
|
2014-01-19 11:49:30 +01:00
|
|
|
String anniversaryFilePath = mcMMO.getFlatFileDirectory() + "anniversary." + currentYear + ".yml";
|
2014-01-12 12:08:47 +01:00
|
|
|
|
2013-01-14 00:20:41 +01:00
|
|
|
try {
|
2013-10-18 16:24:01 +02:00
|
|
|
BufferedWriter writer = new BufferedWriter(new FileWriter(anniversaryFilePath));
|
2013-01-14 00:20:41 +01:00
|
|
|
for (String player : hasCelebrated) {
|
|
|
|
writer.write(player);
|
|
|
|
writer.newLine();
|
2013-01-11 22:31:21 +01:00
|
|
|
}
|
2013-01-14 00:20:41 +01:00
|
|
|
writer.close();
|
2013-01-11 22:31:21 +01:00
|
|
|
}
|
2013-01-14 00:20:41 +01:00
|
|
|
catch (Exception ex) {
|
2013-02-13 04:18:47 +01:00
|
|
|
mcMMO.p.getLogger().severe(ex.toString());
|
2013-01-14 00:20:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
// This gets called from /mcmmo command
|
2014-01-12 12:08:47 +01:00
|
|
|
public void anniversaryCheck(final CommandSender sender) {
|
2014-01-19 11:49:30 +01:00
|
|
|
GregorianCalendar anniversaryStart = new GregorianCalendar(currentYear, Calendar.FEBRUARY, 3);
|
|
|
|
GregorianCalendar anniversaryEnd = new GregorianCalendar(currentYear, Calendar.FEBRUARY, 6);
|
2013-05-29 19:58:32 +02:00
|
|
|
GregorianCalendar day = new GregorianCalendar();
|
2013-01-11 22:31:21 +01:00
|
|
|
|
2013-05-29 19:58:32 +02:00
|
|
|
if (hasCelebrated.contains(sender.getName())) {
|
|
|
|
return;
|
|
|
|
}
|
2013-10-01 22:14:29 +02:00
|
|
|
|
2013-10-03 22:04:39 +02:00
|
|
|
if (!getDateRange(day.getTime(), anniversaryStart.getTime(), anniversaryEnd.getTime())) {
|
2013-10-01 22:14:29 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-01-14 06:48:38 +01:00
|
|
|
sender.sendMessage(LocaleLoader.getString("Holiday.Anniversary", (currentYear - START_YEAR)));
|
2019-04-01 19:04:45 +02:00
|
|
|
/*if (sender instanceof Player) {
|
2013-10-01 22:14:29 +02:00
|
|
|
final int firework_amount = 10;
|
|
|
|
for (int i = 0; i < firework_amount; i++) {
|
2013-10-18 17:18:29 +02:00
|
|
|
int delay = (int) (Misc.getRandom().nextDouble() * 3 * Misc.TICK_CONVERSION_FACTOR) + 4;
|
2013-10-01 22:14:29 +02:00
|
|
|
mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
spawnFireworks((Player) sender);
|
|
|
|
}
|
|
|
|
}, delay);
|
2013-01-11 22:31:21 +01:00
|
|
|
}
|
2019-04-01 19:04:45 +02:00
|
|
|
}*/
|
|
|
|
// else {
|
2013-05-29 19:58:32 +02:00
|
|
|
/*
|
|
|
|
* Credit: http://www.geocities.com/spunk1111/
|
|
|
|
* (good luck finding that in 3 years heh)
|
|
|
|
* .''. . *''* :_\/_: .
|
|
|
|
* :_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'.
|
|
|
|
* .''.: /\ : /)\ ':'* /\ * : '..'. -=:o:=-
|
|
|
|
* :_\/_:'.:::. ' *''* * '.\'/.'_\(/_ '.':'.'
|
|
|
|
* : /\ : ::::: *_\/_* -= o =- /)\ '
|
|
|
|
* '..' ':::' * /\ * .'/.\'. ' *
|
|
|
|
* * *..* : *
|
|
|
|
* * * *
|
|
|
|
* * * *
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Color map
|
|
|
|
* AAAA D GGGG JJJJJJ K
|
|
|
|
* AAAAAA DDDDD EEEGGGGGG JJJJJJ KKKKKKK
|
|
|
|
* BBBBAAAAAA DDD EEEGGGGGG I JJJJJ KKKKKKK
|
|
|
|
* BBBBBBACCCCC D FFFF G IIIIIIIHHHHH KKKKKKK
|
|
|
|
* BBBBBB CCCCC FFFFFF IIIIIII HHH K
|
|
|
|
* BBBB CCCCC FFFFFF IIIIIII H k
|
|
|
|
* b FFFF I k
|
|
|
|
* b i k
|
|
|
|
* b i k
|
|
|
|
*/
|
2013-10-18 17:18:29 +02:00
|
|
|
Object[] colorParams = new Object[]{chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose()};
|
2013-10-01 22:14:29 +02:00
|
|
|
sender.sendMessage(String.format(" %1$s.''. %4$s. %7$s*''* %10$s:_\\/_: %11$s.", colorParams));
|
|
|
|
sender.sendMessage(String.format(" %1$s:_\\/_: %4$s_\\(/_ %5$s.:.%7$s*_\\/_* %10$s: /\\ : %11$s.'.:.'.", colorParams));
|
|
|
|
sender.sendMessage(String.format(" %2$s.''.%1$s: /\\ : %4$s/)\\ %5$s':'%7$s* /\\ * %9$s: %10$s'..'. %11$s-=:o:=-", colorParams));
|
|
|
|
sender.sendMessage(String.format("%2$s:_\\/_:%1$s'%3$s.:::. %4$s' %6$s*''* %7$s* %9$s'.\\'/.'%8$s_\\(/_ %11$s'.':'.'", colorParams));
|
|
|
|
sender.sendMessage(String.format("%2$s: /\\ : %3$s::::: %6$s*_\\/_* %9$s-= o =-%8$s /)\\ %11$s'", colorParams));
|
|
|
|
sender.sendMessage(String.format(" %2$s'..' %3$s':::' %6$s* /\\ * %9$s.'/.\\'. %8$s' %11$s*", colorParams));
|
|
|
|
sender.sendMessage(String.format(" %2$s* %6$s*..* %9$s: %11$s*", colorParams));
|
|
|
|
sender.sendMessage(String.format(" %2$s* %9$s* %11$s*", colorParams));
|
|
|
|
sender.sendMessage(String.format(" %2$s* %9$s* %11$s*", colorParams));
|
2019-04-01 19:04:45 +02:00
|
|
|
// }
|
2013-10-01 22:14:29 +02:00
|
|
|
|
|
|
|
hasCelebrated.add(sender.getName());
|
2013-01-11 22:31:21 +01:00
|
|
|
}
|
|
|
|
|
2014-03-28 23:07:48 +01:00
|
|
|
public boolean getDateRange(Date date, Date start, Date end) {
|
2013-01-11 22:31:21 +01:00
|
|
|
return !(date.before(start) || date.after(end));
|
|
|
|
}
|
|
|
|
|
2019-04-01 19:04:45 +02:00
|
|
|
// public void spawnFireworks(Player player) {
|
|
|
|
// int power = Misc.getRandom().nextInt(3) + 1;
|
|
|
|
// Type fireworkType = Type.values()[Misc.getRandom().nextInt(Type.values().length)];
|
|
|
|
// double varX = Misc.getRandom().nextGaussian() * 3;
|
|
|
|
// double varZ = Misc.getRandom().nextGaussian() * 3;
|
|
|
|
//
|
|
|
|
// Firework fireworks = (Firework) player.getWorld().spawnEntity(player.getLocation().add(varX, 0, varZ), EntityType.FIREWORK);
|
|
|
|
// FireworkMeta fireworkmeta = fireworks.getFireworkMeta();
|
|
|
|
// FireworkEffect effect = FireworkEffect.builder().flicker(Misc.getRandom().nextBoolean()).withColor(colorChoose()).withFade(colorChoose()).with(fireworkType).trail(Misc.getRandom().nextBoolean()).build();
|
|
|
|
// fireworkmeta.addEffect(effect);
|
|
|
|
// fireworkmeta.setPower(power);
|
|
|
|
// fireworks.setFireworkMeta(fireworkmeta);
|
|
|
|
// }
|
2013-01-11 22:31:21 +01:00
|
|
|
|
2013-10-01 22:14:29 +02:00
|
|
|
private static List<Color> colorChoose() {
|
2013-10-18 17:18:29 +02:00
|
|
|
return ALL_COLORS.subList(0, Math.max(Misc.getRandom().nextInt(ALL_COLORS.size() + 1), 1));
|
2013-05-29 19:58:32 +02:00
|
|
|
}
|
|
|
|
|
2013-10-01 22:14:29 +02:00
|
|
|
private static String chatColorChoose() {
|
2013-10-18 16:24:01 +02:00
|
|
|
StringBuilder ret = new StringBuilder(ALL_CHAT_COLORS.get(Misc.getRandom().nextInt(ALL_CHAT_COLORS.size())).toString());
|
2013-10-01 22:14:29 +02:00
|
|
|
|
2013-10-18 17:18:29 +02:00
|
|
|
for (ChatColor chatFormat : CHAT_FORMATS) {
|
|
|
|
if (Misc.getRandom().nextInt(CHAT_FORMATS.size()) == 0) {
|
|
|
|
ret.append(chatFormat);
|
2013-05-29 19:58:32 +02:00
|
|
|
}
|
|
|
|
}
|
2013-10-01 22:14:29 +02:00
|
|
|
|
2013-05-29 19:58:32 +02:00
|
|
|
return ret.toString();
|
|
|
|
}
|
2014-03-28 23:07:48 +01:00
|
|
|
|
|
|
|
public boolean isAprilFirst() {
|
2019-04-01 19:16:43 +02:00
|
|
|
if(!Config.getInstance().isAprilFoolsAllowed())
|
|
|
|
return false;
|
|
|
|
|
2014-03-28 23:07:48 +01:00
|
|
|
GregorianCalendar aprilFirst = new GregorianCalendar(currentYear, Calendar.APRIL, 1);
|
|
|
|
GregorianCalendar aprilSecond = new GregorianCalendar(currentYear, Calendar.APRIL, 2);
|
|
|
|
GregorianCalendar day = new GregorianCalendar();
|
|
|
|
return getDateRange(day.getTime(), aprilFirst.getTime(), aprilSecond.getTime());
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean nearingAprilFirst() {
|
2019-04-01 19:16:43 +02:00
|
|
|
if(!Config.getInstance().isAprilFoolsAllowed())
|
|
|
|
return false;
|
|
|
|
|
2014-03-28 23:07:48 +01:00
|
|
|
GregorianCalendar start = new GregorianCalendar(Calendar.getInstance().get(Calendar.YEAR), Calendar.MARCH, 28);
|
|
|
|
GregorianCalendar end = new GregorianCalendar(Calendar.getInstance().get(Calendar.YEAR), Calendar.APRIL, 2);
|
|
|
|
GregorianCalendar day = new GregorianCalendar();
|
|
|
|
|
|
|
|
return mcMMO.getHolidayManager().getDateRange(day.getTime(), start.getTime(), end.getTime());
|
|
|
|
}
|
|
|
|
|
2014-05-11 15:14:46 +02:00
|
|
|
public void handleStatisticEvent(PlayerStatisticIncrementEvent event) {
|
|
|
|
Player player = event.getPlayer();
|
2014-04-01 15:36:40 +02:00
|
|
|
Statistic statistic = event.getStatistic();
|
|
|
|
int newValue = event.getNewValue();
|
|
|
|
|
|
|
|
int modifier;
|
|
|
|
switch (statistic) {
|
|
|
|
case DAMAGE_TAKEN:
|
|
|
|
modifier = 500;
|
|
|
|
break;
|
|
|
|
case JUMP:
|
|
|
|
modifier = 500;
|
|
|
|
break;
|
|
|
|
case DROP:
|
|
|
|
modifier = 200;
|
|
|
|
break;
|
|
|
|
case MINE_BLOCK:
|
|
|
|
case BREAK_ITEM:
|
|
|
|
modifier = 500;
|
|
|
|
break;
|
|
|
|
case CRAFT_ITEM:
|
|
|
|
modifier = 100;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newValue % modifier == 0) {
|
2014-04-01 20:58:24 +02:00
|
|
|
mcMMO.getHolidayManager().levelUpApril(player, FakeSkillType.getByStatistic(statistic));
|
2014-04-01 15:36:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-28 23:07:48 +01:00
|
|
|
public void levelUpApril(Player player, FakeSkillType fakeSkillType) {
|
2019-04-01 19:16:43 +02:00
|
|
|
if(!Config.getInstance().isAprilFoolsAllowed())
|
|
|
|
return;
|
|
|
|
|
2020-04-01 15:40:29 +02:00
|
|
|
final McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
|
|
|
if (mmoPlayer == null) return;
|
|
|
|
|
|
|
|
int levelTotal = Misc.getRandom().nextInt(1 + mmoPlayer.getSkillLevel(PrimarySkillType.MINING)) + 1;
|
2019-01-13 04:08:54 +01:00
|
|
|
SoundManager.sendSound(player, player.getLocation(), SoundType.LEVEL_UP);
|
2019-01-14 06:48:38 +01:00
|
|
|
NotificationManager.sendPlayerInformation(player, NotificationType.HOLIDAY, "Holiday.AprilFools.Levelup", StringUtils.getCapitalized(fakeSkillType.toString()), String.valueOf(levelTotal));
|
2019-04-01 19:04:45 +02:00
|
|
|
// ParticleEffectUtils.fireworkParticleShower(player, ALL_COLORS.get(Misc.getRandom().nextInt(ALL_COLORS.size())));
|
2014-03-28 23:07:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void registerAprilCommand() {
|
2019-04-01 19:16:43 +02:00
|
|
|
if(!Config.getInstance().isAprilFoolsAllowed())
|
|
|
|
return;
|
|
|
|
|
2020-04-01 15:41:27 +02:00
|
|
|
PluginCommand command = mcMMO.p.getCommand("crafting");
|
2014-03-28 23:07:48 +01:00
|
|
|
command.setExecutor(new AprilCommand());
|
|
|
|
}
|
2013-01-11 22:31:21 +01:00
|
|
|
}
|