├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── config.yml │ └── feature_request.yml └── workflows │ └── build.yml ├── .gitignore ├── LICENSE ├── README.md ├── build.gradle.kts ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle.kts └── src └── main ├── java └── me │ └── zetastormy │ └── akropolis │ ├── AkropolisPlugin.java │ ├── AkropolisPluginLoader.java │ ├── Permissions.java │ ├── action │ ├── Action.java │ ├── ActionManager.java │ └── actions │ │ ├── ActionbarAction.java │ │ ├── BroadcastMessageAction.java │ │ ├── CloseInventoryAction.java │ │ ├── CommandAction.java │ │ ├── ConsoleCommandAction.java │ │ ├── GamemodeAction.java │ │ ├── MenuAction.java │ │ ├── MessageAction.java │ │ ├── PotionEffectAction.java │ │ ├── ServerAction.java │ │ ├── SoundAction.java │ │ └── TitleAction.java │ ├── command │ ├── CommandManager.java │ ├── CustomCommand.java │ ├── InjectableCommand.java │ └── commands │ │ ├── AkropolisCommand.java │ │ ├── ClearchatCommand.java │ │ ├── FlyCommand.java │ │ ├── LobbyCommand.java │ │ ├── LockchatCommand.java │ │ ├── SetLobbyCommand.java │ │ ├── VanishCommand.java │ │ └── gamemode │ │ ├── AdventureCommand.java │ │ ├── CreativeCommand.java │ │ ├── GamemodeCommand.java │ │ ├── SpectatorCommand.java │ │ └── SurvivalCommand.java │ ├── config │ ├── ConfigHandler.java │ ├── ConfigManager.java │ ├── ConfigType.java │ └── Message.java │ ├── cooldown │ └── CooldownManager.java │ ├── hook │ ├── HooksManager.java │ ├── PluginHook.java │ └── hooks │ │ └── head │ │ ├── BaseHead.java │ │ ├── DatabaseHead.java │ │ └── HeadHook.java │ ├── inventory │ ├── AbstractInventory.java │ ├── ClickAction.java │ ├── InventoryBuilder.java │ ├── InventoryItem.java │ ├── InventoryListener.java │ ├── InventoryManager.java │ ├── InventoryTask.java │ └── inventories │ │ └── CustomGUI.java │ ├── module │ ├── Module.java │ ├── ModuleManager.java │ ├── ModuleType.java │ └── modules │ │ ├── chat │ │ ├── AntiSwear.java │ │ ├── AutoBroadcast.java │ │ ├── ChatCommandBlock.java │ │ ├── ChatLock.java │ │ └── groups │ │ │ ├── ChatGroup.java │ │ │ └── ChatGroups.java │ │ ├── hologram │ │ ├── Hologram.java │ │ └── HologramManager.java │ │ ├── hotbar │ │ ├── HotbarItem.java │ │ ├── HotbarManager.java │ │ └── items │ │ │ ├── CustomItem.java │ │ │ └── PlayerHider.java │ │ ├── player │ │ ├── DoubleJump.java │ │ ├── PlayerListener.java │ │ ├── PlayerOffHandSwap.java │ │ └── PlayerVanish.java │ │ ├── visual │ │ ├── bossbar │ │ │ └── BossBarBroadcast.java │ │ ├── nametag │ │ │ ├── NametagHelper.java │ │ │ ├── NametagManager.java │ │ │ └── NametagUpdateTask.java │ │ ├── scoreboard │ │ │ ├── ScoreboardHelper.java │ │ │ ├── ScoreboardManager.java │ │ │ └── ScoreboardUpdateTask.java │ │ └── tablist │ │ │ ├── TablistHelper.java │ │ │ ├── TablistManager.java │ │ │ └── TablistUpdateTask.java │ │ └── world │ │ ├── AntiWorldDownloader.java │ │ ├── Launchpad.java │ │ ├── LobbySpawn.java │ │ └── WorldProtect.java │ └── util │ ├── ItemStackBuilder.java │ ├── PlaceholderUtil.java │ └── TextUtil.java └── resources ├── commands.yml ├── config.yml ├── data.yml ├── messages.yml ├── paper-plugin.yml └── serverselector.yml /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug report 2 | description: Create a bug report and help us improve. 3 | title: "A brief description of your report" 4 | labels: [ bug ] 5 | assignees: 6 | - zetastormy 7 | body: 8 | - type: textarea 9 | attributes: 10 | label: Describe the bug 11 | description: "A clear and concise description of what the bug is." 12 | validations: 13 | required: true 14 | 15 | - type: input 16 | attributes: 17 | label: Link to latest.log file 18 | description: "Reproduce your problem, upload your `/logs/latest.log` file to https://mclo.gs/ or your prefered bin site, click \"Save\" button, and paste the URL below." 19 | validations: 20 | required: true 21 | 22 | - type: textarea 23 | attributes: 24 | label: Steps to reproduce 25 | description: | 26 | - Describe the steps to reproduce the problem in a clear and detailed way. For example: 27 | 1. Change '...' 28 | 2. Enter '....' 29 | 3. Execute '....' 30 | 4. See error 31 | validations: 32 | required: true 33 | 34 | - type: input 35 | attributes: 36 | label: Expected behavior 37 | description: "A clear and concise description of what you expected to happen." 38 | validations: 39 | required: true 40 | 41 | - type: textarea 42 | attributes: 43 | label: Technical information 44 | description: | 45 | - Server software: [e.g. Paper, Spigot] 46 | - Server version: [e.g. 1.12.2, 1.8.8] 47 | - Plugin version: [e.g. 3.5.5, 3.6.0] 48 | validations: 49 | required: true 50 | 51 | - type: textarea 52 | attributes: 53 | label: Additional context 54 | description: "Add any other context about the problem here." 55 | validations: 56 | required: false -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: Feature request 2 | description: Suggest an idea for this project. 3 | title: "A brief description of your request" 4 | labels: [ enhancement ] 5 | assignees: 6 | - zetastormy 7 | body: 8 | - type: textarea 9 | attributes: 10 | label: Is your feature request related to a problem? 11 | description: "Please describe a clear and concise description of what the problem is. Ex. I'm always frustrated when [...]" 12 | validations: 13 | required: true 14 | 15 | - type: textarea 16 | attributes: 17 | label: Describe the solution you'd like 18 | description: "A clear and concise description of what you want to happen." 19 | validations: 20 | required: true 21 | 22 | - type: textarea 23 | attributes: 24 | label: Describe alternatives you've considered 25 | description: "A clear and concise description of any alternative solutions or features you've considered." 26 | validations: 27 | required: true 28 | 29 | - type: textarea 30 | attributes: 31 | label: Additional context 32 | description: "Add any other context or screenshots about the feature request here." 33 | validations: 34 | required: false -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build Akropolis with Gradle. 2 | # It will be compiled against Java 21. 3 | name: Build 4 | on: 5 | push: 6 | branches: [ develop ] 7 | pull_request: 8 | branches: [ develop ] 9 | 10 | jobs: 11 | # Builds Akropolis in recommended JDK version. 12 | build-plugin: 13 | runs-on: ubuntu-latest 14 | 15 | # For Minecraft 1.21, Java 21+ is needed/recommended. 16 | strategy: 17 | matrix: 18 | java_version: [ 21 ] 19 | 20 | steps: 21 | - name: Checkout GitHub repository 22 | uses: actions/checkout@v4 23 | 24 | - name: Gradle Wrapper Validation 25 | uses: gradle/actions/wrapper-validation@v3 26 | 27 | - name: Cleanup old JARs 28 | run: rm -f build/libs/*.jar 29 | 30 | - name: Set up JDK ${{ matrix.java_version }} 31 | uses: actions/setup-java@v4 32 | with: 33 | java-version: ${{ matrix.java_version }} 34 | distribution: temurin 35 | cache: gradle 36 | 37 | - name: Build plugin 38 | run: ./gradlew shadowJar 39 | 40 | - name: Cleanup Gradle Cache 41 | # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. 42 | # Restoring these files from a GitHub Actions cache might cause problems for future builds. 43 | run: | 44 | rm -f ~/.gradle/caches/modules-2/modules-2.lock 45 | rm -f ~/.gradle/caches/modules-2/gc.properties 46 | 47 | - name: Upload artifacts 48 | uses: actions/upload-artifact@v4 49 | with: 50 | name: Akropolis Artifact 51 | path: build/libs/*.jar 52 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### Mac ### 2 | .DS_Store 3 | 4 | ### Maven ### 5 | target/ 6 | dependency-reduced-pom.xml 7 | pom.xml.versionsBackup 8 | 9 | ### Visual Studio Code ### 10 | .vscode/* 11 | 12 | ### IntelliJ IDEA ### 13 | .idea/ 14 | *.iws 15 | out/ 16 | *.iml 17 | .idea_modules/ 18 | atlassian-ide-plugin.xml 19 | 20 | ### Eclipse ### 21 | .classpath 22 | .project 23 | codetemplates.xml 24 | bin/ 25 | .metadata 26 | tmp/ 27 | *.tmp 28 | *.bak 29 | *.swp 30 | *~.nib 31 | local.properties 32 | .settings/ 33 | .loadpath 34 | .recommenders 35 | 36 | ## External tools ## 37 | .externalToolBuilders/ 38 | 39 | # Locally stored "Eclipse launch configurations" 40 | *.launch 41 | 42 | # PyDev specific (Python IDE for Eclipse) 43 | *.pydevproject 44 | 45 | # CDT-specific (C/C++ Development Tooling) 46 | .cproject 47 | 48 | # CDT- autotools 49 | .autotools 50 | 51 | # Java annotation processor (APT) 52 | .factorypath 53 | 54 | # PDT-specific (PHP Development Tools) 55 | .buildpath 56 | 57 | # sbteclipse plugin 58 | .target 59 | 60 | # Tern plugin 61 | .tern-project 62 | 63 | # TeXlipse plugin 64 | .texlipse 65 | 66 | # STS (Spring Tool Suite) 67 | .springBeans 68 | 69 | # Code Recommenders 70 | .recommenders/ 71 | 72 | # Annotation Processing 73 | .apt_generated/ 74 | 75 | # Scala IDE specific (Scala & Java development for Eclipse) 76 | .cache-main 77 | .scala_dependencies 78 | .worksheet 79 | 80 | # Annotation Processing 81 | .apt_generated 82 | .sts4-cache/ 83 | 84 | # Package Files # 85 | *.jar 86 | *.war 87 | *.ear 88 | /lib 89 | **/*~ 90 | 91 | ### Gradle ### 92 | .gradle 93 | build/ 94 | !gradle-wrapper.jar 95 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Akropolis banner](https://user-images.githubusercontent.com/56933557/188349705-b1f1eb56-8e4b-42d2-b99d-f21552ec84c2.png) 2 | 3 | Akropolis is a modern Minecraft hub server solution that is based on DeluxeHub by ItsLewizzz. 4 | It contains almost all of its features and configuration files are almost the same, so you can just 5 | drop your configuration into the plugin's directory, make a few modifications and use it. 6 | 7 | The main difference between Akropolis and DeluxeHub is that Akropolis uses more modern technologies, like MiniMessage, 8 | the Paper API and updated Java versions. While this give us some performance and usability benefits, it also means 9 | that we won't be giving support to older versions of Minecraft and other Minecraft server software that isn't derivated 10 | from Paper, which is not the case of DeluxeHub. 11 | Simply use what you feel meets your needs. 12 | 13 | ## How to 14 | 15 | ### Install 16 | 17 | To use this plugin just a grab a binary from the [releases page](https://github.com/devblook/akropolis/releases) 18 | or [compile it](#compile) yourself and drop it into your `plugins/` directory. Take in mind that you will need to be 19 | running Paper 1.21+ so Akropolis can run properly. You can download Paper from [here](https://papermc.io/downloads). 20 | 21 | ### Compile 22 | 23 | Compiling Akropolis is pretty simple, just one command, and you're ready to go: 24 | 25 | **Linux (and other UNIX derivatives):** 26 | 27 | ```bash 28 | ./gradlew shadowJar 29 | ``` 30 | 31 | **Windows:** 32 | 33 | ```batch 34 | gradlew.bat shadowJar 35 | ``` 36 | 37 | Then you will find the binary under the `build/libs/` directory. 38 | 39 | ### Report bugs or request features 40 | 41 | Reporting a bug or requesting a feature can be useful for further development of the plugin. To do that you just need 42 | to fill one of the issue templates we made for you: 43 | [Click here to report a bug](https://github.com/devblook/akropolis/issues/new?assignees=zetastormy&labels=bug&template=bug_report.yml&title=A+brief+description+of+your+report) 44 | or [click here to request a feature](https://github.com/devblook/akropolis/issues/new?assignees=zetastormy&labels=enhancement&template=feature_request.yml&title=A+brief+description+of+your+request). 45 | 46 | ### Contribute 47 | 48 | At the moment we don't have a lot of requirements to contribute, just make sure to clarify 49 | the features or fixes that you introduce in your pull request and try to follow the 50 | [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification. 51 | 52 | ## License 53 | 54 | This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for 55 | details. 56 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | java 3 | id("com.gradleup.shadow") version ("8.3.5") 4 | id("io.papermc.paperweight.userdev") version ("2.0.0-beta.10") 5 | } 6 | 7 | group = "team.devblook" 8 | version = property("projectVersion") as String 9 | description = "A modern Minecraft server hub core solution. Based on DeluxeHub by ItsLewizzz." 10 | 11 | val libsPackage = property("libsPackage") as String 12 | 13 | java { 14 | toolchain.languageVersion.set(JavaLanguageVersion.of(21)) 15 | } 16 | 17 | repositories { 18 | maven("https://oss.sonatype.org/content/groups/public/") 19 | maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") 20 | maven("https://repo.codemc.org/repository/maven-public") 21 | maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") 22 | maven("https://jitpack.io") 23 | } 24 | 25 | dependencies { 26 | paperweight.paperDevBundle("1.21.4-R0.1-SNAPSHOT") 27 | 28 | implementation("javax.inject:javax.inject:1") 29 | 30 | implementation("net.megavex:scoreboard-library-api:2.2.2") 31 | runtimeOnly("net.megavex:scoreboard-library-implementation:2.2.2") 32 | runtimeOnly("net.megavex:scoreboard-library-modern:2.2.2:mojmap") 33 | 34 | //compileOnly("org.spongepowered:configurate-yaml:4.1.2") 35 | 36 | compileOnly("net.kyori:adventure-text-minimessage:4.18.0") 37 | compileOnly("net.kyori:adventure-api:4.18.0") 38 | 39 | compileOnly("com.mojang:authlib:1.5.25") 40 | compileOnly("me.clip:placeholderapi:2.11.6") 41 | compileOnly("com.arcaniax:HeadDatabase-API:1.3.2") 42 | compileOnly("com.github.cryptomorin:XSeries:12.1.0") 43 | compileOnly("io.github.miniplaceholders:miniplaceholders-api:2.2.3") 44 | } 45 | 46 | configurations.implementation { 47 | exclude("org.bukkit", "bukkit") 48 | } 49 | 50 | tasks { 51 | processResources { 52 | filesMatching("paper-plugin.yml") { 53 | expand("version" to project.version) 54 | } 55 | } 56 | 57 | shadowJar { 58 | archiveClassifier.set("") 59 | archiveFileName.set("Akropolis-${project.version}.jar") 60 | 61 | minimize { 62 | exclude(dependency("net.megavex:.*:.*")) 63 | } 64 | 65 | relocate("net.megavex.scoreboardlibrary", "${libsPackage}.scoreboardlibrary") 66 | } 67 | 68 | withType { 69 | options.encoding = "UTF-8" 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.caching=true 2 | org.gradle.parallel=true 3 | org.gradle.jvmargs='-Dfile.encoding=UTF-8' 4 | projectVersion=1.8.1 5 | libsPackage=team.devblook.akropolis.libs 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devblook/akropolis/c4162f5f954a79494d332ec6c12d36915f7c43b3/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | @rem SPDX-License-Identifier: Apache-2.0 17 | @rem 18 | 19 | @if "%DEBUG%"=="" @echo off 20 | @rem ########################################################################## 21 | @rem 22 | @rem Gradle startup script for Windows 23 | @rem 24 | @rem ########################################################################## 25 | 26 | @rem Set local scope for the variables with windows NT shell 27 | if "%OS%"=="Windows_NT" setlocal 28 | 29 | set DIRNAME=%~dp0 30 | if "%DIRNAME%"=="" set DIRNAME=. 31 | @rem This is normally unused 32 | set APP_BASE_NAME=%~n0 33 | set APP_HOME=%DIRNAME% 34 | 35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 37 | 38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 40 | 41 | @rem Find java.exe 42 | if defined JAVA_HOME goto findJavaFromJavaHome 43 | 44 | set JAVA_EXE=java.exe 45 | %JAVA_EXE% -version >NUL 2>&1 46 | if %ERRORLEVEL% equ 0 goto execute 47 | 48 | echo. 1>&2 49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 50 | echo. 1>&2 51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 52 | echo location of your Java installation. 1>&2 53 | 54 | goto fail 55 | 56 | :findJavaFromJavaHome 57 | set JAVA_HOME=%JAVA_HOME:"=% 58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 59 | 60 | if exist "%JAVA_EXE%" goto execute 61 | 62 | echo. 1>&2 63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 64 | echo. 1>&2 65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 66 | echo location of your Java installation. 1>&2 67 | 68 | goto fail 69 | 70 | :execute 71 | @rem Setup the command line 72 | 73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 74 | 75 | 76 | @rem Execute Gradle 77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 78 | 79 | :end 80 | @rem End local scope for the variables with windows NT shell 81 | if %ERRORLEVEL% equ 0 goto mainEnd 82 | 83 | :fail 84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 85 | rem the _cmd.exe /c_ return code! 86 | set EXIT_CODE=%ERRORLEVEL% 87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 89 | exit /b %EXIT_CODE% 90 | 91 | :mainEnd 92 | if "%OS%"=="Windows_NT" endlocal 93 | 94 | :omega 95 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "akropolis" 2 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/AkropolisPluginLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis; 21 | 22 | import io.papermc.paper.plugin.loader.PluginClasspathBuilder; 23 | import io.papermc.paper.plugin.loader.PluginLoader; 24 | import io.papermc.paper.plugin.loader.library.impl.MavenLibraryResolver; 25 | import org.eclipse.aether.artifact.DefaultArtifact; 26 | import org.eclipse.aether.graph.Dependency; 27 | import org.eclipse.aether.repository.RemoteRepository; 28 | 29 | @SuppressWarnings("UnstableApiUsage") 30 | public class AkropolisPluginLoader implements PluginLoader { 31 | 32 | @Override 33 | public void classloader(PluginClasspathBuilder classpathBuilder) { 34 | MavenLibraryResolver resolver = new MavenLibraryResolver(); 35 | resolver.addDependency(new Dependency(new DefaultArtifact("com.github.cryptomorin:XSeries:12.1.0"), null)); 36 | resolver.addRepository(new RemoteRepository.Builder("central", "default", "https://repo1.maven.org/maven2/").build()); 37 | 38 | classpathBuilder.addLibrary(resolver); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/Permissions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis; 21 | 22 | public enum Permissions { 23 | // Command permissions 24 | COMMAND_AKROPOLIS_HELP("command.help"), COMMAND_AKROPOLIS_RELOAD("command.reload"), 25 | COMMAND_SCOREBOARD_TOGGLE("command.scoreboard"), COMMAND_OPEN_MENUS("command.openmenu"), 26 | COMMAND_HOLOGRAMS("command.holograms"), COMMAND_HOTBAR_TOGGLE("command.hotbar"), 27 | 28 | // Misc permissions 29 | COMMAND_GAMEMODE("command.gamemode"), COMMAND_GAMEMODE_OTHERS("command.gamemode.others"), 30 | COMMAND_CLEARCHAT("command.clearchat"), COMMAND_FLIGHT("command.fly"), COMMAND_FLIGHT_OTHERS("command.fly.others"), 31 | COMMAND_LOCKCHAT("command.lockchat"), COMMAND_SET_LOBBY("command.setlobby"), COMMAND_VANISH("command.vanish"), 32 | 33 | // Bypass permissions 34 | ANTI_SWEAR_BYPASS("bypass.antiswear"), BLOCKED_COMMANDS_BYPASS("bypass.commands"), 35 | LOCK_CHAT_BYPASS("bypass.lockchat"), ANTI_WDL_BYPASS("bypass.antiwdl"), DOUBLE_JUMP_BYPASS("bypass.doublejump"), 36 | 37 | // Notification permissions 38 | ANTI_WDL_NOTIFY("alert.antiwdl"), ANTI_SWEAR_NOTIFY("alert.antiswear"), 39 | 40 | // Event permissions 41 | EVENT_ITEM_DROP("item.drop"), EVENT_ITEM_PICKUP("item.pickup"), EVENT_PLAYER_PVP("player.pvp"), 42 | EVENT_BLOCK_INTERACT("block.interact"), EVENT_BLOCK_BREAK("block.break"), EVENT_BLOCK_PLACE("block.place"); 43 | 44 | private final String permission; 45 | 46 | Permissions(String permission) { 47 | this.permission = permission; 48 | } 49 | 50 | public final String getPermission() { 51 | return "akropolis." + this.permission; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/action/Action.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.action; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import org.bukkit.entity.Player; 24 | 25 | public interface Action { 26 | 27 | String getIdentifier(); 28 | 29 | void execute(AkropolisPlugin plugin, Player player, String data); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/action/ActionManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.action; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.action.actions.*; 24 | import me.zetastormy.akropolis.util.PlaceholderUtil; 25 | import me.zetastormy.akropolis.util.TextUtil; 26 | import org.apache.commons.lang3.StringUtils; 27 | import org.bukkit.entity.Player; 28 | 29 | import java.util.Arrays; 30 | import java.util.HashMap; 31 | import java.util.List; 32 | import java.util.Map; 33 | 34 | public class ActionManager { 35 | private final AkropolisPlugin plugin; 36 | private final Map actions; 37 | 38 | public ActionManager(AkropolisPlugin plugin) { 39 | this.plugin = plugin; 40 | actions = new HashMap<>(); 41 | load(); 42 | } 43 | 44 | private void load() { 45 | registerAction(new MessageAction(), new BroadcastMessageAction(), new CommandAction(), 46 | new ConsoleCommandAction(), new SoundAction(), new PotionEffectAction(), new GamemodeAction(), 47 | new ServerAction(), new CloseInventoryAction(), new ActionbarAction(), new TitleAction(), 48 | new MenuAction()); 49 | } 50 | 51 | public void registerAction(Action... actions) { 52 | Arrays.asList(actions).forEach(action -> this.actions.put(action.getIdentifier(), action)); 53 | } 54 | 55 | public void executeActions(Player player, List actions) { 56 | actions.forEach(actionContent -> { 57 | 58 | String actionName = StringUtils.substringBetween(actionContent, "[", "]").toUpperCase(); 59 | Action action = actionName.isEmpty() ? null : this.actions.get(actionName); 60 | 61 | if (action != null) { 62 | actionContent = actionContent.contains(" ") ? actionContent.split(" ", 2)[1] : ""; 63 | actionContent = TextUtil.raw(PlaceholderUtil.setPlaceholders(actionContent, player)); 64 | 65 | action.execute(plugin, player, actionContent); 66 | } 67 | }); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/action/actions/ActionbarAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.action.actions; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.action.Action; 24 | import me.zetastormy.akropolis.util.TextUtil; 25 | import org.bukkit.entity.Player; 26 | 27 | public class ActionbarAction implements Action { 28 | 29 | @Override 30 | public String getIdentifier() { 31 | return "ACTIONBAR"; 32 | } 33 | 34 | @Override 35 | public void execute(AkropolisPlugin plugin, Player player, String data) { 36 | player.sendActionBar(TextUtil.parse(data)); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/action/actions/BroadcastMessageAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.action.actions; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.action.Action; 24 | import me.zetastormy.akropolis.util.TextUtil; 25 | import net.kyori.adventure.text.Component; 26 | import org.bukkit.Bukkit; 27 | import org.bukkit.entity.Player; 28 | 29 | public class BroadcastMessageAction implements Action { 30 | 31 | @Override 32 | public String getIdentifier() { 33 | return "BROADCAST"; 34 | } 35 | 36 | @Override 37 | public void execute(AkropolisPlugin plugin, Player player, String data) { 38 | Component parsedData = TextUtil.parse(data); 39 | 40 | for (Player p : Bukkit.getOnlinePlayers()) { 41 | p.sendMessage(parsedData); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/action/actions/CloseInventoryAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.action.actions; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.action.Action; 24 | import org.bukkit.entity.Player; 25 | 26 | public class CloseInventoryAction implements Action { 27 | 28 | @Override 29 | public String getIdentifier() { 30 | return "CLOSE"; 31 | } 32 | 33 | @Override 34 | public void execute(AkropolisPlugin plugin, Player player, String data) { 35 | player.closeInventory(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/action/actions/CommandAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.action.actions; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.action.Action; 24 | import org.bukkit.entity.Player; 25 | 26 | public class CommandAction implements Action { 27 | 28 | @Override 29 | public String getIdentifier() { 30 | return "COMMAND"; 31 | } 32 | 33 | @Override 34 | public void execute(AkropolisPlugin plugin, Player player, String data) { 35 | player.chat(data.contains("/") ? data : "/" + data); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/action/actions/ConsoleCommandAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.action.actions; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.action.Action; 24 | import org.bukkit.Bukkit; 25 | import org.bukkit.entity.Player; 26 | 27 | public class ConsoleCommandAction implements Action { 28 | 29 | @Override 30 | public String getIdentifier() { 31 | return "CONSOLE"; 32 | } 33 | 34 | @Override 35 | public void execute(AkropolisPlugin plugin, Player player, String data) { 36 | Bukkit.dispatchCommand(Bukkit.getConsoleSender(), data); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/action/actions/GamemodeAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.action.actions; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.action.Action; 24 | import org.bukkit.GameMode; 25 | import org.bukkit.entity.Player; 26 | 27 | public class GamemodeAction implements Action { 28 | 29 | @Override 30 | public String getIdentifier() { 31 | return "GAMEMODE"; 32 | } 33 | 34 | @Override 35 | public void execute(AkropolisPlugin plugin, Player player, String data) { 36 | try { 37 | player.setGameMode(GameMode.valueOf(data.toUpperCase())); 38 | } catch (IllegalArgumentException ex) { 39 | plugin.getLogger().warning("[Akropolis Action] Invalid gamemode name: " + data.toUpperCase()); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/action/actions/MenuAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.action.actions; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.action.Action; 24 | import me.zetastormy.akropolis.inventory.AbstractInventory; 25 | import org.bukkit.entity.Player; 26 | 27 | import java.util.logging.Level; 28 | 29 | public class MenuAction implements Action { 30 | 31 | @Override 32 | public String getIdentifier() { 33 | return "MENU"; 34 | } 35 | 36 | @Override 37 | public void execute(AkropolisPlugin plugin, Player player, String data) { 38 | AbstractInventory inventory = plugin.getInventoryManager().getInventory(data); 39 | 40 | if (inventory != null) { 41 | inventory.openInventory(player); 42 | } else { 43 | plugin.getLogger().log(Level.WARNING, "[MENU] Action Failed: Menu {0} not found.", data); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/action/actions/MessageAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.action.actions; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.action.Action; 24 | import me.zetastormy.akropolis.util.TextUtil; 25 | import net.kyori.adventure.text.Component; 26 | import org.bukkit.entity.Player; 27 | 28 | public class MessageAction implements Action { 29 | 30 | @Override 31 | public String getIdentifier() { 32 | return "MESSAGE"; 33 | } 34 | 35 | @Override 36 | public void execute(AkropolisPlugin plugin, Player player, String data) { 37 | Component parsedData = TextUtil.parse(data); 38 | 39 | player.sendMessage(parsedData); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/action/actions/PotionEffectAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.action.actions; 21 | 22 | import com.cryptomorin.xseries.XPotion; 23 | import me.zetastormy.akropolis.AkropolisPlugin; 24 | import me.zetastormy.akropolis.action.Action; 25 | import org.bukkit.entity.Player; 26 | import org.bukkit.potion.PotionEffect; 27 | 28 | import java.util.Optional; 29 | 30 | public class PotionEffectAction implements Action { 31 | 32 | @Override 33 | public String getIdentifier() { 34 | return "EFFECT"; 35 | } 36 | 37 | @Override 38 | public void execute(AkropolisPlugin plugin, Player player, String data) { 39 | String[] args = data.split(";"); 40 | Optional xpotion = XPotion.matchXPotion(args[0]); 41 | 42 | try { 43 | xpotion.ifPresent(p -> { 44 | PotionEffect potionEffect = p.buildPotionEffect(1000000, Integer.parseInt(args[1]) - 1); 45 | 46 | if (potionEffect == null) throw new IllegalStateException(); 47 | 48 | player.addPotionEffect(potionEffect); 49 | }); 50 | } catch (Exception e) { 51 | plugin.getLogger().warning("[Akropolis Action] Invalid potion effect name: " + data.toUpperCase()); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/action/actions/ServerAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.action.actions; 21 | 22 | import com.google.common.io.ByteArrayDataOutput; 23 | import com.google.common.io.ByteStreams; 24 | import me.zetastormy.akropolis.AkropolisPlugin; 25 | import me.zetastormy.akropolis.action.Action; 26 | import org.bukkit.entity.Player; 27 | 28 | public class ServerAction implements Action { 29 | 30 | @Override 31 | public String getIdentifier() { 32 | return "SERVER"; 33 | } 34 | 35 | @Override 36 | public void execute(AkropolisPlugin plugin, Player player, String data) { 37 | ByteArrayDataOutput out = ByteStreams.newDataOutput(); 38 | out.writeUTF("ConnectOther"); 39 | out.writeUTF(player.getName()); 40 | out.writeUTF(data); 41 | player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/action/actions/SoundAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.action.actions; 21 | 22 | import com.cryptomorin.xseries.XSound; 23 | import me.zetastormy.akropolis.AkropolisPlugin; 24 | import me.zetastormy.akropolis.action.Action; 25 | import org.bukkit.Sound; 26 | import org.bukkit.entity.Player; 27 | 28 | import java.util.Optional; 29 | 30 | public class SoundAction implements Action { 31 | 32 | @Override 33 | public String getIdentifier() { 34 | return "SOUND"; 35 | } 36 | 37 | @Override 38 | public void execute(AkropolisPlugin plugin, Player player, String data) { 39 | Optional xsound = XSound.matchXSound(data); 40 | 41 | try { 42 | xsound.ifPresent(s -> { 43 | Sound sound = s.parseSound(); 44 | 45 | if (sound == null) throw new IllegalStateException(); 46 | 47 | player.playSound(player.getLocation(), sound, 1L, 1L); 48 | }); 49 | } catch (Exception ex) { 50 | plugin.getLogger().warning("[Akropolis Action] Invalid sound name: " + data.toUpperCase()); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/action/actions/TitleAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.action.actions; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.action.Action; 24 | import me.zetastormy.akropolis.util.TextUtil; 25 | import net.kyori.adventure.text.Component; 26 | import net.kyori.adventure.title.Title; 27 | import org.bukkit.entity.Player; 28 | 29 | import java.time.Duration; 30 | 31 | public class TitleAction implements Action { 32 | 33 | @Override 34 | public String getIdentifier() { 35 | return "TITLE"; 36 | } 37 | 38 | @Override 39 | public void execute(AkropolisPlugin plugin, Player player, String data) { 40 | String[] args = data.split(";"); 41 | 42 | Component title = TextUtil.parse(args[0]); 43 | Component subTitle = TextUtil.parse(args[1]); 44 | 45 | Duration fadeIn; 46 | Duration stay; 47 | Duration fadeOut; 48 | 49 | try { 50 | fadeIn = Duration.ofSeconds(Long.parseLong(args[2])); 51 | stay = Duration.ofSeconds(Long.parseLong(args[3])); 52 | fadeOut = Duration.ofSeconds(Long.parseLong(args[4])); 53 | } catch (NumberFormatException | ArrayIndexOutOfBoundsException e) { 54 | fadeIn = Duration.ofSeconds(1); 55 | stay = Duration.ofSeconds(3); 56 | fadeOut = Duration.ofSeconds(1); 57 | } 58 | 59 | player.showTitle(Title.title(title, subTitle, Title.Times.times(fadeIn, stay, fadeOut))); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/command/CustomCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.command; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.config.Message; 24 | import org.bukkit.command.CommandSender; 25 | import org.bukkit.entity.Player; 26 | import org.bukkit.plugin.Plugin; 27 | 28 | import java.util.List; 29 | 30 | public class CustomCommand extends InjectableCommand { 31 | private String permission; 32 | private final List actions; 33 | 34 | public CustomCommand(Plugin plugin, String name, List aliases, List actions) { 35 | super(plugin, name, "A custom Akropolis command", aliases); 36 | this.actions = actions; 37 | } 38 | 39 | @Override 40 | protected void onCommand(CommandSender sender, String label, String[] args) { 41 | if (!(sender instanceof Player player)) { 42 | Message.CONSOLE_NOT_ALLOWED.sendFrom(sender); 43 | return; 44 | } 45 | 46 | if (permission != null && !sender.hasPermission(permission)) { 47 | Message.CUSTOM_COMMAND_NO_PERMISSION.sendFrom(sender); 48 | return; 49 | } 50 | 51 | AkropolisPlugin.getInstance().getActionManager().executeActions(player, actions); 52 | } 53 | 54 | public void setPermission(String permission) { 55 | this.permission = permission; 56 | } 57 | 58 | public String getPermission() { 59 | return permission; 60 | } 61 | 62 | public List getActions() { 63 | return actions; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/command/InjectableCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.command; 21 | 22 | import me.zetastormy.akropolis.util.TextUtil; 23 | import org.bukkit.command.Command; 24 | import org.bukkit.command.CommandSender; 25 | import org.bukkit.command.PluginIdentifiableCommand; 26 | import org.bukkit.plugin.Plugin; 27 | 28 | import java.util.List; 29 | 30 | @SuppressWarnings("NullableProblems") 31 | public abstract class InjectableCommand extends Command implements PluginIdentifiableCommand { 32 | private final Plugin plugin; 33 | 34 | protected InjectableCommand(Plugin plugin, String name, String description, List aliases) { 35 | super(name, description, "/" + name, aliases); 36 | this.plugin = plugin; 37 | } 38 | 39 | protected InjectableCommand(Plugin plugin, String name, String description, String usageMessage, List aliases) { 40 | super(name, description, usageMessage, aliases); 41 | this.plugin = plugin; 42 | } 43 | 44 | @Override 45 | public boolean execute(CommandSender sender, String label, String[] args) { 46 | try { 47 | if (!isRegistered()) return true; 48 | onCommand(sender, label, args); 49 | } catch (Exception e) { 50 | sender.sendMessage(TextUtil.parse("An error occurred processing this command. Please make sure your parameters are correct.")); 51 | e.printStackTrace(); 52 | } 53 | 54 | return true; 55 | } 56 | 57 | protected abstract void onCommand(CommandSender sender, String label, String[] args); 58 | 59 | @Override 60 | public Plugin getPlugin() { 61 | return this.plugin; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/command/commands/ClearchatCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.command.commands; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.Permissions; 24 | import me.zetastormy.akropolis.command.InjectableCommand; 25 | import me.zetastormy.akropolis.config.Message; 26 | import me.zetastormy.akropolis.util.TextUtil; 27 | import org.bukkit.Bukkit; 28 | import org.bukkit.command.CommandSender; 29 | import org.bukkit.entity.Player; 30 | 31 | import java.util.List; 32 | 33 | public class ClearchatCommand extends InjectableCommand { 34 | 35 | public ClearchatCommand(AkropolisPlugin plugin, List aliases) { 36 | super(plugin, "clearchat", "Clear global or a player's chat", "/clearchat [player]", aliases); 37 | } 38 | 39 | @Override 40 | public void onCommand(CommandSender sender, String label, String[] args) { 41 | if (!(sender.hasPermission(Permissions.COMMAND_CLEARCHAT.getPermission()))) { 42 | Message.NO_PERMISSION.sendFrom(sender); 43 | return; 44 | } 45 | 46 | if (args.length == 0) { 47 | for (Player player : Bukkit.getOnlinePlayers()) { 48 | for (int i = 0; i < 100; i++) { 49 | player.sendMessage(""); 50 | } 51 | 52 | Message.CLEARCHAT.sendFromWithReplacement(player, "player", sender.name()); 53 | } 54 | } else if (args.length == 1) { 55 | 56 | Player player = Bukkit.getPlayer(args[0]); 57 | 58 | if (player == null) { 59 | Message.INVALID_PLAYER.sendFromWithReplacement(sender, "player", TextUtil.parse(args[0])); 60 | return; 61 | } 62 | 63 | for (int i = 0; i < 100; i++) { 64 | player.sendMessage(""); 65 | } 66 | 67 | Message.CLEARCHAT_PLAYER.sendFromWithReplacement(sender, "player", sender.name()); 68 | } 69 | 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/command/commands/FlyCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.command.commands; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.Permissions; 24 | import me.zetastormy.akropolis.command.InjectableCommand; 25 | import me.zetastormy.akropolis.config.ConfigManager; 26 | import me.zetastormy.akropolis.config.ConfigType; 27 | import me.zetastormy.akropolis.config.Message; 28 | import me.zetastormy.akropolis.util.TextUtil; 29 | import org.bukkit.Bukkit; 30 | import org.bukkit.command.CommandSender; 31 | import org.bukkit.configuration.file.FileConfiguration; 32 | import org.bukkit.entity.Player; 33 | 34 | import java.util.List; 35 | 36 | public class FlyCommand extends InjectableCommand { 37 | private final AkropolisPlugin plugin; 38 | private final FileConfiguration dataConfig; 39 | private final boolean saveState; 40 | 41 | public FlyCommand(AkropolisPlugin plugin, List aliases) { 42 | super(plugin, "fly", "Toggle flight mode", "/fly [player]", aliases); 43 | this.plugin = plugin; 44 | 45 | ConfigManager configManager = plugin.getConfigManager(); 46 | 47 | this.dataConfig = configManager.getFile(ConfigType.DATA).get(); 48 | this.saveState = configManager.getFile(ConfigType.SETTINGS).get().getBoolean("fly.save_state", false); 49 | } 50 | 51 | @Override 52 | public void onCommand(CommandSender sender, String label, String[] args) { 53 | if (args.length == 0) { 54 | if (!(sender instanceof Player player)) { 55 | Message.CONSOLE_NOT_ALLOWED.sendFrom(sender); 56 | return; 57 | } 58 | 59 | if (!(sender.hasPermission(Permissions.COMMAND_FLIGHT.getPermission()))) { 60 | Message.NO_PERMISSION.sendFrom(sender); 61 | return; 62 | } 63 | 64 | if (player.getAllowFlight()) { 65 | Message.FLIGHT_DISABLE.sendFrom(player); 66 | toggleFlight(player, false); 67 | } else { 68 | Message.FLIGHT_ENABLE.sendFrom(player); 69 | toggleFlight(player, true); 70 | } 71 | } else if (args.length == 1) { 72 | if (!(sender.hasPermission(Permissions.COMMAND_FLIGHT_OTHERS.getPermission()))) { 73 | Message.NO_PERMISSION.sendFrom(sender); 74 | return; 75 | } 76 | 77 | Player player = Bukkit.getPlayer(args[0]); 78 | 79 | if (player == null) { 80 | Message.INVALID_PLAYER.sendFromWithReplacement(sender, "player", TextUtil.parse(args[0])); 81 | return; 82 | } 83 | 84 | if (player.getAllowFlight()) { 85 | Message.FLIGHT_DISABLE.sendFrom(player); 86 | Message.FLIGHT_DISABLE_OTHER.sendFromWithReplacement(sender, "player", player.name()); 87 | toggleFlight(player, false); 88 | } else { 89 | Message.FLIGHT_ENABLE.sendFrom(player); 90 | Message.FLIGHT_ENABLE_OTHER.sendFromWithReplacement(sender, "player", player.name()); 91 | toggleFlight(player, true); 92 | } 93 | } 94 | 95 | } 96 | 97 | private void toggleFlight(Player player, boolean value) { 98 | player.setAllowFlight(value); 99 | player.setFlying(value); 100 | 101 | if (!saveState) return; 102 | 103 | Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> 104 | dataConfig.set("players." + player.getUniqueId() + ".fly", value)); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/command/commands/LobbyCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.command.commands; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.command.InjectableCommand; 24 | import me.zetastormy.akropolis.module.ModuleType; 25 | import me.zetastormy.akropolis.module.modules.world.LobbySpawn; 26 | import me.zetastormy.akropolis.util.TextUtil; 27 | import org.bukkit.Bukkit; 28 | import org.bukkit.Location; 29 | import org.bukkit.command.CommandSender; 30 | import org.bukkit.entity.Player; 31 | 32 | import java.util.List; 33 | 34 | public class LobbyCommand extends InjectableCommand { 35 | private final AkropolisPlugin plugin; 36 | 37 | public LobbyCommand(AkropolisPlugin plugin, List aliases) { 38 | super(plugin, "lobby", "Teleport to the lobby (if set)", aliases); 39 | this.plugin = plugin; 40 | } 41 | 42 | @Override 43 | public void onCommand(CommandSender sender, String label, String[] args) { 44 | if (!(sender instanceof Player)) { 45 | sender.sendMessage("Console cannot teleport to spawn"); 46 | return; 47 | } 48 | 49 | Location location = ((LobbySpawn) plugin.getModuleManager().getModule(ModuleType.LOBBY)).getLocation(); 50 | if (location == null) { 51 | sender.sendMessage(TextUtil.parse("The spawn location has not been set (/setlobby).")); 52 | return; 53 | } 54 | 55 | Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> ((Player) sender).teleportAsync(location), 3L); 56 | 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/command/commands/LockchatCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.command.commands; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.Permissions; 24 | import me.zetastormy.akropolis.command.InjectableCommand; 25 | import me.zetastormy.akropolis.config.Message; 26 | import me.zetastormy.akropolis.module.ModuleType; 27 | import me.zetastormy.akropolis.module.modules.chat.ChatLock; 28 | import me.zetastormy.akropolis.util.TextUtil; 29 | import org.bukkit.command.CommandSender; 30 | 31 | import java.util.List; 32 | 33 | public class LockchatCommand extends InjectableCommand { 34 | private final AkropolisPlugin plugin; 35 | 36 | public LockchatCommand(AkropolisPlugin plugin, List aliases) { 37 | super(plugin, "lockchat", "Locks global chat", aliases); 38 | this.plugin = plugin; 39 | } 40 | 41 | @Override 42 | public void onCommand(CommandSender sender, String label, String[] args) { 43 | if (!sender.hasPermission(Permissions.COMMAND_LOCKCHAT.getPermission())) { 44 | Message.NO_PERMISSION.sendFrom(sender); 45 | return; 46 | } 47 | 48 | ChatLock chatLockModule = (ChatLock) plugin.getModuleManager().getModule(ModuleType.CHAT_LOCK); 49 | 50 | if (chatLockModule.isChatLocked()) { 51 | plugin.getServer().broadcast( 52 | TextUtil.replace(Message.CHAT_UNLOCKED_BROADCAST.toComponent(), "player", sender.name())); 53 | chatLockModule.setChatLocked(false); 54 | } else { 55 | plugin.getServer() 56 | .broadcast( 57 | TextUtil.replace(Message.CHAT_LOCKED_BROADCAST.toComponent(), "player", sender.name())); 58 | chatLockModule.setChatLocked(true); 59 | } 60 | 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/command/commands/SetLobbyCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.command.commands; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.Permissions; 24 | import me.zetastormy.akropolis.command.InjectableCommand; 25 | import me.zetastormy.akropolis.config.Message; 26 | import me.zetastormy.akropolis.module.ModuleType; 27 | import me.zetastormy.akropolis.module.modules.world.LobbySpawn; 28 | import me.zetastormy.akropolis.util.TextUtil; 29 | import org.bukkit.command.CommandSender; 30 | import org.bukkit.entity.Player; 31 | 32 | import java.util.List; 33 | 34 | public class SetLobbyCommand extends InjectableCommand { 35 | private final AkropolisPlugin plugin; 36 | 37 | public SetLobbyCommand(AkropolisPlugin plugin, List aliases) { 38 | super(plugin, "setlobby", "Set the lobby location", aliases); 39 | this.plugin = plugin; 40 | } 41 | 42 | @Override 43 | public void onCommand(CommandSender sender, String label, String[] args) { 44 | if (!sender.hasPermission(Permissions.COMMAND_SET_LOBBY.getPermission())) { 45 | Message.NO_PERMISSION.sendFrom(sender); 46 | return; 47 | } 48 | 49 | if (!(sender instanceof Player player)) { 50 | sender.sendMessage("Console cannot set the spawn location."); 51 | return; 52 | } 53 | 54 | if (plugin.getModuleManager().getDisabledWorlds().contains(player.getWorld().getName())) { 55 | sender.sendMessage(TextUtil.parse("You cannot set the lobby location in a disabled world.")); 56 | return; 57 | } 58 | 59 | LobbySpawn lobbyModule = ((LobbySpawn) plugin.getModuleManager().getModule(ModuleType.LOBBY)); 60 | lobbyModule.setLocation(player.getLocation()); 61 | Message.SET_LOBBY.sendFrom(sender); 62 | 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/command/commands/VanishCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.command.commands; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.Permissions; 24 | import me.zetastormy.akropolis.command.InjectableCommand; 25 | import me.zetastormy.akropolis.config.Message; 26 | import me.zetastormy.akropolis.module.ModuleType; 27 | import me.zetastormy.akropolis.module.modules.player.PlayerVanish; 28 | import org.bukkit.command.CommandSender; 29 | import org.bukkit.entity.Player; 30 | 31 | import java.util.List; 32 | 33 | public class VanishCommand extends InjectableCommand { 34 | private final AkropolisPlugin plugin; 35 | 36 | public VanishCommand(AkropolisPlugin plugin, List aliases) { 37 | super(plugin, "vanish", "Disappear into thin air!", aliases); 38 | this.plugin = plugin; 39 | } 40 | 41 | @Override 42 | public void onCommand(CommandSender sender, String label, String[] args) { 43 | if (!sender.hasPermission(Permissions.COMMAND_VANISH.getPermission())) { 44 | Message.NO_PERMISSION.sendFrom(sender); 45 | return; 46 | } 47 | 48 | if (!(sender instanceof Player player)) { 49 | sender.sendMessage("Console cannot set the spawn location."); 50 | return; 51 | } 52 | 53 | PlayerVanish vanishModule = ((PlayerVanish) plugin.getModuleManager().getModule(ModuleType.VANISH)); 54 | vanishModule.toggleVanish(player); 55 | 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/command/commands/gamemode/AdventureCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.command.commands.gamemode; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.Permissions; 24 | import me.zetastormy.akropolis.command.InjectableCommand; 25 | import me.zetastormy.akropolis.config.Message; 26 | import me.zetastormy.akropolis.util.TextUtil; 27 | import net.kyori.adventure.text.Component; 28 | import org.bukkit.Bukkit; 29 | import org.bukkit.GameMode; 30 | import org.bukkit.command.CommandSender; 31 | import org.bukkit.entity.Player; 32 | 33 | import java.util.List; 34 | 35 | public class AdventureCommand extends InjectableCommand { 36 | 37 | public AdventureCommand(AkropolisPlugin plugin, List aliases) { 38 | super(plugin, "gma", "Change to adventure mode", "/gma [player]", aliases); 39 | } 40 | 41 | @Override 42 | public void onCommand(CommandSender sender, String label, String[] args) { 43 | if (args.length == 0) { 44 | if (!(sender instanceof Player player)) { 45 | Message.CONSOLE_NOT_ALLOWED.sendFrom(sender); 46 | return; 47 | } 48 | 49 | if (!player.hasPermission(Permissions.COMMAND_GAMEMODE.getPermission())) { 50 | Message.NO_PERMISSION.sendFrom(player); 51 | return; 52 | } 53 | 54 | Message.GAMEMODE_CHANGE.sendFromWithReplacement(player, "gamemode", Component.text("ADVENTURE")); 55 | player.setGameMode(GameMode.ADVENTURE); 56 | } else if (args.length == 1) { 57 | if (!sender.hasPermission(Permissions.COMMAND_GAMEMODE_OTHERS.getPermission())) { 58 | Message.NO_PERMISSION.sendFrom(sender); 59 | return; 60 | } 61 | 62 | Player player = Bukkit.getPlayer(args[0]); 63 | 64 | if (player == null) { 65 | Message.INVALID_PLAYER.sendFromWithReplacement(sender, "player", Component.text(args[0])); 66 | return; 67 | } 68 | 69 | if (sender.getName().equals(player.getName())) { 70 | Message.GAMEMODE_CHANGE.sendFromWithReplacement(player, "gamemode", Component.text("ADVENTURE")); 71 | } else { 72 | Message.GAMEMODE_CHANGE.sendFromWithReplacement(player, "gamemode", Component.text("ADVENTURE")); 73 | sender.sendMessage(TextUtil.replace(TextUtil.replace(Message.GAMEMODE_CHANGE_OTHER.toComponent(), "player", player.name()), "gamemode", Component.text("ADVENTURE"))); 74 | } 75 | 76 | player.setGameMode(GameMode.ADVENTURE); 77 | } 78 | 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/command/commands/gamemode/CreativeCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.command.commands.gamemode; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.Permissions; 24 | import me.zetastormy.akropolis.command.InjectableCommand; 25 | import me.zetastormy.akropolis.config.Message; 26 | import me.zetastormy.akropolis.util.TextUtil; 27 | import org.bukkit.Bukkit; 28 | import org.bukkit.GameMode; 29 | import org.bukkit.command.CommandSender; 30 | import org.bukkit.entity.Player; 31 | 32 | import java.util.List; 33 | 34 | public class CreativeCommand extends InjectableCommand { 35 | 36 | public CreativeCommand(AkropolisPlugin plugin, List aliases) { 37 | super(plugin, "gmc", "Change to creative mode", "/gmc [player]", aliases); 38 | } 39 | 40 | @Override 41 | public void onCommand(CommandSender sender, String label, String[] args) { 42 | if (args.length == 0) { 43 | if (!(sender instanceof Player player)) { 44 | Message.CONSOLE_NOT_ALLOWED.sendFrom(sender); 45 | return; 46 | } 47 | 48 | if (!player.hasPermission(Permissions.COMMAND_GAMEMODE.getPermission())) { 49 | Message.NO_PERMISSION.sendFrom(player); 50 | return; 51 | } 52 | 53 | Message.GAMEMODE_CHANGE.sendFromWithReplacement(player, "gamemode", TextUtil.parse("CREATIVE")); 54 | player.setGameMode(GameMode.CREATIVE); 55 | } else if (args.length == 1) { 56 | if (!sender.hasPermission(Permissions.COMMAND_GAMEMODE_OTHERS.getPermission())) { 57 | Message.NO_PERMISSION.sendFrom(sender); 58 | return; 59 | } 60 | 61 | Player player = Bukkit.getPlayer(args[0]); 62 | 63 | if (player == null) { 64 | Message.INVALID_PLAYER.sendFromWithReplacement(sender, "player", TextUtil.parse(args[0])); 65 | return; 66 | } 67 | 68 | if (sender.getName().equals(player.getName())) { 69 | Message.GAMEMODE_CHANGE.sendFromWithReplacement(player, "gamemode", TextUtil.parse("CREATIVE")); 70 | } else { 71 | Message.GAMEMODE_CHANGE.sendFromWithReplacement(player, "gamemode", TextUtil.parse("CREATIVE")); 72 | sender.sendMessage(TextUtil.replace(TextUtil.replace(Message.GAMEMODE_CHANGE_OTHER.toComponent(), "player", player.name()), "gamemode", TextUtil.parse("CREATIVE"))); 73 | } 74 | 75 | player.setGameMode(GameMode.CREATIVE); 76 | } 77 | 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/command/commands/gamemode/GamemodeCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.command.commands.gamemode; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.Permissions; 24 | import me.zetastormy.akropolis.command.InjectableCommand; 25 | import me.zetastormy.akropolis.config.Message; 26 | import me.zetastormy.akropolis.util.TextUtil; 27 | import net.kyori.adventure.text.Component; 28 | import org.bukkit.Bukkit; 29 | import org.bukkit.GameMode; 30 | import org.bukkit.command.CommandSender; 31 | import org.bukkit.entity.Player; 32 | 33 | import java.util.List; 34 | 35 | public class GamemodeCommand extends InjectableCommand { 36 | 37 | public GamemodeCommand(AkropolisPlugin plugin, List aliases) { 38 | super(plugin, "gamemode", "Allows you to change gamemode", "/gamemode [player]", aliases); 39 | } 40 | 41 | @Override 42 | public void onCommand(CommandSender sender, String label, String[] args) { 43 | if (args.length == 1) { 44 | if (!(sender instanceof Player player)) { 45 | Message.CONSOLE_NOT_ALLOWED.sendFrom(sender); 46 | return; 47 | } 48 | 49 | if (!player.hasPermission(Permissions.COMMAND_GAMEMODE.getPermission())) { 50 | Message.NO_PERMISSION.sendFrom(sender); 51 | return; 52 | } 53 | 54 | GameMode gamemode = getGamemode(args[0]); 55 | 56 | if (gamemode == null) { 57 | Message.GAMEMODE_INVALID.sendFromWithReplacement(sender, "gamemode", TextUtil.parse(args[0])); 58 | return; 59 | } 60 | 61 | Message.GAMEMODE_CHANGE.sendFromWithReplacement(player, "gamemode", TextUtil.parse(gamemode.toString().toUpperCase())); 62 | player.setGameMode(gamemode); 63 | 64 | } else if (args.length == 2) { 65 | if (!sender.hasPermission(Permissions.COMMAND_GAMEMODE_OTHERS.getPermission())) { 66 | Message.NO_PERMISSION.sendFrom(sender); 67 | return; 68 | } 69 | 70 | Player player = Bukkit.getPlayer(args[1]); 71 | if (player == null) { 72 | Message.INVALID_PLAYER.sendFromWithReplacement(sender, "player", TextUtil.parse(args[0])); 73 | return; 74 | } 75 | 76 | GameMode gamemode = getGamemode(args[0]); 77 | 78 | if (gamemode == null) { 79 | Message.GAMEMODE_INVALID.sendFromWithReplacement(sender, "gamemode", TextUtil.parse(args[0])); 80 | return; 81 | } 82 | 83 | Component gamemodeChange = TextUtil.replace(Message.GAMEMODE_CHANGE.toComponent(), "gamemode", TextUtil.parse(gamemode.toString().toUpperCase())); 84 | 85 | if (sender.getName().equals(player.getName())) { 86 | player.sendMessage(gamemodeChange); 87 | } else { 88 | player.sendMessage(gamemodeChange); 89 | sender.sendMessage(TextUtil.replace(TextUtil.replace(Message.GAMEMODE_CHANGE_OTHER.toComponent(), "player", player.name()), "gamemode", TextUtil.parse(gamemode.toString().toUpperCase()))); 90 | } 91 | 92 | player.setGameMode(gamemode); 93 | } 94 | 95 | } 96 | 97 | private GameMode getGamemode(String gamemode) { 98 | if (gamemode.equals("0") || gamemode.equalsIgnoreCase("survival") || gamemode.equalsIgnoreCase("s")) { 99 | return GameMode.SURVIVAL; 100 | } else if (gamemode.equals("1") || gamemode.equalsIgnoreCase("creative") || gamemode.equalsIgnoreCase("c")) { 101 | return GameMode.CREATIVE; 102 | } else if (gamemode.equals("2") || gamemode.equalsIgnoreCase("adventure") || gamemode.equalsIgnoreCase("a")) { 103 | return GameMode.ADVENTURE; 104 | } else if (gamemode.equals("3") || gamemode.equalsIgnoreCase("spectator") || gamemode.equalsIgnoreCase("sp")) { 105 | return GameMode.SPECTATOR; 106 | } 107 | 108 | return null; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/command/commands/gamemode/SpectatorCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.command.commands.gamemode; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.Permissions; 24 | import me.zetastormy.akropolis.command.InjectableCommand; 25 | import me.zetastormy.akropolis.config.Message; 26 | import me.zetastormy.akropolis.util.TextUtil; 27 | import net.kyori.adventure.text.Component; 28 | import org.bukkit.Bukkit; 29 | import org.bukkit.GameMode; 30 | import org.bukkit.command.CommandSender; 31 | import org.bukkit.entity.Player; 32 | 33 | import java.util.List; 34 | 35 | public class SpectatorCommand extends InjectableCommand { 36 | 37 | public SpectatorCommand(AkropolisPlugin plugin, List aliases) { 38 | super(plugin, "gmsp", "Change to spectator mode", "/gmsp [player]", aliases); 39 | } 40 | 41 | @Override 42 | public void onCommand(CommandSender sender, String label, String[] args) { 43 | if (args.length == 0) { 44 | if (!(sender instanceof Player player)) { 45 | Message.CONSOLE_NOT_ALLOWED.sendFrom(sender); 46 | return; 47 | } 48 | 49 | if (!player.hasPermission(Permissions.COMMAND_GAMEMODE.getPermission())) { 50 | Message.NO_PERMISSION.sendFrom(sender); 51 | return; 52 | } 53 | 54 | Message.GAMEMODE_CHANGE.sendFromWithReplacement(player, "gamemode", TextUtil.parse("SPECTATOR")); 55 | player.setGameMode(GameMode.SPECTATOR); 56 | } else if (args.length == 1) { 57 | if (!sender.hasPermission(Permissions.COMMAND_GAMEMODE_OTHERS.getPermission())) { 58 | Message.NO_PERMISSION.sendFrom(sender); 59 | return; 60 | } 61 | 62 | Player player = Bukkit.getPlayer(args[0]); 63 | 64 | if (player == null) { 65 | Message.INVALID_PLAYER.sendFromWithReplacement(sender, "player", Component.text(args[0])); 66 | return; 67 | } 68 | 69 | if (sender.getName().equals(player.getName())) { 70 | Message.GAMEMODE_CHANGE.sendFromWithReplacement(player, "gamemode", Component.text("SPECTATOR")); 71 | } else { 72 | Message.GAMEMODE_CHANGE.sendFromWithReplacement(player, "gamemode", Component.text("SPECTATOR")); 73 | sender.sendMessage(TextUtil.replace(TextUtil.replace(Message.GAMEMODE_CHANGE_OTHER.toComponent(), "player", player.name()), "gamemode", Component.text("SPECTATOR"))); 74 | } 75 | 76 | player.setGameMode(GameMode.SPECTATOR); 77 | } 78 | 79 | } 80 | } -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/command/commands/gamemode/SurvivalCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.command.commands.gamemode; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.Permissions; 24 | import me.zetastormy.akropolis.command.InjectableCommand; 25 | import me.zetastormy.akropolis.config.Message; 26 | import me.zetastormy.akropolis.util.TextUtil; 27 | import net.kyori.adventure.text.Component; 28 | import org.bukkit.Bukkit; 29 | import org.bukkit.GameMode; 30 | import org.bukkit.command.CommandSender; 31 | import org.bukkit.entity.Player; 32 | 33 | import java.util.List; 34 | 35 | public class SurvivalCommand extends InjectableCommand { 36 | 37 | public SurvivalCommand(AkropolisPlugin plugin, List aliases) { 38 | super(plugin, "gms", "Change to survival mode", "/gms [player]", aliases); 39 | } 40 | 41 | @Override 42 | public void onCommand(CommandSender sender, String label, String[] args) { 43 | if (args.length == 0) { 44 | if (!(sender instanceof Player player)) { 45 | Message.CONSOLE_NOT_ALLOWED.sendFrom(sender); 46 | return; 47 | } 48 | 49 | if (!player.hasPermission(Permissions.COMMAND_GAMEMODE.getPermission())) { 50 | Message.NO_PERMISSION.sendFrom(sender); 51 | return; 52 | } 53 | 54 | Message.GAMEMODE_CHANGE.sendFromWithReplacement(player, "gamemode", TextUtil.parse("SURVIVAL")); 55 | player.setGameMode(GameMode.SURVIVAL); 56 | } else if (args.length == 1) { 57 | if (!sender.hasPermission(Permissions.COMMAND_GAMEMODE_OTHERS.getPermission())) { 58 | Message.NO_PERMISSION.sendFrom(sender); 59 | return; 60 | } 61 | 62 | Player player = Bukkit.getPlayer(args[0]); 63 | 64 | if (player == null) { 65 | Message.INVALID_PLAYER.sendFromWithReplacement(sender, "player", Component.text(args[0])); 66 | return; 67 | } 68 | 69 | Message.GAMEMODE_CHANGE.sendFromWithReplacement(player, "gamemode", Component.text("SURVIVAL")); 70 | sender.sendMessage(TextUtil.replace(TextUtil.replace(Message.GAMEMODE_CHANGE_OTHER.toComponent(), "player", player.name()), "gamemode", Component.text("SURVIVAL"))); 71 | player.setGameMode(GameMode.SURVIVAL); 72 | } 73 | 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/config/ConfigHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.config; 21 | 22 | import org.bukkit.configuration.InvalidConfigurationException; 23 | import org.bukkit.configuration.file.FileConfiguration; 24 | import org.bukkit.configuration.file.YamlConfiguration; 25 | import org.bukkit.plugin.java.JavaPlugin; 26 | 27 | import java.io.File; 28 | import java.io.IOException; 29 | import java.util.logging.Level; 30 | 31 | public class ConfigHandler { 32 | private final JavaPlugin plugin; 33 | private final String name; 34 | private final File file; 35 | private FileConfiguration configFile; 36 | 37 | public ConfigHandler(JavaPlugin plugin, String name) { 38 | this.plugin = plugin; 39 | this.name = name + ".yml"; 40 | this.file = new File(plugin.getDataFolder(), this.name); 41 | this.configFile = new YamlConfiguration(); 42 | } 43 | 44 | public void saveDefaultConfig() { 45 | if (!file.exists()) { 46 | plugin.saveResource(name, false); 47 | plugin.getLogger().log(Level.INFO, "Resource file {0} written sucessfully!", name); 48 | } 49 | 50 | try { 51 | configFile.load(file); 52 | } catch (InvalidConfigurationException | IOException e) { 53 | e.printStackTrace(); 54 | plugin.getLogger().severe("There was an error loading " + name); 55 | plugin.getLogger().severe("Please check for any obvious configuration mistakes"); 56 | plugin.getLogger().severe("such as using tabs for spaces or forgetting to end quotes"); 57 | plugin.getLogger().severe("before reporting to the developer. The plugin will now disable."); 58 | plugin.getServer().getPluginManager().disablePlugin(plugin); 59 | } 60 | 61 | } 62 | 63 | public void save() { 64 | if (configFile == null || file == null) return; 65 | 66 | try { 67 | configFile.save(file); 68 | } catch (IOException e) { 69 | e.printStackTrace(); 70 | } 71 | } 72 | 73 | public void reload() { 74 | configFile = YamlConfiguration.loadConfiguration(file); 75 | } 76 | 77 | public FileConfiguration get() { 78 | return configFile; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/config/ConfigManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.config; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | 24 | import java.util.EnumMap; 25 | import java.util.Map; 26 | 27 | public class ConfigManager { 28 | private final Map configurations; 29 | 30 | public ConfigManager() { 31 | configurations = new EnumMap<>(ConfigType.class); 32 | } 33 | 34 | public void loadFiles(AkropolisPlugin plugin) { 35 | registerFile(ConfigType.SETTINGS, new ConfigHandler(plugin, "config")); 36 | registerFile(ConfigType.MESSAGES, new ConfigHandler(plugin, "messages")); 37 | registerFile(ConfigType.DATA, new ConfigHandler(plugin, "data")); 38 | registerFile(ConfigType.COMMANDS, new ConfigHandler(plugin, "commands")); 39 | 40 | configurations.values().forEach(ConfigHandler::saveDefaultConfig); 41 | 42 | Message.setConfiguration(getFile(ConfigType.MESSAGES).get()); 43 | } 44 | 45 | public ConfigHandler getFile(ConfigType type) { 46 | return configurations.get(type); 47 | } 48 | 49 | public void reloadFiles() { 50 | configurations.values().forEach(ConfigHandler::reload); 51 | Message.setConfiguration(getFile(ConfigType.MESSAGES).get()); 52 | } 53 | 54 | public void saveData() { 55 | getFile(ConfigType.DATA).save(); 56 | } 57 | 58 | public void registerFile(ConfigType type, ConfigHandler config) { 59 | configurations.put(type, config); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/config/ConfigType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.config; 21 | 22 | public enum ConfigType { 23 | SETTINGS, MESSAGES, COMMANDS, DATA 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/cooldown/CooldownManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.cooldown; 21 | 22 | import com.google.common.collect.HashBasedTable; 23 | import com.google.common.collect.Table; 24 | 25 | import java.util.UUID; 26 | 27 | public class CooldownManager { 28 | private final Table cooldowns = HashBasedTable.create(); 29 | 30 | /** 31 | * Retrieve the number of milliseconds left until a given cooldown expires. 32 | *

33 | * Check for a negative value to determine if a given cooldown has expired.
34 | * Cooldowns that have never been defined will return {@link Long#MIN_VALUE}. 35 | * 36 | * @param uuid - the uuid of the player. 37 | * @param key - cooldown to locate. 38 | * @return Number of milliseconds until the cooldown expires. 39 | */ 40 | public long getCooldown(UUID uuid, String key) { 41 | return calculateRemainder(cooldowns.get(uuid.toString(), key)); 42 | } 43 | 44 | /** 45 | * Update a cooldown for the specified player. 46 | * 47 | * @param uuid - uuid of the player. 48 | * @param key - cooldown to update. 49 | * @param delay - number of milliseconds until the cooldown will expire again. 50 | */ 51 | public void setCooldown(UUID uuid, String key, long delay) { 52 | calculateRemainder(cooldowns.put(uuid.toString(), key, System.currentTimeMillis() + (delay * 1000))); 53 | } 54 | 55 | /** 56 | * Determine if a given cooldown has expired. If it has, refresh the cooldown. 57 | * If not, do nothing. 58 | * 59 | * @param uuid - uuid of the player. 60 | * @param key - cooldown to update. 61 | * @param delay - number of milliseconds until the cooldown will expire again. 62 | * @return TRUE if the cooldown was expired/unset and has now been reset, FALSE 63 | * otherwise. 64 | */ 65 | public boolean tryCooldown(UUID uuid, String key, long delay) { 66 | if (getCooldown(uuid, key) / 1000 > 0) 67 | return false; 68 | setCooldown(uuid, key, delay + 1); 69 | return true; 70 | } 71 | 72 | private long calculateRemainder(Long expireTime) { 73 | return expireTime != null ? expireTime - System.currentTimeMillis() : Long.MIN_VALUE; 74 | } 75 | } -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/hook/HooksManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.hook; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.hook.hooks.head.BaseHead; 24 | import me.zetastormy.akropolis.hook.hooks.head.DatabaseHead; 25 | import me.zetastormy.akropolis.util.PlaceholderUtil; 26 | import org.bukkit.Bukkit; 27 | 28 | import java.util.HashMap; 29 | import java.util.Map; 30 | import java.util.Objects; 31 | 32 | public class HooksManager { 33 | private final Map hooks; 34 | 35 | public HooksManager(AkropolisPlugin plugin) { 36 | hooks = new HashMap<>(); 37 | 38 | // Base64 head 39 | hooks.put("BASE64", new BaseHead()); 40 | 41 | // PlaceholderAPI 42 | if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) { 43 | hooks.put("PLACEHOLDER_API", null); 44 | PlaceholderUtil.setPapiState(true); 45 | plugin.getLogger().info("Hooked into PlaceholderAPI"); 46 | } 47 | 48 | if (Bukkit.getPluginManager().isPluginEnabled("HeadDatabase")) { 49 | hooks.put("HEAD_DATABASE", new DatabaseHead()); 50 | plugin.getLogger().info("Hooked into HeadDatabase"); 51 | } 52 | 53 | if (Bukkit.getPluginManager().isPluginEnabled("MiniPlaceholders")) { 54 | hooks.put("MINIPLACEHOLDERS", null); 55 | PlaceholderUtil.setMPState(true); 56 | plugin.getLogger().info("Hooked into MiniPlaceholders"); 57 | } 58 | 59 | hooks.values().stream().filter(Objects::nonNull).forEach(pluginHook -> pluginHook.onEnable(plugin)); 60 | } 61 | 62 | public boolean isHookEnabled(String id) { 63 | return hooks.containsKey(id); 64 | } 65 | 66 | public PluginHook getPluginHook(String id) { 67 | return hooks.get(id); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/hook/PluginHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.hook; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | 24 | public interface PluginHook { 25 | 26 | void onEnable(AkropolisPlugin plugin); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/hook/hooks/head/BaseHead.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.hook.hooks.head; 21 | 22 | import com.cryptomorin.xseries.XMaterial; 23 | import com.destroystokyo.paper.profile.PlayerProfile; 24 | import com.destroystokyo.paper.profile.ProfileProperty; 25 | import me.zetastormy.akropolis.AkropolisPlugin; 26 | import me.zetastormy.akropolis.hook.PluginHook; 27 | import org.bukkit.Bukkit; 28 | import org.bukkit.inventory.ItemStack; 29 | import org.bukkit.inventory.meta.SkullMeta; 30 | 31 | import java.util.Collection; 32 | import java.util.HashMap; 33 | import java.util.Map; 34 | import java.util.UUID; 35 | 36 | public class BaseHead implements PluginHook, HeadHook { 37 | private AkropolisPlugin plugin; 38 | private Map cache; 39 | 40 | @Override 41 | public void onEnable(AkropolisPlugin plugin) { 42 | this.plugin = plugin; 43 | cache = new HashMap<>(); 44 | } 45 | 46 | @Override 47 | public ItemStack getHead(String data) { 48 | if (cache.containsKey(data)) return cache.get(data); 49 | 50 | ItemStack head = XMaterial.PLAYER_HEAD.parseItem(); 51 | 52 | if (head == null) { 53 | plugin.getLogger().severe("Could not parse head!"); 54 | return XMaterial.SKELETON_SKULL.parseItem(); 55 | } 56 | 57 | SkullMeta meta = (SkullMeta) head.getItemMeta(); 58 | if (meta == null) { 59 | plugin.getLogger().severe("Could not parse head meta!"); 60 | return head; 61 | } 62 | head.editMeta(SkullMeta.class, skullMeta -> { 63 | PlayerProfile profile = Bukkit.createProfile(UUID.randomUUID(), null); 64 | Collection properties = profile.getProperties(); 65 | properties.clear(); 66 | properties.add(new ProfileProperty("textures", data, "")); 67 | profile.setProperties(properties); 68 | skullMeta.setPlayerProfile(profile); 69 | }); 70 | cache.put(data, head); 71 | return head; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/hook/hooks/head/DatabaseHead.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.hook.hooks.head; 21 | 22 | import me.arcaniax.hdb.api.DatabaseLoadEvent; 23 | import me.arcaniax.hdb.api.HeadDatabaseAPI; 24 | import me.zetastormy.akropolis.AkropolisPlugin; 25 | import me.zetastormy.akropolis.hook.PluginHook; 26 | import org.bukkit.event.EventHandler; 27 | import org.bukkit.event.Listener; 28 | import org.bukkit.inventory.ItemStack; 29 | 30 | public class DatabaseHead implements PluginHook, HeadHook, Listener { 31 | private AkropolisPlugin plugin; 32 | private HeadDatabaseAPI api; 33 | 34 | @Override 35 | public void onEnable(AkropolisPlugin plugin) { 36 | this.plugin = plugin; 37 | plugin.getServer().getPluginManager().registerEvents(this, plugin); 38 | api = new HeadDatabaseAPI(); 39 | } 40 | 41 | @Override 42 | public ItemStack getHead(String data) { 43 | return api.getItemHead(data); 44 | } 45 | 46 | @EventHandler 47 | public void onDatabaseLoad(DatabaseLoadEvent event) { 48 | plugin.getInventoryManager().onEnable(plugin); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/hook/hooks/head/HeadHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.hook.hooks.head; 21 | 22 | import org.bukkit.inventory.ItemStack; 23 | 24 | public interface HeadHook { 25 | 26 | ItemStack getHead(String data); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/inventory/AbstractInventory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.inventory; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.util.ItemStackBuilder; 24 | import org.bukkit.Material; 25 | import org.bukkit.NamespacedKey; 26 | import org.bukkit.entity.Player; 27 | import org.bukkit.event.EventHandler; 28 | import org.bukkit.event.Listener; 29 | import org.bukkit.event.inventory.InventoryCloseEvent; 30 | import org.bukkit.inventory.Inventory; 31 | import org.bukkit.inventory.ItemStack; 32 | import org.bukkit.inventory.meta.ItemMeta; 33 | import org.bukkit.persistence.PersistentDataContainer; 34 | import org.bukkit.persistence.PersistentDataType; 35 | 36 | import java.util.ArrayList; 37 | import java.util.List; 38 | import java.util.UUID; 39 | 40 | public abstract class AbstractInventory implements Listener { 41 | private final AkropolisPlugin plugin; 42 | private boolean refreshEnabled = false; 43 | private final List openInventories; 44 | 45 | protected AbstractInventory(AkropolisPlugin plugin) { 46 | this.plugin = plugin; 47 | openInventories = new ArrayList<>(); 48 | plugin.getServer().getPluginManager().registerEvents(this, plugin); 49 | } 50 | 51 | public void setInventoryRefresh(long value) { 52 | if (value <= 0) 53 | return; 54 | 55 | plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new InventoryTask(this), 0L, value); 56 | refreshEnabled = true; 57 | } 58 | 59 | public abstract void onEnable(); 60 | 61 | protected abstract Inventory getInventory(); 62 | 63 | protected AkropolisPlugin getPlugin() { 64 | return plugin; 65 | } 66 | 67 | public Inventory refreshInventory(Player player, Inventory inventory) { 68 | for (int i = 0; i < inventory.getSize(); i++) { 69 | ItemStack item = getInventory().getItem(i); 70 | 71 | if (item == null || item.getType() == Material.AIR) continue; 72 | if (item.getItemMeta() == null || !item.hasItemMeta()) continue; 73 | 74 | ItemStackBuilder newItem = new ItemStackBuilder(item.clone()); 75 | 76 | if (item.getItemMeta().hasDisplayName()) { 77 | newItem.withName(item.getItemMeta().displayName(), player); 78 | } 79 | 80 | if (item.getItemMeta().hasLore() && item.getItemMeta().lore() != null) { 81 | newItem.withLore(item.getItemMeta().lore(), player); 82 | } 83 | 84 | if (item.getType() == Material.PLAYER_HEAD) { 85 | ItemMeta itemMeta = item.getItemMeta(); 86 | PersistentDataContainer container = itemMeta.getPersistentDataContainer(); 87 | 88 | if (container.has(NamespacedKey.minecraft("player-head"), PersistentDataType.BOOLEAN)) { 89 | newItem.setSkullOwner(player); 90 | } 91 | } 92 | 93 | inventory.setItem(i, newItem.build()); 94 | } 95 | 96 | return inventory; 97 | } 98 | 99 | public void openInventory(Player player) { 100 | if (getInventory() == null) 101 | return; 102 | 103 | player.openInventory(refreshInventory(player, getInventory())); 104 | 105 | if (refreshEnabled && !openInventories.contains(player.getUniqueId())) { 106 | openInventories.add(player.getUniqueId()); 107 | } 108 | } 109 | 110 | public List getOpenInventories() { 111 | return openInventories; 112 | } 113 | 114 | @EventHandler 115 | public void onInventoryClose(InventoryCloseEvent event) { 116 | if (event.getView().getTopInventory().getHolder() instanceof InventoryBuilder && refreshEnabled) { 117 | openInventories.remove(event.getPlayer().getUniqueId()); 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/inventory/ClickAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.inventory; 21 | 22 | import org.bukkit.entity.Player; 23 | 24 | public interface ClickAction { 25 | 26 | void execute(Player p0); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/inventory/InventoryBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.inventory; 21 | 22 | import me.zetastormy.akropolis.util.TextUtil; 23 | import org.bukkit.Bukkit; 24 | import org.bukkit.inventory.Inventory; 25 | import org.bukkit.inventory.InventoryHolder; 26 | 27 | import java.util.HashMap; 28 | import java.util.Map; 29 | 30 | public class InventoryBuilder implements InventoryHolder { 31 | private final Map icons; 32 | private int size; 33 | private final String title; 34 | 35 | public InventoryBuilder(int size, String title) { 36 | this.icons = new HashMap<>(); 37 | this.size = size; 38 | this.title = title; 39 | } 40 | 41 | public void setItem(int slot, InventoryItem item) { 42 | icons.put(slot, item); 43 | } 44 | 45 | public InventoryItem getIcon(final int slot) { 46 | return icons.get(slot); 47 | } 48 | 49 | @SuppressWarnings("NullableProblems") 50 | public Inventory getInventory() { 51 | if (size > 54) 52 | size = 54; 53 | else if (size < 9) 54 | size = 9; 55 | 56 | Inventory inventory = Bukkit.createInventory(this, size, TextUtil.parse(title)); 57 | for (Map.Entry entry : icons.entrySet()) { 58 | inventory.setItem(entry.getKey(), entry.getValue().getItemStack()); 59 | } 60 | return inventory; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/inventory/InventoryItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.inventory; 21 | 22 | import org.bukkit.inventory.ItemStack; 23 | 24 | import java.util.ArrayList; 25 | import java.util.List; 26 | 27 | public class InventoryItem { 28 | public final ItemStack itemStack; 29 | public final List clickActions; 30 | 31 | public InventoryItem(ItemStack itemStack) { 32 | this.clickActions = new ArrayList<>(); 33 | this.itemStack = itemStack; 34 | } 35 | 36 | public InventoryItem addClickAction(ClickAction clickAction) { 37 | this.clickActions.add(clickAction); 38 | return this; 39 | } 40 | 41 | public List getClickActions() { 42 | return this.clickActions; 43 | } 44 | 45 | public ItemStack getItemStack() { 46 | return this.itemStack; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/inventory/InventoryListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.inventory; 21 | 22 | import org.bukkit.Material; 23 | import org.bukkit.entity.Player; 24 | import org.bukkit.event.EventHandler; 25 | import org.bukkit.event.Listener; 26 | import org.bukkit.event.inventory.InventoryClickEvent; 27 | import org.bukkit.inventory.ItemStack; 28 | 29 | public class InventoryListener implements Listener { 30 | 31 | @EventHandler 32 | public void onInventoryClick(InventoryClickEvent event) { 33 | if (event.getView().getTopInventory().getHolder() instanceof InventoryBuilder) { 34 | event.setCancelled(true); 35 | 36 | if (event.getWhoClicked() instanceof Player player) { 37 | 38 | ItemStack itemStack = event.getCurrentItem(); 39 | 40 | if (itemStack == null || itemStack.getType() == Material.AIR) 41 | return; 42 | 43 | InventoryBuilder customHolder = (InventoryBuilder) event.getView().getTopInventory().getHolder(); 44 | InventoryItem item = customHolder.getIcon(event.getRawSlot()); 45 | 46 | if (item == null) 47 | return; 48 | 49 | for (final ClickAction clickAction : item.getClickActions()) { 50 | clickAction.execute(player); 51 | } 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/inventory/InventoryManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.inventory; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.inventory.inventories.CustomGUI; 24 | import org.bukkit.Bukkit; 25 | import org.bukkit.configuration.file.YamlConfiguration; 26 | import org.bukkit.entity.Player; 27 | 28 | import java.io.*; 29 | import java.util.HashMap; 30 | import java.util.Map; 31 | import java.util.UUID; 32 | import java.util.logging.Level; 33 | 34 | public class InventoryManager { 35 | private AkropolisPlugin plugin; 36 | private final Map inventories; 37 | 38 | public InventoryManager() { 39 | inventories = new HashMap<>(); 40 | } 41 | 42 | public void onEnable(AkropolisPlugin plugin) { 43 | this.plugin = plugin; 44 | 45 | loadCustomMenus(); 46 | inventories.values().forEach(AbstractInventory::onEnable); 47 | 48 | plugin.getServer().getPluginManager().registerEvents(new InventoryListener(), plugin); 49 | } 50 | 51 | private void loadCustomMenus() { 52 | File directory = new File(plugin.getDataFolder().getAbsolutePath() + File.separator + "menus"); 53 | 54 | if (!directory.exists()) { 55 | if (!directory.mkdir()) { 56 | plugin.getLogger().severe("Could not create menus' directory!"); 57 | plugin.getLogger().severe("The plugin will now disable."); 58 | Bukkit.getPluginManager().disablePlugin(plugin); 59 | return; 60 | } 61 | 62 | File file = new File(plugin.getDataFolder().getAbsolutePath() + File.separator + "menus", 63 | "serverselector.yml"); 64 | 65 | try (InputStream inputStream = this.plugin.getResource("serverselector.yml"); 66 | OutputStream outputStream = new FileOutputStream(file)) { 67 | if (inputStream == null) { 68 | plugin.getLogger().severe("Resource serverselector.yml not available in plugin's JAR!"); 69 | plugin.getLogger().severe("The plugin will now disable."); 70 | Bukkit.getPluginManager().disablePlugin(plugin); 71 | return; 72 | } 73 | 74 | byte[] buffer = new byte[inputStream.available()]; 75 | 76 | if (inputStream.read(buffer) != 0) { 77 | plugin.getLogger().info("Resource file serverselector.yml written sucessfully!"); 78 | } 79 | 80 | outputStream.write(buffer); 81 | } catch (IOException e) { 82 | e.printStackTrace(); 83 | return; 84 | } 85 | } 86 | 87 | // Load all menu files 88 | File[] yamlFiles = new File(plugin.getDataFolder().getAbsolutePath() + File.separator + "menus") 89 | .listFiles((dir, name) -> name.toLowerCase().endsWith(".yml")); 90 | 91 | if (yamlFiles == null) 92 | return; 93 | 94 | for (File file : yamlFiles) { 95 | String name = file.getName().replace(".yml", ""); 96 | 97 | if (inventories.containsKey(name)) { 98 | plugin.getLogger() 99 | .warning("Inventory with name '" + file.getName() + "' already exists, skipping duplicate.."); 100 | continue; 101 | } 102 | 103 | CustomGUI customGUI; 104 | try { 105 | customGUI = new CustomGUI(plugin, YamlConfiguration.loadConfiguration(file)); 106 | } catch (Exception e) { 107 | plugin.getLogger().severe("Could not load file '" + name + "' (YAML error)."); 108 | e.printStackTrace(); 109 | continue; 110 | } 111 | 112 | inventories.put(name, customGUI); 113 | plugin.getLogger().log(Level.INFO, "Loaded custom menu {0}.", name); 114 | } 115 | } 116 | 117 | public Map getInventories() { 118 | return inventories; 119 | } 120 | 121 | public AbstractInventory getInventory(String key) { 122 | return inventories.get(key); 123 | } 124 | 125 | public void onDisable() { 126 | inventories.values().forEach(abstractInventory -> { 127 | for (UUID uuid : abstractInventory.getOpenInventories()) { 128 | Player player = Bukkit.getPlayer(uuid); 129 | 130 | if (player != null) 131 | player.closeInventory(); 132 | } 133 | 134 | abstractInventory.getOpenInventories().clear(); 135 | }); 136 | 137 | inventories.clear(); 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/inventory/InventoryTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.inventory; 21 | 22 | import org.bukkit.Bukkit; 23 | import org.bukkit.entity.Player; 24 | 25 | import java.util.UUID; 26 | 27 | public class InventoryTask implements Runnable { 28 | private final AbstractInventory inventory; 29 | 30 | InventoryTask(AbstractInventory inventory) { 31 | this.inventory = inventory; 32 | } 33 | 34 | @Override 35 | public void run() { 36 | for (UUID uuid : inventory.getOpenInventories()) { 37 | Player player = Bukkit.getPlayer(uuid); 38 | 39 | if (player != null) { 40 | inventory.refreshInventory(player, player.getOpenInventory().getTopInventory()); 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/inventory/inventories/CustomGUI.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.inventory.inventories; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.inventory.AbstractInventory; 24 | import me.zetastormy.akropolis.inventory.InventoryBuilder; 25 | import me.zetastormy.akropolis.inventory.InventoryItem; 26 | import me.zetastormy.akropolis.util.ItemStackBuilder; 27 | import org.bukkit.configuration.ConfigurationSection; 28 | import org.bukkit.configuration.file.FileConfiguration; 29 | import org.bukkit.inventory.Inventory; 30 | 31 | public class CustomGUI extends AbstractInventory { 32 | private final FileConfiguration config; 33 | private final ConfigurationSection itemsSection; 34 | private InventoryBuilder inventory; 35 | 36 | public CustomGUI(AkropolisPlugin plugin, FileConfiguration config) { 37 | super(plugin); 38 | this.config = config; 39 | this.itemsSection = config.getConfigurationSection("items"); 40 | } 41 | 42 | @Override 43 | public void onEnable() { 44 | InventoryBuilder inventoryBuilder = new InventoryBuilder(config.getInt("slots"), 45 | config.getString("title")); 46 | 47 | if (config.contains("refresh") && config.getBoolean("refresh.enabled")) { 48 | setInventoryRefresh(config.getLong("refresh.rate")); 49 | } 50 | 51 | if (itemsSection == null) { 52 | getPlugin().getLogger().severe("Items configuration section is missing!"); 53 | return; 54 | } 55 | 56 | for (String item : itemsSection.getKeys(false)) { 57 | try { 58 | InventoryItem inventoryItem = build(item); 59 | setFiller(inventoryBuilder, item, inventoryItem); 60 | } catch (Exception e) { 61 | e.printStackTrace(); 62 | getPlugin().getLogger().warning("There was an error loading GUI item ID '" + item + "', skipping.."); 63 | } 64 | } 65 | 66 | inventory = inventoryBuilder; 67 | } 68 | 69 | private InventoryItem build(String item) { 70 | ItemStackBuilder itemStackBuilder = ItemStackBuilder 71 | .getItemStack(itemsSection.getConfigurationSection(item)); 72 | InventoryItem inventoryItem; 73 | 74 | if (!itemsSection.contains(item + ".actions")) { 75 | inventoryItem = new InventoryItem(itemStackBuilder.build()); 76 | } else { 77 | inventoryItem = new InventoryItem(itemStackBuilder.build()).addClickAction(p -> getPlugin() 78 | .getActionManager().executeActions(p, itemsSection.getStringList(item + ".actions"))); 79 | } 80 | 81 | return inventoryItem; 82 | } 83 | 84 | private void setFiller(InventoryBuilder inventoryBuilder, String item, InventoryItem inventoryItem) { 85 | if (itemsSection.contains(item + ".slots")) { 86 | for (String slot : itemsSection.getStringList(item + ".slots")) { 87 | inventoryBuilder.setItem(Integer.parseInt(slot), inventoryItem); 88 | } 89 | } else if (itemsSection.contains(item + ".slot")) { 90 | int slot = itemsSection.getInt(item + ".slot"); 91 | 92 | if (slot == -1) { 93 | while (inventoryBuilder.getInventory().firstEmpty() != -1) { 94 | inventoryBuilder.setItem(inventoryBuilder.getInventory().firstEmpty(), inventoryItem); 95 | } 96 | } else { 97 | inventoryBuilder.setItem(slot, inventoryItem); 98 | } 99 | } 100 | } 101 | 102 | @Override 103 | protected Inventory getInventory() { 104 | return inventory.getInventory(); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/Module.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.config.ConfigType; 24 | import me.zetastormy.akropolis.cooldown.CooldownManager; 25 | import org.bukkit.Location; 26 | import org.bukkit.World; 27 | import org.bukkit.configuration.file.FileConfiguration; 28 | import org.bukkit.entity.Player; 29 | import org.bukkit.event.Listener; 30 | 31 | import java.util.ArrayList; 32 | import java.util.List; 33 | import java.util.UUID; 34 | 35 | public abstract class Module implements Listener { 36 | private final AkropolisPlugin plugin; 37 | private final ModuleType moduleType; 38 | private List disabledWorlds; 39 | private final CooldownManager cooldownManager; 40 | 41 | protected Module(AkropolisPlugin plugin, ModuleType type) { 42 | this.plugin = plugin; 43 | this.moduleType = type; 44 | this.cooldownManager = plugin.getCooldownManager(); 45 | this.disabledWorlds = new ArrayList<>(); 46 | } 47 | 48 | public void setDisabledWorlds(List disabledWorlds) { 49 | this.disabledWorlds = disabledWorlds; 50 | } 51 | 52 | public AkropolisPlugin getPlugin() { 53 | return plugin; 54 | } 55 | 56 | public boolean inDisabledWorld(Location location) { 57 | World world = location.getWorld(); 58 | 59 | if (world == null) return false; 60 | 61 | return disabledWorlds.contains(world.getName()); 62 | } 63 | 64 | public boolean inDisabledWorld(World world) { 65 | return disabledWorlds.contains(world.getName()); 66 | } 67 | 68 | public boolean tryCooldown(UUID uuid, String type, long delay) { 69 | return cooldownManager.tryCooldown(uuid, type, delay); 70 | } 71 | 72 | public long getCooldown(UUID uuid, String type) { 73 | return (cooldownManager.getCooldown(uuid, type) / 1000); 74 | } 75 | 76 | public FileConfiguration getConfig(ConfigType type) { 77 | return getPlugin().getConfigManager().getFile(type).get(); 78 | } 79 | 80 | public void executeActions(Player player, List actions) { 81 | getPlugin().getActionManager().executeActions(player, actions); 82 | } 83 | 84 | public ModuleType getModuleType() { 85 | return moduleType; 86 | } 87 | 88 | public abstract void onEnable(); 89 | 90 | public abstract void onDisable(); 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/ModuleType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module; 21 | 22 | public enum ModuleType { 23 | ANTI_WDL, CHAT_FORMAT, CHAT_LOCK, DOUBLE_JUMP, LAUNCHPAD, NAMETAG, SCOREBOARD, TABLIST, 24 | ANNOUNCEMENTS, WORLD_PROTECT, ANTI_SWEAR, COMMAND_BLOCK, LOBBY, VANISH, HOLOGRAMS, HOTBAR_ITEMS, PLAYER_LISTENER, 25 | PLAYER_OFFHAND_LISTENER, BOSS_BAR_BROADCAST 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/chat/AntiSwear.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.chat; 21 | 22 | import io.papermc.paper.event.player.AsyncChatEvent; 23 | import me.zetastormy.akropolis.AkropolisPlugin; 24 | import me.zetastormy.akropolis.Permissions; 25 | import me.zetastormy.akropolis.config.ConfigType; 26 | import me.zetastormy.akropolis.config.Message; 27 | import me.zetastormy.akropolis.module.Module; 28 | import me.zetastormy.akropolis.module.ModuleType; 29 | import me.zetastormy.akropolis.util.TextUtil; 30 | import net.kyori.adventure.text.Component; 31 | import org.bukkit.Bukkit; 32 | import org.bukkit.entity.Player; 33 | import org.bukkit.event.EventHandler; 34 | 35 | import java.util.List; 36 | 37 | public class AntiSwear extends Module { 38 | private List blockedWords; 39 | 40 | public AntiSwear(AkropolisPlugin plugin) { 41 | super(plugin, ModuleType.ANTI_SWEAR); 42 | } 43 | 44 | @Override 45 | public void onEnable() { 46 | blockedWords = getConfig(ConfigType.SETTINGS).getStringList("anti_swear.blocked_words"); 47 | } 48 | 49 | @Override 50 | public void onDisable() { 51 | // TODO: Refactor to follow Liskov Substitution principle. 52 | } 53 | 54 | @EventHandler 55 | public void onPlayerChat(AsyncChatEvent event) { 56 | Player player = event.getPlayer(); 57 | 58 | if (player.hasPermission(Permissions.ANTI_SWEAR_BYPASS.getPermission())) 59 | return; 60 | 61 | Component message = event.originalMessage(); 62 | 63 | for (String word : blockedWords) { 64 | if (TextUtil.raw(message).contains(word.toLowerCase())) { 65 | event.setCancelled(true); 66 | Message.ANTI_SWEAR_WORD_BLOCKED.sendFrom(player); 67 | 68 | Bukkit.getOnlinePlayers().stream() 69 | .filter(p -> p.hasPermission(Permissions.ANTI_SWEAR_NOTIFY.getPermission())).forEach(p -> p.sendMessage(TextUtil.replace(TextUtil.replace(Message.ANTI_SWEAR_ADMIN_NOTIFY.toComponent(), "player", player.name()), "word", message))); 70 | 71 | return; 72 | } 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/chat/AutoBroadcast.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.chat; 21 | 22 | import com.cryptomorin.xseries.XSound; 23 | import me.zetastormy.akropolis.AkropolisPlugin; 24 | import me.zetastormy.akropolis.config.ConfigType; 25 | import me.zetastormy.akropolis.module.Module; 26 | import me.zetastormy.akropolis.module.ModuleType; 27 | import me.zetastormy.akropolis.util.PlaceholderUtil; 28 | import net.kyori.adventure.text.Component; 29 | import org.bukkit.Bukkit; 30 | import org.bukkit.Sound; 31 | import org.bukkit.configuration.ConfigurationSection; 32 | import org.bukkit.configuration.file.FileConfiguration; 33 | import org.bukkit.entity.Player; 34 | 35 | import java.util.HashMap; 36 | import java.util.List; 37 | import java.util.Map; 38 | 39 | public class AutoBroadcast extends Module implements Runnable { 40 | private Map> broadcasts; 41 | private int broadcastTask = 0; 42 | private int count = 0; 43 | private int size = 0; 44 | private int requiredPlayers = 0; 45 | private Sound sound = null; 46 | private double volume; 47 | private double pitch; 48 | 49 | public AutoBroadcast(AkropolisPlugin plugin) { 50 | super(plugin, ModuleType.ANNOUNCEMENTS); 51 | } 52 | 53 | @Override 54 | public void onEnable() { 55 | FileConfiguration config = getConfig(ConfigType.SETTINGS); 56 | 57 | broadcasts = new HashMap<>(); 58 | int announcementsCount = 0; 59 | ConfigurationSection announcementsSettings = config.getConfigurationSection("announcements"); 60 | 61 | if (announcementsSettings == null) { 62 | getPlugin().getLogger().severe("Announcement settings configuration section is missing!"); 63 | return; 64 | } 65 | 66 | ConfigurationSection announcements = announcementsSettings.getConfigurationSection("announcements"); 67 | 68 | if (announcements == null) { 69 | getPlugin().getLogger().severe("Announcements are missing in the configuration!"); 70 | return; 71 | } 72 | 73 | for (String key : announcements.getKeys(false)) { 74 | broadcasts.put(announcementsCount, announcements.getStringList(key)); 75 | announcementsCount++; 76 | } 77 | 78 | if (announcementsSettings.getBoolean("sound.enabled")) { 79 | String soundValue = announcementsSettings.getString("sound.value"); 80 | 81 | if (soundValue != null) { 82 | XSound.matchXSound(soundValue).ifPresent(s -> sound = s.parseSound()); 83 | volume = announcementsSettings.getDouble("sound.volume"); 84 | pitch = announcementsSettings.getDouble("sound.pitch"); 85 | } 86 | } 87 | 88 | requiredPlayers = announcementsSettings.getInt("required_players", 0); 89 | 90 | size = broadcasts.size(); 91 | if (size > 0) { 92 | broadcastTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(getPlugin(), this, 60L, 93 | announcementsSettings.getLong("delay") * 20); 94 | } 95 | } 96 | 97 | @Override 98 | public void onDisable() { 99 | Bukkit.getScheduler().cancelTask(broadcastTask); 100 | } 101 | 102 | @Override 103 | public void run() { 104 | if (count == size) count = 0; 105 | if (!(count < size && Bukkit.getOnlinePlayers().size() >= requiredPlayers)) return; 106 | 107 | for (Player player : Bukkit.getOnlinePlayers()) { 108 | if (inDisabledWorld(player.getLocation())) continue; 109 | 110 | broadcasts.get(count).forEach(message -> { 111 | Component parsedMessage = PlaceholderUtil.setPlaceholders(message, player); 112 | 113 | player.sendMessage(parsedMessage); 114 | }); 115 | 116 | if (sound != null) player.playSound(player.getLocation(), sound, (float) volume, (float) pitch); 117 | } 118 | 119 | count++; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/chat/ChatCommandBlock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.chat; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.Permissions; 24 | import me.zetastormy.akropolis.config.ConfigType; 25 | import me.zetastormy.akropolis.config.Message; 26 | import me.zetastormy.akropolis.module.Module; 27 | import me.zetastormy.akropolis.module.ModuleType; 28 | import org.bukkit.entity.Player; 29 | import org.bukkit.event.EventHandler; 30 | import org.bukkit.event.player.PlayerCommandPreprocessEvent; 31 | 32 | import java.util.List; 33 | 34 | public class ChatCommandBlock extends Module { 35 | private List blockedCommands; 36 | 37 | public ChatCommandBlock(AkropolisPlugin plugin) { 38 | super(plugin, ModuleType.COMMAND_BLOCK); 39 | } 40 | 41 | @Override 42 | public void onEnable() { 43 | blockedCommands = getConfig(ConfigType.SETTINGS).getStringList("command_block.blocked_commands"); 44 | } 45 | 46 | @Override 47 | public void onDisable() { 48 | // TODO: Refactor to follow Liskov Substitution principle. 49 | } 50 | 51 | @EventHandler 52 | public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { 53 | Player player = event.getPlayer(); 54 | 55 | if (inDisabledWorld(player.getLocation()) 56 | || player.hasPermission(Permissions.BLOCKED_COMMANDS_BYPASS.getPermission())) 57 | return; 58 | 59 | if (blockedCommands.contains(event.getMessage().toLowerCase())) { 60 | event.setCancelled(true); 61 | Message.COMMAND_BLOCKED.sendFrom(player); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/chat/ChatLock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.chat; 21 | 22 | import io.papermc.paper.event.player.AsyncChatEvent; 23 | import me.zetastormy.akropolis.AkropolisPlugin; 24 | import me.zetastormy.akropolis.Permissions; 25 | import me.zetastormy.akropolis.config.ConfigType; 26 | import me.zetastormy.akropolis.config.Message; 27 | import me.zetastormy.akropolis.module.Module; 28 | import me.zetastormy.akropolis.module.ModuleType; 29 | import org.bukkit.entity.Player; 30 | import org.bukkit.event.EventHandler; 31 | import org.bukkit.event.EventPriority; 32 | 33 | public class ChatLock extends Module { 34 | private boolean isChatLocked; 35 | 36 | public ChatLock(AkropolisPlugin plugin) { 37 | super(plugin, ModuleType.CHAT_LOCK); 38 | } 39 | 40 | @Override 41 | public void onEnable() { 42 | isChatLocked = getPlugin().getConfigManager().getFile(ConfigType.DATA).get().getBoolean("chat_locked"); 43 | } 44 | 45 | @Override 46 | public void onDisable() { 47 | getPlugin().getConfigManager().getFile(ConfigType.DATA).get().set("chat_locked", isChatLocked); 48 | } 49 | 50 | @EventHandler(priority = EventPriority.LOWEST) 51 | public void onPlayerChat(AsyncChatEvent event) { 52 | Player player = event.getPlayer(); 53 | 54 | if (!isChatLocked || player.hasPermission(Permissions.LOCK_CHAT_BYPASS.getPermission())) 55 | return; 56 | 57 | event.setCancelled(true); 58 | Message.CHAT_LOCKED.sendFrom(player); 59 | } 60 | 61 | public boolean isChatLocked() { 62 | return isChatLocked; 63 | } 64 | 65 | public void setChatLocked(boolean chatLocked) { 66 | isChatLocked = chatLocked; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/chat/groups/ChatGroup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.chat.groups; 21 | 22 | import me.zetastormy.akropolis.util.PlaceholderUtil; 23 | import me.zetastormy.akropolis.util.TextUtil; 24 | import net.kyori.adventure.text.Component; 25 | import org.bukkit.entity.Player; 26 | 27 | public class ChatGroup { 28 | private final String rawFormat; 29 | private final int cooldownTime; 30 | private final String cooldownMessage; 31 | private final String permission; 32 | 33 | public ChatGroup(String groupName, String rawFormat, int cooldownTime, String cooldownMessage) { 34 | this.rawFormat = rawFormat; 35 | this.cooldownTime = cooldownTime; 36 | this.cooldownMessage = cooldownMessage; 37 | this.permission = "akropolis.chat.group." + groupName; 38 | } 39 | 40 | public Component getFormat(Player player) { 41 | return PlaceholderUtil.setPlaceholders(rawFormat, player); 42 | } 43 | 44 | public int getCooldownTime() { 45 | return cooldownTime; 46 | } 47 | 48 | public Component getCooldownMessage() { 49 | return TextUtil.parse(cooldownMessage); 50 | } 51 | 52 | public String getPermission() { 53 | return permission; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/chat/groups/ChatGroups.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.chat.groups; 21 | 22 | import io.papermc.paper.event.player.AsyncChatEvent; 23 | import me.zetastormy.akropolis.AkropolisPlugin; 24 | import me.zetastormy.akropolis.config.ConfigType; 25 | import me.zetastormy.akropolis.module.Module; 26 | import me.zetastormy.akropolis.module.ModuleType; 27 | import me.zetastormy.akropolis.util.TextUtil; 28 | import net.kyori.adventure.text.Component; 29 | import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; 30 | import org.bukkit.ChatColor; 31 | import org.bukkit.configuration.ConfigurationSection; 32 | import org.bukkit.configuration.file.FileConfiguration; 33 | import org.bukkit.entity.Player; 34 | import org.bukkit.event.EventHandler; 35 | 36 | import java.util.HashMap; 37 | import java.util.Map; 38 | 39 | public class ChatGroups extends Module { 40 | private final Map chatGroups = new HashMap<>(); 41 | 42 | public ChatGroups(AkropolisPlugin plugin) { 43 | super(plugin, ModuleType.CHAT_FORMAT); 44 | } 45 | 46 | @Override 47 | public void onEnable() { 48 | FileConfiguration config = getConfig(ConfigType.SETTINGS); 49 | ConfigurationSection groupsSection = config.getConfigurationSection("groups"); 50 | 51 | if (groupsSection == null) { 52 | getPlugin().getLogger().info("Skipping chat groups creation, configuration section is missing!"); 53 | return; 54 | } 55 | 56 | groupsSection.getKeys(false).stream() 57 | .filter(key -> !key.equals("enabled")) 58 | .forEach(groupName -> chatGroups.put(groupName, new ChatGroup(groupName, 59 | groupsSection.getString(groupName + ".format", "No format."), 60 | groupsSection.getInt(groupName + ".cooldown.time", 0), 61 | groupsSection.getString(groupName + ".cooldown.message", "No cooldown message.")))); 62 | } 63 | 64 | @Override 65 | public void onDisable() { 66 | chatGroups.clear(); 67 | } 68 | 69 | @SuppressWarnings("deprecation") 70 | @EventHandler 71 | public void onPlayerChat(AsyncChatEvent event) { 72 | if (event.isCancelled()) return; 73 | 74 | Player player = event.getPlayer(); 75 | ChatGroup currentGroup = null; 76 | 77 | for (String group : chatGroups.keySet()) { 78 | if (player.hasPermission("akropolis.chat.group." + group)) { 79 | currentGroup = chatGroups.get(group); 80 | } 81 | } 82 | 83 | if (currentGroup == null) return; 84 | 85 | event.setCancelled(true); 86 | 87 | if (!tryCooldown(player.getUniqueId(), "chat", currentGroup.getCooldownTime())) { 88 | player.sendMessage(TextUtil.replace(currentGroup.getCooldownMessage(), "time", Component.text(getCooldown(player.getUniqueId(), "chat")))); 89 | return; 90 | } 91 | 92 | String rawMessage = TextUtil.raw(event.originalMessage()); 93 | String parsedMessage = TextUtil.raw(LegacyComponentSerializer 94 | .legacySection() 95 | .deserialize(ChatColor.translateAlternateColorCodes('&', rawMessage))); 96 | 97 | getPlugin().getServer().sendMessage(TextUtil.replace(currentGroup.getFormat(player), 98 | "message", 99 | TextUtil.parse(parsedMessage))); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/hologram/Hologram.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.hologram; 21 | 22 | import me.zetastormy.akropolis.util.TextUtil; 23 | import net.kyori.adventure.text.Component; 24 | import org.bukkit.Location; 25 | import org.bukkit.World; 26 | import org.bukkit.entity.ArmorStand; 27 | import org.bukkit.entity.EntityType; 28 | 29 | import java.util.ArrayList; 30 | import java.util.List; 31 | import java.util.stream.Collectors; 32 | 33 | public class Hologram { 34 | private final List stands; 35 | private Location location; 36 | private final String name; 37 | 38 | public Hologram(String name, Location location) { 39 | this.name = name; 40 | this.location = location; 41 | stands = new ArrayList<>(); 42 | } 43 | 44 | public void setLines(List lines) { 45 | remove(); 46 | 47 | lines.forEach(this::addLine); 48 | } 49 | 50 | public void addLine(Component text) { 51 | World world = location.getWorld(); 52 | 53 | if (world == null) return; 54 | 55 | ArmorStand stand = (ArmorStand) world.spawnEntity(location.clone().subtract(0, getHeight(), 0), 56 | EntityType.ARMOR_STAND); 57 | 58 | stand.setVisible(false); 59 | stand.setGravity(false); 60 | stand.setCustomNameVisible(true); 61 | stand.customName(text); 62 | stand.setCanPickupItems(false); 63 | stands.add(stand); 64 | } 65 | 66 | public void setLine(int line, String text) { 67 | ArmorStand stand = stands.get(line - 1); 68 | 69 | stand.customName(TextUtil.parse(text.trim())); 70 | } 71 | 72 | public Hologram removeLine(int line) { 73 | ArmorStand stand = stands.get(line - 1); 74 | 75 | stand.remove(); 76 | stands.remove(line - 1); 77 | 78 | if (!refreshLines(line - 1)) return null; 79 | 80 | return this; 81 | } 82 | 83 | public boolean refreshLines(int line) { 84 | List standsTemp = new ArrayList<>(); 85 | 86 | int count = 0; 87 | 88 | for (ArmorStand entry : stands) { 89 | if (count >= line) 90 | standsTemp.add(entry); 91 | count++; 92 | } 93 | 94 | for (ArmorStand stand : standsTemp) 95 | stand.teleportAsync(stand.getLocation().add(0, 0.25, 0)); 96 | 97 | return count >= 1; 98 | } 99 | 100 | public void setLocation(Location location) { 101 | this.location = location; 102 | setLines(stands.stream().map(ArmorStand::customName).collect(Collectors.toList())); 103 | } 104 | 105 | public boolean hasInvalidLine(int line) { 106 | return line - 1 >= stands.size() || line <= 0; 107 | } 108 | 109 | public void remove() { 110 | for (ArmorStand stand : stands) { 111 | stand.remove(); 112 | } 113 | 114 | stands.clear(); 115 | } 116 | 117 | public Location getLocation() { 118 | return location; 119 | } 120 | 121 | public List getStands() { 122 | return stands; 123 | } 124 | 125 | public String getName() { 126 | return name; 127 | } 128 | 129 | private double getHeight() { 130 | return stands.size() * 0.25; 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/hotbar/items/CustomItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.hotbar.items; 21 | 22 | import me.zetastormy.akropolis.config.ConfigType; 23 | import me.zetastormy.akropolis.config.Message; 24 | import me.zetastormy.akropolis.module.modules.hotbar.HotbarItem; 25 | import me.zetastormy.akropolis.module.modules.hotbar.HotbarManager; 26 | import net.kyori.adventure.text.Component; 27 | import org.bukkit.configuration.ConfigurationSection; 28 | import org.bukkit.entity.Player; 29 | import org.bukkit.inventory.ItemStack; 30 | 31 | import java.util.Collections; 32 | import java.util.List; 33 | 34 | public class CustomItem extends HotbarItem { 35 | private final String key; 36 | private final int cooldown; 37 | private final List actions; 38 | 39 | public CustomItem(HotbarManager hotbarManager, ItemStack item, int slot, String key) { 40 | super(hotbarManager, item, slot, key); 41 | this.key = key; 42 | 43 | ConfigurationSection itemSettings = getPlugin().getConfigManager().getFile(ConfigType.SETTINGS).get() 44 | .getConfigurationSection("custom_join_items.items." + key); 45 | 46 | if (itemSettings == null) { 47 | cooldown = 0; 48 | actions = Collections.emptyList(); 49 | return; 50 | } 51 | 52 | cooldown = itemSettings.getInt("cooldown", 0); 53 | actions = itemSettings.getStringList("actions"); 54 | } 55 | 56 | @Override 57 | protected void onInteract(Player player) { 58 | if (!getHotbarManager().tryCooldown(player.getUniqueId(), key, cooldown)) { 59 | Message.COOLDOWN_ACTIVE.sendFromWithReplacement(player, "time", Component.text(getHotbarManager().getCooldown(player.getUniqueId(), key))); 60 | return; 61 | } 62 | 63 | getPlugin().getActionManager().executeActions(player, actions); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/player/DoubleJump.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.player; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.Permissions; 24 | import me.zetastormy.akropolis.config.ConfigType; 25 | import me.zetastormy.akropolis.config.Message; 26 | import me.zetastormy.akropolis.module.Module; 27 | import me.zetastormy.akropolis.module.ModuleType; 28 | import net.kyori.adventure.text.Component; 29 | import org.bukkit.Bukkit; 30 | import org.bukkit.GameMode; 31 | import org.bukkit.Material; 32 | import org.bukkit.configuration.file.FileConfiguration; 33 | import org.bukkit.entity.Player; 34 | import org.bukkit.event.EventHandler; 35 | import org.bukkit.event.player.PlayerChangedWorldEvent; 36 | import org.bukkit.event.player.PlayerGameModeChangeEvent; 37 | import org.bukkit.event.player.PlayerJoinEvent; 38 | import org.bukkit.event.player.PlayerToggleFlightEvent; 39 | 40 | import java.util.List; 41 | import java.util.UUID; 42 | 43 | public class DoubleJump extends Module { 44 | private long cooldownDelay; 45 | private double launch; 46 | private double launchY; 47 | private List actions; 48 | 49 | public DoubleJump(AkropolisPlugin plugin) { 50 | super(plugin, ModuleType.DOUBLE_JUMP); 51 | } 52 | 53 | @Override 54 | public void onEnable() { 55 | FileConfiguration config = getConfig(ConfigType.SETTINGS); 56 | cooldownDelay = config.getLong("double_jump.cooldown", 0); 57 | launch = config.getDouble("double_jump.launch_power", 1.3); 58 | launchY = config.getDouble("double_jump.launch_power_y", 1.2); 59 | actions = config.getStringList("double_jump.actions"); 60 | 61 | if (launch > 4.0) 62 | launch = 4.0; 63 | if (launchY > 4.0) 64 | launchY = 4.0; 65 | } 66 | 67 | @Override 68 | public void onDisable() { 69 | // TODO: Refactor to follow Liskov Substitution principle. 70 | } 71 | 72 | @EventHandler 73 | public void onPlayerToggleFlight(PlayerToggleFlightEvent event) { 74 | Player player = event.getPlayer(); 75 | 76 | // Perform checks 77 | if (player.hasPermission(Permissions.DOUBLE_JUMP_BYPASS.getPermission()) || player.hasPermission(Permissions.COMMAND_FLIGHT.getPermission())) 78 | return; 79 | else if (inDisabledWorld(player.getLocation())) 80 | return; 81 | else if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) 82 | return; 83 | else if (!event.isFlying()) 84 | return; 85 | else if (player.getWorld().getBlockAt(player.getLocation().subtract(0, 2, 0)).getType() == Material.AIR) { 86 | event.setCancelled(true); 87 | return; 88 | } 89 | 90 | // All pre-checks passed, now handle double jump 91 | event.setCancelled(true); 92 | 93 | // Check for cooldown 94 | UUID uuid = player.getUniqueId(); 95 | 96 | if (!tryCooldown(uuid, "double_jump", cooldownDelay)) { 97 | Message.DOUBLE_JUMP_COOLDOWN.sendFromWithReplacement(player, "time", Component.text(getCooldown(uuid, "double_jump"))); 98 | return; 99 | } 100 | 101 | // Execute double jump 102 | player.setVelocity(player.getLocation().getDirection().multiply(launch).setY(launchY)); 103 | executeActions(player, actions); 104 | } 105 | 106 | @EventHandler 107 | public void onWorldChange(PlayerChangedWorldEvent event) { 108 | Player player = event.getPlayer(); 109 | 110 | if (player.getGameMode() != GameMode.CREATIVE && player.getGameMode() != GameMode.SPECTATOR) { 111 | player.setAllowFlight(!inDisabledWorld(player.getLocation())); 112 | } 113 | } 114 | 115 | @EventHandler 116 | public void onPlayerJoin(PlayerJoinEvent event) { 117 | Player player = event.getPlayer(); 118 | 119 | if (player.getGameMode() != GameMode.CREATIVE && player.getGameMode() != GameMode.SPECTATOR) 120 | player.setAllowFlight(!inDisabledWorld(player.getLocation())); 121 | } 122 | 123 | @EventHandler 124 | public void onGameModeChange(PlayerGameModeChangeEvent event) { 125 | Player player = event.getPlayer(); 126 | 127 | if (inDisabledWorld(player.getLocation())) return; 128 | 129 | GameMode newGameMode = event.getNewGameMode(); 130 | if (newGameMode != GameMode.CREATIVE && newGameMode != GameMode.SPECTATOR) { 131 | Bukkit.getScheduler().runTaskLater(getPlugin(), () -> player.setAllowFlight(true), 1L); 132 | } 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/player/PlayerOffHandSwap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.player; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.module.Module; 24 | import me.zetastormy.akropolis.module.ModuleType; 25 | import org.bukkit.event.EventHandler; 26 | import org.bukkit.event.inventory.InventoryClickEvent; 27 | import org.bukkit.event.player.PlayerSwapHandItemsEvent; 28 | 29 | public class PlayerOffHandSwap extends Module { 30 | 31 | public PlayerOffHandSwap(AkropolisPlugin plugin) { 32 | super(plugin, ModuleType.PLAYER_OFFHAND_LISTENER); 33 | } 34 | 35 | @Override 36 | public void onEnable() { 37 | // TODO: Refactor to follow Liskov Substitution principle. 38 | } 39 | 40 | @Override 41 | public void onDisable() { 42 | // TODO: Refactor to follow Liskov Substitution principle. 43 | } 44 | 45 | @EventHandler 46 | public void onPlayerSwapItem(PlayerSwapHandItemsEvent event) { 47 | event.setCancelled(true); 48 | } 49 | 50 | @EventHandler 51 | public void onInventoryClick(InventoryClickEvent event) { 52 | if (event.getRawSlot() != event.getSlot() && event.getSlot() == 40) { 53 | event.setCancelled(true); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/player/PlayerVanish.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.player; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.config.Message; 24 | import me.zetastormy.akropolis.module.Module; 25 | import me.zetastormy.akropolis.module.ModuleType; 26 | import org.bukkit.Bukkit; 27 | import org.bukkit.entity.Player; 28 | import org.bukkit.event.EventHandler; 29 | import org.bukkit.event.player.PlayerJoinEvent; 30 | import org.bukkit.event.player.PlayerQuitEvent; 31 | import org.bukkit.potion.PotionEffect; 32 | import org.bukkit.potion.PotionEffectType; 33 | 34 | import java.util.ArrayList; 35 | import java.util.List; 36 | import java.util.UUID; 37 | 38 | public class PlayerVanish extends Module { 39 | private List vanished; 40 | 41 | public PlayerVanish(AkropolisPlugin plugin) { 42 | super(plugin, ModuleType.VANISH); 43 | } 44 | 45 | @Override 46 | public void onEnable() { 47 | vanished = new ArrayList<>(); 48 | } 49 | 50 | @Override 51 | public void onDisable() { 52 | vanished.clear(); 53 | } 54 | 55 | @SuppressWarnings("deprecation") 56 | public void toggleVanish(Player player) { 57 | if (isVanished(player)) { 58 | vanished.remove(player.getUniqueId()); 59 | Bukkit.getOnlinePlayers().forEach(pl -> pl.showPlayer(player)); 60 | 61 | Message.VANISH_DISABLE.sendFrom(player); 62 | player.removePotionEffect(PotionEffectType.NIGHT_VISION); 63 | } else { 64 | vanished.add(player.getUniqueId()); 65 | Bukkit.getOnlinePlayers().forEach(pl -> pl.hidePlayer(player)); 66 | 67 | Message.VANISH_ENABLE.sendFrom(player); 68 | player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 1000000, 1)); 69 | } 70 | } 71 | 72 | public boolean isVanished(Player player) { 73 | return vanished.contains(player.getUniqueId()); 74 | } 75 | 76 | @SuppressWarnings("deprecation") 77 | @EventHandler 78 | public void onPlayerJoin(PlayerJoinEvent event) { 79 | vanished.forEach(hidden -> { 80 | Player playerHidden = Bukkit.getPlayer(hidden); 81 | 82 | if (playerHidden == null) return; 83 | 84 | event.getPlayer().hidePlayer(playerHidden); 85 | }); 86 | } 87 | 88 | @EventHandler 89 | public void onPlayerQuit(PlayerQuitEvent event) { 90 | Player player = event.getPlayer(); 91 | player.removePotionEffect(PotionEffectType.NIGHT_VISION); 92 | vanished.remove(player.getUniqueId()); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/visual/nametag/NametagHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.visual.nametag; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import net.kyori.adventure.text.Component; 24 | import net.kyori.adventure.text.format.NamedTextColor; 25 | import net.kyori.adventure.text.format.TextColor; 26 | import net.megavex.scoreboardlibrary.api.team.ScoreboardTeam; 27 | import net.megavex.scoreboardlibrary.api.team.TeamDisplay; 28 | import net.megavex.scoreboardlibrary.api.team.TeamManager; 29 | import org.bukkit.entity.Player; 30 | 31 | import java.util.HashMap; 32 | import java.util.Map; 33 | 34 | public class NametagHelper { 35 | private final TeamManager mainTeamManager; 36 | private final Map teams; 37 | 38 | public NametagHelper() { 39 | this.mainTeamManager = AkropolisPlugin.getInstance().getScoreboardLibrary().createTeamManager(); 40 | this.teams = new HashMap<>(); 41 | } 42 | 43 | public void createFormat(Component prefix, TextColor color, Component suffix, Player player) { 44 | if (teams.containsKey(player)) { 45 | ScoreboardTeam team = teams.get(player); 46 | TeamDisplay teamDisplay = team.defaultDisplay(); 47 | 48 | team.teamManager().addPlayer(player); 49 | updateFormat(teamDisplay, prefix, color, suffix); 50 | teamDisplay.addEntry(player.getName()); 51 | return; 52 | } 53 | 54 | ScoreboardTeam team = mainTeamManager.createIfAbsent(player.getName()); 55 | TeamDisplay teamDisplay = team.defaultDisplay(); 56 | 57 | team.teamManager().addPlayer(player); 58 | updateFormat(teamDisplay, prefix, color, suffix); 59 | teamDisplay.addEntry(player.getName()); 60 | teams.put(player, team); 61 | } 62 | 63 | public void updateFormat(TeamDisplay teamDisplay, Component prefix, TextColor color, Component suffix) { 64 | teamDisplay.prefix(prefix); 65 | teamDisplay.playerColor(NamedTextColor.nearestTo(color)); 66 | teamDisplay.suffix(suffix); 67 | } 68 | 69 | public void deleteFormat(Player player) { 70 | if (!teams.containsKey(player) || mainTeamManager.closed()) return; 71 | 72 | ScoreboardTeam team = teams.get(player); 73 | 74 | if (team != null) { 75 | team.teamManager().removePlayer(player); 76 | team.defaultDisplay().removeEntry(player.getName()); 77 | } 78 | } 79 | 80 | public TeamManager getMainTeamManager() { 81 | return mainTeamManager; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/visual/nametag/NametagManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.visual.nametag; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.config.ConfigType; 24 | import me.zetastormy.akropolis.module.Module; 25 | import me.zetastormy.akropolis.module.ModuleType; 26 | import me.zetastormy.akropolis.util.PlaceholderUtil; 27 | import net.kyori.adventure.text.Component; 28 | import net.kyori.adventure.text.format.TextColor; 29 | import org.bukkit.Bukkit; 30 | import org.bukkit.configuration.ConfigurationSection; 31 | import org.bukkit.configuration.file.FileConfiguration; 32 | import org.bukkit.entity.Player; 33 | import org.bukkit.event.EventHandler; 34 | import org.bukkit.event.player.PlayerJoinEvent; 35 | import org.bukkit.event.player.PlayerQuitEvent; 36 | 37 | public class NametagManager extends Module { 38 | private ConfigurationSection format; 39 | private NametagHelper nametagHelper; 40 | private int nametagTask; 41 | 42 | // TODO: make this work on reload 43 | public NametagManager(AkropolisPlugin plugin) { 44 | super(plugin, ModuleType.NAMETAG); 45 | } 46 | 47 | @Override 48 | public void onEnable() { 49 | FileConfiguration config = getConfig(ConfigType.SETTINGS); 50 | 51 | format = config.getConfigurationSection("nametag.format"); 52 | nametagHelper = new NametagHelper(); 53 | 54 | if (config.getBoolean("nametag.refresh.enabled")) { 55 | nametagTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(getPlugin(), new NametagUpdateTask(this, nametagHelper), 0L, 56 | config.getLong("nametag.refresh.rate")); 57 | } 58 | 59 | Bukkit.getScheduler().runTaskLaterAsynchronously(getPlugin(), () -> 60 | Bukkit.getOnlinePlayers().forEach(player -> { 61 | Component prefix = PlaceholderUtil.setPlaceholders(format.getString("prefix"), player); 62 | TextColor color = TextColor.fromHexString(format.getString("name_color", "#FFFFFF")); 63 | Component suffix = PlaceholderUtil.setPlaceholders(format.getString("suffix"), player); 64 | 65 | nametagHelper.createFormat(prefix, color, suffix, player); 66 | }), 20L); 67 | } 68 | 69 | @Override 70 | public void onDisable() { 71 | Bukkit.getScheduler().cancelTask(nametagTask); 72 | Bukkit.getOnlinePlayers().forEach(nametagHelper::deleteFormat); 73 | } 74 | 75 | @EventHandler 76 | public void onPlayerJoin(PlayerJoinEvent event) { 77 | Player player = event.getPlayer(); 78 | 79 | Component prefix = PlaceholderUtil.setPlaceholders(format.getString("prefix"), player); 80 | TextColor color = TextColor.fromHexString(format.getString("name_color", "#FFFFFF")); 81 | Component suffix = PlaceholderUtil.setPlaceholders(format.getString("suffix"), player); 82 | 83 | nametagHelper.createFormat(prefix, color, suffix, player); 84 | } 85 | 86 | @EventHandler 87 | public void onPlayerQuit(PlayerQuitEvent event) { 88 | Player player = event.getPlayer(); 89 | 90 | nametagHelper.deleteFormat(player); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/visual/nametag/NametagUpdateTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.visual.nametag; 21 | 22 | import me.zetastormy.akropolis.config.ConfigType; 23 | import me.zetastormy.akropolis.util.PlaceholderUtil; 24 | import net.kyori.adventure.text.Component; 25 | import net.kyori.adventure.text.format.TextColor; 26 | import net.megavex.scoreboardlibrary.api.team.ScoreboardTeam; 27 | import org.bukkit.Bukkit; 28 | import org.bukkit.configuration.ConfigurationSection; 29 | 30 | public class NametagUpdateTask implements Runnable { 31 | private final NametagHelper nametagHelper; 32 | private final String prefix; 33 | private final TextColor color; 34 | private final String suffix; 35 | 36 | public NametagUpdateTask(NametagManager nametagManager, NametagHelper nametagHelper) { 37 | this.nametagHelper = nametagHelper; 38 | 39 | ConfigurationSection format = nametagManager.getConfig(ConfigType.SETTINGS).getConfigurationSection("nametag.format"); 40 | 41 | this.prefix = format == null ? "" : format.getString("prefix"); 42 | this.color = TextColor.fromHexString(format == null ? "#FFFFFF" : format.getString("name_color", "#FFFFFF")); 43 | this.suffix = format == null ? "" : format.getString("suffix"); 44 | } 45 | 46 | @Override 47 | public void run() { 48 | Bukkit.getOnlinePlayers().forEach(player -> { 49 | ScoreboardTeam team = nametagHelper.getMainTeamManager().team(player.getName()); 50 | 51 | if (team == null) return; 52 | 53 | Component prefix = PlaceholderUtil.setPlaceholders(this.prefix, player); 54 | Component suffix = PlaceholderUtil.setPlaceholders(this.suffix, player); 55 | 56 | nametagHelper.updateFormat(team.defaultDisplay(), prefix, color, suffix); 57 | }); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/visual/scoreboard/ScoreboardHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.visual.scoreboard; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.util.PlaceholderUtil; 24 | import net.kyori.adventure.text.Component; 25 | import net.megavex.scoreboardlibrary.api.sidebar.Sidebar; 26 | import org.bukkit.entity.Player; 27 | 28 | import java.util.List; 29 | 30 | public class ScoreboardHelper { 31 | private final Sidebar sidebar; 32 | private final Player player; 33 | 34 | public ScoreboardHelper(Player player) { 35 | this.player = player; 36 | this.sidebar = AkropolisPlugin.getInstance().getScoreboardLibrary().createSidebar(Sidebar.MAX_LINES); 37 | } 38 | 39 | public void setTitle(String title) { 40 | sidebar.title(setPlaceholders(title)); 41 | } 42 | 43 | public void setLinesFromList(List list) { 44 | for (int i = 0; i < list.size(); i++) { 45 | sidebar.line(i, setPlaceholders(list.get(i))); 46 | } 47 | } 48 | 49 | public Component setPlaceholders(String text) { 50 | return PlaceholderUtil.setPlaceholders(text, player); 51 | } 52 | 53 | public void addPlayer() { 54 | sidebar.addPlayer(player); 55 | } 56 | 57 | public void removePlayer() { 58 | if (sidebar.closed()) return; 59 | 60 | sidebar.removePlayer(player); 61 | sidebar.close(); // To prevent memory leaks 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/visual/scoreboard/ScoreboardUpdateTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.visual.scoreboard; 21 | 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | import java.util.UUID; 25 | 26 | public class ScoreboardUpdateTask implements Runnable { 27 | private final ScoreboardManager scoreboardManager; 28 | 29 | public ScoreboardUpdateTask(ScoreboardManager scoreboardManager) { 30 | this.scoreboardManager = scoreboardManager; 31 | } 32 | 33 | @Override 34 | public void run() { 35 | List toRemove = new ArrayList<>(); 36 | 37 | scoreboardManager.getPlayers().forEach(uuid -> { 38 | if (scoreboardManager.updateScoreboard(uuid) == null) 39 | toRemove.add(uuid); 40 | }); 41 | 42 | scoreboardManager.getPlayers().removeAll(toRemove); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/visual/tablist/TablistHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.visual.tablist; 21 | 22 | import me.zetastormy.akropolis.util.TextUtil; 23 | import net.kyori.adventure.text.Component; 24 | import org.bukkit.entity.Player; 25 | 26 | import java.util.Objects; 27 | 28 | public class TablistHelper { 29 | 30 | private TablistHelper() { 31 | throw new UnsupportedOperationException(); 32 | } 33 | 34 | public static void sendTabList(Player player, Component header, Component footer) { 35 | Objects.requireNonNull(player, "Cannot update tab for null player"); 36 | Component newHeader = header == null ? Component.empty() : TextUtil.replace(header, "player", player.displayName()); 37 | Component newFooter = footer == null ? Component.empty() : TextUtil.replace(footer, "player", player.displayName()); 38 | 39 | player.sendPlayerListHeaderAndFooter(newHeader, newFooter); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/visual/tablist/TablistManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.visual.tablist; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.config.ConfigType; 24 | import me.zetastormy.akropolis.module.Module; 25 | import me.zetastormy.akropolis.module.ModuleType; 26 | import me.zetastormy.akropolis.util.PlaceholderUtil; 27 | import org.bukkit.Bukkit; 28 | import org.bukkit.World; 29 | import org.bukkit.configuration.file.FileConfiguration; 30 | import org.bukkit.entity.Player; 31 | import org.bukkit.event.EventHandler; 32 | import org.bukkit.event.player.PlayerJoinEvent; 33 | import org.bukkit.event.player.PlayerQuitEvent; 34 | import org.bukkit.event.player.PlayerTeleportEvent; 35 | 36 | import java.util.ArrayList; 37 | import java.util.List; 38 | import java.util.UUID; 39 | 40 | public class TablistManager extends Module { 41 | private List players; 42 | private int tablistTask; 43 | private String header; 44 | private String footer; 45 | 46 | public TablistManager(AkropolisPlugin plugin) { 47 | super(plugin, ModuleType.TABLIST); 48 | } 49 | 50 | @Override 51 | public void onEnable() { 52 | players = new ArrayList<>(); 53 | 54 | FileConfiguration config = getConfig(ConfigType.SETTINGS); 55 | 56 | header = String.join("\n", config.getStringList("tablist.header")); 57 | footer = String.join("\n", config.getStringList("tablist.footer")); 58 | 59 | if (config.getBoolean("tablist.refresh.enabled")) { 60 | tablistTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(getPlugin(), new TablistUpdateTask(this), 0L, 61 | config.getLong("tablist.refresh.rate")); 62 | } 63 | 64 | getPlugin().getServer().getScheduler() 65 | .scheduleSyncDelayedTask(getPlugin(), 66 | () -> Bukkit.getOnlinePlayers().stream() 67 | .filter(player -> !inDisabledWorld(player.getLocation())).forEach(this::createTablist), 68 | 20L); 69 | } 70 | 71 | @Override 72 | public void onDisable() { 73 | Bukkit.getScheduler().cancelTask(tablistTask); 74 | Bukkit.getOnlinePlayers().forEach(this::removeTablist); 75 | } 76 | 77 | public void createTablist(Player player) { 78 | UUID uuid = player.getUniqueId(); 79 | players.add(uuid); 80 | updateTablist(uuid); 81 | } 82 | 83 | public boolean updateTablist(UUID uuid) { 84 | if (!players.contains(uuid)) 85 | return false; 86 | 87 | Player player = Bukkit.getPlayer(uuid); 88 | 89 | if (player == null) 90 | return false; 91 | 92 | TablistHelper.sendTabList(player, PlaceholderUtil.setPlaceholders(header, player), 93 | PlaceholderUtil.setPlaceholders(footer, player)); 94 | 95 | return true; 96 | } 97 | 98 | public void removeTablist(Player player) { 99 | if (players.contains(player.getUniqueId())) { 100 | players.remove(player.getUniqueId()); 101 | TablistHelper.sendTabList(player, null, null); 102 | } 103 | } 104 | 105 | public List getPlayers() { 106 | return players; 107 | } 108 | 109 | @EventHandler 110 | public void onPlayerJoin(PlayerJoinEvent event) { 111 | Player player = event.getPlayer(); 112 | 113 | if (!inDisabledWorld(player.getLocation())) 114 | createTablist(player); 115 | } 116 | 117 | @EventHandler 118 | public void onPlayerQuit(PlayerQuitEvent event) { 119 | removeTablist(event.getPlayer()); 120 | } 121 | 122 | @EventHandler 123 | public void onWorldChange(PlayerTeleportEvent event) { 124 | Player player = event.getPlayer(); 125 | World fromWorld = event.getFrom().getWorld(); 126 | World toWorld = event.getTo().getWorld(); 127 | 128 | if (toWorld == null) return; 129 | if (fromWorld == toWorld) return; 130 | 131 | if (inDisabledWorld(toWorld) && players.contains(player.getUniqueId())) { 132 | removeTablist(player); 133 | return; 134 | } 135 | 136 | createTablist(player); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/visual/tablist/TablistUpdateTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.visual.tablist; 21 | 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | import java.util.UUID; 25 | 26 | public class TablistUpdateTask implements Runnable { 27 | private final TablistManager tablistManager; 28 | 29 | public TablistUpdateTask(TablistManager tablistManager) { 30 | this.tablistManager = tablistManager; 31 | } 32 | 33 | @Override 34 | public void run() { 35 | List toRemove = new ArrayList<>(); 36 | 37 | tablistManager.getPlayers().forEach(uuid -> { 38 | if (!tablistManager.updateTablist(uuid)) 39 | toRemove.add(uuid); 40 | }); 41 | 42 | tablistManager.getPlayers().removeAll(toRemove); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/world/AntiWorldDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.world; 21 | 22 | import com.google.common.io.ByteArrayDataOutput; 23 | import com.google.common.io.ByteStreams; 24 | import me.zetastormy.akropolis.AkropolisPlugin; 25 | import me.zetastormy.akropolis.Permissions; 26 | import me.zetastormy.akropolis.config.ConfigType; 27 | import me.zetastormy.akropolis.config.Message; 28 | import me.zetastormy.akropolis.module.Module; 29 | import me.zetastormy.akropolis.module.ModuleType; 30 | import me.zetastormy.akropolis.util.TextUtil; 31 | import org.bukkit.Bukkit; 32 | import org.bukkit.entity.Player; 33 | import org.bukkit.plugin.messaging.PluginMessageListener; 34 | 35 | public class AntiWorldDownloader extends Module implements PluginMessageListener { 36 | 37 | public AntiWorldDownloader(AkropolisPlugin plugin) { 38 | super(plugin, ModuleType.ANTI_WDL); 39 | } 40 | 41 | @Override 42 | public void onEnable() { 43 | getPlugin().getServer().getMessenger().registerIncomingPluginChannel(getPlugin(), "wdl:init", this); 44 | getPlugin().getServer().getMessenger().registerOutgoingPluginChannel(getPlugin(), "wdl:control"); 45 | } 46 | 47 | @Override 48 | public void onDisable() { 49 | getPlugin().getServer().getMessenger().unregisterIncomingPluginChannel(getPlugin(), "wdl:init"); 50 | getPlugin().getServer().getMessenger().unregisterOutgoingPluginChannel(getPlugin(), "wdl:control"); 51 | } 52 | 53 | @SuppressWarnings("NullableProblems") 54 | public void onPluginMessageReceived(String channel, Player player, byte[] data) { 55 | if (player.hasPermission(Permissions.ANTI_WDL_BYPASS.getPermission())) 56 | return; 57 | 58 | if (!channel.equals("wdl:init")) return; 59 | 60 | ByteArrayDataOutput out = ByteStreams.newDataOutput(); 61 | out.writeInt(0); 62 | out.writeBoolean(false); 63 | 64 | player.sendPluginMessage(getPlugin(), "wdl:control", out.toByteArray()); 65 | 66 | if (!getPlugin().getConfigManager().getFile(ConfigType.SETTINGS).get() 67 | .getBoolean("anti_wdl.admin_notify")) 68 | return; 69 | 70 | for (Player p : Bukkit.getOnlinePlayers()) { 71 | if (p.hasPermission(Permissions.ANTI_WDL_NOTIFY.getPermission())) { 72 | p.sendMessage(TextUtil.replace(Message.WORLD_DOWNLOAD_NOTIFY.toComponent(), "player", player.name())); 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/world/Launchpad.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.world; 21 | 22 | import com.cryptomorin.xseries.XMaterial; 23 | import me.zetastormy.akropolis.AkropolisPlugin; 24 | import me.zetastormy.akropolis.config.ConfigType; 25 | import me.zetastormy.akropolis.module.Module; 26 | import me.zetastormy.akropolis.module.ModuleType; 27 | import org.bukkit.Location; 28 | import org.bukkit.Material; 29 | import org.bukkit.configuration.file.FileConfiguration; 30 | import org.bukkit.entity.Player; 31 | import org.bukkit.event.EventHandler; 32 | import org.bukkit.event.block.Action; 33 | import org.bukkit.event.player.PlayerInteractEvent; 34 | 35 | import java.util.List; 36 | import java.util.Objects; 37 | 38 | public class Launchpad extends Module { 39 | private double launch; 40 | private double launchY; 41 | private List actions; 42 | private Material topBlock; 43 | private Material bottomBlock; 44 | 45 | public Launchpad(AkropolisPlugin plugin) { 46 | super(plugin, ModuleType.LAUNCHPAD); 47 | } 48 | 49 | @Override 50 | public void onEnable() { 51 | FileConfiguration config = getConfig(ConfigType.SETTINGS); 52 | launch = config.getDouble("launchpad.launch_power", 1.3); 53 | launchY = config.getDouble("launchpad.launch_power_y", 1.2); 54 | actions = config.getStringList("launchpad.actions"); 55 | 56 | if (launch > 4.0) 57 | launch = 4.0; 58 | if (launchY > 4.0) 59 | launchY = 4.0; 60 | 61 | 62 | String rawTopBlock = config.getString("launchpad.top_block"); 63 | String rawBottomBlock = config.getString("launchpad.bottom_block"); 64 | 65 | if (rawTopBlock == null) { 66 | getPlugin().getLogger().severe("Launchpad' top block is missing, using air item!"); 67 | XMaterial.matchXMaterial("AIR").ifPresent(m -> topBlock = m.get()); 68 | } else { 69 | XMaterial.matchXMaterial(rawTopBlock).ifPresent(m -> topBlock = m.get()); 70 | } 71 | 72 | if (rawBottomBlock == null) { 73 | getPlugin().getLogger().severe("Launchpad' bottom block is missing, using air item!"); 74 | XMaterial.matchXMaterial("AIR").ifPresent(m -> bottomBlock = m.get()); 75 | } else { 76 | XMaterial.matchXMaterial(rawBottomBlock).ifPresent(m -> bottomBlock = m.get()); 77 | } 78 | } 79 | 80 | @Override 81 | public void onDisable() { 82 | // TODO: Refactor to follow Liskov Substitution principle. 83 | } 84 | 85 | @EventHandler 86 | public void onLaunchPadInteract(PlayerInteractEvent event) { 87 | if (!event.hasBlock() || event.getAction() != Action.PHYSICAL) 88 | return; 89 | 90 | Player player = event.getPlayer(); 91 | Location playerLocation = player.getLocation(); 92 | Location blockLocation = Objects.requireNonNull(event.getClickedBlock()).getLocation(); 93 | 94 | if (inDisabledWorld(blockLocation)) 95 | return; 96 | 97 | // Check for launchpad block and cooldown 98 | if (blockLocation.getBlock().getType() == topBlock && blockLocation.subtract(0, 1, 0).getBlock().getType() == bottomBlock 99 | && tryCooldown(player.getUniqueId(), "launchpad", 1)) { 100 | player.setVelocity(playerLocation.getDirection().multiply(launch).setY(launchY)); 101 | executeActions(player, actions); 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/module/modules/world/LobbySpawn.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.module.modules.world; 21 | 22 | import me.zetastormy.akropolis.AkropolisPlugin; 23 | import me.zetastormy.akropolis.config.ConfigType; 24 | import me.zetastormy.akropolis.module.Module; 25 | import me.zetastormy.akropolis.module.ModuleType; 26 | import org.bukkit.Bukkit; 27 | import org.bukkit.Location; 28 | import org.bukkit.configuration.file.FileConfiguration; 29 | import org.bukkit.entity.Player; 30 | import org.bukkit.event.EventHandler; 31 | import org.bukkit.event.EventPriority; 32 | import org.bukkit.event.player.PlayerJoinEvent; 33 | import org.bukkit.event.player.PlayerRespawnEvent; 34 | 35 | public class LobbySpawn extends Module { 36 | private boolean spawnJoin; 37 | private Location location = null; 38 | 39 | public LobbySpawn(AkropolisPlugin plugin) { 40 | super(plugin, ModuleType.LOBBY); 41 | } 42 | 43 | @Override 44 | public void onEnable() { 45 | Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> { 46 | FileConfiguration config = getConfig(ConfigType.DATA); 47 | if (config.contains("spawn")) 48 | location = (Location) config.get("spawn"); 49 | }); 50 | 51 | spawnJoin = getConfig(ConfigType.SETTINGS).getBoolean("join_settings.spawn_join", false); 52 | } 53 | 54 | @Override 55 | public void onDisable() { 56 | getConfig(ConfigType.DATA).set("spawn", location); 57 | } 58 | 59 | public Location getLocation() { 60 | return location; 61 | } 62 | 63 | public void setLocation(Location location) { 64 | this.location = location; 65 | } 66 | 67 | @EventHandler(priority = EventPriority.HIGH) 68 | public void onPlayerJoin(PlayerJoinEvent event) { 69 | Player player = event.getPlayer(); 70 | if (spawnJoin && location != null) 71 | player.teleport(location); 72 | } 73 | 74 | @EventHandler(priority = EventPriority.HIGHEST) 75 | public void onPlayerRespawn(PlayerRespawnEvent event) { 76 | Player player = event.getPlayer(); 77 | if (location != null && !inDisabledWorld(player.getLocation())) 78 | event.setRespawnLocation(location); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/util/PlaceholderUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.util; 21 | 22 | import io.github.miniplaceholders.api.MiniPlaceholders; 23 | import me.clip.placeholderapi.PlaceholderAPI; 24 | import net.kyori.adventure.text.Component; 25 | import net.kyori.adventure.text.minimessage.tag.Tag; 26 | import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; 27 | import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; 28 | import org.bukkit.Bukkit; 29 | import org.bukkit.ChatColor; 30 | import org.bukkit.Location; 31 | import org.bukkit.entity.Player; 32 | 33 | public class PlaceholderUtil { 34 | private static boolean papi = false; 35 | private static boolean miniplaceholders = false; 36 | 37 | private PlaceholderUtil() { 38 | throw new UnsupportedOperationException(); 39 | } 40 | 41 | public static Component setPlaceholders(String rawText, Player player) { 42 | Component text = TextUtil.parse(rawText); 43 | 44 | if (rawText.contains("") && player != null) { 45 | text = TextUtil.parseAndReplace(TextUtil.raw(text), "player", player.name()); 46 | } 47 | 48 | if (rawText.contains("")) { 49 | text = TextUtil.parseAndReplace(TextUtil.raw(text), "online", Component.text(Bukkit.getOnlinePlayers().size())); 50 | } 51 | 52 | if (rawText.contains("")) { 53 | text = TextUtil.parseAndReplace(TextUtil.raw(text), "online_max", Component.text(Bukkit.getMaxPlayers())); 54 | } 55 | 56 | if (rawText.contains("") && player != null) { 57 | Location l = player.getLocation(); 58 | text = TextUtil.parseAndReplace(TextUtil.raw(text), "location", Component.text(l.getBlockX() + ", " + l.getBlockY() + ", " + l.getBlockZ())); 59 | } 60 | 61 | if (rawText.contains("") && player != null) { 62 | text = TextUtil.parseAndReplace(TextUtil.raw(text), "ping", Component.text(player.getPing())); 63 | } 64 | 65 | if (rawText.contains("") && player != null) { 66 | text = TextUtil.parseAndReplace(TextUtil.raw(text), "world", Component.text(player.getWorld().getName())); 67 | } 68 | 69 | if (papi && player != null) { 70 | text = TextUtil.parse(TextUtil.raw(text), papiTag(player)); 71 | } 72 | 73 | if (miniplaceholders && player != null) { 74 | text = TextUtil.parse(TextUtil.raw(text), MiniPlaceholders.getAudienceGlobalPlaceholders(player)); 75 | } 76 | 77 | return text; 78 | } 79 | 80 | @SuppressWarnings("deprecation") 81 | public static TagResolver papiTag(Player player) { 82 | return TagResolver.resolver("papi", (argumentQueue, context) -> { 83 | String papiPlaceholder = argumentQueue.popOr("papi tag requires an argument").value(); 84 | String parsedPlaceholder = TextUtil.raw(LegacyComponentSerializer 85 | .legacySection() 86 | .deserialize(ChatColor.translateAlternateColorCodes('&', 87 | PlaceholderAPI.setPlaceholders(player, '%' + papiPlaceholder + '%')))); 88 | 89 | return Tag.selfClosingInserting(TextUtil.parse(parsedPlaceholder)); 90 | }); 91 | } 92 | 93 | public static void setPapiState(boolean papiState) { 94 | papi = papiState; 95 | } 96 | 97 | public static void setMPState(boolean miniplaceholdersState) { 98 | miniplaceholders = miniplaceholdersState; 99 | } 100 | } -------------------------------------------------------------------------------- /src/main/java/me/zetastormy/akropolis/util/TextUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Akropolis 3 | * 4 | * Copyright (c) 2024 DevBlook Team and others 5 | * 6 | * Akropolis free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Akropolis is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Akropolis. If not, see . 18 | */ 19 | 20 | package me.zetastormy.akropolis.util; 21 | 22 | import net.kyori.adventure.text.Component; 23 | import net.kyori.adventure.text.minimessage.MiniMessage; 24 | import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; 25 | import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; 26 | import org.bukkit.Color; 27 | 28 | public class TextUtil { 29 | private static final MiniMessage MINI_MESSAGE = MiniMessage.miniMessage(); 30 | 31 | private TextUtil() { 32 | throw new UnsupportedOperationException(); 33 | } 34 | 35 | public static Component parse(String message) { 36 | return MINI_MESSAGE.deserialize(message); 37 | } 38 | 39 | public static Component parse(String message, TagResolver resolver) { 40 | return MINI_MESSAGE.deserialize(message, resolver); 41 | } 42 | 43 | public static String raw(Component message) { 44 | return MINI_MESSAGE.serialize(message).replaceAll("\\\\<", "<"); 45 | } 46 | 47 | public static Component parseAndReplace(String message, String pattern, Component replacement) { 48 | return MINI_MESSAGE.deserialize(message, Placeholder.component(pattern, replacement)); 49 | } 50 | 51 | public static Component replace(Component message, String pattern, Component replacement) { 52 | return MINI_MESSAGE.deserialize(raw(message), Placeholder.component(pattern, replacement)); 53 | } 54 | 55 | public static String joinString(int index, String[] args) { 56 | StringBuilder builder = new StringBuilder(); 57 | 58 | for (int i = index; i < args.length; i++) { 59 | builder.append(args[i]).append(" "); 60 | } 61 | 62 | return builder.toString(); 63 | } 64 | 65 | public static Color getColor(String s) { 66 | return switch (s.toUpperCase()) { 67 | case "AQUA" -> Color.AQUA; 68 | case "BLACK" -> Color.BLACK; 69 | case "BLUE" -> Color.BLUE; 70 | case "FUCHSIA" -> Color.FUCHSIA; 71 | case "GRAY" -> Color.GRAY; 72 | case "GREEN" -> Color.GREEN; 73 | case "LIME" -> Color.LIME; 74 | case "MAROON" -> Color.MAROON; 75 | case "NAVY" -> Color.NAVY; 76 | case "OLIVE" -> Color.OLIVE; 77 | case "ORANGE" -> Color.ORANGE; 78 | case "PURPLE" -> Color.PURPLE; 79 | case "RED" -> Color.RED; 80 | case "SILVER" -> Color.SILVER; 81 | case "TEAL" -> Color.TEAL; 82 | case "WHITE" -> Color.WHITE; 83 | case "YELLOW" -> Color.YELLOW; 84 | default -> null; 85 | }; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/resources/commands.yml: -------------------------------------------------------------------------------- 1 | # _ _ _ _ 2 | # / \ | | ___ __ ___ _ __ ___ | (_)___ 3 | # / _ \ | |/ / '__/ _ \| '_ \ / _ \| | / __| 4 | # / ___ \| <| | | (_) | |_) | (_) | | \__ \ 5 | # /_/ \_\_|\_\_| \___/| .__/ \___/|_|_|___/ 6 | # |_| 7 | #-------- 8 | # COMMANDS CUSTOMIZATION: 9 | # 10 | # In this file you can enable or disable commands of the plugin as you like, and even create 11 | # your own custom commands. ATTENTION: You will need to restart your server in order to apply 12 | # changes made to this file! 13 | #-------- 14 | # ACTIONS: 15 | # 16 | # [MESSAGE] - Send a message to the player 17 | # [BROADCAST] - Broadcast a message to everyone 18 | # [TITLE] [;fade-in][;stay][;fade-out] - Send the player a title message 19 | # [ACTIONBAR] - Send an action bar message 20 | # [SOUND] - Send the player a sound 21 | # [COMMAND] - Execute a command as the player 22 | # [CONSOLE] - Execute a command as console 23 | # [GAMEMODE] - Change a players' gamemode 24 | # [SERVER] - Send a player to a server 25 | # [EFFECT] - Give a potion effect 26 | # [MENU]

- Open a menu from (plugins/Akropolis/menus) 27 | # [CLOSE] - Close an open inventory 28 | #-------- 29 | # MESSAGE FORMATTING: 30 | # 31 | # The plugin uses MiniMessage to format the chat, 32 | # so you can use tags to color messages, like this: Red colored message! 33 | # You can also use HEX colors in an easy way, just like this: <#00ff00>R G B! 34 | # 35 | # More information about MiniMessage can be found here: https://docs.adventure.kyori.net/minimessage/format.html 36 | # There's also an online MiniMessage Viewer available: https://webui.adventure.kyori.net/ 37 | # 38 | 39 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 40 | # | CUSTOM COMMANDS | 41 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 42 | 43 | custom_commands: 44 | # Command name, this will be used as the main command 45 | website: 46 | # List any aliases for the command here 47 | aliases: 48 | - web 49 | # Actions to be executed 50 | actions: 51 | - "[MESSAGE] | Click here to navigate!'>Click here to visit www.example.com!" 52 | clearinventory: 53 | # Players will require this permission to execute this command. 54 | permission: akropolis.clearinventory 55 | aliases: 56 | - ci 57 | actions: 58 | - "[CONSOLE] minecraft:clear " 59 | - "[MESSAGE] | Your inventory has been cleared!" 60 | 61 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 62 | # | PLUGIN COMMANDS | 63 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 64 | 65 | commands: 66 | gamemode: 67 | enabled: true 68 | aliases: 69 | - gm 70 | gms: 71 | enabled: true 72 | gmc: 73 | enabled: true 74 | gma: 75 | enabled: true 76 | gmsp: 77 | enabled: true 78 | clearchat: 79 | enabled: true 80 | fly: 81 | enabled: true 82 | lockchat: 83 | enabled: true 84 | aliases: 85 | - lc 86 | setlobby: 87 | enabled: true 88 | lobby: 89 | enabled: true 90 | vanish: 91 | enabled: true 92 | aliases: 93 | - v 94 | -------------------------------------------------------------------------------- /src/main/resources/data.yml: -------------------------------------------------------------------------------- 1 | chat_locked: false 2 | -------------------------------------------------------------------------------- /src/main/resources/paper-plugin.yml: -------------------------------------------------------------------------------- 1 | name: Akropolis 2 | authors: [ ZetaStormy, ItsLewizzz ] 3 | version: ${version} 4 | description: A modern Minecraft server hub core solution. Based on DeluxeHub by ItsLewizzz. 5 | api-version: "1.21" 6 | main: me.zetastormy.akropolis.AkropolisPlugin 7 | loader: me.zetastormy.akropolis.AkropolisPluginLoader 8 | 9 | dependencies: 10 | server: 11 | Essentials: 12 | load: AFTER 13 | required: false 14 | PlaceholderAPI: 15 | load: BEFORE 16 | required: false 17 | HeadDatabase: 18 | load: BEFORE 19 | required: false 20 | Multiverse-Core: 21 | load: BEFORE 22 | required: false 23 | MiniPlaceholders: 24 | load: BEFORE 25 | required: false 26 | 27 | permissions: 28 | akropolis.*: 29 | description: Gives access to all Akropolis permissions 30 | children: 31 | akropolis.command.*: true 32 | akropolis.bypass.*: true 33 | akropolis.alert.*: true 34 | akropolis.item.*: true 35 | akropolis.player.*: true 36 | akropolis.block.*: true 37 | akropolis.command.*: 38 | description: Gives access to all command permissions 39 | children: 40 | akropolis.command.help: true 41 | akropolis.command.reload: true 42 | akropolis.command.scoreboard: true 43 | akropolis.command.openmenu: true 44 | akropolis.command.holograms: true 45 | akropolis.command.gamemode: true 46 | akropolis.command.gamemode.others: true 47 | akropolis.command.clearchat: true 48 | akropolis.command.lockchat: true 49 | akropolis.command.fly: true 50 | akropolis.command.fly.others: true 51 | akropolis.command.setlobby: true 52 | akropolis.command.vanish: true 53 | akropolis.bypass.*: 54 | description: Gives access to all bypass permissions 55 | children: 56 | akropolis.bypass.antiswear: true 57 | akropolis.bypass.commands: true 58 | akropolis.bypass.lockchat: true 59 | akropolis.bypass.antiwdl: true 60 | akropolis.bypass.doublejump: false 61 | akropolis.alert.*: 62 | description: Gives access to all alert permissions 63 | children: 64 | akropolis.alert.antiswear: true 65 | akropolis.alert.antiwdl: true 66 | akropolis.item.*: 67 | description: Gives access to all item based permissions 68 | children: 69 | akropolis.item.drop: true 70 | akropolis.item.pickup: true 71 | akropolis.player.*: 72 | description: Gives access to all player based permissions 73 | children: 74 | akropolis.player.pvp: true 75 | akropolis.block.*: 76 | description: Gives access to all block based permissions 77 | children: 78 | akropolis.block.break: true 79 | akropolis.block.place: true 80 | akropolis.block.interact: true 81 | akropolis.chat.group.*: 82 | description: Determines which chat format and cooldown time should be used 83 | children: 84 | akropolis.chat.group.default: true 85 | -------------------------------------------------------------------------------- /src/main/resources/serverselector.yml: -------------------------------------------------------------------------------- 1 | # _ _ _ _ 2 | # / \ | | ___ __ ___ _ __ ___ | (_)___ 3 | # / _ \ | |/ / '__/ _ \| '_ \ / _ \| | / __| 4 | # / ___ \| <| | | (_) | |_) | (_) | | \__ \ 5 | # /_/ \_\_|\_\_| \___/| .__/ \___/|_|_|___/ 6 | # |_| 7 | #-------- 8 | # SERVER SELECTOR GUI: 9 | # 10 | # The ID of this inventory is 'serverselector' which you can open using the [MENU] action (e.g. "[MENU] serverselector"). 11 | # You can create more custom GUIs, just copy this entire file and paste a new one in the menus' directory. 12 | # The name of the file is the menu ID. 13 | #-------- 14 | # PLAYER HEADS: 15 | # 16 | # You can have player heads, using player names, base64 or HeadDatabase IDs. 17 | # Examples: 18 | # Username (must have logged into the server once) 19 | # material: PLAYER_HEAD 20 | # username: 21 | # 22 | # Base64 23 | # material: PLAYER_HEAD 24 | # base64: 25 | # 26 | # HeadDatabase 27 | # material: PLAYER_HEAD 28 | # hdb: 29 | #-------- 30 | # ITEM FLAGS: 31 | # 32 | # You can add flags to the item (https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/ItemFlag.html) 33 | # Example: 34 | # item_flags: 35 | # - HIDE_ATTRIBUTES 36 | # - HIDE_DESTROYS 37 | # - HIDE_ENCHANTS 38 | # - HIDE_PLACED_ON 39 | # - HIDE_POTION_EFFECTS 40 | # - HIDE_UNBREAKABLE 41 | #-------- 42 | # ACTIONS: 43 | # 44 | # [MESSAGE] - Send a message to the player 45 | # [BROADCAST] - Broadcast a message to everyone 46 | # [TITLE] [;fade-in][;stay][;fade-out] - Send the player a title message 47 | # [ACTIONBAR] - Send an action bar message 48 | # [SOUND] - Send the player a sound 49 | # [COMMAND] - Execute a command as the player 50 | # [CONSOLE] - Execute a command as console 51 | # [GAMEMODE] - Change a players' gamemode 52 | # [SERVER] - Send a player to a server 53 | # [EFFECT] - Give a potion effect 54 | # [MENU] - Open a menu from (plugins/Akropolis/menus) 55 | # [CLOSE] - Close an open inventory 56 | #-------- 57 | # MESSAGE FORMATTING: 58 | # 59 | # The plugin uses MiniMessage to format the chat, 60 | # so you can use tags to color messages, like this: Red colored message! 61 | # You can also use HEX colors in an easy way, just like this: <#00ff00>R G B! 62 | # 63 | # More information about MiniMessage can be found here: https://docs.adventure.kyori.net/minimessage/format.html 64 | # There's also an online MiniMessage Viewer available: https://webui.adventure.kyori.net/ 65 | # 66 | 67 | # Slots of the GUI 68 | slots: 27 69 | 70 | # Title of the GUI 71 | title: "Server Selector" 72 | 73 | # Automatically update open inventories. 74 | # This can be used to update placeholders in the GUI. 75 | refresh: 76 | enabled: false 77 | rate: 40 78 | 79 | # The items inside the GUI can be listed here 80 | items: 81 | filler: 82 | material: GRAY_STAINED_GLASS_PANE 83 | slot: -1 # Setting the slot to -1 will fill every empty slot, you can also do "slots: [0, 1, 2]" 84 | factions: 85 | material: TNT 86 | slot: 11 87 | amount: 1 88 | glow: true 89 | display_name: "Factions" 90 | lore: 91 | - "» Join now to our coolest server!" 92 | actions: 93 | - "[CLOSE]" 94 | - "[MESSAGE] | Sending you to: Factions" 95 | - "[SERVER] factions" 96 | # For multi-world servers using Multiverse-Core, use the action: 97 | # - '[CONSOLE] mvtp world' 98 | survival: 99 | material: GRASS_BLOCK 100 | slot: 15 101 | amount: 1 102 | glow: false 103 | display_name: "Survival" 104 | lore: 105 | - "» Never gonna give you up!" 106 | actions: 107 | - "[CLOSE]" 108 | - "[MESSAGE] | Sending you to: Survival" 109 | - "[SERVER] survival" 110 | --------------------------------------------------------------------------------