mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-28 05:35:33 +01:00
Permit /questadmin commands on offline players, part 3. Per #1040
This commit is contained in:
parent
7d4a08d8b6
commit
2dea1eeebb
@ -201,8 +201,10 @@ public class Quest {
|
|||||||
}
|
}
|
||||||
String stageCompleteMessage = currentStage.completeMessage;
|
String stageCompleteMessage = currentStage.completeMessage;
|
||||||
if (stageCompleteMessage != null) {
|
if (stageCompleteMessage != null) {
|
||||||
quester.getPlayer().sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(stageCompleteMessage,
|
if (quester.getOfflinePlayer().isOnline()) {
|
||||||
this, quester.getPlayer()));
|
quester.getPlayer().sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(stageCompleteMessage,
|
||||||
|
this, quester.getPlayer()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (plugin.getSettings().canUseCompass()) {
|
if (plugin.getSettings().canUseCompass()) {
|
||||||
quester.resetCompass();
|
quester.resetCompass();
|
||||||
@ -246,6 +248,7 @@ public class Quest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Force player to proceed to the specified stage
|
* Force player to proceed to the specified stage
|
||||||
|
*
|
||||||
* @param quester Player to force
|
* @param quester Player to force
|
||||||
* @param stage Stage number to specify
|
* @param stage Stage number to specify
|
||||||
* @throws InvalidStageException if stage does not exist
|
* @throws InvalidStageException if stage does not exist
|
||||||
@ -254,12 +257,15 @@ public class Quest {
|
|||||||
if (orderedStages.size() - 1 < stage) {
|
if (orderedStages.size() - 1 < stage) {
|
||||||
throw new InvalidStageException(this, stage);
|
throw new InvalidStageException(this, stage);
|
||||||
}
|
}
|
||||||
|
OfflinePlayer player = quester.getOfflinePlayer();
|
||||||
Stage currentStage = quester.getCurrentStage(this);
|
Stage currentStage = quester.getCurrentStage(this);
|
||||||
Stage nextStage = getStage(stage);
|
Stage nextStage = getStage(stage);
|
||||||
QuesterPreChangeStageEvent preEvent = new QuesterPreChangeStageEvent(quester, this, currentStage, nextStage);
|
if (player.isOnline()) {
|
||||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
QuesterPreChangeStageEvent preEvent = new QuesterPreChangeStageEvent(quester, this, currentStage, nextStage);
|
||||||
if (preEvent.isCancelled()) {
|
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||||
return;
|
if (preEvent.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
quester.hardQuit(this);
|
quester.hardQuit(this);
|
||||||
quester.hardStagePut(this, stage);
|
quester.hardStagePut(this, stage);
|
||||||
@ -271,18 +277,22 @@ public class Quest {
|
|||||||
nextStage.startAction.fire(quester, this);
|
nextStage.startAction.fire(quester, this);
|
||||||
}
|
}
|
||||||
updateCompass(quester, nextStage);
|
updateCompass(quester, nextStage);
|
||||||
String msg = Lang.get(quester.getPlayer(), "questObjectivesTitle");
|
if (player.isOnline()) {
|
||||||
msg = msg.replace("<quest>", name);
|
Player p = quester.getPlayer();
|
||||||
quester.getPlayer().sendMessage(ChatColor.GOLD + msg);
|
String msg = Lang.get(p, "questObjectivesTitle");
|
||||||
plugin.showObjectives(this, quester, false);
|
msg = msg.replace("<quest>", name);
|
||||||
String stageStartMessage = quester.getCurrentStage(this).startMessage;
|
p.sendMessage(ChatColor.GOLD + msg);
|
||||||
if (stageStartMessage != null) {
|
plugin.showObjectives(this, quester, false);
|
||||||
quester.getPlayer().sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(stageStartMessage, this,
|
String stageStartMessage = quester.getCurrentStage(this).startMessage;
|
||||||
quester.getPlayer()));
|
if (stageStartMessage != null) {
|
||||||
|
p.sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(stageStartMessage, this, p));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
quester.updateJournal();
|
quester.updateJournal();
|
||||||
QuesterPostChangeStageEvent postEvent = new QuesterPostChangeStageEvent(quester, this, currentStage, nextStage);
|
if (player.isOnline()) {
|
||||||
plugin.getServer().getPluginManager().callEvent(postEvent);
|
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
|
* @param q The quester finishing this quest
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void completeQuest(Quester q) {
|
public void completeQuest(Quester q) {
|
||||||
QuesterPreCompleteQuestEvent preEvent = new QuesterPreCompleteQuestEvent(q, this);
|
OfflinePlayer player = q.getOfflinePlayer();
|
||||||
plugin.getServer().getPluginManager().callEvent(preEvent);
|
if (player.isOnline()) {
|
||||||
if (preEvent.isCancelled()) {
|
QuesterPreCompleteQuestEvent preEvent = new QuesterPreCompleteQuestEvent(q, this);
|
||||||
return;
|
plugin.getServer().getPluginManager().callEvent(preEvent);
|
||||||
|
if (preEvent.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
final Player player = plugin.getServer().getPlayer(q.getUUID());
|
|
||||||
q.hardQuit(this);
|
q.hardQuit(this);
|
||||||
if (!q.completedQuests.contains(name)) {
|
if (!q.completedQuests.contains(name)) {
|
||||||
q.completedQuests.add(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()) {
|
for (Map.Entry<Integer, Quest> entry : q.timers.entrySet()) {
|
||||||
if (entry.getValue().getName().equals(getName())) {
|
if (entry.getValue().getName().equals(getName())) {
|
||||||
plugin.getServer().getScheduler().cancelTask(entry.getKey());
|
plugin.getServer().getScheduler().cancelTask(entry.getKey());
|
||||||
q.timers.remove(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
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
player.sendMessage(ps);
|
p.sendMessage(ps);
|
||||||
}
|
}
|
||||||
}, 40);
|
}, 40);
|
||||||
|
}
|
||||||
if (rews.getMoney() > 0 && plugin.getDependencies().getVaultEconomy() != null) {
|
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;
|
none = null;
|
||||||
}
|
}
|
||||||
if (pln.getCooldown() > -1) {
|
if (pln.getCooldown() > -1) {
|
||||||
@ -473,21 +489,24 @@ public class Quest {
|
|||||||
q.amountsCompleted.put(this.name, 1);
|
q.amountsCompleted.put(this.name, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ItemStack i : rews.getItems()) {
|
if (player.isOnline()) {
|
||||||
try {
|
Player p = (Player)player;
|
||||||
InventoryUtil.addItem(player, i);
|
for (ItemStack i : rews.getItems()) {
|
||||||
} catch (Exception e) {
|
try {
|
||||||
plugin.getLogger().severe("Unable to add null reward item to inventory of "
|
InventoryUtil.addItem(p, i);
|
||||||
+ player.getName() + " upon completion of quest " + name);
|
} catch (Exception e) {
|
||||||
player.sendMessage(ChatColor.RED + "Quests encountered a problem with an item. "
|
plugin.getLogger().severe("Unable to add null reward item to inventory of "
|
||||||
+ "Please contact an administrator.");
|
+ 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()) {
|
for (String s : rews.getCommands()) {
|
||||||
String temp = s.replace("<player>", player.getName());
|
String temp = s.replace("<player>", player.getName());
|
||||||
if (plugin.getDependencies().getPlaceholderApi() != null) {
|
if (plugin.getDependencies().getPlaceholderApi() != null && player.isOnline()) {
|
||||||
temp = PlaceholderAPI.setPlaceholders(player, temp);
|
temp = PlaceholderAPI.setPlaceholders((Player)player, temp);
|
||||||
}
|
}
|
||||||
final String command = temp;
|
final String command = temp;
|
||||||
if (Bukkit.isPrimaryThread()) {
|
if (Bukkit.isPrimaryThread()) {
|
||||||
@ -503,22 +522,27 @@ public class Quest {
|
|||||||
}
|
}
|
||||||
none = null;
|
none = null;
|
||||||
}
|
}
|
||||||
for (String s : rews.getPermissions()) {
|
if (player.isOnline()) {
|
||||||
if (plugin.getDependencies().getVaultPermission() != null) {
|
for (String s : rews.getPermissions()) {
|
||||||
plugin.getDependencies().getVaultPermission().playerAdd(player, s);
|
if (plugin.getDependencies().getVaultPermission() != null) {
|
||||||
|
plugin.getDependencies().getVaultPermission().playerAdd((Player)player, s);
|
||||||
|
}
|
||||||
|
none = null;
|
||||||
}
|
}
|
||||||
none = null;
|
|
||||||
}
|
}
|
||||||
for (String s : rews.getMcmmoSkills()) {
|
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)));
|
rews.getMcmmoAmounts().get(rews.getMcmmoSkills().indexOf(s)));
|
||||||
none = null;
|
none = null;
|
||||||
}
|
}
|
||||||
for (String s : rews.getHeroesClasses()) {
|
if (player.isOnline()) {
|
||||||
Hero hero = plugin.getHero(player.getUniqueId());
|
for (String s : rews.getHeroesClasses()) {
|
||||||
hero.addExp(rews.getHeroesAmounts().get(rews.getHeroesClasses().indexOf(s)),
|
Hero hero = plugin.getHero(player.getUniqueId());
|
||||||
plugin.getDependencies().getHeroes().getClassManager().getClass(s), player.getLocation());
|
hero.addExp(rews.getHeroesAmounts().get(rews.getHeroesClasses().indexOf(s)),
|
||||||
none = null;
|
plugin.getDependencies().getHeroes().getClassManager().getClass(s),
|
||||||
|
((Player)player).getLocation());
|
||||||
|
none = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LinkedList<ItemStack> phatLootItems = new LinkedList<ItemStack>();
|
LinkedList<ItemStack> phatLootItems = new LinkedList<ItemStack>();
|
||||||
int phatLootExp = 0;
|
int phatLootExp = 0;
|
||||||
@ -527,229 +551,241 @@ public class Quest {
|
|||||||
LootBundle lb = PhatLootsAPI.getPhatLoot(s).rollForLoot();
|
LootBundle lb = PhatLootsAPI.getPhatLoot(s).rollForLoot();
|
||||||
if (lb.getExp() > 0) {
|
if (lb.getExp() > 0) {
|
||||||
phatLootExp += lb.getExp();
|
phatLootExp += lb.getExp();
|
||||||
player.giveExp(lb.getExp());
|
if (player.isOnline()) {
|
||||||
|
((Player)player).giveExp(lb.getExp());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (lb.getMoney() > 0) {
|
if (lb.getMoney() > 0) {
|
||||||
if (plugin.getDependencies().getVaultEconomy() != null) {
|
if (plugin.getDependencies().getVaultEconomy() != null) {
|
||||||
plugin.getDependencies().getVaultEconomy()
|
plugin.getDependencies().getVaultEconomy()
|
||||||
.depositPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()), lb.getMoney());
|
.depositPlayer(player, lb.getMoney());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lb.getItemList().isEmpty() == false) {
|
if (lb.getItemList().isEmpty() == false) {
|
||||||
phatLootItems.addAll(lb.getItemList());
|
phatLootItems.addAll(lb.getItemList());
|
||||||
for (ItemStack is : lb.getItemList()) {
|
if (player.isOnline()) {
|
||||||
try {
|
Player p = (Player)player;
|
||||||
InventoryUtil.addItem(player, is);
|
for (ItemStack is : lb.getItemList()) {
|
||||||
} catch (Exception e) {
|
try {
|
||||||
plugin.getLogger().severe("Unable to add PhatLoots item to inventory of " + player.getName()
|
InventoryUtil.addItem(p, is);
|
||||||
+ " upon completion of quest " + name);
|
} catch (Exception e) {
|
||||||
player.sendMessage(ChatColor.RED + "Quests encountered a problem with an item. "
|
plugin.getLogger().severe("Unable to add PhatLoots item to inventory of " + p.getName()
|
||||||
+ "Please contact an administrator.");
|
+ " 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()) {
|
for (CommandLoot cl : lb.getCommandList()) {
|
||||||
cl.execute(player);
|
cl.execute((Player)player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lb.getMessageList().isEmpty() == false) {
|
if (lb.getMessageList().isEmpty() == false) {
|
||||||
phatLootMessages.addAll(lb.getMessageList());
|
phatLootMessages.addAll(lb.getMessageList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rews.getExp() > 0) {
|
if (rews.getExp() > 0 && player.isOnline()) {
|
||||||
player.giveExp(rews.getExp());
|
((Player)player).giveExp(rews.getExp());
|
||||||
none = null;
|
none = null;
|
||||||
}
|
}
|
||||||
String complete = Lang.get(player, "questCompleteTitle");
|
if (player.isOnline()) {
|
||||||
complete = complete.replace("<quest>", ChatColor.YELLOW + name + ChatColor.GOLD);
|
Player p = (Player)player;
|
||||||
player.sendMessage(ChatColor.GOLD + complete);
|
String complete = Lang.get(p, "questCompleteTitle");
|
||||||
player.sendMessage(ChatColor.GREEN + Lang.get(player, "questRewardsTitle"));
|
complete = complete.replace("<quest>", ChatColor.YELLOW + name + ChatColor.GOLD);
|
||||||
if (plugin.getSettings().canShowQuestTitles()) {
|
p.sendMessage(ChatColor.GOLD + complete);
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + player.getName()
|
p.sendMessage(ChatColor.GREEN + Lang.get(p, "questRewardsTitle"));
|
||||||
+ " title " + "{\"text\":\"" + Lang.get(player, "quest") + " " + Lang.get(player, "complete")
|
if (plugin.getSettings().canShowQuestTitles()) {
|
||||||
+ "\",\"color\":\"gold\"}");
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + p.getName()
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + player.getName()
|
+ " title " + "{\"text\":\"" + Lang.get(p, "quest") + " " + Lang.get(p, "complete")
|
||||||
+ " subtitle " + "{\"text\":\"" + name + "\",\"color\":\"yellow\"}");
|
+ "\",\"color\":\"gold\"}");
|
||||||
}
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + p.getName()
|
||||||
if (rews.getQuestPoints() > 0) {
|
+ " subtitle " + "{\"text\":\"" + name + "\",\"color\":\"yellow\"}");
|
||||||
player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getQuestPoints() + " "
|
}
|
||||||
+ Lang.get(player, "questPoints"));
|
if (rews.getQuestPoints() > 0) {
|
||||||
q.questPoints += rews.getQuestPoints();
|
p.sendMessage("- " + ChatColor.DARK_GREEN + rews.getQuestPoints() + " "
|
||||||
none = null;
|
+ Lang.get(p, "questPoints"));
|
||||||
}
|
q.questPoints += rews.getQuestPoints();
|
||||||
for (ItemStack i : rews.getItems()) {
|
none = null;
|
||||||
String text = "error";
|
}
|
||||||
if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) {
|
for (ItemStack i : rews.getItems()) {
|
||||||
if (i.getEnchantments().isEmpty()) {
|
String text = "error";
|
||||||
text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
|
if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) {
|
||||||
+ ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount();
|
if (i.getEnchantments().isEmpty()) {
|
||||||
} else {
|
text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
|
||||||
text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
|
+ ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount();
|
||||||
+ ChatColor.RESET;
|
} else {
|
||||||
try {
|
text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
|
||||||
if (!i.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) {
|
+ ChatColor.RESET;
|
||||||
text += ChatColor.GRAY + " " + Lang.get(player, "with") + ChatColor.DARK_PURPLE;
|
try {
|
||||||
for (Entry<Enchantment, Integer> e : i.getEnchantments().entrySet()) {
|
if (!i.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) {
|
||||||
text += " " + ItemUtil.getPrettyEnchantmentName(e.getKey()) + ":" + e.getValue();
|
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) {
|
text += ChatColor.GRAY + " x " + i.getAmount();
|
||||||
// Do nothing, hasItemFlag() not introduced until 1.8.6
|
|
||||||
}
|
}
|
||||||
text += ChatColor.GRAY + " x " + i.getAmount();
|
} else if (i.getDurability() != 0) {
|
||||||
}
|
if (i.getEnchantments().isEmpty()) {
|
||||||
} else if (i.getDurability() != 0) {
|
text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY
|
||||||
if (i.getEnchantments().isEmpty()) {
|
+ " x " + i.getAmount();
|
||||||
text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY
|
} else {
|
||||||
+ " x " + i.getAmount();
|
text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY
|
||||||
} else {
|
+ " " + Lang.get(p, "with");
|
||||||
text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY
|
for (Entry<Enchantment, Integer> e : i.getEnchantments().entrySet()) {
|
||||||
+ " " + Lang.get(player, "with");
|
text += " " + ItemUtil.getPrettyEnchantmentName(e.getKey()) + ":" + e.getValue();
|
||||||
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 {
|
} else {
|
||||||
text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i);
|
if (i.getEnchantments().isEmpty()) {
|
||||||
try {
|
text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " + i.getAmount();
|
||||||
if (!i.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) {
|
} else {
|
||||||
text += ChatColor.GRAY + " " + Lang.get(player, "with");
|
text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i);
|
||||||
for (Entry<Enchantment, Integer> e : i.getEnchantments().entrySet()) {
|
try {
|
||||||
text += " " + ItemUtil.getPrettyEnchantmentName(e.getKey()) + ":" + e.getValue();
|
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) {
|
text += ChatColor.GRAY + " x " + i.getAmount();
|
||||||
// Do nothing, hasItemFlag() not introduced until 1.8.6
|
|
||||||
}
|
}
|
||||||
text += ChatColor.GRAY + " x " + i.getAmount();
|
|
||||||
}
|
}
|
||||||
|
p.sendMessage(text);
|
||||||
|
none = null;
|
||||||
}
|
}
|
||||||
player.sendMessage(text);
|
for (ItemStack i : phatLootItems) {
|
||||||
none = null;
|
if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) {
|
||||||
}
|
if (i.getEnchantments().isEmpty()) {
|
||||||
for (ItemStack i : phatLootItems) {
|
p.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
|
||||||
if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) {
|
+ ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount());
|
||||||
if (i.getEnchantments().isEmpty()) {
|
} else {
|
||||||
player.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
|
p.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
|
||||||
+ ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount());
|
+ ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " "
|
||||||
} else {
|
+ Lang.get(p, "enchantedItem"));
|
||||||
player.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
|
}
|
||||||
+ ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " "
|
} else if (i.getDurability() != 0) {
|
||||||
+ Lang.get(player, "enchantedItem"));
|
if (i.getEnchantments().isEmpty()) {
|
||||||
}
|
p.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability()
|
||||||
} else if (i.getDurability() != 0) {
|
+ ChatColor.GRAY + " x " + i.getAmount());
|
||||||
if (i.getEnchantments().isEmpty()) {
|
} else {
|
||||||
player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability()
|
p.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability()
|
||||||
+ ChatColor.GRAY + " x " + i.getAmount());
|
+ ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " "
|
||||||
} else {
|
+ Lang.get(p, "enchantedItem"));
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage("- " + ChatColor.DARK_GREEN + s);
|
if (i.getEnchantments().isEmpty()) {
|
||||||
}
|
p.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x "
|
||||||
index++;
|
+ i.getAmount());
|
||||||
}
|
} else {
|
||||||
none = null;
|
p.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x "
|
||||||
}
|
+ i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get(p, "enchantedItem"));
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
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));
|
none = null;
|
||||||
} else {
|
}
|
||||||
plugin.getLogger().warning("Quester \"" + player.getName() + "\" completed the Quest \"" + name
|
if (rews.getMoney() > 1) {
|
||||||
+ "\", but the Custom Reward \"" + s + "\" could not be found. Does it still exist?");
|
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();
|
q.saveData();
|
||||||
player.updateInventory();
|
if (player.isOnline()) {
|
||||||
|
((Player)player).updateInventory();
|
||||||
|
}
|
||||||
q.updateJournal();
|
q.updateJournal();
|
||||||
q.findCompassTarget();
|
q.findCompassTarget();
|
||||||
QuesterPostCompleteQuestEvent postEvent = new QuesterPostCompleteQuestEvent(q, this);
|
if (player.isOnline()) {
|
||||||
plugin.getServer().getPluginManager().callEvent(postEvent);
|
QuesterPostCompleteQuestEvent postEvent = new QuesterPostCompleteQuestEvent(q, this);
|
||||||
|
plugin.getServer().getPluginManager().callEvent(postEvent);
|
||||||
|
}
|
||||||
|
|
||||||
// Multiplayer
|
// Multiplayer
|
||||||
if (opts.getShareProgressLevel() == 4) {
|
if (opts.getShareProgressLevel() == 4) {
|
||||||
@ -765,7 +801,7 @@ public class Quest {
|
|||||||
/**
|
/**
|
||||||
* Force player to quit quest and inform them of their failure
|
* 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")
|
@SuppressWarnings("deprecation")
|
||||||
public void failQuest(Quester q) {
|
public void failQuest(Quester q) {
|
||||||
|
@ -28,7 +28,6 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -304,11 +303,11 @@ public class Quester {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return Bukkit.getServer().getPlayer(id);
|
return plugin.getServer().getPlayer(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OfflinePlayer getOfflinePlayer() {
|
public OfflinePlayer getOfflinePlayer() {
|
||||||
return Bukkit.getServer().getOfflinePlayer(id);
|
return plugin.getServer().getOfflinePlayer(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stage getCurrentStage(Quest quest) {
|
public Stage getCurrentStage(Quest quest) {
|
||||||
@ -516,10 +515,10 @@ public class Quester {
|
|||||||
p.sendMessage(ChatColor.GREEN + accepted);
|
p.sendMessage(ChatColor.GREEN + accepted);
|
||||||
p.sendMessage("");
|
p.sendMessage("");
|
||||||
if (plugin.getSettings().canShowQuestTitles()) {
|
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") + " "
|
+ player.getName() + " title " + "{\"text\":\"" + Lang.get(getPlayer(), "quest") + " "
|
||||||
+ Lang.get(getPlayer(), "accepted") + "\",\"color\":\"gold\"}");
|
+ 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()
|
+ player.getName() + " subtitle " + "{\"text\":\"" + q.getName()
|
||||||
+ "\",\"color\":\"yellow\"}");
|
+ "\",\"color\":\"yellow\"}");
|
||||||
}
|
}
|
||||||
@ -3272,7 +3271,7 @@ public class Quester {
|
|||||||
}
|
}
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
int size = ((quests.size() / 9) + 1) * 9;
|
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());
|
+ npc.getName());
|
||||||
int inc = 0;
|
int inc = 0;
|
||||||
for (int i = 0; i < quests.size(); i++) {
|
for (int i = 0; i < quests.size(); i++) {
|
||||||
|
@ -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
|
* @param id Player UUID
|
||||||
* @return Quester, or null if offline
|
* @return Quester, or null if not found
|
||||||
*/
|
*/
|
||||||
public Quester getQuester(UUID id) {
|
public Quester getQuester(UUID id) {
|
||||||
Quester quester = null;
|
Quester quester = null;
|
||||||
|
@ -19,7 +19,7 @@ import me.blackvein.quests.Quester;
|
|||||||
import me.blackvein.quests.Stage;
|
import me.blackvein.quests.Stage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after a quester changes stage
|
* Called after an online quester changes stage
|
||||||
*/
|
*/
|
||||||
public class QuesterPostChangeStageEvent extends QuesterEvent {
|
public class QuesterPostChangeStageEvent extends QuesterEvent {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
@ -18,7 +18,7 @@ import me.blackvein.quests.Quest;
|
|||||||
import me.blackvein.quests.Quester;
|
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 {
|
public class QuesterPostCompleteQuestEvent extends QuesterEvent {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
@ -20,7 +20,7 @@ import me.blackvein.quests.Quester;
|
|||||||
import me.blackvein.quests.Stage;
|
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 {
|
public class QuesterPreChangeStageEvent extends QuesterEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
@ -19,7 +19,7 @@ import me.blackvein.quests.Quest;
|
|||||||
import me.blackvein.quests.Quester;
|
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 {
|
public class QuesterPreCompleteQuestEvent extends QuesterEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
@ -580,23 +580,23 @@ public class CmdExecutor implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private void questsStats(final CommandSender cs, String[] args) {
|
private void questsStats(final CommandSender cs, String[] args) {
|
||||||
Quester quester;
|
OfflinePlayer target;
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
quester = plugin.getQuester(args[1]);
|
target = getPlayer(args[1]);
|
||||||
if (quester == null) {
|
if (target == null) {
|
||||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
try {
|
||||||
return;
|
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||||
} else if (Bukkit.getOfflinePlayer(quester.getUUID()).getName() != null) {
|
} catch (IllegalArgumentException e) {
|
||||||
cs.sendMessage(ChatColor.GOLD + "- " + Bukkit.getOfflinePlayer(quester.getUUID()).getName() + " -");
|
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
||||||
} else {
|
return;
|
||||||
cs.sendMessage(ChatColor.GOLD + "- " + args[1] + " -");
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
quester = plugin.getQuester(((Player) cs).getUniqueId());
|
target = Bukkit.getOfflinePlayer(((Player)cs).getUniqueId());
|
||||||
cs.sendMessage(ChatColor.GOLD + "- " + ((Player) cs).getName() + " -");
|
|
||||||
}
|
}
|
||||||
|
Quester quester = plugin.getQuester(target.getUniqueId());
|
||||||
|
cs.sendMessage(ChatColor.GOLD + "- " + target.getName() + " -");
|
||||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("questPointsDisplay") + " " + ChatColor.DARK_PURPLE
|
cs.sendMessage(ChatColor.YELLOW + Lang.get("questPointsDisplay") + " " + ChatColor.DARK_PURPLE
|
||||||
+ quester.getQuestPoints());
|
+ quester.getQuestPoints());
|
||||||
if (quester.getCurrentQuests().isEmpty()) {
|
if (quester.getCurrentQuests().isEmpty()) {
|
||||||
@ -898,28 +898,36 @@ public class CmdExecutor implements CommandExecutor {
|
|||||||
|
|
||||||
private void adminGivePoints(final CommandSender cs, String[] args) {
|
private void adminGivePoints(final CommandSender cs, String[] args) {
|
||||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.givepoints")) {
|
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.givepoints")) {
|
||||||
Player target = getPlayer(args[1]);
|
OfflinePlayer target = getPlayer(args[1]);
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
|
||||||
} else {
|
|
||||||
int points;
|
|
||||||
try {
|
try {
|
||||||
points = Integer.parseInt(args[2]);
|
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||||
Quester quester = plugin.getQuester(target.getUniqueId());
|
} catch (IllegalArgumentException e) {
|
||||||
quester.setQuestPoints(quester.getQuestPoints() + Math.abs(points));
|
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
||||||
String msg1 = Lang.get("giveQuestPoints");
|
return;
|
||||||
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"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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 {
|
} else {
|
||||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||||
}
|
}
|
||||||
@ -927,29 +935,36 @@ public class CmdExecutor implements CommandExecutor {
|
|||||||
|
|
||||||
private void adminTakePoints(final CommandSender cs, String[] args) {
|
private void adminTakePoints(final CommandSender cs, String[] args) {
|
||||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.takepoints")) {
|
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.takepoints")) {
|
||||||
Player target = getPlayer(args[1]);
|
OfflinePlayer target = getPlayer(args[1]);
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
|
||||||
} else {
|
|
||||||
int points;
|
|
||||||
try {
|
try {
|
||||||
points = Integer.parseInt(args[2]);
|
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||||
} catch (NumberFormatException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
|
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Quester quester = plugin.getQuester(target.getUniqueId());
|
}
|
||||||
quester.setQuestPoints(quester.getQuestPoints() - Math.abs(points));
|
int points;
|
||||||
String msg1 = Lang.get("takeQuestPoints");
|
try {
|
||||||
msg1 = msg1.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);
|
points = Integer.parseInt(args[2]);
|
||||||
msg1 = msg1.replace("<number>", ChatColor.DARK_PURPLE + "" + points + ChatColor.GOLD);
|
} catch (NumberFormatException e) {
|
||||||
cs.sendMessage(ChatColor.GOLD + msg1);
|
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
|
||||||
String msg2 = Lang.get(target, "questPointsTaken");
|
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("<player>", ChatColor.GREEN + cs.getName() + ChatColor.GOLD);
|
||||||
msg2 = msg2.replace("<number>", ChatColor.DARK_PURPLE + "" + points + ChatColor.GOLD);
|
msg2 = msg2.replace("<number>", ChatColor.DARK_PURPLE + "" + points + ChatColor.GOLD);
|
||||||
target.sendMessage(ChatColor.GREEN + msg2);
|
p.sendMessage(ChatColor.GREEN + msg2);
|
||||||
quester.saveData();
|
|
||||||
}
|
}
|
||||||
|
quester.saveData();
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||||
}
|
}
|
||||||
@ -957,29 +972,36 @@ public class CmdExecutor implements CommandExecutor {
|
|||||||
|
|
||||||
private void adminPoints(final CommandSender cs, String[] args) {
|
private void adminPoints(final CommandSender cs, String[] args) {
|
||||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.points")) {
|
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.points")) {
|
||||||
Player target = getPlayer(args[1]);
|
OfflinePlayer target = getPlayer(args[1]);
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
|
||||||
} else {
|
|
||||||
int points;
|
|
||||||
try {
|
try {
|
||||||
points = Integer.parseInt(args[2]);
|
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||||
} catch (NumberFormatException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
|
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Quester quester = plugin.getQuester(target.getUniqueId());
|
}
|
||||||
quester.setQuestPoints(points);
|
int points;
|
||||||
String msg1 = Lang.get("setQuestPoints");
|
try {
|
||||||
msg1 = msg1.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);
|
points = Integer.parseInt(args[2]);
|
||||||
msg1 = msg1.replace("<number>", ChatColor.DARK_PURPLE + "" + points + ChatColor.GOLD);
|
} catch (NumberFormatException e) {
|
||||||
cs.sendMessage(ChatColor.GOLD + msg1);
|
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
|
||||||
String msg2 = Lang.get("questPointsSet");
|
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("<player>", ChatColor.GREEN + cs.getName() + ChatColor.GOLD);
|
||||||
msg2 = msg2.replace("<number>", ChatColor.DARK_PURPLE + "" + points + ChatColor.GOLD);
|
msg2 = msg2.replace("<number>", ChatColor.DARK_PURPLE + "" + points + ChatColor.GOLD);
|
||||||
target.sendMessage(ChatColor.GREEN + msg2);
|
p.sendMessage(ChatColor.GREEN + msg2);
|
||||||
quester.saveData();
|
|
||||||
}
|
}
|
||||||
|
quester.saveData();
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||||
}
|
}
|
||||||
@ -1120,32 +1142,39 @@ public class CmdExecutor implements CommandExecutor {
|
|||||||
|
|
||||||
private void adminFinish(final CommandSender cs, String[] args) {
|
private void adminFinish(final CommandSender cs, String[] args) {
|
||||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.finish")) {
|
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.finish")) {
|
||||||
Player target = getPlayer(args[1]);
|
OfflinePlayer target = getPlayer(args[1]);
|
||||||
if (target == null) {
|
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 {
|
} else {
|
||||||
Quester quester = plugin.getQuester(target.getUniqueId());
|
Quest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
|
||||||
if (quester.getCurrentQuests().isEmpty()) {
|
if (quest == null) {
|
||||||
String msg = Lang.get("noCurrentQuest");
|
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
|
||||||
msg = msg.replace("<player>", target.getName());
|
return;
|
||||||
cs.sendMessage(ChatColor.YELLOW + msg);
|
}
|
||||||
} else {
|
String msg1 = Lang.get("questForceFinish");
|
||||||
Quest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
|
msg1 = msg1.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);
|
||||||
if (quest == null) {
|
msg1 = msg1.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.GOLD);
|
||||||
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
|
cs.sendMessage(ChatColor.GOLD + msg1);
|
||||||
return;
|
if (target.isOnline()) {
|
||||||
}
|
Player p = (Player)target;
|
||||||
String msg1 = Lang.get("questForceFinish");
|
String msg2 = Lang.get(p, "questForcedFinish");
|
||||||
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");
|
|
||||||
msg2 = msg2.replace("<player>", ChatColor.GREEN + cs.getName() + ChatColor.GOLD);
|
msg2 = msg2.replace("<player>", ChatColor.GREEN + cs.getName() + ChatColor.GOLD);
|
||||||
msg2 = msg2.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.GOLD);
|
msg2 = msg2.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.GOLD);
|
||||||
target.sendMessage(ChatColor.GREEN + msg2);
|
p.sendMessage(ChatColor.GREEN + msg2);
|
||||||
quest.completeQuest(quester);
|
|
||||||
quester.saveData();
|
|
||||||
}
|
}
|
||||||
|
quest.completeQuest(quester);
|
||||||
|
quester.saveData();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||||
@ -1154,13 +1183,13 @@ public class CmdExecutor implements CommandExecutor {
|
|||||||
|
|
||||||
private void adminSetStage(final CommandSender cs, String[] args) {
|
private void adminSetStage(final CommandSender cs, String[] args) {
|
||||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.setstage")) {
|
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.setstage")) {
|
||||||
Player target = getPlayer(args[1]);
|
OfflinePlayer target = getPlayer(args[1]);
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
for (Player p : plugin.getServer().getOnlinePlayers()) {
|
try {
|
||||||
if (p.getName().toLowerCase().contains(args[1].toLowerCase())) {
|
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||||
target = p;
|
} catch (IllegalArgumentException e) {
|
||||||
break;
|
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int stage = -1;
|
int stage = -1;
|
||||||
@ -1174,29 +1203,25 @@ public class CmdExecutor implements CommandExecutor {
|
|||||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("COMMAND_QUESTADMIN_SETSTAGE_USAGE"));
|
cs.sendMessage(ChatColor.YELLOW + Lang.get("COMMAND_QUESTADMIN_SETSTAGE_USAGE"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (target == null) {
|
Quester quester = plugin.getQuester(target.getUniqueId());
|
||||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
if (quester.getCurrentQuests().isEmpty()) {
|
||||||
|
String msg = Lang.get("noCurrentQuest");
|
||||||
|
msg = msg.replace("<player>", target.getName());
|
||||||
|
cs.sendMessage(ChatColor.YELLOW + msg);
|
||||||
} else {
|
} else {
|
||||||
Quester quester = plugin.getQuester(target.getUniqueId());
|
Quest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 2, ' '));
|
||||||
if (quester.getCurrentQuests().isEmpty()) {
|
if (quest == null) {
|
||||||
String msg = Lang.get("noCurrentQuest");
|
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
|
||||||
msg = msg.replace("<player>", target.getName());
|
return;
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
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 {
|
} else {
|
||||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||||
@ -1205,32 +1230,39 @@ public class CmdExecutor implements CommandExecutor {
|
|||||||
|
|
||||||
private void adminNextStage(final CommandSender cs, String[] args) {
|
private void adminNextStage(final CommandSender cs, String[] args) {
|
||||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.nextstage")) {
|
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.nextstage")) {
|
||||||
Player target = getPlayer(args[1]);
|
OfflinePlayer target = getPlayer(args[1]);
|
||||||
if (target == null) {
|
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 {
|
} else {
|
||||||
Quester quester = plugin.getQuester(target.getUniqueId());
|
Quest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
|
||||||
if (quester.getCurrentQuests().isEmpty()) {
|
if (quest == null) {
|
||||||
String msg = Lang.get("noCurrentQuest");
|
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
|
||||||
msg = msg.replace("<player>", target.getName());
|
return;
|
||||||
cs.sendMessage(ChatColor.YELLOW + msg);
|
}
|
||||||
} else {
|
String msg1 = Lang.get("questForceNextStage");
|
||||||
Quest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
|
msg1 = msg1.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);
|
||||||
if (quest == null) {
|
msg1 = msg1.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.GOLD);
|
||||||
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
|
cs.sendMessage(ChatColor.GOLD + msg1);
|
||||||
return;
|
if (target.isOnline()) {
|
||||||
}
|
Player p = (Player)target;
|
||||||
String msg1 = Lang.get("questForceNextStage");
|
String msg2 = Lang.get(p, "questForcedNextStage");
|
||||||
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");
|
|
||||||
msg2 = msg2.replace("<player>", ChatColor.GREEN + cs.getName() + ChatColor.GOLD);
|
msg2 = msg2.replace("<player>", ChatColor.GREEN + cs.getName() + ChatColor.GOLD);
|
||||||
msg2 = msg2.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.GOLD);
|
msg2 = msg2.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.GOLD);
|
||||||
target.sendMessage(ChatColor.GREEN + msg2);
|
p.sendMessage(ChatColor.GREEN + msg2);
|
||||||
quest.nextStage(quester, false);
|
|
||||||
quester.saveData();
|
|
||||||
}
|
}
|
||||||
|
quest.nextStage(quester, false);
|
||||||
|
quester.saveData();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||||
@ -1281,13 +1313,16 @@ public class CmdExecutor implements CommandExecutor {
|
|||||||
|
|
||||||
private void adminReset(final CommandSender cs, String[] args) {
|
private void adminReset(final CommandSender cs, String[] args) {
|
||||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.reset")) {
|
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.reset")) {
|
||||||
@SuppressWarnings("deprecation")
|
OfflinePlayer target = getPlayer(args[1]);
|
||||||
Quester quester = plugin.getQuester(args[1]);
|
if (target == null) {
|
||||||
if (quester == null) {
|
try {
|
||||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||||
return;
|
} catch (IllegalArgumentException e) {
|
||||||
|
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
UUID id = quester.getUUID();
|
UUID id = target.getUniqueId();
|
||||||
LinkedList<Quester> temp = plugin.getQuesters();
|
LinkedList<Quester> temp = plugin.getQuesters();
|
||||||
for(Iterator<Quester> itr = temp.iterator(); itr.hasNext();) {
|
for(Iterator<Quester> itr = temp.iterator(); itr.hasNext();) {
|
||||||
if (itr.next().getUUID().equals(id)) {
|
if (itr.next().getUUID().equals(id)) {
|
||||||
@ -1295,6 +1330,7 @@ public class CmdExecutor implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
plugin.setQuesters(temp);
|
plugin.setQuesters(temp);
|
||||||
|
Quester quester = plugin.getQuester(target.getUniqueId());
|
||||||
try {
|
try {
|
||||||
quester.hardClear();
|
quester.hardClear();
|
||||||
quester.saveData();
|
quester.saveData();
|
||||||
@ -1303,9 +1339,8 @@ public class CmdExecutor implements CommandExecutor {
|
|||||||
final File quest = new File(dataFolder, id + ".yml");
|
final File quest = new File(dataFolder, id + ".yml");
|
||||||
quest.delete();
|
quest.delete();
|
||||||
String msg = Lang.get("questReset");
|
String msg = Lang.get("questReset");
|
||||||
if (Bukkit.getOfflinePlayer(id).getName() != null) {
|
if (target.getName() != null) {
|
||||||
msg = msg.replace("<player>", ChatColor.GREEN + Bukkit.getOfflinePlayer(id).getName()
|
msg = msg.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);
|
||||||
+ ChatColor.GOLD);
|
|
||||||
} else {
|
} else {
|
||||||
msg = msg.replace("<player>", ChatColor.GREEN + args[1] + ChatColor.GOLD);
|
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) {
|
private void adminRemove(final CommandSender cs, String[] args) {
|
||||||
if (cs.hasPermission("quests.admin.*") && cs.hasPermission("quests.admin.remove")) {
|
if (cs.hasPermission("quests.admin.*") && cs.hasPermission("quests.admin.remove")) {
|
||||||
@SuppressWarnings("deprecation")
|
OfflinePlayer target = getPlayer(args[1]);
|
||||||
Quester quester = plugin.getQuester(args[1]);
|
if (target == null) {
|
||||||
if (quester == null) {
|
try {
|
||||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||||
return;
|
} catch (IllegalArgumentException e) {
|
||||||
|
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Quest toRemove = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
|
Quest toRemove = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
|
||||||
if (toRemove == null) {
|
if (toRemove == null) {
|
||||||
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
|
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Quester quester = plugin.getQuester(target.getUniqueId());
|
||||||
String msg = Lang.get("questRemoved");
|
String msg = Lang.get("questRemoved");
|
||||||
if (Bukkit.getOfflinePlayer(quester.getUUID()).getName() != null) {
|
if (target.getName() != null) {
|
||||||
msg = msg.replace("<player>", ChatColor.GREEN + Bukkit.getOfflinePlayer(quester.getUUID()).getName()
|
msg = msg.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);
|
||||||
+ ChatColor.GOLD);
|
|
||||||
} else {
|
} else {
|
||||||
msg = msg.replace("<player>", ChatColor.GREEN + args[1] + ChatColor.GOLD);
|
msg = msg.replace("<player>", ChatColor.GREEN + args[1] + ChatColor.GOLD);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user