diff --git a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java index 867779ee7..414ac6b48 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/quests/command/GetQuestCommand.java @@ -55,6 +55,10 @@ public class GetQuestCommand extends CommandBase } } } + else + { + players.add(caller); + } Quest quest = Plugin.getQuestByID(Integer.parseInt(args[0])); @@ -64,16 +68,16 @@ public class GetQuestCommand extends CommandBase UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "Added " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName())); - if (args[1].equalsIgnoreCase("all")) - { - UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You gave the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + "everyone")); - } - else + if (!args[1].equalsIgnoreCase("all")) { if (caller != players.get(0)) UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You gave the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + player.getName())); - } } + + if (args[1].equalsIgnoreCase("all")) + { + UtilPlayer.message(caller, F.main(QuestManager.QUEST_NAME, "You gave the " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName() + ChatColor.GRAY + " to " + ChatColor.YELLOW + "everyone")); + } } } 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 39596d508..7f980d389 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 @@ -3,6 +3,7 @@ package nautilus.game.arcade.game; import com.google.common.collect.Lists; import com.mojang.authlib.GameProfile; import mineplex.core.Managers; +import mineplex.core.MiniPlugin; import mineplex.core.antihack.AntiHack; import mineplex.core.arcadeevents.CoreGameStartEvent; import mineplex.core.arcadeevents.CoreGameStopEvent; @@ -1778,6 +1779,16 @@ public abstract class Game extends ListenerComponent implements Lifetimed { return _questTrackers; } + + public > T getQuestTracker(Class clazz) + { + for (QuestTracker tracker : _questTrackers) + { + if (tracker.getClass().equals(clazz)) + return clazz.cast(tracker); + } + return null; + } @EventHandler public void onHangingBreak(HangingBreakEvent event) @@ -2057,7 +2068,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed public void onQuestBuy(QuestInteractEvent event) { if (GetState() == GameState.Live || GetState() == GameState.Prepare || GetState() == GameState.End) - event.setCancelled("You cant interact with " + QuestManager.QUEST_NAME + "s while you are ingame!"); + event.setCancelled("You can't interact with " + QuestManager.QUEST_NAME + "s while you are ingame!"); } public NautHashMap getDeadBodies() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java index 38abce9fb..8a9272463 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/DragonEscape.java @@ -62,6 +62,7 @@ import nautilus.game.arcade.game.games.dragonescape.kits.KitDigger; import nautilus.game.arcade.game.games.dragonescape.kits.KitDisruptor; import nautilus.game.arcade.game.games.dragonescape.kits.KitLeaper; import nautilus.game.arcade.game.games.dragonescape.kits.KitWarper; +import nautilus.game.arcade.game.games.dragonescape.quests.DragonEscapeWinQuestTracker; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.managers.chat.ChatStatData; @@ -144,6 +145,8 @@ public class DragonEscape extends SoloGame BlankLine, new ChatStatData("kit", "Kit", true) ); + + registerQuestTrackers(new DragonEscapeWinQuestTracker(this)); new CompassModule() .setGiveCompass(true) @@ -487,7 +490,10 @@ public class DragonEscape extends SoloGame AddGems(_winner, 10, "Course Complete", false, false); if (places.size() >= 1) + { AddGems(places.get(0), 20, "1st Place", false, false); + getQuestTracker(DragonEscapeWinQuestTracker.class).increment(places.get(0)); + } if (places.size() >= 2) AddGems(places.get(1), 15, "2nd Place", false, false); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/quests/DragonEscapeWinQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/quests/DragonEscapeWinQuestTracker.java new file mode 100644 index 000000000..b47de5575 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/dragonescape/quests/DragonEscapeWinQuestTracker.java @@ -0,0 +1,30 @@ +package nautilus.game.arcade.game.games.dragonescape.quests; + +import org.bukkit.entity.Player; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.quests.TriggerType; + +import nautilus.game.arcade.Arcade; +import nautilus.game.arcade.game.games.dragonescape.DragonEscape; +import nautilus.game.arcade.quest.QuestTracker; + +/** + * DragonEscapeWinQuestTracker + * + * @author xXVevzZXx + */ +public class DragonEscapeWinQuestTracker extends QuestTracker +{ + + public DragonEscapeWinQuestTracker(DragonEscape game) + { + super(game, TriggerType.COMPLETE); + } + + public void increment(Player player) + { + incrementQuests(player, 1, ((Arcade) UtilServer.getPlugin()).getServerConfig().getServerGroup().getPrefix(), getGame().GetKit(player).GetName() + "Kit", "Parkour"); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java index 83367508e..9bcc6165e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/CollectQuestTracker.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.quest; +import java.awt.dnd.DragSourceDropEvent; import java.util.ArrayList; import org.bukkit.ChatColor; @@ -15,6 +16,7 @@ import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; @@ -33,6 +35,7 @@ import nautilus.game.arcade.game.Game; public class CollectQuestTracker extends QuestTracker { private ArrayList _itemsAvailable = new ArrayList<>(); + private ArrayList _badItems = new ArrayList<>(); private ArrayList _usedChests = new ArrayList<>(); private ArrayList _usedBlocks = new ArrayList<>(); @@ -67,6 +70,12 @@ public class CollectQuestTracker extends QuestTracker } + @EventHandler(priority=EventPriority.HIGHEST) + public void itemRegister(PlayerDropItemEvent event) + { + _badItems.add(event.getItemDrop().getItemStack()); + } + @EventHandler(priority=EventPriority.HIGHEST) public void itemRegister(BlockBreakEvent event) { @@ -76,12 +85,12 @@ public class CollectQuestTracker extends QuestTracker if (event.isCancelled()) return; - if (_usedBlocks.contains(event.getBlock().getLocation())) + if (!_usedBlocks.contains(event.getBlock().getLocation())) return; for (ItemStack item : event.getBlock().getDrops()) { - _itemsAvailable.add(item); + _badItems.add(item); } } @@ -95,19 +104,12 @@ public class CollectQuestTracker extends QuestTracker return; ItemStack item = event.getItem().getItemStack(); - ItemStack fromList = null; - for (ItemStack available : _itemsAvailable) + if (_badItems.contains(item)) { - if (available.getType() == item.getType()) - fromList = available; - } - - if (fromList == null) + _badItems.remove(item); return; - - _itemsAvailable.remove(fromList); - + } String itemName = item.getType().toString(); if (item.hasItemMeta()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java index 107048e14..71070aaf1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/quest/HitQuestTracker.java @@ -9,6 +9,7 @@ import org.bukkit.event.entity.ProjectileHitEvent; import mineplex.core.common.util.UtilItem; import mineplex.core.quests.TriggerType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.Game; @@ -34,30 +35,27 @@ public class HitQuestTracker extends QuestTracker if (!(event.getEntity() instanceof Player)) return; - incrementQuests((Player) event.getDamager(), 1, "Player", getGame().GetKit((Player) event.getDamager()).GetName() + "Kit"); + + Item itemEntity = (Item) event.getEntity(); + String item = itemEntity.getItemStack().getType().toString(); + + incrementQuests((Player) event.getDamager(), 1, "Player", item, getGame().GetKit((Player) event.getDamager()).GetName() + "Kit"); } @EventHandler - public void onProjectileHit(ProjectileHitEvent event) + public void onProjectileHit(CustomDamageEvent event) { if (!getGame().IsLive()) return; - if (!(event.getEntity().getShooter() instanceof Player)) + if (event.GetReason() == null) return; - Item itemEntity = (Item) event.getEntity(); - String item = itemEntity.getItemStack().getType().toString(); + if (!event.GetReason().contains("Axe Thrower")) + return; - if (UtilItem.isAxe(itemEntity.getItemStack().getType())) - { - item = "Axe"; - } + System.out.println("Test2"); - Entity ent = event.getEntity().getLastDamageCause().getEntity(); - if (ent instanceof Player) - { - incrementQuests((Player) event.getEntity().getShooter(), 1, "Player", item, getGame().GetKit((Player) event.getEntity().getShooter()).GetName() + "Kit"); - } + incrementQuests(event.GetDamagerPlayer(true), 1, "Player", "Axe", getGame().GetKit(event.GetDamagerPlayer(true)).GetName() + "Kit"); } }