mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-25 18:48:15 +01:00
Improve GUI Display code
This commit is contained in:
parent
4cf50b00b5
commit
422d1055a8
@ -3683,16 +3683,6 @@ public class Quester {
|
||||
return false;
|
||||
}
|
||||
if (canAcceptOffer(quest, giveReason)) {
|
||||
if (quest.getRegionStart() != null) {
|
||||
if (!quest.isInRegion(this)) {
|
||||
if (giveReason) {
|
||||
String msg = Lang.get(getPlayer(), "questInvalidLocation");
|
||||
msg = msg.replace("<quest>", ChatColor.AQUA + quest.getName() + ChatColor.YELLOW);
|
||||
getPlayer().sendMessage(ChatColor.YELLOW + msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (getPlayer() instanceof Conversable) {
|
||||
if (getPlayer().isConversing() == false) {
|
||||
setQuestToTake(quest.getName());
|
||||
@ -3771,6 +3761,15 @@ public class Quester {
|
||||
getPlayer().sendMessage(ChatColor.YELLOW + msg);
|
||||
}
|
||||
return false;
|
||||
} else if (quest.getRegionStart() != null) {
|
||||
if (!quest.isInRegion(this)) {
|
||||
if (giveReason) {
|
||||
String msg = Lang.get(getPlayer(), "questInvalidLocation");
|
||||
msg = msg.replace("<quest>", ChatColor.AQUA + quest.getName() + ChatColor.YELLOW);
|
||||
getPlayer().sendMessage(ChatColor.YELLOW + msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -122,48 +122,12 @@ public class PlayerListener implements Listener {
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
if (quest.getGUIDisplay() != null) {
|
||||
if (ItemUtil.compareItems(clicked, quest.getGUIDisplay(), false) == 0) {
|
||||
if (quester.getCurrentQuests().size() >= plugin.getSettings().getMaxQuests()
|
||||
&& plugin.getSettings().getMaxQuests() > 0) {
|
||||
String msg = Lang.get(player, "questMaxAllowed");
|
||||
msg = msg.replace("<number>", String.valueOf(plugin.getSettings().getMaxQuests()));
|
||||
player.sendMessage(ChatColor.YELLOW + msg);
|
||||
} else if (quester.getCompletedQuests().contains(quest.getName())
|
||||
&& quest.getPlanner().getCooldown() < 0) {
|
||||
String completed = Lang.get(player, "questAlreadyCompleted");
|
||||
completed = completed.replace("<quest>", ChatColor.AQUA + quest.getName()
|
||||
+ ChatColor.YELLOW);
|
||||
player.sendMessage(ChatColor.YELLOW + completed);
|
||||
} else {
|
||||
boolean takeable = true;
|
||||
if (quester.getCompletedQuests().contains(quest.getName())) {
|
||||
if (quester.getCooldownDifference(quest) > 0) {
|
||||
String early = Lang.get(player, "questTooEarly");
|
||||
early = early.replace("<quest>", ChatColor.AQUA + quest.getName()
|
||||
+ ChatColor.YELLOW);
|
||||
early = early.replace("<time>", ChatColor.DARK_PURPLE
|
||||
+ MiscUtil.getTime(quester.getCooldownDifference(quest))
|
||||
+ ChatColor.YELLOW);
|
||||
player.sendMessage(ChatColor.YELLOW + early);
|
||||
takeable = false;
|
||||
}
|
||||
}
|
||||
if (quest.getRegionStart() != null) {
|
||||
if (!quest.isInRegion(quester)) {
|
||||
String invalidLoc = Lang.get(player, "questInvalidLocation");
|
||||
invalidLoc = invalidLoc.replace("<quest>", ChatColor.AQUA + quest.getName()
|
||||
+ ChatColor.YELLOW);
|
||||
player.sendMessage(ChatColor.YELLOW + invalidLoc);
|
||||
takeable = false;
|
||||
}
|
||||
}
|
||||
if (takeable == true) {
|
||||
if (quester.canAcceptOffer(quest, true)) {
|
||||
try {
|
||||
quester.takeQuest(quest, false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
evt.getWhoClicked().closeInventory();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user