Add "all" to the GetMineplexMission Command, dont let specs get chest quest progress

This commit is contained in:
Sarah 2017-07-05 23:38:24 +02:00
parent 333f1eda76
commit 1d046ff119
3 changed files with 36 additions and 8 deletions

View File

@ -1,5 +1,7 @@
package mineplex.core.quests.command; package mineplex.core.quests.command;
import java.util.ArrayList;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -7,6 +9,7 @@ import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.quests.Quest; import mineplex.core.quests.Quest;
import mineplex.core.quests.QuestManager; import mineplex.core.quests.QuestManager;
@ -37,19 +40,40 @@ public class GetQuestCommand extends CommandBase<QuestManager>
return; return;
} }
Player player = caller; ArrayList<Player> players = new ArrayList<>();
if (args.length == 2) if (args.length == 2)
{ {
if (UtilPlayer.searchExact(args[1]) != null) if (UtilPlayer.searchExact(args[1]) != null)
player = UtilPlayer.searchExact(args[1]); {
players.add(UtilPlayer.searchExact(args[1]));
}
else
{
if (args[1].equalsIgnoreCase("all"))
{
players.addAll(UtilServer.getPlayersCollection());
}
}
} }
Quest quest = Plugin.getQuestByID(Integer.parseInt(args[0])); Quest quest = Plugin.getQuestByID(Integer.parseInt(args[0]));
Plugin.addNewQuest(player, quest); for (Player player : players)
UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "Added " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName())); {
Plugin.addNewQuest(player, quest);
UtilPlayer.message(player, F.main(QuestManager.QUEST_NAME, "Added " + QuestManager.QUEST_NAME + ": " + ChatColor.YELLOW + quest.getName()));
if (caller != player)
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"));
}
else
{
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()));
}
}
} }
} }

View File

@ -8,7 +8,6 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import mineplex.core.common.Pair;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Color; import org.bukkit.Color;
@ -34,6 +33,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.scoreboard.Team; import org.bukkit.scoreboard.Team;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import mineplex.core.common.Pair;
import mineplex.core.common.block.BlockData; import mineplex.core.common.block.BlockData;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
@ -52,6 +52,7 @@ import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;

View File

@ -38,6 +38,9 @@ public class ChestOpenQuestTracker extends QuestTracker<Game>
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
return; return;
if (!getGame().IsAlive(event.getPlayer()))
return;
if (event.getClickedBlock().getType() != Material.CHEST) if (event.getClickedBlock().getType() != Material.CHEST)
return; return;