diff --git a/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java b/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java index 980983aa..ff211d8c 100644 --- a/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java +++ b/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java @@ -21,6 +21,7 @@ import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobsPlayer; import net.Zrips.CMILib.CMILib; +import net.Zrips.CMILib.Colors.CMIChatColor; import net.Zrips.CMILib.Container.CMICommands; import net.Zrips.CMILib.GUI.CMIGui; import net.Zrips.CMILib.GUI.CMIGuiButton; @@ -144,25 +145,40 @@ public class GuiManager { } lore.add(""); - lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftClick")); + + if (Jobs.getGCManager().JobsGUISwitcheButtons) { + if (!jPlayer.isInJob(job)) { + lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftClick")); + } + } else { + lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftClick")); + } + if (jPlayer.isInJob(job)) { if (Version.isCurrentEqualOrHigher(Version.v1_18_R1)) lore.add(Jobs.getLanguage().getMessage("command.info.gui.qClick")); else lore.add(Jobs.getLanguage().getMessage("command.info.gui.middleClick")); } - lore.add(Jobs.getLanguage().getMessage("command.info.gui.rightClick")); - ItemStack guiItem = job.getGuiItem(); - ItemMeta meta = guiItem.getItemMeta(); - meta.setDisplayName(job.getDisplayName()); - meta.setLore(lore); - - if (Jobs.getGCManager().hideItemAttributes) { - meta.addItemFlags(org.bukkit.inventory.ItemFlag.HIDE_ATTRIBUTES, org.bukkit.inventory.ItemFlag.HIDE_ENCHANTS); + if (!Jobs.getGCManager().JobsGUISwitcheButtons) { + if (!jPlayer.isInJob(job)) { + lore.add(Jobs.getLanguage().getMessage("command.info.gui.rightClick")); + } + } else { + lore.add(Jobs.getLanguage().getMessage("command.info.gui.rightClick")); } - guiItem.setItemMeta(meta); + ItemStack guiItem = job.getGuiItem(); +// ItemMeta meta = guiItem.getItemMeta(); +// meta.setDisplayName(job.getDisplayName()); +// meta.setLore(lore); +// +// if (Jobs.getGCManager().hideItemAttributes) { +// meta.addItemFlags(org.bukkit.inventory.ItemFlag.HIDE_ATTRIBUTES, org.bukkit.inventory.ItemFlag.HIDE_ENCHANTS); +// } +// +// guiItem.setItemMeta(meta); CMIGuiButton button = new CMIGuiButton(job.getGuiSlot() >= 0 ? job.getGuiSlot() : pos, guiItem) { @@ -206,6 +222,12 @@ public class GuiManager { } }; + button.setName(job.getDisplayName()); + button.addLore(lore); + if (Jobs.getGCManager().hideItemAttributes) { + button.hideItemFlags(); + } + if (jPlayer.isInJob(job)) { button.setGlowing(); } @@ -288,15 +310,15 @@ public class GuiManager { double income = jInfo.getIncome(level, numjobs, jPlayer.maxJobsEquation); income = boost.getFinalAmount(CurrencyType.MONEY, income); - String incomeColor = income >= 0 ? "" : ChatColor.DARK_RED.toString(); + String incomeColor = income >= 0 ? "" : CMIChatColor.DARK_RED.toString(); double xp = jInfo.getExperience(level, numjobs, jPlayer.maxJobsEquation); xp = boost.getFinalAmount(CurrencyType.EXP, xp); - String xpColor = xp >= 0 ? "" : ChatColor.GRAY.toString(); + String xpColor = xp >= 0 ? "" : CMIChatColor.GRAY.toString(); double points = jInfo.getPoints(level, numjobs, jPlayer.maxJobsEquation); points = boost.getFinalAmount(CurrencyType.POINTS, points); - String pointsColor = points >= 0 ? "" : ChatColor.RED.toString(); + String pointsColor = points >= 0 ? "" : CMIChatColor.RED.toString(); if (income == 0D && points == 0D && xp == 0D) continue; @@ -384,6 +406,24 @@ public class GuiManager { }); } + if (!Jobs.getGCManager().DisableJoiningJobThroughGui) { + if (jPlayer.isInJob(job)) { + CMIGuiButton button = new CMIGuiButton(40, Jobs.getGCManager().guiLeaveButton) { + @Override + public void click(GUIClickType type) { + leaveConfirmation(player, job, fromCommand, guiSize); + } + }; + button.setName(Jobs.getLanguage().getMessage("general.info.leave")); + + gui.addButton(button); + } else if (Jobs.getPlayerManager().getJobsLimit(jPlayer, (short) jPlayer.getJobProgression().size())) { + gui.addButton(generateJoinButton(player, job, fromCommand, 39)); + gui.addButton(generateJoinButton(player, job, fromCommand, 40)); + gui.addButton(generateJoinButton(player, job, fromCommand, 41)); + } + } + if (i >= 53 && !jobsRemained.isEmpty()) { CMIItemStack next = CMILib.getInstance().getConfigManager().getGUINextPage(); next.setDisplayName(LC.info_nextPageHover.getLocale()); @@ -400,6 +440,57 @@ public class GuiManager { gui.open(); } + private void leaveConfirmation(Player player, Job job, boolean fromCommand, int guiSize) { + + CMIGui gui = new CMIGui(player); + gui.setTitle(Jobs.getLanguage().getMessage("command.info.gui.jobinfo", "[jobname]", job.getName())); + gui.setInvSize(guiSize); + + gui.addButton(generateLeaveButton(player, job, fromCommand, 21)); + gui.addButton(generateLeaveButton(player, job, fromCommand, 22)); + gui.addButton(generateLeaveButton(player, job, fromCommand, 23)); + + CMIGuiButton button = new CMIGuiButton(40, Jobs.getGCManager().guiJoinButton) { + @Override + public void click(GUIClickType type) { + openJobsBrowseGUI(player, job, fromCommand); + } + }; + button.setName(LC.modify_cancelSymbolHover.getLocale()); + gui.addButton(button); + + gui.fillEmptyButtons(); + gui.open(); + } + + private CMIGuiButton generateJoinButton(Player player, Job job, boolean fromCommand, int slot) { + + CMIGuiButton button = new CMIGuiButton(slot, Jobs.getGCManager().guiJoinButton) { + @Override + public void click(GUIClickType type) { + Jobs.getCommandManager().onCommand(player, null, "jobs", new String[] { "join", job.getName() }); + openJobsBrowseGUI(player, job, fromCommand); + } + }; + button.setName(Jobs.getLanguage().getMessage("general.info.join")); + + return button; + } + + private CMIGuiButton generateLeaveButton(Player player, Job job, boolean fromCommand, int slot) { + + CMIGuiButton button = new CMIGuiButton(slot, Jobs.getGCManager().guiLeaveButton) { + @Override + public void click(GUIClickType type) { + Jobs.getCommandManager().onCommand(player, null, "jobs", new String[] { "leave", job.getName() }); + openJobsBrowseGUI(player, job, fromCommand); + } + }; + button.setName(Jobs.getLanguage().getMessage("general.info.leave")); + + return button; + } + private void openJobsBrowseGUI(Player player, Job job, List jobsRemained) { Inventory tempInv = Bukkit.createInventory(player, 54, ""); diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index db601aaa..fb8382be 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -116,6 +116,8 @@ public class GeneralConfigManager { public boolean DailyQuestsEnabled; public ItemStack guiInfoButton; + public ItemStack guiJoinButton; + public ItemStack guiLeaveButton; public int InfoButtonSlot = 9; public List InfoButtonCommands = new ArrayList(); @@ -1105,7 +1107,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=")); + 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==")); + 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!")); diff --git a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java index bb1b89f0..bb6721a1 100644 --- a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java @@ -98,6 +98,10 @@ public class LanguageManager { c.get("general.info.blocks.smoker", "Smoker"); c.get("general.info.blocks.blastfurnace", "Blast furnace"); c.get("general.info.blocks.brewingstand", "Brewing stand"); + + c.get("general.info.join", "&eClick to join job"); + c.get("general.info.leave", "&cClick to leave job"); + c.get("general.admin.error", "&cThere was an error in the command."); c.get("general.admin.success", "&eYour command has been performed."); c.get("general.error.noHelpPage", "&cThere is no help page by this number!"); @@ -111,6 +115,7 @@ public class LanguageManager { c.get("general.error.reenabledBlock", "&eReenabled ownership"); c.get("general.error.noRegistration", "&cYou've reached max [block] count!"); c.get("general.error.blockDisabled", "&6Payments from &e[type] &6got disabled. &2[location]"); + c.get("command.help.output.cmdUsage", "&2Usage: &7[command]"); c.get("command.help.output.label", "Jobs"); diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 772f2b04..680c4c6f 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -77,7 +77,6 @@ import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerShearEntityEvent; -import org.bukkit.event.player.PlayerBucketEntityEvent; import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.inventory.AnvilInventory; import org.bukkit.inventory.EnchantingInventory;