mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-04 23:37:49 +01:00
Jobs browse GUI full customization
This commit is contained in:
parent
23d32d0765
commit
713f626bce
@ -39,19 +39,25 @@ public class GuiManager {
|
|||||||
GuiInfoList info = GuiList.get(player.getName());
|
GuiInfoList info = GuiList.get(player.getName());
|
||||||
List<Job> JobsList = info.getJobList();
|
List<Job> JobsList = info.getJobList();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int pos = 7;
|
int pos = Jobs.getGCManager().getJobsGUIStartPosition() - 1;
|
||||||
main: for (int z = 1; z < 5; z++) {
|
int group = 0;
|
||||||
pos += 2;
|
main: for (int z = 0; z < JobsList.size(); z++) {
|
||||||
for (int x = 1; x < 8; x++) {
|
group++;
|
||||||
pos++;
|
|
||||||
if (i >= JobsList.size())
|
|
||||||
break main;
|
|
||||||
|
|
||||||
if (pos == slot)
|
if (group > Jobs.getGCManager().getJobsGUIGroupAmount()) {
|
||||||
return JobsList.get(i);
|
group = 1;
|
||||||
i++;
|
pos += Jobs.getGCManager().getJobsGUISkipAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pos++;
|
||||||
|
if (i >= JobsList.size())
|
||||||
|
break main;
|
||||||
|
|
||||||
|
if (pos == slot)
|
||||||
|
return JobsList.get(i);
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +81,7 @@ public class GuiManager {
|
|||||||
|
|
||||||
GuiList.put(player.getName(), guiInfo);
|
GuiList.put(player.getName(), guiInfo);
|
||||||
|
|
||||||
int GuiSize = 54;
|
int GuiSize = Jobs.getGCManager().getJobsGUIRows() * 9;
|
||||||
|
|
||||||
JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||||
|
|
||||||
@ -88,66 +94,74 @@ public class GuiManager {
|
|||||||
Inventory GuiInv = Bukkit.createInventory(null, GuiSize, title);
|
Inventory GuiInv = Bukkit.createInventory(null, GuiSize, title);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int pos = 7;
|
int pos = Jobs.getGCManager().getJobsGUIStartPosition() - 1;
|
||||||
main: for (int z = 1; z < 5; z++) {
|
int group = 0;
|
||||||
pos += 2;
|
main: for (int z = 0; z < JobsList.size(); z++) {
|
||||||
for (int x = 1; x < 8; x++) {
|
group++;
|
||||||
pos++;
|
|
||||||
if (i >= JobsList.size())
|
|
||||||
break main;
|
|
||||||
Job job = JobsList.get(i);
|
|
||||||
|
|
||||||
ArrayList<String> Lore = new ArrayList<String>();
|
if (group > Jobs.getGCManager().getJobsGUIGroupAmount()) {
|
||||||
|
group = 1;
|
||||||
for (JobProgression onePJob : pJobs) {
|
pos += Jobs.getGCManager().getJobsGUISkipAmount();
|
||||||
if (onePJob.getJob().getName().equalsIgnoreCase(job.getName()))
|
|
||||||
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.working"));
|
|
||||||
}
|
|
||||||
|
|
||||||
int maxlevel = job.getMaxLevel(JPlayer);
|
|
||||||
if (maxlevel > 0)
|
|
||||||
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.max") + maxlevel);
|
|
||||||
|
|
||||||
if (Jobs.getGCManager().ShowTotalWorkers)
|
|
||||||
Lore.add(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", job.getTotalPlayers()));
|
|
||||||
|
|
||||||
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus)
|
|
||||||
if (job.getBonus() < 0)
|
|
||||||
Lore.add(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (job.getBonus() * 100) * -1));
|
|
||||||
else
|
|
||||||
Lore.add(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (job.getBonus() * 100)));
|
|
||||||
|
|
||||||
Lore.addAll(Arrays.asList(job.getDescription().split("/n")));
|
|
||||||
|
|
||||||
if (job.getMaxSlots() != null)
|
|
||||||
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftSlots") + ((job.getMaxSlots() - Jobs.getUsedSlots(job)) > 0 ? (job.getMaxSlots() - Jobs
|
|
||||||
.getUsedSlots(
|
|
||||||
job)) : 0));
|
|
||||||
|
|
||||||
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.actions"));
|
|
||||||
for (ActionType actionType : ActionType.values()) {
|
|
||||||
List<JobInfo> info = job.getJobInfo(actionType);
|
|
||||||
if (info != null && !info.isEmpty()) {
|
|
||||||
Lore.add(ChatColor.translateAlternateColorCodes('&', "&e" + Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase()
|
|
||||||
+ ".info")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Lore.add("");
|
|
||||||
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftClick"));
|
|
||||||
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.rightClick"));
|
|
||||||
|
|
||||||
ItemStack GuiItem = job.getGuiItem();
|
|
||||||
|
|
||||||
ItemMeta meta = GuiItem.getItemMeta();
|
|
||||||
meta.setDisplayName(job.getChatColor() + job.getName());
|
|
||||||
meta.setLore(Lore);
|
|
||||||
GuiItem.setItemMeta(meta);
|
|
||||||
|
|
||||||
GuiInv.setItem(pos, GuiItem);
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pos += 2;
|
||||||
|
// for (int x = 1; x <= 7; x++) {
|
||||||
|
pos++;
|
||||||
|
if (i >= JobsList.size())
|
||||||
|
break main;
|
||||||
|
Job job = JobsList.get(i);
|
||||||
|
|
||||||
|
ArrayList<String> Lore = new ArrayList<String>();
|
||||||
|
|
||||||
|
for (JobProgression onePJob : pJobs) {
|
||||||
|
if (onePJob.getJob().getName().equalsIgnoreCase(job.getName()))
|
||||||
|
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.working"));
|
||||||
|
}
|
||||||
|
|
||||||
|
int maxlevel = job.getMaxLevel(JPlayer);
|
||||||
|
if (maxlevel > 0)
|
||||||
|
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.max") + maxlevel);
|
||||||
|
|
||||||
|
if (Jobs.getGCManager().ShowTotalWorkers)
|
||||||
|
Lore.add(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", job.getTotalPlayers()));
|
||||||
|
|
||||||
|
if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus)
|
||||||
|
if (job.getBonus() < 0)
|
||||||
|
Lore.add(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (job.getBonus() * 100) * -1));
|
||||||
|
else
|
||||||
|
Lore.add(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (job.getBonus() * 100)));
|
||||||
|
|
||||||
|
Lore.addAll(Arrays.asList(job.getDescription().split("/n")));
|
||||||
|
|
||||||
|
if (job.getMaxSlots() != null)
|
||||||
|
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftSlots") + ((job.getMaxSlots() - Jobs.getUsedSlots(job)) > 0 ? (job.getMaxSlots() - Jobs
|
||||||
|
.getUsedSlots(
|
||||||
|
job)) : 0));
|
||||||
|
|
||||||
|
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.actions"));
|
||||||
|
for (ActionType actionType : ActionType.values()) {
|
||||||
|
List<JobInfo> info = job.getJobInfo(actionType);
|
||||||
|
if (info != null && !info.isEmpty()) {
|
||||||
|
Lore.add(ChatColor.translateAlternateColorCodes('&', "&e" + Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase()
|
||||||
|
+ ".info")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Lore.add("");
|
||||||
|
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftClick"));
|
||||||
|
Lore.add(Jobs.getLanguage().getMessage("command.info.gui.rightClick"));
|
||||||
|
|
||||||
|
ItemStack GuiItem = job.getGuiItem();
|
||||||
|
|
||||||
|
ItemMeta meta = GuiItem.getItemMeta();
|
||||||
|
meta.setDisplayName(job.getChatColor() + job.getName());
|
||||||
|
meta.setLore(Lore);
|
||||||
|
GuiItem.setItemMeta(meta);
|
||||||
|
|
||||||
|
GuiInv.setItem(pos, GuiItem);
|
||||||
|
i++;
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack filler = Jobs.getGCManager().guiFiller;
|
ItemStack filler = Jobs.getGCManager().guiFiller;
|
||||||
@ -257,8 +271,8 @@ public class GuiManager {
|
|||||||
items.add(one);
|
items.add(one);
|
||||||
}
|
}
|
||||||
|
|
||||||
int GuiSize = 54;
|
int GuiSize = Jobs.getGCManager().getJobsGUIRows() * 9;
|
||||||
int backButton = 45;
|
int backButton = Jobs.getGCManager().getJobsGUIBackButton();
|
||||||
|
|
||||||
String title = Jobs.getLanguage().getMessage("command.info.gui.jobinfo", "[jobname]", job.getName());
|
String title = Jobs.getLanguage().getMessage("command.info.gui.jobinfo", "[jobname]", job.getName());
|
||||||
if (title.length() > 32)
|
if (title.length() > 32)
|
||||||
|
@ -103,6 +103,11 @@ public class GeneralConfigManager {
|
|||||||
EmptyServerAcountActionBar, ActionBarsMessageByDefault, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment,
|
EmptyServerAcountActionBar, ActionBarsMessageByDefault, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment,
|
||||||
useGlobalBoostScheduler, JobsGUIOpenOnBrowse, JobsGUIShowChatBrowse, JobsGUISwitcheButtons, JobsGUIOpenOnJoin;
|
useGlobalBoostScheduler, JobsGUIOpenOnBrowse, JobsGUIShowChatBrowse, JobsGUISwitcheButtons, JobsGUIOpenOnJoin;
|
||||||
|
|
||||||
|
private int JobsGUIRows, JobsGUIBackButton,
|
||||||
|
JobsGUIStartPosition,
|
||||||
|
JobsGUIGroupAmount,
|
||||||
|
JobsGUISkipAmount;
|
||||||
|
|
||||||
private String DecimalPlacesMoney, DecimalPlacesExp, DecimalPlacesPoints;
|
private String DecimalPlacesMoney, DecimalPlacesExp, DecimalPlacesPoints;
|
||||||
|
|
||||||
public ItemStack guiBackButton;
|
public ItemStack guiBackButton;
|
||||||
@ -892,7 +897,16 @@ public class GeneralConfigManager {
|
|||||||
c.getW().addComment("JobsGUI.SwitcheButtons", "With true left mouse button will join job and right will show more info",
|
c.getW().addComment("JobsGUI.SwitcheButtons", "With true left mouse button will join job and right will show more info",
|
||||||
"With false left mouse button will show more info, rigth will join job", "Dont forget to adjust locale file");
|
"With false left mouse button will show more info, rigth will join job", "Dont forget to adjust locale file");
|
||||||
JobsGUISwitcheButtons = c.get("JobsGUI.SwitcheButtons", false);
|
JobsGUISwitcheButtons = c.get("JobsGUI.SwitcheButtons", false);
|
||||||
c.getW().addComment("JobsBrowse.ShowPenaltyBonus", "Do you want to show GUI when performing /jobs join command");
|
c.getW().addComment("JobsGUI.Rows", "Defines size in rows of GUI");
|
||||||
|
JobsGUIRows = c.get("JobsGUI.Rows", 5);
|
||||||
|
c.getW().addComment("JobsGUI.BackButtonSlot", "Defines back button slot in GUI");
|
||||||
|
JobsGUIBackButton = c.get("JobsGUI.BackButtonSlot", 37);
|
||||||
|
c.getW().addComment("JobsGUI.StartPosition", "Defines start position in gui from which job icons will be shown");
|
||||||
|
JobsGUIStartPosition = c.get("JobsGUI.StartPosition", 11);
|
||||||
|
c.getW().addComment("JobsGUI.GroupAmount", "Defines By how many jobs we need to group up");
|
||||||
|
JobsGUIGroupAmount = c.get("JobsGUI.GroupAmount", 7);
|
||||||
|
c.getW().addComment("JobsGUI.SkipAmount", "Defines By how many slot we need to skip after group");
|
||||||
|
JobsGUISkipAmount = c.get("JobsGUI.SkipAmount", 2);
|
||||||
|
|
||||||
Material tmat = Material.getMaterial(c.get("JobsGUI.BackButton.Material", "JACK_O_LANTERN"));
|
Material tmat = Material.getMaterial(c.get("JobsGUI.BackButton.Material", "JACK_O_LANTERN"));
|
||||||
guiBackButton = new ItemStack(tmat == null ? Material.JACK_O_LANTERN : tmat, 1, (byte) c.get("JobsGUI.BackButton.Data", 0));
|
guiBackButton = new ItemStack(tmat == null ? Material.JACK_O_LANTERN : tmat, 1, (byte) c.get("JobsGUI.BackButton.Data", 0));
|
||||||
@ -965,4 +979,32 @@ public class GeneralConfigManager {
|
|||||||
return DecimalPlacesPoints;
|
return DecimalPlacesPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getJobsGUIRows() {
|
||||||
|
if (JobsGUIRows < 1)
|
||||||
|
JobsGUIRows = 1;
|
||||||
|
return JobsGUIRows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getJobsGUIBackButton() {
|
||||||
|
if (JobsGUIBackButton < 1)
|
||||||
|
JobsGUIBackButton = 1;
|
||||||
|
if (JobsGUIBackButton > JobsGUIRows * 9)
|
||||||
|
JobsGUIBackButton = JobsGUIRows * 9;
|
||||||
|
return JobsGUIBackButton - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getJobsGUIStartPosition() {
|
||||||
|
if (JobsGUIBackButton < 1)
|
||||||
|
JobsGUIBackButton = 1;
|
||||||
|
return JobsGUIStartPosition - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getJobsGUIGroupAmount() {
|
||||||
|
return JobsGUIGroupAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getJobsGUISkipAmount() {
|
||||||
|
return JobsGUISkipAmount;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -232,14 +232,14 @@ public class JobsListener implements Listener {
|
|||||||
if (job != null) {
|
if (job != null) {
|
||||||
Inventory inv = Jobs.getGUIManager().CreateJobsSubGUI(player, job);
|
Inventory inv = Jobs.getGUIManager().CreateJobsSubGUI(player, job);
|
||||||
Inventory top = player.getOpenInventory().getTopInventory();
|
Inventory top = player.getOpenInventory().getTopInventory();
|
||||||
if (top.getSize() == 54)
|
if (top.getSize() == Jobs.getGCManager().getJobsGUIRows() * 9)
|
||||||
top.setContents(inv.getContents());
|
top.setContents(inv.getContents());
|
||||||
}
|
}
|
||||||
} else if (joblist.isJobInfo()) {
|
} else if (joblist.isJobInfo()) {
|
||||||
if (slot == joblist.getbackButton()) {
|
if (slot == joblist.getbackButton()) {
|
||||||
Inventory inv = Jobs.getGUIManager().CreateJobsGUI(player);
|
Inventory inv = Jobs.getGUIManager().CreateJobsGUI(player);
|
||||||
Inventory top = player.getOpenInventory().getTopInventory();
|
Inventory top = player.getOpenInventory().getTopInventory();
|
||||||
if (top.getSize() == 54)
|
if (top.getSize() == Jobs.getGCManager().getJobsGUIRows() * 9)
|
||||||
top.setContents(inv.getContents());
|
top.setContents(inv.getContents());
|
||||||
}
|
}
|
||||||
} else if (!Jobs.getGCManager().JobsGUISwitcheButtons && event.getClick() == ClickType.RIGHT ||
|
} else if (!Jobs.getGCManager().JobsGUISwitcheButtons && event.getClick() == ClickType.RIGHT ||
|
||||||
|
Loading…
Reference in New Issue
Block a user