├── .poggit.yml ├── LICENSE ├── README.md ├── icon.png ├── plugin.yml ├── resources ├── jobs.yml ├── messages.yml └── players.yml └── src └── hamid0740 └── JobUI └── Main.php /.poggit.yml: -------------------------------------------------------------------------------- 1 | --- # Poggit-CI Manifest. Open the CI at https://poggit.pmmp.io/ci/hamid0740/JobUI 2 | build-by-default: true 3 | branches: 4 | - master 5 | projects: 6 | JobUI: 7 | path: "" 8 | libs: 9 | - src: jojoe77777/FormAPI/libFormAPI 10 | version: ^1.3 11 | ... 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | 179 | Copyright JobUI hamid0740 180 | 181 | Licensed under the Apache License, Version 2.0 (the "License"); 182 | you may not use this file except in compliance with the License. 183 | You may obtain a copy of the License at 184 | 185 | http://www.apache.org/licenses/LICENSE-2.0 186 | 187 | Unless required by applicable law or agreed to in writing, software 188 | distributed under the License is distributed on an "AS IS" BASIS, 189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 190 | See the License for the specific language governing permissions and 191 | limitations under the License. 192 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JobUI 2 | [![Plugin Status](https://poggit.pmmp.io/shield.state/JobUI)](https://poggit.pmmp.io/p/JobUI) [![Plugin Version](https://poggit.pmmp.io/shield.api/JobUI)](https://poggit.pmmp.io/p/JobUI) [![Downloads](https://poggit.pmmp.io/shield.dl/JobUI)](https://poggit.pmmp.io/p/JobUI) [![Total Downloads](https://poggit.pmmp.io/shield.dl.total/JobUI)](https://poggit.pmmp.io/p/JobUI) 3 | * __!!! IMPORTANT !!! if you have installed this plugin before, remove the `plugin_data/JobUI` folder then the new Yaml files will be created.__ 4 | * __Simple Mode & Goal Mode Jobs are supported. By joining SimpleMode Jobs when you do 1 mission you will earn the specified money. By joining GoalMode Jobs when you complete the Goal you will earn the specified salary. You can change the Modes of jobs in `plugin_data/JobUI/jobs.yml`__ 5 | * __Customisable and Infinite Jobs are supported. You can edit or add jobs in `plugin_data/JobUI/jobs.yml`.__ 6 | * __Customisable Messages are supported. You can change them in `plugin_data/JobUI/messages.yml`__ 7 | * I changed the default permissions to "op" to prevent earning money in a "Build and Mine Protected World" like Lobby. 8 | * You will learn how to let players Join Jobs and Earn Money only in a specified world, but before you need to install the PurePerms plugin. 9 | * Thanks to [@H3xmor](https://github.com/h3xmor) to help me on the line 486 10 | ### Default Jobs 11 | * __Tree-Cutter:__ By joining this job, when you break any kind of logs with any directions you will earn 25$. 12 | * __Miner:__ By joining this job, when you break Stone you will earn 25$, when you break Coal Ore you will earn 30$ and when you break Iron Ore you will earn 35$. 13 | * __Hunter:__ By joining this job, when you kill a Mob(Animal or Monster) you will earn 30$. 14 | * __Murderer:__ By joining this job, when you kill a Player you will earn 50$. 15 | * __Tree-Cutter-Goal:__ By joining this job, when you break 20 Blocks of any kind of logs with any directions you will earn 500$. 16 | * __Miner-Goal:__ By joining this job, when you break 20 Blocks of Stone, Coal ore or Iron ore you will earn 600$. 17 | * __Hunter-Goal:__ By joining this job, when you kill 20 Mobs(Animal or Monster) you will earn 600$. 18 | * __Murderer-Goal:__ By joining this job, when you kill 20 Players you will earn 1000$. 19 | ### Dependencies: 20 | * [EconomyAPI by onebone](https://poggit.pmmp.io/p/EconomyAPI/) [[Download]](https://poggit.pmmp.io/r/34531/EconomyAPI.phar) [[GitHub]](https://github.com/poggit-orphanage/EconomyS/) __(Required)__ 21 | * [PurePerms by 64FF00](https://poggit.pmmp.io/p/PurePerms/) [[Download]](https://poggit.pmmp.io/r/70018/PurePerms.phar) [[GitHub]](https://github.com/poggit-orphanage/PurePerms/) (Optional) 22 | * [MineReset by falkirks](https://poggit.pmmp.io/p/MineReset/) [[Download]](https://poggit.pmmp.io/r/40667/MineReset.phar) [[GitHub]](https://github.com/falkirks/MineReset/) (Optional) 23 | * [PureEntitiesX by RevivalPMMP](https://poggit.pmmp.io/p/PureEntitiesX/) [[Download]](https://poggit.pmmp.io/r/93487/PureEntitiesX.phar) [[GitHub]](https://github.com/RevivalPMMP/PureEntitiesX/) (Optional) 24 | ### How to let players Join Jobs and Earn Money only in a specified world? 25 | * As I said you need to install the PurePerms plugin. 26 | * __*Before completing the next steps, make sure that `enable-multiworld-perms` has been set to `true` in `plugin_data/PurePerms/config.yml`.*__ 27 | * Open this file path `plugin_data/PurePerms/groups.yml`. Then the only thing that you should do is to add the world and permissions to the Group you want. I will give an example below: 28 | ```yaml 29 | --- 30 | Guest: 31 | alias: gst 32 | isDefault: true 33 | inheritance: [] 34 | permissions: 35 | worlds: 36 | Mine: 37 | isDefault: true 38 | permissions: 39 | - jobui.job.tree-cutter 40 | - jobui.job.miner 41 | - jobui.job.tree-cutter-goal 42 | - jobui.job.miner-goal 43 | - jobui.earn.break 44 | - jobui.progress.break 45 | Survival: 46 | isDefault: true 47 | permissions: 48 | - jobui.job.hunter 49 | - jobui.job.hunter-goal 50 | - jobui.earn.hunter 51 | - jobui.progress.hunter 52 | PvP: 53 | isDefault: true 54 | permissions: 55 | - jobui.job.murderer 56 | - jobui.job.murderer-goal 57 | - jobui.earn.murderer 58 | - jobui.progress.murderer 59 | 60 | ... 61 | ``` 62 | * If a player is in the Guest group, he will be able to join "Tree-Cutter" & "Miner" & "Tree-Cutter-Goal" & "Miner-Goal" job only in the "Mine" world 63 | * If a player is in the Guest group, he will be able to join "Hunter" & "Hunter-Goal" job only in the "Survival" world 64 | * If a player is in the Guest group, he will be able to join "Murderer" & "Murderer-Goal" job only in the "PvP" world 65 | * Also, he will be able to earn money or increase the progress of a job by a "Breaking" MissionType only in the "Mine" world 66 | * Also, he will be able to earn money or increase the progress of a job by a "Hunter" MissionType only in the "Survival" world 67 | * Also, he will be able to earn money or increase the progress of a job by a "Murderer" MissionType only in the "PvP" world 68 | ### Image 69 | ![Image](http://www.mediafire.com/convkey/c57e/26ld17819ayjny3zg.jpg) 70 | ### Video 71 | [![Video](https://img.youtube.com/vi/kkwxWiDJZ2k/0.jpg)](https://www.youtube.com/watch?v=kkwxWiDJZ2k) 72 | ### To-Do list 73 | * [X] Adding Customizable feature for jobs, so that you will be able to add more jobs 74 | * [X] Adding Customizable feature for texts of the UI and every messages 75 | * [X] Adding Customizable feature for Button names and Images for JobJoinUI 76 | * [X] Adding "Hunter" & "Murderer" MissionType 77 | * [X] Adding Job Modes(Simple Mode and Goal Mode) 78 | ### Permissions and Commands: 79 | Permission | Command | Default | About 80 | ---------- | ------- | ------- | ----- 81 | jobui.* | - | op | Able to use all commands, all earning ways and join all of the jobs of JobUI plugin 82 | jobui.job.* | - | op | Able to join all of the jobs 83 | jobui.command.job | /job | true | Able to see the UI of the Jobs 84 | jobui.command.retire | /retire | true | Able to be retired 85 | jobui.earn.break | - | op | Able to earn money by a Breaking Job 86 | jobui.earn.place | - | op | Able to earn money by a Placing Job 87 | jobui.earn.hunter | - | op | Able to earn money by a Killing Mobs Job 88 | jobui.earn.murderer | - | op | Able to increase the progress of a job by a Killing Players Job 89 | jobui.progress.break | - | op | Able to increase the progress of a job by a Breaking Job 90 | jobui.progress.place | - | op | Able to increase the progress of a job by a Placing Job 91 | jobui.progress.hunter | - | op | Able to increase the progress of a job by a Killing Mobs Job 92 | jobui.progress.murderer | - | op | Able to increase the progress of a job by a Killing Players Job 93 | * You can edit each Job permission in `plugin_data/JobUI/jobs.yml` 94 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hamid0740/JobUI/995fb964a19edadeceb07dcf655e310abc775a46/icon.png -------------------------------------------------------------------------------- /plugin.yml: -------------------------------------------------------------------------------- 1 | name: JobUI 2 | version: 2.4.0 3 | api: 3.9.0 4 | main: hamid0740\JobUI\Main 5 | author: hamid0740 6 | website: https://github.com/hamid0740/JobUI 7 | depend: EconomyAPI 8 | 9 | commands: 10 | job: 11 | description: Job UI command (By hamid0740) 12 | usage: /job 13 | permission: jobui.command.job 14 | retire: 15 | description: Retire command (To join a job use /job) 16 | usage: /retire 17 | permission: jobui.command.retire 18 | 19 | permissions: 20 | jobui.*: 21 | description: Allows player to use all commands, all earning ways and join all of the jobs of JobUI plugin 22 | default: op 23 | jobui.job.*: 24 | description: Allows player to join all of the jobs 25 | default: op 26 | jobui.command.job: 27 | description: Allows player to use /job 28 | default: true 29 | jobui.command.retire: 30 | description: Allows player to use /retire 31 | default: true 32 | jobui.earn.break: 33 | description: Allows player to earn money by a breaking job 34 | default: op 35 | jobui.earn.place: 36 | description: Allows player to earn money by a placing job 37 | default: op 38 | jobui.earn.hunter: 39 | description: Allows player to earn money by a killing mobs job 40 | default: op 41 | jobui.earn.murderer: 42 | description: Allows player to earn money by a killing players job 43 | default: op 44 | jobui.progress.break: 45 | description: Allows player to increase the job progress by a breaking job 46 | default: op 47 | jobui.progress.place: 48 | description: Allows player to increase the job progress by a placing job 49 | default: op 50 | jobui.progress.hunter: 51 | description: Allows player to increase the job progress by a killing mobs job 52 | default: op 53 | jobui.progress.murderer: 54 | description: Allows player to increase the job progress by a killing players job 55 | default: op 56 | -------------------------------------------------------------------------------- /resources/jobs.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Mission Types: "Break" & "Place" & "Hunter" & "Murderer" 3 | # Add more jobs in this format: 4 | # 5 | # (SIMPLE MODE JOB) 6 | # Job-ID: (can contain only numbers 0-9) 7 | # Name: "Job Name" 8 | # Button-Name: "§fYour Job Button Name" 9 | # Image-Type: 0 10 | # Image: "textures/blocks/diamond_block" 11 | # Info: "Your New Job Info" 12 | # Permission: "jobui.job.JobName" (can be anything like "job.JobName") 13 | # Mode: 14 | # Name: "Simple" 15 | # Goal: 0 (It should be 0 if the JobMode is Simple) 16 | # Salary: 0 (It should be 0 if the JobMode is Simple) 17 | # Mission: 18 | # BlockID:BlockData:MissionType: Money (if you want Break or Place JobType) 19 | # MissionType: Money (if you want Hunter or Murderer JobType) 20 | # e.g. 21 | # 2:0:Break: 10 (By Breaking Grass you will earn 10$) 22 | # 2:0:Place: 10 (By Placing Grass you will earn 10$) 23 | # Hunter: 20 (By Killing Mobs or Monsters you will earn 20$) 24 | # Murderer: 30 (By Killing Players you will earn 30$) 25 | # 26 | # (GOAL MODE JOB) 27 | # Job-ID: (can contain only numbers 0-9) 28 | # Name: "Job Name" 29 | # Button-Name: "§fYour Job Button Name" 30 | # Image-Type: 0 31 | # Image: "textures/blocks/diamond_block" 32 | # Info: "Your New Job Info" 33 | # Permission: "jobui.job.JobName" (can be anything like "job.JobName") 34 | # Mode: 35 | # Name: "Goal" 36 | # Goal: 20 37 | # Salary: 500 38 | # Mission: 39 | # BlockID:BlockData:MissionType: Money (if you want Break or Place JobType)(Money should be 0 if the JobMode is Goal) 40 | # MissionType: Money (if you want Hunter or Murderer JobType)(Money should be 0 if the JobMode is Goal) 41 | # e.g. 42 | # 2:0:Break: 0 (It should be 0 if the JobMode is Goal) 43 | # 2:0:Place: 0 (It should be 0 if the JobMode is Goal) 44 | # Hunter: 0 (It should be 0 if the JobMode is Goal) 45 | # Murderer: 0 (It should be 0 if the JobMode is Goal) 46 | # 47 | # NOTE: Even you can add more than 1 MissionType for each Job. So that you will have a Mixed Job. 48 | # For example a combination of a Break and Murderer MissionType ;) 49 | # 50 | # NOTES FOR CHANGING THE UI DETAILS: (Button-Name & Image-Type & Image) 51 | # Use "§" and "0-9" or "a-f" and "r" after it to add a color. E.g. "§6This text will be Orange" 52 | # Use "\n" to go to the next line. E.g. "First Line\nSecond Line" 53 | # Image Types: 0 (Path like "textures/blocks/coal_ore") and 1 (URL like "https://gamepedia.cursecdn.com/minecraft_gamepedia/c/c5/Oak_Log_Axis_Y_JE5_BE3.png") 54 | # URL Image Type starts with "https://" 55 | # If you don't want an image for the button, put the Image Type to: -1 56 | # NOTE: Path Image Type loads faster 57 | # 58 | # IMPORTANT NOTE: if you don't follow the right format for jobs, your server might crash. 59 | 1: 60 | Name: "Tree Cutter" 61 | Button-Name: "§aTree Cutter" 62 | Image-Type: 0 63 | Image: "textures/blocks/log_oak" 64 | Info: "§6- §aTree Cutter§6:\n§dMission:\n§d(B)§bOak log §d[25$] (B)§bSpruce log §d[25$]\n§d(B)§bBirch log §d[25$] (B)§bJungle log §d[25$]\n§d(B)§bAcacia log §d[25$] (B)§bDark Oak log §d[25$]" 65 | Permission: "jobui.job.tree-cutter" 66 | Mode: 67 | Name: "Simple" 68 | Goal: 0 69 | Salary: 0 70 | Mission: 71 | 17:0:Break: 25 72 | 17:1:Break: 25 73 | 17:2:Break: 25 74 | 17:3:Break: 25 75 | 17:4:Break: 25 76 | 17:5:Break: 25 77 | 17:6:Break: 25 78 | 17:7:Break: 25 79 | 17:8:Break: 25 80 | 17:9:Break: 25 81 | 17:10:Break: 25 82 | 17:11:Break: 25 83 | 162:0:Break: 25 84 | 162:1:Break: 25 85 | 162:4:Break: 25 86 | 162:5:Break: 25 87 | 162:8:Break: 25 88 | 162:9:Break: 25 89 | 2: 90 | Name: "Miner" 91 | Button-Name: "§3Miner" 92 | Image-Type: 0 93 | Image: "textures/blocks/coal_ore" 94 | Info: "§6- §3Miner§6:\n§dMission:\n§d(B)§bStone §d[25$] (B)§bCoal ore §d[30$]\n§d(B)§bIron ore §d[35$]" 95 | Permission: "jobui.job.miner" 96 | Mode: 97 | Name: "Simple" 98 | Goal: 0 99 | Salary: 0 100 | Mission: 101 | 1:0:Break: 25 102 | 16:0:Break: 30 103 | 15:0:Break: 35 104 | 3: 105 | Name: "Hunter" 106 | Button-Name: "§6Hunter\n§4Killing Mobs" 107 | Image-Type: 0 108 | Image: "textures/items/crossbow_arrow" 109 | Info: "§a- §6Hunter§a:\n§dMission:\n§bKilling Mobs §d[30$]" 110 | Permission: "jobui.job.hunter" 111 | Mode: 112 | Name: "Simple" 113 | Goal: 0 114 | Salary: 0 115 | Mission: 116 | Hunter: 30 117 | 4: 118 | Name: "Murderer" 119 | Button-Name: "§cMurderer\n§4Killing Players" 120 | Image-Type: 0 121 | Image: "textures/items/iron_axe" 122 | Info: "§6- §cMurderer§6:\n§dMission:\n§bKilling Players §d[50$]" 123 | Permission: "jobui.job.murderer" 124 | Mode: 125 | Name: "Simple" 126 | Goal: 0 127 | Salary: 0 128 | Mission: 129 | Murderer: 50 130 | 5: 131 | Name: "Tree Cutter Goal" 132 | Button-Name: "§aTree Cutter\n§dGoal" 133 | Image-Type: 0 134 | Image: "textures/blocks/log_oak" 135 | Info: "§6- §aTree Cutter(Goal Mode)§6:\n§dMission:\n§d(B)§bOak log§d, (B)§bSpruce log§d,\n§d(B)§bBirch log§d, (B)§bJungle log§d,\n§d(B)§bAcacia log§d, (B)§bDark Oak log\n§cGoal: §e20\n§cSalary: §e500" 136 | Permission: "jobui.job.tree-cutter-goal" 137 | Mode: 138 | Name: "Goal" 139 | Goal: 20 140 | Salary: 500 141 | Mission: 142 | 17:0:Break: 0 143 | 17:1:Break: 0 144 | 17:2:Break: 0 145 | 17:3:Break: 0 146 | 17:4:Break: 0 147 | 17:5:Break: 0 148 | 17:6:Break: 0 149 | 17:7:Break: 0 150 | 17:8:Break: 0 151 | 17:9:Break: 0 152 | 17:10:Break: 0 153 | 17:11:Break: 0 154 | 162:0:Break: 0 155 | 162:1:Break: 0 156 | 162:4:Break: 0 157 | 162:5:Break: 0 158 | 162:8:Break: 0 159 | 162:9:Break: 0 160 | 6: 161 | Name: "Miner Goal" 162 | Button-Name: "§3Miner\n§dGoal" 163 | Image-Type: 0 164 | Image: "textures/blocks/coal_ore" 165 | Info: "§6- §3Miner(Goal Mode)§6:\n§dMission:\n§d(B)§bStone§d, (B)§bCoal ore§d,\n§d(B)§bIron ore\n§cGoal: §e20\n§cSalary: §e600" 166 | Permission: "jobui.job.miner-goal" 167 | Mode: 168 | Name: "Goal" 169 | Goal: 20 170 | Salary: 600 171 | Mission: 172 | 1:0:Break: 0 173 | 16:0:Break: 0 174 | 15:0:Break: 0 175 | 7: 176 | Name: "Hunter Goal" 177 | Button-Name: "§6Hunter\n§dGoal" 178 | Image-Type: 0 179 | Image: "textures/items/crossbow_arrow" 180 | Info: "§e- §6Hunter(Goal Mode)§e:\n§dMission:\n§bKilling Mobs\n§cGoal: §e20\n§cSalary: §e600" 181 | Permission: "jobui.job.hunter-goal" 182 | Mode: 183 | Name: "Goal" 184 | Goal: 20 185 | Salary: 600 186 | Mission: 187 | Hunter: 0 188 | 8: 189 | Name: "Murderer Goal" 190 | Button-Name: "§cMurderer\n§dGoal" 191 | Image-Type: 0 192 | Image: "textures/items/iron_axe" 193 | Info: "§6- §cMurderer(Goal Mode)§6:\n§dMission:\n§bKilling Players\n§cGoal: §e20\n§cSalary: §e1000" 194 | Permission: "jobui.job.murderer-goal" 195 | Mode: 196 | Name: "Goal" 197 | Goal: 20 198 | Salary: 1000 199 | Mission: 200 | Murderer: 0 201 | ... 202 | -------------------------------------------------------------------------------- /resources/messages.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # IMPORTANT NOTES: !!! Before Changing the messages read this !!! 3 | # Use "§" and "0-9" or "a-f" and "r" after it to add a color. E.g. "§6This text will be Orange" 4 | # Use "\n" to go to the next line. E.g. "First Line\nSecond Line" 5 | # 6 | # PopUp that appears when a player earn money by his Job 7 | earn-popup-1: "§b+ " # between the first part of the popup and the second, will be Money and MonatryUnit like this: "25$" 8 | earn-popup-2: " for Job!" 9 | # PopUp that appears when a player completes the progress of a Goal Mode Job 10 | salary-popup-1: "§b+ " # between the first part of the popup and the second, will be Money and MonatryUnit like this: "25$" 11 | salary-popup-2: " as Job salary!" 12 | # PopUp that appears when a player adds the progress of a Goal Mode Job 13 | progress-popup: "§6Progress of your job: " # at the end of this popup the progress of the player's job will automatically be written 14 | 15 | 16 | # PopUp that appears when a player has a job but doesn't have "jobui.progress.break" permission 17 | progress-break-noperm-message: "§cYou don't have permission to increase your job's progress by Breaking a block here. Get to the right world or Use /retire to get retired." 18 | # PopUp that appears when a player has a job but doesn't have "jobui.progress.place" permission 19 | progress-place-noperm-message: "§cYou don't have permission to increase your job's progress by Placing a block here. Get to the right world or Use /retire to get retired." 20 | # PopUp that appears when a player has a job but doesn't have "jobui.progress.hunter" permission 21 | progress-hunter-noperm-message: "§cYou don't have permission to increase your job's progress by Killing Mobs here. Get to the right world or Use /retire to get retired." 22 | # PopUp that appears when a player has a job but doesn't have "jobui.progress.murderer" permission 23 | progress-murderer-noperm-message: "§cYou don't have permission to increase your job's progress by Killing Player here. Get to the right world or Use /retire to get retired." 24 | 25 | 26 | # PopUp that appears when a player has a job but doesn't have "jobui.earn.break" permission 27 | break-noperm-message: "§cYou don't have permission to earn money by Breaking a block here. Get to the right world or Use /retire to get retired." 28 | # PopUp that appears when a player has a job but doesn't have "jobui.earn.place" permission 29 | place-noperm-message: "§cYou don't have permission to earn money by Placing a block here. Get to the right world or Use /retire to get retired." 30 | # PopUp that appears when a player has a job but doesn't have "jobui.earn.hunter" permission 31 | hunter-noperm-message: "§cYou don't have permission to earn money by Killing Mobs here. Get to the right world or Use /retire to get retired." 32 | # PopUp that appears when a player has a job but doesn't have "jobui.earn.murderer" permission 33 | murderer-noperm-message: "§cYou don't have permission to earn money by Killing Player here. Get to the right world or Use /retire to get retired." 34 | 35 | 36 | # Message that appears when a player joins a Job by JobsListUI 37 | jobjoin-message: "§aYou have joined the job §e" # at the end of this text the job will automatically be written 38 | # Message that appears when a player joins a Job by JobsListUI 39 | jobjoin-noperm-message: "§cYou don't have permission to join the job §e" # at the end of this text the job will automatically be written 40 | # Message the appears when the player get retired by "/retire" command or by the UI 41 | retire-message: "§cYou have retired from the job §e" # at the end of this message the job will automatically be written 42 | # Message the appears when the player finishes a GoalMode job and earns his salary and retires from his job 43 | salary-retire-message: "§aYour job has been finished and you got your salary. Now you can join another job. Also you have retired from the job §e" # at the end of this message the job will automatically be written 44 | # Message that appear when a player doesn't have a job and wants to get retired by "/retire" command or by the UI 45 | nojob-retire-message: "§cYou don't have a job yet. First join a job then you'll be able to get retired." 46 | 47 | 48 | # Message that appears when a player wants to know his job by "My Job" button in the UI 49 | myjob-message: "§aYour job is: §e" # at the end of this message the job will automatically be written 50 | # Mesage that appears when a player wants to know his job's progress status by "My Job" button in the UI (Only for GoalMode jobs) 51 | progress-myjob-message: "§aProgress of your job is: §e" # at the end of this message the progress of the player's job will automatically be written 52 | # Message that appears when a player wants to know his job by "My Job" button in the UI but he doesn't have a job 53 | nojob-message: "§cYou don't have a job yet. First join a job then you'll be able to know your job." 54 | 55 | 56 | # Title of the MainUI that appears by "/job" command 57 | title-mainui: "§bJob" 58 | # Text that shows the player's job in the MainUI 59 | myjob-text-mainui: "§aYour Job: §e" # at the end of this text the job will automatically be written 60 | # Text that shows the player's job in the MainUI 61 | progress-myjob-text-mainui: "§aProgress of your Job: §e" # at the end of this message the progress of the player's job will automatically be written 62 | # Text that shows the player's job in the MainUI when the player doesn't have a job 63 | nojob-text-mainui: "§cYou don't have a job" 64 | # Text of the JobJoin button in the MainUI 65 | jobjoin-button-mainui: "§aJoin a Job" 66 | # Text of the JobsInfo button in the MainUI 67 | myjobinfo-button-mainui: "§6My Job Info" 68 | # Text of the MyJob button in the MainUI 69 | myjob-button-mainui: "§dMy Job" 70 | # Text of the Retire button in the MainUI 71 | retire-button-mainui: "§cRetire from your Job" 72 | 73 | 74 | # Title of the JobsListUI that appears by JobJoin button in the MainUI 75 | title-jobslistui: "§bJobs List" 76 | # Text that shows a message in JobsListUI 77 | text-jobslistui: "§aWhich job do you want to join?" 78 | # Text of the Return to MainUI button in the JobsListUI 79 | return-to-mainui-button-jobslistui: "§cReturn to the Main Menu" 80 | 81 | 82 | # Title of the JobsListUI that appears by JobJoin button in the MainUI 83 | title-jobjoinui: "§bJoin a Job" 84 | # Text of the Join button in the JobJoinUI 85 | join-button-jobjoinui: "§aJoin the job §e" # at the end of this message the Name of the job will automatically be written 86 | # Text of the Return to JobsListUI button in the JobJoinUI 87 | return-to-jobslistui-button-jobjoinui: "§cReturn to the Jobs List" 88 | 89 | 90 | # Title of the MyJobInfoUI that appears by JobsInfo button in the MainUI 91 | title-myjobinfoui: "§bMy Job Info" 92 | # Text of the MyJobInfoUI when a player doesn't have a job 93 | nojob-text-myjobinfoui: "§cYou don't have a job yet. First join a job then you'll be able to know your job info." 94 | # Text of the Exit button in the MyJobInfoUI 95 | exit-button-myjobinfoui: "§aOkay!" 96 | # Text of the Return to MainUI button in the MyJobInfoUI 97 | return-to-mainui-button-myjobinfoui: "§cReturn to the Main Menu" 98 | ... 99 | -------------------------------------------------------------------------------- /resources/players.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Nothing Here 3 | ... 4 | -------------------------------------------------------------------------------- /src/hamid0740/JobUI/Main.php: -------------------------------------------------------------------------------- 1 | getDataFolder()); 70 | $this->saveDefaultConfig(); 71 | $this->saveResource("jobs.yml"); 72 | $this->saveResource("messages.yml"); 73 | $this->jobs = new Config($this->getDataFolder() . "jobs.yml", Config::YAML); 74 | $this->messages = new Config($this->getDataFolder() . "messages.yml", Config::YAML); 75 | $this->player = new Config($this->getDataFolder() . "players.yml", Config::YAML); 76 | 77 | $this->getServer()->getPluginManager()->registerEvents($this, $this); 78 | 79 | $this->api = EconomyAPI::getInstance(); 80 | self::$instance = $this; 81 | } 82 | 83 | private function readResource($res){ 84 | $path = $this->getFile()."resources/".$res; 85 | $resource = $this->getResource($res); 86 | if(!is_resource($resource)){ 87 | $this->getLogger()->debug("Tried to load unknown resource ".TextFormat::AQUA.$res.TextFormat::RESET); 88 | return false; 89 | } 90 | $content = stream_get_contents($resource); 91 | @fclose($content); 92 | return $content; 93 | } 94 | 95 | public function onDisable(){ 96 | $this->player->save(); 97 | } 98 | 99 | /** 100 | * Get JobUI messages 101 | * 102 | * @param string $id 103 | * 104 | * @return string | bool 105 | */ 106 | public function getMessage($id){ 107 | if($this->messages->exists($id)){ 108 | return $this->messages->get($id); 109 | } 110 | return false; 111 | } 112 | 113 | /** 114 | * @priority HIGHEST 115 | * @ignoreCancelled true 116 | * @param BlockBreakEvent $event 117 | */ 118 | public function onBlockBreak(BlockBreakEvent $event){ 119 | $player = $event->getPlayer(); 120 | $block = $event->getBlock(); 121 | 122 | try { 123 | if ($this->jobs->get($this->player->get($player->getName())) == true or $this->jobs->get($this->player->get($player->getName())) == false){return;} 124 | } catch (\Throwable $th) { 125 | //throw $th; 126 | } 127 | 128 | if ($event->isCancelled()){return;} 129 | $job = $this->jobs->get($this->player->get($player->getName())["JobID"]); 130 | if($job !== false){ 131 | $player_data = $this->player->get($player->getName()); 132 | $job = $this->jobs->get($player_data["JobID"]); 133 | if($player_data["Mode"] == "Goal"){ 134 | if(isset($job["Mode"]["Salary"]) and isset($job["Mission"][$block->getID().":".$block->getDamage().":Break"])){ 135 | $nothing = $job["Mission"][$block->getID().":".$block->getDamage().":Break"]; 136 | $progress = $player_data["Progress"]; 137 | $goal = $player_data["Goal"]; 138 | if ($player->hasPermission("jobui.progress.break") or $player->hasPermission("jobui.*")) { 139 | $progress++; 140 | $this->player->set($player->getName(), ["JobID" => $player_data["JobID"], "Job" => $player_data["Job"], "Mode" => "Goal", "Progress" => $progress, "Goal" => $job["Mode"]["Goal"]]); 141 | 142 | if ($progress >= $goal){ 143 | $salary = $job["Mode"]["Salary"]; 144 | $this->api->addMoney($player, $salary); 145 | $player->sendPopup($this->getMessage("salary-popup-1") . $salary . EconomyAPI::getInstance()->getMonetaryUnit() . $this->getMessage("salary-popup-2")); 146 | $player->sendMessage("§7[§6JobUI§7] " . $this->getMessage("salary-retire-message") . $player_data["Job"]); 147 | $this->player->remove($player->getName()); 148 | $this->player->save(); 149 | }else{ 150 | $player->sendPopup($this->getMessage("progress-popup") . $progress . " / " . $goal); 151 | $this->player->save(); 152 | } 153 | }else{ 154 | $player->sendMessage("§7[§6JobUI§7] " . $this->getMessage("progress-break-noperm-message")); 155 | } 156 | } 157 | }else{ 158 | if(isset($job["Mission"][$block->getID().":".$block->getDamage().":Break"])){ 159 | $money = $job["Mission"][$block->getID().":".$block->getDamage().":Break"]; 160 | if ($player->hasPermission("jobui.earn.break") or $player->hasPermission("jobui.*")) { 161 | if($money > 0){ 162 | $this->api->addMoney($player, $money); 163 | $player->sendPopup($this->getMessage("earn-popup-1") . $money . EconomyAPI::getInstance()->getMonetaryUnit() . $this->getMessage("earn-popup-2")); 164 | }else{ 165 | $this->api->reduceMoney($player, $money); 166 | } 167 | }else{ 168 | $player->sendMessage("§7[§6JobUI§7] " . $this->getMessage("break-noperm-message")); 169 | } 170 | } 171 | } 172 | } 173 | } 174 | 175 | /** 176 | * @priority HIGHEST 177 | * @ignoreCancelled true 178 | * @param BlockPlaceEvent $event 179 | */ 180 | public function onBlockPlace(BlockPlaceEvent $event){ 181 | $player = $event->getPlayer(); 182 | $block = $event->getBlock(); 183 | try { 184 | if ($this->jobs->get($this->player->get($player->getName())) == true or $this->jobs->get($this->player->get($player->getName())) == false){return;} 185 | } catch (\Throwable $th) { 186 | //throw $th; 187 | } 188 | if ($event->isCancelled()){return;} 189 | $job = $this->jobs->get($this->player->get($player->getName())["JobID"]); 190 | if($job !== false){ 191 | $player_data = $this->player->get($player->getName()); 192 | $job = $this->jobs->get($player_data["JobID"]); 193 | if($player_data["Mode"] == "Goal"){ 194 | if(isset($job["Mode"]["Salary"]) and isset($job["Mission"][$block->getID().":".$block->getDamage().":Place"])){ 195 | $nothing = $job["Mission"][$block->getID().":".$block->getDamage().":Place"]; 196 | $progress = $player_data["Progress"]; 197 | $goal = $player_data["Goal"]; 198 | if ($player->hasPermission("jobui.progress.place") or $player->hasPermission("jobui.*")) { 199 | $progress++; 200 | $this->player->set($player->getName(), ["JobID" => $player_data["JobID"], "Job" => $player_data["Job"], "Mode" => "Goal", "Progress" => $progress, "Goal" => $job["Mode"]["Goal"]]); 201 | 202 | if ($progress >= $goal){ 203 | $salary = $job["Mode"]["Salary"]; 204 | $this->api->addMoney($player, $salary); 205 | $player->sendPopup($this->getMessage("salary-popup-1") . $salary . EconomyAPI::getInstance()->getMonetaryUnit() . $this->getMessage("salary-popup-2")); 206 | $player->sendMessage("§7[§6JobUI§7] " . $this->getMessage("salary-retire-message") . $player_data["Job"]); 207 | $this->player->remove($player->getName()); 208 | $this->player->save(); 209 | }else{ 210 | $player->sendPopup($this->getMessage("progress-popup") . $progress . " / " . $goal); 211 | $this->player->save(); 212 | } 213 | }else{ 214 | $player->sendMessage("§7[§6JobUI§7] " . $this->getMessage("progress-place-noperm-message")); 215 | } 216 | } 217 | }else{ 218 | if(isset($job["Mission"][$block->getID().":".$block->getDamage().":Place"])){ 219 | $money = $job["Mission"][$block->getID().":".$block->getDamage().":Place"]; 220 | if ($player->hasPermission("jobui.earn.place") or $player->hasPermission("jobui.*")) { 221 | if($money > 0){ 222 | $this->api->addMoney($player, $money); 223 | $player->sendPopup($this->getMessage("earn-popup-1") . $money . EconomyAPI::getInstance()->getMonetaryUnit() . $this->getMessage("earn-popup-2")); 224 | }else{ 225 | $this->api->reduceMoney($player, $money); 226 | } 227 | }else{ 228 | $player->sendMessage("§7[§6JobUI§7] " . $this->getMessage("place-noperm-message")); 229 | } 230 | } 231 | } 232 | } 233 | } 234 | 235 | /** 236 | * @priority LOWEST 237 | * @ignoreCancelled true 238 | * @param EntityDeathEvent $event 239 | */ 240 | public function onMobDeath(EntityDeathEvent $event){ 241 | $entity = $event->getEntity(); 242 | $cause = $entity->getLastDamageCause(); 243 | if($cause instanceof EntityDamageByEntityEvent){ 244 | $player = $cause->getDamager(); 245 | if($player instanceof Player){ 246 | $job = $this->jobs->get($this->player->get($player->getName())["JobID"]); 247 | if($job !== false){ 248 | $player_data = $this->player->get($player->getName()); 249 | $job = $this->jobs->get($player_data["JobID"]); 250 | if(!$entity instanceof Player){ 251 | if($player_data["Mode"] == "Goal"){ 252 | if(isset($job["Mode"]["Salary"]) and isset($job["Mission"]["Hunter"])){ 253 | $progress = $player_data["Progress"]; 254 | $goal = $player_data["Goal"]; 255 | if ($player->hasPermission("jobui.progress.hunter") or $player->hasPermission("jobui.*")) { 256 | $progress++; 257 | $this->player->set($player->getName(), ["JobID" => $player_data["JobID"], "Job" => $player_data["Job"], "Mode" => "Goal", "Progress" => $progress, "Goal" => $job["Mode"]["Goal"]]); 258 | 259 | if ($progress >= $goal){ 260 | $salary = $job["Mode"]["Salary"]; 261 | $this->api->addMoney($player, $salary); 262 | $player->sendPopup($this->getMessage("salary-popup-1") . $salary . EconomyAPI::getInstance()->getMonetaryUnit() . $this->getMessage("salary-popup-2")); 263 | $player->sendMessage("§7[§6JobUI§7] " . $this->getMessage("salary-retire-message") . $player_data["Job"]); 264 | $this->player->remove($player->getName()); 265 | $this->player->save(); 266 | }else{ 267 | $player->sendPopup($this->getMessage("progress-popup") . $progress . " / " . $goal); 268 | $this->player->save(); 269 | } 270 | }else{ 271 | $player->sendMessage("§7[§6JobUI§7] " . $this->getMessage("progress-hunter-noperm-message")); 272 | } 273 | } 274 | }else{ 275 | if(isset($job["Mission"]["Hunter"])){ 276 | $money = $job["Mission"]["Hunter"]; 277 | if ($player->hasPermission("jobui.earn.hunter") or $player->hasPermission("jobui.*")) { 278 | if($money > 0){ 279 | $this->api->addMoney($player, $money); 280 | $player->sendPopup($this->getMessage("earn-popup-1") . $money . EconomyAPI::getInstance()->getMonetaryUnit() . $this->getMessage("earn-popup-2")); 281 | }else{ 282 | $this->api->reduceMoney($player, $money); 283 | } 284 | }else{ 285 | $player->sendMessage("§7[§6JobUI§7] " . $this->getMessage("hunter-noperm-message")); 286 | } 287 | } 288 | } 289 | } 290 | } 291 | } 292 | } 293 | } 294 | 295 | /** 296 | * @priority LOWEST 297 | * @ignoreCancelled true 298 | * @param PlayerDeathEvent $event 299 | */ 300 | public function onPlayerDeath(PlayerDeathEvent $event){ 301 | $entity = $event->getEntity(); 302 | $cause = $entity->getLastDamageCause(); 303 | if($cause instanceof EntityDamageByEntityEvent){ 304 | $player = $cause->getDamager(); 305 | if($player instanceof Player){ 306 | $job = $this->jobs->get($this->player->get($player->getName())["JobID"]); 307 | if($job !== false){ 308 | $player_data = $this->player->get($player->getName()); 309 | $job = $this->jobs->get($player_data["JobID"]); 310 | if($entity instanceof Player){ 311 | if($player_data["Mode"] == "Goal"){ 312 | if(isset($job["Mode"]["Salary"]) and isset($job["Mission"]["Murderer"])){ 313 | $progress = $player_data["Progress"]; 314 | $goal = $player_data["Goal"]; 315 | if ($player->hasPermission("jobui.progress.murderer") or $player->hasPermission("jobui.*")) { 316 | $progress++; 317 | $this->player->set($player->getName(), ["JobID" => $player_data["JobID"], "Job" => $player_data["Job"], "Mode" => "Goal", "Progress" => $progress, "Goal" => $job["Mode"]["Goal"]]); 318 | 319 | if ($progress >= $goal){ 320 | $salary = $job["Mode"]["Salary"]; 321 | $this->api->addMoney($player, $salary); 322 | $player->sendPopup($this->getMessage("salary-popup-1") . $salary . EconomyAPI::getInstance()->getMonetaryUnit() . $this->getMessage("salary-popup-2")); 323 | $player->sendMessage("§7[§6JobUI§7] " . $this->getMessage("salary-retire-message") . $player_data["Job"]); 324 | $this->player->remove($player->getName()); 325 | $this->player->save(); 326 | }else{ 327 | $player->sendPopup($this->getMessage("progress-popup") . $progress . " / " . $goal); 328 | $this->player->save(); 329 | } 330 | }else{ 331 | $player->sendMessage("§7[§6JobUI§7] " . $this->getMessage("progress-murderer-noperm-message")); 332 | } 333 | } 334 | }else{ 335 | if(isset($job["Mission"]["Murderer"])){ 336 | $money = $job["Mission"]["Murderer"]; 337 | if ($player->hasPermission("jobui.earn.murderer") or $player->hasPermission("jobui.*")) { 338 | if($money > 0){ 339 | $this->api->addMoney($player, $money); 340 | $player->sendPopup($this->getMessage("earn-popup-1") . $money . EconomyAPI::getInstance()->getMonetaryUnit() . $this->getMessage("earn-popup-2")); 341 | }else{ 342 | $this->api->reduceMoney($player, $money); 343 | } 344 | }else{ 345 | $player->sendMessage("§7[§6JobUI§7] " . $this->getMessage("murderer-noperm-message")); 346 | } 347 | } 348 | } 349 | } 350 | } 351 | } 352 | } 353 | } 354 | 355 | /** 356 | * @return Main 357 | */ 358 | public static function getInstance(){ 359 | return static::$instance; 360 | } 361 | 362 | public function onCommand(CommandSender $sender, Command $command, $label, array $params) : bool{ 363 | if($command->getName() === "job"){ 364 | if(!$sender instanceof Player){ 365 | $sender->sendMessage("Please run this command in-game."); 366 | }else{ 367 | if ($sender->hasPermission("jobui.command.job") or $sender->hasPermission("jobui.*")) { 368 | $this->FormJob($sender); 369 | }else{ 370 | $sender->sendMessage("§7[§6JobUI§7] " . "§cYou can't join a job in this world"); 371 | } 372 | } 373 | } 374 | if($command->getName() === "retire"){ 375 | if(!$sender instanceof Player){ 376 | $sender->sendMessage("Please run this command in-game."); 377 | }else{ 378 | if ($sender->hasPermission("jobui.command.retire") or $sender->hasPermission("jobui.*")){ 379 | if($this->player->exists($sender->getName())){ 380 | $job = $this->player->get($sender->getName())["Job"]; 381 | $sender->sendMessage("§7[§6JobUI§7] " . $this->getMessage("retire-message") . $job); 382 | $this->player->remove($sender->getName()); 383 | $this->player->save(); 384 | }else{ 385 | $sender->sendMessage("§7[§6JobUI§7] " . $this->getMessage("nojob-retire-message")); 386 | } 387 | }else{ 388 | $sender->sendMessage("§7[§6JobUI§7] " . "§cYou can't get retired in this world"); 389 | } 390 | } 391 | } 392 | return true; 393 | } 394 | 395 | public function FormJob($player){ 396 | $form = new SimpleForm(function (Player $player, int $data = null){ 397 | if($data === null){ 398 | return true; 399 | }else{ 400 | switch($data){ 401 | case "0": 402 | $this->FormJobsList($player); 403 | break; 404 | 405 | case "1": 406 | $this->FormMyJobInfo($player); 407 | break; 408 | 409 | case "2": 410 | if($this->player->exists($player->getName())){ 411 | if($this->player->get($player->getName())["Mode"] == "Goal"){ 412 | $progress = $this->player->get($player->getName())["Progress"]; 413 | $goal = $this->player->get($player->getName())["Goal"]; 414 | $player->sendMessage("§7[§6JobUI§7] " . $this->getMessage("myjob-message") . $this->player->get($player->getName())["Job"]); 415 | $player->sendMessage("§7[§6JobUI§7] " . $this->getMessage("progress-myjob-message") . $progress . " / " . $goal); 416 | }else{ 417 | $player->sendMessage("§7[§6JobUI§7] " . $this->getMessage("myjob-message") . $this->player->get($player->getName())["Job"]); 418 | } 419 | }else{ 420 | $player->sendMessage("§7[§6JobUI§7] " . $this->getMessage("nojob-message")); 421 | } 422 | 423 | break; 424 | 425 | case "3": 426 | if($this->player->exists($player->getName())){ 427 | $job = $this->player->get($player->getName())["Job"]; 428 | $player->sendMessage("§7[§6JobUI§7] " . $this->getMessage("retire-message") . $job); 429 | $this->player->remove($player->getName()); 430 | $this->player->save(); 431 | }else{ 432 | $player->sendMessage("§7[§6JobUI§7] " . $this->getMessage("nojob-retire-message")); 433 | } 434 | break; 435 | } 436 | } 437 | }); 438 | 439 | $form->setTitle($this->getMessage("title-mainui")); 440 | if($this->player->exists($player->getName())){ 441 | if($this->player->get($player->getName())["Mode"] == "Goal"){ 442 | $progress = $this->player->get($player->getName())["Progress"]; 443 | $goal = $this->player->get($player->getName())["Goal"]; 444 | $form->setContent($this->getMessage("myjob-text-mainui") . $this->player->get($player->getName())["Job"] . "\n" . $this->getMessage("progress-myjob-text-mainui") . $progress . " / " . $goal); 445 | }else{ 446 | $form->setContent($this->getMessage("myjob-text-mainui") . $this->player->get($player->getName())["Job"]); 447 | } 448 | }else{ 449 | $form->setContent($this->getMessage("nojob-text-mainui")); 450 | } 451 | $form->addButton($this->getMessage("jobjoin-button-mainui")); 452 | $form->addButton($this->getMessage("myjobinfo-button-mainui")); 453 | $form->addButton($this->getMessage("myjob-button-mainui")); 454 | $form->addButton($this->getMessage("retire-button-mainui")); 455 | 456 | $player->sendForm($form); 457 | return $form; 458 | } 459 | 460 | public function FormJobsList($player){ 461 | $form = new SimpleForm(function (Player $player, int $data = null){ 462 | if($data === null){ 463 | return true; 464 | }else{ 465 | $i = 0; 466 | foreach($this->jobs->getAll() as $name => $job){ 467 | switch($data){ 468 | case "$i": 469 | if ($player->hasPermission($job["Permission"]) or $player->hasPermission("jobui.job.*") or $player->hasPermission("jobui.*")){ 470 | $this->FormJobJoin($player, $job, $name); 471 | }else{ 472 | $player->sendMessage("§7[§6JobUI§7] " . $this->getMessage("jobjoin-noperm-message") . $name); 473 | } 474 | break; 475 | } 476 | $i++; 477 | } 478 | switch($data){ 479 | case "$i": 480 | $this->FormJob($player); 481 | break; 482 | } 483 | } 484 | }); 485 | 486 | $form->setTitle($this->getMessage("title-jobslistui")); 487 | $form->setContent($this->getMessage("text-jobslistui")); 488 | foreach($this->jobs->getAll() as $job){ 489 | $form->addButton($job["Button-Name"], $job["Image-Type"], $job["Image"]); 490 | } 491 | $form->addButton($this->getMessage("return-to-mainui-button-jobslistui")); 492 | 493 | $player->sendForm($form); 494 | return $form; 495 | } 496 | 497 | public function FormJobJoin($player, $job, $jobid){ 498 | $form = new SimpleForm(function (Player $player, $data = null) use($job, $jobid){ // Thanks to https://github.com/h3xmor/ to help me for use($job, $jobid) 499 | if($data === null){ 500 | return true; 501 | }else{ 502 | switch($data){ 503 | case "0": 504 | if ($job["Mode"]["Name"] == "Goal"){ 505 | $this->player->set($player->getName(), ["JobID" => $jobid, "Job" => $job["Name"], "Mode" => "Goal", "Progress" => 0, "Goal" => $job["Mode"]["Goal"]]); 506 | $this->player->save(); 507 | }else{ 508 | $this->player->set($player->getName(), ["JobID" => $jobid, "Job" => $job["Name"], "Mode" => "Simple"]); 509 | $this->player->save(); 510 | } 511 | $player_job = $this->player->get($player->getName())["Job"]; 512 | $player->sendMessage("§7[§6JobUI§7] " . $this->getMessage("jobjoin-message") . $player_job); 513 | break; 514 | 515 | case "1": 516 | $this->FormJobsList($player); 517 | break; 518 | } 519 | } 520 | }); 521 | 522 | $form->setTitle($this->getMessage("title-jobjoinui")); 523 | $form->setContent($job["Info"]); 524 | $form->addButton($this->getMessage("join-button-jobjoinui") . $job["Name"]); 525 | $form->addButton($this->getMessage("return-to-jobslistui-button-jobjoinui")); 526 | 527 | $player->sendForm($form); 528 | return $form; 529 | } 530 | 531 | public function FormMyJobInfo($player){ 532 | $form = new SimpleForm(function (Player $player, $data = null){ 533 | if($data === null){ 534 | return true; 535 | }else{ 536 | switch($data){ 537 | case "0": 538 | break; 539 | case "1": 540 | $this->FormJob($player); 541 | break; 542 | } 543 | } 544 | }); 545 | 546 | $form->setTitle($this->getMessage("title-myjobinfoui")); 547 | if($this->player->exists($player->getName())){ 548 | $job = $this->jobs->get($this->player->get($player->getName())["JobID"]); 549 | $form->setContent($job["Info"]); 550 | }else{ 551 | $form->setContent($this->getMessage("nojob-text-myjobinfoui")); 552 | } 553 | $form->addButton($this->getMessage("exit-button-myjobinfoui")); 554 | $form->addButton($this->getMessage("return-to-mainui-button-myjobinfoui")); 555 | 556 | $player->sendForm($form); 557 | return $form; 558 | } 559 | } 560 | --------------------------------------------------------------------------------