mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Improve holiday manager with 1.7 changes
This commit is contained in:
parent
70a1eea231
commit
e1b8088c17
@ -24,6 +24,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
import org.bukkit.event.player.PlayerStatisticIncrementEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -694,4 +695,13 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onPlayerStatisticIncrementEvent(PlayerStatisticIncrementEvent event) {
|
||||||
|
if (!mcMMO.getHolidayManager().isAprilFirst()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMO.getHolidayManager().handleStatisticEvent(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.runnables.skills;
|
|||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
@ -19,6 +20,7 @@ public class AprilTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||||
|
int random = Misc.getRandom().nextInt(40) + 11;
|
||||||
int betterRandom = Misc.getRandom().nextInt(2000);
|
int betterRandom = Misc.getRandom().nextInt(2000);
|
||||||
if (betterRandom == 0) {
|
if (betterRandom == 0) {
|
||||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
||||||
@ -26,10 +28,9 @@ public class AprilTask extends BukkitRunnable {
|
|||||||
fireworksShow(player);
|
fireworksShow(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (HolidayManager.FakeSkillType fakeSkillType : HolidayManager.FakeSkillType.values()) {
|
for (Statistic statistic : mcMMO.getHolidayManager().movementStatistics) {
|
||||||
int random = Misc.getRandom().nextInt(250);
|
if (player.getStatistic(statistic) > 0 && player.getStatistic(statistic) % random == 0) {
|
||||||
if (random == 0) {
|
mcMMO.getHolidayManager().levelUpApril(player, HolidayManager.FakeSkillType.getByStatistic(statistic));
|
||||||
mcMMO.getHolidayManager().levelUpApril(player, fakeSkillType);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -20,11 +22,13 @@ import org.bukkit.DyeColor;
|
|||||||
import org.bukkit.FireworkEffect;
|
import org.bukkit.FireworkEffect;
|
||||||
import org.bukkit.FireworkEffect.Type;
|
import org.bukkit.FireworkEffect.Type;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Firework;
|
import org.bukkit.entity.Firework;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerStatisticIncrementEvent;
|
||||||
import org.bukkit.inventory.meta.FireworkMeta;
|
import org.bukkit.inventory.meta.FireworkMeta;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
@ -67,7 +71,44 @@ public final class HolidayManager {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
case DIVE_ONE_CM:
|
||||||
|
return FakeSkillType.DIVING;
|
||||||
|
case PIG_ONE_CM:
|
||||||
|
return FakeSkillType.PIGGY;
|
||||||
|
default:
|
||||||
|
return FakeSkillType.UNKNOWN;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final Set<Statistic> movementStatistics = EnumSet.of(
|
||||||
|
Statistic.WALK_ONE_CM, Statistic.SWIM_ONE_CM, Statistic.FALL_ONE_CM,
|
||||||
|
Statistic.CLIMB_ONE_CM, Statistic.FLY_ONE_CM, Statistic.DIVE_ONE_CM,
|
||||||
|
Statistic.PIG_ONE_CM);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
List<Color> colors = new ArrayList<Color>();
|
List<Color> colors = new ArrayList<Color>();
|
||||||
@ -301,6 +342,37 @@ public final class HolidayManager {
|
|||||||
return mcMMO.getHolidayManager().getDateRange(day.getTime(), start.getTime(), end.getTime());
|
return mcMMO.getHolidayManager().getDateRange(day.getTime(), start.getTime(), end.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void handleStatisticEvent(PlayerStatisticIncrementEvent event) {Player player = event.getPlayer();
|
||||||
|
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) {
|
||||||
|
mcMMO.p.getHolidayManager().levelUpApril(player, FakeSkillType.getByStatistic(statistic));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void levelUpApril(Player player, FakeSkillType fakeSkillType) {
|
public void levelUpApril(Player player, FakeSkillType fakeSkillType) {
|
||||||
int levelTotal = Misc.getRandom().nextInt(UserManager.getPlayer(player).getSkillLevel(SkillType.MINING)) + 1;
|
int levelTotal = Misc.getRandom().nextInt(UserManager.getPlayer(player).getSkillLevel(SkillType.MINING)) + 1;
|
||||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
||||||
|
Loading…
Reference in New Issue
Block a user