diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelChestReward.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelChestReward.java index e85698ea7..05e5c7823 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelChestReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelChestReward.java @@ -29,8 +29,8 @@ public class LevelChestReward implements ScalableLevelReward } @Override - public ScalableLevelReward cloneScalable(int scale) + public ScalableLevelReward cloneScalable(double scale) { - return new LevelChestReward(_chest, scale * _amount); + return new LevelChestReward(_chest, (int) (scale * _amount)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelCurrencyReward.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelCurrencyReward.java index 4c3f530ed..129c771c1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelCurrencyReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelCurrencyReward.java @@ -30,8 +30,13 @@ public class LevelCurrencyReward implements ScalableLevelReward } @Override - public ScalableLevelReward cloneScalable(int scale) + public ScalableLevelReward cloneScalable(double scale) { - return new LevelCurrencyReward(_type, scale * _amount); + return new LevelCurrencyReward(_type, (int) (scale * _amount)); + } + + public GlobalCurrency getType() + { + return _type; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelExperienceReward.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelExperienceReward.java index 2c6e9ed54..18f958f1e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelExperienceReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelExperienceReward.java @@ -32,8 +32,8 @@ public class LevelExperienceReward implements ScalableLevelReward } @Override - public ScalableLevelReward cloneScalable(int scale) + public ScalableLevelReward cloneScalable(double scale) { - return new LevelExperienceReward(scale * _amount); + return new LevelExperienceReward((int) (scale * _amount)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelGameAmplifierReward.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelGameAmplifierReward.java index 5d54fd2d3..162e9e285 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelGameAmplifierReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/LevelGameAmplifierReward.java @@ -28,8 +28,8 @@ public class LevelGameAmplifierReward implements ScalableLevelReward } @Override - public ScalableLevelReward cloneScalable(int scale) + public ScalableLevelReward cloneScalable(double scale) { - return new LevelGameAmplifierReward(scale * _amount); + return new LevelGameAmplifierReward((int) (scale * _amount)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/ScalableLevelReward.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/ScalableLevelReward.java index 856ed1def..beda58b50 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/ScalableLevelReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/leveling/rewards/ScalableLevelReward.java @@ -3,6 +3,6 @@ package mineplex.core.achievement.leveling.rewards; public interface ScalableLevelReward extends LevelReward { - ScalableLevelReward cloneScalable(int scale); + ScalableLevelReward cloneScalable(double scale); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 58dec098c..5c47a0517 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -330,6 +330,7 @@ import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffect import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffectRankLegend; import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffectRankTitan; import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffectRankUltra; +import mineplex.core.gadget.mission.GadgetUseTracker; import mineplex.core.gadget.persistence.UserGadgetPersistence; import mineplex.core.gadget.set.SetBalance; import mineplex.core.gadget.set.SetCanadian; @@ -376,6 +377,8 @@ import mineplex.core.incognito.IncognitoManager; import mineplex.core.incognito.events.IncognitoStatusChangeEvent; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.mission.MissionManager; +import mineplex.core.mission.MissionTrackerType; import mineplex.core.packethandler.PacketHandler; import mineplex.core.pet.PetManager; import mineplex.core.preferences.PreferencesManager; @@ -422,6 +425,7 @@ public class GadgetManager extends MiniPlugin private final HologramManager _hologramManager; private final IncognitoManager _incognitoManager; private final GameCosmeticManager _gameCosmeticManager; + private final MissionManager _missionManager; private SoulManager _soulManager; private CastleManager _castleManager; @@ -460,11 +464,13 @@ public class GadgetManager extends MiniPlugin _userGadgetPersistence = new UserGadgetPersistence(this); _incognitoManager = require(IncognitoManager.class); _gameCosmeticManager = require(GameCosmeticManager.class); + _missionManager = require(MissionManager.class); _soulManager = new SoulManager(); _castleManager = require(CastleManager.class); createGadgets(); createSets(); + registerTrackers(); generatePermissions(); } @@ -1023,6 +1029,11 @@ public class GadgetManager extends MiniPlugin }); } + private void registerTrackers() + { + _missionManager.registerTrackers(new GadgetUseTracker(_missionManager)); + } + public T getGadget(Class c) { for (GadgetType type : GadgetType.values()) @@ -1624,6 +1635,7 @@ public class GadgetManager extends MiniPlugin return; } + _missionManager.incrementProgress(player, 1, MissionTrackerType.GAME_TAUNT, null, gadget.getClass()); taunt.start(player); } @@ -1688,4 +1700,9 @@ public class GadgetManager extends MiniPlugin { return _achievementManager; } + + public MissionManager getMissionManager() + { + return _missionManager; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java index 2576cbba4..4a7763153 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java @@ -20,6 +20,7 @@ import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.Ammo; import mineplex.core.gadget.types.ItemGadget; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.mission.MissionTrackerType; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; import mineplex.core.updater.UpdateType; @@ -81,6 +82,8 @@ public class ItemFleshHook extends ItemGadget implements IThrown //Inform UtilPlayer.message(target, F.main("Skill", F.name(player.getName()) + " hit you with " + F.skill(getName()) + ".")); + + Manager.getMissionManager().incrementProgress(player, 1, MissionTrackerType.LOBBY_FLESH_HOOK, null, null); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/mission/GadgetUseTracker.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/mission/GadgetUseTracker.java new file mode 100644 index 000000000..d37f9d68b --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/mission/GadgetUseTracker.java @@ -0,0 +1,25 @@ +package mineplex.core.gadget.mission; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.core.gadget.event.ItemGadgetUseEvent; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.mission.MissionManager; +import mineplex.core.mission.MissionTracker; +import mineplex.core.mission.MissionTrackerType; + +public class GadgetUseTracker extends MissionTracker> +{ + + public GadgetUseTracker(MissionManager manager) + { + super(manager, MissionTrackerType.LOBBY_GADGET_USE); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void gadgetUse(ItemGadgetUseEvent event) + { + incrementProgress(event.getPlayer(), 1, null, event.getGadget().getClass()); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionLength.java b/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionLength.java index 45da73574..e3e94bc29 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionLength.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionLength.java @@ -32,9 +32,9 @@ public enum MissionLength _calendarField = calendarField; } - public PlayerMission createFromContext(MissionContext context) + public PlayerMission createFromContext(MissionContext context, double rankBonus) { - return new PlayerMission<>(context, this, context.getRandomX(), context.getRandomY(), 0); + return new PlayerMission<>(context, this, context.getRandomX(), context.getRandomY(), 0, rankBonus); } public String getName() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionManager.java b/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionManager.java index 9ae65067f..ed1289a78 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionManager.java @@ -10,6 +10,7 @@ import java.util.Map; import java.util.Set; import java.util.TimeZone; import java.util.UUID; +import java.util.function.Predicate; import java.util.stream.Collectors; import org.bukkit.Location; @@ -116,10 +117,18 @@ public class MissionManager extends MiniDbClientPlugin } } - public void clearTrackers() + public void clearTrackers(Predicate removeIf) { - _missionTrackers.forEach(UtilServer::Unregister); - _missionTrackers.clear(); + _missionTrackers.removeIf(tracker -> + { + if (removeIf.test(tracker)) + { + UtilServer.Unregister(tracker); + return true; + } + + return false; + }); } @Override @@ -145,7 +154,7 @@ public class MissionManager extends MiniDbClientPlugin int x = resultSet.getInt("x"); int y = resultSet.getInt("y"); long startTime = resultSet.getLong("startTime"); - PlayerMission mission = new PlayerMission<>(context, MissionLength.values()[length], x, y, progress); + PlayerMission mission = new PlayerMission<>(context, MissionLength.values()[length], x, y, progress, getRankBonus(uuid)); Calendar start = Calendar.getInstance(utc); start.setTimeInMillis(startTime); @@ -262,7 +271,7 @@ public class MissionManager extends MiniDbClientPlugin continue; } - startMission(player, MissionLength.EVENT.createFromContext(context)); + startMission(player, MissionLength.EVENT.createFromContext(context, getRankBonus(player))); started++; } @@ -295,7 +304,7 @@ public class MissionManager extends MiniDbClientPlugin } missions.remove(context); - startMission(player, length.createFromContext(context)); + startMission(player, length.createFromContext(context, getRankBonus(player))); started++; } @@ -353,6 +362,30 @@ public class MissionManager extends MiniDbClientPlugin .orElse(null); } + private double getRankBonus(Player player) + { + return getRankBonus(player.getUniqueId()); + } + + private double getRankBonus(UUID player) + { + switch (ClientManager.Get(player).getPrimaryGroup()) + { + case PLAYER: + return 0; + case ULTRA: + return 0.5; + case HERO: + return 1; + case LEGEND: + return 1.5; + case TITAN: + return 2; + default: + return 2.5; + } + } + public void createNPC(Location location) { NPC npc = SimpleNPC.of(location, Slime.class, NPC_METADATA, 3); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionPopulator.java b/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionPopulator.java index 9f8daf42e..9ef6f2f16 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionPopulator.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionPopulator.java @@ -2,13 +2,10 @@ package mineplex.core.mission; import org.bukkit.Material; -import mineplex.core.achievement.leveling.rewards.LevelChestReward; import mineplex.core.achievement.leveling.rewards.LevelCurrencyReward; import mineplex.core.achievement.leveling.rewards.LevelExperienceReward; import mineplex.core.common.currency.GlobalCurrency; -import mineplex.core.treasure.types.TreasureType; -import static mineplex.core.game.GameDisplay.*; import static mineplex.core.mission.MissionTrackerType.*; public class MissionPopulator @@ -16,30 +13,146 @@ public class MissionPopulator public static void populateMissions(MissionManager manager) { - MissionContext.newBuilder(manager, 1) - .name("Gold Finger") - .description("Get %s kills with a Golden Pickaxe") - .xRange(4, 8) - .games(CakeWars4, CakeWarsDuos) - .tracker(GAME_KILL) - .trackerData(Material.GOLD_PICKAXE) + /* + Similar to GameKits, Mission ids should be grouped according to the game. With each group having 100 + ids to use. + */ + + // Lobby Missions 0-99 + + MissionContext.newBuilder(manager, 0) + .name("Parkourist") + .description("Complete any Parkour") + .tracker(LOBBY_PARKOUR) .rewards( - new LevelCurrencyReward(GlobalCurrency.GEM, 2000), - new LevelExperienceReward(100) + new LevelExperienceReward(200), + new LevelCurrencyReward(GlobalCurrency.GEM, 100), + new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 100) ) .build(); - MissionContext.newBuilder(manager, 2) - .name("Cake Winner") - .description("Win %s games of Cake Wars Standard") - .xRange(2, 4) - .games(CakeWars4) - .tracker(GAME_WIN) + MissionContext.newBuilder(manager, 1) + .name("Gadget Crazy") + .description("Use %s gadgets") + .xRange(25, 50) + .tracker(LOBBY_GADGET_USE) .rewards( - new LevelCurrencyReward(GlobalCurrency.GEM, 2000), - new LevelChestReward(TreasureType.ANCIENT, 1) + new LevelExperienceReward(3), + new LevelCurrencyReward(GlobalCurrency.GEM, 2), + new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 2) ) .build(); + + MissionContext.newBuilder(manager, 2) + .name("Not In The Face!") + .description("Flesh Hook %s players") + .xRange(25, 50) + .tracker(LOBBY_FLESH_HOOK) + .rewards( + new LevelExperienceReward(5), + new LevelCurrencyReward(GlobalCurrency.GEM, 2), + new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 2) + ) + .build(); + + MissionContext.newBuilder(manager, 3) + .name("Jumper") + .description("Use a jump pad %s times") + .xRange(10, 50) + .tracker(LOBBY_JUMP_PAD) + .rewards( + new LevelExperienceReward(5), + new LevelCurrencyReward(GlobalCurrency.GEM, 2), + new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 2) + ) + .build(); + + MissionContext.newBuilder(manager, 4) + .name("Mini Mini Games") + .description("Play %s Lobby Games") + .xRange(2, 4) + .tracker(LOBBY_GAMES_PLAYED) + .rewards( + new LevelExperienceReward(10), + new LevelCurrencyReward(GlobalCurrency.GEM, 5), + new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 5) + ) + .build(); + + MissionContext.newBuilder(manager, 5) + .name("Quick Killer") + .description("Kill someone in under %s seconds in GLD") + .yRange(45, 60) + .tracker(LOBBY_GLD_QUICK) + .rewards( + new LevelExperienceReward(1000), + new LevelCurrencyReward(GlobalCurrency.GEM, 300), + new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 300) + ) + .build(); + + MissionContext.newBuilder(manager, 6) + .name("Skilled") + .description("Take no damage in GLD") + .tracker(LOBBY_GLD_NO_DAMAGE) + .rewards( + new LevelExperienceReward(1000), + new LevelCurrencyReward(GlobalCurrency.GEM, 300), + new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 300) + ) + .build(); + + // Global Game Missions 100-199 + + MissionContext.newBuilder(manager, 100) + .name("Enthusiast") + .description("Play %s games.") + .xRange(10, 50) + .tracker(GAME_PLAY) + .rewards( + new LevelExperienceReward(10), + new LevelCurrencyReward(GlobalCurrency.GEM, 5), + new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 5) + ) + .build(); + + MissionContext.newBuilder(manager, 101) + .name("Winner") + .description("Win %s games.") + .xRange(2, 10) + .tracker(GAME_WIN) + .rewards( + new LevelExperienceReward(40), + new LevelCurrencyReward(GlobalCurrency.GEM, 20), + new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 20) + ) + .build(); + + MissionContext.newBuilder(manager, 102) + .name("Killer") + .description("Kill %s players in game.") + .xRange(10, 50) + .tracker(GAME_KILL) + .rewards( + new LevelExperienceReward(10), + new LevelCurrencyReward(GlobalCurrency.GEM, 5), + new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 5) + ) + .build(); + + MissionContext.newBuilder(manager, 103) + .name("I Shall Taunt You A Second Time") + .description("Taunt %s times in game.") + .xRange(2, 20) + .tracker(GAME_TAUNT) + .rewards( + new LevelExperienceReward(30), + new LevelCurrencyReward(GlobalCurrency.GEM, 10), + new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 10) + ) + .build(); + + // Turf Wars } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionTrackerType.java b/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionTrackerType.java index 7eb47229d..e900fa483 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionTrackerType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mission/MissionTrackerType.java @@ -3,7 +3,17 @@ package mineplex.core.mission; public enum MissionTrackerType { + LOBBY_PARKOUR, + LOBBY_GADGET_USE, + LOBBY_FLESH_HOOK, + LOBBY_JUMP_PAD, + LOBBY_GAMES_PLAYED, + LOBBY_GLD_QUICK, + LOBBY_GLD_NO_DAMAGE, + GAME_WIN, - GAME_KILL + GAME_PLAY, + GAME_KILL, + GAME_TAUNT, } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mission/PlayerMission.java b/Plugins/Mineplex.Core/src/mineplex/core/mission/PlayerMission.java index 97c80fb99..7def02d77 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mission/PlayerMission.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mission/PlayerMission.java @@ -1,7 +1,9 @@ package mineplex.core.mission; +import mineplex.core.achievement.leveling.rewards.LevelCurrencyReward; import mineplex.core.achievement.leveling.rewards.LevelReward; import mineplex.core.achievement.leveling.rewards.ScalableLevelReward; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.game.GameDisplay; public class PlayerMission implements Mission @@ -18,7 +20,7 @@ public class PlayerMission implements Mission private int _currentProgress, _unsavedProgress; private boolean _rewarded; - PlayerMission(MissionContext context, MissionLength length, int x, int y, int currentProgress) + PlayerMission(MissionContext context, MissionLength length, int x, int y, int currentProgress, double rankBonus) { _context = context; _length = length; @@ -26,9 +28,16 @@ public class PlayerMission implements Mission _x = x * length.getxScale(); _y = y; - _description = String.format(context.getDescription(), _x, y); + if (_x == 0) + { + _description = String.format(context.getDescription(), _x, y); + } + else + { + _description = String.format(context.getDescription(), y); + } - if (_x != 1) + if (_x != 1 || rankBonus > 0) { _rewards = new LevelReward[context.getRewards().length]; @@ -38,7 +47,14 @@ public class PlayerMission implements Mission if (reward instanceof ScalableLevelReward) { - _rewards[i] = ((ScalableLevelReward) reward).cloneScalable(x); + double shardRankBonus = 1; + + if (reward instanceof LevelCurrencyReward && ((LevelCurrencyReward) reward).getType().equals(GlobalCurrency.TREASURE_SHARD)) + { + shardRankBonus += rankBonus; + } + + _rewards[i] = ((ScalableLevelReward) reward).cloneScalable(_x * shardRankBonus); } else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mission/ui/MissionMainPage.java b/Plugins/Mineplex.Core/src/mineplex/core/mission/ui/MissionMainPage.java index bb7c35be2..691df7257 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mission/ui/MissionMainPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mission/ui/MissionMainPage.java @@ -64,7 +64,11 @@ public class MissionMainPage extends ShopPageBase .setTitle((complete ? C.cGreenB : C.cYellowB)) .addLore(""); - if (games.length > 0) + if (games.length == GameDisplay.values().length) + { + builder.addLore("Game: " + C.Reset + "Any"); + } + else if (games.length > 0) { String lore = "Game: " + C.Reset + games[0].getName(); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 8015870d5..7279a3c96 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -49,6 +49,7 @@ import mineplex.core.chat.IChatMessageFormatter; import mineplex.core.common.generator.VoidGenerator; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -142,6 +143,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess private final HologramManager _hologramManager; private final ParkourManager _parkourManager; private final HubGameManager _hubGameManager; + private final MissionManager _missionManager; private final HubPlugin _hubPlugin; @@ -207,6 +209,10 @@ public class HubManager extends MiniClientPlugin implements IChatMess new ForcefieldManager(this); _achievementManager = achievementManager; + _missionManager = require(MissionManager.class); + Location location = _worldData.getCustomLocation("MISSIONS").get(0); + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, GetSpawn()))); + _missionManager.createNPC(location); new NotificationManager(getPlugin(), clientManager); new BotSpamManager(_plugin, clientManager, punish); @@ -572,6 +578,11 @@ public class HubManager extends MiniClientPlugin implements IChatMess return _hubGameManager; } + public MissionManager getMissionManager() + { + return _missionManager; + } + @EventHandler(priority = EventPriority.LOWEST) public void ignoreVelocity(PlayerVelocityEvent event) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/doublejump/JumpManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/doublejump/JumpManager.java index e2aa7f272..0e75f59dd 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/doublejump/JumpManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/doublejump/JumpManager.java @@ -27,6 +27,7 @@ import mineplex.core.disguise.disguises.DisguiseChicken; import mineplex.core.disguise.disguises.DisguiseEnderman; import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.gadget.event.GadgetBlockEvent; +import mineplex.core.mission.MissionTrackerType; import mineplex.core.preferences.Preference; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -147,6 +148,7 @@ public class JumpManager extends MiniPlugin direction.setY(1.2); player.getWorld().playSound(location, Sound.CHICKEN_EGG_POP, 2, 0.5F); UtilAction.velocity(player, direction); + Manager.getMissionManager().incrementProgress(player, 1, MissionTrackerType.LOBBY_JUMP_PAD, null, null); } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/common/damage/DamageComponent.java b/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/common/damage/DamageComponent.java index 432eee907..a6ae96a16 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/common/damage/DamageComponent.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/common/damage/DamageComponent.java @@ -90,7 +90,7 @@ public class DamageComponent extends HubGameComponent @EventHandler public void playerDeath(CombatDeathEvent event) { - Player player = (Player) event.GetEvent().getEntity(); + Player player = event.GetEvent().getEntity(); if (!_game.isAlive(player)) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/common/general/MissionsComponent.java b/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/common/general/MissionsComponent.java new file mode 100644 index 000000000..409658961 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/common/general/MissionsComponent.java @@ -0,0 +1,36 @@ +package mineplex.hub.hubgame.common.general; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.mission.MissionManager; +import mineplex.core.mission.MissionTrackerType; +import mineplex.hub.hubgame.CycledGame; +import mineplex.hub.hubgame.CycledGame.GameState; +import mineplex.hub.hubgame.common.HubGameComponent; +import mineplex.hub.hubgame.event.HubGameStateChangeEvent; + +public class MissionsComponent extends HubGameComponent +{ + + public MissionsComponent(CycledGame game) + { + super(game); + } + + @EventHandler + public void gamesPlayed(HubGameStateChangeEvent event) + { + if (event.getState() != GameState.End || !event.getGame().equals(_game)) + { + return; + } + + MissionManager manager = _game.getManager().getHubManager().getMissionManager(); + + for (Player player : _game.getAllPlayers()) + { + manager.incrementProgress(player, 1, MissionTrackerType.LOBBY_GAMES_PLAYED, null, _game.getGameType().toString()); + } + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/duel/Duels.java b/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/duel/Duels.java index a95e70e1e..571596df2 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/duel/Duels.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/duel/Duels.java @@ -1,5 +1,6 @@ package mineplex.hub.hubgame.duel; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; @@ -15,6 +16,8 @@ import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.mission.MissionManager; +import mineplex.core.mission.MissionTrackerType; import mineplex.hub.hubgame.CycledGame; import mineplex.hub.hubgame.HubGameManager; import mineplex.hub.hubgame.HubGameType; @@ -23,12 +26,14 @@ import mineplex.hub.hubgame.common.general.DoubleJumpComponent; import mineplex.hub.hubgame.common.general.GameDescriptionComponent; import mineplex.hub.hubgame.common.general.GameTimeoutComponent; import mineplex.hub.hubgame.common.general.InventoryEditComponent; +import mineplex.hub.hubgame.common.general.MissionsComponent; import mineplex.hub.hubgame.common.general.PlayerGameModeComponent; import mineplex.hub.hubgame.common.general.PrepareFreezeComponent; import mineplex.hub.hubgame.common.general.SingleWinnerComponent; import mineplex.hub.hubgame.common.map.BlockRecorderComponent; import mineplex.hub.hubgame.common.map.PreventNonAlivePlayersComponent; import mineplex.hub.hubgame.common.map.TeleportIntoMapComponent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class Duels extends CycledGame { @@ -71,10 +76,15 @@ public class Duels extends CycledGame .build(), }; + private final List _notDamaged; + private long _lastStart; + public Duels(HubGameManager manager) { super(manager, HubGameType.DUELS); + _notDamaged = new ArrayList<>(getGameType().getMaxPlayers()); + registerComponent(new DamageComponent(this)); //registerComponent(new PVPTrackerComponent(this)); registerComponent(new GameDescriptionComponent(this, player -> @@ -96,6 +106,7 @@ public class Duels extends CycledGame registerComponent(new GameTimeoutComponent(this, TimeUnit.MINUTES.toMillis(2))); registerComponent(new SingleWinnerComponent(this)); registerComponent(new PlayerGameModeComponent(this, GameMode.SURVIVAL)); + registerComponent(new MissionsComponent(this)); List corners = _worldData.getDataLocation("LIME"); Location a = corners.get(0); @@ -108,13 +119,36 @@ public class Duels extends CycledGame @Override public void onPrepare() { + _lastStart = System.currentTimeMillis(); + _notDamaged.clear(); + for (Player player : getAlivePlayers()) { player.getInventory().addItem(ITEMS); player.getInventory().setArmorContents(ARMOUR); + _notDamaged.add(player); } } + @Override + public void onEnd() + { + MissionManager manager = getManager().getHubManager().getMissionManager(); + long since = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - _lastStart); + + for (Player player : getAlivePlayers()) + { + manager.incrementProgress(player, 1, MissionTrackerType.LOBBY_GLD_QUICK, null, since); + + if (_notDamaged.contains(player)) + { + manager.incrementProgress(player, 1, MissionTrackerType.LOBBY_GLD_NO_DAMAGE, null, null); + } + } + + _notDamaged.clear(); + } + @Override public boolean endCheck() { @@ -136,4 +170,17 @@ public class Duels extends CycledGame event.setCancelled(true); } } + + @EventHandler + public void damage(CustomDamageEvent event) + { + Player damagee = event.GetDamageePlayer(); + + if (damagee == null) + { + return; + } + + _notDamaged.remove(damagee); + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/tron/Tron.java b/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/tron/Tron.java index c860f3050..0d9ba5329 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/tron/Tron.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/hubgame/tron/Tron.java @@ -22,6 +22,7 @@ import mineplex.hub.hubgame.HubGameManager; import mineplex.hub.hubgame.HubGameType; import mineplex.hub.hubgame.common.general.GameDescriptionComponent; import mineplex.hub.hubgame.common.general.GameTimeoutComponent; +import mineplex.hub.hubgame.common.general.MissionsComponent; import mineplex.hub.hubgame.common.general.PlacesComponent; import mineplex.hub.hubgame.common.map.PreventNonAlivePlayersComponent; import mineplex.hub.hubgame.common.map.TeleportIntoMapComponent; @@ -47,6 +48,7 @@ public class Tron extends CycledGame registerComponent(new GameDescriptionComponent(this)); registerComponent(new GameTimeoutComponent(this, TimeUnit.MINUTES.toMillis(3))); registerComponent(new PlacesComponent(this)); + registerComponent(new MissionsComponent(this)); List corners = _worldData.getDataLocation("WHITE"); Location a = corners.get(0); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/parkour/ParkourManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/parkour/ParkourManager.java index cdd368aed..a5e60655f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/parkour/ParkourManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/parkour/ParkourManager.java @@ -14,7 +14,6 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; @@ -32,6 +31,7 @@ import mineplex.core.gadget.event.GadgetBlockEvent; import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.mission.MissionTrackerType; import mineplex.core.newnpc.NPC; import mineplex.core.newnpc.NewNPCManager; import mineplex.core.newnpc.event.NPCInteractEvent; @@ -251,7 +251,7 @@ public class ParkourManager extends MiniPlugin private void rewardPlayer(Player player, ParkourData data) { - + _hubManager.getMissionManager().incrementProgress(player, 1, MissionTrackerType.LOBBY_PARKOUR, null, data.getKey()); } public List> getActivePlayers(ParkourData data) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 8387ace65..00346d186 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -104,7 +104,9 @@ import nautilus.game.arcade.kit.LinearUpgradeKit; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.managers.lobby.LobbyManager; +import nautilus.game.arcade.missions.GameMissionTracker; import nautilus.game.arcade.missions.KillMissionTracker; +import nautilus.game.arcade.missions.PlayGameMissionTracker; import nautilus.game.arcade.missions.WinMissionTracker; import nautilus.game.arcade.scoreboard.GameScoreboard; import nautilus.game.arcade.stats.AssistsStatTracker; @@ -438,6 +440,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed // Mission Tracks registerMissions( + new PlayGameMissionTracker(this), new WinMissionTracker(this), new KillMissionTracker(this) ); @@ -2109,7 +2112,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed Managers.get(AntiHack.class).setStrict(false); getLifetime().end(); getStatTrackers().forEach(HandlerList::unregisterAll); - getArcadeManager().getMissionsManager().clearTrackers(); + getArcadeManager().getMissionsManager().clearTrackers(tracker -> tracker instanceof GameMissionTracker); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/missions/PlayGameMissionTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/missions/PlayGameMissionTracker.java new file mode 100644 index 000000000..c9f237691 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/missions/PlayGameMissionTracker.java @@ -0,0 +1,44 @@ +package nautilus.game.arcade.missions; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.core.game.GameDisplay; +import mineplex.core.mission.MissionTrackerType; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.Game.GameState; + +public class PlayGameMissionTracker extends GameMissionTracker +{ + + public PlayGameMissionTracker(Game game) + { + super(MissionTrackerType.GAME_PLAY, game); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void gameStart(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + // Run after 30 seconds so that players don't quit immediately + _manager.runSyncLater(() -> + { + for (Player player : _game.GetPlayers(false)) + { + if (!player.isOnline()) + { + continue; + } + + incrementProgress(player, 1, null); + } + }, 600); + } +}