mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-25 20:16:13 +01:00
Lets show quests in GUI, optional, enabled by default
This commit is contained in:
parent
80b8ac5684
commit
7d9c6cedc3
@ -16,6 +16,10 @@ import com.gamingmesh.jobs.container.QuestObjective;
|
||||
import com.gamingmesh.jobs.container.QuestProgression;
|
||||
import com.gamingmesh.jobs.i18n.Language;
|
||||
|
||||
import net.Zrips.CMILib.GUI.CMIGui;
|
||||
import net.Zrips.CMILib.GUI.CMIGuiButton;
|
||||
import net.Zrips.CMILib.GUI.GUIManager.GUIClickType;
|
||||
import net.Zrips.CMILib.GUI.GUIManager.InvType;
|
||||
import net.Zrips.CMILib.Locale.LC;
|
||||
import net.Zrips.CMILib.Messages.CMIMessages;
|
||||
import net.Zrips.CMILib.RawMessages.RawMessage;
|
||||
@ -78,13 +82,18 @@ public class quests implements Cmd {
|
||||
}
|
||||
}
|
||||
|
||||
if (isPlayer && Jobs.getGeneralConfigManager().isDailyQuestsUseGUI()) {
|
||||
openGui((Player) sender, jPlayer);
|
||||
return true;
|
||||
}
|
||||
|
||||
Language.sendMessage(sender, "command.quests.toplineseparator", "[playerName]", jPlayer.getName(), "[questsDone]", jPlayer.getDoneQuests());
|
||||
|
||||
for (JobProgression jobProg : jPlayer.progression) {
|
||||
List<QuestProgression> list = jPlayer.getQuestProgressions(jobProg.getJob());
|
||||
|
||||
for (QuestProgression q : list) {
|
||||
|
||||
|
||||
int totalAmountNeeded = q.getTotalAmountNeeded();
|
||||
int totalAmountDone = q.getTotalAmountDone();
|
||||
|
||||
@ -111,7 +120,7 @@ public class quests implements Cmd {
|
||||
List<String> hoverList = new ArrayList<>();
|
||||
|
||||
for (String current : hoverMsg.split("\n")) {
|
||||
current = current.replace("[jobName]", jobProg.getJob().getName())
|
||||
current = current.replace("[jobName]", jobProg.getJob().getDisplayName())
|
||||
.replace("[time]", CMITimeManager.to24hourShort(q.getValidUntil() - System.currentTimeMillis()));
|
||||
|
||||
if (current.contains("[desc]")) {
|
||||
@ -135,7 +144,6 @@ public class quests implements Cmd {
|
||||
for (String one : hoverList) {
|
||||
if (!hover.isEmpty())
|
||||
hover += "\n";
|
||||
|
||||
hover += one;
|
||||
}
|
||||
|
||||
@ -155,4 +163,95 @@ public class quests implements Cmd {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void openGui(Player player, JobsPlayer jPlayer) {
|
||||
|
||||
CMIGui gui = new CMIGui(player);
|
||||
gui.setTitle(jPlayer.getDisplayName());
|
||||
gui.addLock(InvType.Gui);
|
||||
gui.addLock(InvType.Main);
|
||||
|
||||
for (JobProgression jobProg : jPlayer.progression) {
|
||||
List<QuestProgression> list = jPlayer.getQuestProgressions(jobProg.getJob());
|
||||
|
||||
for (QuestProgression q : list) {
|
||||
|
||||
int totalAmountNeeded = q.getTotalAmountNeeded();
|
||||
int totalAmountDone = q.getTotalAmountDone();
|
||||
|
||||
String progressLine = Jobs.getCommandManager().jobProgressMessage(totalAmountNeeded, totalAmountDone);
|
||||
|
||||
boolean completed = q.isCompleted();
|
||||
|
||||
if (completed)
|
||||
progressLine = Jobs.getLanguage().getMessage("command.quests.output.completed");
|
||||
|
||||
Quest quest = q.getQuest();
|
||||
|
||||
String hoverMsg = Jobs.getLanguage().getMessage("command.quests.output.hover");
|
||||
List<String> hoverList = new ArrayList<>();
|
||||
|
||||
for (String current : hoverMsg.split("\n")) {
|
||||
current = current.replace("[jobName]", jobProg.getJob().getName())
|
||||
.replace("[time]", CMITimeManager.to24hourShort(q.getValidUntil() - System.currentTimeMillis()));
|
||||
|
||||
if (current.contains("[desc]")) {
|
||||
hoverList.addAll(quest.getDescription());
|
||||
} else {
|
||||
hoverList.add(current);
|
||||
}
|
||||
}
|
||||
|
||||
for (java.util.Map<String, QuestObjective> oneAction : quest.getObjectives().values()) {
|
||||
for (Entry<String, QuestObjective> oneObjective : oneAction.entrySet()) {
|
||||
hoverList.add(Jobs.getLanguage().getMessage("command.info.output." + oneObjective.getValue().getAction().toString().toLowerCase() + ".info") + " " +
|
||||
Jobs.getNameTranslatorManager().translate(oneObjective.getKey(), oneObjective.getValue().getAction(), oneObjective.getValue().getTargetId(), oneObjective.getValue()
|
||||
.getTargetMeta(), oneObjective.getValue().getTargetName())
|
||||
+ " " + q.getAmountDone(oneObjective.getValue()) + "/"
|
||||
+ oneObjective.getValue().getAmount());
|
||||
}
|
||||
}
|
||||
|
||||
String title = Jobs.getLanguage().getMessage("command.quests.output.questLine", "[progress]", progressLine, "[questName]", quest.getQuestName(), "[done]", totalAmountDone, "[required]",
|
||||
totalAmountNeeded);
|
||||
|
||||
String hover = "";
|
||||
|
||||
for (String one : hoverList) {
|
||||
if (!hover.isEmpty())
|
||||
hover += "\n";
|
||||
hover += "&r&f" + one;
|
||||
}
|
||||
|
||||
if (list.size() < jobProg.getJob().getQuests().size() && Jobs.getGCManager().getDailyQuestsSkips() > jPlayer.getSkippedQuests() && !completed) {
|
||||
if (Jobs.getGCManager().getDailyQuestsSkips() > 0) {
|
||||
hover += "\n" + Jobs.getLanguage().getMessage("command.quests.output.skip");
|
||||
hover += "\n" + Jobs.getLanguage().getMessage("command.quests.output.skips", "[skips]", (Jobs.getGCManager().getDailyQuestsSkips() - jPlayer.getSkippedQuests()));
|
||||
}
|
||||
|
||||
CMIGuiButton button = new CMIGuiButton(jobProg.getJob().getGuiItem()) {
|
||||
@Override
|
||||
public void click(GUIClickType type) {
|
||||
player.performCommand("jobs skipquest " + jobProg.getJob().getName() + " " + quest.getConfigName() + " " + jPlayer.getName());
|
||||
}
|
||||
};
|
||||
|
||||
button.setName(title);
|
||||
button.addLore(hover);
|
||||
button.hideItemFlags();
|
||||
gui.addButton(button);
|
||||
} else {
|
||||
CMIGuiButton button = new CMIGuiButton(jobProg.getJob().getGuiItem());
|
||||
button.setName(title);
|
||||
button.addLore(hover);
|
||||
button.hideItemFlags();
|
||||
gui.addButton(button);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
gui.fillEmptyButtons();
|
||||
gui.open();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class GeneralConfigManager {
|
||||
public float maxPaymentCurveFactor;
|
||||
|
||||
private boolean FurnacesReassign, BrewingStandsReassign, useTnTFinder = false, ShowNewVersion;
|
||||
private boolean InformDuplicates;
|
||||
private boolean InformDuplicates, DailyQuestsUseGUI;
|
||||
|
||||
private FireworkEffect fireworkEffect;
|
||||
|
||||
@ -446,6 +446,8 @@ public class GeneralConfigManager {
|
||||
"Any daily quests given before reset will be invalid and new ones will be given out");
|
||||
ResetTimeHour = c.get("DailyQuests.ResetTime.Hour", 4);
|
||||
ResetTimeMinute = c.get("DailyQuests.ResetTime.Minute", 0);
|
||||
c.addComment("DailyQuests.useGUI", "Defines amount of skips player can do on a quest", "This allows player to abandon current quest and get new one");
|
||||
DailyQuestsUseGUI = c.get("DailyQuests.useGUI", true);
|
||||
c.addComment("DailyQuests.Skips", "Defines amount of skips player can do on a quest", "This allows player to abandon current quest and get new one");
|
||||
DailyQuestsSkips = c.get("DailyQuests.Skips", 1);
|
||||
c.addComment("DailyQuests.SkipQuestCost", "The cost of the quest skip (money).", "Default 0, disabling cost of skipping quest.");
|
||||
@ -1107,15 +1109,15 @@ public class GeneralConfigManager {
|
||||
CMIItemStack item = CMILib.getInstance().getItemManager().getItem(c.get("JobsGUI.InfoButton.Material",
|
||||
"head:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjcwNWZkOTRhMGM0MzE5MjdmYjRlNjM5YjBmY2ZiNDk3MTdlNDEyMjg1YTAyYjQzOWUwMTEyZGEyMmIyZTJlYyJ9fX0="));
|
||||
guiInfoButton = item.getCMIType() == CMIMaterial.NONE ? CMIMaterial.ARROW.newItemStack() : item.getItemStack();
|
||||
|
||||
|
||||
item = CMIItemStack.deserialize(c.get("JobsGUI.JoinButton.Material",
|
||||
"head:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmZlYzNkMjVhZTBkMTQ3YzM0MmM0NTM3MGUwZTQzMzAwYTRlNDhhNWI0M2Y5YmI4NThiYWJmZjc1NjE0NGRhYyJ9fX0="));
|
||||
"head:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmZlYzNkMjVhZTBkMTQ3YzM0MmM0NTM3MGUwZTQzMzAwYTRlNDhhNWI0M2Y5YmI4NThiYWJmZjc1NjE0NGRhYyJ9fX0="));
|
||||
guiJoinButton = item == null || item.getCMIType() == CMIMaterial.NONE ? CMIMaterial.GREEN_STAINED_GLASS_PANE.newItemStack() : item.getItemStack();
|
||||
|
||||
|
||||
item = CMIItemStack.deserialize(c.get("JobsGUI.LeaveButton.Material",
|
||||
"head:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzY1ZjNiYWUwZDIwM2JhMTZmZTFkYzNkMTMwN2E4NmE2MzhiZTkyNDQ3MWYyM2U4MmFiZDlkNzhmOGEzZmNhIn19fQ=="));
|
||||
"head:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzY1ZjNiYWUwZDIwM2JhMTZmZTFkYzNkMTMwN2E4NmE2MzhiZTkyNDQ3MWYyM2U4MmFiZDlkNzhmOGEzZmNhIn19fQ=="));
|
||||
guiLeaveButton = item == null || item.getCMIType() == CMIMaterial.NONE ? CMIMaterial.RED_STAINED_GLASS_PANE.newItemStack() : item.getItemStack();
|
||||
|
||||
|
||||
c.addComment("JobsGUI.InfoButton.Commands", "closeinv! can be used to close players inventory when you click this icon");
|
||||
InfoButtonCommands = c.get("JobsGUI.InfoButton.Commands", Arrays.asList("closeinv!"));
|
||||
|
||||
@ -1277,4 +1279,8 @@ public class GeneralConfigManager {
|
||||
public boolean isBossBarAsync() {
|
||||
return bossBarAsync;
|
||||
}
|
||||
|
||||
public boolean isDailyQuestsUseGUI() {
|
||||
return DailyQuestsUseGUI;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user