More changes

This commit is contained in:
Sam 2018-06-29 17:35:07 +01:00 committed by Alexander Meech
parent 01ae8aafa6
commit e4695b07f0
23 changed files with 560 additions and 60 deletions

View File

@ -11,6 +11,7 @@ import java.util.Set;
import java.util.TimeZone;
import java.util.UUID;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import org.bukkit.Location;
@ -67,6 +68,7 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
private final MissionRepository _repository;
private final MissionShop _shop;
private Supplier<Boolean> _canIncrement;
private boolean _debug;
private MissionManager()
@ -128,6 +130,7 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
{
if (removeIf.test(tracker))
{
tracker.cleanup();
UtilServer.Unregister(tracker);
return true;
}
@ -247,14 +250,24 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
runAsync(() -> _repository.completeMission(ClientManager.getAccountId(player), mission.getId()));
}
@SuppressWarnings("unchecked")
public <T> void incrementProgress(Player player, int amount, MissionTrackerType trackerType, GameDisplay game, T data)
{
incrementProgress(player, amount, trackerType, game, data, 0);
}
@SuppressWarnings("unchecked")
public <T> void incrementProgress(Player player, int amount, MissionTrackerType trackerType, GameDisplay game, T data, int y)
{
if (_canIncrement != null && !_canIncrement.get())
{
return;
}
MissionClient client = Get(player);
client.getMissions().forEach(mission ->
{
if (mission.getTrackerType() != trackerType || !mission.canProgress(game) || !mission.validateData(data))
if (mission.getTrackerType() != trackerType || !mission.canProgress(game) || !mission.validateData(data) || !mission.validateY(y))
{
return;
}
@ -424,6 +437,11 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
}
}
public void setCanIncrement(Supplier<Boolean> canIncrement)
{
_canIncrement = canIncrement;
}
public boolean toggleDebug()
{
_debug = !_debug;

View File

@ -7,6 +7,7 @@ import mineplex.core.achievement.leveling.rewards.LevelExperienceReward;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.game.GameDisplay;
import static mineplex.core.game.GameDisplay.*;
import static mineplex.core.mission.MissionTrackerType.*;
public class MissionPopulator
@ -21,7 +22,7 @@ public class MissionPopulator
// Lobby Missions 0-99
MissionContext.<Material>newBuilder(manager, 0)
MissionContext.newBuilder(manager, 0)
.name("Parkourist")
.description("Complete any Parkour")
.tracker(LOBBY_PARKOUR)
@ -32,7 +33,7 @@ public class MissionPopulator
)
.build();
MissionContext.<Material>newBuilder(manager, 1)
MissionContext.newBuilder(manager, 1)
.name("Gadget Crazy")
.description("Use %s gadgets")
.xRange(25, 50)
@ -44,7 +45,7 @@ public class MissionPopulator
)
.build();
MissionContext.<Material>newBuilder(manager, 2)
MissionContext.newBuilder(manager, 2)
.name("Not In The Face!")
.description("Flesh Hook %s players")
.xRange(25, 50)
@ -56,7 +57,7 @@ public class MissionPopulator
)
.build();
MissionContext.<Material>newBuilder(manager, 3)
MissionContext.newBuilder(manager, 3)
.name("Jumper")
.description("Use a jump pad %s times")
.xRange(10, 50)
@ -68,7 +69,7 @@ public class MissionPopulator
)
.build();
MissionContext.<Material>newBuilder(manager, 4)
MissionContext.newBuilder(manager, 4)
.name("Mini Mini Games")
.description("Play %s Lobby Games")
.xRange(2, 4)
@ -80,7 +81,7 @@ public class MissionPopulator
)
.build();
MissionContext.<Material>newBuilder(manager, 5)
MissionContext.newBuilder(manager, 5)
.name("Quick Killer")
.description("Kill someone in under %s seconds in GLD")
.yRange(45, 60)
@ -92,7 +93,7 @@ public class MissionPopulator
)
.build();
MissionContext.<Material>newBuilder(manager, 6)
MissionContext.newBuilder(manager, 6)
.name("Skilled")
.description("Take no damage in GLD")
.tracker(LOBBY_GLD_NO_DAMAGE)
@ -107,7 +108,7 @@ public class MissionPopulator
MissionContext.<Material>newBuilder(manager, 100)
.name("Enthusiast")
.description("Play %s games.")
.description("Play %s games")
.games(GameDisplay.values())
.xRange(10, 50)
.tracker(GAME_PLAY)
@ -118,9 +119,9 @@ public class MissionPopulator
)
.build();
MissionContext.<Material>newBuilder(manager, 101)
MissionContext.newBuilder(manager, 101)
.name("Winner")
.description("Win %s games.")
.description("Win %s games")
.games(GameDisplay.values())
.xRange(2, 10)
.tracker(GAME_WIN)
@ -131,9 +132,9 @@ public class MissionPopulator
)
.build();
MissionContext.<Material>newBuilder(manager, 102)
MissionContext.newBuilder(manager, 102)
.name("Killer")
.description("Kill %s players in game.")
.description("Kill %s players in game")
.games(GameDisplay.values())
.xRange(10, 50)
.tracker(GAME_KILL)
@ -144,9 +145,9 @@ public class MissionPopulator
)
.build();
MissionContext.<Material>newBuilder(manager, 103)
MissionContext.newBuilder(manager, 103)
.name("I Shall Taunt You A Second Time")
.description("Taunt %s times in game.")
.description("Taunt %s times in game")
.games(GameDisplay.values())
.xRange(2, 20)
.tracker(GAME_TAUNT)
@ -157,7 +158,211 @@ public class MissionPopulator
)
.build();
// Turf Wars
// Turf Wars 200-299
MissionContext.<Boolean>newBuilder(manager, 200)
.name("Juggler")
.description("Kill %s players while in midair")
.games(TurfWars)
.xRange(3, 6)
.tracker(GAME_KILL_MIDAIR)
.rewards(
new LevelExperienceReward(100),
new LevelCurrencyReward(GlobalCurrency.GEM, 50),
new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 50)
)
.build();
MissionContext.newBuilder(manager, 201)
.name("Sneaky")
.description("Be on the enemy turf for %s seconds")
.games(TurfWars)
.xRange(60, 120)
.tracker(TURF_WARS_ON_ENEMY)
.rewards(
new LevelExperienceReward(4),
new LevelCurrencyReward(GlobalCurrency.GEM, 2),
new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 2)
)
.build();
MissionContext.newBuilder(manager, 202)
.name("Better than explosions")
.description("Break %s wool with your bow")
.games(TurfWars)
.xRange(5, 40)
.tracker(TURF_WARS_BOW_BREAK)
.rewards(
new LevelExperienceReward(25),
new LevelCurrencyReward(GlobalCurrency.GEM, 10),
new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 10)
)
.build();
// Draw My Thing 300-399
MissionContext.newBuilder(manager, 300)
.name("Quick Thinker")
.description("Guess %s words in under %s seconds")
.games(Draw)
.xRange(2, 5)
.yRange(10, 20)
.tracker(DMT_GUESS)
.rewards(
new LevelExperienceReward(200),
new LevelCurrencyReward(GlobalCurrency.GEM, 100),
new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 100)
)
.build();
MissionContext.newBuilder(manager, 301)
.name("Hard To Beat")
.description("Guess every word in a game")
.games(Draw)
.tracker(DMT_GUESS_ALL)
.rewards(
new LevelExperienceReward(1250),
new LevelCurrencyReward(GlobalCurrency.GEM, 750),
new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 750)
)
.build();
MissionContext.newBuilder(manager, 301)
.name("Streak!")
.description("Guess the word %s times in a row")
.games(Draw)
.yRange(2, 5)
.tracker(DMT_GUESS_STREAK)
.rewards(
new LevelExperienceReward(250),
new LevelCurrencyReward(GlobalCurrency.GEM, 125),
new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 125)
)
.build();
// Survival Games 400-499
MissionContext.newBuilder(manager, 400)
.name("Tickle Master")
.description("Kill %s players with a feather")
.games(SurvivalGames, SurvivalGamesTeams)
.xRange(1, 5)
.tracker(GAME_KILL)
.trackerData("Feather")
.rewards(
new LevelExperienceReward(200),
new LevelCurrencyReward(GlobalCurrency.GEM, 100),
new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 100)
)
.build();
MissionContext.newBuilder(manager, 401)
.name("Bojack Takedown")
.description("Kill %s players while riding a horse.")
.games(SurvivalGames, SurvivalGamesTeams)
.xRange(1, 5)
.tracker(SG_BOW_HORSE_KILL)
.rewards(
new LevelExperienceReward(400),
new LevelCurrencyReward(GlobalCurrency.GEM, 200),
new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 200)
)
.build();
MissionContext.newBuilder(manager, 402)
.name("Not Enough Supply")
.description("Open %s supply drops.")
.games(SurvivalGames, SurvivalGamesTeams)
.xRange(2, 15)
.tracker(SG_SUPPLY_DROP_OPEN)
.rewards(
new LevelExperienceReward(150),
new LevelCurrencyReward(GlobalCurrency.GEM, 75),
new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 75)
)
.build();
MissionContext.<Material>newBuilder(manager, 403)
.name("Diamond Weaponsmith")
.description("Craft %s diamond swords.")
.games(SurvivalGames, SurvivalGamesTeams)
.xRange(1, 10)
.tracker(GAME_CRAFT_ITEM)
.trackerData(Material.DIAMOND_SWORD)
.rewards(
new LevelExperienceReward(250),
new LevelCurrencyReward(GlobalCurrency.GEM, 125),
new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 125)
)
.build();
MissionContext.<Material>newBuilder(manager, 404)
.name("Gold Weaponsmith")
.description("Craft %s gold swords.")
.games(SurvivalGames, SurvivalGamesTeams)
.xRange(1, 10)
.tracker(GAME_CRAFT_ITEM)
.trackerData(Material.GOLD_SWORD)
.rewards(
new LevelExperienceReward(250),
new LevelCurrencyReward(GlobalCurrency.GEM, 125),
new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 125)
)
.build();
MissionContext.<Material>newBuilder(manager, 405)
.name("Iron Weaponsmith")
.description("Craft %s gold swords.")
.games(SurvivalGames, SurvivalGamesTeams)
.xRange(1, 10)
.tracker(GAME_CRAFT_ITEM)
.trackerData(Material.IRON_SWORD)
.rewards(
new LevelExperienceReward(250),
new LevelCurrencyReward(GlobalCurrency.GEM, 125),
new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 125)
)
.build();
MissionContext.<Material>newBuilder(manager, 406)
.name("Why Thou")
.description("Craft %s gold shovels.")
.games(SurvivalGames, SurvivalGamesTeams)
.xRange(1, 10)
.tracker(GAME_CRAFT_ITEM)
.trackerData(Material.GOLD_SPADE)
.rewards(
new LevelExperienceReward(250),
new LevelCurrencyReward(GlobalCurrency.GEM, 125),
new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 125)
)
.build();
MissionContext.<Material>newBuilder(manager, 407)
.name("Looter")
.description("Loot %s chests.")
.games(SurvivalGames, SurvivalGamesTeams)
.xRange(25, 100)
.tracker(GAME_CHEST_OPEN)
.rewards(
new LevelExperienceReward(4),
new LevelCurrencyReward(GlobalCurrency.GEM, 2),
new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 2)
)
.build();
MissionContext.<Material>newBuilder(manager, 407)
.name("Steve Walker")
.description("Walk %s blocks.")
.games(SurvivalGames, SurvivalGamesTeams)
.xRange(1000, 5000)
.tracker(SG_WALK)
.rewards(
new LevelExperienceReward(1),
new LevelCurrencyReward(GlobalCurrency.GEM, 1),
new LevelCurrencyReward(GlobalCurrency.TREASURE_SHARD, 1)
)
.build();
}
}

View File

@ -1,15 +1,12 @@
package mineplex.core.mission;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import mineplex.core.game.GameDisplay;
public class MissionTracker<T> implements Listener
public class MissionTracker implements Listener
{
protected final MissionManager _manager;
private final MissionTrackerType _trackerType;
protected final MissionTrackerType _trackerType;
public MissionTracker(MissionManager manager, MissionTrackerType trackerType)
{
@ -17,8 +14,6 @@ public class MissionTracker<T> implements Listener
_trackerType = trackerType;
}
protected void incrementProgress(Player player, int amount, GameDisplay game, T data)
{
_manager.incrementProgress(player, amount, _trackerType, game, data);
}
public void cleanup()
{}
}

View File

@ -13,7 +13,22 @@ public enum MissionTrackerType
GAME_WIN,
GAME_PLAY,
GAME_KILL,
GAME_TAUNT,
GAME_KILL,
GAME_KILL_MIDAIR,
GAME_CHEST_OPEN,
GAME_CRAFT_ITEM,
TURF_WARS_ON_ENEMY,
TURF_WARS_BOW_BREAK,
DMT_GUESS,
DMT_GUESS_ALL,
DMT_GUESS_STREAK,
SG_BOW_HORSE_KILL,
SG_SUPPLY_DROP_OPEN,
SG_WALK,
}

View File

@ -46,6 +46,10 @@ public class PlayerMission<T> implements Mission<T>
{
_rewards = new LevelReward[_context.getRewards().length];
// Reduce the reward scaling if the number is >= 1000
// This is only the case for things like the "Walk x blocks" missions.
int x = _x >= 1000 ? _x / 100 : _x;
for (int i = 0; i < _rewards.length; i++)
{
LevelReward reward = _context.getRewards()[i];
@ -59,7 +63,7 @@ public class PlayerMission<T> implements Mission<T>
shardRankBonus += rankBonus;
}
_rewards[i] = ((ScalableLevelReward) reward).cloneScalable(_x * shardRankBonus);
_rewards[i] = ((ScalableLevelReward) reward).cloneScalable(x * shardRankBonus);
}
else
{
@ -114,6 +118,11 @@ public class PlayerMission<T> implements Mission<T>
return _x;
}
public boolean validateY(int y)
{
return y <= getY();
}
public int getY()
{
return _y;

View File

@ -138,7 +138,7 @@ public class Duels extends CycledGame
for (Player player : getAlivePlayers())
{
manager.incrementProgress(player, 1, MissionTrackerType.LOBBY_GLD_QUICK, null, since);
manager.incrementProgress(player, 1, MissionTrackerType.LOBBY_GLD_QUICK, null, null, (int) since);
if (_notDamaged.contains(player))
{

View File

@ -1,10 +1,8 @@
package mineplex.minecraft.game.core.combat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@ -411,7 +409,7 @@ public class CombatManager extends MiniPlugin
// Killed
String killedColor = log.GetKilledColor();
String deadPlayer = killedColor + event.getEntity().getName();
String message = "";
String message;
// Killer
if (log.GetKiller() != null)

View File

@ -104,6 +104,7 @@ 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.CraftItemMissionTracker;
import nautilus.game.arcade.missions.GameMissionTracker;
import nautilus.game.arcade.missions.KillMissionTracker;
import nautilus.game.arcade.missions.PlayGameMissionTracker;
@ -442,8 +443,10 @@ public abstract class Game extends ListenerComponent implements Lifetimed
registerMissions(
new PlayGameMissionTracker(this),
new WinMissionTracker(this),
new KillMissionTracker(this)
new KillMissionTracker(this),
new CraftItemMissionTracker(this)
);
manager.getMissionsManager().setCanIncrement(() -> CanAddStats && manager.IsRewardStats());
Manager.getResourcePackManager().setResourcePack(gameType.getResourcePackUrls(this), gameType.isEnforceResourcePack(this));

View File

@ -7,6 +7,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -41,6 +42,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.mission.MissionTrackerType;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -52,6 +54,7 @@ import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.GameScore;
import nautilus.game.arcade.game.games.draw.kits.KitArtist;
import nautilus.game.arcade.game.games.draw.mission.GuessStreakTracker;
import nautilus.game.arcade.game.games.draw.tools.Tool;
import nautilus.game.arcade.game.games.draw.tools.ToolCircle;
import nautilus.game.arcade.game.games.draw.tools.ToolLine;
@ -255,6 +258,8 @@ public class Draw extends SoloGame
new DrawGuessStatTracker(this)
);
registerMissions(new GuessStreakTracker(this));
registerChatStats(
new ChatStatData("TotalGuess", "Total Guesses", true),
new ChatStatData("PureLuck", "Lucky Guesses", true)
@ -537,6 +542,9 @@ public class Draw extends SoloGame
Announce(C.cYellow + C.Bold + "+" + score + " " + C.cGreen + C.Bold + player.getName()
+ " has guessed the word!");
long since = TimeUnit.MILLISECONDS.toSeconds(GetStateTime() - _round.Time);
getArcadeManager().getMissionsManager().incrementProgress(player, 1, MissionTrackerType.DMT_GUESS, GetType().getDisplay(), null, (int) since);
if (score == 1)
this.AddGems(player, 1, "Words Guessed", true, true);
else

View File

@ -0,0 +1,49 @@
package nautilus.game.arcade.game.games.draw.mission;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.mission.MissionTrackerType;
import nautilus.game.arcade.game.games.draw.Draw;
import nautilus.game.arcade.game.games.draw.DrawGuessCorrectlyEvent;
import nautilus.game.arcade.game.games.draw.DrawRoundEndEvent;
import nautilus.game.arcade.missions.GameMissionTracker;
public class GuessStreakTracker extends GameMissionTracker<Draw>
{
private final Map<String, Integer> _streaks;
public GuessStreakTracker(Draw game)
{
super(MissionTrackerType.DMT_GUESS_STREAK, game);
_streaks = new HashMap<>();
}
@Override
public void cleanup()
{
_streaks.clear();
}
@EventHandler
public void guessCorrect(DrawGuessCorrectlyEvent event)
{
Player player = event.getPlayer();
int streak = _streaks.getOrDefault(player.getName(), 0) + 1;
_streaks.put(player.getName(), streak);
_manager.incrementProgress(player, 1, MissionTrackerType.DMT_GUESS_STREAK, getGameType(), null, streak);
}
@EventHandler
public void round(DrawRoundEndEvent event)
{
_streaks.keySet().removeIf(player -> !event.getDrawRound().Guessed.contains(player));
}
}

View File

@ -68,6 +68,8 @@ import nautilus.game.arcade.game.games.survivalgames.kit.KitBrawler;
import nautilus.game.arcade.game.games.survivalgames.kit.KitHorseman;
import nautilus.game.arcade.game.games.survivalgames.kit.KitKnight;
import nautilus.game.arcade.game.games.survivalgames.kit.KitNecromancer;
import nautilus.game.arcade.game.games.survivalgames.misison.BowHorseKillTracker;
import nautilus.game.arcade.game.games.survivalgames.misison.WalkMissionTracker;
import nautilus.game.arcade.game.games.survivalgames.modules.BorderModule;
import nautilus.game.arcade.game.games.survivalgames.modules.FurnaceLootModule;
import nautilus.game.arcade.game.games.survivalgames.modules.SupplyDropModule;
@ -197,6 +199,12 @@ public abstract class SurvivalGamesNew extends Game
new SimultaneousSkeletonStatTracker(this, 5)
);
registerMissions
(
new BowHorseKillTracker(this),
new WalkMissionTracker(this)
);
registerChatStats
(
Kills,

View File

@ -0,0 +1,35 @@
package nautilus.game.arcade.game.games.survivalgames.misison;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PlayerDeathEvent;
import mineplex.core.mission.MissionTrackerType;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.missions.GameMissionTracker;
public class BowHorseKillTracker extends GameMissionTracker<Game>
{
public BowHorseKillTracker(Game game)
{
super(MissionTrackerType.SG_BOW_HORSE_KILL, game);
}
@EventHandler(priority = EventPriority.MONITOR)
public void playerDeath(PlayerDeathEvent event)
{
Player player = event.getEntity();
Player killer = player.getKiller();
if (killer == null || killer.equals(player) || killer.getVehicle() == null || !(killer.getVehicle() instanceof Horse))
{
return;
}
_manager.incrementProgress(player, 1, _trackerType, getGameType(), null);
}
}

View File

@ -0,0 +1,74 @@
package nautilus.game.arcade.game.games.survivalgames.misison;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerQuitEvent;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.mission.MissionTrackerType;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.missions.GameMissionTracker;
public class WalkMissionTracker extends GameMissionTracker<Game>
{
private final Map<Player, Location> _last;
public WalkMissionTracker(Game game)
{
super(MissionTrackerType.GAME_CRAFT_ITEM, game);
_last = new HashMap<>();
}
@Override
public void cleanup()
{
_last.clear();
}
@EventHandler
public void live(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
{
return;
}
_game.GetPlayers(true).forEach(player -> _last.put(player, player.getLocation()));
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC || !_game.IsLive())
{
return;
}
_last.entrySet().forEach(entry ->
{
Player player = entry.getKey();
Location last = entry.getValue(), now = player.getLocation();
double distance = UtilMath.offset(now, last);
_manager.incrementProgress(player, (int) distance, _trackerType, getGameType(), null);
entry.setValue(now);
});
}
@EventHandler
public void playerQuit(PlayerQuitEvent event)
{
_last.remove(event.getPlayer());
}
}

View File

@ -46,6 +46,7 @@ import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.mission.MissionTrackerType;
import mineplex.core.treasure.util.TreasureUtil;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -250,6 +251,7 @@ public class SupplyDropModule extends Module
_supplyDrop = null;
_firstOpening = false;
getGame().AddStat(player, "SupplyDropsOpened", 1, false, false);
getGame().getArcadeManager().getMissionsManager().incrementProgress(player, 1, MissionTrackerType.SG_SUPPLY_DROP_OPEN, getGame().GetType().getDisplay(), null);
}
}

View File

@ -46,6 +46,7 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.mission.MissionTrackerType;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -60,6 +61,7 @@ import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.turfforts.kits.KitInfiltrator;
import nautilus.game.arcade.game.games.turfforts.kits.KitMarksman;
import nautilus.game.arcade.game.games.turfforts.kits.KitShredder;
import nautilus.game.arcade.game.games.turfforts.mission.KillMidAirMissionTracker;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.managers.chat.ChatStatData;
@ -164,6 +166,8 @@ public class TurfForts extends TeamGame
_breakStatTracker
);
registerMissions(new KillMidAirMissionTracker(this));
registerChatStats(
Kills,
Deaths,
@ -474,6 +478,7 @@ public class TurfForts extends TeamGame
{
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, data == 3 ? Material.LAPIS_BLOCK : Material.REDSTONE_BLOCK);
_breakStatTracker.addStat(shooter);
getArcadeManager().getMissionsManager().incrementProgress(shooter, 1, MissionTrackerType.TURF_WARS_BOW_BREAK, GetType().getDisplay(), null);
AddGems(shooter, 0.25, "Blocks Broken", true, true);
}
@ -857,6 +862,7 @@ public class TurfForts extends TeamGame
_enemyTurf.forEach((player, data) ->
{
data.Seconds++;
getArcadeManager().getMissionsManager().incrementProgress(player, 1, MissionTrackerType.TURF_WARS_ON_ENEMY, GetType().getDisplay(), null);
if (UtilTime.elapsed(data.LastTick, data.HasKilled ? 2500 : 5000))
{

View File

@ -0,0 +1,35 @@
package nautilus.game.arcade.game.games.turfforts.mission;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PlayerDeathEvent;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.mission.MissionTrackerType;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.missions.GameMissionTracker;
public class KillMidAirMissionTracker extends GameMissionTracker<Game>
{
public KillMidAirMissionTracker(Game game)
{
super(MissionTrackerType.GAME_KILL_MIDAIR, game);
}
@EventHandler(priority = EventPriority.MONITOR)
public void playerDeath(PlayerDeathEvent event)
{
Player player = event.getEntity();
Player killer = player.getKiller();
if (killer == null || killer.equals(player) || UtilEnt.onBlock(killer))
{
return;
}
_manager.incrementProgress(player, 1, _trackerType, getGameType(), null);
}
}

View File

@ -31,6 +31,7 @@ import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.mission.MissionTrackerType;
import mineplex.core.titles.tracks.standard.LuckyTrack;
import mineplex.core.titles.tracks.standard.UnluckyTrack;
import mineplex.core.updater.UpdateType;
@ -231,6 +232,7 @@ public class ChestLootModule extends Module
Player player = event.getPlayer();
ArcadeManager manager = getGame().getArcadeManager();
getGame().AddStat(player, "ChestsOpened", 1, false, false);
getGame().getArcadeManager().getMissionsManager().incrementProgress(player, 1, MissionTrackerType.GAME_CHEST_OPEN, getGame().GetType().getDisplay(), metadata.Type.Name);
if (manager.IsRewardStats())
{

View File

@ -0,0 +1,33 @@
package nautilus.game.arcade.missions;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.mission.MissionTrackerType;
import nautilus.game.arcade.game.Game;
public class CraftItemMissionTracker extends GameMissionTracker<Game>
{
public CraftItemMissionTracker(Game game)
{
super(MissionTrackerType.GAME_CRAFT_ITEM, game);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void craftItem(CraftItemEvent event)
{
ItemStack itemStack = event.getRecipe().getResult();
if (itemStack == null)
{
return;
}
_manager.incrementProgress((Player) event.getWhoClicked(), itemStack.getAmount(), _trackerType, getGameType(), itemStack.getType());
}
}

View File

@ -1,31 +1,25 @@
package nautilus.game.arcade.missions;
import org.bukkit.entity.Player;
import mineplex.core.game.GameDisplay;
import mineplex.core.mission.MissionTracker;
import mineplex.core.mission.MissionTrackerType;
import nautilus.game.arcade.game.Game;
public class GameMissionTracker<T, U extends Game> extends MissionTracker<T>
public class GameMissionTracker<U extends Game> extends MissionTracker
{
protected final U _game;
GameMissionTracker(MissionTrackerType trackerType, U game)
public GameMissionTracker(MissionTrackerType trackerType, U game)
{
super(game.getArcadeManager().getMissionsManager(), trackerType);
_game = game;
}
protected void incrementProgress(Player player, int amount, T data)
protected GameDisplay getGameType()
{
if (!_game.CanAddStats || !_game.getArcadeManager().IsRewardStats())
{
return;
}
incrementProgress(player, amount, _game.GetType().getDisplay(), data);
return _game.GetType().getDisplay();
}
}

View File

@ -1,17 +1,17 @@
package nautilus.game.arcade.missions;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.mission.MissionTrackerType;
import mineplex.minecraft.game.core.combat.CombatComponent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.game.Game;
public class KillMissionTracker extends GameMissionTracker<Material, Game>
public class KillMissionTracker extends GameMissionTracker<Game>
{
public KillMissionTracker(Game game)
@ -20,16 +20,23 @@ public class KillMissionTracker extends GameMissionTracker<Material, Game>
}
@EventHandler(priority = EventPriority.MONITOR)
public void playerDeath(PlayerDeathEvent event)
public void playerDeath(CombatDeathEvent event)
{
Player player = event.getEntity();
Player killer = player.getKiller();
Player player = event.GetEvent().getEntity();
CombatComponent killer = event.GetLog().GetKiller();
if (killer != null && !player.equals(killer))
if (killer == null || !killer.IsPlayer())
{
ItemStack itemStack = killer.getItemInHand();
incrementProgress(killer, 1, itemStack == null ? null : itemStack.getType());
return;
}
Player killerPlayer = UtilPlayer.searchExact(killer.getUniqueIdOfEntity());
if (killerPlayer == null || player.equals(killerPlayer))
{
return;
}
_manager.incrementProgress(killerPlayer, 1, _trackerType, getGameType(), killer.GetLastDamageSource());
}
}

View File

@ -11,7 +11,7 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState;
public class PlayGameMissionTracker extends GameMissionTracker<GameDisplay, Game>
public class PlayGameMissionTracker extends GameMissionTracker<Game>
{
public PlayGameMissionTracker(Game game)
@ -37,7 +37,7 @@ public class PlayGameMissionTracker extends GameMissionTracker<GameDisplay, Game
continue;
}
incrementProgress(player, 1, null);
_manager.incrementProgress(player, 1, _trackerType, getGameType(), null);
}
}, 600);
}

View File

@ -6,14 +6,13 @@ 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 WinMissionTracker extends GameMissionTracker<GameDisplay, Game>
public class WinMissionTracker extends GameMissionTracker<Game>
{
public WinMissionTracker(Game game)
@ -36,6 +35,6 @@ public class WinMissionTracker extends GameMissionTracker<GameDisplay, Game>
return;
}
winners.forEach(player -> incrementProgress(player, 1, null));
winners.forEach(player -> _manager.incrementProgress(player, 1, _trackerType, getGameType(), null));
}
}

View File

@ -8,6 +8,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import mineplex.core.mission.MissionTrackerType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.draw.Draw;
@ -55,7 +57,10 @@ public class KeenEyeStatTracker extends StatTracker<Draw>
if (event.GetState() == Game.GameState.End)
{
for (Player player : _guessAll)
{
addStat(player, "KeenEye", 1, true, false);
getGame().getArcadeManager().getMissionsManager().incrementProgress(player, 1, MissionTrackerType.DMT_GUESS_ALL, getGame().GetType().getDisplay(), null);
}
}
}
}