Improve GUI Display code

This commit is contained in:
PikaMug 2020-02-12 08:21:30 -05:00
parent 4cf50b00b5
commit 422d1055a8
2 changed files with 14 additions and 51 deletions

View File

@ -3683,16 +3683,6 @@ public class Quester {
return false; return false;
} }
if (canAcceptOffer(quest, giveReason)) { 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() instanceof Conversable) {
if (getPlayer().isConversing() == false) { if (getPlayer().isConversing() == false) {
setQuestToTake(quest.getName()); setQuestToTake(quest.getName());
@ -3771,6 +3761,15 @@ public class Quester {
getPlayer().sendMessage(ChatColor.YELLOW + msg); getPlayer().sendMessage(ChatColor.YELLOW + msg);
} }
return false; 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; return true;
} }

View File

@ -122,48 +122,12 @@ public class PlayerListener implements Listener {
for (Quest quest : plugin.getQuests()) { for (Quest quest : plugin.getQuests()) {
if (quest.getGUIDisplay() != null) { if (quest.getGUIDisplay() != null) {
if (ItemUtil.compareItems(clicked, quest.getGUIDisplay(), false) == 0) { if (ItemUtil.compareItems(clicked, quest.getGUIDisplay(), false) == 0) {
if (quester.getCurrentQuests().size() >= plugin.getSettings().getMaxQuests() if (quester.canAcceptOffer(quest, true)) {
&& 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) {
try { try {
quester.takeQuest(quest, false); quester.takeQuest(quest, false);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
}
evt.getWhoClicked().closeInventory(); evt.getWhoClicked().closeInventory();
} }
} }