mirror of
https://github.com/PikaMug/Quests.git
synced 2025-01-27 18:51:34 +01:00
Abstract command classes
This commit is contained in:
parent
0c7c727acc
commit
0640ac8852
@ -37,7 +37,7 @@ import me.blackvein.quests.exceptions.QuestFormatException;
|
||||
import me.blackvein.quests.exceptions.StageFormatException;
|
||||
import me.blackvein.quests.interfaces.ReloadCallback;
|
||||
import me.blackvein.quests.listeners.BlockListener;
|
||||
import me.blackvein.quests.listeners.CmdExecutor;
|
||||
import me.blackvein.quests.listeners.CommandManager;
|
||||
import me.blackvein.quests.listeners.ConvoListener;
|
||||
import me.blackvein.quests.listeners.ItemListener;
|
||||
import me.blackvein.quests.listeners.NpcListener;
|
||||
@ -212,7 +212,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
|
||||
}
|
||||
|
||||
// 4 - Load command executor
|
||||
cmdExecutor = new CmdExecutor(this);
|
||||
cmdExecutor = new CommandManager(this);
|
||||
|
||||
// 5 - Load soft-depends
|
||||
depends.init();
|
||||
|
@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands;
|
||||
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class QuestsSubCommand {
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public abstract String getNameI18N();
|
||||
|
||||
public abstract String getDescription();
|
||||
|
||||
public abstract String getPermission();
|
||||
|
||||
public abstract String getSyntax();
|
||||
|
||||
public abstract void execute(CommandSender commandSender, String[] args);
|
||||
|
||||
public static boolean assertNonPlayer(CommandSender commandSender) {
|
||||
if (!(commandSender instanceof Player)) {
|
||||
commandSender.sendMessage(ChatColor.YELLOW + Lang.get("consoleError"));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an online Player by name
|
||||
*
|
||||
* @param name Name of the player
|
||||
* @return Player or null if not found
|
||||
*/
|
||||
public static Player getOnlinePlayer(final String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
for (final Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (p.getName().equalsIgnoreCase(name)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
for (final Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (p.getName().toLowerCase().startsWith(name)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
for (final Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (p.getName().toLowerCase().contains(name)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a potentially offline Player by name
|
||||
*
|
||||
* @param name Name of the player
|
||||
* @return Player or null if not found
|
||||
*/
|
||||
public static OfflinePlayer getOfflinePlayer(final String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
final Player player = getOnlinePlayer(name);
|
||||
if (player != null) {
|
||||
return player;
|
||||
}
|
||||
for (final OfflinePlayer p : Bukkit.getServer().getOfflinePlayers()) {
|
||||
if (p != null && p.getName() != null && p.getName().equalsIgnoreCase(name)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
for (final OfflinePlayer p : Bukkit.getServer().getOfflinePlayers()) {
|
||||
if (p != null && p.getName() != null && p.getName().toLowerCase().startsWith(name)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
for (final OfflinePlayer p : Bukkit.getServer().getOfflinePlayers()) {
|
||||
if (p != null && p.getName() != null && p.getName().toLowerCase().contains(name)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get quest names that contain spaces from command input
|
||||
*
|
||||
* @param args an array of Strings
|
||||
* @param startingIndex the index to start combining at
|
||||
* @param endingIndex the index to stop combining at
|
||||
* @param delimiter the character for which the array was split
|
||||
* @return a String or null
|
||||
*/
|
||||
public static String concatArgArray(final String[] args, final int startingIndex, final int endingIndex,
|
||||
final char delimiter) {
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (int i = startingIndex; i <= endingIndex; i++) {
|
||||
s.append(args[i]).append(delimiter);
|
||||
}
|
||||
s = new StringBuilder(s.substring(0, s.length()));
|
||||
return s.toString().trim().equals("") ? null : s.toString().trim();
|
||||
}
|
||||
|
||||
public static Map<String, Integer> sort(final Map<String, Integer> unsortedMap) {
|
||||
final List<Map.Entry<String, Integer>> list = new LinkedList<>(unsortedMap.entrySet());
|
||||
list.sort((o1, o2) -> {
|
||||
final int i = o1.getValue();
|
||||
final int i2 = o2.getValue();
|
||||
return Integer.compare(i2, i);
|
||||
});
|
||||
final Map<String, Integer> sortedMap = new LinkedHashMap<>();
|
||||
for (final Map.Entry<String, Integer> entry : list) {
|
||||
sortedMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return sortedMap;
|
||||
}
|
||||
}
|
@ -0,0 +1,218 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.quest;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.quests.IQuest;
|
||||
import me.blackvein.quests.quests.IStage;
|
||||
import me.blackvein.quests.quests.Requirements;
|
||||
import me.blackvein.quests.util.ItemUtil;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import me.blackvein.quests.util.MiscUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class QuestCommandHandler {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestCommandHandler(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public boolean check(final CommandSender cs, final String[] args) {
|
||||
if (cs instanceof Player) {
|
||||
if (cs.hasPermission("quests.quest")) {
|
||||
if (args.length == 0) {
|
||||
final Player player = (Player) cs;
|
||||
final IQuester quester = plugin.getQuester(player.getUniqueId());
|
||||
if (!quester.getCurrentQuestsTemp().isEmpty()) {
|
||||
for (final IQuest q : quester.getCurrentQuestsTemp().keySet()) {
|
||||
final IStage stage = quester.getCurrentStage(q);
|
||||
q.updateCompass(quester, stage);
|
||||
if (plugin.getQuester(player.getUniqueId()).getQuestData(q).getDelayStartTime() == 0) {
|
||||
final String msg = Lang.get(player, "questObjectivesTitle")
|
||||
.replace("<quest>", q.getName());
|
||||
Lang.send(player, ChatColor.GOLD + msg);
|
||||
plugin.showObjectives(q, quester, false);
|
||||
} else {
|
||||
final long time = plugin.getQuester(player.getUniqueId()).getStageTime(q);
|
||||
String msg = ChatColor.YELLOW + "(" + Lang.get(player, "delay") + ") " + ChatColor.RED
|
||||
+ Lang.get(player, "plnTooEarly");
|
||||
msg = msg.replace("<quest>", q.getName());
|
||||
msg = msg.replace("<time>", MiscUtil.getTime(time));
|
||||
Lang.send(player, msg);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "noActiveQuest"));
|
||||
}
|
||||
} else {
|
||||
showQuestDetails(cs, args);
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("consoleError"));
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showQuestDetails(final CommandSender cs, final String[] args) {
|
||||
if (cs.hasPermission("quests.questinfo")) {
|
||||
StringBuilder name = new StringBuilder();
|
||||
if (args.length == 1) {
|
||||
name = new StringBuilder(args[0].toLowerCase());
|
||||
} else {
|
||||
int index = 0;
|
||||
for (final String s : args) {
|
||||
if (index == (args.length - 1)) {
|
||||
name.append(s.toLowerCase());
|
||||
} else {
|
||||
name.append(s.toLowerCase()).append(" ");
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
final IQuest q = plugin.getQuestTemp(name.toString());
|
||||
if (q != null) {
|
||||
final Player player = (Player) cs;
|
||||
final IQuester quester = plugin.getQuester(player.getUniqueId());
|
||||
cs.sendMessage(ChatColor.GOLD + "- " + q.getName() + " -");
|
||||
cs.sendMessage(" ");
|
||||
if (q.getNpcStart() != null) {
|
||||
String msg = Lang.get("speakTo");
|
||||
msg = msg.replace("<npc>", q.getNpcStart().getName());
|
||||
cs.sendMessage(ChatColor.YELLOW + msg);
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.YELLOW + q.getDescription());
|
||||
}
|
||||
cs.sendMessage(" ");
|
||||
if (plugin.getSettings().canShowQuestReqs()) {
|
||||
cs.sendMessage(ChatColor.GOLD + Lang.get("requirements"));
|
||||
final Requirements reqs = q.getRequirements();
|
||||
if (!reqs.getPermissions().isEmpty()) {
|
||||
for (final String perm : reqs.getPermissions()) {
|
||||
if (plugin.getDependencies().getVaultPermission().has(player, perm)) {
|
||||
cs.sendMessage(ChatColor.GREEN + Lang.get("permissionDisplay") + " " + perm);
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("permissionDisplay") + " " + perm);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (reqs.getHeroesPrimaryClass() != null) {
|
||||
if (plugin.getDependencies()
|
||||
.testPrimaryHeroesClass(reqs.getHeroesPrimaryClass(), player.getUniqueId())) {
|
||||
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + reqs.getHeroesPrimaryClass()
|
||||
+ ChatColor.RESET + "" + ChatColor.DARK_GREEN + " " + Lang.get("heroesClass"));
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.DARK_RED + reqs.getHeroesPrimaryClass()
|
||||
+ ChatColor.RESET + "" + ChatColor.RED + " " + Lang.get("heroesClass"));
|
||||
}
|
||||
}
|
||||
if (reqs.getHeroesSecondaryClass() != null) {
|
||||
if (plugin.getDependencies()
|
||||
.testSecondaryHeroesClass(reqs.getHeroesSecondaryClass(), player.getUniqueId())) {
|
||||
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.DARK_RED + reqs.getHeroesSecondaryClass()
|
||||
+ ChatColor.RESET + "" + ChatColor.RED + " " + Lang.get("heroesClass"));
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + reqs.getHeroesSecondaryClass()
|
||||
+ ChatColor.RESET + "" + ChatColor.DARK_GREEN + " " + Lang.get("heroesClass"));
|
||||
}
|
||||
}
|
||||
if (!reqs.getMcmmoSkills().isEmpty()) {
|
||||
for (final String skill : reqs.getMcmmoSkills()) {
|
||||
final int level = plugin.getDependencies().getMcmmoSkillLevel(Quests
|
||||
.getMcMMOSkill(skill), player.getName());
|
||||
final int req = reqs.getMcmmoAmounts().get(reqs.getMcmmoSkills().indexOf(skill));
|
||||
final String skillName = MiscUtil.getCapitalized(skill);
|
||||
if (level >= req) {
|
||||
cs.sendMessage(ChatColor.GREEN + skillName + " " + Lang.get("mcMMOLevel") + " " + req);
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + skillName + " " + Lang.get("mcMMOLevel") + " " + req);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (reqs.getQuestPoints() != 0) {
|
||||
if (quester.getQuestPoints() >= reqs.getQuestPoints()) {
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + reqs.getQuestPoints() + " "
|
||||
+ Lang.get("questPoints"));
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + reqs.getQuestPoints() + " "
|
||||
+ Lang.get("questPoints"));
|
||||
}
|
||||
}
|
||||
if (reqs.getMoney() != 0) {
|
||||
if (plugin.getDependencies().getVaultEconomy() != null && plugin.getDependencies()
|
||||
.getVaultEconomy().getBalance(quester.getOfflinePlayer()) >= reqs.getMoney()) {
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + reqs.getMoney() + " "
|
||||
+ (reqs.getMoney() > 1 ? plugin.getDependencies().getVaultEconomy()
|
||||
.currencyNamePlural() : plugin.getDependencies().getVaultEconomy()
|
||||
.currencyNameSingular()));
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + reqs.getMoney() + " "
|
||||
+ (reqs.getMoney() > 1 ? plugin.getDependencies().getVaultEconomy()
|
||||
.currencyNamePlural() : plugin.getDependencies().getVaultEconomy()
|
||||
.currencyNameSingular()));
|
||||
}
|
||||
}
|
||||
if (!reqs.getItems().isEmpty()) {
|
||||
for (final ItemStack is : reqs.getItems()) {
|
||||
if (plugin.getQuester(player.getUniqueId()).hasItem(is)) {
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + ItemUtil.getString(is));
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + ItemUtil.getString(is));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!reqs.getNeededQuests().isEmpty()) {
|
||||
for (final IQuest quest : reqs.getNeededQuests()) {
|
||||
if (quester.getCompletedQuestsTemp().contains(quest)) {
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + Lang.get("complete") + " "
|
||||
+ ChatColor.ITALIC + quest.getName());
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + Lang.get("complete") + " "
|
||||
+ ChatColor.ITALIC + quest.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!reqs.getBlockQuests().isEmpty()) {
|
||||
for (final IQuest quest : reqs.getBlockQuests()) {
|
||||
if (quester.getCompletedQuestsTemp().contains(quest)) {
|
||||
String msg = Lang.get("haveCompleted");
|
||||
msg = msg.replace("<quest>", ChatColor.ITALIC + "" + ChatColor.DARK_PURPLE
|
||||
+ quest.getName() + ChatColor.RED);
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + msg);
|
||||
} else {
|
||||
String msg = Lang.get("cannotComplete");
|
||||
msg = msg.replace("<quest>", ChatColor.ITALIC + "" + ChatColor.DARK_PURPLE
|
||||
+ quest.getName() + ChatColor.GREEN);
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("questNotFound"));
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.questadmin;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.questadmin.subcommands.QuestadminFinishCommand;
|
||||
import me.blackvein.quests.commands.questadmin.subcommands.QuestadminGiveCommand;
|
||||
import me.blackvein.quests.commands.questadmin.subcommands.QuestadminGivepointsCommand;
|
||||
import me.blackvein.quests.commands.questadmin.subcommands.QuestadminNextstageCommand;
|
||||
import me.blackvein.quests.commands.questadmin.subcommands.QuestadminPointsCommand;
|
||||
import me.blackvein.quests.commands.questadmin.subcommands.QuestadminPointsallCommand;
|
||||
import me.blackvein.quests.commands.questadmin.subcommands.QuestadminQuitCommand;
|
||||
import me.blackvein.quests.commands.questadmin.subcommands.QuestadminReloadCommand;
|
||||
import me.blackvein.quests.commands.questadmin.subcommands.QuestadminRemoveCommand;
|
||||
import me.blackvein.quests.commands.questadmin.subcommands.QuestadminResetCommand;
|
||||
import me.blackvein.quests.commands.questadmin.subcommands.QuestadminSetstageCommand;
|
||||
import me.blackvein.quests.commands.questadmin.subcommands.QuestadminStatsCommand;
|
||||
import me.blackvein.quests.commands.questadmin.subcommands.QuestadminTakepointsCommand;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class QuestadminCommandHandler {
|
||||
|
||||
private final Quests plugin;
|
||||
private final Map<String, QuestsSubCommand> subCommands;
|
||||
|
||||
public QuestadminCommandHandler(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
subCommands = Stream.of(new QuestadminStatsCommand(plugin),
|
||||
new QuestadminGiveCommand(plugin),
|
||||
new QuestadminQuitCommand(plugin),
|
||||
new QuestadminPointsCommand(plugin),
|
||||
new QuestadminTakepointsCommand(plugin),
|
||||
new QuestadminGivepointsCommand(plugin),
|
||||
new QuestadminPointsallCommand(plugin),
|
||||
new QuestadminFinishCommand(plugin),
|
||||
new QuestadminNextstageCommand(plugin),
|
||||
new QuestadminSetstageCommand(plugin),
|
||||
new QuestadminResetCommand(plugin),
|
||||
new QuestadminRemoveCommand(plugin),
|
||||
new QuestadminReloadCommand(plugin))
|
||||
.collect(Collectors.toMap(QuestsSubCommand::getName, Function.identity()));
|
||||
}
|
||||
|
||||
public boolean check(final CommandSender cs, final String[] args) {
|
||||
if (args.length == 0) {
|
||||
printAdminHelp(cs);
|
||||
return true;
|
||||
}
|
||||
for (Map.Entry<String, QuestsSubCommand> cmd : subCommands.entrySet()) {
|
||||
if (args[0].equalsIgnoreCase(cmd.getKey()) || args[0].equalsIgnoreCase(cmd.getValue().getNameI18N())) {
|
||||
cmd.getValue().execute(cs, args);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("questsUnknownAdminCommand"));
|
||||
/*if (args[0].equalsIgnoreCase("stats") || args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_STATS"))) {
|
||||
new QuestadminStatsCommand(plugin).execute(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase("give") || args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_GIVE"))) {
|
||||
new QuestadminGiveCommand(plugin).execute(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase("quit") || args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_QUIT"))) {
|
||||
new QuestadminQuitCommand(plugin).execute(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase("points")
|
||||
|| args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_POINTS"))) {
|
||||
new QuestadminPointsCommand(plugin).execute(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase("takepoints")
|
||||
|| args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_TAKEPOINTS"))) {
|
||||
new QuestadminTakepointsCommand(plugin).execute(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase("givepoints")
|
||||
|| args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_GIVEPOINTS"))) {
|
||||
new QuestadminGivepointsCommand(plugin).execute(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase("pointsall")
|
||||
|| args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_POINTSALL"))) {
|
||||
new QuestadminPointsallCommand(plugin).execute(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase("finish")
|
||||
|| args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_FINISH"))) {
|
||||
new QuestadminFinishCommand(plugin).execute(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase("nextstage")
|
||||
|| args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_NEXTSTAGE"))) {
|
||||
new QuestadminNextstageCommand(plugin).execute(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase("setstage")
|
||||
|| args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_SETSTAGE"))) {
|
||||
new QuestadminSetstageCommand(plugin).execute(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase("reset")
|
||||
|| args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_RESET"))) {
|
||||
new QuestadminResetCommand(plugin).execute(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase("remove")
|
||||
|| args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_REMOVE"))) {
|
||||
new QuestadminRemoveCommand(plugin).execute(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase("reload")
|
||||
|| args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_RELOAD"))) {
|
||||
new QuestadminReloadCommand(plugin).execute(cs, args);
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("questsUnknownAdminCommand"));
|
||||
}*/
|
||||
return true;
|
||||
}
|
||||
|
||||
private void printAdminHelp(final CommandSender cs) {
|
||||
if (!(cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin"))) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
return;
|
||||
}
|
||||
cs.sendMessage(ChatColor.GOLD + Lang.get("questAdminHelpTitle"));
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin" + ChatColor.RED + " " + Lang.get("COMMAND_QUESTADMIN_HELP"));
|
||||
final boolean translateSubCommands = plugin.getSettings().canTranslateSubCommands();
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.stats")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_STATS_HELP")
|
||||
.replace("<command>", ChatColor.GOLD + (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_STATS")
|
||||
: "stats") + ChatColor.RED));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.give")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_GIVE_HELP")
|
||||
.replace("<command>", ChatColor.GOLD + (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_GIVE")
|
||||
: "give") + ChatColor.RED));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.quit")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_QUIT_HELP")
|
||||
.replace("<command>", ChatColor.GOLD + (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_QUIT")
|
||||
: "quit") + ChatColor.RED));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.points")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED
|
||||
+ Lang.get("COMMAND_QUESTADMIN_POINTS_HELP")
|
||||
.replace("<points>", Lang.get("questPoints"))
|
||||
.replace("<command>", ChatColor.GOLD
|
||||
+ (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_POINTS") : "points") + ChatColor.RED));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.takepoints")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED
|
||||
+ Lang.get("COMMAND_QUESTADMIN_TAKEPOINTS_HELP")
|
||||
.replace("<points>", Lang.get("questPoints"))
|
||||
.replace("<command>", ChatColor.GOLD
|
||||
+ (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_TAKEPOINTS") : "takepoints")
|
||||
+ ChatColor.RED));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.givepoints")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED
|
||||
+ Lang.get("COMMAND_QUESTADMIN_GIVEPOINTS_HELP")
|
||||
.replace("<points>", Lang.get("questPoints"))
|
||||
.replace("<command>", ChatColor.GOLD
|
||||
+ (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_GIVEPOINTS") : "givepoints")
|
||||
+ ChatColor.RED));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.pointsall")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED
|
||||
+ Lang.get("COMMAND_QUESTADMIN_POINTSALL_HELP")
|
||||
.replace("<points>", Lang.get("questPoints"))
|
||||
.replace("<command>", ChatColor.GOLD
|
||||
+ (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_POINTSALL") : "pointsall") + ChatColor.RED));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.finish")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED
|
||||
+ Lang.get("COMMAND_QUESTADMIN_FINISH_HELP").replace("<command>", ChatColor.GOLD
|
||||
+ (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_FINISH") : "finish") + ChatColor.RED));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.nextstage")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED
|
||||
+ Lang.get("COMMAND_QUESTADMIN_NEXTSTAGE_HELP").replace("<command>", ChatColor.GOLD
|
||||
+ (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_NEXTSTAGE") : "nextstage") + ChatColor.RED));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.setstage")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED
|
||||
+ Lang.get("COMMAND_QUESTADMIN_SETSTAGE_HELP").replace("<command>", ChatColor.GOLD
|
||||
+ (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_SETSTAGE") : "setstage") + ChatColor.RED));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.reset")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED+ Lang.get("COMMAND_QUESTADMIN_RESET_HELP")
|
||||
.replace("<command>", ChatColor.GOLD + (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_RESET")
|
||||
: "reset") + ChatColor.RED));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.remove")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED
|
||||
+ Lang.get("COMMAND_QUESTADMIN_REMOVE_HELP").replace("<command>", ChatColor.GOLD
|
||||
+ (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_REMOVE") : "remove") + ChatColor.RED));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.reload")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED
|
||||
+ Lang.get("COMMAND_QUESTADMIN_RELOAD_HELP").replace("<command>", ChatColor.GOLD
|
||||
+ (translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_RELOAD") : "reload") + ChatColor.RED));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.quests.IQuest;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class QuestadminFinishCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestadminFinishCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "finish";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_FINISH");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_FINISH_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.finish";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin finish";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.finish")) {
|
||||
OfflinePlayer target = getOfflinePlayer(args[1]);
|
||||
if (target == null) {
|
||||
try {
|
||||
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
final IQuester quester = plugin.getQuester(target.getUniqueId());
|
||||
if (quester.getCurrentQuestsTemp().isEmpty() && target.getName() != null) {
|
||||
String msg = Lang.get("noCurrentQuest");
|
||||
msg = msg.replace("<player>", target.getName());
|
||||
cs.sendMessage(ChatColor.YELLOW + msg);
|
||||
} else {
|
||||
final IQuest quest = plugin.getQuestTemp(concatArgArray(args, 2, args.length - 1, ' '));
|
||||
if (quest == null) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
|
||||
return;
|
||||
}
|
||||
String msg1 = Lang.get("questForceFinish");
|
||||
msg1 = msg1.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);
|
||||
msg1 = msg1.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.GOLD);
|
||||
cs.sendMessage(ChatColor.GOLD + msg1);
|
||||
if (target.isOnline()) {
|
||||
final Player p = (Player)target;
|
||||
String msg2 = Lang.get(p, "questForcedFinish");
|
||||
msg2 = msg2.replace("<player>", ChatColor.GREEN + cs.getName() + ChatColor.GOLD);
|
||||
msg2 = msg2.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.GOLD);
|
||||
p.sendMessage(ChatColor.GREEN + msg2);
|
||||
}
|
||||
quest.completeQuest(quester);
|
||||
quester.saveData();
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.quests.IQuest;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class QuestadminGiveCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestadminGiveCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "give";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_GIVE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_GIVE_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.give";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin give";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.give")) {
|
||||
OfflinePlayer target = getOfflinePlayer(args[1]);
|
||||
if (target == null) {
|
||||
try {
|
||||
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
final IQuest questToGive;
|
||||
StringBuilder name = new StringBuilder();
|
||||
if (args.length == 3) {
|
||||
name = new StringBuilder(args[2].toLowerCase());
|
||||
} else {
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
final int lastIndex = args.length - 1;
|
||||
if (i == lastIndex) {
|
||||
name.append(args[i].toLowerCase());
|
||||
} else {
|
||||
name.append(args[i].toLowerCase()).append(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
questToGive = plugin.getQuestTemp(name.toString());
|
||||
if (questToGive == null) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("questNotFound"));
|
||||
} else {
|
||||
final IQuester quester = plugin.getQuester(target.getUniqueId());
|
||||
for (final IQuest q : quester.getCurrentQuestsTemp().keySet()) {
|
||||
if (q.getName().equalsIgnoreCase(questToGive.getName())) {
|
||||
String msg = Lang.get("questsPlayerHasQuestAlready");
|
||||
msg = msg.replace("<player>", ChatColor.ITALIC + "" + ChatColor.GREEN + target.getName()
|
||||
+ ChatColor.RESET + ChatColor.YELLOW);
|
||||
msg = msg.replace("<quest>", ChatColor.ITALIC + "" + ChatColor.DARK_PURPLE
|
||||
+ questToGive.getName() + ChatColor.RESET + ChatColor.YELLOW);
|
||||
cs.sendMessage(ChatColor.YELLOW + msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
quester.hardQuit(questToGive);
|
||||
String msg1 = Lang.get("questForceTake");
|
||||
msg1 = msg1.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);
|
||||
msg1 = msg1.replace("<quest>", ChatColor.DARK_PURPLE + questToGive.getName() + ChatColor.GOLD);
|
||||
cs.sendMessage(ChatColor.GOLD + msg1);
|
||||
if (target.isOnline()) {
|
||||
final Player p = (Player)target;
|
||||
String msg2 = Lang.get(p, "questForcedTake");
|
||||
msg2 = msg2.replace("<player>", ChatColor.GREEN + cs.getName() + ChatColor.GOLD);
|
||||
msg2 = msg2.replace("<quest>", ChatColor.DARK_PURPLE + questToGive.getName() + ChatColor.GOLD);
|
||||
p.sendMessage(ChatColor.GREEN + msg2);
|
||||
}
|
||||
quester.takeQuest(questToGive, true);
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class QuestadminGivepointsCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestadminGivepointsCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "givepoints";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_GIVEPOINTS");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_GIVEPOINTS_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.givepoints";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin givepoints";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.givepoints")) {
|
||||
OfflinePlayer target = getOfflinePlayer(args[1]);
|
||||
if (target == null) {
|
||||
try {
|
||||
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
final int points;
|
||||
try {
|
||||
points = Integer.parseInt(args[2]);
|
||||
} catch (final NumberFormatException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
|
||||
return;
|
||||
}
|
||||
final IQuester quester = plugin.getQuester(target.getUniqueId());
|
||||
quester.setQuestPoints(quester.getQuestPoints() + Math.abs(points));
|
||||
String msg1 = Lang.get("giveQuestPoints").replace("<points>", Lang.get("questPoints"));
|
||||
msg1 = msg1.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);
|
||||
msg1 = msg1.replace("<number>", ChatColor.DARK_PURPLE + "" + points + ChatColor.GOLD);
|
||||
cs.sendMessage(ChatColor.GOLD + msg1);
|
||||
if (target.isOnline()) {
|
||||
final Player p = (Player)target;
|
||||
String msg2 = Lang.get(p, "questPointsGiven").replace("<points>", Lang.get("questPoints"));
|
||||
msg2 = msg2.replace("<player>", ChatColor.GREEN + cs.getName() + ChatColor.GOLD);
|
||||
msg2 = msg2.replace("<number>", ChatColor.DARK_PURPLE + "" + points + ChatColor.GOLD);
|
||||
p.sendMessage(ChatColor.GREEN + msg2);
|
||||
}
|
||||
quester.saveData();
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.quests.IQuest;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class QuestadminNextstageCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestadminNextstageCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "nextstage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_NEXTSTAGE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_NEXTSTAGE_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.nextstage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin nextstage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.nextstage")) {
|
||||
OfflinePlayer target = getOfflinePlayer(args[1]);
|
||||
if (target == null) {
|
||||
try {
|
||||
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
final IQuester quester = plugin.getQuester(target.getUniqueId());
|
||||
if (quester.getCurrentQuestsTemp().isEmpty() && target.getName() != null) {
|
||||
String msg = Lang.get("noCurrentQuest");
|
||||
msg = msg.replace("<player>", target.getName());
|
||||
cs.sendMessage(ChatColor.YELLOW + msg);
|
||||
} else {
|
||||
final IQuest quest = plugin.getQuestTemp(concatArgArray(args, 2, args.length - 1, ' '));
|
||||
if (quest == null) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
|
||||
return;
|
||||
}
|
||||
String msg1 = Lang.get("questForceNextStage");
|
||||
msg1 = msg1.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);
|
||||
msg1 = msg1.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.GOLD);
|
||||
cs.sendMessage(ChatColor.GOLD + msg1);
|
||||
if (target.isOnline()) {
|
||||
final Player p = (Player)target;
|
||||
String msg2 = Lang.get(p, "questForcedNextStage");
|
||||
msg2 = msg2.replace("<player>", ChatColor.GREEN + cs.getName() + ChatColor.GOLD);
|
||||
msg2 = msg2.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.GOLD);
|
||||
p.sendMessage(ChatColor.GREEN + msg2);
|
||||
}
|
||||
quest.nextStage(quester, false);
|
||||
quester.saveData();
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class QuestadminPointsCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestadminPointsCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "points";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_POINTS");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_POINTS_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.points";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin points";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.points")) {
|
||||
OfflinePlayer target = getOfflinePlayer(args[1]);
|
||||
if (target == null) {
|
||||
try {
|
||||
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
final int points;
|
||||
try {
|
||||
points = Integer.parseInt(args[2]);
|
||||
} catch (final NumberFormatException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
|
||||
return;
|
||||
}
|
||||
final IQuester quester = plugin.getQuester(target.getUniqueId());
|
||||
quester.setQuestPoints(points);
|
||||
String msg1 = Lang.get("setQuestPoints").replace("<points>", Lang.get("questPoints"));
|
||||
msg1 = msg1.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);
|
||||
msg1 = msg1.replace("<number>", ChatColor.DARK_PURPLE + "" + points + ChatColor.GOLD);
|
||||
cs.sendMessage(ChatColor.GOLD + msg1);
|
||||
if (target.isOnline()) {
|
||||
final Player p = (Player)target;
|
||||
String msg2 = Lang.get(p, "questPointsSet").replace("<points>", Lang.get("questPoints"));
|
||||
msg2 = msg2.replace("<player>", ChatColor.GREEN + cs.getName() + ChatColor.GOLD);
|
||||
msg2 = msg2.replace("<number>", ChatColor.DARK_PURPLE + "" + points + ChatColor.GOLD);
|
||||
p.sendMessage(ChatColor.GREEN + msg2);
|
||||
}
|
||||
quester.saveData();
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class QuestadminPointsallCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestadminPointsallCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "pointsall";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_POINTSALL");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_POINTSALL_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.pointsall";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin pointsall";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.pointsall")) {
|
||||
final int amount;
|
||||
try {
|
||||
amount = Integer.parseInt(args[1]);
|
||||
if (amount < 0) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("inputPosNum"));
|
||||
return;
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("inputNum"));
|
||||
return;
|
||||
}
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("settingAllQuestPoints")
|
||||
.replace("<points>", Lang.get("questPoints")));
|
||||
for (final IQuester q : plugin.getOfflineQuesters()) {
|
||||
q.setQuestPoints(amount);
|
||||
}
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
final File questerFolder = new File(plugin.getDataFolder(), "data");
|
||||
if (questerFolder.exists() && questerFolder.isDirectory()) {
|
||||
final FileConfiguration data = new YamlConfiguration();
|
||||
final File[] files = questerFolder.listFiles();
|
||||
int failCount = 0;
|
||||
boolean suppressed = false;
|
||||
if (files != null) {
|
||||
for (final File f : files) {
|
||||
try {
|
||||
data.load(f);
|
||||
data.set("quest-points", amount);
|
||||
data.save(f);
|
||||
} catch (final IOException | InvalidConfigurationException e) {
|
||||
if (failCount < 10) {
|
||||
String msg = Lang.get("errorReading");
|
||||
msg = msg.replace("<file>", ChatColor.DARK_AQUA + f.getName() + ChatColor.RED);
|
||||
cs.sendMessage(ChatColor.RED + msg);
|
||||
failCount++;
|
||||
} else if (!suppressed) {
|
||||
String msg = Lang.get("errorReadingSuppress");
|
||||
msg = msg.replace("<file>", ChatColor.DARK_AQUA + f.getName() + ChatColor.RED);
|
||||
cs.sendMessage(ChatColor.RED + msg);
|
||||
suppressed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cs.sendMessage(ChatColor.GREEN + Lang.get("done"));
|
||||
String msg = Lang.get("allQuestPointsSet").replace("<points>", Lang.get("questPoints"));
|
||||
msg = msg.replace("<number>", ChatColor.AQUA + "" + amount + ChatColor.GOLD);
|
||||
plugin.getServer().broadcastMessage(ChatColor.YELLOW + "" + ChatColor.GOLD + msg);
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("errorDataFolder"));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.quests.IQuest;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class QuestadminQuitCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestadminQuitCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "quit";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_QUIT");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_QUIT_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.quit";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin quit";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.quit")) {
|
||||
OfflinePlayer target = getOfflinePlayer(args[1]);
|
||||
if (target == null) {
|
||||
try {
|
||||
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
final IQuester quester = plugin.getQuester(target.getUniqueId());
|
||||
if (quester.getCurrentQuestsTemp().isEmpty() && target.getName() != null) {
|
||||
String msg = Lang.get("noCurrentQuest");
|
||||
msg = msg.replace("<player>", target.getName());
|
||||
cs.sendMessage(ChatColor.YELLOW + msg);
|
||||
} else {
|
||||
final IQuest quest = plugin.getQuestTemp(concatArgArray(args, 2, args.length - 1, ' '));
|
||||
if (quest == null) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
|
||||
return;
|
||||
}
|
||||
String msg1 = Lang.get("questForceQuit");
|
||||
msg1 = msg1.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);
|
||||
msg1 = msg1.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.GOLD);
|
||||
cs.sendMessage(ChatColor.GOLD + msg1);
|
||||
String msg2 = Lang.get((Player) target, "questForcedQuit");
|
||||
msg2 = msg2.replace("<player>", ChatColor.GREEN + cs.getName() + ChatColor.GOLD);
|
||||
msg2 = msg2.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.GOLD);
|
||||
quester.quitQuest(quest, msg2);
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.interfaces.ReloadCallback;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class QuestadminReloadCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestadminReloadCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_RELOAD");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_RELOAD_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.reload")) {
|
||||
final ReloadCallback<Boolean> callback = response -> {
|
||||
if (response) {
|
||||
cs.sendMessage(ChatColor.GOLD + Lang.get("questsReloaded"));
|
||||
String msg = Lang.get("numQuestsLoaded");
|
||||
msg = msg.replace("<number>", ChatColor.DARK_PURPLE + String.valueOf(plugin.getLoadedQuests().size())
|
||||
+ ChatColor.GOLD);
|
||||
cs.sendMessage(ChatColor.GOLD + msg);
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("unknownError"));
|
||||
}
|
||||
};
|
||||
plugin.reload(callback);
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.quests.IQuest;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class QuestadminRemoveCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestadminRemoveCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "remove";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_REMOVE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_REMOVE_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.remove";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin remove";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission("quests.admin.*") && cs.hasPermission("quests.admin.remove")) {
|
||||
OfflinePlayer target = getOfflinePlayer(args[1]);
|
||||
if (target == null) {
|
||||
try {
|
||||
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
final IQuest toRemove = plugin.getQuestTemp(concatArgArray(args, 2, args.length - 1, ' '));
|
||||
if (toRemove == null) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
|
||||
return;
|
||||
}
|
||||
final IQuester quester = plugin.getQuester(target.getUniqueId());
|
||||
String msg = Lang.get("questRemoved");
|
||||
if (target.getName() != null) {
|
||||
msg = msg.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);
|
||||
} else {
|
||||
msg = msg.replace("<player>", ChatColor.GREEN + args[1] + ChatColor.GOLD);
|
||||
}
|
||||
msg = msg.replace("<quest>", ChatColor.DARK_PURPLE + toRemove.getName() + ChatColor.AQUA);
|
||||
cs.sendMessage(ChatColor.GOLD + msg);
|
||||
cs.sendMessage(ChatColor.DARK_PURPLE + " UUID: " + ChatColor.DARK_AQUA + quester.getUUID().toString());
|
||||
quester.hardRemove(toRemove);
|
||||
quester.saveData();
|
||||
quester.updateJournal();
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quester;
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.storage.Storage;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
|
||||
public class QuestadminResetCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestadminResetCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "reset";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_RESET");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_RESET_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.reset";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin reset";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.reset")) {
|
||||
OfflinePlayer target = getOfflinePlayer(args[1]);
|
||||
if (target == null) {
|
||||
try {
|
||||
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
final UUID id = target.getUniqueId();
|
||||
final ConcurrentSkipListSet<IQuester> temp = (ConcurrentSkipListSet<IQuester>) plugin.getOfflineQuesters();
|
||||
temp.removeIf(quester -> quester.getUUID().equals(id));
|
||||
plugin.setOfflineQuesters(temp);
|
||||
IQuester quester = plugin.getQuester(id);
|
||||
try {
|
||||
quester.resetCompass();
|
||||
quester.hardClear();
|
||||
quester.saveData();
|
||||
quester.updateJournal();
|
||||
final Storage storage = plugin.getStorage();
|
||||
storage.deleteQuester(id);
|
||||
String msg = Lang.get("questReset");
|
||||
if (target.getName() != null) {
|
||||
msg = msg.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);
|
||||
} else {
|
||||
msg = msg.replace("<player>", ChatColor.GREEN + args[1] + ChatColor.GOLD);
|
||||
}
|
||||
cs.sendMessage(ChatColor.GOLD + msg);
|
||||
cs.sendMessage(ChatColor.DARK_PURPLE + " UUID: " + ChatColor.DARK_AQUA + id);
|
||||
} catch (final Exception e) {
|
||||
plugin.getLogger().info("Data file does not exist for " + id);
|
||||
}
|
||||
quester = new Quester(plugin, id);
|
||||
quester.saveData();
|
||||
final ConcurrentSkipListSet<IQuester> temp2 = (ConcurrentSkipListSet<IQuester>) plugin.getOfflineQuesters();
|
||||
temp2.add(quester);
|
||||
plugin.setOfflineQuesters(temp2);
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.quests.IQuest;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class QuestadminSetstageCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestadminSetstageCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "setstage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_SETSTAGE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_SETSTAGE_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.setstage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin setstage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.setstage")) {
|
||||
OfflinePlayer target = getOfflinePlayer(args[1]);
|
||||
if (target == null) {
|
||||
try {
|
||||
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
int stage = -1;
|
||||
if (args.length > 3) {
|
||||
try {
|
||||
stage = Integer.parseInt(args[args.length - 1]);
|
||||
} catch (final NumberFormatException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("COMMAND_QUESTADMIN_SETSTAGE_USAGE"));
|
||||
return;
|
||||
}
|
||||
final IQuester quester = plugin.getQuester(target.getUniqueId());
|
||||
if (quester.getCurrentQuestsTemp().isEmpty() && target.getName() != null) {
|
||||
String msg = Lang.get("noCurrentQuest");
|
||||
msg = msg.replace("<player>", target.getName());
|
||||
cs.sendMessage(ChatColor.YELLOW + msg);
|
||||
} else {
|
||||
final IQuest quest = plugin.getQuestTemp(concatArgArray(args, 2, args.length - 2, ' '));
|
||||
if (quest == null) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
quest.setStage(quester, stage - 1);
|
||||
} catch (final IndexOutOfBoundsException e) {
|
||||
String msg = Lang.get("invalidRange");
|
||||
msg = msg.replace("<least>", "1").replace("<greatest>", String.valueOf(quest.getStages().size()));
|
||||
cs.sendMessage(ChatColor.RED + msg);
|
||||
}
|
||||
quester.saveData();
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.quests.IQuest;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class QuestadminStatsCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestadminStatsCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "stats";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_STATS");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_STATS_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.stats";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin stats";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission("quests.admin.*") && cs.hasPermission("quests.admin.stats")) {
|
||||
OfflinePlayer target = getOfflinePlayer(args[1]);
|
||||
if (target == null) {
|
||||
try {
|
||||
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
final IQuester quester = plugin.getQuester(target.getUniqueId());
|
||||
cs.sendMessage(ChatColor.GOLD + "- " + target.getName() + " -");
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("questPoints") + " - " + ChatColor.DARK_PURPLE
|
||||
+ quester.getQuestPoints());
|
||||
if (quester.getCurrentQuestsTemp().isEmpty()) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("currentQuest") + " " + ChatColor.DARK_PURPLE+ Lang.get("none"));
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("currentQuest"));
|
||||
for (final Map.Entry<IQuest, Integer> set : quester.getCurrentQuestsTemp().entrySet()) {
|
||||
final IQuest q = set.getKey();
|
||||
final String msg = ChatColor.LIGHT_PURPLE + " - " + ChatColor.DARK_PURPLE + q.getName()
|
||||
+ ChatColor.LIGHT_PURPLE + " (" + Lang.get("stageEditorStage") + " " + (set.getValue() + 1) + ")";
|
||||
cs.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("completedQuest"));
|
||||
|
||||
if (quester.getCompletedQuestsTemp().isEmpty()) {
|
||||
cs.sendMessage(ChatColor.DARK_PURPLE + Lang.get("none"));
|
||||
} else {
|
||||
final StringBuilder completed = new StringBuilder(" ");
|
||||
int index = 1;
|
||||
for (final IQuest q : quester.getCompletedQuestsTemp()) {
|
||||
completed.append(ChatColor.DARK_PURPLE).append(q.getName());
|
||||
if (quester.getAmountsCompleted().containsKey(q) && quester.getAmountsCompleted().get(q) > 1) {
|
||||
completed.append(ChatColor.LIGHT_PURPLE).append(" (x").append(quester.getAmountsCompleted()
|
||||
.get(q)).append(")");
|
||||
}
|
||||
if (index < (quester.getCompletedQuestsTemp().size())) {
|
||||
completed.append(", ");
|
||||
}
|
||||
index++;
|
||||
}
|
||||
cs.sendMessage(completed.toString());
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class QuestadminTakepointsCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestadminTakepointsCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "takepoints";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_TAKEPOINTS");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_QUESTADMIN_TAKEPOINTS_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.takepoints";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin takepoints";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.takepoints")) {
|
||||
OfflinePlayer target = getOfflinePlayer(args[1]);
|
||||
if (target == null) {
|
||||
try {
|
||||
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
final int points;
|
||||
try {
|
||||
points = Integer.parseInt(args[2]);
|
||||
} catch (final NumberFormatException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
|
||||
return;
|
||||
}
|
||||
final IQuester quester = plugin.getQuester(target.getUniqueId());
|
||||
quester.setQuestPoints(quester.getQuestPoints() - Math.abs(points));
|
||||
String msg1 = Lang.get("takeQuestPoints").replace("<points>", Lang.get("questPoints"));
|
||||
msg1 = msg1.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);
|
||||
msg1 = msg1.replace("<number>", ChatColor.DARK_PURPLE + "" + points + ChatColor.GOLD);
|
||||
cs.sendMessage(ChatColor.GOLD + msg1);
|
||||
if (target.isOnline()) {
|
||||
final Player p = (Player)target;
|
||||
String msg2 = Lang.get(p, "questPointsTaken").replace("<points>", Lang.get("questPoints"));
|
||||
msg2 = msg2.replace("<player>", ChatColor.GREEN + cs.getName() + ChatColor.GOLD);
|
||||
msg2 = msg2.replace("<number>", ChatColor.DARK_PURPLE + "" + points + ChatColor.GOLD);
|
||||
p.sendMessage(ChatColor.GREEN + msg2);
|
||||
}
|
||||
quester.saveData();
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.quests;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.quests.subcommands.QuestsActionsCommand;
|
||||
import me.blackvein.quests.commands.quests.subcommands.QuestsConditionsCommand;
|
||||
import me.blackvein.quests.commands.quests.subcommands.QuestsEditorCommand;
|
||||
import me.blackvein.quests.commands.quests.subcommands.QuestsInfoCommand;
|
||||
import me.blackvein.quests.commands.quests.subcommands.QuestsJournalCommand;
|
||||
import me.blackvein.quests.commands.quests.subcommands.QuestsListCommand;
|
||||
import me.blackvein.quests.commands.quests.subcommands.QuestsQuitCommand;
|
||||
import me.blackvein.quests.commands.quests.subcommands.QuestsStatsCommand;
|
||||
import me.blackvein.quests.commands.quests.subcommands.QuestsTakeCommand;
|
||||
import me.blackvein.quests.commands.quests.subcommands.QuestsTopCommand;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class QuestsCommandHandler {
|
||||
|
||||
private final Quests plugin;
|
||||
private final Map<String, QuestsSubCommand> subCommands;
|
||||
|
||||
public QuestsCommandHandler(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
subCommands = Stream.of(new QuestsListCommand(plugin),
|
||||
new QuestsTakeCommand(plugin),
|
||||
new QuestsQuitCommand(plugin),
|
||||
new QuestsStatsCommand(plugin),
|
||||
new QuestsJournalCommand(plugin),
|
||||
new QuestsTopCommand(plugin),
|
||||
new QuestsEditorCommand(plugin),
|
||||
new QuestsActionsCommand(plugin),
|
||||
new QuestsConditionsCommand(plugin),
|
||||
new QuestsInfoCommand(plugin))
|
||||
.collect(Collectors.toMap(QuestsSubCommand::getName, Function.identity()));
|
||||
}
|
||||
|
||||
public boolean check(final CommandSender cs, final String[] args) {
|
||||
if (args.length == 0) {
|
||||
printHelp(cs);
|
||||
return true;
|
||||
}
|
||||
for (Map.Entry<String, QuestsSubCommand> cmd : subCommands.entrySet()) {
|
||||
if (args[0].equalsIgnoreCase(cmd.getKey()) || args[0].equalsIgnoreCase(cmd.getValue().getNameI18N())) {
|
||||
cmd.getValue().execute(cs, args);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("questsUnknownCommand"));
|
||||
/*if (args[0].equalsIgnoreCase("list") || args[0].equalsIgnoreCase(Lang.get("COMMAND_LIST"))) {
|
||||
new QuestsListCommand(plugin).execute(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase("take") || args[0].equalsIgnoreCase(Lang.get("COMMAND_TAKE"))) {
|
||||
new QuestsTakeCommand(plugin).execute(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase("quit") || args[0].equalsIgnoreCase(Lang.get("COMMAND_QUIT"))) {
|
||||
new QuestsQuitCommand(plugin).execute(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase("stats") || args[0].equalsIgnoreCase(Lang.get("COMMAND_STATS"))) {
|
||||
new QuestsStatsCommand(plugin).execute(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase("journal") || args[0].equalsIgnoreCase(Lang.get("COMMAND_JOURNAL"))) {
|
||||
new QuestsJournalCommand(plugin).execute(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase("top") || args[0].equalsIgnoreCase(Lang.get("COMMAND_TOP"))) {
|
||||
new QuestsTopCommand(plugin).execute(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase("editor") || args[0].equalsIgnoreCase(Lang.get("COMMAND_EDITOR"))) {
|
||||
new QuestsEditorCommand(plugin).execute(cs, args);
|
||||
} else if (args[0].startsWith("action") || args[0].startsWith("event")
|
||||
|| args[0].startsWith(Lang.get("COMMAND_EVENTS_EDITOR"))) {
|
||||
new QuestsActionsCommand(plugin).execute(cs, args);
|
||||
} else if (args[0].startsWith("condition") || args[0].startsWith(Lang.get("COMMAND_CONDITIONS_EDITOR"))) {
|
||||
new QuestsConditionsCommand(plugin).execute(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase("info") || args[0].equalsIgnoreCase(Lang.get("COMMAND_INFO"))) {
|
||||
new QuestsInfoCommand(plugin).execute(cs, args);
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("questsUnknownCommand"));
|
||||
return true;
|
||||
}*/
|
||||
return true;
|
||||
}
|
||||
|
||||
private void printHelp(final CommandSender cs) {
|
||||
if (!cs.hasPermission("quests.quests")) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
return;
|
||||
}
|
||||
cs.sendMessage(ChatColor.GOLD + Lang.get("questHelpTitle"));
|
||||
cs.sendMessage(ChatColor.YELLOW + "/quests " + Lang.get("questDisplayHelp"));
|
||||
for (final QuestsSubCommand cmd : subCommands.values()) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/quests " + cmd.getDescription().replace("<command>", ChatColor.GOLD
|
||||
+ (plugin.getSettings().canTranslateSubCommands() ? cmd.getNameI18N() : cmd.getName())
|
||||
+ ChatColor.YELLOW));
|
||||
}
|
||||
if (cs instanceof Player) {
|
||||
cs.sendMessage(ChatColor.DARK_AQUA + "/quest " + ChatColor.YELLOW + Lang.get("COMMAND_QUEST_HELP"));
|
||||
if (cs.hasPermission("quests.questinfo")) {
|
||||
cs.sendMessage(ChatColor.DARK_AQUA + "/quest " + ChatColor.YELLOW
|
||||
+ Lang.get("COMMAND_QUESTINFO_HELP"));
|
||||
}
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED
|
||||
+ Lang.get("COMMAND_QUESTADMIN_HELP"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.quests.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.conversations.Conversable;
|
||||
|
||||
public class QuestsActionsCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestsActionsCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "actions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_EVENTS_EDITOR");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_EVENTS_EDITOR_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.actions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/quests actions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission("quests.events.*") || cs.hasPermission("quests.actions.*")
|
||||
|| cs.hasPermission("quests.actions.editor") || cs.hasPermission("quests.events.editor")
|
||||
|| cs.hasPermission("quests.mode.trial")) {
|
||||
final Conversable c = (Conversable) cs;
|
||||
if (!c.isConversing()) {
|
||||
plugin.getActionFactory().getConversationFactory().buildConversation(c).begin();
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("duplicateEditor"));
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.quests.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.conversations.Conversable;
|
||||
|
||||
public class QuestsConditionsCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestsConditionsCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "conditions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_CONDITIONS_EDITOR");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_CONDITIONS_EDITOR_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.conditions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/quests conditions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission("quests.conditions.*") || cs.hasPermission("quests.conditions.editor")
|
||||
|| cs.hasPermission("quests.mode.trial")) {
|
||||
final Conversable c = (Conversable) cs;
|
||||
if (!c.isConversing()) {
|
||||
plugin.getConditionFactory().getConversationFactory().buildConversation(c).begin();
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("duplicateEditor"));
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.quests.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quester;
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.events.command.QuestsCommandPreQuestsEditorEvent;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.conversations.Conversable;
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class QuestsEditorCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestsEditorCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "editor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_EDITOR");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_EDITOR_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.editor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/quests editor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission("quests.editor.*") || cs.hasPermission("quests.editor.editor")
|
||||
|| cs.hasPermission("quests.mode.trial")) {
|
||||
final Conversable c = (Conversable) cs;
|
||||
if (!c.isConversing()) {
|
||||
final Conversation cn = plugin.getQuestFactory().getConversationFactory().buildConversation(c);
|
||||
if (cs instanceof Player) {
|
||||
final Quester quester = plugin.getQuester(((Player) cs).getUniqueId());
|
||||
final QuestsCommandPreQuestsEditorEvent event
|
||||
= new QuestsCommandPreQuestsEditorEvent(quester, cn.getContext());
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
cn.begin();
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("duplicateEditor"));
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.quests.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class QuestsInfoCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestsInfoCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "info";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_INFO");
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_INFO_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.info";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/quests info";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission("quests.info")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "Quests " + ChatColor.GOLD
|
||||
+ plugin.getDescription().getVersion());
|
||||
cs.sendMessage(ChatColor.GOLD + Lang.get("createdBy") + " " + ChatColor.RED + "Blackvein"
|
||||
+ ChatColor.GOLD + " " + Lang.get("continuedBy") + " " + ChatColor.RED + "PikaMug & contributors");
|
||||
cs.sendMessage(ChatColor.DARK_AQUA + "" + ChatColor.UNDERLINE
|
||||
+ "https://github.com/PikaMug/Quests");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.quests.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quester;
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.events.command.QuestsCommandPreQuestsJournalEvent;
|
||||
import me.blackvein.quests.item.QuestJournal;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class QuestsJournalCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestsJournalCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "journal";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_JOURNAL");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_JOURNAL_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.journal";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/quests journal";
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (assertNonPlayer(cs)) {
|
||||
return;
|
||||
}
|
||||
final Player player = (Player) cs;
|
||||
if (player.hasPermission(getPermission())) {
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
final QuestsCommandPreQuestsJournalEvent preEvent = new QuestsCommandPreQuestsJournalEvent(quester);
|
||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||
if (preEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Inventory inv = player.getInventory();
|
||||
final int index = quester.getJournalIndex();
|
||||
if (index != -1) {
|
||||
inv.setItem(index, null);
|
||||
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "journalPutAway")
|
||||
.replace("<journal>", Lang.get(player, "journalTitle")));
|
||||
} else if (player.getItemInHand().getType().equals(Material.AIR)) {
|
||||
final QuestJournal journal = new QuestJournal(quester);
|
||||
player.setItemInHand(journal.toItemStack());
|
||||
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "journalTaken")
|
||||
.replace("<journal>", Lang.get(player, "journalTitle")));
|
||||
} else if (inv.firstEmpty() != -1) {
|
||||
final ItemStack[] arr = inv.getContents();
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
if (arr[i] == null) {
|
||||
final QuestJournal journal = new QuestJournal(quester);
|
||||
inv.setItem(i, journal.toItemStack());
|
||||
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "journalTaken")
|
||||
.replace("<journal>", Lang.get(player, "journalTitle")));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "journalNoRoom")
|
||||
.replace("<journal>", Lang.get(player, "journalTitle")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.quests.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quester;
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.events.command.QuestsCommandPreQuestsListEvent;
|
||||
import me.blackvein.quests.quests.IQuest;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class QuestsListCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestsListCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "list";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_LIST");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_LIST_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.list";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/quests list";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission(getPermission())) {
|
||||
if (!(cs instanceof Player)) {
|
||||
int num = 1;
|
||||
cs.sendMessage(ChatColor.GOLD + Lang.get("questListTitle"));
|
||||
for (final IQuest q : plugin.getLoadedQuests()) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "" + num + ". " + q.getName());
|
||||
num++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
final Player player = (Player)cs;
|
||||
if (args.length == 1) {
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
final QuestsCommandPreQuestsListEvent preEvent = new QuestsCommandPreQuestsListEvent(quester, 1);
|
||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||
if (preEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.listQuests(quester, 1);
|
||||
} else if (args.length == 2) {
|
||||
final int page;
|
||||
try {
|
||||
page = Integer.parseInt(args[1]);
|
||||
if (page < 1) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("pageSelectionPosNum"));
|
||||
} else {
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
final QuestsCommandPreQuestsListEvent preEvent
|
||||
= new QuestsCommandPreQuestsListEvent(quester, page);
|
||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||
if (preEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.listQuests(quester, page);
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("pageSelectionNum"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.quests.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.quests.IQuest;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class QuestsQuitCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestsQuitCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "quit";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_QUIT");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_QUIT_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.quit";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/quests quit";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (assertNonPlayer(cs)) {
|
||||
return;
|
||||
}
|
||||
final Player player = (Player) cs;
|
||||
if (player.hasPermission(getPermission())) {
|
||||
if (args.length == 1) {
|
||||
Lang.send(player, ChatColor.RED + Lang.get(player, "COMMAND_QUIT_HELP"));
|
||||
return;
|
||||
}
|
||||
final IQuester quester = plugin.getQuester(player.getUniqueId());
|
||||
if (!quester.getCurrentQuestsTemp().isEmpty()) {
|
||||
final IQuest quest = plugin.getQuestTemp(concatArgArray(args, 1, args.length - 1, ' '));
|
||||
if (quest != null) {
|
||||
if (quest.getOptions().canAllowQuitting()) {
|
||||
final String msg = ChatColor.YELLOW + Lang.get("questQuit").replace("<quest>",
|
||||
ChatColor.DARK_PURPLE + quest.getName() + ChatColor.YELLOW);
|
||||
quester.abandonQuest(quest, msg);
|
||||
} else {
|
||||
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "questQuitDisabled"));
|
||||
}
|
||||
} else {
|
||||
Lang.send(player, ChatColor.RED + Lang.get(player, "questNotFound"));
|
||||
}
|
||||
} else {
|
||||
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "noActiveQuest"));
|
||||
}
|
||||
} else {
|
||||
Lang.send(player, ChatColor.RED + Lang.get(player, "noPermission"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.quests.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.quests.IQuest;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class QuestsStatsCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestsStatsCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "stats";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_STATS");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_STATS_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.stats";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/quests stats";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (assertNonPlayer(cs)) {
|
||||
return;
|
||||
}
|
||||
final Player player = (Player) cs;
|
||||
if (cs.hasPermission(getPermission())) {
|
||||
final IQuester quester = plugin.getQuester(player.getUniqueId());
|
||||
cs.sendMessage(ChatColor.GOLD + "- " + player.getName() + " -");
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("questPoints") + " - " + ChatColor.DARK_PURPLE
|
||||
+ quester.getQuestPoints());
|
||||
if (quester.getCurrentQuestsTemp().isEmpty()) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("currentQuest") + " " + ChatColor.DARK_PURPLE+ Lang.get("none"));
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("currentQuest"));
|
||||
for (final Map.Entry<IQuest, Integer> set : quester.getCurrentQuestsTemp().entrySet()) {
|
||||
final IQuest q = set.getKey();
|
||||
final String msg = ChatColor.LIGHT_PURPLE + " - " + ChatColor.DARK_PURPLE + q.getName()
|
||||
+ ChatColor.LIGHT_PURPLE + " (" + Lang.get("stageEditorStage") + " " + (set.getValue() + 1) + ")";
|
||||
cs.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("completedQuest"));
|
||||
|
||||
if (quester.getCompletedQuestsTemp().isEmpty()) {
|
||||
cs.sendMessage(ChatColor.DARK_PURPLE + Lang.get("none"));
|
||||
} else {
|
||||
final StringBuilder completed = new StringBuilder(" ");
|
||||
int index = 1;
|
||||
for (final IQuest q : quester.getCompletedQuestsTemp()) {
|
||||
completed.append(ChatColor.DARK_PURPLE).append(q.getName());
|
||||
if (quester.getAmountsCompleted().containsKey(q) && quester.getAmountsCompleted().get(q) > 1) {
|
||||
completed.append(ChatColor.LIGHT_PURPLE).append(" (x").append(quester.getAmountsCompleted()
|
||||
.get(q)).append(")");
|
||||
}
|
||||
if (index < (quester.getCompletedQuestsTemp().size())) {
|
||||
completed.append(", ");
|
||||
}
|
||||
index++;
|
||||
}
|
||||
cs.sendMessage(completed.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.quests.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.player.IQuester;
|
||||
import me.blackvein.quests.quests.IQuest;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class QuestsTakeCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestsTakeCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "take";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_TAKE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_TAKE_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.take";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/quests take";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (assertNonPlayer(cs)) {
|
||||
return;
|
||||
}
|
||||
final Player player = (Player) cs;
|
||||
if (plugin.getSettings().canAllowCommands()) {
|
||||
if (player.hasPermission(getPermission())) {
|
||||
if (args.length == 1) {
|
||||
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "COMMAND_TAKE_USAGE"));
|
||||
} else {
|
||||
final IQuest questToFind = plugin.getQuestTemp(concatArgArray(args, 1, args.length - 1, ' '));
|
||||
final IQuester quester = plugin.getQuester(player.getUniqueId());
|
||||
if (questToFind != null) {
|
||||
for (final IQuest q : quester.getCurrentQuestsTemp().keySet()) {
|
||||
if (q.getId().equals(questToFind.getId())) {
|
||||
Lang.send(player, ChatColor.RED + Lang.get(player, "questAlreadyOn"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
quester.offerQuest(questToFind, true);
|
||||
} else {
|
||||
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "questNotFound"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Lang.send(player, ChatColor.RED + Lang.get(player, "noPermission"));
|
||||
}
|
||||
} else {
|
||||
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "questTakeDisabled"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.commands.quests.subcommands;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.QuestsSubCommand;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class QuestsTopCommand extends QuestsSubCommand {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public QuestsTopCommand(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "top";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return Lang.get("COMMAND_TOP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return Lang.get("COMMAND_TOP_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.top";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/quests top";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission(getPermission())) {
|
||||
if (args.length > 2) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("COMMAND_TOP_USAGE"));
|
||||
} else {
|
||||
final int topNumber;
|
||||
if (args.length == 1) {
|
||||
topNumber = 5; // default
|
||||
} else {
|
||||
try {
|
||||
topNumber = Integer.parseInt(args[1]);
|
||||
} catch (final NumberFormatException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (topNumber < 1 || topNumber > plugin.getSettings().getTopLimit()) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("invalidRange").replace("<least>", "1")
|
||||
.replace("<greatest>", String.valueOf(plugin.getSettings().getTopLimit())));
|
||||
return;
|
||||
}
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
final File folder = new File(plugin.getDataFolder(), "data");
|
||||
final File[] playerFiles = folder.listFiles();
|
||||
final Map<String, Integer> questPoints = new HashMap<>();
|
||||
if (playerFiles != null) {
|
||||
for (final File f : playerFiles) {
|
||||
if (!f.isDirectory()) {
|
||||
final FileConfiguration data = new YamlConfiguration();
|
||||
try {
|
||||
data.load(f);
|
||||
} catch (final IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
questPoints.put(data.getString("lastKnownName", "Unknown"),
|
||||
data.getInt("quest-points", 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
final LinkedHashMap<String, Integer> sortedMap = (LinkedHashMap<String, Integer>) sort(questPoints);
|
||||
int numPrinted = 0;
|
||||
String msg = Lang.get("topQuestersTitle");
|
||||
msg = msg.replace("<number>", ChatColor.DARK_PURPLE + "" + topNumber + ChatColor.GOLD);
|
||||
cs.sendMessage(ChatColor.GOLD + msg);
|
||||
for (final Map.Entry<String, Integer> entry : sortedMap.entrySet()) {
|
||||
numPrinted++;
|
||||
cs.sendMessage(ChatColor.YELLOW + String.valueOf(numPrinted) + ". " + entry.getKey() + " - "
|
||||
+ ChatColor.DARK_PURPLE + entry.getValue() + ChatColor.YELLOW + " "
|
||||
+ Lang.get("questPoints"));
|
||||
if (numPrinted == topNumber) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,167 @@
|
||||
/*
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.listeners;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.commands.quest.QuestCommandHandler;
|
||||
import me.blackvein.quests.commands.questadmin.QuestadminCommandHandler;
|
||||
import me.blackvein.quests.commands.quests.QuestsCommandHandler;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CommandManager implements CommandExecutor {
|
||||
private final Quests plugin;
|
||||
private final Map<String, Integer> commandSizes = new HashMap<>();
|
||||
private final Map<String, Integer> adminCommandSizes = new HashMap<>();
|
||||
|
||||
public CommandManager(final Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final @NotNull CommandSender cs, final @NotNull Command cmd,
|
||||
final @NotNull String label, final String[] args) {
|
||||
if (plugin.isLoading()) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("errorLoading"));
|
||||
return true;
|
||||
}
|
||||
if (cs instanceof Player) {
|
||||
if (!plugin.canUseQuests(((Player) cs).getUniqueId())) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get((Player) cs, "noPermission"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
final String error = validateCommand(cmd.getName(), args);
|
||||
if (error != null) {
|
||||
cs.sendMessage(error);
|
||||
return true;
|
||||
}
|
||||
if (cmd.getName().equalsIgnoreCase("quest")) {
|
||||
return new QuestCommandHandler(plugin).check(cs, args);
|
||||
} else if (cmd.getName().equalsIgnoreCase("quests")) {
|
||||
return new QuestsCommandHandler(plugin).check(cs, args);
|
||||
} else if (cmd.getName().equalsIgnoreCase("questadmin")) {
|
||||
return new QuestadminCommandHandler(plugin).check(cs, args);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
// [] - required
|
||||
// {} - optional
|
||||
if (plugin.getSettings().canTranslateSubCommands()) {
|
||||
commandSizes.put(Lang.get("COMMAND_LIST"), 1); // list {page}
|
||||
commandSizes.put(Lang.get("COMMAND_TAKE"), 2); // take [quest]
|
||||
commandSizes.put(Lang.get("COMMAND_QUIT"), 2); // quit [quest]
|
||||
commandSizes.put(Lang.get("COMMAND_EDITOR"), 1); // editor
|
||||
commandSizes.put(Lang.get("COMMAND_EVENTS_EDITOR"), 1); // actions
|
||||
commandSizes.put(Lang.get("COMMAND_CONDITIONS_EDITOR"), 1); // conditions
|
||||
commandSizes.put(Lang.get("COMMAND_STATS"), 1); // stats
|
||||
commandSizes.put(Lang.get("COMMAND_TOP"), 2); // top {number}
|
||||
commandSizes.put(Lang.get("COMMAND_INFO"), 1); // info
|
||||
commandSizes.put(Lang.get("COMMAND_JOURNAL"), 1); // journal
|
||||
adminCommandSizes.put(Lang.get("COMMAND_QUESTADMIN_STATS"), 2); // stats [player]
|
||||
adminCommandSizes.put(Lang.get("COMMAND_QUESTADMIN_GIVE"), 3); // give [player] [quest]
|
||||
adminCommandSizes.put(Lang.get("COMMAND_QUESTADMIN_QUIT"), 3); // quit [player] [quest]
|
||||
adminCommandSizes.put(Lang.get("COMMAND_QUESTADMIN_REMOVE"), 3); // remove [player] [quest]
|
||||
adminCommandSizes.put(Lang.get("COMMAND_QUESTADMIN_POINTS"), 3); // points [player] [amount]
|
||||
adminCommandSizes.put(Lang.get("COMMAND_QUESTADMIN_TAKEPOINTS"), 3); // takepoints [player] [amount]
|
||||
adminCommandSizes.put(Lang.get("COMMAND_QUESTADMIN_GIVEPOINTS"), 3); // givepoints [player] [amount]
|
||||
adminCommandSizes.put(Lang.get("COMMAND_QUESTADMIN_POINTSALL"), 2); // pointsall [amount]
|
||||
adminCommandSizes.put(Lang.get("COMMAND_QUESTADMIN_FINISH"), 3); // finish [player] [quest]
|
||||
adminCommandSizes.put(Lang.get("COMMAND_QUESTADMIN_NEXTSTAGE"), 3); // nextstage [player] [quest]
|
||||
adminCommandSizes.put(Lang.get("COMMAND_QUESTADMIN_SETSTAGE"), 4); // setstage [player] [quest] [stage]
|
||||
adminCommandSizes.put(Lang.get("COMMAND_QUESTADMIN_RESET"), 2); // reset [player]
|
||||
adminCommandSizes.put(Lang.get("COMMAND_QUESTADMIN_RELOAD"), 1); // reload
|
||||
} else {
|
||||
commandSizes.put("list", 1); // list {page}
|
||||
commandSizes.put("take", 2); // take [quest]
|
||||
commandSizes.put("quit", 2); // quit [quest]
|
||||
commandSizes.put("editor", 1); // editor
|
||||
commandSizes.put("actions", 1); // actions
|
||||
commandSizes.put("events", 1); // LEGACY - events
|
||||
commandSizes.put("conditions", 1); // conditions
|
||||
commandSizes.put("stats", 1); // stats
|
||||
commandSizes.put("top", 2); // top [number]
|
||||
commandSizes.put("info", 1); // info
|
||||
commandSizes.put("journal", 1); // journal
|
||||
adminCommandSizes.put("stats", 2); // stats [player]
|
||||
adminCommandSizes.put("give", 3); // give [player] [quest]
|
||||
adminCommandSizes.put("quit", 3); // quit [player] [quest]
|
||||
adminCommandSizes.put("remove", 3); // remove [player] [quest]
|
||||
adminCommandSizes.put("points", 3); // points [player] [amount]
|
||||
adminCommandSizes.put("takepoints", 3); // takepoints [player] [amount]
|
||||
adminCommandSizes.put("givepoints", 3); // givepoints [player] [amount]
|
||||
adminCommandSizes.put("pointsall", 2); // pointsall [amount]
|
||||
adminCommandSizes.put("finish", 3); // finish [player] [quest]
|
||||
adminCommandSizes.put("nextstage", 3); // nextstage [player] [quest]
|
||||
adminCommandSizes.put("setstage", 4); // setstage [player] [quest] [stage]
|
||||
adminCommandSizes.put("reset", 2); // reset [player]
|
||||
adminCommandSizes.put("reload", 1); // reload
|
||||
}
|
||||
}
|
||||
|
||||
public String validateCommand(final String cmd, final String[] args) {
|
||||
if (cmd.equalsIgnoreCase("quest") || args.length == 0) {
|
||||
return null;
|
||||
}
|
||||
if (cmd.equalsIgnoreCase("quests")) {
|
||||
String subCmd = args[0].toLowerCase();
|
||||
if (subCmd.equals("action")) {
|
||||
subCmd = "actions";
|
||||
} else if (subCmd.equals("condition")) {
|
||||
subCmd = "conditions";
|
||||
}
|
||||
if (commandSizes.containsKey(subCmd)) {
|
||||
final int min = commandSizes.get(subCmd);
|
||||
if (args.length < min) {
|
||||
return getQuestsCommandUsage(subCmd);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return ChatColor.YELLOW + Lang.get("questsUnknownCommand");
|
||||
} else if (cmd.equalsIgnoreCase("questsadmin") || cmd.equalsIgnoreCase("questadmin")) {
|
||||
final String subCmd = args[0].toLowerCase();
|
||||
if (adminCommandSizes.containsKey(subCmd)) {
|
||||
final int min = adminCommandSizes.get(subCmd);
|
||||
if (args.length < min) {
|
||||
return getQuestadminCommandUsage(subCmd);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return ChatColor.YELLOW + Lang.get("questsUnknownAdminCommand");
|
||||
}
|
||||
return "NULL";
|
||||
}
|
||||
|
||||
public String getQuestsCommandUsage(final String cmd) {
|
||||
return ChatColor.RED + Lang.get("usage") + ": " + ChatColor.YELLOW + "/quests "
|
||||
+ Lang.get(Lang.getKeyFromPrefix("COMMAND_", cmd) + "_HELP");
|
||||
}
|
||||
|
||||
public String getQuestadminCommandUsage(final String cmd) {
|
||||
return ChatColor.RED + Lang.get("usage") + ": " + ChatColor.YELLOW + "/questadmin "
|
||||
+ Lang.get(Lang.getKeyFromPrefix("COMMAND_QUESTADMIN_", cmd) + "_HELP");
|
||||
}
|
||||
}
|
@ -72,6 +72,7 @@ permissions:
|
||||
quests.admin.points: true
|
||||
quests.admin.takepoints: true
|
||||
quests.admin.givepoints: true
|
||||
quests.admin.pointsall: true
|
||||
quests.admin.finish: true
|
||||
quests.admin.nextstage: true
|
||||
quests.admin.setstage: true
|
||||
|
Loading…
Reference in New Issue
Block a user