├── .editorconfig ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug-report.md │ └── feature-request.md └── issue-branch.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── LICENSE.txt ├── README.md ├── pom.xml └── src └── main ├── java └── com │ └── alpsbte │ └── plotsystem │ ├── PlotSystem.java │ ├── commands │ ├── BaseCommand.java │ ├── CMD_CancelChat.java │ ├── CMD_Companion.java │ ├── CMD_Plots.java │ ├── CMD_Tpll.java │ ├── CMD_Tutorial.java │ ├── CommandManager.java │ ├── ICommand.java │ ├── SubCommand.java │ ├── admin │ │ ├── CMD_DeletePlot.java │ │ ├── CMD_PReload.java │ │ ├── CMD_SetLeaderboard.java │ │ └── setup │ │ │ ├── CMD_Setup.java │ │ │ ├── CMD_Setup_BuildTeam.java │ │ │ ├── CMD_Setup_City.java │ │ │ ├── CMD_Setup_Country.java │ │ │ ├── CMD_Setup_Difficulty.java │ │ │ ├── CMD_Setup_FTP.java │ │ │ └── CMD_Setup_Server.java │ ├── plot │ │ ├── CMD_Plot.java │ │ ├── CMD_Plot_Abandon.java │ │ ├── CMD_Plot_Feedback.java │ │ ├── CMD_Plot_Invite.java │ │ ├── CMD_Plot_Links.java │ │ ├── CMD_Plot_Members.java │ │ ├── CMD_Plot_Submit.java │ │ ├── CMD_Plot_Teleport.java │ │ └── CMD_Plot_UndoSubmit.java │ └── review │ │ ├── CMD_EditFeedback.java │ │ ├── CMD_EditPlot.java │ │ ├── CMD_Review.java │ │ └── CMD_UndoReview.java │ ├── core │ ├── EventListener.java │ ├── database │ │ └── DatabaseConnection.java │ ├── holograms │ │ ├── HologramConfiguration.java │ │ ├── HologramRegister.java │ │ ├── PlotTutorialHologram.java │ │ ├── PlotsLeaderboard.java │ │ └── ScoreLeaderboard.java │ ├── menus │ │ ├── AbstractMenu.java │ │ ├── AbstractPaginatedMenu.java │ │ ├── BuilderUtilitiesMenu.java │ │ ├── FeedbackMenu.java │ │ ├── PlayerPlotsMenu.java │ │ ├── PlotActionsMenu.java │ │ ├── PlotMemberMenu.java │ │ ├── PlotTypeMenu.java │ │ ├── ReviewMenu.java │ │ ├── ReviewPlotMenu.java │ │ ├── SettingsMenu.java │ │ ├── SpecialToolsMenu.java │ │ ├── companion │ │ │ ├── CityProjectMenu.java │ │ │ ├── CompanionMenu.java │ │ │ ├── ContinentMenu.java │ │ │ └── CountryMenu.java │ │ └── tutorial │ │ │ ├── TutorialStagesMenu.java │ │ │ └── TutorialsMenu.java │ └── system │ │ ├── BuildTeam.java │ │ ├── Builder.java │ │ ├── CityProject.java │ │ ├── Country.java │ │ ├── Difficulty.java │ │ ├── FTPConfiguration.java │ │ ├── Payout.java │ │ ├── Review.java │ │ ├── Server.java │ │ ├── plot │ │ ├── AbstractPlot.java │ │ ├── Plot.java │ │ ├── TutorialPlot.java │ │ ├── generator │ │ │ ├── AbstractPlotGenerator.java │ │ │ ├── DefaultPlotGenerator.java │ │ │ ├── PlotWorldGenerator.java │ │ │ └── TutorialPlotGenerator.java │ │ ├── utils │ │ │ ├── PlotPermissions.java │ │ │ ├── PlotType.java │ │ │ └── PlotUtils.java │ │ └── world │ │ │ ├── CityPlotWorld.java │ │ │ ├── IWorld.java │ │ │ ├── OnePlotWorld.java │ │ │ └── PlotWorld.java │ │ └── tutorial │ │ ├── AbstractPlotTutorial.java │ │ ├── AbstractTutorial.java │ │ ├── AbstractTutorialHologram.java │ │ ├── BeginnerTutorial.java │ │ ├── PlotTutorial.java │ │ ├── Tutorial.java │ │ ├── TutorialCategory.java │ │ ├── TutorialDataModel.java │ │ ├── TutorialEventListener.java │ │ ├── stage │ │ ├── AbstractPlotStage.java │ │ ├── AbstractStage.java │ │ ├── StageTimeline.java │ │ ├── TutorialTimeline.java │ │ ├── TutorialWorld.java │ │ └── tasks │ │ │ ├── AbstractTask.java │ │ │ ├── DelayTask.java │ │ │ ├── PlotPermissionChangeTask.java │ │ │ ├── PlotSchematicPasteTask.java │ │ │ ├── TeleportTask.java │ │ │ ├── events │ │ │ ├── BuildEventTask.java │ │ │ ├── ChatEventTask.java │ │ │ ├── EventTask.java │ │ │ ├── NpcInteractEventTask.java │ │ │ ├── TeleportPointEventTask.java │ │ │ └── commands │ │ │ │ ├── AbstractCmdEventTask.java │ │ │ │ ├── ContinueCmdEventTask.java │ │ │ │ ├── LineCmdEventTask.java │ │ │ │ └── WandCmdEventTask.java │ │ │ └── message │ │ │ ├── ChatMessageTask.java │ │ │ ├── CreateHologramTask.java │ │ │ └── DeleteHologramTask.java │ │ └── utils │ │ ├── TutorialNPC.java │ │ ├── TutorialNPCHologram.java │ │ ├── TutorialNPCTurnTracker.java │ │ └── TutorialUtils.java │ └── utils │ ├── PacketListener.java │ ├── PlotMemberInvitation.java │ ├── ShortLink.java │ ├── Utils.java │ ├── chat │ ├── ChatInput.java │ ├── PlayerFeedbackChatInput.java │ └── PlayerInviteeChatInput.java │ ├── conversion │ ├── CoordinateConversion.java │ ├── MathUtils.java │ └── projection │ │ ├── GeographicProjection.java │ │ ├── InvertableVectorField.java │ │ ├── OffsetProjectionTransform.java │ │ ├── OutOfProjectionBoundsException.java │ │ ├── ProjectionTransform.java │ │ ├── ScaleProjectionTransform.java │ │ ├── UprightOrientationProjectionTransform.java │ │ └── airocean │ │ ├── Airocean.java │ │ ├── ConformalEstimate.java │ │ └── ModifiedAirocean.java │ ├── enums │ ├── Category.java │ ├── Continent.java │ ├── PlotDifficulty.java │ ├── Slot.java │ └── Status.java │ ├── io │ ├── ConfigPaths.java │ ├── ConfigUtil.java │ ├── FTPManager.java │ ├── LangPaths.java │ ├── LangUtil.java │ └── TutorialPaths.java │ └── items │ ├── BaseItems.java │ ├── CustomHeads.java │ └── MenuItems.java └── resources ├── commands.yml ├── config.yml ├── conformal.txt ├── items.yml ├── lang ├── de_DE.yml ├── en_GB.yml ├── fr_FR.yml ├── ko_KR.yml ├── pt_PT.yml ├── ru_RU.yml ├── zh_CN.yml └── zh_TW.yml ├── plugin.yml └── tutorial ├── schematics ├── 0-0.schematic.gz ├── 0-1.schematic.gz ├── 0-2.schematic.gz ├── 0-3.schematic.gz ├── 0-4.schematic.gz ├── 0-5.schematic.gz ├── 0-6.schematic.gz ├── 0-7.schematic.gz └── 0-env.schematic.gz ├── tutorial_beginner.yml └── tutorial_template.yml /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: AlpsBTE 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: [ 'https://www.tipeeestream.com/alps-bte/donation' ] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a report to help us improve 4 | title: "[Bug] - " 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Description 11 | 12 | ## Steps to Reproduce 13 | 1. 14 | 2. 15 | 3. 16 | 17 | ## Possible Solution 18 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Suggest an idea for this project 4 | title: "[Feature] - " 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/issue-branch.yml: -------------------------------------------------------------------------------- 1 | mode: chatops 2 | silent: false 3 | branchName: '${issue.number}-${issue.title,}' 4 | gitSafeReplacementChar: '-' 5 | autoCloseIssue: true 6 | openDraftPR: true 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | *.xml 22 | *.iml 23 | 24 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 25 | hs_err_pid* 26 | 27 | # Maven 28 | .classpath 29 | .project 30 | .settings/ 31 | target/ 32 | 33 | # .idea 34 | .idea/ -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Alps BTE 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/commands/CMD_CancelChat.java: -------------------------------------------------------------------------------- 1 | package com.alpsbte.plotsystem.commands; 2 | 3 | import com.alpsbte.plotsystem.utils.Utils; 4 | import com.alpsbte.plotsystem.utils.chat.ChatInput; 5 | import com.alpsbte.plotsystem.utils.io.LangPaths; 6 | import com.alpsbte.plotsystem.utils.io.LangUtil; 7 | import org.bukkit.command.Command; 8 | import org.bukkit.command.CommandSender; 9 | import org.bukkit.entity.Player; 10 | import org.jetbrains.annotations.NotNull; 11 | 12 | public class CMD_CancelChat extends BaseCommand { 13 | @Override 14 | public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String s, String[] args) { 15 | if (!sender.hasPermission(getPermission())) { 16 | sender.sendMessage(Utils.ChatUtils.getAlertFormat(LangUtil.getInstance().get(sender, LangPaths.Message.Error.PLAYER_HAS_NO_PERMISSIONS))); 17 | return true; 18 | } 19 | 20 | if (getPlayer(sender) == null) return true; 21 | 22 | Player player = getPlayer(sender); 23 | if (!ChatInput.awaitChatInput.containsKey(player.getUniqueId())) return true; 24 | ChatInput.awaitChatInput.remove(player.getUniqueId()); 25 | player.sendMessage(Utils.ChatUtils.getInfoFormat(LangUtil.getInstance().get(player, LangPaths.Message.Error.CHAT_INPUT_EXPIRED))); 26 | player.playSound(player.getLocation(), Utils.SoundUtils.DONE_SOUND, 1f, 1f); 27 | return true; 28 | } 29 | 30 | @Override 31 | public String[] getNames() { 32 | return new String[]{"cancelchat"}; 33 | } 34 | 35 | @Override 36 | public String getDescription() { 37 | return "Cancels the chat input."; 38 | } 39 | 40 | @Override 41 | public String[] getParameter() { 42 | return new String[0]; 43 | } 44 | 45 | @Override 46 | public String getPermission() { 47 | return "plotsystem.chatcancel"; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/commands/CMD_Companion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.commands; 26 | 27 | import com.alpsbte.plotsystem.PlotSystem; 28 | import com.alpsbte.plotsystem.core.menus.companion.CompanionMenu; 29 | import com.alpsbte.plotsystem.core.menus.tutorial.TutorialStagesMenu; 30 | import com.alpsbte.plotsystem.core.menus.tutorial.TutorialsMenu; 31 | import com.alpsbte.plotsystem.core.system.plot.TutorialPlot; 32 | import com.alpsbte.plotsystem.core.system.tutorial.AbstractTutorial; 33 | import com.alpsbte.plotsystem.core.system.tutorial.Tutorial; 34 | import com.alpsbte.plotsystem.core.system.tutorial.TutorialCategory; 35 | import com.alpsbte.plotsystem.utils.Utils; 36 | import com.alpsbte.plotsystem.utils.io.ConfigPaths; 37 | import com.alpsbte.plotsystem.utils.io.LangPaths; 38 | import com.alpsbte.plotsystem.utils.io.LangUtil; 39 | import org.bukkit.command.Command; 40 | import org.bukkit.command.CommandSender; 41 | import org.bukkit.configuration.file.FileConfiguration; 42 | import org.bukkit.entity.Player; 43 | import org.jetbrains.annotations.NotNull; 44 | 45 | import java.sql.SQLException; 46 | 47 | import static net.kyori.adventure.text.Component.text; 48 | 49 | public class CMD_Companion extends BaseCommand { 50 | @Override 51 | public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String s, String[] args) { 52 | if (!sender.hasPermission(getPermission())) { 53 | sender.sendMessage(Utils.ChatUtils.getAlertFormat(LangUtil.getInstance().get(sender, LangPaths.Message.Error.PLAYER_HAS_NO_PERMISSIONS))); 54 | return true; 55 | } 56 | 57 | if (getPlayer(sender) == null) return true; 58 | 59 | try { 60 | FileConfiguration config = PlotSystem.getPlugin().getConfig(); 61 | Tutorial tutorial = AbstractTutorial.getActiveTutorial(getPlayer(sender).getUniqueId()); 62 | if (tutorial != null) { 63 | new TutorialStagesMenu(getPlayer(sender), tutorial.getId()); 64 | } else if (config.getBoolean(ConfigPaths.TUTORIAL_ENABLE) && config.getBoolean(ConfigPaths.TUTORIAL_REQUIRE_BEGINNER_TUTORIAL) && 65 | !TutorialPlot.isPlotCompleted(getPlayer(sender), TutorialCategory.BEGINNER.getId()) && getPlayer(sender).hasPermission("plotsystem.tutorial")) { 66 | new TutorialsMenu(getPlayer(sender)); 67 | } else CompanionMenu.open((Player) sender); 68 | } catch (SQLException ex) { 69 | PlotSystem.getPlugin().getComponentLogger().error(text("A SQL error occurred!"), ex); 70 | } 71 | 72 | return true; 73 | } 74 | 75 | @Override 76 | public String[] getNames() { 77 | return new String[]{"companion"}; 78 | } 79 | 80 | @Override 81 | public String getDescription() { 82 | return "Open the Companion menu (Displays all city projects and your ongoing projects)."; 83 | } 84 | 85 | @Override 86 | public String[] getParameter() { 87 | return new String[0]; 88 | } 89 | 90 | @Override 91 | public String getPermission() { 92 | return "plotsystem.companion"; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/commands/CMD_Plots.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.commands; 26 | 27 | import com.alpsbte.plotsystem.PlotSystem; 28 | import com.alpsbte.plotsystem.core.menus.PlayerPlotsMenu; 29 | import com.alpsbte.plotsystem.core.system.Builder; 30 | import com.alpsbte.plotsystem.utils.Utils; 31 | import com.alpsbte.plotsystem.utils.io.LangPaths; 32 | import com.alpsbte.plotsystem.utils.io.LangUtil; 33 | import net.kyori.adventure.text.format.NamedTextColor; 34 | import org.bukkit.Bukkit; 35 | import org.bukkit.command.Command; 36 | import org.bukkit.command.CommandSender; 37 | import org.bukkit.entity.Player; 38 | import org.jetbrains.annotations.NotNull; 39 | 40 | import java.sql.SQLException; 41 | 42 | import static net.kyori.adventure.text.Component.text; 43 | 44 | public class CMD_Plots extends BaseCommand { 45 | @Override 46 | public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String s, String[] args) { 47 | if (!sender.hasPermission(getPermission())) { 48 | sender.sendMessage(Utils.ChatUtils.getAlertFormat(LangUtil.getInstance().get(sender, LangPaths.Message.Error.PLAYER_HAS_NO_PERMISSIONS))); 49 | return true; 50 | } 51 | 52 | if (getPlayer(sender) == null) { 53 | Bukkit.getConsoleSender().sendMessage(text("This command can only be used as a player!", NamedTextColor.RED)); 54 | return true; 55 | } 56 | 57 | Player player = (Player) sender; 58 | 59 | try { 60 | if (args.length < 1) { 61 | new PlayerPlotsMenu(player, Builder.byUUID(player.getUniqueId())); 62 | return true; 63 | } 64 | 65 | Builder builder = Builder.getBuilderByName(args[0]); 66 | if (builder == null) { 67 | player.sendMessage(Utils.ChatUtils.getAlertFormat(LangUtil.getInstance().get(sender, LangPaths.Message.Error.PLAYER_NOT_FOUND))); 68 | return true; 69 | } 70 | 71 | new PlayerPlotsMenu(player, builder); 72 | } catch (SQLException ex) { 73 | sender.sendMessage(Utils.ChatUtils.getAlertFormat(LangUtil.getInstance().get(sender, LangPaths.Message.Error.ERROR_OCCURRED))); 74 | PlotSystem.getPlugin().getComponentLogger().error(text("A SQL error occurred!"), ex); 75 | } 76 | return true; 77 | } 78 | 79 | @Override 80 | public String[] getNames() { 81 | return new String[]{"plots"}; 82 | } 83 | 84 | @Override 85 | public String getDescription() { 86 | return "Shows all plots of the given player."; 87 | } 88 | 89 | @Override 90 | public String[] getParameter() { 91 | return new String[]{"Player"}; 92 | } 93 | 94 | @Override 95 | public String getPermission() { 96 | return "plotsystem.plots"; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/commands/CMD_Tutorial.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | 26 | package com.alpsbte.plotsystem.commands; 27 | 28 | import com.alpsbte.alpslib.utils.AlpsUtils; 29 | import com.alpsbte.plotsystem.PlotSystem; 30 | import com.alpsbte.plotsystem.core.menus.tutorial.TutorialStagesMenu; 31 | import com.alpsbte.plotsystem.core.menus.tutorial.TutorialsMenu; 32 | import com.alpsbte.plotsystem.core.system.tutorial.AbstractTutorial; 33 | import com.alpsbte.plotsystem.core.system.tutorial.Tutorial; 34 | import com.alpsbte.plotsystem.core.system.tutorial.TutorialCategory; 35 | import com.alpsbte.plotsystem.utils.Utils; 36 | import com.alpsbte.plotsystem.utils.io.ConfigPaths; 37 | import com.alpsbte.plotsystem.utils.io.LangPaths; 38 | import com.alpsbte.plotsystem.utils.io.LangUtil; 39 | import net.kyori.adventure.text.Component; 40 | import net.kyori.adventure.text.format.NamedTextColor; 41 | import org.bukkit.Bukkit; 42 | import org.bukkit.command.Command; 43 | import org.bukkit.command.CommandSender; 44 | import org.jetbrains.annotations.NotNull; 45 | 46 | public class CMD_Tutorial extends BaseCommand { 47 | 48 | @Override 49 | public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String s, String[] args) { 50 | if (sender.hasPermission(getPermission())) { 51 | if (getPlayer(sender) != null) { 52 | if (PlotSystem.getPlugin().getConfig().getBoolean(ConfigPaths.TUTORIAL_ENABLE)) { 53 | if (args.length == 0) { 54 | Tutorial tutorial = AbstractTutorial.getActiveTutorial(getPlayer(sender).getUniqueId()); 55 | if (tutorial != null) { 56 | new TutorialStagesMenu(tutorial.getPlayer(), tutorial.getId()); 57 | } else { 58 | new TutorialsMenu(getPlayer(sender)); 59 | } 60 | } else if (args.length == 1 && AlpsUtils.tryParseInt(args[0]) != null) { 61 | int tutorialId = Integer.parseInt(args[0]); 62 | if (TutorialCategory.byId(tutorialId) == null) return true; 63 | AbstractTutorial.loadTutorial(getPlayer(sender), tutorialId); 64 | } 65 | } else { 66 | sender.sendMessage(Utils.ChatUtils.getAlertFormat(LangUtil.getInstance().get(sender, LangPaths.Message.Error.TUTORIAL_DISABLED))); 67 | } 68 | } else { 69 | Bukkit.getConsoleSender().sendMessage(Component.text("This command can only be used as a player!", NamedTextColor.RED)); 70 | } 71 | } else { 72 | sender.sendMessage(Utils.ChatUtils.getAlertFormat(LangUtil.getInstance().get(sender, LangPaths.Message.Error.PLAYER_HAS_NO_PERMISSIONS))); 73 | } 74 | return true; 75 | } 76 | 77 | @Override 78 | public String[] getNames() { 79 | return new String[]{"tutorial"}; 80 | } 81 | 82 | @Override 83 | public String getDescription() { 84 | return "Start and manage your tutorials."; 85 | } 86 | 87 | @Override 88 | public String[] getParameter() { 89 | return new String[0]; 90 | } 91 | 92 | @Override 93 | public String getPermission() { 94 | return "plotsystem.tutorial"; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/commands/CommandManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.commands; 26 | 27 | import com.alpsbte.plotsystem.PlotSystem; 28 | import com.alpsbte.plotsystem.commands.admin.CMD_DeletePlot; 29 | import com.alpsbte.plotsystem.commands.admin.CMD_PReload; 30 | import com.alpsbte.plotsystem.commands.admin.CMD_SetLeaderboard; 31 | import com.alpsbte.plotsystem.commands.admin.setup.CMD_Setup; 32 | import com.alpsbte.plotsystem.commands.plot.CMD_Plot; 33 | import com.alpsbte.plotsystem.commands.review.CMD_EditPlot; 34 | import com.alpsbte.plotsystem.commands.review.CMD_Review; 35 | import com.alpsbte.plotsystem.commands.review.CMD_EditFeedback; 36 | import com.alpsbte.plotsystem.commands.review.CMD_UndoReview; 37 | 38 | import java.util.ArrayList; 39 | import java.util.List; 40 | import java.util.Objects; 41 | 42 | public class CommandManager { 43 | 44 | public final List baseCommands = new ArrayList() {{ 45 | // Default Commands 46 | add(new CMD_CancelChat()); 47 | add(new CMD_Companion()); 48 | add(new CMD_Plots()); 49 | add(new CMD_Tpll()); 50 | 51 | // Plot Commands 52 | add(new CMD_Plot()); 53 | 54 | // Review Commands 55 | add(new CMD_Review()); 56 | add(new CMD_UndoReview()); 57 | add(new CMD_EditFeedback()); 58 | add(new CMD_EditPlot()); 59 | 60 | // Admin Commands 61 | add(new CMD_DeletePlot()); 62 | add(new CMD_SetLeaderboard()); 63 | add(new CMD_PReload()); 64 | 65 | // Admin Setup Commands 66 | add(new CMD_Setup()); 67 | add(new CMD_Tutorial()); 68 | }}; 69 | 70 | public void init() { 71 | for (BaseCommand baseCmd : baseCommands) { 72 | for (String baseName : baseCmd.getNames()) { 73 | Objects.requireNonNull(PlotSystem.getPlugin().getCommand(baseName)).setExecutor(baseCmd); 74 | } 75 | } 76 | } 77 | 78 | public List getBaseCommands() { 79 | return baseCommands; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/commands/ICommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2021, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.commands; 26 | 27 | import org.bukkit.command.CommandSender; 28 | 29 | public interface ICommand { 30 | /** 31 | * @return Command Name(s) 32 | */ 33 | String[] getNames(); 34 | 35 | /** 36 | * @return Command Description 37 | */ 38 | String getDescription(); 39 | 40 | /** 41 | * @return Command Parameter(s) 42 | */ 43 | String[] getParameter(); 44 | 45 | /** 46 | * @return Command Permission 47 | */ 48 | String getPermission(); 49 | 50 | /** 51 | * Lists all relevant commands to the player 52 | * 53 | * @param sender player or console 54 | */ 55 | void sendInfo(CommandSender sender); 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/commands/admin/CMD_DeletePlot.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.commands.admin; 26 | 27 | import com.alpsbte.alpslib.utils.AlpsUtils; 28 | import com.alpsbte.plotsystem.commands.BaseCommand; 29 | import com.alpsbte.plotsystem.core.system.plot.Plot; 30 | import com.alpsbte.plotsystem.core.system.plot.utils.PlotUtils; 31 | import com.alpsbte.plotsystem.utils.Utils; 32 | import org.bukkit.command.Command; 33 | import org.bukkit.command.CommandSender; 34 | import org.jetbrains.annotations.NotNull; 35 | 36 | public class CMD_DeletePlot extends BaseCommand { 37 | @Override 38 | public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String s, String[] args) { 39 | if (!sender.hasPermission(getPermission())) { 40 | sender.sendMessage(Utils.ChatUtils.getAlertFormat("You don't have permission to use this command!")); 41 | return true; 42 | } 43 | 44 | if (!(args.length > 0 && AlpsUtils.tryParseInt(args[0]) != null)) { 45 | sendInfo(sender); 46 | return true; 47 | } 48 | 49 | int plotID = Integer.parseInt(args[0]); 50 | if (!PlotUtils.plotExists(plotID)) { 51 | sender.sendMessage(Utils.ChatUtils.getAlertFormat("Could not find plot with ID #" + plotID + "!")); 52 | return true; 53 | } 54 | 55 | sender.sendMessage(Utils.ChatUtils.getInfoFormat("Deleting plot...")); 56 | if (PlotUtils.Actions.deletePlot(new Plot(plotID))) { 57 | sender.sendMessage(Utils.ChatUtils.getInfoFormat("Successfully deleted plot with the ID §6#" + plotID + "§a!")); 58 | if (getPlayer(sender) != null) getPlayer(sender).playSound(getPlayer(sender).getLocation(), Utils.SoundUtils.DONE_SOUND, 1f, 1f); 59 | } else sender.sendMessage(Utils.ChatUtils.getAlertFormat("An unexpected error has occurred!")); 60 | return true; 61 | } 62 | 63 | @Override 64 | public String[] getNames() { 65 | return new String[]{"deleteplot"}; 66 | } 67 | 68 | @Override 69 | public String getDescription() { 70 | return "Delete a plot from the system."; 71 | } 72 | 73 | @Override 74 | public String[] getParameter() { 75 | return new String[]{"ID"}; 76 | } 77 | 78 | @Override 79 | public String getPermission() { 80 | return "plotsystem.admin.deleteplot"; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/commands/admin/CMD_PReload.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.commands.admin; 26 | 27 | import com.alpsbte.alpslib.hologram.DecentHologramDisplay; 28 | import com.alpsbte.plotsystem.PlotSystem; 29 | import com.alpsbte.plotsystem.commands.BaseCommand; 30 | import com.alpsbte.plotsystem.core.database.DatabaseConnection; 31 | import com.alpsbte.plotsystem.core.holograms.HologramConfiguration; 32 | import com.alpsbte.plotsystem.core.holograms.HologramRegister; 33 | import com.alpsbte.plotsystem.utils.Utils; 34 | import org.bukkit.command.Command; 35 | import org.bukkit.command.CommandSender; 36 | import org.jetbrains.annotations.NotNull; 37 | 38 | import static net.kyori.adventure.text.Component.text; 39 | 40 | public class CMD_PReload extends BaseCommand { 41 | 42 | @Override 43 | public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String s, String[] args) { 44 | if (!sender.hasPermission(getPermission())) { 45 | sender.sendMessage(Utils.ChatUtils.getAlertFormat("You don't have permission to use this command!")); 46 | return true; 47 | } 48 | 49 | try { 50 | PlotSystem.getPlugin().reloadConfig(); 51 | sender.sendMessage(Utils.ChatUtils.getInfoFormat("Successfully reloaded config!")); 52 | 53 | DecentHologramDisplay.activeDisplays.forEach(leaderboard -> leaderboard.setLocation(HologramRegister 54 | .getLocation((HologramConfiguration) leaderboard))); 55 | HologramRegister.reload(); 56 | sender.sendMessage(Utils.ChatUtils.getInfoFormat("Successfully reloaded leaderboards!")); 57 | 58 | DatabaseConnection.InitializeDatabase(); 59 | } catch (Exception ex) { 60 | sender.sendMessage(Utils.ChatUtils.getAlertFormat("An error occurred while executing command!")); 61 | PlotSystem.getPlugin().getComponentLogger().error(text("A SQL error occurred!"), ex); 62 | } 63 | return true; 64 | } 65 | 66 | @Override 67 | public String[] getNames() { 68 | return new String[]{"preload"}; 69 | } 70 | 71 | @Override 72 | public String getDescription() { 73 | return "Reloads configuration files and leaderboards."; 74 | } 75 | 76 | @Override 77 | public String[] getParameter() { 78 | return new String[0]; 79 | } 80 | 81 | @Override 82 | public String getPermission() { 83 | return "plotsystem.admin.preload"; 84 | } 85 | } -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/commands/admin/CMD_SetLeaderboard.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.commands.admin; 26 | 27 | import com.alpsbte.alpslib.hologram.DecentHologramDisplay; 28 | import com.alpsbte.plotsystem.commands.BaseCommand; 29 | import com.alpsbte.plotsystem.core.holograms.HologramConfiguration; 30 | import com.alpsbte.plotsystem.core.holograms.HologramRegister; 31 | import com.alpsbte.plotsystem.utils.Utils; 32 | import net.kyori.adventure.text.Component; 33 | import net.kyori.adventure.text.format.NamedTextColor; 34 | import org.bukkit.Bukkit; 35 | import org.bukkit.command.Command; 36 | import org.bukkit.command.CommandSender; 37 | import org.bukkit.entity.Player; 38 | import org.jetbrains.annotations.NotNull; 39 | 40 | public class CMD_SetLeaderboard extends BaseCommand { 41 | 42 | @Override 43 | public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String s, String[] args) { 44 | if (!sender.hasPermission(getPermission())) { 45 | sender.sendMessage(Utils.ChatUtils.getAlertFormat("You don't have permission to use this command!")); 46 | return true; 47 | } 48 | 49 | if (getPlayer(sender) == null) { 50 | Bukkit.getConsoleSender().sendMessage(Component.text("This command can only be used as a player!", NamedTextColor.RED)); 51 | return true; 52 | } 53 | 54 | Player player = (Player) sender; 55 | if (args.length != 1) { 56 | sendInfo(sender); 57 | player.sendMessage("§8------- §6§lLeaderboards §8-------"); 58 | for (DecentHologramDisplay holo : DecentHologramDisplay.activeDisplays) { 59 | player.sendMessage(" §6> §f" + holo.getId()); 60 | } 61 | player.sendMessage("§8--------------------------"); 62 | return true; 63 | } 64 | 65 | // Find leaderboard by name 66 | DecentHologramDisplay leaderboard = DecentHologramDisplay.activeDisplays.stream() 67 | .filter(holo -> holo.getId().equalsIgnoreCase(args[0])) 68 | .findFirst() 69 | .orElse(null); 70 | 71 | // Update leaderboard location 72 | if (leaderboard == null) { 73 | player.sendMessage(Utils.ChatUtils.getAlertFormat("Leaderboard could not be found!")); 74 | return true; 75 | } 76 | HologramRegister.saveLocation(leaderboard.getId(), (HologramConfiguration) leaderboard, getPlayer(sender).getLocation()); 77 | player.sendMessage(Utils.ChatUtils.getInfoFormat("Successfully updated hologram location!")); 78 | player.playSound(player.getLocation(), Utils.SoundUtils.DONE_SOUND, 1, 1); 79 | return true; 80 | } 81 | 82 | @Override 83 | public String[] getNames() { 84 | return new String[]{"setleaderboard"}; 85 | } 86 | 87 | @Override 88 | public String getDescription() { 89 | return "Sets the position of a leaderboard."; 90 | } 91 | 92 | @Override 93 | public String[] getParameter() { 94 | return new String[]{"Name"}; 95 | } 96 | 97 | @Override 98 | public String getPermission() { 99 | return "plotsystem.admin.setleaderboard"; 100 | } 101 | } -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/commands/admin/setup/CMD_Setup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2021, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.commands.admin.setup; 26 | 27 | import com.alpsbte.plotsystem.commands.BaseCommand; 28 | import org.bukkit.command.Command; 29 | import org.bukkit.command.CommandSender; 30 | import org.jetbrains.annotations.NotNull; 31 | 32 | public class CMD_Setup extends BaseCommand { 33 | 34 | public CMD_Setup() { 35 | registerSubCommand(new CMD_Setup_BuildTeam(this)); 36 | registerSubCommand(new CMD_Setup_FTP(this)); 37 | registerSubCommand(new CMD_Setup_Server(this)); 38 | registerSubCommand(new CMD_Setup_Country(this)); 39 | registerSubCommand(new CMD_Setup_City(this)); 40 | registerSubCommand(new CMD_Setup_Difficulty(this)); 41 | } 42 | 43 | @Override 44 | public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String s, String[] args) { 45 | if (args.length == 0) { 46 | sendInfo(sender); 47 | } 48 | 49 | return super.onCommand(sender, cmd, s, args); 50 | } 51 | 52 | @Override 53 | public String[] getNames() { 54 | return new String[]{"pss"}; 55 | } 56 | 57 | @Override 58 | public String getDescription() { 59 | return ""; 60 | } 61 | 62 | @Override 63 | public String[] getParameter() { 64 | return new String[0]; 65 | } 66 | 67 | @Override 68 | public String getPermission() { 69 | return null; 70 | } 71 | 72 | public static String appendArgs(String[] args, int startIndex) { 73 | StringBuilder name = new StringBuilder(); 74 | for (int i = startIndex; i < args.length; i++) { 75 | name.append(args[i]); 76 | // Add space between words 77 | if (i != args.length - 1) { 78 | name.append(" "); 79 | } 80 | } 81 | return name.toString(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/commands/plot/CMD_Plot.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2021, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.commands.plot; 26 | 27 | import com.alpsbte.plotsystem.commands.BaseCommand; 28 | import org.bukkit.command.Command; 29 | import org.bukkit.command.CommandSender; 30 | import org.jetbrains.annotations.NotNull; 31 | 32 | public class CMD_Plot extends BaseCommand { 33 | 34 | // Register Sub-Commands 35 | public CMD_Plot() { 36 | registerSubCommand(new CMD_Plot_Teleport(this)); 37 | registerSubCommand(new CMD_Plot_Links(this)); 38 | registerSubCommand(new CMD_Plot_Submit(this)); 39 | registerSubCommand(new CMD_Plot_Abandon(this)); 40 | registerSubCommand(new CMD_Plot_Invite(this)); 41 | registerSubCommand(new CMD_Plot_Feedback(this)); 42 | registerSubCommand(new CMD_Plot_UndoSubmit(this)); 43 | registerSubCommand(new CMD_Plot_Members(this)); 44 | } 45 | 46 | @Override 47 | public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String s, String[] args) { 48 | if (args.length == 0) { 49 | sendInfo(sender); 50 | return true; 51 | } 52 | 53 | return super.onCommand(sender, cmd, s, args); 54 | } 55 | 56 | @Override 57 | public String[] getNames() { 58 | return new String[]{"plot", "p"}; 59 | } 60 | 61 | @Override 62 | public String getDescription() { 63 | return ""; 64 | } 65 | 66 | @Override 67 | public String[] getParameter() { 68 | return new String[0]; 69 | } 70 | 71 | @Override 72 | public String getPermission() { 73 | return null; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/commands/plot/CMD_Plot_Invite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.commands.plot; 26 | 27 | import com.alpsbte.plotsystem.PlotSystem; 28 | import com.alpsbte.plotsystem.commands.BaseCommand; 29 | import com.alpsbte.plotsystem.commands.SubCommand; 30 | import com.alpsbte.plotsystem.utils.io.ConfigPaths; 31 | import com.alpsbte.plotsystem.utils.PlotMemberInvitation; 32 | import com.alpsbte.plotsystem.utils.Utils; 33 | import com.alpsbte.plotsystem.utils.io.LangPaths; 34 | import org.bukkit.command.CommandSender; 35 | import org.bukkit.configuration.file.FileConfiguration; 36 | 37 | import java.sql.SQLException; 38 | 39 | import static net.kyori.adventure.text.Component.text; 40 | 41 | public class CMD_Plot_Invite extends SubCommand { 42 | 43 | public CMD_Plot_Invite(BaseCommand baseCommand) { 44 | super(baseCommand); 45 | } 46 | 47 | @Override 48 | public void onCommand(CommandSender sender, String[] args) { 49 | if (args.length > 0) { 50 | FileConfiguration config = PlotSystem.getPlugin().getConfig(); 51 | if (getPlayer(sender) != null && config.getBoolean(ConfigPaths.ENABLE_GROUP_SUPPORT)) { 52 | PlotMemberInvitation invite = null; 53 | for (PlotMemberInvitation item : PlotMemberInvitation.invitationsList) { 54 | if (item.invitee.getUniqueId().toString().equals(getPlayer(sender).getUniqueId().toString())) { 55 | invite = item; 56 | try { 57 | switch (args[0]) { 58 | case "accept": 59 | item.acceptInvite(); 60 | break; 61 | case "reject": 62 | item.rejectInvite(); 63 | break; 64 | default: 65 | sendInfo(sender); 66 | break; 67 | } 68 | } catch (SQLException ex) { 69 | PlotSystem.getPlugin().getComponentLogger().error(text("A SQL error occurred!"), ex); 70 | } 71 | } 72 | } 73 | 74 | if (invite != null) { 75 | PlotMemberInvitation.invitationsList.remove(invite); 76 | } else { 77 | sender.sendMessage(Utils.ChatUtils.getAlertFormat(langUtil.get(sender, LangPaths.Message.Error.PLAYER_HAS_NO_INVITATIONS))); 78 | } 79 | } 80 | } else { 81 | sendInfo(sender); 82 | } 83 | } 84 | 85 | @Override 86 | public String[] getNames() { 87 | return new String[]{"invite"}; 88 | } 89 | 90 | @Override 91 | public String getDescription() { 92 | return "Accept or reject incoming invitations."; 93 | } 94 | 95 | @Override 96 | public String[] getParameter() { 97 | return new String[]{"Accept/Reject"}; 98 | } 99 | 100 | @Override 101 | public String getPermission() { 102 | return "plotsystem.plot.invite"; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/commands/plot/CMD_Plot_Links.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.commands.plot; 26 | 27 | import com.alpsbte.alpslib.utils.AlpsUtils; 28 | import com.alpsbte.plotsystem.PlotSystem; 29 | import com.alpsbte.plotsystem.commands.BaseCommand; 30 | import com.alpsbte.plotsystem.commands.SubCommand; 31 | import com.alpsbte.plotsystem.core.system.Builder; 32 | import com.alpsbte.plotsystem.core.system.plot.Plot; 33 | import com.alpsbte.plotsystem.core.system.plot.utils.PlotUtils; 34 | import com.alpsbte.plotsystem.utils.Utils; 35 | import com.alpsbte.plotsystem.utils.enums.Status; 36 | import com.alpsbte.plotsystem.utils.io.LangPaths; 37 | import net.kyori.adventure.text.format.NamedTextColor; 38 | import org.bukkit.Bukkit; 39 | import org.bukkit.command.CommandSender; 40 | 41 | import java.sql.SQLException; 42 | 43 | import static net.kyori.adventure.text.Component.text; 44 | 45 | public class CMD_Plot_Links extends SubCommand { 46 | 47 | public CMD_Plot_Links(BaseCommand baseCommand) { 48 | super(baseCommand); 49 | } 50 | 51 | @Override 52 | public void onCommand(CommandSender sender, String[] args) { 53 | try { 54 | if (getPlayer(sender) != null) { 55 | if (args.length > 0 && AlpsUtils.tryParseInt(args[0]) != null) { 56 | int plotID = Integer.parseInt(args[0]); 57 | if (PlotUtils.plotExists(plotID)) { 58 | PlotUtils.ChatFormatting.sendLinkMessages(new Plot(plotID), getPlayer(sender)); 59 | } else { 60 | sender.sendMessage(Utils.ChatUtils.getAlertFormat(langUtil.get(sender, LangPaths.Message.Error.PLOT_DOES_NOT_EXIST))); 61 | } 62 | } else if (PlotUtils.isPlotWorld(getPlayer(sender).getWorld())) { 63 | PlotUtils.ChatFormatting.sendLinkMessages(PlotUtils.getCurrentPlot(Builder.byUUID(getPlayer(sender).getUniqueId()), Status.unfinished, Status.unreviewed), getPlayer(sender)); 64 | } else { 65 | sendInfo(sender); 66 | } 67 | } else { 68 | Bukkit.getConsoleSender().sendMessage(text("This command can only be used as a player!", NamedTextColor.RED)); 69 | } 70 | } catch (SQLException ex) { 71 | PlotSystem.getPlugin().getComponentLogger().error(text("A SQL error occurred!"), ex); 72 | } 73 | } 74 | 75 | @Override 76 | public String[] getNames() { 77 | return new String[]{"links", "link"}; 78 | } 79 | 80 | @Override 81 | public String getDescription() { 82 | return "Sends you the links of the plot you are currently on."; 83 | } 84 | 85 | @Override 86 | public String[] getParameter() { 87 | return new String[]{"ID"}; 88 | } 89 | 90 | @Override 91 | public String getPermission() { 92 | return "plotsystem.plot.links"; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/commands/plot/CMD_Plot_Teleport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.commands.plot; 26 | 27 | import com.alpsbte.alpslib.utils.AlpsUtils; 28 | import com.alpsbte.plotsystem.PlotSystem; 29 | import com.alpsbte.plotsystem.commands.BaseCommand; 30 | import com.alpsbte.plotsystem.commands.ICommand; 31 | import com.alpsbte.plotsystem.commands.SubCommand; 32 | import com.alpsbte.plotsystem.core.system.Builder; 33 | import com.alpsbte.plotsystem.core.system.plot.Plot; 34 | import com.alpsbte.plotsystem.core.system.plot.generator.DefaultPlotGenerator; 35 | import com.alpsbte.plotsystem.core.system.plot.utils.PlotUtils; 36 | import com.alpsbte.plotsystem.utils.Utils; 37 | import com.alpsbte.plotsystem.utils.enums.Status; 38 | import com.alpsbte.plotsystem.utils.io.LangPaths; 39 | import net.kyori.adventure.text.format.NamedTextColor; 40 | import org.bukkit.Bukkit; 41 | import org.bukkit.command.CommandSender; 42 | 43 | import java.sql.SQLException; 44 | 45 | import static net.kyori.adventure.text.Component.text; 46 | 47 | public class CMD_Plot_Teleport extends SubCommand implements ICommand { 48 | 49 | public CMD_Plot_Teleport(BaseCommand baseCommand) { 50 | super(baseCommand); 51 | } 52 | 53 | @Override 54 | public void onCommand(CommandSender sender, String[] args) { 55 | try { 56 | if (getPlayer(sender) != null) { 57 | if (args.length > 0 && AlpsUtils.tryParseInt(args[0]) != null) { 58 | int plotID = Integer.parseInt(args[0]); 59 | Plot plot; 60 | if (PlotUtils.plotExists(plotID) && (plot = new Plot(plotID)).getStatus() != Status.unclaimed) { 61 | plot.getWorld().teleportPlayer(getPlayer(sender)); 62 | } else { 63 | if (sender.hasPermission("plotsystem.admin") && PlotUtils.plotExists(plotID)) { 64 | new DefaultPlotGenerator(new Plot(plotID), Builder.byUUID(getPlayer(sender).getUniqueId())); 65 | } else { 66 | sender.sendMessage(Utils.ChatUtils.getAlertFormat(langUtil.get(sender, LangPaths.Message.Error.PLOT_DOES_NOT_EXIST))); 67 | } 68 | } 69 | } else { 70 | sendInfo(sender); 71 | } 72 | } else { 73 | Bukkit.getConsoleSender().sendMessage(text("This command can only be used as a player!", NamedTextColor.RED)); 74 | } 75 | } catch (SQLException ex) { 76 | sender.sendMessage(Utils.ChatUtils.getAlertFormat(langUtil.get(sender, LangPaths.Message.Error.ERROR_OCCURRED))); 77 | PlotSystem.getPlugin().getComponentLogger().error(text("A SQL error occurred!"), ex); 78 | } 79 | } 80 | 81 | @Override 82 | public String[] getNames() { 83 | return new String[]{"tp", "teleport"}; 84 | } 85 | 86 | @Override 87 | public String getDescription() { 88 | return "Teleport to a plot."; 89 | } 90 | 91 | @Override 92 | public String[] getParameter() { 93 | return new String[]{"ID"}; 94 | } 95 | 96 | @Override 97 | public String getPermission() { 98 | return "plotsystem.plot.teleport"; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/holograms/HologramConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.holograms; 26 | 27 | public interface HologramConfiguration { 28 | String getEnablePath(); 29 | 30 | String getXPath(); 31 | 32 | String getYPath(); 33 | 34 | String getZPath(); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/holograms/HologramRegister.java: -------------------------------------------------------------------------------- 1 | package com.alpsbte.plotsystem.core.holograms; 2 | 3 | import com.alpsbte.alpslib.hologram.DecentHologramDisplay; 4 | import com.alpsbte.plotsystem.PlotSystem; 5 | import com.alpsbte.plotsystem.utils.Utils; 6 | import com.alpsbte.plotsystem.utils.io.ConfigUtil; 7 | import org.bukkit.Bukkit; 8 | import org.bukkit.Location; 9 | import org.bukkit.configuration.file.FileConfiguration; 10 | import org.bukkit.entity.Player; 11 | 12 | import java.util.Objects; 13 | 14 | public final class HologramRegister { 15 | /** 16 | * Registers the {@link ScoreLeaderboard}, {@link PlotsLeaderboard} and adds 17 | * them to {@link DecentHologramDisplay#activeDisplays}. 18 | */ 19 | public static void init() { 20 | new ScoreLeaderboard(); 21 | new PlotsLeaderboard(); 22 | } 23 | 24 | public static void reload() { 25 | for (DecentHologramDisplay display : DecentHologramDisplay.activeDisplays) { 26 | // Register and create holograms 27 | if (PlotSystem.getPlugin().getConfig().getBoolean(((HologramConfiguration) display).getEnablePath())) { 28 | display.setEnabled(true); 29 | for (Player player : Objects.requireNonNull(Bukkit.getWorld(display.getLocation().getWorld().getName())).getPlayers()) 30 | display.create(player); 31 | } else { 32 | display.setEnabled(false); 33 | display.removeAll(); 34 | } 35 | } 36 | } 37 | 38 | public static Location getLocation(HologramConfiguration configPaths) { 39 | FileConfiguration config = PlotSystem.getPlugin().getConfig(); 40 | 41 | return new Location(Objects.requireNonNull(Utils.getSpawnLocation().getWorld()), 42 | config.getDouble(configPaths.getXPath()), 43 | config.getDouble(configPaths.getYPath()), 44 | config.getDouble(configPaths.getZPath()) 45 | ); 46 | } 47 | 48 | public static void saveLocation(String id, HologramConfiguration configPaths, Location newLocation) { 49 | FileConfiguration config = PlotSystem.getPlugin().getConfig(); 50 | config.set(configPaths.getEnablePath(), true); 51 | config.set(configPaths.getXPath(), newLocation.getX()); 52 | config.set(configPaths.getYPath(), newLocation.getY()); 53 | config.set(configPaths.getZPath(), newLocation.getZ()); 54 | ConfigUtil.getInstance().saveFiles(); 55 | 56 | for (DecentHologramDisplay display : DecentHologramDisplay.activeDisplays) { 57 | if (!Objects.equals(display.getId(), id)) continue; 58 | display.setLocation(newLocation); 59 | } 60 | } 61 | 62 | public static class LeaderboardPositionLine extends DecentHologramDisplay.TextLine { 63 | public LeaderboardPositionLine(int position, String username, int score) { 64 | super("§e#" + position + " " + (username != null ? "§a" + username : "§8No one, yet") + " §7- §b" + score); 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/holograms/PlotTutorialHologram.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.holograms; 26 | 27 | import com.alpsbte.plotsystem.core.system.tutorial.AbstractTutorialHologram; 28 | import com.alpsbte.plotsystem.core.system.tutorial.utils.TutorialUtils; 29 | import com.alpsbte.plotsystem.core.system.tutorial.stage.tasks.message.ChatMessageTask; 30 | import com.alpsbte.plotsystem.utils.io.LangPaths; 31 | import com.alpsbte.plotsystem.utils.io.LangUtil; 32 | import net.kyori.adventure.text.Component; 33 | import net.kyori.adventure.text.event.ClickEvent; 34 | import net.kyori.adventure.text.format.NamedTextColor; 35 | import org.bukkit.Sound; 36 | import org.bukkit.entity.Player; 37 | 38 | import static org.bukkit.ChatColor.*; 39 | 40 | public class PlotTutorialHologram extends AbstractTutorialHologram { 41 | public PlotTutorialHologram(Player player, int plotTutorialId, int holoId, String content) { 42 | this(player, plotTutorialId, holoId, content, -1); 43 | } 44 | 45 | public PlotTutorialHologram(Player player, int plotTutorialId, int holoId, String content, int readMoreId) { 46 | super(player, plotTutorialId, holoId, content, readMoreId); 47 | } 48 | 49 | @Override 50 | protected String getTitle() { 51 | return GOLD + BOLD.toString() + LangUtil.getInstance().get(player, LangPaths.Note.TIP).toUpperCase(); 52 | } 53 | 54 | @Override 55 | protected String getReadMoreActionText() { 56 | return DARK_GRAY + "[" + GRAY + LangUtil.getInstance().get(player, LangPaths.Note.Action.READ_MORE) + DARK_GRAY + "]"; 57 | } 58 | 59 | @Override 60 | protected void handleReadMoreClickAction() { 61 | player.sendMessage(new ChatMessageTask.ClickableTaskMessage(TutorialUtils.CHAT_PREFIX_COMPONENT.append(Component.text(getReadMoreLink(), NamedTextColor.GRAY)), 62 | Component.text(LangUtil.getInstance().get(player, LangPaths.Note.Action.READ_MORE) + "...", NamedTextColor.GRAY), ClickEvent.openUrl(getReadMoreLink())).getComponent()); 63 | player.playSound(player.getLocation(), Sound.ENTITY_ITEM_FRAME_ADD_ITEM, 1, 1.2f); 64 | } 65 | 66 | @Override 67 | protected String getMarkAsReadActionText() { 68 | return DARK_GRAY + "[" + YELLOW + LangUtil.getInstance().get(player, LangPaths.Note.Action.MARK_AS_READ) + " " + READ_EMOJI + DARK_GRAY + "]"; 69 | } 70 | 71 | @Override 72 | protected String getMarkAsReadClickedActionText() { 73 | return GREEN + LangUtil.getInstance().get(player, LangPaths.Note.Action.READ) + " " + READ_EMOJI; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/holograms/PlotsLeaderboard.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.holograms; 26 | 27 | import com.alpsbte.alpslib.hologram.DecentHologramDisplay; 28 | import com.alpsbte.plotsystem.PlotSystem; 29 | import com.alpsbte.plotsystem.core.system.Builder; 30 | import com.alpsbte.plotsystem.utils.io.ConfigPaths; 31 | import com.alpsbte.plotsystem.utils.items.BaseItems; 32 | import org.bukkit.inventory.ItemStack; 33 | 34 | import java.sql.SQLException; 35 | import java.util.ArrayList; 36 | import java.util.List; 37 | import java.util.UUID; 38 | import java.util.logging.Level; 39 | 40 | public class PlotsLeaderboard extends DecentHologramDisplay implements HologramConfiguration { 41 | protected PlotsLeaderboard() { 42 | super(ConfigPaths.PLOTS_LEADERBOARD, null, false); 43 | setLocation(HologramRegister.getLocation(this)); 44 | setEnabled(PlotSystem.getPlugin().getConfig().getBoolean(getEnablePath())); 45 | } 46 | 47 | @Override 48 | public ItemStack getItem() { 49 | return new ItemStack(BaseItems.LEADERBOARD_PLOT.getItem()); 50 | } 51 | 52 | @Override 53 | public String getTitle(UUID playerUUID) { 54 | return "§b§lCOMPLETED PLOTS §6§l[Lifetime]"; 55 | } 56 | 57 | @Override 58 | public List> getContent(UUID playerUUID) { 59 | try { 60 | ArrayList> lines = new ArrayList<>(); 61 | 62 | List> entries = Builder.getBuildersByCompletedBuilds(10); 63 | for (int i = 0; i < 10; i++) { 64 | Builder.DatabaseEntry entry = i < entries.size() && entries.get(i).getValue() != 0 ? entries.get(i) : null; 65 | lines.add(new HologramRegister.LeaderboardPositionLine(i + 1, entry != null ? entry.getKey() : null, entry != null ? entry.getValue() : 0)); 66 | } 67 | 68 | return lines; 69 | } catch (SQLException ex) { 70 | PlotSystem.getPlugin().getLogger().log(Level.SEVERE, "An error occurred while reading leaderboard content", ex); 71 | } 72 | return new ArrayList<>(); 73 | } 74 | 75 | @Override 76 | public boolean hasViewPermission(UUID uuid) { 77 | return true; 78 | } 79 | 80 | @Override 81 | public String getEnablePath() { 82 | return ConfigPaths.PLOTS_LEADERBOARD_ENABLE; 83 | } 84 | 85 | @Override 86 | public String getXPath() { 87 | return ConfigPaths.PLOTS_LEADERBOARD_X; 88 | } 89 | 90 | @Override 91 | public String getYPath() { 92 | return ConfigPaths.PLOTS_LEADERBOARD_Y; 93 | } 94 | 95 | @Override 96 | public String getZPath() { 97 | return ConfigPaths.PLOTS_LEADERBOARD_Z; 98 | } 99 | } -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/menus/AbstractMenu.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.menus; 26 | 27 | import com.alpsbte.plotsystem.PlotSystem; 28 | import org.bukkit.Bukkit; 29 | import org.bukkit.entity.Player; 30 | import org.ipvp.canvas.Menu; 31 | import org.ipvp.canvas.mask.Mask; 32 | import org.ipvp.canvas.type.ChestMenu; 33 | 34 | import static net.kyori.adventure.text.Component.text; 35 | 36 | public abstract class AbstractMenu { 37 | private final Menu menu; 38 | private final Player menuPlayer; 39 | private final String title; 40 | 41 | public AbstractMenu(int rows, String title, Player menuPlayer) { 42 | this(rows, title, menuPlayer, true); 43 | } 44 | 45 | public AbstractMenu(int rows, String title, Player menuPlayer, boolean reload) { 46 | this.title = title; 47 | this.menuPlayer = menuPlayer; 48 | this.menu = ChestMenu.builder(rows).title(text(title)).redraw(true).build(); 49 | 50 | if (reload) reloadMenuAsync(); 51 | } 52 | 53 | /** 54 | * Places items asynchronously in the menu after it is opened 55 | */ 56 | protected abstract void setMenuItemsAsync(); 57 | 58 | /** 59 | * Sets click events for the items placed in the menu async after it is opened 60 | */ 61 | protected abstract void setItemClickEventsAsync(); 62 | 63 | /** 64 | * Places pre-defined items in the menu before it is opened 65 | * 66 | * @return Pre-defined mask 67 | * @see 68 | */ 69 | protected abstract Mask getMask(); 70 | 71 | /** 72 | * Places items synchronously in the menu and opens it afterward 73 | * NOTE: This method gets called before class is loaded! 74 | */ 75 | protected void setPreviewItems() { 76 | if (getMask() != null) getMask().apply(getMenu()); 77 | getMenu().open(getMenuPlayer()); 78 | getMenuPlayer().getOpenInventory().setTitle(title); 79 | } 80 | 81 | /** 82 | * Reloads all menu items and click events in the menu asynchronously 83 | * {@link #setPreviewItems()}.{@link #setMenuItemsAsync()}.{@link #setItemClickEventsAsync()} 84 | */ 85 | protected void reloadMenuAsync() { 86 | setPreviewItems(); 87 | Bukkit.getScheduler().runTaskAsynchronously(PlotSystem.getPlugin(), () -> { 88 | setMenuItemsAsync(); 89 | setItemClickEventsAsync(); 90 | }); 91 | } 92 | 93 | /** 94 | * @return Inventory 95 | */ 96 | protected Menu getMenu() { 97 | return menu; 98 | } 99 | 100 | /** 101 | * @return Inventory player 102 | */ 103 | protected Player getMenuPlayer() { 104 | return menuPlayer; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/Difficulty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system; 26 | 27 | import com.alpsbte.plotsystem.PlotSystem; 28 | import com.alpsbte.plotsystem.core.database.DatabaseConnection; 29 | import com.alpsbte.plotsystem.utils.enums.PlotDifficulty; 30 | 31 | import java.sql.ResultSet; 32 | import java.sql.SQLException; 33 | import java.util.ArrayList; 34 | import java.util.List; 35 | 36 | import static net.kyori.adventure.text.Component.text; 37 | 38 | public class Difficulty { 39 | private final int ID; 40 | 41 | private PlotDifficulty difficulty; 42 | private double multiplier; 43 | private int scoreRequirement; 44 | 45 | public Difficulty(int ID) throws SQLException { 46 | this.ID = ID; 47 | 48 | try (ResultSet rs = DatabaseConnection.createStatement("SELECT name, multiplier, score_requirment FROM plotsystem_difficulties WHERE id = ?") 49 | .setValue(this.ID).executeQuery()) { 50 | 51 | if (rs.next()) { 52 | this.difficulty = PlotDifficulty.valueOf(rs.getString(1)); 53 | this.multiplier = rs.getDouble(2); 54 | this.scoreRequirement = rs.getInt(3); 55 | } 56 | 57 | DatabaseConnection.closeResultSet(rs); 58 | } 59 | } 60 | 61 | public int getID() { 62 | return ID; 63 | } 64 | 65 | public PlotDifficulty getDifficulty() { 66 | return difficulty; 67 | } 68 | 69 | public double getMultiplier() { 70 | return multiplier; 71 | } 72 | 73 | public int getScoreRequirement() { 74 | return scoreRequirement; 75 | } 76 | 77 | public static List getDifficulties() { 78 | try (ResultSet rs = DatabaseConnection.createStatement("SELECT id FROM plotsystem_difficulties").executeQuery()) { 79 | List difficulties = new ArrayList<>(); 80 | while (rs.next()) { 81 | difficulties.add(new Difficulty(rs.getInt(1))); 82 | } 83 | 84 | DatabaseConnection.closeResultSet(rs); 85 | 86 | return difficulties; 87 | } catch (SQLException ex) { 88 | PlotSystem.getPlugin().getComponentLogger().error(text("A SQL error occurred!"), ex); 89 | } 90 | return new ArrayList<>(); 91 | } 92 | 93 | public static void setMultiplier(int difficultyID, double multiplier) throws SQLException { 94 | DatabaseConnection.createStatement("UPDATE plotsystem_difficulties SET multiplier = ? WHERE id = ?") 95 | .setValue(multiplier).setValue(difficultyID).executeUpdate(); 96 | } 97 | 98 | public static void setScoreRequirement(int difficultyID, int scoreRequirement) throws SQLException { 99 | DatabaseConnection.createStatement("UPDATE plotsystem_difficulties SET score_requirment = ? WHERE id = ?") 100 | .setValue(scoreRequirement).setValue(difficultyID).executeUpdate(); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/Payout.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2021-2022, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system; 26 | 27 | import com.alpsbte.plotsystem.core.database.DatabaseConnection; 28 | import com.alpsbte.plotsystem.core.holograms.ScoreLeaderboard; 29 | 30 | import java.sql.ResultSet; 31 | import java.sql.SQLException; 32 | 33 | public class Payout { 34 | private final int id; 35 | private final ScoreLeaderboard.LeaderboardTimeframe timeframe; 36 | private final int position; 37 | private final String payoutAmount; 38 | 39 | private Payout(int id, ScoreLeaderboard.LeaderboardTimeframe timeframe, int position, String payoutAmount) { 40 | this.id = id; 41 | this.timeframe = timeframe; 42 | this.position = position; 43 | this.payoutAmount = payoutAmount; 44 | } 45 | 46 | public static Payout getPayout(ScoreLeaderboard.LeaderboardTimeframe timeframe, int position) throws SQLException { 47 | if (timeframe == ScoreLeaderboard.LeaderboardTimeframe.LIFETIME) { 48 | throw new IllegalArgumentException("Invalid option LIFETIME"); 49 | } 50 | if (position < 1 || position > 10) { 51 | throw new IllegalArgumentException("Illegal position " + position); 52 | } 53 | 54 | try (ResultSet rs = DatabaseConnection.createStatement("SELECT id, timeframe, position, payout_amount FROM plotsystem_payouts WHERE timeframe = ? AND position = ?") 55 | .setValue(timeframe.name()).setValue(position).executeQuery()) { 56 | Payout instance = null; 57 | 58 | if (rs.next()) { 59 | instance = new Payout(rs.getInt(1), ScoreLeaderboard.LeaderboardTimeframe.valueOf(rs.getString(2)), rs.getInt(3), rs.getString(4)); 60 | } 61 | 62 | DatabaseConnection.closeResultSet(rs); 63 | return instance; 64 | } 65 | } 66 | 67 | public int getId() { 68 | return id; 69 | } 70 | 71 | public ScoreLeaderboard.LeaderboardTimeframe getTimeframe() { 72 | return timeframe; 73 | } 74 | 75 | public int getPosition() { 76 | return position; 77 | } 78 | 79 | public String getPayoutAmount() { 80 | return payoutAmount; 81 | } 82 | } -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/Server.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system; 26 | 27 | import com.alpsbte.plotsystem.PlotSystem; 28 | import com.alpsbte.plotsystem.core.database.DatabaseConnection; 29 | 30 | import java.sql.ResultSet; 31 | import java.sql.SQLException; 32 | import java.util.ArrayList; 33 | import java.util.List; 34 | 35 | import static net.kyori.adventure.text.Component.text; 36 | 37 | public class Server { 38 | private final int ID; 39 | private int ftpConfigurationID; 40 | 41 | private String name; 42 | 43 | public Server(int ID) throws SQLException { 44 | this.ID = ID; 45 | 46 | try (ResultSet rs = DatabaseConnection.createStatement("SELECT ftp_configuration_id, name FROM plotsystem_servers WHERE id = ?") 47 | .setValue(this.ID).executeQuery()) { 48 | 49 | if (rs.next()) { 50 | this.ftpConfigurationID = rs.getInt(1); 51 | if (rs.wasNull()) this.ftpConfigurationID = -1; 52 | 53 | this.name = rs.getString(2); 54 | } 55 | 56 | DatabaseConnection.closeResultSet(rs); 57 | } 58 | } 59 | 60 | public int getID() { 61 | return ID; 62 | } 63 | 64 | public String getName() { 65 | return name; 66 | } 67 | 68 | public FTPConfiguration getFTPConfiguration() throws SQLException { 69 | return ftpConfigurationID != -1 ? new FTPConfiguration(ftpConfigurationID) : null; 70 | } 71 | 72 | public static List getServers() { 73 | try (ResultSet rs = DatabaseConnection.createStatement("SELECT id FROM plotsystem_servers").executeQuery()) { 74 | List servers = new ArrayList<>(); 75 | while (rs.next()) { 76 | servers.add(new Server(rs.getInt(1))); 77 | } 78 | 79 | DatabaseConnection.closeResultSet(rs); 80 | 81 | return servers; 82 | } catch (SQLException ex) { 83 | PlotSystem.getPlugin().getComponentLogger().error(text("A SQL error occurred!"), ex); 84 | } 85 | return new ArrayList<>(); 86 | } 87 | 88 | public static Server addServer(String name) throws SQLException { 89 | int id = DatabaseConnection.getTableID("plotsystem_servers"); 90 | DatabaseConnection.createStatement("INSERT INTO plotsystem_servers (id, name) VALUES (?, ?)") 91 | .setValue(id) 92 | .setValue(name).executeUpdate(); 93 | return new Server(id); 94 | } 95 | 96 | public static void removeServer(int serverID) throws SQLException { 97 | DatabaseConnection.createStatement("DELETE FROM plotsystem_servers WHERE id = ?") 98 | .setValue(serverID).executeUpdate(); 99 | } 100 | 101 | public static void setFTP(int serverID, int ftpID) throws SQLException { 102 | if (ftpID != -1) { 103 | DatabaseConnection.createStatement("UPDATE plotsystem_servers SET ftp_configuration_id = ? WHERE id = ?") 104 | .setValue(ftpID) 105 | .setValue(serverID).executeUpdate(); 106 | } else { 107 | DatabaseConnection.createStatement("UPDATE plotsystem_servers SET ftp_configuration_id = DEFAULT WHERE id = ?") 108 | .setValue(serverID).executeUpdate(); 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/plot/utils/PlotPermissions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2021-2022, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.plot.utils; 26 | 27 | import com.alpsbte.plotsystem.core.system.plot.world.PlotWorld; 28 | 29 | import java.util.UUID; 30 | 31 | public class PlotPermissions { 32 | 33 | private final PlotWorld world; 34 | 35 | public PlotPermissions(PlotWorld world) { 36 | this.world = world; 37 | } 38 | 39 | public PlotPermissions addBuilderPerms(UUID builder) { 40 | if (world.getProtectedRegion() != null) world.getProtectedRegion().getOwners().addPlayer(builder); 41 | world.getProtectedBuildRegion().getOwners().addPlayer(builder); 42 | PlotUtils.Cache.clearCache(builder); 43 | return this; 44 | } 45 | 46 | public PlotPermissions removeBuilderPerms(UUID builder) { 47 | if (world.getProtectedRegion() != null) world.getProtectedRegion().getOwners().removePlayer(builder); 48 | world.getProtectedBuildRegion().getOwners().removePlayer(builder); 49 | PlotUtils.Cache.clearCache(builder); 50 | return this; 51 | } 52 | 53 | public void clearAllPerms() { 54 | if (world.getProtectedRegion() != null) world.getProtectedRegion().getOwners().removeAll(); 55 | world.getProtectedBuildRegion().getOwners().removeAll(); 56 | } 57 | 58 | public boolean hasBuildingPerms(UUID builder) { 59 | return world.getProtectedBuildRegion().getOwners().contains(builder); 60 | } 61 | 62 | public void save() { 63 | world.unloadWorld(false); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/plot/utils/PlotType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.plot.utils; 26 | 27 | public enum PlotType { 28 | 29 | FOCUS_MODE(0), 30 | LOCAL_INSPIRATION_MODE(1), 31 | CITY_INSPIRATION_MODE(2), 32 | TUTORIAL(3); 33 | 34 | final int id; 35 | 36 | PlotType(int id) { 37 | this.id = id; 38 | } 39 | 40 | public int getId() { 41 | return id; 42 | } 43 | 44 | // Returns true, if the plot type only contains environment around the plot. 45 | public boolean hasEnvironment() { 46 | return id == 1 || id == 2 || id == 3; 47 | } 48 | 49 | // Returns true, if the plot type only contains one plot per world. 50 | public boolean hasOnePlotPerWorld() { 51 | return id == 0 || id == 1 || id == 3; 52 | } 53 | 54 | public static PlotType byId(int id) { 55 | for (PlotType plotType : values()) 56 | if (plotType.getId() == id) 57 | return plotType; 58 | 59 | return null; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/tutorial/PlotTutorial.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.tutorial; 26 | 27 | import java.util.UUID; 28 | 29 | public interface PlotTutorial extends Tutorial { 30 | 31 | /** 32 | * This method is called when a schematic outline in the plot world is pasted. 33 | * 34 | * @param playerUUID uuid of the player 35 | * @param schematicId The schematic id 36 | */ 37 | void onPlotSchematicPaste(UUID playerUUID, int schematicId); 38 | 39 | /** 40 | * This method is called when the building and WorldEdit permissions on the plot need to be changed. 41 | * 42 | * @param playerUUID uuid of the player 43 | * @param isBuildingAllowed true if building is enabled, otherwise false 44 | * @param isWorldEditAllowed true if WorldEdit is enabled, otherwise false 45 | */ 46 | void onPlotPermissionChange(UUID playerUUID, boolean isBuildingAllowed, boolean isWorldEditAllowed); 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/tutorial/TutorialCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.tutorial; 26 | 27 | public enum TutorialCategory { 28 | BEGINNER(0); 29 | 30 | 31 | final int id; 32 | 33 | TutorialCategory(int id) { 34 | this.id = id; 35 | } 36 | 37 | public int getId() { 38 | return id; 39 | } 40 | 41 | public static TutorialCategory byId(int id) { 42 | for (TutorialCategory theme : values()) 43 | if (theme.getId() == id) 44 | return theme; 45 | return null; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/tutorial/TutorialDataModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.tutorial; 26 | 27 | import java.sql.SQLException; 28 | import java.util.Date; 29 | import java.util.UUID; 30 | 31 | public interface TutorialDataModel { 32 | /** 33 | * Gets the ID of the individual tutorial from your storage system (database or config). 34 | * 35 | * @return id, negative if not set 36 | */ 37 | int getID(); 38 | 39 | /** 40 | * Gets the UUID of the player who started the tutorial. The UUID is 36 characters long and contains 4 dashes. 41 | * 42 | * @return uuid of the player 43 | */ 44 | UUID getPlayerUUID() throws SQLException; 45 | 46 | /** 47 | * The ID which is assigned to the tutorial. This ID is used to identify the tutorial in the system. 48 | * 49 | * @return tutorial id, negative if not set 50 | */ 51 | int getTutorialID() throws SQLException; 52 | 53 | /** 54 | * Gets the highest stage id which the player has completed. The stage id starts at 0. 55 | * 56 | * @return stage id, negative if not set 57 | */ 58 | int getStageID() throws SQLException; 59 | 60 | /** 61 | * Checks if the player has completed all stages of the tutorial. 62 | * 63 | * @return true if the player has completed the tutorial otherwise false 64 | */ 65 | boolean isCompleted() throws SQLException; 66 | 67 | /** 68 | * Gets the date when the player created the tutorial. 69 | * 70 | * @return create date 71 | */ 72 | Date getCreationDate() throws SQLException; 73 | 74 | /** 75 | * Gets the date when the player last completed a stage. 76 | * 77 | * @return last stage completion date 78 | */ 79 | Date getLastStageCompletionDate() throws SQLException; 80 | 81 | /** 82 | * Gets the date when the player completed the tutorial. 83 | * 84 | * @return completion date 85 | */ 86 | Date getCompletionDate() throws SQLException; 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/tutorial/TutorialEventListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.tutorial; 26 | 27 | import com.alpsbte.plotsystem.core.system.tutorial.stage.tasks.events.EventTask; 28 | import com.destroystokyo.paper.event.player.PlayerUseUnknownEntityEvent; 29 | import io.papermc.paper.event.player.AsyncChatEvent; 30 | import org.bukkit.event.EventHandler; 31 | import org.bukkit.event.EventPriority; 32 | import org.bukkit.event.Listener; 33 | import org.bukkit.event.block.BlockPlaceEvent; 34 | import org.bukkit.event.player.*; 35 | 36 | import java.util.HashMap; 37 | import java.util.Map; 38 | 39 | public class TutorialEventListener implements Listener { 40 | public static final Map runningEventTasks = new HashMap<>(); 41 | 42 | @EventHandler 43 | private void onPlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent event) { 44 | if (!runningEventTasks.containsKey(event.getPlayer().getUniqueId().toString())) return; 45 | runningEventTasks.get(event.getPlayer().getUniqueId().toString()).performEvent(event); 46 | } 47 | 48 | @EventHandler 49 | private void onPlayerTeleportEvent(PlayerTeleportEvent event) { 50 | if (!runningEventTasks.containsKey(event.getPlayer().getUniqueId().toString())) return; 51 | runningEventTasks.get(event.getPlayer().getUniqueId().toString()).performEvent(event); 52 | } 53 | 54 | @EventHandler 55 | private void onPlayerInteractEvent(PlayerInteractEvent event) { 56 | if (!runningEventTasks.containsKey(event.getPlayer().getUniqueId().toString())) return; 57 | runningEventTasks.get(event.getPlayer().getUniqueId().toString()).performEvent(event); 58 | } 59 | 60 | @EventHandler 61 | private void onNpcInteractEvent(PlayerUseUnknownEntityEvent event) { 62 | if (!runningEventTasks.containsKey(event.getPlayer().getUniqueId().toString())) return; 63 | runningEventTasks.get(event.getPlayer().getUniqueId().toString()).performEvent(event); 64 | } 65 | 66 | @EventHandler(priority = EventPriority.LOWEST) 67 | private void onPlayerChatEvent(AsyncChatEvent event) { 68 | if (!runningEventTasks.containsKey(event.getPlayer().getUniqueId().toString())) return; 69 | runningEventTasks.get(event.getPlayer().getUniqueId().toString()).performEvent(event); 70 | } 71 | 72 | @EventHandler 73 | private void onPlayerPlaceBlockEvent(BlockPlaceEvent event) { 74 | if (!runningEventTasks.containsKey(event.getPlayer().getUniqueId().toString())) return; 75 | runningEventTasks.get(event.getPlayer().getUniqueId().toString()).performEvent(event); 76 | } 77 | 78 | @EventHandler 79 | private void onPlayerChangedWorldEvent(PlayerChangedWorldEvent event) { 80 | Tutorial tutorial = AbstractTutorial.getActiveTutorial(event.getPlayer().getUniqueId()); 81 | if (tutorial != null && (tutorial.getCurrentWorld() == null || !tutorial.getCurrentWorld().getName().equals(event.getPlayer().getWorld().getName()))) 82 | tutorial.onTutorialStop(event.getPlayer().getUniqueId()); 83 | } 84 | } -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/tutorial/stage/AbstractPlotStage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | 26 | package com.alpsbte.plotsystem.core.system.tutorial.stage; 27 | 28 | import com.alpsbte.plotsystem.core.system.plot.TutorialPlot; 29 | import org.bukkit.entity.Player; 30 | 31 | public abstract class AbstractPlotStage extends AbstractStage { 32 | private final TutorialPlot plot; 33 | private final int initSchematicId; 34 | 35 | protected AbstractPlotStage(Player player, int initWorldIndex, TutorialPlot plot, int initSchematicId) { 36 | super(player, plot.getID(), initWorldIndex); 37 | this.plot = plot; 38 | this.initSchematicId = initSchematicId; 39 | } 40 | 41 | public TutorialPlot getPlot() { 42 | return plot; 43 | } 44 | 45 | public int getInitSchematicId() { 46 | return initSchematicId; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/tutorial/stage/AbstractStage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.tutorial.stage; 26 | 27 | import com.alpsbte.plotsystem.core.system.tutorial.AbstractTutorialHologram; 28 | import com.alpsbte.plotsystem.core.system.tutorial.stage.tasks.AbstractTask; 29 | import org.bukkit.entity.Player; 30 | 31 | import java.io.IOException; 32 | import java.sql.SQLException; 33 | import java.util.List; 34 | 35 | public abstract class AbstractStage { 36 | private final Player player; 37 | private final int id; 38 | private final int initWorldIndex; 39 | 40 | private final String title; 41 | private final List messages; 42 | private final List tasks; 43 | private final List holograms; 44 | 45 | protected AbstractStage(Player player, int id, int initWorldIndex) { 46 | this.player = player; 47 | this.id = id; 48 | this.initWorldIndex = initWorldIndex; 49 | 50 | this.title = setTitle(); 51 | this.messages = setMessages(); 52 | this.tasks = setTasks(); 53 | this.holograms = setHolograms(); 54 | } 55 | 56 | /** 57 | * Sets the title of the tutorial stage 58 | * 59 | * @return title 60 | */ 61 | protected abstract String setTitle(); 62 | 63 | /** 64 | * Sets the messages of the tutorial stage 65 | * 66 | * @return messages 67 | */ 68 | protected abstract List setMessages(); 69 | 70 | /** 71 | * Sets the tasks of the tutorial stage 72 | * 73 | * @return tasks 74 | * @see AbstractTask#getAssignmentMessage() 75 | */ 76 | protected abstract List setTasks(); 77 | 78 | /** 79 | * Sets the tutorial holograms for the tutorial stage 80 | * 81 | * @return holograms 82 | */ 83 | protected abstract List setHolograms(); 84 | 85 | /** 86 | * Gets the timeline of the tutorial stage 87 | * 88 | * @return timeline 89 | */ 90 | public abstract StageTimeline getTimeline() throws IOException, SQLException; 91 | 92 | public Player getPlayer() { 93 | return player; 94 | } 95 | 96 | public int getId() { 97 | return id; 98 | } 99 | 100 | public int getInitWorldIndex() { 101 | return initWorldIndex; 102 | } 103 | 104 | public String getTitle() { 105 | return title; 106 | } 107 | 108 | public List getMessages() { 109 | return messages; 110 | } 111 | 112 | public List getTasks() { 113 | return tasks; 114 | } 115 | 116 | public List getHolograms() { 117 | return holograms; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/tutorial/stage/TutorialTimeline.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.tutorial.stage; 26 | 27 | import com.alpsbte.plotsystem.core.system.tutorial.stage.tasks.AbstractTask; 28 | 29 | public interface TutorialTimeline { 30 | 31 | /** 32 | * This method is called when a stage task is completed. 33 | * If there is no next task, the timeline will be stopped. 34 | * 35 | * @param task completed task 36 | */ 37 | void onTaskDone(AbstractTask task); 38 | 39 | /** 40 | * This method is called when a player assignment is updated. 41 | * Assignments are not tasks and do not inherit from AbstractTask. 42 | * They are in a task and are used to track the player's progress. 43 | * 44 | * @param task task of updated assignment 45 | */ 46 | void onAssignmentUpdate(AbstractTask task); 47 | 48 | /** 49 | * This method is called when the task timeline is stopped. 50 | * Every ongoing task will end and the tip holograms will be removed. 51 | */ 52 | void onStopTimeLine(); 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/tutorial/stage/TutorialWorld.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.tutorial.stage; 26 | 27 | import com.alpsbte.plotsystem.PlotSystem; 28 | import com.alpsbte.plotsystem.core.system.tutorial.utils.TutorialUtils; 29 | import com.alpsbte.plotsystem.utils.io.ConfigUtil; 30 | import org.bukkit.Bukkit; 31 | import org.bukkit.Location; 32 | import org.bukkit.configuration.ConfigurationSection; 33 | import org.bukkit.configuration.file.FileConfiguration; 34 | 35 | import java.util.Set; 36 | 37 | import static net.kyori.adventure.text.Component.text; 38 | 39 | public class TutorialWorld { 40 | private String worldName; 41 | private String playerSpawnConfigPath; 42 | private String npcSpawnConfigPath; 43 | 44 | public TutorialWorld(int tutorialId, int tutorialWorldIndex) { 45 | this(tutorialId, tutorialWorldIndex, null); 46 | } 47 | 48 | public TutorialWorld(int tutorialId, int tutorialWorldIndex, String worldName) { 49 | FileConfiguration config = ConfigUtil.getTutorialInstance().configs[tutorialId]; 50 | 51 | // Read tutorial spawn section 52 | ConfigurationSection tutorialSpawnsSection = config.getConfigurationSection(TutorialUtils.Path.TUTORIAL_WORLDS); 53 | if (tutorialSpawnsSection == null) { 54 | PlotSystem.getPlugin().getComponentLogger().warn(text("Could not find tutorial spawns section in the tutorial config!")); 55 | return; 56 | } 57 | 58 | Set tutorialSpawn = tutorialSpawnsSection.getKeys(false); 59 | if (tutorialSpawn.size() < tutorialWorldIndex) { 60 | PlotSystem.getPlugin().getComponentLogger().warn(text("Could not find spawn point " + tutorialWorldIndex + " in the tutorial config!")); 61 | return; 62 | } 63 | 64 | ConfigurationSection spawnSection = tutorialSpawnsSection.getConfigurationSection(tutorialSpawn.toArray()[tutorialWorldIndex].toString()); 65 | if (spawnSection == null) return; 66 | this.worldName = worldName == null ? spawnSection.getName() : worldName; 67 | this.playerSpawnConfigPath = spawnSection.getString(TutorialUtils.Path.TUTORIAL_WORLDS_SPAWN_PLAYER); 68 | this.npcSpawnConfigPath = spawnSection.getString(TutorialUtils.Path.TUTORIAL_WORLDS_SPAWN_NPC); 69 | } 70 | 71 | public Location getPlayerSpawnLocation() { 72 | return getSpawnLocation(worldName, playerSpawnConfigPath); 73 | } 74 | 75 | public Location getNpcSpawnLocation() { 76 | return getSpawnLocation(worldName, npcSpawnConfigPath); 77 | } 78 | 79 | public String getWorldName() { 80 | return worldName; 81 | } 82 | 83 | public static Location getSpawnLocation(String worldName, String configPath) { 84 | String[] spawnPointData = configPath.trim().split(","); 85 | return new Location(Bukkit.getWorld(worldName), 86 | Double.parseDouble(spawnPointData[0]), 87 | Double.parseDouble(spawnPointData[1]), 88 | Double.parseDouble(spawnPointData[2]), 89 | Float.parseFloat(spawnPointData[3]), 90 | Float.parseFloat(spawnPointData[4])); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/tutorial/stage/tasks/DelayTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.tutorial.stage.tasks; 26 | 27 | import com.alpsbte.plotsystem.PlotSystem; 28 | import org.bukkit.Bukkit; 29 | import org.bukkit.entity.Player; 30 | 31 | public class DelayTask extends AbstractTask { 32 | private long delay; 33 | 34 | public DelayTask(Player player) { 35 | super(player); 36 | } 37 | 38 | public DelayTask(Player player, long delay) { 39 | this(player); 40 | this.delay = delay; 41 | } 42 | 43 | @Override 44 | public void performTask() { 45 | Bukkit.getScheduler().runTaskLater(PlotSystem.getPlugin(), this::setTaskDone, 20 * delay); 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | return "DelayTask"; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/tutorial/stage/tasks/PlotPermissionChangeTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.tutorial.stage.tasks; 26 | 27 | import com.alpsbte.plotsystem.core.system.tutorial.AbstractTutorial; 28 | import com.alpsbte.plotsystem.core.system.tutorial.PlotTutorial; 29 | import org.bukkit.entity.Player; 30 | 31 | public class PlotPermissionChangeTask extends AbstractTask { 32 | private final boolean isBuildingAllowed; 33 | private final boolean isWorldEditAllowed; 34 | 35 | public PlotPermissionChangeTask(Player player, boolean allowBuilding, boolean allowWorldEdit) { 36 | super(player); 37 | isBuildingAllowed = allowBuilding; 38 | isWorldEditAllowed = allowWorldEdit; 39 | } 40 | 41 | @Override 42 | public void performTask() { 43 | PlotTutorial tutorial = (PlotTutorial) AbstractTutorial.getActiveTutorial(player.getUniqueId()); 44 | if (tutorial != null) tutorial.onPlotPermissionChange(player.getUniqueId(), isBuildingAllowed, isWorldEditAllowed); 45 | setTaskDone(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/tutorial/stage/tasks/PlotSchematicPasteTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.tutorial.stage.tasks; 26 | 27 | import com.alpsbte.plotsystem.core.system.tutorial.AbstractTutorial; 28 | import com.alpsbte.plotsystem.core.system.tutorial.PlotTutorial; 29 | import org.bukkit.entity.Player; 30 | 31 | public class PlotSchematicPasteTask extends AbstractTask { 32 | private final int schematicId; 33 | 34 | public PlotSchematicPasteTask(Player player, int schematicId) { 35 | super(player); 36 | this.schematicId = schematicId; 37 | } 38 | 39 | @Override 40 | public void performTask() { 41 | PlotTutorial tutorial = (PlotTutorial) AbstractTutorial.getActiveTutorial(player.getUniqueId()); 42 | if (tutorial != null) tutorial.onPlotSchematicPaste(player.getUniqueId(), schematicId); 43 | setTaskDone(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/tutorial/stage/tasks/TeleportTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.tutorial.stage.tasks; 26 | 27 | import com.alpsbte.plotsystem.PlotSystem; 28 | import com.alpsbte.plotsystem.core.system.tutorial.AbstractTutorial; 29 | import org.bukkit.Bukkit; 30 | import org.bukkit.Location; 31 | import org.bukkit.entity.Player; 32 | 33 | public class TeleportTask extends AbstractTask { 34 | private int tutorialWorldIndex; 35 | private Location location = null; 36 | 37 | public TeleportTask(Player player, int tutorialWorldIndex) { 38 | super(player); 39 | this.tutorialWorldIndex = tutorialWorldIndex; 40 | } 41 | 42 | public TeleportTask(Player player, Location location) { 43 | super(player); 44 | this.location = location; 45 | } 46 | 47 | @Override 48 | public void performTask() { 49 | Bukkit.getScheduler().runTask(PlotSystem.getPlugin(), () -> { 50 | if (location == null) { 51 | for (int i = 0; i < AbstractTutorial.getActiveTutorials().size(); i++) 52 | AbstractTutorial.getActiveTutorials().get(i).onSwitchWorld(player.getUniqueId(), tutorialWorldIndex); 53 | } else { 54 | player.teleport(location); 55 | } 56 | setTaskDone(); 57 | }); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/tutorial/stage/tasks/events/ChatEventTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.tutorial.stage.tasks.events; 26 | 27 | import com.alpsbte.alpslib.utils.AlpsUtils; 28 | import com.alpsbte.plotsystem.core.system.tutorial.TutorialEventListener; 29 | import com.alpsbte.plotsystem.core.system.tutorial.stage.tasks.AbstractTask; 30 | import io.papermc.paper.event.player.AsyncChatEvent; 31 | import net.kyori.adventure.text.Component; 32 | import net.kyori.adventure.text.TextComponent; 33 | import org.bukkit.entity.Player; 34 | import org.bukkit.event.Event; 35 | 36 | public class ChatEventTask extends AbstractTask implements EventTask { 37 | private final int expectedValue; 38 | private final int offset; 39 | private final BiTaskAction onChatAction; 40 | 41 | private int attemptsLeft; 42 | 43 | public ChatEventTask(Player player, Component assignmentMessage, int expectedValue, int offset, int maxAttempts, BiTaskAction onChatAction) { 44 | super(player, assignmentMessage, 1); 45 | this.expectedValue = expectedValue; 46 | this.offset = offset; 47 | this.onChatAction = onChatAction; 48 | 49 | attemptsLeft = maxAttempts; 50 | } 51 | 52 | @Override 53 | public void performTask() { 54 | TutorialEventListener.runningEventTasks.put(player.getUniqueId().toString(), this); 55 | } 56 | 57 | @Override 58 | public void performEvent(Event event) { 59 | if (event instanceof AsyncChatEvent) { 60 | AsyncChatEvent chatEvent = (AsyncChatEvent) event; 61 | chatEvent.setCancelled(true); 62 | 63 | TextComponent message = (TextComponent) chatEvent.message(); 64 | if (AlpsUtils.tryParseInt(message.content()) != null) { 65 | int value = Integer.parseInt(message.content()); 66 | if (value >= expectedValue - offset && value <= expectedValue + offset) { 67 | onChatAction.performAction(true, attemptsLeft); 68 | attemptsLeft = 0; 69 | } else { 70 | attemptsLeft--; 71 | onChatAction.performAction(false, attemptsLeft); 72 | } 73 | } 74 | 75 | if (attemptsLeft <= 0) { 76 | updateAssignments(); 77 | setTaskDone(); 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/tutorial/stage/tasks/events/EventTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.tutorial.stage.tasks.events; 26 | 27 | import org.bukkit.event.Event; 28 | 29 | public interface EventTask { 30 | /** 31 | * Performs the event check in the given task 32 | * 33 | * @param event The event to check 34 | */ 35 | void performEvent(Event event); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/tutorial/stage/tasks/events/NpcInteractEventTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.tutorial.stage.tasks.events; 26 | 27 | import com.alpsbte.plotsystem.core.system.tutorial.AbstractTutorial; 28 | import com.alpsbte.plotsystem.core.system.tutorial.TutorialEventListener; 29 | import com.alpsbte.plotsystem.core.system.tutorial.stage.tasks.AbstractTask; 30 | import com.destroystokyo.paper.event.player.PlayerUseUnknownEntityEvent; 31 | import net.kyori.adventure.text.Component; 32 | import org.bukkit.entity.Player; 33 | import org.bukkit.event.Event; 34 | 35 | public class NpcInteractEventTask extends AbstractTask implements EventTask { 36 | private final int entityId; 37 | 38 | public NpcInteractEventTask(Player player, int entityId, Component assignmentMessage) { 39 | super(player, assignmentMessage, 1); 40 | this.entityId = entityId; 41 | } 42 | 43 | @Override 44 | public void performTask() { 45 | TutorialEventListener.runningEventTasks.put(player.getUniqueId().toString(), this); 46 | } 47 | 48 | @Override 49 | public void performEvent(Event event) { 50 | if (AbstractTutorial.isPlayerIsOnInteractCoolDown(player.getUniqueId())) return; 51 | if (event instanceof PlayerUseUnknownEntityEvent && entityId == ((PlayerUseUnknownEntityEvent) event).getEntityId()) { 52 | updateAssignments(); 53 | setTaskDone(); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/tutorial/stage/tasks/events/commands/AbstractCmdEventTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.tutorial.stage.tasks.events.commands; 26 | 27 | import com.alpsbte.plotsystem.core.system.tutorial.TutorialEventListener; 28 | import com.alpsbte.plotsystem.core.system.tutorial.stage.tasks.AbstractTask; 29 | import com.alpsbte.plotsystem.core.system.tutorial.stage.tasks.events.EventTask; 30 | import net.kyori.adventure.text.Component; 31 | import org.bukkit.entity.Player; 32 | import org.bukkit.event.Event; 33 | import org.bukkit.event.player.PlayerCommandPreprocessEvent; 34 | 35 | import java.util.Arrays; 36 | 37 | public abstract class AbstractCmdEventTask extends AbstractTask implements EventTask { 38 | protected final String expectedCommand; 39 | protected final String[] args1; 40 | 41 | private final boolean isCancelCmdEvent; 42 | 43 | public AbstractCmdEventTask(Player player, String expectedCommand, Component assignmentMessage, int totalAssignments, boolean cancelCmdEvent) { 44 | this(player, expectedCommand, null, assignmentMessage, totalAssignments, cancelCmdEvent); 45 | } 46 | 47 | public AbstractCmdEventTask(Player player, String expectedCommand, String[] args1, Component assignmentMessage, int totalAssignments, boolean cancelCmdEvent) { 48 | super(player, assignmentMessage, totalAssignments); 49 | this.expectedCommand = expectedCommand; 50 | this.args1 = args1; 51 | this.isCancelCmdEvent = cancelCmdEvent; 52 | } 53 | 54 | @Override 55 | public void performTask() { 56 | TutorialEventListener.runningEventTasks.put(player.getUniqueId().toString(), this); 57 | } 58 | 59 | protected abstract void onCommand(boolean isValid, String[] args); 60 | 61 | @Override 62 | public void performEvent(Event event) { 63 | if (event instanceof PlayerCommandPreprocessEvent) { 64 | PlayerCommandPreprocessEvent cmdEvent = (PlayerCommandPreprocessEvent) event; 65 | if (cmdEvent.getMessage().toLowerCase().startsWith(expectedCommand.toLowerCase())) { 66 | if (isCancelCmdEvent) cmdEvent.setCancelled(true); 67 | 68 | // Check if the expected args are used 69 | String[] args = cmdEvent.getMessage().toLowerCase().replaceFirst(expectedCommand.toLowerCase(), "").trim().split(" "); 70 | if (args1 != null && args1.length > 0) { 71 | if (args.length == 0 || Arrays.stream(args1).noneMatch(arg -> arg.equalsIgnoreCase(args[0]))) { 72 | onCommand(false, args); 73 | return; 74 | } 75 | } 76 | onCommand(true, args); 77 | } 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/tutorial/stage/tasks/events/commands/ContinueCmdEventTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.tutorial.stage.tasks.events.commands; 26 | 27 | import com.alpsbte.plotsystem.core.system.tutorial.AbstractTutorial; 28 | import com.destroystokyo.paper.event.player.PlayerUseUnknownEntityEvent; 29 | import org.bukkit.entity.Player; 30 | import org.bukkit.event.Event; 31 | 32 | /** 33 | * This command event task is used to wait till the player clicks on the "continue" button in 34 | * the chat to proceed with the tutorial. 35 | * 36 | * @see com.alpsbte.plotsystem.core.system.tutorial.stage.tasks.message.ChatMessageTask#sendTaskMessage(Player, Object[], boolean) 37 | */ 38 | public class ContinueCmdEventTask extends AbstractCmdEventTask { 39 | private final int entityId; 40 | 41 | public ContinueCmdEventTask(Player player, int entityId) { 42 | super(player, "/tutorial", new String[]{"continue"}, null, 0, false); 43 | this.entityId = entityId; 44 | } 45 | 46 | @Override 47 | public void performEvent(Event event) { 48 | if (AbstractTutorial.isPlayerIsOnInteractCoolDown(player.getUniqueId())) return; 49 | if (event instanceof PlayerUseUnknownEntityEvent && entityId == ((PlayerUseUnknownEntityEvent) event).getEntityId()) { 50 | setTaskDone(); 51 | return; 52 | } 53 | super.performEvent(event); 54 | } 55 | 56 | @Override 57 | protected void onCommand(boolean isValid, String[] args) { 58 | if (!isValid) return; 59 | setTaskDone(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/tutorial/stage/tasks/events/commands/WandCmdEventTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.tutorial.stage.tasks.events.commands; 26 | 27 | import com.alpsbte.plotsystem.core.system.tutorial.utils.TutorialUtils; 28 | import net.kyori.adventure.text.Component; 29 | import org.bukkit.entity.Player; 30 | 31 | public class WandCmdEventTask extends AbstractCmdEventTask { 32 | public WandCmdEventTask(Player player, Component assignmentMessage) { 33 | super(player, "//wand", assignmentMessage, 1, false); 34 | } 35 | 36 | @Override 37 | protected void onCommand(boolean isValid, String[] args) { 38 | if (!isValid) return; 39 | updateAssignments(); 40 | player.playSound(player.getLocation(), TutorialUtils.Sound.ASSIGNMENT_COMPLETED, 1f, 1f); 41 | setTaskDone(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/tutorial/stage/tasks/message/CreateHologramTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.tutorial.stage.tasks.message; 26 | 27 | import com.alpsbte.plotsystem.core.system.tutorial.AbstractTutorialHologram; 28 | import com.alpsbte.plotsystem.core.system.tutorial.utils.TutorialUtils; 29 | import com.alpsbte.plotsystem.core.system.tutorial.stage.tasks.AbstractTask; 30 | import eu.decentsoftware.holograms.event.HologramClickEvent; 31 | import net.kyori.adventure.text.Component; 32 | import org.bukkit.entity.Player; 33 | import org.jetbrains.annotations.NotNull; 34 | 35 | import java.util.List; 36 | 37 | public class CreateHologramTask extends AbstractTask { 38 | private final List hologramsToCreate; 39 | private final boolean isMarkAsRead; 40 | 41 | public CreateHologramTask(Player player, List hologramsToCreate) { 42 | super(player); 43 | this.hologramsToCreate = hologramsToCreate; 44 | this.isMarkAsRead = false; 45 | } 46 | 47 | public CreateHologramTask(Player player, Component assignmentMessage, List hologramsToCreate, boolean isMarkAsRead) { 48 | super(player, assignmentMessage, hologramsToCreate.size()); 49 | this.hologramsToCreate = hologramsToCreate; 50 | this.isMarkAsRead = isMarkAsRead; 51 | } 52 | 53 | @Override 54 | public void performTask() { 55 | for (AbstractTutorialHologram hologram : hologramsToCreate) { 56 | if (isMarkAsRead) hologram.setMarkAsReadClickAction((@NotNull HologramClickEvent clickEvent) -> onMarkAsReadClick(hologram.getId())); 57 | hologram.create(player); 58 | } 59 | if (!isMarkAsRead) setTaskDone(); 60 | } 61 | 62 | private void onMarkAsReadClick(String holoId) { 63 | AbstractTutorialHologram hologram = hologramsToCreate.stream().filter(holo -> holo.getId().equals(holoId)).findFirst().orElse(null); 64 | if (hologram == null) return; 65 | player.playSound(player.getLocation(), TutorialUtils.Sound.ASSIGNMENT_COMPLETED, 1f, 1f); 66 | hologramsToCreate.remove(hologram); 67 | updateAssignments(); 68 | 69 | if (hologramsToCreate.isEmpty()) setTaskDone(); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/tutorial/stage/tasks/message/DeleteHologramTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.tutorial.stage.tasks.message; 26 | 27 | import com.alpsbte.plotsystem.core.system.tutorial.AbstractTutorial; 28 | import com.alpsbte.plotsystem.core.system.tutorial.AbstractTutorialHologram; 29 | import com.alpsbte.plotsystem.core.system.tutorial.stage.tasks.AbstractTask; 30 | import org.bukkit.entity.Player; 31 | 32 | import java.util.List; 33 | 34 | public class DeleteHologramTask extends AbstractTask { 35 | private List hologramsToRemove; 36 | 37 | public DeleteHologramTask(Player player) { 38 | this(player, null); 39 | } 40 | 41 | public DeleteHologramTask(Player player, List hologramsToRemove) { 42 | super(player); 43 | this.hologramsToRemove = hologramsToRemove; 44 | } 45 | 46 | @Override 47 | public void performTask() { 48 | if (hologramsToRemove == null) hologramsToRemove = AbstractTutorial.getActiveTutorial(player.getUniqueId()).getActiveHolograms(); 49 | for (AbstractTutorialHologram hologram : hologramsToRemove) if (hologram.isVisible(player.getUniqueId())) hologram.delete(); 50 | setTaskDone(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/core/system/tutorial/utils/TutorialNPCTurnTracker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2024, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.core.system.tutorial.utils; 26 | 27 | import com.alpsbte.plotsystem.core.system.tutorial.AbstractTutorial; 28 | import de.oliver.fancynpcs.api.FancyNpcsPlugin; 29 | import org.bukkit.Location; 30 | 31 | public class TutorialNPCTurnTracker implements Runnable { 32 | public static int turnToPlayerDistance = FancyNpcsPlugin.get().getFancyNpcConfig().getTurnToPlayerDistance();; 33 | 34 | @Override 35 | public void run() { 36 | for (AbstractTutorial tutorial : AbstractTutorial.getActiveTutorials()) { 37 | if (tutorial.getNPC() == null) continue; 38 | Location playerLoc = tutorial.getPlayer().getLocation(); 39 | Location npcLoc = tutorial.getNPC().getNpc().getData().getLocation(); 40 | if (npcLoc == null || !npcLoc.getWorld().getName() 41 | .equalsIgnoreCase(playerLoc.getWorld().getName())) continue; 42 | 43 | double distance = playerLoc.distance(npcLoc); 44 | if (Double.isNaN(distance)) continue; 45 | 46 | if (distance < turnToPlayerDistance) { 47 | Location newLoc = playerLoc.clone(); 48 | newLoc.setDirection(newLoc.subtract(npcLoc).toVector()); 49 | tutorial.getNPC().getNpc().lookAt(tutorial.getPlayer(), newLoc); 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/PacketListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.utils; 26 | 27 | import com.alpsbte.plotsystem.PlotSystem; 28 | import com.comphenix.protocol.PacketType; 29 | import com.comphenix.protocol.ProtocolManager; 30 | import com.comphenix.protocol.events.ListenerPriority; 31 | import com.comphenix.protocol.events.PacketAdapter; 32 | import com.comphenix.protocol.events.PacketEvent; 33 | 34 | public class PacketListener { 35 | public PacketListener() { 36 | ProtocolManager protocolManager = PlotSystem.DependencyManager.getProtocolManager(); 37 | if (protocolManager != null) { 38 | // Update inventory slots of player after changing client game settings 39 | protocolManager.addPacketListener(new PacketAdapter(PlotSystem.getPlugin(), 40 | ListenerPriority.LOWEST, PacketType.Play.Client.SETTINGS) { 41 | @Override 42 | public void onPacketReceiving(PacketEvent event) { 43 | Utils.updatePlayerInventorySlots(event.getPlayer()); 44 | } 45 | }); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/ShortLink.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.utils; 26 | 27 | import com.alpsbte.plotsystem.PlotSystem; 28 | import com.alpsbte.plotsystem.utils.io.ConfigPaths; 29 | import org.jetbrains.annotations.NotNull; 30 | 31 | import javax.net.ssl.HttpsURLConnection; 32 | import java.io.BufferedReader; 33 | import java.io.IOException; 34 | import java.io.InputStreamReader; 35 | import java.net.URI; 36 | import java.net.URISyntaxException; 37 | import java.net.URLEncoder; 38 | import java.nio.charset.StandardCharsets; 39 | 40 | public class ShortLink { 41 | private ShortLink() {} 42 | 43 | public static @NotNull String generateShortLink(String linkToShorten) throws IOException, URISyntaxException { 44 | String apikey = PlotSystem.getPlugin().getConfig().getString(ConfigPaths.SHORTLINK_APIKEY); 45 | String host = PlotSystem.getPlugin().getConfig().getString(ConfigPaths.SHORTLINK_HOST); 46 | String fullURL = URLEncoder.encode(linkToShorten, StandardCharsets.UTF_8); 47 | URI uri = new URI(host + "/rest/v2/short-urls/shorten?apiKey=" + apikey + "&format=txt&longUrl=" + fullURL); 48 | HttpsURLConnection con = (HttpsURLConnection) uri.toURL().openConnection(); 49 | con.setRequestMethod("GET"); 50 | con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11"); 51 | con.addRequestProperty("Accept", "*/*"); 52 | con.connect(); 53 | 54 | StringBuilder content = new StringBuilder(); 55 | try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) { 56 | String inputLine; 57 | while ((inputLine = in.readLine()) != null) { 58 | content.append(inputLine); 59 | } 60 | } 61 | con.getInputStream().close(); 62 | return content.toString(); 63 | } 64 | } 65 | 66 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/chat/ChatInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.utils.chat; 26 | 27 | import java.time.LocalDateTime; 28 | import java.util.*; 29 | 30 | public interface ChatInput { 31 | Map awaitChatInput = new HashMap<>(); 32 | 33 | LocalDateTime getDateTime(); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/chat/PlayerFeedbackChatInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.utils.chat; 26 | 27 | import com.alpsbte.plotsystem.core.system.Review; 28 | import com.alpsbte.plotsystem.utils.Utils; 29 | import com.alpsbte.plotsystem.utils.io.LangPaths; 30 | import com.alpsbte.plotsystem.utils.io.LangUtil; 31 | import net.kyori.adventure.text.Component; 32 | import org.bukkit.entity.Player; 33 | 34 | import java.time.LocalDateTime; 35 | import java.util.UUID; 36 | 37 | import static net.kyori.adventure.text.Component.text; 38 | import static net.kyori.adventure.text.format.NamedTextColor.*; 39 | 40 | public class PlayerFeedbackChatInput implements ChatInput { 41 | private final LocalDateTime dateTime; 42 | private final Review review; 43 | 44 | public PlayerFeedbackChatInput(UUID playerUUID, Review review) { 45 | this.dateTime = LocalDateTime.now(); 46 | this.review = review; 47 | awaitChatInput.put(playerUUID, this); 48 | } 49 | 50 | @Override 51 | public LocalDateTime getDateTime() { 52 | return dateTime; 53 | } 54 | 55 | public Review getReview() { 56 | return review; 57 | } 58 | 59 | public static void sendChatInputMessage(Player player) { 60 | player.sendMessage(Component.empty()); 61 | player.sendMessage(Utils.ChatUtils.getInfoFormat(text(LangUtil.getInstance().get(player, LangPaths.Message.Info.CHAT_ENTER_FEEDBACK), GRAY))); 62 | Utils.ChatUtils.sendChatInputExpiryComponent(player); 63 | player.sendMessage(Component.empty()); 64 | player.playSound(player.getLocation(), Utils.SoundUtils.NOTIFICATION_SOUND, 1f, 1f); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/chat/PlayerInviteeChatInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.utils.chat; 26 | 27 | import com.alpsbte.plotsystem.core.system.plot.Plot; 28 | import com.alpsbte.plotsystem.utils.Utils; 29 | import com.alpsbte.plotsystem.utils.io.LangPaths; 30 | import com.alpsbte.plotsystem.utils.io.LangUtil; 31 | import net.kyori.adventure.text.Component; 32 | import org.bukkit.entity.Player; 33 | 34 | import java.time.LocalDateTime; 35 | import java.util.UUID; 36 | 37 | import static net.kyori.adventure.text.Component.text; 38 | import static net.kyori.adventure.text.format.NamedTextColor.*; 39 | 40 | public class PlayerInviteeChatInput implements ChatInput { 41 | private final LocalDateTime dateTime; 42 | private final Plot plot; 43 | 44 | public PlayerInviteeChatInput(UUID playerUUID, Plot plot) { 45 | this.dateTime = LocalDateTime.now(); 46 | this.plot = plot; 47 | awaitChatInput.put(playerUUID, this); 48 | } 49 | 50 | @Override 51 | public LocalDateTime getDateTime() { 52 | return dateTime; 53 | } 54 | 55 | public Plot getPlot() { 56 | return plot; 57 | } 58 | 59 | public static void sendChatInputMessage(Player player) { 60 | player.sendMessage(Component.empty()); 61 | player.sendMessage(Utils.ChatUtils.getInfoFormat(text(LangUtil.getInstance().get(player, LangPaths.Message.Info.CHAT_ENTER_PLAYER), GRAY))); 62 | Utils.ChatUtils.sendChatInputExpiryComponent(player); 63 | player.sendMessage(Component.empty()); 64 | player.playSound(player.getLocation(), Utils.SoundUtils.NOTIFICATION_SOUND, 1f, 1f); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/conversion/MathUtils.java: -------------------------------------------------------------------------------- 1 | package com.alpsbte.plotsystem.utils.conversion; 2 | 3 | public class MathUtils { 4 | /** 5 | * Square root of 3 6 | */ 7 | public static final double ROOT3 = Math.sqrt(3); 8 | 9 | /** 10 | * Two times pi 11 | */ 12 | public static final double TAU = 2 * Math.PI; 13 | 14 | 15 | /** 16 | * Converts geographic latitude and longitude coordinates to spherical coordinates on a sphere of radius 1. 17 | * 18 | * @param geo - geographic coordinates as a double array of length 2, {longitude, latitude}, in degrees 19 | * @return the corresponding spherical coordinates in radians: {longitude, colatitude} 20 | */ 21 | public static double[] geo2Spherical(double[] geo) { 22 | double lambda = Math.toRadians(geo[0]); 23 | double phi = Math.toRadians(90 - geo[1]); 24 | return new double[]{lambda, phi}; 25 | } 26 | 27 | 28 | /** 29 | * Converts spherical coordinates to geographic coordinates on a sphere of radius 1. 30 | * 31 | * @param spherical - spherical coordinates in radians as a double array of length 2: {longitude, colatitude} 32 | * @return the corresponding geographic coordinates in degrees: {longitude, latitude} 33 | */ 34 | public static double[] spherical2Geo(double[] spherical) { 35 | double lon = Math.toDegrees(spherical[0]); 36 | double lat = 90 - Math.toDegrees(spherical[1]); 37 | return new double[]{lon, lat}; 38 | } 39 | 40 | 41 | /** 42 | * Converts spherical coordinates to Cartesian coordinates on a sphere of radius 1. 43 | * 44 | * @param spherical - spherical coordinates in radians as a double array of length 2: {longitude, colatitude} 45 | * @return the corresponding Cartesian coordinates: {x, y, z} 46 | */ 47 | public static double[] spherical2Cartesian(double[] spherical) { 48 | double sinphi = Math.sin(spherical[1]); 49 | double x = sinphi * Math.cos(spherical[0]); 50 | double y = sinphi * Math.sin(spherical[0]); 51 | double z = Math.cos(spherical[1]); 52 | return new double[]{x, y, z}; 53 | } 54 | 55 | /** 56 | * Converts Cartesian coordinates to spherical coordinates on a sphere of radius 1. 57 | * 58 | * @param cartesian - Cartesian coordinates as double array of length 3: {x, y, z} 59 | * @return the spherical coordinates of the corresponding normalized vector 60 | */ 61 | public static double[] cartesian2Spherical(double[] cartesian) { 62 | double lambda = Math.atan2(cartesian[1], cartesian[0]); 63 | double phi = Math.atan2(Math.sqrt(cartesian[0] * cartesian[0] + cartesian[1] * cartesian[1]), cartesian[2]); 64 | return new double[]{lambda, phi}; 65 | } 66 | 67 | 68 | /** 69 | * TODO produceZYZRotationMatrix javadoc 70 | * 71 | * @param a 72 | * @param b 73 | * @param c 74 | * @return 75 | */ 76 | public static double[][] produceZYZRotationMatrix(double a, double b, double c) { 77 | 78 | double sina = Math.sin(a); 79 | double cosa = Math.cos(a); 80 | double sinb = Math.sin(b); 81 | double cosb = Math.cos(b); 82 | double sinc = Math.sin(c); 83 | double cosc = Math.cos(c); 84 | 85 | double[][] mat = new double[3][3]; 86 | mat[0][0] = cosa * cosb * cosc - sinc * sina; 87 | mat[0][1] = -sina * cosb * cosc - sinc * cosa; 88 | mat[0][2] = cosc * sinb; 89 | 90 | mat[1][0] = sinc * cosb * cosa + cosc * sina; 91 | mat[1][1] = cosc * cosa - sinc * cosb * sina; 92 | mat[1][2] = sinc * sinb; 93 | 94 | mat[2][0] = -sinb * cosa; 95 | mat[2][1] = sinb * sina; 96 | mat[2][2] = cosb; 97 | 98 | return mat; 99 | } 100 | 101 | /** 102 | * Multiples the given matrix with the given vector. 103 | * The matrix is assumed to be square and the vector is assumed to be of the same dimension as the matrix. 104 | * 105 | * @param matrix - the matrix as an n*n double array 106 | * @param vector - the vector as double array of length n 107 | * @return the result of the multiplication as an array of double on length n 108 | */ 109 | public static double[] matVecProdD(double[][] matrix, double[] vector) { 110 | double[] result = new double[vector.length]; 111 | for (int i = 0; i < result.length; i++) { 112 | for (int j = 0; j < matrix[i].length; j++) { 113 | result[i] += matrix[i][j] * vector[j]; 114 | } 115 | } 116 | return result; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/conversion/projection/InvertableVectorField.java: -------------------------------------------------------------------------------- 1 | package com.alpsbte.plotsystem.utils.conversion.projection; 2 | 3 | import com.alpsbte.plotsystem.utils.conversion.MathUtils; 4 | 5 | public class InvertableVectorField { 6 | 7 | private final double[][] VECTOR_X; 8 | private final double[][] VECTOR_Y; 9 | private final int sideLength; 10 | 11 | public InvertableVectorField(double[][] vx, double[][] vy) { 12 | this.sideLength = vx.length - 1; 13 | this.VECTOR_X = vx; 14 | this.VECTOR_Y = vy; 15 | } 16 | 17 | 18 | public double[] getInterpolatedVector(double x, double y) { 19 | //scale up triangle to be triangleSize across 20 | x *= this.sideLength; 21 | y *= this.sideLength; 22 | 23 | //convert to triangle units 24 | double v = 2 * y / MathUtils.ROOT3; 25 | double u = x - v * 0.5; 26 | 27 | int u1 = (int) u; 28 | int v1 = (int) v; 29 | 30 | if (u1 < 0) { 31 | u1 = 0; 32 | } else if (u1 >= this.sideLength) { 33 | u1 = this.sideLength - 1; 34 | } 35 | 36 | if (v1 < 0) { 37 | v1 = 0; 38 | } else if (v1 >= this.sideLength - u1) { 39 | v1 = this.sideLength - u1 - 1; 40 | } 41 | 42 | double valx1; 43 | double valy1; 44 | double valx2; 45 | double valy2; 46 | double valx3; 47 | double valy3; 48 | double y3; 49 | double x3; 50 | 51 | double flip = 1; 52 | 53 | if (y < -MathUtils.ROOT3 * (x - u1 - v1 - 1) || v1 == this.sideLength - u1 - 1) { 54 | valx1 = this.VECTOR_X[u1][v1]; 55 | valy1 = this.VECTOR_Y[u1][v1]; 56 | valx2 = this.VECTOR_X[u1][v1 + 1]; 57 | valy2 = this.VECTOR_Y[u1][v1 + 1]; 58 | valx3 = this.VECTOR_X[u1 + 1][v1]; 59 | valy3 = this.VECTOR_Y[u1 + 1][v1]; 60 | 61 | y3 = 0.5 * MathUtils.ROOT3 * v1; 62 | x3 = (u1 + 1) + 0.5 * v1; 63 | } else { 64 | valx1 = this.VECTOR_X[u1][v1 + 1]; 65 | valy1 = this.VECTOR_Y[u1][v1 + 1]; 66 | valx2 = this.VECTOR_X[u1 + 1][v1]; 67 | valy2 = this.VECTOR_Y[u1 + 1][v1]; 68 | valx3 = this.VECTOR_X[u1 + 1][v1 + 1]; 69 | valy3 = this.VECTOR_Y[u1 + 1][v1 + 1]; 70 | 71 | flip = -1; 72 | y = -y; 73 | 74 | y3 = -(0.5 * MathUtils.ROOT3 * (v1 + 1)); 75 | x3 = (u1 + 1) + 0.5 * (v1 + 1); 76 | } 77 | 78 | //TODO: not sure if weights are right (but weirdly mirrors stuff so there may be simplifcation yet) 79 | double w1 = -(y - y3) / MathUtils.ROOT3 - (x - x3); 80 | double w2 = 2 * (y - y3) / MathUtils.ROOT3; 81 | double w3 = 1 - w1 - w2; 82 | 83 | return new double[]{valx1 * w1 + valx2 * w2 + valx3 * w3, valy1 * w1 + valy2 * w2 + valy3 * w3, 84 | (valx3 - valx1) * this.sideLength, this.sideLength * flip * (2 * valx2 - valx1 - valx3) / MathUtils.ROOT3, 85 | (valy3 - valy1) * this.sideLength, this.sideLength * flip * (2 * valy2 - valy1 - valy3) / MathUtils.ROOT3}; 86 | } 87 | 88 | public double[] applyNewtonsMethod(double expectedf, double expectedg, double xest, double yest, int iter) { 89 | for (int i = 0; i < iter; i++) { 90 | double[] c = this.getInterpolatedVector(xest, yest); 91 | 92 | double f = c[0] - expectedf; 93 | double g = c[1] - expectedg; 94 | double dfdx = c[2]; 95 | double dfdy = c[3]; 96 | double dgdx = c[4]; 97 | double dgdy = c[5]; 98 | 99 | double determinant = 1 / (dfdx * dgdy - dfdy * dgdx); 100 | 101 | xest -= determinant * (dgdy * f - dfdy * g); 102 | yest -= determinant * (-dgdx * f + dfdx * g); 103 | } 104 | 105 | return new double[]{xest, yest}; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/conversion/projection/OffsetProjectionTransform.java: -------------------------------------------------------------------------------- 1 | package com.alpsbte.plotsystem.utils.conversion.projection; 2 | 3 | import com.google.common.base.Preconditions; 4 | 5 | /** 6 | * Applies a simple translation to the projected space, such that: 7 | * x' = x + offsetX and y' = y + offsetY 8 | */ 9 | public class OffsetProjectionTransform extends ProjectionTransform { 10 | 11 | private final double deltaX, deltaY; 12 | 13 | /** 14 | * @param input - Input projection 15 | * @param deltaX - how much to move along the X axis 16 | * @param deltaY - how much to move along the Y axis 17 | */ 18 | public OffsetProjectionTransform(GeographicProjection input, double deltaX, double deltaY) { 19 | super(input); 20 | Preconditions.checkArgument(Double.isFinite(deltaX) && Double.isFinite(deltaY), "Projection offsets have to be finite doubles"); 21 | this.deltaX = deltaX; 22 | this.deltaY = deltaY; 23 | } 24 | 25 | @Override 26 | public double[] bounds() { 27 | double[] b = this.input.bounds(); 28 | b[0] += this.deltaX; 29 | b[1] += this.deltaY; 30 | return b; 31 | } 32 | 33 | @Override 34 | public double[] toGeo(double x, double y) throws OutOfProjectionBoundsException { 35 | return this.input.toGeo(x - this.deltaX, y - this.deltaY); 36 | } 37 | 38 | @Override 39 | public double[] fromGeo(double longitude, double latitude) throws OutOfProjectionBoundsException { 40 | double[] pos = this.input.fromGeo(longitude, latitude); 41 | pos[0] += this.deltaX; 42 | pos[1] += this.deltaY; 43 | return pos; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/conversion/projection/OutOfProjectionBoundsException.java: -------------------------------------------------------------------------------- 1 | package com.alpsbte.plotsystem.utils.conversion.projection; 2 | 3 | public final class OutOfProjectionBoundsException extends Exception { 4 | private static final OutOfProjectionBoundsException INSTANCE = new OutOfProjectionBoundsException(false); 5 | 6 | private static final boolean FAST = Boolean.parseBoolean(System.getProperty("terraplusplus.fastExcept", "true")); 7 | 8 | public static OutOfProjectionBoundsException get() { 9 | if (FAST) { 10 | return INSTANCE; 11 | } else { 12 | return new OutOfProjectionBoundsException(true); 13 | } 14 | } 15 | 16 | private OutOfProjectionBoundsException(boolean flag) { 17 | super(null, null, flag, flag); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/conversion/projection/ProjectionTransform.java: -------------------------------------------------------------------------------- 1 | package com.alpsbte.plotsystem.utils.conversion.projection; 2 | 3 | public abstract class ProjectionTransform extends GeographicProjection { 4 | protected final GeographicProjection input; 5 | 6 | /** 7 | * @param input - projection to transform 8 | */ 9 | public ProjectionTransform(GeographicProjection input) { 10 | this.input = input; 11 | } 12 | 13 | @Override 14 | public boolean upright() { 15 | return this.input.upright(); 16 | } 17 | 18 | @Override 19 | public double[] bounds() { 20 | return this.input.bounds(); 21 | } 22 | 23 | @Override 24 | public double metersPerUnit() { 25 | return this.input.metersPerUnit(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/conversion/projection/ScaleProjectionTransform.java: -------------------------------------------------------------------------------- 1 | package com.alpsbte.plotsystem.utils.conversion.projection; 2 | 3 | import com.google.common.base.Preconditions; 4 | 5 | /** 6 | * Scales the warp's projection's projected space up or down. 7 | * More specifically, it multiplies x and y by there respective scale factors. 8 | */ 9 | public class ScaleProjectionTransform extends ProjectionTransform { 10 | private final double scaleX; 11 | private final double scaleY; 12 | 13 | /** 14 | * Creates a new ScaleProjection with different scale factors for the x and y-axis. 15 | * 16 | * @param input - projection to transform 17 | * @param scaleX - scaling to apply along the x-axis 18 | * @param scaleY - scaling to apply along the y-axis 19 | */ 20 | public ScaleProjectionTransform(GeographicProjection input, double scaleX, double scaleY) { 21 | super(input); 22 | Preconditions.checkArgument(Double.isFinite(scaleX) && Double.isFinite(scaleY), "Projection scales should be finite"); 23 | Preconditions.checkArgument(scaleX != 0 && scaleY != 0, "Projection scale cannot be 0!"); 24 | this.scaleX = scaleX; 25 | this.scaleY = scaleY; 26 | } 27 | 28 | @Override 29 | public double[] toGeo(double x, double y) throws OutOfProjectionBoundsException { 30 | return this.input.toGeo(x / this.scaleX, y / this.scaleY); 31 | } 32 | 33 | @Override 34 | public double[] fromGeo(double lon, double lat) throws OutOfProjectionBoundsException { 35 | double[] p = this.input.fromGeo(lon, lat); 36 | p[0] *= this.scaleX; 37 | p[1] *= this.scaleY; 38 | return p; 39 | } 40 | 41 | @Override 42 | public boolean upright() { 43 | return (this.scaleY < 0) ^ this.input.upright(); 44 | } 45 | 46 | @Override 47 | public double[] bounds() { 48 | double[] b = this.input.bounds(); 49 | b[0] *= this.scaleX; 50 | b[1] *= this.scaleY; 51 | b[2] *= this.scaleX; 52 | b[3] *= this.scaleY; 53 | return b; 54 | } 55 | 56 | @Override 57 | public double metersPerUnit() { 58 | return this.input.metersPerUnit() / Math.sqrt((this.scaleX * this.scaleX + this.scaleY * this.scaleY) / 2); //TODO: better transform 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/conversion/projection/UprightOrientationProjectionTransform.java: -------------------------------------------------------------------------------- 1 | package com.alpsbte.plotsystem.utils.conversion.projection; 2 | 3 | /** 4 | * Mirrors the warped projection vertically. 5 | * I.E. x' = x and y' = -y 6 | */ 7 | public class UprightOrientationProjectionTransform extends ProjectionTransform { 8 | 9 | /** 10 | * @param input - projection to transform 11 | */ 12 | public UprightOrientationProjectionTransform(GeographicProjection input) { 13 | super(input); 14 | } 15 | 16 | @Override 17 | public double[] toGeo(double x, double y) throws OutOfProjectionBoundsException { 18 | return this.input.toGeo(x, -y); 19 | } 20 | 21 | @Override 22 | public double[] fromGeo(double longitude, double latitude) throws OutOfProjectionBoundsException { 23 | double[] p = this.input.fromGeo(longitude, latitude); 24 | p[1] = -p[1]; 25 | return p; 26 | } 27 | 28 | @Override 29 | public boolean upright() { 30 | return !this.input.upright(); 31 | } 32 | 33 | @Override 34 | public double[] bounds() { 35 | double[] b = this.input.bounds(); 36 | return new double[]{b[0], -b[3], b[2], -b[1]}; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/conversion/projection/airocean/ConformalEstimate.java: -------------------------------------------------------------------------------- 1 | package com.alpsbte.plotsystem.utils.conversion.projection.airocean; 2 | 3 | import com.alpsbte.plotsystem.utils.conversion.MathUtils; 4 | import com.alpsbte.plotsystem.utils.conversion.projection.InvertableVectorField; 5 | 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | import java.util.Objects; 9 | import java.util.Scanner; 10 | 11 | /** 12 | * Implementation of the Dynmaxion like conformal projection. 13 | * Slightly modifies the Dynmaxion projection to make it conformal. 14 | * 15 | * @see Airocean 16 | */ 17 | public class ConformalEstimate extends Airocean { 18 | 19 | private final InvertableVectorField inverse; 20 | 21 | private final double VECTOR_SCALE_FACTOR = 1 / 1.1473979730192934; 22 | 23 | public ConformalEstimate() { 24 | 25 | int sideLength = 256; 26 | 27 | double[][] xs = new double[sideLength + 1][]; 28 | double[][] ys = new double[xs.length][]; 29 | 30 | try (InputStream is = this.getClass().getClassLoader().getResourceAsStream("conformal.txt"); Scanner sc = new Scanner(Objects.requireNonNull(is))) { 31 | 32 | for (int u = 0; u < xs.length; u++) { 33 | double[] px = new double[xs.length - u]; 34 | double[] py = new double[xs.length - u]; 35 | xs[u] = px; 36 | ys[u] = py; 37 | } 38 | 39 | for (int v = 0; v < xs.length; v++) { 40 | for (int u = 0; u < xs.length - v; u++) { 41 | String line = sc.nextLine(); 42 | line = line.substring(1, line.length() - 3); 43 | String[] split = line.split(", "); 44 | xs[u][v] = Double.parseDouble(split[0]) * this.VECTOR_SCALE_FACTOR; 45 | ys[u][v] = Double.parseDouble(split[1]) * this.VECTOR_SCALE_FACTOR; 46 | } 47 | } 48 | } catch (IOException e) { 49 | System.err.println("Can't load conformal: " + e); 50 | } 51 | 52 | this.inverse = new InvertableVectorField(xs, ys); 53 | } 54 | 55 | @Override 56 | protected double[] triangleTransform(double[] vec) { 57 | double[] c = super.triangleTransform(vec); 58 | 59 | double x = c[0]; 60 | double y = c[1]; 61 | 62 | c[0] /= ARC; 63 | c[1] /= ARC; 64 | 65 | c[0] += 0.5; 66 | c[1] += MathUtils.ROOT3 / 6; 67 | 68 | //use another interpolated vector to have a good guess before using Newton's method 69 | //Note: forward was removed for now, will need to be added back if this improvement is ever re-implemented 70 | //c = forward.getInterpolatedVector(c[0], c[1]); 71 | //c = inverse.applyNewtonsMethod(x, y, c[0]/ARC + 0.5, c[1]/ARC + ROOT3/6, 1); 72 | 73 | //just use newtons method: slower 74 | c = this.inverse.applyNewtonsMethod(x, y, c[0], c[1], 5);//c[0]/ARC + 0.5, c[1]/ARC + ROOT3/6 75 | 76 | c[0] -= 0.5; 77 | c[1] -= MathUtils.ROOT3 / 6; 78 | 79 | c[0] *= ARC; 80 | c[1] *= ARC; 81 | 82 | return c; 83 | } 84 | 85 | @Override 86 | protected double[] inverseTriangleTransform(double x, double y) { 87 | 88 | x /= ARC; 89 | y /= ARC; 90 | 91 | x += 0.5; 92 | y += MathUtils.ROOT3 / 6; 93 | 94 | double[] c = this.inverse.getInterpolatedVector(x, y); 95 | return super.inverseTriangleTransform(c[0], c[1]); 96 | } 97 | 98 | @Override 99 | public double metersPerUnit() { 100 | return (40075017 / (2 * Math.PI)) / this.VECTOR_SCALE_FACTOR; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/conversion/projection/airocean/ModifiedAirocean.java: -------------------------------------------------------------------------------- 1 | package com.alpsbte.plotsystem.utils.conversion.projection.airocean; 2 | 3 | import com.alpsbte.plotsystem.utils.conversion.MathUtils; 4 | import com.alpsbte.plotsystem.utils.conversion.projection.OutOfProjectionBoundsException; 5 | 6 | /** 7 | * Implementation of the BTE modified Dynmaxion projection. 8 | * 9 | * @see Airocean 10 | * @see ConformalEstimate 11 | */ 12 | public class ModifiedAirocean extends ConformalEstimate { 13 | 14 | protected static final double THETA = Math.toRadians(-150); 15 | protected static final double SIN_THETA = Math.sin(THETA); 16 | protected static final double COS_THETA = Math.cos(THETA); 17 | protected static final double BERING_X = -0.3420420960118339;//-0.3282152608138795; 18 | protected static final double BERING_Y = -0.322211064085279;//-0.3281491467713469; 19 | protected static final double ARCTIC_Y = -0.2;//-0.3281491467713469; 20 | protected static final double ARCTIC_M = (ARCTIC_Y - MathUtils.ROOT3 * ARC / 4) / (BERING_X - -0.5 * ARC); 21 | protected static final double ARCTIC_B = ARCTIC_Y - ARCTIC_M * BERING_X; 22 | protected static final double ALEUTIAN_Y = -0.5000446805492526;//-0.5127463765943157; 23 | protected static final double ALEUTIAN_XL = -0.5149231279757507;//-0.4957832938238718; 24 | protected static final double ALEUTIAN_XR = -0.45; 25 | protected static final double ALEUTIAN_M = (BERING_Y - ALEUTIAN_Y) / (BERING_X - ALEUTIAN_XR); 26 | protected static final double ALEUTIAN_B = BERING_Y - ALEUTIAN_M * BERING_X; 27 | 28 | @Override 29 | public double[] fromGeo(double longitude, double latitude) { 30 | double[] c = super.fromGeo(longitude, latitude); 31 | double x = c[0]; 32 | double y = c[1]; 33 | 34 | boolean easia = this.isEurasianPart(x, y); 35 | 36 | y -= 0.75 * ARC * MathUtils.ROOT3; 37 | 38 | if (easia) { 39 | x += ARC; 40 | 41 | double t = x; 42 | x = COS_THETA * x - SIN_THETA * y; 43 | y = SIN_THETA * t + COS_THETA * y; 44 | 45 | } else { 46 | x -= ARC; 47 | } 48 | 49 | c[0] = y; 50 | c[1] = -x; 51 | return c; 52 | } 53 | 54 | @Override 55 | public double[] toGeo(double x, double y) throws OutOfProjectionBoundsException { 56 | boolean easia; 57 | if (y < 0) { 58 | easia = x > 0; 59 | } else if (y > ARC / 2) { 60 | easia = x > -MathUtils.ROOT3 * ARC / 2; 61 | } else { 62 | easia = y * -MathUtils.ROOT3 < x; 63 | } 64 | 65 | double t = x; 66 | x = -y; 67 | y = t; 68 | 69 | if (easia) { 70 | t = x; 71 | x = COS_THETA * x + SIN_THETA * y; 72 | y = COS_THETA * y - SIN_THETA * t; 73 | x -= ARC; 74 | 75 | } else { 76 | x += ARC; 77 | } 78 | 79 | y += 0.75 * ARC * MathUtils.ROOT3; 80 | 81 | //check to make sure still in right part 82 | if (easia != this.isEurasianPart(x, y)) throw OutOfProjectionBoundsException.get(); 83 | 84 | return super.toGeo(x, y); 85 | } 86 | 87 | protected boolean isEurasianPart(double x, double y) { 88 | 89 | //catch the vast majority of cases in not near boundary 90 | if (x > 0) { 91 | return false; 92 | } 93 | if (x < -0.5 * ARC) { 94 | return true; 95 | } 96 | 97 | if (y > MathUtils.ROOT3 * ARC / 4) //above arctic ocean 98 | { 99 | return x < 0; 100 | } 101 | 102 | if (y < ALEUTIAN_Y) //below bering sea 103 | { 104 | return y < (ALEUTIAN_Y + ALEUTIAN_XL) - x; 105 | } 106 | 107 | if (y > BERING_Y) { //boundary across arctic ocean 108 | 109 | if (y < ARCTIC_Y) { 110 | return x < BERING_X; //in strait 111 | } 112 | 113 | return y < ARCTIC_M * x + ARCTIC_B; //above strait 114 | } 115 | 116 | return y > ALEUTIAN_M * x + ALEUTIAN_B; 117 | } 118 | 119 | @Override 120 | public double[] bounds() { 121 | return new double[]{-1.5 * ARC * MathUtils.ROOT3, -1.5 * ARC, 3 * ARC, MathUtils.ROOT3 * ARC}; //TODO: 3*ARC is prly to high 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/enums/Category.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2021, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.utils.enums; 26 | 27 | public enum Category { 28 | ACCURACY, BLOCKPALETTE, DETAILING, TECHNIQUE, ALL 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/enums/Continent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.utils.enums; 26 | 27 | import com.alpsbte.alpslib.utils.item.ItemBuilder; 28 | import com.alpsbte.alpslib.utils.item.LoreBuilder; 29 | import com.alpsbte.plotsystem.core.system.Country; 30 | import com.alpsbte.plotsystem.utils.io.LangPaths; 31 | import com.alpsbte.plotsystem.utils.io.LangUtil; 32 | import net.kyori.adventure.text.format.NamedTextColor; 33 | import net.kyori.adventure.text.format.TextDecoration; 34 | import org.bukkit.Material; 35 | import org.bukkit.entity.Player; 36 | import org.bukkit.inventory.ItemStack; 37 | 38 | import java.util.Arrays; 39 | import java.util.List; 40 | 41 | import static net.kyori.adventure.text.Component.*; 42 | 43 | public enum Continent { 44 | EUROPE("europe", LangPaths.Continent.EUROPE), 45 | ASIA("asia", LangPaths.Continent.ASIA), 46 | AFRICA("africa", LangPaths.Continent.AFRICA), 47 | OCEANIA("oceania", LangPaths.Continent.OCEANIA), 48 | SOUTH_AMERICA("south america", LangPaths.Continent.SOUTH_AMERICA), 49 | NORTH_AMERICA("north america", LangPaths.Continent.NORTH_AMERICA); 50 | 51 | public final String databaseEnum; 52 | public final String langPath; 53 | 54 | Continent(String databaseEnum, String langPath) { 55 | this.databaseEnum = databaseEnum; 56 | // although LangPath.Continent keys match the enum name, you cannot get the value without reflection 57 | this.langPath = langPath; 58 | } 59 | 60 | public static Continent fromDatabase(String databaseEnum) { 61 | return Arrays.stream(Continent.values()).filter(c -> c.databaseEnum.equals(databaseEnum)).findFirst().orElse(null); 62 | } 63 | 64 | /** 65 | * Get menu item for this continent 66 | * 67 | * @param player Used to translate the menu item 68 | * @return Menu item 69 | */ 70 | public ItemStack getItem(Player player) { 71 | List countries = Country.getCountries(this); 72 | 73 | return new ItemBuilder(Material.COMPASS) 74 | .setName(text(LangUtil.getInstance().get(player, langPath), NamedTextColor.YELLOW).decoration(TextDecoration.BOLD, true)) 75 | .setLore(new LoreBuilder().addLines(text(countries.size() + " ", NamedTextColor.GOLD).append(text(LangUtil.getInstance().get(player, LangPaths.Country.COUNTRIES), NamedTextColor.GRAY))).build()) 76 | .build(); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/enums/PlotDifficulty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2021, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.utils.enums; 26 | 27 | public enum PlotDifficulty { 28 | EASY, MEDIUM, HARD 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/enums/Slot.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2021, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.utils.enums; 26 | 27 | public enum Slot { 28 | first_slot, second_slot, third_slot 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/enums/Status.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2021, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.utils.enums; 26 | 27 | public enum Status { 28 | unclaimed, unfinished, unreviewed, completed 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/io/ConfigUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2025, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.utils.io; 26 | 27 | import com.alpsbte.alpslib.io.config.ConfigNotImplementedException; 28 | import com.alpsbte.alpslib.io.config.ConfigurationUtil; 29 | import com.alpsbte.plotsystem.PlotSystem; 30 | import com.alpsbte.plotsystem.core.system.plot.utils.PlotUtils; 31 | import com.alpsbte.plotsystem.core.system.tutorial.utils.TutorialUtils; 32 | import org.jetbrains.annotations.NotNull; 33 | 34 | import java.io.File; 35 | import java.nio.file.Paths; 36 | 37 | import static net.kyori.adventure.text.Component.text; 38 | 39 | public class ConfigUtil { 40 | private ConfigUtil() {} 41 | private static ConfigurationUtil configUtilInstance; 42 | private static TutorialConfigurationUtil tutorialConfigUtilInstance; 43 | 44 | public static void init() throws ConfigNotImplementedException { 45 | if (configUtilInstance == null) { 46 | configUtilInstance = new ConfigurationUtil(new ConfigurationUtil.ConfigFile[]{ 47 | new ConfigurationUtil.ConfigFile(Paths.get("config.yml"), 3.0, true), 48 | new ConfigurationUtil.ConfigFile(Paths.get("commands.yml"), 1.1, false), 49 | new ConfigurationUtil.ConfigFile(Paths.get("items.yml"), 1.2, false) 50 | }); 51 | } 52 | 53 | if (tutorialConfigUtilInstance == null) { 54 | tutorialConfigUtilInstance = new TutorialConfigurationUtil(new ConfigurationUtil.ConfigFile[]{ 55 | new TutorialConfigurationUtil.ConfigFile(Paths.get("tutorial", "tutorial_beginner.yml"), 1.1, false) 56 | }); 57 | } 58 | } 59 | 60 | public static ConfigurationUtil getInstance() { 61 | return configUtilInstance; 62 | } 63 | 64 | public static TutorialConfigurationUtil getTutorialInstance() { 65 | return tutorialConfigUtilInstance; 66 | } 67 | 68 | public static class TutorialConfigurationUtil extends ConfigurationUtil { 69 | public TutorialConfigurationUtil(ConfigFile[] configs) throws ConfigNotImplementedException { 70 | super(configs); 71 | } 72 | 73 | @Override 74 | public void updateConfigFile(@NotNull ConfigFile file) { 75 | int tutorialId = file.getInt(TutorialUtils.Path.TUTORIAL_ID); 76 | 77 | File directory = Paths.get(PlotUtils.getDefaultSchematicPath(), "tutorials").toFile(); 78 | File[] files = directory.listFiles(); 79 | if (files == null) return; 80 | 81 | // Delete schematic files of the updated tutorial config after config has been updated 82 | for (File schematic : files) { 83 | if (schematic.getName().startsWith(String.valueOf(tutorialId)) && !schematic.delete()) { 84 | PlotSystem.getPlugin().getComponentLogger().error(text("Failed to delete " + schematic.getName() + " after update.")); 85 | } 86 | } 87 | 88 | super.updateConfigFile(file); 89 | } 90 | 91 | public ConfigFile getBeginnerTutorial() { 92 | return configs[0]; 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/io/LangUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2025, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.utils.io; 26 | 27 | import com.alpsbte.plotsystem.PlotSystem; 28 | import com.alpsbte.plotsystem.utils.Utils.ChatUtils; 29 | import li.cinnazeyy.langlibs.core.Language; 30 | import li.cinnazeyy.langlibs.core.file.LanguageFile; 31 | import li.cinnazeyy.langlibs.core.language.LangLibAPI; 32 | import li.cinnazeyy.langlibs.core.language.LanguageUtil; 33 | import org.bukkit.Bukkit; 34 | import org.bukkit.entity.Player; 35 | 36 | public class LangUtil extends LanguageUtil { 37 | private static LangUtil langUtilInstance; 38 | 39 | public static void init() { 40 | if (langUtilInstance != null) return; 41 | LangLibAPI.register(PlotSystem.getPlugin(), new LanguageFile[]{ 42 | new LanguageFile(Language.en_GB, 2.2), 43 | new LanguageFile(Language.de_DE, 2.2, "de_AT", "de_CH"), 44 | new LanguageFile(Language.fr_FR, 2.3, "fr_CA"), 45 | new LanguageFile(Language.pt_PT, 2.2, "pt_BR"), 46 | new LanguageFile(Language.ko_KR, 2.2), 47 | new LanguageFile(Language.ru_RU, 2.2, "ba_RU", "tt_RU"), 48 | new LanguageFile(Language.zh_CN, 2.2), 49 | new LanguageFile(Language.zh_TW, 2.3, "zh_HK"), 50 | }); 51 | langUtilInstance = new LangUtil(); 52 | } 53 | 54 | public LangUtil() { 55 | super(PlotSystem.getPlugin()); 56 | } 57 | 58 | public void broadcast(String key, String... args) { 59 | for (Player player : Bukkit.getOnlinePlayers()) { 60 | player.sendMessage(ChatUtils.getInfoFormat(get(player, key, args))); 61 | } 62 | } 63 | 64 | public static LangUtil getInstance() { 65 | return langUtilInstance; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/io/TutorialPaths.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.utils.io; 26 | 27 | public abstract class TutorialPaths { 28 | public static final class Beginner { 29 | private static final String BEGINNER = "beginner."; 30 | public static final String PLOT_OUTLINES = BEGINNER + "plot-outlines"; 31 | private static final String TELEPORT_COORDINATES = BEGINNER + "building-coordinates."; 32 | public static final String POINT_1 = TELEPORT_COORDINATES + "point-1"; 33 | public static final String POINT_2 = TELEPORT_COORDINATES + "point-2"; 34 | public static final String POINT_3 = TELEPORT_COORDINATES + "point-3"; 35 | public static final String POINT_4 = TELEPORT_COORDINATES + "point-4"; 36 | public static final String BASE_BLOCK = BEGINNER + "base-block"; 37 | public static final String BASE_BLOCK_ID = BEGINNER + "base-block-id"; 38 | public static final String HEIGHT = BEGINNER + "height"; 39 | public static final String HEIGHT_OFFSET = BEGINNER + "height-offset"; 40 | public static final String WINDOW_POINTS = BEGINNER + "window-points"; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/items/BaseItems.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2025, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.utils.items; 26 | 27 | import com.alpsbte.alpslib.utils.item.ItemBuilder; 28 | import com.alpsbte.plotsystem.utils.io.ConfigUtil; 29 | import org.bukkit.Material; 30 | import org.bukkit.inventory.ItemStack; 31 | 32 | public enum BaseItems { 33 | COMPANION_ITEM("companion-item"), 34 | 35 | LEADERBOARD_PLOT("leaderboard-plot"), 36 | LEADERBOARD_SCORE("leaderboard-score"), 37 | 38 | PLOT_UNFINISHED("plot-unfinished"), 39 | PLOT_UNREVIEWED("plot-unreviewed"), 40 | PLOT_COMPLETED("plot-completed"), 41 | 42 | MENU_ERROR("menu-error"), 43 | MENU_CLOSE("menu-close"), 44 | 45 | REVIEW_ITEM("review-item"), 46 | REVIEW_ACCURACY("review-accuracy"), 47 | REVIEW_BLOCK_PALETTE("review-block-palette"), 48 | REVIEW_DETAILING("review-detailing"), 49 | REVIEW_TECHNIQUE("review-technique"), 50 | REVIEW_POINT_ZERO("review-point-zero"), 51 | REVIEW_POINT_ONE("review-point-one"), 52 | REVIEW_POINT_TWO("review-point-two"), 53 | REVIEW_POINT_THREE("review-point-three"), 54 | REVIEW_POINT_FOUR("review-point-four"), 55 | REVIEW_POINT_FIVE("review-point-five"), 56 | REVIEW_SUBMIT("review-submit"), 57 | REVIEW_CANCEL("review-cancel"), 58 | REVIEW_INFO_PLOT("review-info-plot"), 59 | 60 | SETTINGS_ITEM("settings-item"), 61 | RANDOM_PLOT_ITEM("random-plot-item"); 62 | 63 | final ItemStack itemStack; 64 | 65 | BaseItems(String configPath) { 66 | String materialString = ConfigUtil.getInstance().configs[2].getString(configPath + ".material"); 67 | Material material = Material.getMaterial(materialString == null ? "" : materialString, false); 68 | material = material == null ? Material.BARRIER : material; 69 | 70 | itemStack = new ItemBuilder(material).setItemModel(ConfigUtil.getInstance().configs[2].get(configPath + ".modelId")).build(); 71 | } 72 | 73 | public ItemStack getItem() { 74 | return itemStack; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/alpsbte/plotsystem/utils/items/CustomHeads.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright © 2023, Alps BTE 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.alpsbte.plotsystem.utils.items; 26 | 27 | public enum CustomHeads { 28 | WHITE_CONCRETE("8614"), 29 | GREEN_CONCRETE("8621"), 30 | YELLOW_CONCRETE("8613"), 31 | RED_CONCRETE("8616"), 32 | WORKBENCH("24180"), 33 | ADD_BUTTON("9237"), 34 | REMOVE_BUTTON("9243"), 35 | BACK_BUTTON("9226"), 36 | NEXT_BUTTON("9223"), 37 | PREVIOUS_BUTTON("9226"), 38 | INFO_BUTTON("46488"), 39 | GLOBE_HEAD("49973"), 40 | PLOT_TYPE_BUTTON("4159"), 41 | FOCUS_MODE_BUTTON("38199"), 42 | CITY_INSPIRATION_MODE_BUTTON("38094"); 43 | 44 | final String id; 45 | 46 | CustomHeads(String id) { 47 | this.id = id; 48 | } 49 | 50 | public String getId() { 51 | return id; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/resources/commands.yml: -------------------------------------------------------------------------------- 1 | # ----------------------------------------------------- 2 | # | Plot System - by Alps BTE 3 | # ----------------------------------------------------- 4 | # | [Github Repo] https://github.com/AlpsBTE/PlotSystem 5 | # | [Config Documentation] https://github.com/AlpsBTE/PlotSystem/wiki/Configuration 6 | # | [Contacts - Discord] R3tuxn#7169, Cinnazeyy#2440 7 | # ----------------------------------------------------- 8 | 9 | # Allow /editplot on plots for reviewers 10 | # NOTE: Reviewers will be able to modify plots 11 | editplot-enabled: false 12 | 13 | # Blocked commands for plot owner and plot members on plots 14 | blocked-commands-builders: 15 | - /cmd1 16 | 17 | 18 | # NOTE: Do not change 19 | config-version: 1.1 -------------------------------------------------------------------------------- /src/main/resources/items.yml: -------------------------------------------------------------------------------- 1 | companion-item: 2 | material: NETHER_STAR 3 | modelId: '' 4 | 5 | leaderboard-plot: 6 | material: NETHER_STAR 7 | modelId: '' 8 | leaderboard-score: 9 | material: NETHER_STAR 10 | modelId: '' 11 | 12 | plot-unfinished: 13 | material: ORANGE_WOOL 14 | modelId: '' 15 | plot-unreviewed: 16 | material: FILLED_MAP 17 | modelId: '' 18 | plot-completed: 19 | material: GREEN_WOOL 20 | modelId: '' 21 | 22 | menu-error: 23 | material: BARRIER 24 | modelId: '' 25 | menu-close: 26 | material: BARRIER 27 | modelId: '' 28 | 29 | review-item: 30 | material: BOOK 31 | modelId: '' 32 | review-accuracy: 33 | material: ARROW 34 | modelId: '' 35 | review-block-palette: 36 | material: PAINTING 37 | modelId: '' 38 | review-detailing: 39 | material: ENDER_EYE 40 | modelId: '' 41 | review-technique: 42 | material: WOODEN_AXE 43 | modelId: '' 44 | review-point-zero: 45 | material: LIGHT_GRAY_WOOL 46 | modelId: '' 47 | review-point-one: 48 | material: RED_WOOL 49 | modelId: '' 50 | review-point-two: 51 | material: ORANGE_WOOL 52 | modelId: '' 53 | review-point-three: 54 | material: YELLOW_WOOL 55 | modelId: '' 56 | review-point-four: 57 | material: GREEN_WOOL 58 | modelId: '' 59 | review-point-five: 60 | material: LIME_WOOL 61 | modelId: '' 62 | review-submit: 63 | material: GREEN_CONCRETE 64 | modelId: '' 65 | review-cancel: 66 | material: RED_CONCRETE 67 | modelId: '' 68 | review-info-plot: 69 | material: MAP 70 | modelId: '' 71 | 72 | settings-item: 73 | material: COMPARATOR 74 | modelId: '' 75 | random-plot-item: 76 | material: COMPARATOR 77 | modelId: '' 78 | # NOTE: Do not change 79 | config-version: 1.2 -------------------------------------------------------------------------------- /src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | main: com.alpsbte.plotsystem.PlotSystem 2 | version: 4.1.3 3 | api-version: "1.21" 4 | name: Plot-System 5 | author: R3tuxn & Cinnazeyy 6 | softdepend: [ LangLibs, FancyNpcs, VoidGen, FastAsyncWorldEdit, Multiverse-Core, WorldEdit, 7 | DecentHolograms, WorldGuard, WorldGuardExtraFlags, HeadDatabase, ProtocolLib, ParticleNativeAPI ] 8 | 9 | commands: 10 | cancelchat: 11 | description: Cancels the chat input. 12 | usage: /cancelchat 13 | companion: 14 | description: Opens the Companion menu. 15 | usage: /companion 16 | plots: 17 | description: Shows all plots of the given player. 18 | usage: /plots, /plots 19 | tpll: 20 | description: Teleport to a position in the plot, using irl coordinates 21 | usage: /tpll 22 | p: 23 | description: List all plot commands. 24 | usage: /p help 25 | plot: 26 | description: List all plot commands. 27 | usage: /plot help 28 | review: 29 | description: Opens the review or review plot menu. 30 | usage: /review 31 | undoreview: 32 | description: Undo a review of a plot. 33 | usage: /undoreview 34 | editfeedback: 35 | description: Updates the feedback of a plot. 36 | usage: /editfeedback 37 | editplot: 38 | description: Enable/disable build permissions for reviewers on a plot. 39 | usage: /editplot 40 | deleteplot: 41 | description: Delete a plot from the system. 42 | usage: /deleteplot 43 | setleaderboard: 44 | description: Sets the position of a leaderboard. 45 | usage: /setleaderboard 46 | preload: 47 | description: Reload configs and leaderboards 48 | usage: /preload 49 | pss: 50 | description: Command for setting up the database. 51 | usage: /pss help 52 | tutorial: 53 | description: Start the Beginner Tutorial process. Only for test usages. 54 | usage: /tutorial 55 | permissions: 56 | plotsystem.plot: 57 | description: Builder permissions 58 | plotsystem.review: 59 | description: Reviewer permissions 60 | plotsystem.admin: 61 | description: Administrator permissions -------------------------------------------------------------------------------- /src/main/resources/tutorial/schematics/0-0.schematic.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlpsBTE/Plot-System/68964d7c6d48e2971831be419a28d439f24d4cba/src/main/resources/tutorial/schematics/0-0.schematic.gz -------------------------------------------------------------------------------- /src/main/resources/tutorial/schematics/0-1.schematic.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlpsBTE/Plot-System/68964d7c6d48e2971831be419a28d439f24d4cba/src/main/resources/tutorial/schematics/0-1.schematic.gz -------------------------------------------------------------------------------- /src/main/resources/tutorial/schematics/0-2.schematic.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlpsBTE/Plot-System/68964d7c6d48e2971831be419a28d439f24d4cba/src/main/resources/tutorial/schematics/0-2.schematic.gz -------------------------------------------------------------------------------- /src/main/resources/tutorial/schematics/0-3.schematic.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlpsBTE/Plot-System/68964d7c6d48e2971831be419a28d439f24d4cba/src/main/resources/tutorial/schematics/0-3.schematic.gz -------------------------------------------------------------------------------- /src/main/resources/tutorial/schematics/0-4.schematic.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlpsBTE/Plot-System/68964d7c6d48e2971831be419a28d439f24d4cba/src/main/resources/tutorial/schematics/0-4.schematic.gz -------------------------------------------------------------------------------- /src/main/resources/tutorial/schematics/0-5.schematic.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlpsBTE/Plot-System/68964d7c6d48e2971831be419a28d439f24d4cba/src/main/resources/tutorial/schematics/0-5.schematic.gz -------------------------------------------------------------------------------- /src/main/resources/tutorial/schematics/0-6.schematic.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlpsBTE/Plot-System/68964d7c6d48e2971831be419a28d439f24d4cba/src/main/resources/tutorial/schematics/0-6.schematic.gz -------------------------------------------------------------------------------- /src/main/resources/tutorial/schematics/0-7.schematic.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlpsBTE/Plot-System/68964d7c6d48e2971831be419a28d439f24d4cba/src/main/resources/tutorial/schematics/0-7.schematic.gz -------------------------------------------------------------------------------- /src/main/resources/tutorial/schematics/0-env.schematic.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlpsBTE/Plot-System/68964d7c6d48e2971831be419a28d439f24d4cba/src/main/resources/tutorial/schematics/0-env.schematic.gz -------------------------------------------------------------------------------- /src/main/resources/tutorial/tutorial_beginner.yml: -------------------------------------------------------------------------------- 1 | # ----------------------------------------------------- 2 | # | Plot System - by Alps BTE 3 | # ----------------------------------------------------- 4 | # | [Github Repo] https://github.com/AlpsBTE/PlotSystem 5 | # | [Config Documentation] https://github.com/AlpsBTE/PlotSystem/wiki/Configuration 6 | # | [Contacts - Discord] R3tuxn#7169, Cinnazeyy#2440 7 | # | 8 | # | [Tutorial Config - Beginner] 9 | # | 10 | # | IMPORTANT: THIS CONFIG FILE SHOULD NOT BE EDITED IF YOU DON´T KNOW WHAT YOU ARE DOING! 11 | # | Any changes may lead to unexpected behaviours or issues. 12 | # ----------------------------------------------------- 13 | tutorial-id: 0 14 | tutorial-item-name: "BRICKS" 15 | tutorial-stages: 10 16 | 17 | # Spawn points for the player and the NPC (x, y, z, yaw, pitch) 18 | # To define the plot world spawn, use the key word ´plot´ 19 | tutorial-worlds: 20 | spawn_start: 21 | spawn-player: '580.5, 42.0, 538.5, -65, 0' 22 | spawn-npc: '591.5, 43.0, 542.5, 115.8, 3.0' 23 | plot: 24 | spawn-player: '3693357.5, 11.0, -4531324.5, 150, 0' 25 | spawn-npc: '3693348.5, 11.0, -4531329.5, -60, 0' 26 | spawn_end: 27 | spawn-player: '550.5, 53.0, 576.5, 135.3, 2.2' 28 | spawn-npc: '545.5, 52.0, 570.5, -39.3, -3.6' 29 | 30 | # Tip hologram coordinates (x, y, z) 31 | tip-hologram-coordinates: 32 | - '3693351.5, 14, -4531334.5' 33 | - '3693362.5, 21, -4531331.5' 34 | - '3693363.5, 14, -4531330.5' 35 | - '3693363.5, 17, -4531325.5' 36 | - '3693358.5, 24, -4531334.5' 37 | - '3693355.5, 14, -4531329.5' 38 | - '3693365.5, 14, -4531325.5' 39 | - '3693351.5, 14, -4531331.5' 40 | - '3693365.5, 14, -4531325.5' 41 | - '3693360.5, 22, -4531330.5' 42 | - '3693356.5, 14, -4531329.5' 43 | - '3693365.5, 14, -4531325.5' 44 | - '3693355.5, 14, -4531329.5' 45 | - '3693351.5, 14, -4531334.5' 46 | 47 | # Documentation links which can be opened by clicking on ´Read More´ on tip holograms. 48 | documentation-links: 49 | - 'https://docs.alps-bte.com/' 50 | - 'https://minecraft-worldedit.fandom.com/wiki///replace' 51 | - 'https://minecraft-worldedit.fandom.com/wiki///stack' 52 | - 'https://cdn.buildtheearth.net/static/tpll.mp4' 53 | - 'https://youtu.be/eYpry4CZ1uQ?si=qZe9i2eMIbzqS_AF&t=122' 54 | - 'https://youtu.be/VX7E7o9zLyI?si=krc0OPTMEjTUrtG7' 55 | - 'https://alps-bte.com/en/' 56 | 57 | # ----------------------------------------------------- 58 | # | Beginner Tutorial 59 | # ----------------------------------------------------- 60 | beginner: 61 | # Outlines of the plot area the player can build and interact 62 | plot-outlines: '3693351.0,-4531330.0|3693370.0,-4531324.0|3693375.0,-4531339.0|3693355.0,-4531346.0' 63 | # Coordinates for the building outlines 64 | building-coordinates: 65 | point-1: '3693354.0,-4531333.0' 66 | point-2: '3693367.0,-4531328.0' 67 | point-3: '3693370.0,-4531337.0' 68 | point-4: '3693357.0,-4531342.0' 69 | # BaseBlock for the building outline 70 | base-block: 'WHITE_WOOL' 71 | base-block-id: 35 72 | # Height of the plot building, which must be calculated 73 | height: 7 74 | height-offset: 1 75 | # Blocks and positions for the windows that needs to be placed 76 | # Get material name from https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html 77 | # NOTE: Material needs to be placeable block! 78 | window-points: 79 | - '3693356.0;12.0;-4531332.0;minecraft:white_banner' 80 | - '3693357.0;12.0;-4531332.0;minecraft:white_banner' 81 | - '3693356.0;13.0;-4531332.0;minecraft:iron_trapdoor[half=bottom]' 82 | - '3693357.0;13.0;-4531332.0;minecraft:iron_trapdoor[half=bottom]' 83 | - '3693356.0;15.0;-4531332.0;minecraft:white_banner' 84 | - '3693356.0;16.0;-4531332.0;minecraft:quartz_slab[type=top]' 85 | 86 | config-version: 1.1 -------------------------------------------------------------------------------- /src/main/resources/tutorial/tutorial_template.yml: -------------------------------------------------------------------------------- 1 | # ----------------------------------------------------- 2 | # | Plot System - by Alps BTE 3 | # ----------------------------------------------------- 4 | # | [Github Repo] https://github.com/AlpsBTE/PlotSystem 5 | # | [Config Documentation] https://github.com/AlpsBTE/PlotSystem/wiki/Configuration 6 | # | [Contacts - Discord] R3tuxn#7169, Cinnazeyy#2440 7 | # | 8 | # | [Tutorial Config - XYZ] 9 | # | 10 | # | IMPORTANT: THIS CONFIG FILE SHOULD NOT BE EDITED IF YOU DON´T KNOW WHAT YOU ARE DOING! 11 | # | Any changes may lead to unexpected behaviours or issues. 12 | # ----------------------------------------------------- 13 | tutorial-id: 'id' 14 | tutorial-item-name: "material_name" 15 | tutorial-stages: 1 16 | 17 | # Spawn points for the player and the NPC (x, y, z, yaw, pitch) 18 | # To define the plot world spawn, use the key word ´plot´ 19 | tutorial-spawns: 20 | hub: 21 | spawn-player: '' 22 | spawn-npc: '' 23 | plot: 24 | spawn-player: '' 25 | spawn-npc: '' 26 | 27 | plot-outlines: '' 28 | 29 | # Tip hologram coordinates (x, y, z) 30 | tip-hologram-coordinates: 31 | - '' 32 | 33 | # Documentation links which can be opened by clicking on ´Read More´ on tip holograms. 34 | documentation-links: 35 | - '' 36 | 37 | # ----------------------------------------------------- 38 | # | XYZ Tutorial 39 | # ----------------------------------------------------- 40 | tutorial: 41 | 42 | 43 | config-version: 1.0 --------------------------------------------------------------------------------