Permit /questadmin commands on offline players, part 3. Per #1040

This commit is contained in:
PikaMug 2020-01-22 04:55:51 -05:00
parent 7d4a08d8b6
commit 2dea1eeebb
8 changed files with 470 additions and 397 deletions

View File

@ -201,8 +201,10 @@ public class Quest {
}
String stageCompleteMessage = currentStage.completeMessage;
if (stageCompleteMessage != null) {
quester.getPlayer().sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(stageCompleteMessage,
this, quester.getPlayer()));
if (quester.getOfflinePlayer().isOnline()) {
quester.getPlayer().sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(stageCompleteMessage,
this, quester.getPlayer()));
}
}
if (plugin.getSettings().canUseCompass()) {
quester.resetCompass();
@ -246,6 +248,7 @@ public class Quest {
/**
* Force player to proceed to the specified stage
*
* @param quester Player to force
* @param stage Stage number to specify
* @throws InvalidStageException if stage does not exist
@ -254,12 +257,15 @@ public class Quest {
if (orderedStages.size() - 1 < stage) {
throw new InvalidStageException(this, stage);
}
OfflinePlayer player = quester.getOfflinePlayer();
Stage currentStage = quester.getCurrentStage(this);
Stage nextStage = getStage(stage);
QuesterPreChangeStageEvent preEvent = new QuesterPreChangeStageEvent(quester, this, currentStage, nextStage);
plugin.getServer().getPluginManager().callEvent(preEvent);
if (preEvent.isCancelled()) {
return;
if (player.isOnline()) {
QuesterPreChangeStageEvent preEvent = new QuesterPreChangeStageEvent(quester, this, currentStage, nextStage);
plugin.getServer().getPluginManager().callEvent(preEvent);
if (preEvent.isCancelled()) {
return;
}
}
quester.hardQuit(this);
quester.hardStagePut(this, stage);
@ -271,18 +277,22 @@ public class Quest {
nextStage.startAction.fire(quester, this);
}
updateCompass(quester, nextStage);
String msg = Lang.get(quester.getPlayer(), "questObjectivesTitle");
msg = msg.replace("<quest>", name);
quester.getPlayer().sendMessage(ChatColor.GOLD + msg);
plugin.showObjectives(this, quester, false);
String stageStartMessage = quester.getCurrentStage(this).startMessage;
if (stageStartMessage != null) {
quester.getPlayer().sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(stageStartMessage, this,
quester.getPlayer()));
if (player.isOnline()) {
Player p = quester.getPlayer();
String msg = Lang.get(p, "questObjectivesTitle");
msg = msg.replace("<quest>", name);
p.sendMessage(ChatColor.GOLD + msg);
plugin.showObjectives(this, quester, false);
String stageStartMessage = quester.getCurrentStage(this).startMessage;
if (stageStartMessage != null) {
p.sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(stageStartMessage, this, p));
}
}
quester.updateJournal();
QuesterPostChangeStageEvent postEvent = new QuesterPostChangeStageEvent(quester, this, currentStage, nextStage);
plugin.getServer().getPluginManager().callEvent(postEvent);
if (player.isOnline()) {
QuesterPostChangeStageEvent postEvent = new QuesterPostChangeStageEvent(quester, this, currentStage, nextStage);
plugin.getServer().getPluginManager().callEvent(postEvent);
}
}
/**
@ -430,39 +440,45 @@ public class Quest {
}
/**
* Proceed to finish this quest, issuing any rewards
* Proceed to finish this quest, issuing applicable rewards
*
* @param q The quester finishing this quest
*/
@SuppressWarnings("deprecation")
public void completeQuest(Quester q) {
QuesterPreCompleteQuestEvent preEvent = new QuesterPreCompleteQuestEvent(q, this);
plugin.getServer().getPluginManager().callEvent(preEvent);
if (preEvent.isCancelled()) {
return;
OfflinePlayer player = q.getOfflinePlayer();
if (player.isOnline()) {
QuesterPreCompleteQuestEvent preEvent = new QuesterPreCompleteQuestEvent(q, this);
plugin.getServer().getPluginManager().callEvent(preEvent);
if (preEvent.isCancelled()) {
return;
}
}
final Player player = plugin.getServer().getPlayer(q.getUUID());
q.hardQuit(this);
if (!q.completedQuests.contains(name)) {
q.completedQuests.add(name);
}
String none = ChatColor.GRAY + "- (" + Lang.get(player, "none") + ")";
final String[] ps = plugin.parseStringWithPossibleLineBreaks(ChatColor.AQUA + finished, this, player);
for (Map.Entry<Integer, Quest> entry : q.timers.entrySet()) {
if (entry.getValue().getName().equals(getName())) {
plugin.getServer().getScheduler().cancelTask(entry.getKey());
q.timers.remove(entry.getKey());
}
}
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
String none = null;
if (player.isOnline()) {
Player p = (Player)player;
none = ChatColor.GRAY + "- (" + Lang.get(p, "none") + ")";
final String[] ps = ConfigUtil.parseStringWithPossibleLineBreaks(ChatColor.AQUA + finished, this, p);
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
player.sendMessage(ps);
}
}, 40);
@Override
public void run() {
p.sendMessage(ps);
}
}, 40);
}
if (rews.getMoney() > 0 && plugin.getDependencies().getVaultEconomy() != null) {
plugin.getDependencies().getVaultEconomy().depositPlayer(q.getOfflinePlayer(), rews.getMoney());
plugin.getDependencies().getVaultEconomy().depositPlayer(player, rews.getMoney());
none = null;
}
if (pln.getCooldown() > -1) {
@ -473,21 +489,24 @@ public class Quest {
q.amountsCompleted.put(this.name, 1);
}
}
for (ItemStack i : rews.getItems()) {
try {
InventoryUtil.addItem(player, i);
} catch (Exception e) {
plugin.getLogger().severe("Unable to add null reward item to inventory of "
+ player.getName() + " upon completion of quest " + name);
player.sendMessage(ChatColor.RED + "Quests encountered a problem with an item. "
+ "Please contact an administrator.");
if (player.isOnline()) {
Player p = (Player)player;
for (ItemStack i : rews.getItems()) {
try {
InventoryUtil.addItem(p, i);
} catch (Exception e) {
plugin.getLogger().severe("Unable to add null reward item to inventory of "
+ player.getName() + " upon completion of quest " + name);
p.sendMessage(ChatColor.RED + "Quests encountered a problem with an item. "
+ "Please contact an administrator.");
}
none = null;
}
none = null;
}
for (String s : rews.getCommands()) {
String temp = s.replace("<player>", player.getName());
if (plugin.getDependencies().getPlaceholderApi() != null) {
temp = PlaceholderAPI.setPlaceholders(player, temp);
if (plugin.getDependencies().getPlaceholderApi() != null && player.isOnline()) {
temp = PlaceholderAPI.setPlaceholders((Player)player, temp);
}
final String command = temp;
if (Bukkit.isPrimaryThread()) {
@ -503,22 +522,27 @@ public class Quest {
}
none = null;
}
for (String s : rews.getPermissions()) {
if (plugin.getDependencies().getVaultPermission() != null) {
plugin.getDependencies().getVaultPermission().playerAdd(player, s);
if (player.isOnline()) {
for (String s : rews.getPermissions()) {
if (plugin.getDependencies().getVaultPermission() != null) {
plugin.getDependencies().getVaultPermission().playerAdd((Player)player, s);
}
none = null;
}
none = null;
}
for (String s : rews.getMcmmoSkills()) {
UserManager.getPlayer(player).getProfile().addLevels(Quests.getMcMMOSkill(s),
UserManager.getOfflinePlayer(player).getProfile().addLevels(Quests.getMcMMOSkill(s),
rews.getMcmmoAmounts().get(rews.getMcmmoSkills().indexOf(s)));
none = null;
}
for (String s : rews.getHeroesClasses()) {
Hero hero = plugin.getHero(player.getUniqueId());
hero.addExp(rews.getHeroesAmounts().get(rews.getHeroesClasses().indexOf(s)),
plugin.getDependencies().getHeroes().getClassManager().getClass(s), player.getLocation());
none = null;
if (player.isOnline()) {
for (String s : rews.getHeroesClasses()) {
Hero hero = plugin.getHero(player.getUniqueId());
hero.addExp(rews.getHeroesAmounts().get(rews.getHeroesClasses().indexOf(s)),
plugin.getDependencies().getHeroes().getClassManager().getClass(s),
((Player)player).getLocation());
none = null;
}
}
LinkedList<ItemStack> phatLootItems = new LinkedList<ItemStack>();
int phatLootExp = 0;
@ -527,229 +551,241 @@ public class Quest {
LootBundle lb = PhatLootsAPI.getPhatLoot(s).rollForLoot();
if (lb.getExp() > 0) {
phatLootExp += lb.getExp();
player.giveExp(lb.getExp());
if (player.isOnline()) {
((Player)player).giveExp(lb.getExp());
}
}
if (lb.getMoney() > 0) {
if (plugin.getDependencies().getVaultEconomy() != null) {
plugin.getDependencies().getVaultEconomy()
.depositPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()), lb.getMoney());
.depositPlayer(player, lb.getMoney());
}
}
if (lb.getItemList().isEmpty() == false) {
phatLootItems.addAll(lb.getItemList());
for (ItemStack is : lb.getItemList()) {
try {
InventoryUtil.addItem(player, is);
} catch (Exception e) {
plugin.getLogger().severe("Unable to add PhatLoots item to inventory of " + player.getName()
+ " upon completion of quest " + name);
player.sendMessage(ChatColor.RED + "Quests encountered a problem with an item. "
+ "Please contact an administrator.");
if (player.isOnline()) {
Player p = (Player)player;
for (ItemStack is : lb.getItemList()) {
try {
InventoryUtil.addItem(p, is);
} catch (Exception e) {
plugin.getLogger().severe("Unable to add PhatLoots item to inventory of " + p.getName()
+ " upon completion of quest " + name);
p.sendMessage(ChatColor.RED + "Quests encountered a problem with an item. "
+ "Please contact an administrator.");
}
}
}
}
if (lb.getCommandList().isEmpty() == false) {
if (lb.getCommandList().isEmpty() == false && player.isOnline()) {
for (CommandLoot cl : lb.getCommandList()) {
cl.execute(player);
cl.execute((Player)player);
}
}
if (lb.getMessageList().isEmpty() == false) {
phatLootMessages.addAll(lb.getMessageList());
}
}
if (rews.getExp() > 0) {
player.giveExp(rews.getExp());
if (rews.getExp() > 0 && player.isOnline()) {
((Player)player).giveExp(rews.getExp());
none = null;
}
String complete = Lang.get(player, "questCompleteTitle");
complete = complete.replace("<quest>", ChatColor.YELLOW + name + ChatColor.GOLD);
player.sendMessage(ChatColor.GOLD + complete);
player.sendMessage(ChatColor.GREEN + Lang.get(player, "questRewardsTitle"));
if (plugin.getSettings().canShowQuestTitles()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + player.getName()
+ " title " + "{\"text\":\"" + Lang.get(player, "quest") + " " + Lang.get(player, "complete")
+ "\",\"color\":\"gold\"}");
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + player.getName()
+ " subtitle " + "{\"text\":\"" + name + "\",\"color\":\"yellow\"}");
}
if (rews.getQuestPoints() > 0) {
player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getQuestPoints() + " "
+ Lang.get(player, "questPoints"));
q.questPoints += rews.getQuestPoints();
none = null;
}
for (ItemStack i : rews.getItems()) {
String text = "error";
if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) {
if (i.getEnchantments().isEmpty()) {
text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
+ ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount();
} else {
text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
+ ChatColor.RESET;
try {
if (!i.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) {
text += ChatColor.GRAY + " " + Lang.get(player, "with") + ChatColor.DARK_PURPLE;
for (Entry<Enchantment, Integer> e : i.getEnchantments().entrySet()) {
text += " " + ItemUtil.getPrettyEnchantmentName(e.getKey()) + ":" + e.getValue();
if (player.isOnline()) {
Player p = (Player)player;
String complete = Lang.get(p, "questCompleteTitle");
complete = complete.replace("<quest>", ChatColor.YELLOW + name + ChatColor.GOLD);
p.sendMessage(ChatColor.GOLD + complete);
p.sendMessage(ChatColor.GREEN + Lang.get(p, "questRewardsTitle"));
if (plugin.getSettings().canShowQuestTitles()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + p.getName()
+ " title " + "{\"text\":\"" + Lang.get(p, "quest") + " " + Lang.get(p, "complete")
+ "\",\"color\":\"gold\"}");
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + p.getName()
+ " subtitle " + "{\"text\":\"" + name + "\",\"color\":\"yellow\"}");
}
if (rews.getQuestPoints() > 0) {
p.sendMessage("- " + ChatColor.DARK_GREEN + rews.getQuestPoints() + " "
+ Lang.get(p, "questPoints"));
q.questPoints += rews.getQuestPoints();
none = null;
}
for (ItemStack i : rews.getItems()) {
String text = "error";
if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) {
if (i.getEnchantments().isEmpty()) {
text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
+ ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount();
} else {
text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
+ ChatColor.RESET;
try {
if (!i.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) {
text += ChatColor.GRAY + " " + Lang.get(p, "with") + ChatColor.DARK_PURPLE;
for (Entry<Enchantment, Integer> e : i.getEnchantments().entrySet()) {
text += " " + ItemUtil.getPrettyEnchantmentName(e.getKey()) + ":" + e.getValue();
}
}
} catch (Throwable tr) {
// Do nothing, hasItemFlag() not introduced until 1.8.6
}
} catch (Throwable tr) {
// Do nothing, hasItemFlag() not introduced until 1.8.6
text += ChatColor.GRAY + " x " + i.getAmount();
}
text += ChatColor.GRAY + " x " + i.getAmount();
}
} else if (i.getDurability() != 0) {
if (i.getEnchantments().isEmpty()) {
text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY
+ " x " + i.getAmount();
} else {
text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY
+ " " + Lang.get(player, "with");
for (Entry<Enchantment, Integer> e : i.getEnchantments().entrySet()) {
text += " " + ItemUtil.getPrettyEnchantmentName(e.getKey()) + ":" + e.getValue();
} else if (i.getDurability() != 0) {
if (i.getEnchantments().isEmpty()) {
text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY
+ " x " + i.getAmount();
} else {
text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY
+ " " + Lang.get(p, "with");
for (Entry<Enchantment, Integer> e : i.getEnchantments().entrySet()) {
text += " " + ItemUtil.getPrettyEnchantmentName(e.getKey()) + ":" + e.getValue();
}
text += ChatColor.GRAY + " x " + i.getAmount();
}
text += ChatColor.GRAY + " x " + i.getAmount();
}
} else {
if (i.getEnchantments().isEmpty()) {
text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " + i.getAmount();
} else {
text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i);
try {
if (!i.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) {
text += ChatColor.GRAY + " " + Lang.get(player, "with");
for (Entry<Enchantment, Integer> e : i.getEnchantments().entrySet()) {
text += " " + ItemUtil.getPrettyEnchantmentName(e.getKey()) + ":" + e.getValue();
if (i.getEnchantments().isEmpty()) {
text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " + i.getAmount();
} else {
text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i);
try {
if (!i.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) {
text += ChatColor.GRAY + " " + Lang.get(p, "with");
for (Entry<Enchantment, Integer> e : i.getEnchantments().entrySet()) {
text += " " + ItemUtil.getPrettyEnchantmentName(e.getKey()) + ":" + e.getValue();
}
}
} catch (Throwable tr) {
// Do nothing, hasItemFlag() not introduced until 1.8.6
}
} catch (Throwable tr) {
// Do nothing, hasItemFlag() not introduced until 1.8.6
text += ChatColor.GRAY + " x " + i.getAmount();
}
text += ChatColor.GRAY + " x " + i.getAmount();
}
p.sendMessage(text);
none = null;
}
player.sendMessage(text);
none = null;
}
for (ItemStack i : phatLootItems) {
if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) {
if (i.getEnchantments().isEmpty()) {
player.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
+ ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount());
} else {
player.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
+ ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " "
+ Lang.get(player, "enchantedItem"));
}
} else if (i.getDurability() != 0) {
if (i.getEnchantments().isEmpty()) {
player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability()
+ ChatColor.GRAY + " x " + i.getAmount());
} else {
player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability()
+ ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " "
+ Lang.get(player, "enchantedItem"));
}
} else {
if (i.getEnchantments().isEmpty()) {
player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x "
+ i.getAmount());
} else {
player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x "
+ i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get(player, "enchantedItem"));
}
}
none = null;
}
if (rews.getMoney() > 1) {
player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMoney() + " " + ChatColor.DARK_PURPLE
+ plugin.getCurrency(true));
none = null;
} else if (rews.getMoney() == 1) {
player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMoney() + " " + ChatColor.DARK_PURPLE
+ plugin.getCurrency(false));
none = null;
}
if (rews.getExp() > 0 || phatLootExp > 0) {
int tot = rews.getExp() + phatLootExp;
player.sendMessage("- " + ChatColor.DARK_GREEN + tot + ChatColor.DARK_PURPLE + " "
+ Lang.get(player, "experience"));
none = null;
}
if (rews.getCommands().isEmpty() == false) {
int index = 0;
for (String s : rews.getCommands()) {
if (rews.getCommandsOverrideDisplay().isEmpty() == false && rews.getCommandsOverrideDisplay().size()
> index) {
if (!rews.getCommandsOverrideDisplay().get(index).trim().equals("")) {
player.sendMessage("- " + ChatColor.DARK_GREEN
+ rews.getCommandsOverrideDisplay().get(index));
for (ItemStack i : phatLootItems) {
if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) {
if (i.getEnchantments().isEmpty()) {
p.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
+ ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount());
} else {
p.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
+ ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " "
+ Lang.get(p, "enchantedItem"));
}
} else if (i.getDurability() != 0) {
if (i.getEnchantments().isEmpty()) {
p.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability()
+ ChatColor.GRAY + " x " + i.getAmount());
} else {
p.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability()
+ ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " "
+ Lang.get(p, "enchantedItem"));
}
} else {
player.sendMessage("- " + ChatColor.DARK_GREEN + s);
}
index++;
}
none = null;
}
if (rews.getMcmmoSkills().isEmpty() == false) {
for (String s : rews.getMcmmoSkills()) {
player.sendMessage("- " + ChatColor.DARK_GREEN
+ rews.getMcmmoAmounts().get(rews.getMcmmoSkills().indexOf(s)) + " " + ChatColor.DARK_PURPLE
+ s + " " + Lang.get(player, "experience"));
}
none = null;
}
if (rews.getHeroesClasses().isEmpty() == false) {
for (String s : rews.getHeroesClasses()) {
player.sendMessage("- " + ChatColor.AQUA
+ rews.getHeroesAmounts().get(rews.getHeroesClasses().indexOf(s)) + " " + ChatColor.BLUE
+ s + " " + Lang.get(player, "experience"));
}
none = null;
}
if (phatLootMessages.isEmpty() == false) {
for (String s : phatLootMessages) {
player.sendMessage("- " + s);
}
none = null;
}
for (String s : rews.getCustomRewards().keySet()) {
CustomReward found = null;
for (CustomReward cr : plugin.getCustomRewards()) {
if (cr.getName().equalsIgnoreCase(s)) {
found = cr;
break;
}
}
if (found != null) {
Map<String, Object> datamap = rews.getCustomRewards().get(found.getName());
String message = found.getRewardName();
if (message != null) {
for (String key : datamap.keySet()) {
message = message.replace("%" + key + "%", datamap.get(key).toString());
if (i.getEnchantments().isEmpty()) {
p.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x "
+ i.getAmount());
} else {
p.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x "
+ i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get(p, "enchantedItem"));
}
player.sendMessage("- " + ChatColor.GOLD + message);
} else {
plugin.getLogger().warning("Failed to notify player: Custom Reward does not have an assigned name");
}
found.giveReward(player, rews.getCustomRewards().get(s));
} else {
plugin.getLogger().warning("Quester \"" + player.getName() + "\" completed the Quest \"" + name
+ "\", but the Custom Reward \"" + s + "\" could not be found. Does it still exist?");
none = null;
}
if (rews.getMoney() > 1) {
p.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMoney() + " " + ChatColor.DARK_PURPLE
+ plugin.getCurrency(true));
none = null;
} else if (rews.getMoney() == 1) {
p.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMoney() + " " + ChatColor.DARK_PURPLE
+ plugin.getCurrency(false));
none = null;
}
if (rews.getExp() > 0 || phatLootExp > 0) {
int tot = rews.getExp() + phatLootExp;
p.sendMessage("- " + ChatColor.DARK_GREEN + tot + ChatColor.DARK_PURPLE + " "
+ Lang.get(p, "experience"));
none = null;
}
if (rews.getCommands().isEmpty() == false) {
int index = 0;
for (String s : rews.getCommands()) {
if (rews.getCommandsOverrideDisplay().isEmpty() == false && rews.getCommandsOverrideDisplay().size()
> index) {
if (!rews.getCommandsOverrideDisplay().get(index).trim().equals("")) {
p.sendMessage("- " + ChatColor.DARK_GREEN
+ rews.getCommandsOverrideDisplay().get(index));
}
} else {
p.sendMessage("- " + ChatColor.DARK_GREEN + s);
}
index++;
}
none = null;
}
if (rews.getMcmmoSkills().isEmpty() == false) {
for (String s : rews.getMcmmoSkills()) {
p.sendMessage("- " + ChatColor.DARK_GREEN
+ rews.getMcmmoAmounts().get(rews.getMcmmoSkills().indexOf(s)) + " " + ChatColor.DARK_PURPLE
+ s + " " + Lang.get(p, "experience"));
}
none = null;
}
if (rews.getHeroesClasses().isEmpty() == false) {
for (String s : rews.getHeroesClasses()) {
p.sendMessage("- " + ChatColor.AQUA
+ rews.getHeroesAmounts().get(rews.getHeroesClasses().indexOf(s)) + " " + ChatColor.BLUE
+ s + " " + Lang.get(p, "experience"));
}
none = null;
}
if (phatLootMessages.isEmpty() == false) {
for (String s : phatLootMessages) {
p.sendMessage("- " + s);
}
none = null;
}
for (String s : rews.getCustomRewards().keySet()) {
CustomReward found = null;
for (CustomReward cr : plugin.getCustomRewards()) {
if (cr.getName().equalsIgnoreCase(s)) {
found = cr;
break;
}
}
if (found != null) {
Map<String, Object> datamap = rews.getCustomRewards().get(found.getName());
String message = found.getRewardName();
if (message != null) {
for (String key : datamap.keySet()) {
message = message.replace("%" + key + "%", datamap.get(key).toString());
}
p.sendMessage("- " + ChatColor.GOLD + message);
} else {
plugin.getLogger().warning("Failed to notify player: Custom Reward does not have an assigned name");
}
found.giveReward(p, rews.getCustomRewards().get(s));
} else {
plugin.getLogger().warning("Quester \"" + player.getName() + "\" completed the Quest \"" + name
+ "\", but the Custom Reward \"" + s + "\" could not be found. Does it still exist?");
}
none = null;
}
if (none != null) {
p.sendMessage(none);
}
none = null;
}
if (none != null) {
player.sendMessage(none);
}
q.saveData();
player.updateInventory();
if (player.isOnline()) {
((Player)player).updateInventory();
}
q.updateJournal();
q.findCompassTarget();
QuesterPostCompleteQuestEvent postEvent = new QuesterPostCompleteQuestEvent(q, this);
plugin.getServer().getPluginManager().callEvent(postEvent);
if (player.isOnline()) {
QuesterPostCompleteQuestEvent postEvent = new QuesterPostCompleteQuestEvent(q, this);
plugin.getServer().getPluginManager().callEvent(postEvent);
}
// Multiplayer
if (opts.getShareProgressLevel() == 4) {
@ -765,7 +801,7 @@ public class Quest {
/**
* Force player to quit quest and inform them of their failure
*
* @param q The player to ejected
* @param q The quester to be ejected
*/
@SuppressWarnings("deprecation")
public void failQuest(Quester q) {

View File

@ -28,7 +28,6 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Location;
@ -304,11 +303,11 @@ public class Quester {
}
public Player getPlayer() {
return Bukkit.getServer().getPlayer(id);
return plugin.getServer().getPlayer(id);
}
public OfflinePlayer getOfflinePlayer() {
return Bukkit.getServer().getOfflinePlayer(id);
return plugin.getServer().getOfflinePlayer(id);
}
public Stage getCurrentStage(Quest quest) {
@ -516,10 +515,10 @@ public class Quester {
p.sendMessage(ChatColor.GREEN + accepted);
p.sendMessage("");
if (plugin.getSettings().canShowQuestTitles()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title "
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "title "
+ player.getName() + " title " + "{\"text\":\"" + Lang.get(getPlayer(), "quest") + " "
+ Lang.get(getPlayer(), "accepted") + "\",\"color\":\"gold\"}");
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title "
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "title "
+ player.getName() + " subtitle " + "{\"text\":\"" + q.getName()
+ "\",\"color\":\"yellow\"}");
}
@ -3272,7 +3271,7 @@ public class Quester {
}
Player player = getPlayer();
int size = ((quests.size() / 9) + 1) * 9;
Inventory inv = Bukkit.getServer().createInventory(player, size, Lang.get(player, "quests") + " | "
Inventory inv = plugin.getServer().createInventory(player, size, Lang.get(player, "quests") + " | "
+ npc.getName());
int inc = 0;
for (int i = 0; i < quests.size(); i++) {

View File

@ -1316,10 +1316,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
/**
* Get online Quester from player UUID
* Get Quester from player UUID
*
* @param id Player UUID
* @return Quester, or null if offline
* @return Quester, or null if not found
*/
public Quester getQuester(UUID id) {
Quester quester = null;

View File

@ -19,7 +19,7 @@ import me.blackvein.quests.Quester;
import me.blackvein.quests.Stage;
/**
* Called after a quester changes stage
* Called after an online quester changes stage
*/
public class QuesterPostChangeStageEvent extends QuesterEvent {
private static final HandlerList handlers = new HandlerList();

View File

@ -18,7 +18,7 @@ import me.blackvein.quests.Quest;
import me.blackvein.quests.Quester;
/**
* Called after a quester completes a quest
* Called after an online quester completes a quest
*/
public class QuesterPostCompleteQuestEvent extends QuesterEvent {
private static final HandlerList handlers = new HandlerList();

View File

@ -20,7 +20,7 @@ import me.blackvein.quests.Quester;
import me.blackvein.quests.Stage;
/**
* Called before a quester changes stage
* Called before an online quester changes stage
*/
public class QuesterPreChangeStageEvent extends QuesterEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();

View File

@ -19,7 +19,7 @@ import me.blackvein.quests.Quest;
import me.blackvein.quests.Quester;
/**
* Called before a quester completes a quest
* Called before an online quester completes a quest
*/
public class QuesterPreCompleteQuestEvent extends QuesterEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();

View File

@ -580,23 +580,23 @@ public class CmdExecutor implements CommandExecutor {
return true;
}
@SuppressWarnings("deprecation")
private void questsStats(final CommandSender cs, String[] args) {
Quester quester;
OfflinePlayer target;
if (args != null) {
quester = plugin.getQuester(args[1]);
if (quester == null) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
return;
} else if (Bukkit.getOfflinePlayer(quester.getUUID()).getName() != null) {
cs.sendMessage(ChatColor.GOLD + "- " + Bukkit.getOfflinePlayer(quester.getUUID()).getName() + " -");
} else {
cs.sendMessage(ChatColor.GOLD + "- " + args[1] + " -");
target = getPlayer(args[1]);
if (target == null) {
try {
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
} catch (IllegalArgumentException e) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
return;
}
}
} else {
quester = plugin.getQuester(((Player) cs).getUniqueId());
cs.sendMessage(ChatColor.GOLD + "- " + ((Player) cs).getName() + " -");
target = Bukkit.getOfflinePlayer(((Player)cs).getUniqueId());
}
Quester quester = plugin.getQuester(target.getUniqueId());
cs.sendMessage(ChatColor.GOLD + "- " + target.getName() + " -");
cs.sendMessage(ChatColor.YELLOW + Lang.get("questPointsDisplay") + " " + ChatColor.DARK_PURPLE
+ quester.getQuestPoints());
if (quester.getCurrentQuests().isEmpty()) {
@ -898,28 +898,36 @@ public class CmdExecutor implements CommandExecutor {
private void adminGivePoints(final CommandSender cs, String[] args) {
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.givepoints")) {
Player target = getPlayer(args[1]);
OfflinePlayer target = getPlayer(args[1]);
if (target == null) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
} else {
int points;
try {
points = Integer.parseInt(args[2]);
Quester quester = plugin.getQuester(target.getUniqueId());
quester.setQuestPoints(quester.getQuestPoints() + Math.abs(points));
String msg1 = Lang.get("giveQuestPoints");
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);
String msg2 = Lang.get(target, "questPointsGiven");
msg2 = msg2.replace("<player>", ChatColor.GREEN + cs.getName() + ChatColor.GOLD);
msg2 = msg2.replace("<number>", ChatColor.DARK_PURPLE + "" + points + ChatColor.GOLD);
target.sendMessage(ChatColor.GREEN + msg2);
quester.saveData();
} catch (NumberFormatException e) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
} catch (IllegalArgumentException e) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
return;
}
}
int points;
try {
points = Integer.parseInt(args[2]);
} catch (NumberFormatException e) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
return;
}
Quester quester = plugin.getQuester(target.getUniqueId());
quester.setQuestPoints(quester.getQuestPoints() + Math.abs(points));
String msg1 = Lang.get("giveQuestPoints");
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()) {
Player p = (Player)target;
String msg2 = Lang.get(p, "questPointsGiven");
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"));
}
@ -927,29 +935,36 @@ public class CmdExecutor implements CommandExecutor {
private void adminTakePoints(final CommandSender cs, String[] args) {
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.takepoints")) {
Player target = getPlayer(args[1]);
OfflinePlayer target = getPlayer(args[1]);
if (target == null) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
} else {
int points;
try {
points = Integer.parseInt(args[2]);
} catch (NumberFormatException e) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
} catch (IllegalArgumentException e) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
return;
}
Quester quester = plugin.getQuester(target.getUniqueId());
quester.setQuestPoints(quester.getQuestPoints() - Math.abs(points));
String msg1 = Lang.get("takeQuestPoints");
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);
String msg2 = Lang.get(target, "questPointsTaken");
}
int points;
try {
points = Integer.parseInt(args[2]);
} catch (NumberFormatException e) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
return;
}
Quester quester = plugin.getQuester(target.getUniqueId());
quester.setQuestPoints(quester.getQuestPoints() - Math.abs(points));
String msg1 = Lang.get("takeQuestPoints");
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()) {
Player p = (Player)target;
String msg2 = Lang.get(p, "questPointsTaken");
msg2 = msg2.replace("<player>", ChatColor.GREEN + cs.getName() + ChatColor.GOLD);
msg2 = msg2.replace("<number>", ChatColor.DARK_PURPLE + "" + points + ChatColor.GOLD);
target.sendMessage(ChatColor.GREEN + msg2);
quester.saveData();
p.sendMessage(ChatColor.GREEN + msg2);
}
quester.saveData();
} else {
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
}
@ -957,29 +972,36 @@ public class CmdExecutor implements CommandExecutor {
private void adminPoints(final CommandSender cs, String[] args) {
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.points")) {
Player target = getPlayer(args[1]);
OfflinePlayer target = getPlayer(args[1]);
if (target == null) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
} else {
int points;
try {
points = Integer.parseInt(args[2]);
} catch (NumberFormatException e) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
} catch (IllegalArgumentException e) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
return;
}
Quester quester = plugin.getQuester(target.getUniqueId());
quester.setQuestPoints(points);
String msg1 = Lang.get("setQuestPoints");
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);
String msg2 = Lang.get("questPointsSet");
}
int points;
try {
points = Integer.parseInt(args[2]);
} catch (NumberFormatException e) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
return;
}
Quester quester = plugin.getQuester(target.getUniqueId());
quester.setQuestPoints(points);
String msg1 = Lang.get("setQuestPoints");
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()) {
Player p = (Player)target;
String msg2 = Lang.get(p, "questPointsSet");
msg2 = msg2.replace("<player>", ChatColor.GREEN + cs.getName() + ChatColor.GOLD);
msg2 = msg2.replace("<number>", ChatColor.DARK_PURPLE + "" + points + ChatColor.GOLD);
target.sendMessage(ChatColor.GREEN + msg2);
quester.saveData();
p.sendMessage(ChatColor.GREEN + msg2);
}
quester.saveData();
} else {
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
}
@ -1120,32 +1142,39 @@ public class CmdExecutor implements CommandExecutor {
private void adminFinish(final CommandSender cs, String[] args) {
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.finish")) {
Player target = getPlayer(args[1]);
OfflinePlayer target = getPlayer(args[1]);
if (target == null) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
try {
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
} catch (IllegalArgumentException e) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
return;
}
}
Quester quester = plugin.getQuester(target.getUniqueId());
if (quester.getCurrentQuests().isEmpty()) {
String msg = Lang.get("noCurrentQuest");
msg = msg.replace("<player>", target.getName());
cs.sendMessage(ChatColor.YELLOW + msg);
} else {
Quester quester = plugin.getQuester(target.getUniqueId());
if (quester.getCurrentQuests().isEmpty()) {
String msg = Lang.get("noCurrentQuest");
msg = msg.replace("<player>", target.getName());
cs.sendMessage(ChatColor.YELLOW + msg);
} else {
Quest quest = plugin.getQuest(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);
String msg2 = Lang.get(target, "questForcedFinish");
Quest quest = plugin.getQuest(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()) {
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);
target.sendMessage(ChatColor.GREEN + msg2);
quest.completeQuest(quester);
quester.saveData();
p.sendMessage(ChatColor.GREEN + msg2);
}
quest.completeQuest(quester);
quester.saveData();
}
} else {
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
@ -1154,13 +1183,13 @@ public class CmdExecutor implements CommandExecutor {
private void adminSetStage(final CommandSender cs, String[] args) {
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.setstage")) {
Player target = getPlayer(args[1]);
OfflinePlayer target = getPlayer(args[1]);
if (target == null) {
for (Player p : plugin.getServer().getOnlinePlayers()) {
if (p.getName().toLowerCase().contains(args[1].toLowerCase())) {
target = p;
break;
}
try {
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
} catch (IllegalArgumentException e) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
return;
}
}
int stage = -1;
@ -1174,29 +1203,25 @@ public class CmdExecutor implements CommandExecutor {
cs.sendMessage(ChatColor.YELLOW + Lang.get("COMMAND_QUESTADMIN_SETSTAGE_USAGE"));
return;
}
if (target == null) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
Quester quester = plugin.getQuester(target.getUniqueId());
if (quester.getCurrentQuests().isEmpty()) {
String msg = Lang.get("noCurrentQuest");
msg = msg.replace("<player>", target.getName());
cs.sendMessage(ChatColor.YELLOW + msg);
} else {
Quester quester = plugin.getQuester(target.getUniqueId());
if (quester.getCurrentQuests().isEmpty()) {
String msg = Lang.get("noCurrentQuest");
msg = msg.replace("<player>", target.getName());
cs.sendMessage(ChatColor.YELLOW + msg);
} else {
Quest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 2, ' '));
if (quest == null) {
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
return;
}
try {
quest.setStage(quester, stage - 1);
} catch (InvalidStageException e) {
String msg = Lang.get("invalidStageNum");
msg = msg.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.RED);
cs.sendMessage(ChatColor.RED + msg);
}
quester.saveData();
Quest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 2, ' '));
if (quest == null) {
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
return;
}
try {
quest.setStage(quester, stage - 1);
} catch (InvalidStageException e) {
String msg = Lang.get("invalidStageNum");
msg = msg.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.RED);
cs.sendMessage(ChatColor.RED + msg);
}
quester.saveData();
}
} else {
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
@ -1205,32 +1230,39 @@ public class CmdExecutor implements CommandExecutor {
private void adminNextStage(final CommandSender cs, String[] args) {
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.nextstage")) {
Player target = getPlayer(args[1]);
OfflinePlayer target = getPlayer(args[1]);
if (target == null) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
try {
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
} catch (IllegalArgumentException e) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
return;
}
}
Quester quester = plugin.getQuester(target.getUniqueId());
if (quester.getCurrentQuests().isEmpty()) {
String msg = Lang.get("noCurrentQuest");
msg = msg.replace("<player>", target.getName());
cs.sendMessage(ChatColor.YELLOW + msg);
} else {
Quester quester = plugin.getQuester(target.getUniqueId());
if (quester.getCurrentQuests().isEmpty()) {
String msg = Lang.get("noCurrentQuest");
msg = msg.replace("<player>", target.getName());
cs.sendMessage(ChatColor.YELLOW + msg);
} else {
Quest quest = plugin.getQuest(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);
String msg2 = Lang.get(target, "questForcedNextStage");
Quest quest = plugin.getQuest(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()) {
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);
target.sendMessage(ChatColor.GREEN + msg2);
quest.nextStage(quester, false);
quester.saveData();
p.sendMessage(ChatColor.GREEN + msg2);
}
quest.nextStage(quester, false);
quester.saveData();
}
} else {
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
@ -1281,13 +1313,16 @@ public class CmdExecutor implements CommandExecutor {
private void adminReset(final CommandSender cs, String[] args) {
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.reset")) {
@SuppressWarnings("deprecation")
Quester quester = plugin.getQuester(args[1]);
if (quester == null) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
return;
OfflinePlayer target = getPlayer(args[1]);
if (target == null) {
try {
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
} catch (IllegalArgumentException e) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
return;
}
}
UUID id = quester.getUUID();
UUID id = target.getUniqueId();
LinkedList<Quester> temp = plugin.getQuesters();
for(Iterator<Quester> itr = temp.iterator(); itr.hasNext();) {
if (itr.next().getUUID().equals(id)) {
@ -1295,6 +1330,7 @@ public class CmdExecutor implements CommandExecutor {
}
}
plugin.setQuesters(temp);
Quester quester = plugin.getQuester(target.getUniqueId());
try {
quester.hardClear();
quester.saveData();
@ -1303,9 +1339,8 @@ public class CmdExecutor implements CommandExecutor {
final File quest = new File(dataFolder, id + ".yml");
quest.delete();
String msg = Lang.get("questReset");
if (Bukkit.getOfflinePlayer(id).getName() != null) {
msg = msg.replace("<player>", ChatColor.GREEN + Bukkit.getOfflinePlayer(id).getName()
+ ChatColor.GOLD);
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);
}
@ -1335,21 +1370,24 @@ public class CmdExecutor implements CommandExecutor {
private void adminRemove(final CommandSender cs, String[] args) {
if (cs.hasPermission("quests.admin.*") && cs.hasPermission("quests.admin.remove")) {
@SuppressWarnings("deprecation")
Quester quester = plugin.getQuester(args[1]);
if (quester == null) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
return;
OfflinePlayer target = getPlayer(args[1]);
if (target == null) {
try {
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
} catch (IllegalArgumentException e) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
return;
}
}
Quest toRemove = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
if (toRemove == null) {
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
return;
}
Quester quester = plugin.getQuester(target.getUniqueId());
String msg = Lang.get("questRemoved");
if (Bukkit.getOfflinePlayer(quester.getUUID()).getName() != null) {
msg = msg.replace("<player>", ChatColor.GREEN + Bukkit.getOfflinePlayer(quester.getUUID()).getName()
+ ChatColor.GOLD);
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);
}