4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.lgtm.yml:
--------------------------------------------------------------------------------
1 | extraction:
2 | java:
3 | index:
4 | java_version: 11
5 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | os: linux
2 | language: java
3 | dist: focal
4 | jdk:
5 | - openjdk11
6 |
7 | before_install:
8 | - chmod +x gradlew
9 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | plugins {
26 | id 'org.cadixdev.licenser' version '0.6.1' apply false
27 | }
28 |
29 | defaultTasks 'build', 'test', 'check', 'shadowJar'
30 |
31 | allprojects {
32 | group = 'com.github.derklaro'
33 | version = "2.0.0-SNAPSHOT-" + getCurrentShortRevision()
34 | }
35 |
36 | subprojects {
37 | apply plugin: 'checkstyle'
38 | apply plugin: 'java-library'
39 | apply plugin: 'maven-publish'
40 | apply plugin: 'org.cadixdev.licenser'
41 |
42 | repositories {
43 | mavenLocal()
44 | mavenCentral()
45 |
46 | maven {
47 | name = 'spigotmc'
48 | url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
49 | }
50 |
51 | maven {
52 | name = 'cloudnet-snapshots'
53 | url = 'https://repo.cloudnetservice.eu/repository/snapshots/'
54 | }
55 |
56 | maven {
57 | name = 'cloudnet-releases'
58 | url = 'https://repo.cloudnetservice.eu/repository/releases/'
59 | }
60 |
61 | maven {
62 | name = 'sonatype-releases'
63 | url = 'https://oss.sonatype.org/content/groups/public/'
64 | }
65 |
66 | maven {
67 | name = 'jitpack'
68 | url = 'https://jitpack.io'
69 | }
70 | }
71 |
72 | dependencies {
73 | compileOnly 'org.jetbrains:annotations:23.0.0'
74 | // lombok configuration
75 | compileOnly 'org.projectlombok:lombok:1.18.24'
76 | annotationProcessor 'org.projectlombok:lombok:1.18.24'
77 | }
78 |
79 | sourceCompatibility = '8'
80 | targetCompatibility = '8'
81 |
82 | publishing {
83 | publications {
84 | maven(MavenPublication) {
85 | from(components.java)
86 | }
87 | }
88 | }
89 |
90 | license {
91 | include '**/*.java'
92 | header = project.rootProject.file('license_header.txt')
93 | }
94 |
95 | tasks.withType(JavaCompile) {
96 | options.encoding = 'UTF-8'
97 | }
98 |
99 | tasks.withType(Checkstyle) {
100 | configFile = project.rootProject.file('checkstyle.xml')
101 | }
102 | }
103 |
104 | def getCurrentShortRevision() {
105 | new ByteArrayOutputStream().withStream { os ->
106 | exec {
107 | executable = "git"
108 | args = ["rev-parse", "HEAD"]
109 | standardOutput = os
110 | }
111 | return os.toString().trim().substring(0, 8)
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # This file is part of ps-system, licensed under the MIT License (MIT).
3 | #
4 | # Copyright (c) 2020-2021 Pasqual K. and contributors
5 | #
6 | # Permission is hereby granted, free of charge, to any person obtaining a copy
7 | # of this software and associated documentation files (the "Software"), to deal
8 | # in the Software without restriction, including without limitation the rights
9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | # copies of the Software, and to permit persons to whom the Software is
11 | # furnished to do so, subject to the following conditions:
12 | #
13 | # The above copyright notice and this permission notice shall be included in
14 | # all copies or substantial portions of the Software.
15 | #
16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | # THE SOFTWARE.
23 | #
24 | org.gradle.caching=true
25 | org.gradle.parallel=true
26 | org.gradle.warning.mode=all
27 | org.gradle.logging.level=info
28 | org.gradle.jvmargs=-Xmx512m -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8
29 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/derklaro/ps-system/e278df9284020e4a98d2450403efe634c2d0c7dd/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #
2 | # This file is part of ps-system, licensed under the MIT License (MIT).
3 | #
4 | # Copyright (c) 2020-2021 Pasqual K. and contributors
5 | #
6 | # Permission is hereby granted, free of charge, to any person obtaining a copy
7 | # of this software and associated documentation files (the "Software"), to deal
8 | # in the Software without restriction, including without limitation the rights
9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | # copies of the Software, and to permit persons to whom the Software is
11 | # furnished to do so, subject to the following conditions:
12 | #
13 | # The above copyright notice and this permission notice shall be included in
14 | # all copies or substantial portions of the Software.
15 | #
16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | # THE SOFTWARE.
23 | #
24 | distributionBase=GRADLE_USER_HOME
25 | distributionPath=wrapper/dists
26 | zipStoreBase=GRADLE_USER_HOME
27 | zipStorePath=wrapper/dists
28 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
29 | distributionSha256Sum=de8f52ad49bdc759164f72439a3bf56ddb1589c4cde802d3cec7d6ad0e0ee410
30 |
--------------------------------------------------------------------------------
/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 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/jitpack.yml:
--------------------------------------------------------------------------------
1 | before_install:
2 | - source "$HOME/.sdkman/bin/sdkman-init.sh"
3 | - sdk update
4 | - sdk install java 16.0.1.hs-adpt
5 | - sdk use java 16.0.1.hs-adpt
6 |
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 - 2021 Pasqual Koschmieder and contributors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/license_header.txt:
--------------------------------------------------------------------------------
1 | This file is part of ps-system, licensed under the MIT License (MIT).
2 |
3 | Copyright (c) 2020-2021 Pasqual K. and contributors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/ps-api-annotation-processor/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | plugins {
26 | id 'com.github.johnrengelman.shadow' version '7.1.2'
27 | }
28 |
29 | dependencies {
30 | api project(':ps-api')
31 | api 'com.google.code.gson:gson:2.9.0'
32 | }
33 |
34 | java {
35 | withJavadocJar()
36 | }
37 |
38 | shadowJar {
39 | archiveVersion.set(null)
40 | archiveFileName.set('ps-api-annotation-processor.jar')
41 | }
42 |
--------------------------------------------------------------------------------
/ps-api-annotation-processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor:
--------------------------------------------------------------------------------
1 | #
2 | # This file is part of ps-system, licensed under the MIT License (MIT).
3 | #
4 | # Copyright (c) 2020-2021 Pasqual K. and contributors
5 | #
6 | # Permission is hereby granted, free of charge, to any person obtaining a copy
7 | # of this software and associated documentation files (the "Software"), to deal
8 | # in the Software without restriction, including without limitation the rights
9 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | # copies of the Software, and to permit persons to whom the Software is
11 | # furnished to do so, subject to the following conditions:
12 | #
13 | # The above copyright notice and this permission notice shall be included in
14 | # all copies or substantial portions of the Software.
15 | #
16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | # THE SOFTWARE.
23 | #
24 |
25 | com.github.derklaro.privateservers.ap.ModuleAnnotationProcessor
26 |
--------------------------------------------------------------------------------
/ps-api/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | plugins {
26 | id 'com.github.johnrengelman.shadow' version '7.1.2'
27 | }
28 |
29 | dependencies {
30 | api 'net.kyori:adventure-api:4.11.0'
31 | api 'net.kyori:adventure-text-serializer-legacy:4.11.0'
32 | }
33 |
34 | java {
35 | withJavadocJar()
36 | }
37 |
38 | shadowJar {
39 | archiveVersion.set(null)
40 | archiveFileName.set('ps-api.jar')
41 | }
42 |
--------------------------------------------------------------------------------
/ps-api/src/main/java/com/github/derklaro/privateservers/api/Constants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.api;
26 |
27 | import org.jetbrains.annotations.ApiStatus;
28 |
29 | /**
30 | * Holds some constants which may be removed or change from version to version. Don't feel save if you use this
31 | * class for your plugin!
32 | */
33 | @ApiStatus.Internal
34 | public final class Constants {
35 |
36 | public static final String WHITELIST_JOIN_PERM = "ps.whitelist.bypass";
37 | public static final String WHITELIST_COMMAND_USE_PERM = "ps.command.whitelist";
38 | public static final String VISIBILITY_COMMAND_USE_PERM = "ps.command.visibility";
39 | public static final String SERVER_INFO_COMMAND_USE_PERM = "ps.command.server.info";
40 | public static final String SYSTEM_INFO_COMMAND_USE_PERM = "ps.command.system.info";
41 |
42 | private Constants() {
43 | throw new UnsupportedOperationException();
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/ps-api/src/main/java/com/github/derklaro/privateservers/api/Plugin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.api;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.CloudDetector;
28 | import com.github.derklaro.privateservers.api.module.ModuleLoader;
29 | import com.github.derklaro.privateservers.api.task.TaskManager;
30 | import org.jetbrains.annotations.NotNull;
31 |
32 | /**
33 | * Represents a plugin running on any platform. It holds general abstractions for common api methods which may be
34 | * required for different platforms or modules.
35 | */
36 | public interface Plugin {
37 | /**
38 | * Get the task manager instance of the platform the plugin is running on.
39 | *
40 | * @return the task manager instance.
41 | */
42 | @NotNull TaskManager getTaskManager();
43 |
44 | /**
45 | * Get the embedded cloud system detector, used to identify which underlying sub-system should be used to
46 | * start and manage services. The detector will (when initialized) also hold the current detected cloud system
47 | * instance.
48 | *
49 | * @return the embedded cloud system detector.
50 | */
51 | @NotNull CloudDetector getCloudSystemDetector();
52 |
53 | /**
54 | * Get the loader for the modules which loaded all modules supporting the base system.
55 | *
56 | * @return the current module loader instance.
57 | */
58 | @NotNull ModuleLoader getModuleLoader();
59 | }
60 |
--------------------------------------------------------------------------------
/ps-api/src/main/java/com/github/derklaro/privateservers/api/cloud/CloudDetector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.api.cloud;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.exception.CloudSystemAlreadyDetectedException;
28 | import com.github.derklaro.privateservers.api.cloud.exception.CloudSystemAlreadyRegisteredException;
29 | import org.jetbrains.annotations.NotNull;
30 |
31 | import java.util.Optional;
32 | import java.util.function.Supplier;
33 |
34 | /**
35 | * Represents a provider and detector for cloud systems.
36 | */
37 | public interface CloudDetector {
38 | /**
39 | * Registers a new cloud system for detection.
40 | *
41 | * @param requiredClass the class which is required to run the cloud system.
42 | * @param factory the factory to create a new instance of the cloud system.
43 | * @throws CloudSystemAlreadyRegisteredException thrown if the cloud system is already registered.
44 | */
45 | void registerCloudSystem(@NotNull String requiredClass, @NotNull Supplier factory) throws CloudSystemAlreadyRegisteredException;
46 |
47 | /**
48 | * Detects the best cloud system which can currently be ran.
49 | *
50 | * @throws CloudSystemAlreadyDetectedException thrown if a cloud system is already detected.
51 | */
52 | void detectCloudSystem() throws CloudSystemAlreadyDetectedException;
53 |
54 | /**
55 | * Get if a cloud system is already detected.
56 | *
57 | * @return if a cloud system is already detected.
58 | */
59 | boolean isCloudSystemDetected();
60 |
61 | /**
62 | * Get the detected cloud system if one got detected.
63 | *
64 | * @return the detected cloud system if one got detected.
65 | */
66 | @NotNull Optional getDetectedCloudSystem();
67 | }
68 |
--------------------------------------------------------------------------------
/ps-api/src/main/java/com/github/derklaro/privateservers/api/cloud/CloudSystem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.api.cloud;
26 |
27 | import org.jetbrains.annotations.NotNull;
28 |
29 | /**
30 | * Represents an embedded system which manages services.
31 | */
32 | public interface CloudSystem {
33 | /**
34 | * Get the class which must be present in order for the system to work.
35 | *
36 | * @return the class which must be present in order for the system to work.
37 | */
38 | @NotNull String getIdentifierClass();
39 |
40 | /**
41 | * Get the fully qualified name of this system.
42 | *
43 | * @return the fully qualified name of this system.
44 | */
45 | @NotNull String getName();
46 |
47 | /**
48 | * Get the manager which allows access to the underlying system.
49 | *
50 | * @return the manager which allows access to the underlying system.
51 | */
52 | @NotNull CloudServiceManager getCloudServiceManager();
53 | }
54 |
--------------------------------------------------------------------------------
/ps-api/src/main/java/com/github/derklaro/privateservers/api/cloud/configuration/CloudServiceConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.api.cloud.configuration;
26 |
27 | import lombok.AllArgsConstructor;
28 | import lombok.Data;
29 | import lombok.EqualsAndHashCode;
30 | import lombok.RequiredArgsConstructor;
31 | import lombok.ToString;
32 |
33 | import java.util.Collection;
34 | import java.util.UUID;
35 |
36 | /**
37 | * Represents a data class which holds all configuration options for a private server.
38 | */
39 | @Data
40 | @ToString
41 | @EqualsAndHashCode
42 | @AllArgsConstructor
43 | @RequiredArgsConstructor
44 | public class CloudServiceConfiguration {
45 |
46 | private final boolean autoDeleteAfterOwnerLeave;
47 | private final boolean autoSaveBeforeStop;
48 | private final int maxIdleSeconds;
49 |
50 | private final Collection whitelistedPlayers;
51 | private final UUID ownerUniqueId;
52 | private final String ownerName;
53 |
54 | private final String initialGroup;
55 | private final String initialTemplate;
56 | private final String initialTemplateBackend;
57 |
58 | private boolean publicService;
59 | private boolean whitelist;
60 |
61 | public int getMaxIdleSeconds() {
62 | return this.maxIdleSeconds > 0 ? this.maxIdleSeconds : 30;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/ps-api/src/main/java/com/github/derklaro/privateservers/api/cloud/connection/ConnectionRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.api.cloud.connection;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.service.CloudService;
28 | import org.jetbrains.annotations.NotNull;
29 |
30 | import java.util.UUID;
31 |
32 | /**
33 | * Represents a re-usable request of a player to join a specific cloud service.
34 | *
35 | * @see CloudService#createConnectionRequest(UUID)
36 | */
37 | public interface ConnectionRequest {
38 | /**
39 | * Get the service the player will be connected to when fired.
40 | *
41 | * @return the service the player will be connected to.
42 | */
43 | @NotNull CloudService getTargetService();
44 |
45 | /**
46 | * Get the unique id of the player which should be sent when fired.
47 | *
48 | * @return the unique id of the player which should be sent.
49 | */
50 | @NotNull UUID getTargetPlayer();
51 |
52 | /**
53 | * Fires the request connecting the player to the target service if it still exists.
54 | */
55 | void fire();
56 | }
57 |
--------------------------------------------------------------------------------
/ps-api/src/main/java/com/github/derklaro/privateservers/api/cloud/exception/CloudSystemAlreadyDetectedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.api.cloud.exception;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.CloudSystem;
28 | import org.jetbrains.annotations.NotNull;
29 |
30 | /**
31 | * Represents an exception fired when a cloud system is already detected and should be re-detected.
32 | */
33 | public class CloudSystemAlreadyDetectedException extends RuntimeException {
34 |
35 | private static final long serialVersionUID = -4867031072188003556L;
36 |
37 | public CloudSystemAlreadyDetectedException(@NotNull CloudSystem detectedSystem) {
38 | super("The cloud system " + detectedSystem.getName() + " is already detected, unable to re-detect");
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/ps-api/src/main/java/com/github/derklaro/privateservers/api/cloud/exception/CloudSystemAlreadyRegisteredException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.api.cloud.exception;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.CloudSystem;
28 | import org.jetbrains.annotations.NotNull;
29 |
30 | import java.util.function.Supplier;
31 |
32 | /**
33 | * Fired when a cloud system is registered twice to the same provider.
34 | */
35 | public class CloudSystemAlreadyRegisteredException extends RuntimeException {
36 |
37 | private static final long serialVersionUID = 5639173515905181782L;
38 |
39 | public CloudSystemAlreadyRegisteredException(@NotNull String requiredClass, @NotNull Supplier factory) {
40 | super("Tried to register cloud system detector for class " + requiredClass + " but it's already present @ " + factory);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/ps-api/src/main/java/com/github/derklaro/privateservers/api/cloud/service/CloudServiceInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.api.cloud.service;
26 |
27 | import org.jetbrains.annotations.NotNull;
28 |
29 | import java.net.InetSocketAddress;
30 |
31 | /**
32 | * Holds server specific information about a cloud service.
33 | */
34 | public interface CloudServiceInfo {
35 |
36 | /**
37 | * Get the address the service is bound to.
38 | *
39 | * @return the bound address of the service.
40 | */
41 | @NotNull InetSocketAddress getAddress();
42 |
43 | /**
44 | * Get the motd (message of the day) of the service.
45 | *
46 | * @return the motd of the service.
47 | */
48 | @NotNull String getMessageOfTheDay();
49 |
50 | /**
51 | * Get the state of the service.
52 | *
53 | * @return the state of the service.
54 | */
55 | @NotNull String getState();
56 |
57 | /**
58 | * Get the amount of player currently connected to the service.
59 | *
60 | * @return the amount of players connected to the service.
61 | */
62 | int getOnlineCount();
63 |
64 | /**
65 | * Get the maximum amount of players that can connect to the service.
66 | *
67 | * @return the maximum player count of the service.
68 | */
69 | int getMaximumPlayerCount();
70 |
71 | /**
72 | * Get the maximum heap memory size the service can use.
73 | *
74 | * @return the maximum heap memory of the service.
75 | */
76 | int getHeapMemory();
77 | }
78 |
--------------------------------------------------------------------------------
/ps-api/src/main/java/com/github/derklaro/privateservers/api/cloud/service/ServiceListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.api.cloud.service;
26 |
27 | import org.jetbrains.annotations.NotNull;
28 |
29 | /**
30 | * Represents a common listener for service state changes.
31 | */
32 | public interface ServiceListener {
33 | /**
34 | * Called when a new service registers into the system.
35 | *
36 | * @param cloudService the cloud service registered.
37 | */
38 | void handleServiceRegister(@NotNull CloudService cloudService);
39 |
40 | /**
41 | * Called when any change happens to a cloud service.
42 | *
43 | * @param cloudService the changed service.
44 | */
45 | void handleServerUpdate(@NotNull CloudService cloudService);
46 |
47 | /**
48 | * Called when a service unregisters from the system.
49 | *
50 | * @param cloudService the unregistered service.
51 | */
52 | void handleServiceUnregister(@NotNull CloudService cloudService);
53 | }
54 |
--------------------------------------------------------------------------------
/ps-api/src/main/java/com/github/derklaro/privateservers/api/cloud/service/template/CloudServiceTemplate.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.api.cloud.service.template;
26 |
27 | import net.kyori.adventure.util.Buildable;
28 | import org.jetbrains.annotations.NotNull;
29 |
30 | /**
31 | * Represents a template which holds files for a service.
32 | */
33 | public interface CloudServiceTemplate extends Buildable {
34 | /**
35 | * Creates a new builder instance for a template.
36 | *
37 | * @return a new builder instance for a template.
38 | */
39 | static @NotNull CloudServiceTemplate.Builder builder() {
40 | return new DefaultCloudServiceTemplate.DefaultBuilder();
41 | }
42 |
43 | /**
44 | * Get the name of the template.
45 | *
46 | * @return the name of the template.
47 | */
48 | @NotNull String templateName();
49 |
50 | /**
51 | * Get the backend name of the template.
52 | *
53 | * @return the backend name of the template.
54 | */
55 | @NotNull String templateBackend();
56 |
57 | /**
58 | * Represents a builder for a template.
59 | */
60 | interface Builder extends Buildable.Builder {
61 | /**
62 | * Sets the name of the template.
63 | *
64 | * @param templateName the name of the template.
65 | * @return the same instance of this class, for chaining.
66 | */
67 | @NotNull Builder templateName(@NotNull String templateName);
68 |
69 | /**
70 | * Sets the name of the backend the template is located in.
71 | *
72 | * @param templateBackend the name of the backend the template is located in.
73 | * @return the same instance of this class, for chaining.
74 | */
75 | @NotNull Builder templateBackend(@NotNull String templateBackend);
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/ps-api/src/main/java/com/github/derklaro/privateservers/api/cloud/service/template/DefaultCloudServiceTemplate.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.api.cloud.service.template;
26 |
27 | import org.jetbrains.annotations.NotNull;
28 |
29 | import java.util.Objects;
30 |
31 | final class DefaultCloudServiceTemplate implements CloudServiceTemplate {
32 |
33 | private final String templateName;
34 | private final String templateBackend;
35 |
36 | public DefaultCloudServiceTemplate(String templateName, String templateBackend) {
37 | this.templateName = Objects.requireNonNull(templateName, "templateName");
38 | this.templateBackend = Objects.requireNonNull(templateBackend, "templateBackend");
39 | }
40 |
41 | @Override
42 | public @NotNull String templateName() {
43 | return this.templateName;
44 | }
45 |
46 | @Override
47 | public @NotNull String templateBackend() {
48 | return this.templateBackend;
49 | }
50 |
51 | @Override
52 | public @NotNull CloudServiceTemplate.Builder toBuilder() {
53 | return CloudServiceTemplate.builder()
54 | .templateName(this.templateName)
55 | .templateBackend(this.templateBackend);
56 | }
57 |
58 | public static final class DefaultBuilder implements CloudServiceTemplate.Builder {
59 |
60 | private String templateName;
61 | private String templateBackend;
62 |
63 | @Override
64 | public @NotNull Builder templateName(@NotNull String templateName) {
65 | this.templateName = Objects.requireNonNull(templateName, "templateName");
66 | return this;
67 | }
68 |
69 | @Override
70 | public @NotNull Builder templateBackend(@NotNull String templateBackend) {
71 | this.templateBackend = Objects.requireNonNull(templateBackend, "templateBackend");
72 | return this;
73 | }
74 |
75 | @Override
76 | public @NotNull CloudServiceTemplate build() {
77 | return new DefaultCloudServiceTemplate(this.templateName, this.templateBackend);
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/ps-api/src/main/java/com/github/derklaro/privateservers/api/configuration/NpcConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.api.configuration;
26 |
27 | import lombok.AllArgsConstructor;
28 | import lombok.Data;
29 | import lombok.EqualsAndHashCode;
30 | import lombok.ToString;
31 |
32 | /**
33 | * Represents the configuration for the npcs.
34 | */
35 | @Data
36 | @ToString
37 | @EqualsAndHashCode
38 | @AllArgsConstructor
39 | public class NpcConfiguration {
40 |
41 | private int actionDistance;
42 | private int spawnDistance;
43 | private int tablistRemovalTicks;
44 |
45 | private boolean imitatePlayer;
46 | private boolean lookAtPlayer;
47 |
48 | private LabyModConfiguration labyModConfiguration;
49 | private KnockbackConfiguration knockbackConfiguration;
50 |
51 | public NpcConfiguration() {
52 | this.actionDistance = 20;
53 | this.spawnDistance = 50;
54 | this.tablistRemovalTicks = 30;
55 |
56 | this.imitatePlayer = true;
57 | this.lookAtPlayer = true;
58 |
59 | this.labyModConfiguration = new LabyModConfiguration();
60 | this.knockbackConfiguration = new KnockbackConfiguration();
61 | }
62 |
63 | @Data
64 | @ToString
65 | @EqualsAndHashCode
66 | public static class LabyModConfiguration {
67 |
68 | private int[] emoteIds;
69 | private int emoteDelayTicks;
70 |
71 | public LabyModConfiguration() {
72 | this.emoteIds = new int[]{2, 49};
73 | this.emoteDelayTicks = 20 * 20;
74 | }
75 | }
76 |
77 | @Data
78 | @ToString
79 | @EqualsAndHashCode
80 | public static class KnockbackConfiguration {
81 |
82 | private boolean enabled;
83 | private String bypassPermission;
84 | private double knockbackDistance;
85 | private double knockbackStrength;
86 |
87 | public KnockbackConfiguration() {
88 | this.enabled = true;
89 | this.bypassPermission = "ps.npc.knockback.bypass";
90 | this.knockbackDistance = 1.0;
91 | this.knockbackStrength = 0.8;
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/ps-api/src/main/java/com/github/derklaro/privateservers/api/module/ModuleContainer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.api.module;
26 |
27 | import com.github.derklaro.privateservers.api.module.annotation.ModuleDescription;
28 | import org.jetbrains.annotations.ApiStatus;
29 | import org.jetbrains.annotations.NotNull;
30 |
31 | import java.net.URLClassLoader;
32 | import java.nio.file.Path;
33 |
34 | /**
35 | * Represents a loaded module in the runtime.
36 | */
37 | public interface ModuleContainer {
38 | /**
39 | * Get the description file of the module.
40 | *
41 | * @return the description file of the module.
42 | */
43 | @NotNull ModuleDescription getDescription();
44 |
45 | /**
46 | * Get the current state of the module.
47 | *
48 | * @return the current state of the module.
49 | */
50 | @NotNull ModuleState getState();
51 |
52 | /**
53 | * Get the class loader used to load the module main class.
54 | *
55 | * @return the class loader used to load the module main class.
56 | */
57 | @NotNull URLClassLoader getClassLoader();
58 |
59 | /**
60 | * Get the path where the module was loaded from.
61 | *
62 | * @return the path where the module was loaded from.
63 | */
64 | @NotNull Path getModulePath();
65 |
66 | /**
67 | * Get the main class of the module.
68 | *
69 | * @return the main class of the module.
70 | */
71 | @NotNull Class> getMainClass();
72 |
73 | /**
74 | * Get the instance of the module created during the load.
75 | *
76 | * @return the instance of the module.
77 | */
78 | @NotNull Object getInstance();
79 |
80 | /**
81 | * Sets the current state of this module.
82 | *
83 | * @param moduleState the new state of the module.
84 | */
85 | @ApiStatus.Internal
86 | void setModuleState(@NotNull ModuleState moduleState);
87 | }
88 |
--------------------------------------------------------------------------------
/ps-api/src/main/java/com/github/derklaro/privateservers/api/module/ModuleLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.api.module;
26 |
27 | import com.github.derklaro.privateservers.api.Plugin;
28 | import com.github.derklaro.privateservers.api.module.exception.ModuleMainClassNotFoundException;
29 | import org.jetbrains.annotations.NotNull;
30 | import org.jetbrains.annotations.UnmodifiableView;
31 |
32 | import java.util.Collection;
33 | import java.util.Optional;
34 |
35 | public interface ModuleLoader {
36 |
37 | void detectModules();
38 |
39 | void loadModules(@NotNull Plugin loader, @NotNull ClassLoader classLoader) throws ModuleMainClassNotFoundException;
40 |
41 | void disableModules();
42 |
43 | @NotNull Optional getModuleByInstance(@NotNull Object instance);
44 |
45 | @NotNull Optional getModuleById(@NotNull String id);
46 |
47 | @NotNull @UnmodifiableView Collection getModules();
48 | }
49 |
--------------------------------------------------------------------------------
/ps-api/src/main/java/com/github/derklaro/privateservers/api/module/ModuleState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.api.module;
26 |
27 | /**
28 | * The states a module can be in.
29 | */
30 | public enum ModuleState {
31 | /**
32 | * The module is enabled and loaded.
33 | */
34 | ENABLED,
35 | /**
36 | * The module is loaded but currently disabled.
37 | */
38 | DISABLED
39 | }
40 |
--------------------------------------------------------------------------------
/ps-api/src/main/java/com/github/derklaro/privateservers/api/module/annotation/Module.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.api.module.annotation;
26 |
27 | import org.jetbrains.annotations.NotNull;
28 |
29 | import java.lang.annotation.Documented;
30 | import java.lang.annotation.ElementType;
31 | import java.lang.annotation.Retention;
32 | import java.lang.annotation.RetentionPolicy;
33 | import java.lang.annotation.Target;
34 |
35 | /**
36 | * Represents a module configuration. This configuration will be moved into a module.json during the compile time.
37 | */
38 | @Documented
39 | @Retention(RetentionPolicy.RUNTIME)
40 | @Target(ElementType.TYPE)
41 | public @interface Module {
42 | /**
43 | * Get the id namespace of the module.
44 | *
45 | * @return the id namespace of the module.
46 | */
47 | @NotNull String id();
48 |
49 | /**
50 | * Get the display name of the module. Empty by default.
51 | *
52 | * @return the display name of the module.
53 | */
54 | @NotNull String displayName() default "";
55 |
56 | /**
57 | * Get the version of the module.
58 | *
59 | * @return the version of the module.
60 | */
61 | @NotNull String version();
62 |
63 | /**
64 | * Get the website of the module. Empty by default.
65 | *
66 | * @return he website of the module.
67 | */
68 | @NotNull String website() default "";
69 |
70 | /**
71 | * Get the description of the module. Empty by default.
72 | *
73 | * @return the description of the module.
74 | */
75 | @NotNull String description() default "";
76 |
77 | /**
78 | * Get the authors of the module. Empty by default.
79 | *
80 | * @return the authors of the module.
81 | */
82 | @NotNull String[] authors() default "";
83 | }
84 |
--------------------------------------------------------------------------------
/ps-api/src/main/java/com/github/derklaro/privateservers/api/module/annotation/ModuleDescription.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.api.module.annotation;
26 |
27 | import lombok.Data;
28 | import lombok.EqualsAndHashCode;
29 | import lombok.ToString;
30 |
31 | /**
32 | * Represents a written file based of a {@link Module} annotation.
33 | */
34 | @Data
35 | @ToString
36 | @EqualsAndHashCode
37 | public class ModuleDescription {
38 |
39 | private final String id;
40 | private final String displayName;
41 | private final String version;
42 | private final String website;
43 | private final String description;
44 | private final String mainClass;
45 | private final String[] authors;
46 |
47 | public static ModuleDescription from(Module annotation, String mainClass) {
48 | return new ModuleDescription(annotation.id(), annotation.displayName(), annotation.version(),
49 | annotation.website(), annotation.description(), mainClass, annotation.authors());
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/ps-api/src/main/java/com/github/derklaro/privateservers/api/module/exception/ModuleMainClassNotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.api.module.exception;
26 |
27 | import java.nio.file.Path;
28 |
29 | /**
30 | * An exception thrown when the main class of a module can not be found.
31 | */
32 | public class ModuleMainClassNotFoundException extends RuntimeException {
33 |
34 | private static final long serialVersionUID = 2719365883380259224L;
35 |
36 | public ModuleMainClassNotFoundException(Path path) {
37 | super("Unable to find ps_module.json in " + path);
38 | }
39 |
40 | public ModuleMainClassNotFoundException(String mainClass, Path path) {
41 | super("Unable to find main-class " + mainClass + " in " + path);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/ps-cloudnet2-legacy/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | dependencies {
26 | annotationProcessor project(':ps-api-annotation-processor')
27 | compileOnly project(':ps-common')
28 | compileOnly 'de.dytanic.cloudnet:cloudnet-api-bridge:2.1.17'
29 | compileOnly 'org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT'
30 | }
31 |
32 | java {
33 | withJavadocJar()
34 | }
35 |
36 | jar {
37 | archiveVersion.set(null)
38 | archiveFileName.set('ps-cloudnet2-legacy.jar')
39 | }
40 |
--------------------------------------------------------------------------------
/ps-cloudnet2-legacy/src/main/java/com/github/derklaro/privateservers/cloudnet/v2/legacy/CloudNetV2LegacyModule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.cloudnet.v2.legacy;
26 |
27 | import com.github.derklaro.privateservers.api.Plugin;
28 | import com.github.derklaro.privateservers.api.module.annotation.Module;
29 | import com.github.derklaro.privateservers.cloudnet.v2.legacy.cloud.CloudNetV2CloudSystem;
30 | import org.jetbrains.annotations.NotNull;
31 |
32 | @Module(
33 | id = "com.github.derklaro.privateservers.cloudnet.v2.legacy",
34 | displayName = "CloudNetV2LegacyPrivateServerModule",
35 | version = "1.1.0",
36 | description = "Module for private servers cloudnet v2 integration",
37 | authors = "derklaro"
38 | )
39 | public class CloudNetV2LegacyModule {
40 |
41 | private static final String IDENTITY_CLASS = "de.dytanic.cloudnet.lib.utility.CollectionWrapper";
42 |
43 | public CloudNetV2LegacyModule(@NotNull Plugin plugin) {
44 | plugin.getCloudSystemDetector().registerCloudSystem(IDENTITY_CLASS, CloudNetV2CloudSystem::new);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/ps-cloudnet2-legacy/src/main/java/com/github/derklaro/privateservers/cloudnet/v2/legacy/cloud/CloudNetV2CloudServiceInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.cloudnet.v2.legacy.cloud;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.service.CloudServiceInfo;
28 | import de.dytanic.cloudnet.lib.server.info.ServerInfo;
29 | import org.jetbrains.annotations.NotNull;
30 |
31 | import java.net.InetSocketAddress;
32 |
33 | final class CloudNetV2CloudServiceInfo implements CloudServiceInfo {
34 |
35 | private final ServerInfo handle;
36 |
37 | public CloudNetV2CloudServiceInfo(ServerInfo handle) {
38 | this.handle = handle;
39 | }
40 |
41 | @Override
42 | public @NotNull InetSocketAddress getAddress() {
43 | return new InetSocketAddress(this.handle.getHost(), this.handle.getPort());
44 | }
45 |
46 | @Override
47 | public @NotNull String getMessageOfTheDay() {
48 | return this.handle.getMotd();
49 | }
50 |
51 | @Override
52 | public @NotNull String getState() {
53 | return this.handle.getServerState().name();
54 | }
55 |
56 | @Override
57 | public int getOnlineCount() {
58 | return this.handle.getOnlineCount();
59 | }
60 |
61 | @Override
62 | public int getMaximumPlayerCount() {
63 | return this.handle.getMaxPlayers();
64 | }
65 |
66 | @Override
67 | public int getHeapMemory() {
68 | return this.handle.getMemory();
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/ps-cloudnet2-legacy/src/main/java/com/github/derklaro/privateservers/cloudnet/v2/legacy/cloud/CloudNetV2CloudSystem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.cloudnet.v2.legacy.cloud;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.CloudServiceManager;
28 | import com.github.derklaro.privateservers.api.cloud.CloudSystem;
29 | import com.github.derklaro.privateservers.cloudnet.v2.legacy.listeners.CloudNetV2CloudServiceListener;
30 | import com.github.derklaro.privateservers.cloudnet.v2.legacy.listeners.CloudServiceStartAwaitListener;
31 | import de.dytanic.cloudnet.bridge.CloudServer;
32 | import org.bukkit.Bukkit;
33 | import org.jetbrains.annotations.NotNull;
34 |
35 | public class CloudNetV2CloudSystem implements CloudSystem {
36 |
37 | public CloudNetV2CloudSystem() {
38 | Bukkit.getPluginManager().registerEvents(new CloudNetV2CloudServiceListener(this), CloudServer.getInstance().getPlugin());
39 | Bukkit.getPluginManager().registerEvents(new CloudServiceStartAwaitListener(), CloudServer.getInstance().getPlugin());
40 | }
41 |
42 | @Override
43 | public @NotNull String getIdentifierClass() {
44 | return "de.dytanic.cloudnet.lib.utility.CollectionWrapper";
45 | }
46 |
47 | @Override
48 | public @NotNull String getName() {
49 | return "CloudNetV2-Legacy";
50 | }
51 |
52 | @Override
53 | public @NotNull CloudServiceManager getCloudServiceManager() {
54 | return CloudNetV2CloudServiceManager.INSTANCE;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/ps-cloudnet2-legacy/src/main/java/com/github/derklaro/privateservers/cloudnet/v2/legacy/connection/CloudNetV2ConnectionRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.cloudnet.v2.legacy.connection;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.service.CloudService;
28 | import com.github.derklaro.privateservers.common.cloud.util.DefaultConnectionRequest;
29 | import com.google.common.base.Preconditions;
30 | import de.dytanic.cloudnet.api.CloudAPI;
31 | import de.dytanic.cloudnet.lib.utility.document.Document;
32 | import org.jetbrains.annotations.NotNull;
33 |
34 | import java.util.UUID;
35 |
36 | public class CloudNetV2ConnectionRequest extends DefaultConnectionRequest {
37 |
38 | protected CloudNetV2ConnectionRequest(CloudService targetService, UUID targetPlayer) {
39 | super(targetService, targetPlayer);
40 | }
41 |
42 | public static CloudNetV2ConnectionRequest of(@NotNull CloudService targetService, @NotNull UUID player) {
43 | Preconditions.checkNotNull(targetService, "targetService");
44 | Preconditions.checkNotNull(player, "player");
45 |
46 | return new CloudNetV2ConnectionRequest(targetService, player);
47 | }
48 |
49 | @Override
50 | public void fire() {
51 | CloudAPI.getInstance().sendCustomSubProxyMessage(
52 | "cloudnet_internal",
53 | "sendPlayer",
54 | new Document("uniqueId", super.getTargetPlayer()).append("server", super.getTargetService().getName())
55 | );
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/ps-cloudnet2-legacy/src/main/java/com/github/derklaro/privateservers/cloudnet/v2/legacy/listeners/CloudNetV2CloudServiceListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.cloudnet.v2.legacy.listeners;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.CloudSystem;
28 | import com.github.derklaro.privateservers.cloudnet.v2.legacy.cloud.CloudNetV2CloudService;
29 | import de.dytanic.cloudnet.bridge.event.bukkit.BukkitServerAddEvent;
30 | import de.dytanic.cloudnet.bridge.event.bukkit.BukkitServerInfoUpdateEvent;
31 | import de.dytanic.cloudnet.bridge.event.bukkit.BukkitServerRemoveEvent;
32 | import org.bukkit.event.EventHandler;
33 | import org.bukkit.event.Listener;
34 | import org.jetbrains.annotations.NotNull;
35 |
36 | public class CloudNetV2CloudServiceListener implements Listener {
37 |
38 | private final CloudSystem cloudSystem;
39 |
40 | public CloudNetV2CloudServiceListener(CloudSystem cloudSystem) {
41 | this.cloudSystem = cloudSystem;
42 | }
43 |
44 | @EventHandler
45 | public void handleStart(@NotNull BukkitServerAddEvent event) {
46 | CloudNetV2CloudService.fromServerInfo(event.getServerInfo()).ifPresent(
47 | cloudService -> this.cloudSystem.getCloudServiceManager().getUnsafe().handleCloudServiceStart(cloudService)
48 | );
49 | }
50 |
51 | @EventHandler
52 | public void handleUpdate(@NotNull BukkitServerInfoUpdateEvent event) {
53 | CloudNetV2CloudService.fromServerInfo(event.getServerInfo()).ifPresent(
54 | cloudService -> this.cloudSystem.getCloudServiceManager().getUnsafe().handleCloudServiceUpdate(cloudService)
55 | );
56 | }
57 |
58 | @EventHandler
59 | public void handleStop(@NotNull BukkitServerRemoveEvent event) {
60 | CloudNetV2CloudService.fromServerInfo(event.getServerInfo()).ifPresent(
61 | cloudService -> this.cloudSystem.getCloudServiceManager().getUnsafe().handleCloudServiceStop(cloudService)
62 | );
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/ps-cloudnet2-legacy/src/main/java/com/github/derklaro/privateservers/cloudnet/v2/legacy/listeners/CloudServiceStartAwaitListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.cloudnet.v2.legacy.listeners;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.service.CloudService;
28 | import com.github.derklaro.privateservers.cloudnet.v2.legacy.cloud.CloudNetV2CloudService;
29 | import de.dytanic.cloudnet.bridge.event.bukkit.BukkitServerAddEvent;
30 | import org.bukkit.event.EventHandler;
31 | import org.bukkit.event.Listener;
32 | import org.jetbrains.annotations.NotNull;
33 |
34 | import java.util.Map;
35 | import java.util.UUID;
36 | import java.util.concurrent.CompletableFuture;
37 | import java.util.concurrent.ConcurrentHashMap;
38 |
39 | public class CloudServiceStartAwaitListener implements Listener {
40 |
41 | private static final Map> FUTURE_MAP = new ConcurrentHashMap<>();
42 |
43 | @NotNull
44 | public static CompletableFuture awaitStart(@NotNull UUID waitUniqueID) {
45 | CompletableFuture future = new CompletableFuture<>();
46 | FUTURE_MAP.put(waitUniqueID.toString(), future);
47 | return future;
48 | }
49 |
50 | @EventHandler
51 | public void handleStart(@NotNull BukkitServerAddEvent event) {
52 | String waitUniqueID = event.getServerInfo().getServerConfig().getProperties().getString("ps::wait");
53 | if (waitUniqueID == null) {
54 | return;
55 | }
56 |
57 | CompletableFuture future = FUTURE_MAP.remove(waitUniqueID);
58 | if (future == null) {
59 | return;
60 | }
61 |
62 | future.complete(CloudNetV2CloudService.fromServerInfo(event.getServerInfo()).orElse(null));
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/ps-cloudnet2/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | dependencies {
26 | annotationProcessor project(':ps-api-annotation-processor')
27 | compileOnly project(':ps-common')
28 | compileOnly 'de.dytanic.cloudnet:cloudnet-api-bridge:2.2.0-SNAPSHOT'
29 | compileOnly 'org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT'
30 | }
31 |
32 | java {
33 | withJavadocJar()
34 | }
35 |
36 | jar {
37 | archiveVersion.set(null)
38 | archiveFileName.set('ps-cloudnet2.jar')
39 | }
40 |
--------------------------------------------------------------------------------
/ps-cloudnet2/src/main/java/com/github/derklaro/privateservers/cloudnet/v2/CloudNetV2Module.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.cloudnet.v2;
26 |
27 | import com.github.derklaro.privateservers.api.Plugin;
28 | import com.github.derklaro.privateservers.api.module.annotation.Module;
29 | import com.github.derklaro.privateservers.cloudnet.v2.cloud.CloudNetV2CloudSystem;
30 | import org.jetbrains.annotations.NotNull;
31 |
32 | @Module(
33 | id = "com.github.derklaro.privateservers.cloudnet.v2",
34 | displayName = "CloudNetV2PrivateServerModule",
35 | version = "1.1.0",
36 | description = "Module for private servers cloudnet v2.2 integration",
37 | authors = "derklaro"
38 | )
39 | public class CloudNetV2Module {
40 |
41 | private static final String IDENTITY_CLASS = "de.dytanic.cloudnet.api.builders.ApiServerProcessBuilder";
42 |
43 | public CloudNetV2Module(@NotNull Plugin plugin) {
44 | plugin.getCloudSystemDetector().registerCloudSystem(IDENTITY_CLASS, CloudNetV2CloudSystem::new);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/ps-cloudnet2/src/main/java/com/github/derklaro/privateservers/cloudnet/v2/cloud/CloudNetV2CloudServiceInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.cloudnet.v2.cloud;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.service.CloudServiceInfo;
28 | import de.dytanic.cloudnet.lib.server.info.ServerInfo;
29 | import org.jetbrains.annotations.NotNull;
30 |
31 | import java.net.InetSocketAddress;
32 |
33 | final class CloudNetV2CloudServiceInfo implements CloudServiceInfo {
34 |
35 | private final ServerInfo handle;
36 |
37 | public CloudNetV2CloudServiceInfo(ServerInfo handle) {
38 | this.handle = handle;
39 | }
40 |
41 | @Override
42 | public @NotNull InetSocketAddress getAddress() {
43 | return new InetSocketAddress(this.handle.getHost(), this.handle.getPort());
44 | }
45 |
46 | @Override
47 | public @NotNull String getMessageOfTheDay() {
48 | return this.handle.getMotd();
49 | }
50 |
51 | @Override
52 | public @NotNull String getState() {
53 | return this.handle.getServerState().name();
54 | }
55 |
56 | @Override
57 | public int getOnlineCount() {
58 | return this.handle.getOnlineCount();
59 | }
60 |
61 | @Override
62 | public int getMaximumPlayerCount() {
63 | return this.handle.getMaxPlayers();
64 | }
65 |
66 | @Override
67 | public int getHeapMemory() {
68 | return this.handle.getMemory();
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/ps-cloudnet2/src/main/java/com/github/derklaro/privateservers/cloudnet/v2/cloud/CloudNetV2CloudSystem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.cloudnet.v2.cloud;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.CloudServiceManager;
28 | import com.github.derklaro.privateservers.api.cloud.CloudSystem;
29 | import com.github.derklaro.privateservers.cloudnet.v2.listeners.CloudNetV2CloudServiceListener;
30 | import de.dytanic.cloudnet.bridge.CloudServer;
31 | import org.bukkit.Bukkit;
32 | import org.jetbrains.annotations.NotNull;
33 |
34 | public class CloudNetV2CloudSystem implements CloudSystem {
35 |
36 | public CloudNetV2CloudSystem() {
37 | Bukkit.getPluginManager().registerEvents(new CloudNetV2CloudServiceListener(this), CloudServer.getInstance().getPlugin());
38 | }
39 |
40 | @Override
41 | public @NotNull String getIdentifierClass() {
42 | return "de.dytanic.cloudnet.api.builders.ApiServerProcessBuilder";
43 | }
44 |
45 | @Override
46 | public @NotNull String getName() {
47 | return "CloudNETV2";
48 | }
49 |
50 | @Override
51 | public @NotNull CloudServiceManager getCloudServiceManager() {
52 | return CloudNetV2CloudServiceManager.INSTANCE;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/ps-cloudnet2/src/main/java/com/github/derklaro/privateservers/cloudnet/v2/connection/CloudNetV2ConnectionRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.cloudnet.v2.connection;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.service.CloudService;
28 | import com.github.derklaro.privateservers.common.cloud.util.DefaultConnectionRequest;
29 | import com.google.common.base.Preconditions;
30 | import de.dytanic.cloudnet.api.CloudAPI;
31 | import de.dytanic.cloudnet.lib.utility.document.Document;
32 | import org.jetbrains.annotations.NotNull;
33 |
34 | import java.util.UUID;
35 |
36 | public class CloudNetV2ConnectionRequest extends DefaultConnectionRequest {
37 |
38 | protected CloudNetV2ConnectionRequest(CloudService targetService, UUID targetPlayer) {
39 | super(targetService, targetPlayer);
40 | }
41 |
42 | public static CloudNetV2ConnectionRequest of(@NotNull CloudService targetService, @NotNull UUID player) {
43 | Preconditions.checkNotNull(targetService, "targetService");
44 | Preconditions.checkNotNull(player, "player");
45 |
46 | return new CloudNetV2ConnectionRequest(targetService, player);
47 | }
48 |
49 | @Override
50 | public void fire() {
51 | CloudAPI.getInstance().sendCustomSubProxyMessage(
52 | "cloudnet_internal",
53 | "sendPlayer",
54 | new Document("uniqueId", super.getTargetPlayer()).append("server", super.getTargetService().getName())
55 | );
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/ps-cloudnet2/src/main/java/com/github/derklaro/privateservers/cloudnet/v2/listeners/CloudNetV2CloudServiceListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.cloudnet.v2.listeners;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.CloudSystem;
28 | import com.github.derklaro.privateservers.cloudnet.v2.cloud.CloudNetV2CloudService;
29 | import de.dytanic.cloudnet.bridge.event.bukkit.BukkitServerAddEvent;
30 | import de.dytanic.cloudnet.bridge.event.bukkit.BukkitServerInfoUpdateEvent;
31 | import de.dytanic.cloudnet.bridge.event.bukkit.BukkitServerRemoveEvent;
32 | import org.bukkit.event.EventHandler;
33 | import org.bukkit.event.Listener;
34 | import org.jetbrains.annotations.NotNull;
35 |
36 | public class CloudNetV2CloudServiceListener implements Listener {
37 |
38 | private final CloudSystem cloudSystem;
39 |
40 | public CloudNetV2CloudServiceListener(CloudSystem cloudSystem) {
41 | this.cloudSystem = cloudSystem;
42 | }
43 |
44 | @EventHandler
45 | public void handleStart(@NotNull BukkitServerAddEvent event) {
46 | CloudNetV2CloudService.fromServerInfo(event.getServerInfo()).ifPresent(
47 | cloudService -> this.cloudSystem.getCloudServiceManager().getUnsafe().handleCloudServiceStart(cloudService)
48 | );
49 | }
50 |
51 | @EventHandler
52 | public void handleUpdate(@NotNull BukkitServerInfoUpdateEvent event) {
53 | CloudNetV2CloudService.fromServerInfo(event.getServerInfo()).ifPresent(
54 | cloudService -> this.cloudSystem.getCloudServiceManager().getUnsafe().handleCloudServiceUpdate(cloudService)
55 | );
56 | }
57 |
58 | @EventHandler
59 | public void handleStop(@NotNull BukkitServerRemoveEvent event) {
60 | CloudNetV2CloudService.fromServerInfo(event.getServerInfo()).ifPresent(
61 | cloudService -> this.cloudSystem.getCloudServiceManager().getUnsafe().handleCloudServiceStop(cloudService)
62 | );
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/ps-cloudnet3/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | dependencies {
26 | annotationProcessor project(':ps-api-annotation-processor')
27 | compileOnly project(':ps-common')
28 | compileOnly 'de.dytanic.cloudnet:cloudnet-driver:3.4.3-RELEASE'
29 | compileOnly 'de.dytanic.cloudnet:cloudnet-bridge:3.4.3-RELEASE'
30 | compileOnly 'de.dytanic.cloudnet:cloudnet-wrapper-jvm:3.4.3-RELEASE'
31 | }
32 |
33 | java {
34 | withJavadocJar()
35 | }
36 |
37 | jar {
38 | archiveVersion.set(null)
39 | archiveFileName.set('ps-cloudnet3.jar')
40 | }
41 |
--------------------------------------------------------------------------------
/ps-cloudnet3/src/main/java/com/github/derklaro/privateservers/cloudnet/v3/CloudNetV3Module.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.cloudnet.v3;
26 |
27 | import com.github.derklaro.privateservers.api.Plugin;
28 | import com.github.derklaro.privateservers.api.module.annotation.Module;
29 | import com.github.derklaro.privateservers.cloudnet.v3.cloud.CloudNetV3CloudSystem;
30 | import org.jetbrains.annotations.NotNull;
31 |
32 | @Module(
33 | id = "com.github.derklaro.privateservers.cloudnet.v3",
34 | displayName = "CloudNetV3PrivateServerModule",
35 | version = "1.1.0",
36 | description = "Module for private servers cloudnet v3 integration",
37 | authors = "derklaro"
38 | )
39 | public class CloudNetV3Module {
40 |
41 | private static final String IDENTITY_CLASS = "de.dytanic.cloudnet.ext.bridge.BridgeServiceProperty";
42 |
43 | public CloudNetV3Module(@NotNull Plugin plugin) {
44 | plugin.getCloudSystemDetector().registerCloudSystem(IDENTITY_CLASS, CloudNetV3CloudSystem::new);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/ps-cloudnet3/src/main/java/com/github/derklaro/privateservers/cloudnet/v3/cloud/CloudNetV3CloudServiceInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.cloudnet.v3.cloud;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.service.CloudServiceInfo;
28 | import de.dytanic.cloudnet.driver.service.ServiceInfoSnapshot;
29 | import de.dytanic.cloudnet.ext.bridge.BridgeServiceProperty;
30 | import org.jetbrains.annotations.NotNull;
31 |
32 | import java.net.InetSocketAddress;
33 |
34 | final class CloudNetV3CloudServiceInfo implements CloudServiceInfo {
35 |
36 | private final ServiceInfoSnapshot handle;
37 |
38 | public CloudNetV3CloudServiceInfo(ServiceInfoSnapshot handle) {
39 | this.handle = handle;
40 | }
41 |
42 | @Override
43 | public @NotNull InetSocketAddress getAddress() {
44 | return new InetSocketAddress(this.handle.getAddress().getHost(), this.handle.getAddress().getPort());
45 | }
46 |
47 | @Override
48 | public @NotNull String getMessageOfTheDay() {
49 | return BridgeServiceProperty.MOTD.get(this.handle).orElse("");
50 | }
51 |
52 | @Override
53 | public @NotNull String getState() {
54 | return BridgeServiceProperty.STATE.get(this.handle).orElse("");
55 | }
56 |
57 | @Override
58 | public int getOnlineCount() {
59 | return BridgeServiceProperty.ONLINE_COUNT.get(this.handle).orElse(0);
60 | }
61 |
62 | @Override
63 | public int getMaximumPlayerCount() {
64 | return BridgeServiceProperty.MAX_PLAYERS.get(this.handle).orElse(0);
65 | }
66 |
67 | @Override
68 | public int getHeapMemory() {
69 | return this.handle.getConfiguration().getProcessConfig().getMaxHeapMemorySize();
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/ps-cloudnet3/src/main/java/com/github/derklaro/privateservers/cloudnet/v3/cloud/CloudNetV3CloudSystem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.cloudnet.v3.cloud;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.CloudServiceManager;
28 | import com.github.derklaro.privateservers.api.cloud.CloudSystem;
29 | import com.github.derklaro.privateservers.cloudnet.v3.listeners.CloudNetV3ServiceListener;
30 | import de.dytanic.cloudnet.driver.CloudNetDriver;
31 | import org.jetbrains.annotations.NotNull;
32 |
33 | public class CloudNetV3CloudSystem implements CloudSystem {
34 |
35 | public CloudNetV3CloudSystem() {
36 | CloudNetDriver.getInstance().getEventManager().registerListener(new CloudNetV3ServiceListener(this));
37 | }
38 |
39 | @Override
40 | public @NotNull String getIdentifierClass() {
41 | return "de.dytanic.cloudnet.ext.bridge.BridgeServiceProperty";
42 | }
43 |
44 | @Override
45 | public @NotNull String getName() {
46 | return "CloudNETV3";
47 | }
48 |
49 | @Override
50 | public @NotNull CloudServiceManager getCloudServiceManager() {
51 | return CloudNetV3CloudServiceManager.INSTANCE;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/ps-cloudnet3/src/main/java/com/github/derklaro/privateservers/cloudnet/v3/connection/CloudNetV3ConnectionRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.cloudnet.v3.connection;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.service.CloudService;
28 | import com.github.derklaro.privateservers.common.cloud.util.DefaultConnectionRequest;
29 | import com.google.common.base.Preconditions;
30 | import de.dytanic.cloudnet.driver.CloudNetDriver;
31 | import de.dytanic.cloudnet.ext.bridge.player.IPlayerManager;
32 | import org.jetbrains.annotations.NotNull;
33 |
34 | import java.util.UUID;
35 |
36 | public class CloudNetV3ConnectionRequest extends DefaultConnectionRequest {
37 |
38 | protected CloudNetV3ConnectionRequest(CloudService targetService, UUID targetPlayer) {
39 | super(targetService, targetPlayer);
40 | }
41 |
42 | public static CloudNetV3ConnectionRequest of(@NotNull CloudService targetService, @NotNull UUID player) {
43 | Preconditions.checkNotNull(targetService, "targetService");
44 | Preconditions.checkNotNull(player, "player");
45 |
46 | return new CloudNetV3ConnectionRequest(targetService, player);
47 | }
48 |
49 | @Override
50 | public void fire() {
51 | CloudNetDriver.getInstance().getServicesRegistry().getFirstService(IPlayerManager.class)
52 | .getPlayerExecutor(super.getTargetPlayer())
53 | .connect(super.getTargetService().getName());
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/ps-cloudnet3/src/main/java/com/github/derklaro/privateservers/cloudnet/v3/listeners/CloudNetV3ServiceListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.cloudnet.v3.listeners;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.CloudSystem;
28 | import com.github.derklaro.privateservers.cloudnet.v3.cloud.CloudNetV3CloudService;
29 | import de.dytanic.cloudnet.driver.event.EventListener;
30 | import de.dytanic.cloudnet.driver.event.events.service.CloudServiceInfoUpdateEvent;
31 | import de.dytanic.cloudnet.driver.event.events.service.CloudServiceStartEvent;
32 | import de.dytanic.cloudnet.driver.event.events.service.CloudServiceStopEvent;
33 | import org.jetbrains.annotations.NotNull;
34 |
35 | public class CloudNetV3ServiceListener {
36 |
37 | private final CloudSystem cloudSystem;
38 |
39 | public CloudNetV3ServiceListener(CloudSystem cloudSystem) {
40 | this.cloudSystem = cloudSystem;
41 | }
42 |
43 | @EventListener
44 | public void handleStart(@NotNull CloudServiceStartEvent event) {
45 | CloudNetV3CloudService.fromServiceInfoSnapshot(event.getServiceInfo()).ifPresent(
46 | cloudService -> this.cloudSystem.getCloudServiceManager().getUnsafe().handleCloudServiceStart(cloudService)
47 | );
48 | }
49 |
50 | @EventListener
51 | public void handleUpdate(@NotNull CloudServiceInfoUpdateEvent event) {
52 | CloudNetV3CloudService.fromServiceInfoSnapshot(event.getServiceInfo()).ifPresent(
53 | cloudService -> this.cloudSystem.getCloudServiceManager().getUnsafe().handleCloudServiceUpdate(cloudService)
54 | );
55 | }
56 |
57 | @EventListener
58 | public void handleStop(@NotNull CloudServiceStopEvent event) {
59 | CloudNetV3CloudService.fromServiceInfoSnapshot(event.getServiceInfo()).ifPresent(
60 | cloudService -> this.cloudSystem.getCloudServiceManager().getUnsafe().handleCloudServiceStop(cloudService)
61 | );
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/ps-cloudnet3/src/main/java/com/github/derklaro/privateservers/cloudnet/v3/util/CloudNetV3Constants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.cloudnet.v3.util;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.configuration.CloudServiceConfiguration;
28 | import de.dytanic.cloudnet.driver.service.property.ServiceProperty;
29 |
30 | import static de.dytanic.cloudnet.driver.service.property.DefaultJsonServiceProperty.createFromType;
31 |
32 | public final class CloudNetV3Constants {
33 |
34 | public static final ServiceProperty CLOUD_SERVICE_CONFIG_PROPERTY
35 | = createFromType("cloudServiceConfiguration", CloudServiceConfiguration.class);
36 |
37 | private CloudNetV3Constants() {
38 | throw new UnsupportedOperationException();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/ps-common/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | plugins {
26 | id 'com.github.johnrengelman.shadow' version '7.1.2'
27 | }
28 |
29 | dependencies {
30 | api project(':ps-api')
31 | implementation 'com.google.code.gson:gson:2.9.0'
32 | }
33 |
34 | java {
35 | withJavadocJar()
36 | }
37 |
38 | shadowJar {
39 | archiveVersion.set(null)
40 | archiveFileName.set('ps-common.jar')
41 |
42 | relocate 'com.google.gson', 'com.github.derklaro.privateservers.relocate.gson'
43 | }
44 |
--------------------------------------------------------------------------------
/ps-common/src/main/java/com/github/derklaro/privateservers/common/cloud/DefaultCloudService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.common.cloud;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.configuration.CloudServiceConfiguration;
28 | import com.github.derklaro.privateservers.api.cloud.service.CloudService;
29 | import lombok.EqualsAndHashCode;
30 | import lombok.ToString;
31 | import org.jetbrains.annotations.NotNull;
32 |
33 | import java.util.UUID;
34 |
35 | @ToString
36 | @EqualsAndHashCode
37 | public abstract class DefaultCloudService implements CloudService {
38 |
39 | protected final String name;
40 | protected final UUID uniqueID;
41 | protected CloudServiceConfiguration cloudServiceConfiguration;
42 |
43 | public DefaultCloudService(String name, UUID uniqueID, CloudServiceConfiguration cloudServiceConfiguration) {
44 | this.name = name;
45 | this.uniqueID = uniqueID;
46 | this.cloudServiceConfiguration = cloudServiceConfiguration;
47 | }
48 |
49 | @Override
50 | public @NotNull String getName() {
51 | return this.name;
52 | }
53 |
54 | @Override
55 | public @NotNull UUID getServiceUniqueId() {
56 | return this.uniqueID;
57 | }
58 |
59 | @Override
60 | public @NotNull UUID getOwnerUniqueId() {
61 | return this.cloudServiceConfiguration.getOwnerUniqueId();
62 | }
63 |
64 | @Override
65 | public @NotNull String getOwnerName() {
66 | return this.cloudServiceConfiguration.getOwnerName();
67 | }
68 |
69 | @Override
70 | public @NotNull CloudServiceConfiguration getCloudServiceConfiguration() {
71 | return this.cloudServiceConfiguration;
72 | }
73 |
74 | @Override
75 | public void setCloudServiceConfiguration(@NotNull CloudServiceConfiguration cloudServiceConfiguration) {
76 | this.cloudServiceConfiguration = cloudServiceConfiguration;
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/ps-common/src/main/java/com/github/derklaro/privateservers/common/cloud/DefaultCloudSystemDetector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.common.cloud;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.CloudDetector;
28 | import com.github.derklaro.privateservers.api.cloud.CloudSystem;
29 | import com.github.derklaro.privateservers.api.cloud.exception.CloudSystemAlreadyDetectedException;
30 | import com.github.derklaro.privateservers.api.cloud.exception.CloudSystemAlreadyRegisteredException;
31 | import org.jetbrains.annotations.NotNull;
32 |
33 | import java.util.Map;
34 | import java.util.Optional;
35 | import java.util.concurrent.ConcurrentHashMap;
36 | import java.util.concurrent.atomic.AtomicReference;
37 | import java.util.function.Supplier;
38 |
39 | public final class DefaultCloudSystemDetector implements CloudDetector {
40 |
41 | public static final CloudDetector DEFAULT_INSTANCE = new DefaultCloudSystemDetector();
42 |
43 | private final AtomicReference detectedCloudSystem = new AtomicReference<>();
44 | private final Map> cloudSystemFactories = new ConcurrentHashMap<>();
45 |
46 | private DefaultCloudSystemDetector() {
47 | }
48 |
49 | @Override
50 | public void registerCloudSystem(@NotNull String requiredClass, @NotNull Supplier factory) throws CloudSystemAlreadyRegisteredException {
51 | if (this.cloudSystemFactories.putIfAbsent(requiredClass, factory) != null) {
52 | throw new CloudSystemAlreadyRegisteredException(requiredClass, factory);
53 | }
54 | }
55 |
56 | @Override
57 | public void detectCloudSystem() throws CloudSystemAlreadyDetectedException {
58 | if (this.isCloudSystemDetected()) {
59 | throw new CloudSystemAlreadyDetectedException(this.detectedCloudSystem.get());
60 | }
61 |
62 | for (Map.Entry> entry : this.cloudSystemFactories.entrySet()) {
63 | try {
64 | Class.forName(entry.getKey());
65 | // class is present, we can use this as the running system
66 | this.detectedCloudSystem.set(entry.getValue().get());
67 | break;
68 | } catch (ClassNotFoundException ignored) {
69 | }
70 | }
71 | }
72 |
73 | @Override
74 | public boolean isCloudSystemDetected() {
75 | return this.detectedCloudSystem.get() != null;
76 | }
77 |
78 | @Override
79 | public @NotNull Optional getDetectedCloudSystem() {
80 | return Optional.ofNullable(this.detectedCloudSystem.get());
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ps-common/src/main/java/com/github/derklaro/privateservers/common/cloud/util/DefaultConnectionRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.common.cloud.util;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.connection.ConnectionRequest;
28 | import com.github.derklaro.privateservers.api.cloud.service.CloudService;
29 | import lombok.EqualsAndHashCode;
30 | import lombok.ToString;
31 | import org.jetbrains.annotations.NotNull;
32 |
33 | import java.util.UUID;
34 |
35 | @ToString
36 | @EqualsAndHashCode
37 | public abstract class DefaultConnectionRequest implements ConnectionRequest {
38 |
39 | private final CloudService targetService;
40 | private final UUID targetPlayer;
41 |
42 | public DefaultConnectionRequest(CloudService targetService, UUID targetPlayer) {
43 | this.targetService = targetService;
44 | this.targetPlayer = targetPlayer;
45 | }
46 |
47 | @Override
48 | public @NotNull CloudService getTargetService() {
49 | return this.targetService;
50 | }
51 |
52 | @Override
53 | public @NotNull UUID getTargetPlayer() {
54 | return this.targetPlayer;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/ps-common/src/main/java/com/github/derklaro/privateservers/common/module/DefaultModuleContainer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.common.module;
26 |
27 | import com.github.derklaro.privateservers.api.module.ModuleContainer;
28 | import com.github.derklaro.privateservers.api.module.ModuleState;
29 | import com.github.derklaro.privateservers.api.module.annotation.ModuleDescription;
30 | import org.jetbrains.annotations.NotNull;
31 |
32 | import java.net.URLClassLoader;
33 | import java.nio.file.Path;
34 |
35 | class DefaultModuleContainer implements ModuleContainer {
36 |
37 | private final ModuleDescription description;
38 | private final Class> mainClass;
39 | private final Object instance;
40 | private final URLClassLoader classLoader;
41 | private final Path path;
42 | private ModuleState state;
43 |
44 | DefaultModuleContainer(ModuleDescription description, Class> mainClass, URLClassLoader classLoader, Path path, Object instance) {
45 | this.description = description;
46 | this.mainClass = mainClass;
47 | this.classLoader = classLoader;
48 | this.path = path;
49 | this.instance = instance;
50 | this.state = ModuleState.ENABLED;
51 | }
52 |
53 | @NotNull
54 | @Override
55 | public ModuleDescription getDescription() {
56 | return this.description;
57 | }
58 |
59 | @Override
60 | public @NotNull ModuleState getState() {
61 | return this.state;
62 | }
63 |
64 | @Override
65 | public @NotNull URLClassLoader getClassLoader() {
66 | return this.classLoader;
67 | }
68 |
69 | @Override
70 | public @NotNull Path getModulePath() {
71 | return this.path;
72 | }
73 |
74 | @Override
75 | public @NotNull Class> getMainClass() {
76 | return this.mainClass;
77 | }
78 |
79 | @Override
80 | public @NotNull Object getInstance() {
81 | return this.instance;
82 | }
83 |
84 | @Override
85 | public void setModuleState(@NotNull ModuleState moduleState) {
86 | this.state = moduleState;
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/ps-common/src/main/java/com/github/derklaro/privateservers/common/util/EnumUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.common.util;
26 |
27 | import org.jetbrains.annotations.NotNull;
28 | import org.jetbrains.annotations.Nullable;
29 |
30 | import java.lang.ref.WeakReference;
31 | import java.util.Collection;
32 | import java.util.EnumSet;
33 | import java.util.HashMap;
34 | import java.util.Map;
35 | import java.util.Optional;
36 | import java.util.concurrent.ConcurrentHashMap;
37 |
38 | public final class EnumUtil {
39 |
40 | private static final Map>, Map>>> CACHE = new ConcurrentHashMap<>();
41 |
42 | private EnumUtil() {
43 | throw new UnsupportedOperationException();
44 | }
45 |
46 | public static > T findEnumField(@NotNull Class enumClass, @NotNull String field, @Nullable T defaultField) {
47 | return findEnumField(enumClass, field).orElse(defaultField);
48 | }
49 |
50 | private static > Optional findEnumField(Class enumClass, String field) {
51 | Map>> cached = CACHE.computeIfAbsent(enumClass, aClass -> cache(enumClass));
52 | WeakReference extends Enum>> reference = cached.get(field);
53 | return reference == null ? Optional.empty() : Optional.ofNullable(enumClass.cast(reference.get()));
54 | }
55 |
56 | @NotNull
57 | private static > Map>> cache(Class enumClass) {
58 | Map>> out = new HashMap<>();
59 | try {
60 | Collection instance = EnumSet.allOf(enumClass);
61 | instance.forEach(t -> out.put(t.name(), new WeakReference<>(t)));
62 | } catch (Throwable ignored) {
63 | }
64 |
65 | return out;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/ps-common/src/main/java/com/github/derklaro/privateservers/common/util/Iterables.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.common.util;
26 |
27 | import org.jetbrains.annotations.NotNull;
28 |
29 | import java.util.Collection;
30 | import java.util.Optional;
31 | import java.util.function.Predicate;
32 |
33 | public final class Iterables {
34 |
35 | private Iterables() {
36 | throw new UnsupportedOperationException();
37 | }
38 |
39 | @NotNull
40 | public static Optional first(@NotNull Collection collection, @NotNull Predicate filter) {
41 | for (T t : collection) {
42 | if (filter.test(t)) {
43 | return Optional.of(t);
44 | }
45 | }
46 |
47 | return Optional.empty();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/ps-lobby-spigot/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | plugins {
26 | id 'com.github.johnrengelman.shadow' version '7.1.2'
27 | }
28 |
29 | dependencies {
30 | api 'com.github.juliarn:npc-lib:development-SNAPSHOT'
31 | api 'com.google.code.gson:gson:2.9.0'
32 | compileOnly project(':ps-plugin-spigot')
33 | annotationProcessor project(':ps-api-annotation-processor')
34 | compileOnly 'org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT'
35 | }
36 |
37 | java {
38 | withJavadocJar()
39 | }
40 |
41 | shadowJar {
42 | archiveVersion.set(null)
43 | archiveFileName.set('ps-lobby-spigot.jar')
44 |
45 | relocate 'com.github.juliarn', 'com.github.derklaro.privateservers.relocate.npc.lib'
46 | relocate 'com.google.gson', 'com.github.derklaro.privateservers.relocate.gson'
47 | }
48 |
--------------------------------------------------------------------------------
/ps-lobby-spigot/src/main/java/com/github/derklaro/privateservers/lobby/command/CommandRemoveNpc.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.lobby.command;
26 |
27 | import com.github.derklaro.privateservers.PrivateServersSpigot;
28 | import com.github.derklaro.privateservers.common.translation.Message;
29 | import com.github.derklaro.privateservers.translation.BukkitComponentRenderer;
30 | import org.bukkit.command.Command;
31 | import org.bukkit.command.CommandExecutor;
32 | import org.bukkit.command.CommandSender;
33 | import org.bukkit.entity.Player;
34 | import org.bukkit.metadata.FixedMetadataValue;
35 | import org.bukkit.metadata.MetadataValue;
36 |
37 | public class CommandRemoveNpc implements CommandExecutor {
38 |
39 | private static final MetadataValue NPC_REMOVE = new FixedMetadataValue(PrivateServersSpigot.getInstance(), true);
40 |
41 | @Override
42 | public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
43 | if (!(commandSender instanceof Player)) {
44 | return true;
45 | }
46 |
47 | Player player = (Player) commandSender;
48 | if (!player.hasPermission("ps.command.npc.remove")) {
49 | BukkitComponentRenderer.renderAndSend(player, Message.COMMAND_NOT_ALLOWED.build());
50 | return true;
51 | }
52 |
53 | if (player.hasMetadata("npc_remove")) {
54 | BukkitComponentRenderer.renderAndSend(player, Message.NPC_REMOVE_ALREADY_ACTIVATED.build());
55 | return true;
56 | }
57 |
58 | player.setMetadata("npc_remove", NPC_REMOVE);
59 | BukkitComponentRenderer.renderAndSend(player, Message.NPC_REMOVE_MODE_ACTIVATED.build());
60 | return true;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/ps-lobby-spigot/src/main/java/com/github/derklaro/privateservers/lobby/event/DatabaseChooseEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.lobby.event;
26 |
27 | import com.github.derklaro.privateservers.lobby.npc.database.NpcDatabase;
28 | import org.bukkit.event.Event;
29 | import org.bukkit.event.HandlerList;
30 |
31 | public class DatabaseChooseEvent extends Event {
32 |
33 | private static final HandlerList HANDLER_LIST = new HandlerList();
34 |
35 | private final String databaseName;
36 | private NpcDatabase database;
37 |
38 | public DatabaseChooseEvent(NpcDatabase database, String databaseName) {
39 | this.database = database;
40 | this.databaseName = databaseName;
41 | }
42 |
43 | public static HandlerList getHandlerList() {
44 | return HANDLER_LIST;
45 | }
46 |
47 | public NpcDatabase getDatabase() {
48 | return this.database;
49 | }
50 |
51 | public void setDatabase(NpcDatabase database) {
52 | this.database = database;
53 | }
54 |
55 | public String getDatabaseName() {
56 | return this.databaseName;
57 | }
58 |
59 | @Override
60 | public HandlerList getHandlers() {
61 | return HANDLER_LIST;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/ps-lobby-spigot/src/main/java/com/github/derklaro/privateservers/lobby/inventory/ClickHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.lobby.inventory;
26 |
27 | import org.bukkit.entity.Player;
28 | import org.bukkit.inventory.Inventory;
29 | import org.bukkit.inventory.ItemStack;
30 | import org.jetbrains.annotations.NotNull;
31 |
32 | @FunctionalInterface
33 | public interface ClickHandler {
34 |
35 | boolean handleClick(@NotNull Player player, @NotNull Inventory inventory, @NotNull ItemStack itemStack, int slot);
36 | }
37 |
--------------------------------------------------------------------------------
/ps-lobby-spigot/src/main/java/com/github/derklaro/privateservers/lobby/inventory/InventoryRebuildListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.lobby.inventory;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.CloudServiceManager;
28 | import com.github.derklaro.privateservers.api.cloud.service.CloudService;
29 | import com.github.derklaro.privateservers.api.cloud.service.ServiceListener;
30 | import com.github.derklaro.privateservers.api.configuration.Configuration;
31 | import org.jetbrains.annotations.NotNull;
32 |
33 | final class InventoryRebuildListener implements ServiceListener {
34 |
35 | private final Configuration configuration;
36 | private final CloudServiceManager cloudServiceManager;
37 | private final PublicServersInventoryHandler inventoryHandler;
38 |
39 | public InventoryRebuildListener(Configuration configuration, CloudServiceManager cloudServiceManager, PublicServersInventoryHandler inventoryHandler) {
40 | this.configuration = configuration;
41 | this.cloudServiceManager = cloudServiceManager;
42 | this.inventoryHandler = inventoryHandler;
43 | }
44 |
45 | @Override
46 | public void handleServiceRegister(@NotNull CloudService cloudService) {
47 | this.inventoryHandler.rebuildPublicServerListInventory(this.configuration, this.cloudServiceManager);
48 | }
49 |
50 | @Override
51 | public void handleServerUpdate(@NotNull CloudService cloudService) {
52 | this.inventoryHandler.rebuildPublicServerListInventory(this.configuration, this.cloudServiceManager);
53 | }
54 |
55 | @Override
56 | public void handleServiceUnregister(@NotNull CloudService cloudService) {
57 | this.inventoryHandler.rebuildPublicServerListInventory(this.configuration, this.cloudServiceManager);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/ps-lobby-spigot/src/main/java/com/github/derklaro/privateservers/lobby/inventory/handlers/HandlerUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.lobby.inventory.handlers;
26 |
27 | import com.github.derklaro.privateservers.api.configuration.InventoryConfiguration;
28 | import com.github.derklaro.privateservers.common.translation.Message;
29 | import com.github.derklaro.privateservers.translation.BukkitComponentRenderer;
30 | import org.bukkit.entity.Player;
31 | import org.jetbrains.annotations.NotNull;
32 |
33 | public final class HandlerUtils {
34 |
35 | private HandlerUtils() {
36 | throw new UnsupportedOperationException();
37 | }
38 |
39 | public static boolean canUse(@NotNull Player player, @NotNull InventoryConfiguration.ItemLayout layout) {
40 | return layout.getUsePermission() == null || player.hasPermission(layout.getUsePermission());
41 | }
42 |
43 | public static void notifyNotAllowed(@NotNull Player player) {
44 | player.closeInventory();
45 | BukkitComponentRenderer.renderAndSend(player, Message.ITEM_USE_NO_PERMISSION.build());
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/ps-lobby-spigot/src/main/java/com/github/derklaro/privateservers/lobby/inventory/handlers/PublicServerListClickHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.lobby.inventory.handlers;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.service.CloudService;
28 | import com.github.derklaro.privateservers.api.configuration.Configuration;
29 | import com.github.derklaro.privateservers.api.configuration.InventoryConfiguration;
30 | import com.github.derklaro.privateservers.lobby.inventory.ClickHandler;
31 | import com.github.derklaro.privateservers.lobby.inventory.InventoryHandler;
32 | import com.github.derklaro.privateservers.lobby.inventory.PublicServersInventoryHandler;
33 | import org.bukkit.entity.Player;
34 | import org.bukkit.inventory.Inventory;
35 | import org.bukkit.inventory.ItemStack;
36 | import org.jetbrains.annotations.NotNull;
37 |
38 | public class PublicServerListClickHandler implements ClickHandler {
39 |
40 | private final PublicServersInventoryHandler inventoryHandler;
41 | private final InventoryConfiguration.PublicServerListConfiguration configuration;
42 |
43 | public PublicServerListClickHandler(Configuration configuration, InventoryHandler inventoryHandler) {
44 | this.inventoryHandler = inventoryHandler.getPublicServersInventoryHandler();
45 | this.configuration = configuration.getPublicServerListConfiguration();
46 | }
47 |
48 | @Override
49 | public boolean handleClick(@NotNull Player player, @NotNull Inventory inventory, @NotNull ItemStack itemStack, int slot) {
50 | CloudService cloudService = this.inventoryHandler.getTargetService(slot);
51 | if (cloudService != null) {
52 | if (this.shouldSend(player, cloudService)) {
53 | cloudService.createConnectionRequest(player.getUniqueId()).fire();
54 | } else {
55 | HandlerUtils.notifyNotAllowed(player);
56 | }
57 | }
58 | return true;
59 | }
60 |
61 | private boolean shouldSend(@NotNull Player player, @NotNull CloudService cloudService) {
62 | InventoryConfiguration.ItemLayout itemLayout;
63 | if (cloudService.getCloudServiceConfiguration().isWhitelist()) {
64 | itemLayout = this.configuration.getServerWithWhitelistLayout();
65 | } else {
66 | itemLayout = this.configuration.getOpenServerLayout();
67 | }
68 |
69 | return HandlerUtils.canUse(player, itemLayout);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/ps-lobby-spigot/src/main/java/com/github/derklaro/privateservers/lobby/listeners/CloudSystemPickedListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.lobby.listeners;
26 |
27 | import com.github.derklaro.privateservers.event.CloudSystemPickedEvent;
28 | import com.github.derklaro.privateservers.lobby.PrivateServersLobby;
29 | import org.bukkit.event.EventHandler;
30 | import org.bukkit.event.Listener;
31 | import org.jetbrains.annotations.NotNull;
32 |
33 | public class CloudSystemPickedListener implements Listener {
34 |
35 | private final PrivateServersLobby lobby;
36 |
37 | public CloudSystemPickedListener(PrivateServersLobby lobby) {
38 | this.lobby = lobby;
39 | }
40 |
41 | @EventHandler
42 | public void handle(@NotNull CloudSystemPickedEvent event) {
43 | this.lobby.handleCloudSystemPick(event.getCloudSystem());
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/ps-lobby-spigot/src/main/java/com/github/derklaro/privateservers/lobby/listeners/PlayerListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.lobby.listeners;
26 |
27 | import com.github.derklaro.privateservers.PrivateServersSpigot;
28 | import com.github.derklaro.privateservers.common.translation.Message;
29 | import com.github.derklaro.privateservers.lobby.inventory.InventoryHandler;
30 | import com.github.derklaro.privateservers.lobby.npc.NpcManager;
31 | import com.github.derklaro.privateservers.lobby.npc.database.NpcDatabase;
32 | import com.github.derklaro.privateservers.translation.BukkitComponentRenderer;
33 | import com.github.juliarn.npc.event.PlayerNPCInteractEvent;
34 | import org.bukkit.event.EventHandler;
35 | import org.bukkit.event.Listener;
36 | import org.bukkit.event.inventory.InventoryClickEvent;
37 | import org.jetbrains.annotations.NotNull;
38 |
39 | public class PlayerListener implements Listener {
40 |
41 | private final NpcManager npcManager;
42 | private final NpcDatabase npcDatabase;
43 | private final InventoryHandler inventoryHandler;
44 |
45 | public PlayerListener(NpcManager npcManager, NpcDatabase npcDatabase, InventoryHandler inventoryHandler) {
46 | this.npcManager = npcManager;
47 | this.npcDatabase = npcDatabase;
48 | this.inventoryHandler = inventoryHandler;
49 | }
50 |
51 | @EventHandler
52 | public void handle(@NotNull PlayerNPCInteractEvent event) {
53 | if (!this.npcManager.isManagedNpc(event.getNPC().getEntityId())) {
54 | return;
55 | }
56 |
57 | switch (event.getUseAction()) {
58 | case ATTACK:
59 | if (event.getPlayer().hasMetadata("npc_remove")) {
60 | this.npcManager.removeNpc(event.getNPC().getLocation());
61 | this.npcDatabase.removeNpc(event.getNPC().getLocation());
62 |
63 | event.getPlayer().removeMetadata("npc_remove", PrivateServersSpigot.getInstance());
64 | BukkitComponentRenderer.renderAndSend(event.getPlayer(), Message.NPC_REMOVE_SUCCESSFUL.build());
65 | }
66 | break;
67 | case INTERACT:
68 | this.inventoryHandler.openMainInventory(event.getPlayer());
69 | break;
70 | default:
71 | break;
72 | }
73 | }
74 |
75 | @EventHandler
76 | public void handleInventoryClick(@NotNull InventoryClickEvent event) {
77 | this.inventoryHandler.handleInventoryClick(event);
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/ps-lobby-spigot/src/main/java/com/github/derklaro/privateservers/lobby/npc/NpcManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.lobby.npc;
26 |
27 | import org.bukkit.Location;
28 | import org.jetbrains.annotations.NotNull;
29 |
30 | public interface NpcManager {
31 |
32 | void createAndSpawnNpc(@NotNull Location location, @NotNull String texturePlayerName, @NotNull String displayName);
33 |
34 | void removeNpc(@NotNull Location location);
35 |
36 | void removeAllNPCs();
37 |
38 | boolean isManagedNpc(int entityId);
39 | }
40 |
--------------------------------------------------------------------------------
/ps-lobby-spigot/src/main/java/com/github/derklaro/privateservers/lobby/npc/database/NpcDatabase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.lobby.npc.database;
26 |
27 | import org.bukkit.Location;
28 | import org.jetbrains.annotations.NotNull;
29 | import org.jetbrains.annotations.UnmodifiableView;
30 |
31 | import java.util.Collection;
32 |
33 | public interface NpcDatabase {
34 |
35 | void initialize();
36 |
37 | void addNpc(@NotNull DatabaseNPCObject object);
38 |
39 | void removeNpc(@NotNull DatabaseNPCObject object);
40 |
41 | void removeNpc(@NotNull Location location);
42 |
43 | void removeAllNPCs();
44 |
45 | @NotNull @UnmodifiableView Collection getAllNPCs();
46 | }
47 |
--------------------------------------------------------------------------------
/ps-lobby-spigot/src/main/java/com/github/derklaro/privateservers/lobby/npc/runnables/KnockbackRunnable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.lobby.npc.runnables;
26 |
27 | import com.github.derklaro.privateservers.api.Plugin;
28 | import com.github.derklaro.privateservers.api.configuration.Configuration;
29 | import com.github.derklaro.privateservers.api.configuration.NpcConfiguration;
30 | import com.github.derklaro.privateservers.lobby.npc.DefaultNpcManager;
31 | import com.github.juliarn.npc.NPC;
32 | import org.bukkit.entity.Player;
33 | import org.jetbrains.annotations.NotNull;
34 |
35 | public class KnockbackRunnable {
36 |
37 | private final DefaultNpcManager npcManager;
38 |
39 | public KnockbackRunnable(Configuration configuration, DefaultNpcManager npcManager, Plugin plugin) {
40 | this.npcManager = npcManager;
41 | this.schedule(configuration.getNpcConfiguration().getKnockbackConfiguration(), plugin);
42 | }
43 |
44 | protected void schedule(@NotNull NpcConfiguration.KnockbackConfiguration configuration, @NotNull Plugin plugin) {
45 | if (configuration.isEnabled() && configuration.getKnockbackDistance() > 0 && configuration.getKnockbackStrength() > 0) {
46 | double distance = configuration.getKnockbackDistance();
47 | double strength = configuration.getKnockbackStrength();
48 |
49 | plugin.getTaskManager().scheduleSyncRepeatingTask(() -> {
50 | for (NPC npc : this.npcManager.getNpcPool().getNPCs()) {
51 | npc.getLocation().getWorld()
52 | .getNearbyEntities(npc.getLocation(), distance, distance, distance)
53 | .stream()
54 | .filter(entity -> entity instanceof Player && !entity.hasPermission(configuration.getBypassPermission()))
55 | .filter(entity -> npc.isShownFor((Player) entity))
56 | .forEach(entity -> entity.setVelocity(entity.getLocation().toVector()
57 | .subtract(npc.getLocation().toVector())
58 | .normalize()
59 | .multiply(strength)
60 | .setY(0.2D))
61 | );
62 | }
63 | }, 20, 5);
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/ps-lobby-spigot/src/main/java/com/github/derklaro/privateservers/lobby/npc/runnables/LabyModEmoteTask.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.lobby.npc.runnables;
26 |
27 | import com.github.derklaro.privateservers.api.Plugin;
28 | import com.github.derklaro.privateservers.api.configuration.Configuration;
29 | import com.github.derklaro.privateservers.api.configuration.NpcConfiguration;
30 | import com.github.derklaro.privateservers.lobby.npc.DefaultNpcManager;
31 | import com.github.juliarn.npc.NPC;
32 | import com.github.juliarn.npc.modifier.LabyModModifier;
33 | import org.bukkit.Bukkit;
34 | import org.bukkit.entity.Player;
35 | import org.jetbrains.annotations.NotNull;
36 |
37 | import java.util.Random;
38 |
39 | public class LabyModEmoteTask {
40 |
41 | private static final Random RANDOM = new Random();
42 |
43 | private final DefaultNpcManager npcManager;
44 |
45 | public LabyModEmoteTask(@NotNull Configuration configuration, @NotNull Plugin plugin, @NotNull DefaultNpcManager npcManager) {
46 | this.npcManager = npcManager;
47 |
48 | NpcConfiguration.LabyModConfiguration labyModConfiguration = configuration.getNpcConfiguration().getLabyModConfiguration();
49 | if (labyModConfiguration.getEmoteDelayTicks() > 0 && labyModConfiguration.getEmoteIds().length > 0) {
50 | this.schedule(labyModConfiguration, plugin);
51 | }
52 | }
53 |
54 | protected void schedule(@NotNull NpcConfiguration.LabyModConfiguration configuration, @NotNull Plugin plugin) {
55 | int delayTicks = configuration.getEmoteDelayTicks();
56 | int emoteId = configuration.getEmoteIds()[RANDOM.nextInt(configuration.getEmoteIds().length)];
57 |
58 | plugin.getTaskManager().scheduleAsyncTask(() -> {
59 | for (NPC npc : this.npcManager.getNpcPool().getNPCs()) {
60 | for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
61 | if (npc.isShownFor(onlinePlayer)) {
62 | npc.labymod()
63 | .queue(LabyModModifier.LabyModAction.EMOTE, emoteId)
64 | .send(onlinePlayer);
65 | }
66 | }
67 | }
68 |
69 | this.schedule(configuration, plugin);
70 | }, delayTicks);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/ps-plugin-spigot/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) $2020-today.year Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | plugins {
26 | id 'com.github.johnrengelman.shadow' version '7.1.2'
27 | id 'net.minecrell.plugin-yml.bukkit' version '0.5.2'
28 | }
29 |
30 | dependencies {
31 | api project(':ps-common')
32 | compileOnly 'org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT'
33 | }
34 |
35 | java {
36 | withJavadocJar()
37 | }
38 |
39 | shadowJar {
40 | archiveVersion.set(null)
41 | archiveFileName.set('ps-plugin-spigot.jar')
42 |
43 | relocate 'com.google.gson', 'com.github.derklaro.privateservers.relocate.gson'
44 | }
45 |
46 | bukkit {
47 | name = 'PrivateServerSystem'
48 | author = 'derklaro'
49 | version = project.version
50 | website = 'https://github.com/derklaro/ps-system'
51 | description = 'An infinitely expandable private server system by derklaro'
52 |
53 | apiVersion = '1.13'
54 | softDepend = ['ProtocolLib', 'CloudNetAPI']
55 | main = 'com.github.derklaro.privateservers.PrivateServersSpigot'
56 |
57 | commands {
58 | whitelist {
59 | aliases = ['allowlist', 'wlist', 'alist']
60 | description = 'Manage the allowlist of your private server'
61 | }
62 | visibility {
63 | aliases = ['v']
64 | description = 'Changes the visibility of the current server, public servers are shown in the server list'
65 | }
66 | removenpc {
67 | aliases = ['rnpc', 'deletenpc', 'dnpc']
68 | description = 'Sets you in the mode which allows you to remove npcs by hitting them'
69 | }
70 | createnpc {
71 | aliases = ['cnpc']
72 | description = 'Creates a new npc to start/stop/join and list the private servers'
73 | }
74 | psinfo {
75 | aliases = ['pinfo', 'pi']
76 | description = 'Gives you information about the current private server'
77 | }
78 | pssinfo {
79 | description = 'Shows you information about the private the server plugin'
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ps-plugin-spigot/src/main/java/com/github/derklaro/privateservers/configuration/JsonConfigurationLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.configuration;
26 |
27 | import com.github.derklaro.privateservers.api.configuration.Configuration;
28 | import com.google.gson.Gson;
29 | import com.google.gson.GsonBuilder;
30 |
31 | import java.io.IOException;
32 | import java.io.InputStreamReader;
33 | import java.io.OutputStreamWriter;
34 | import java.io.Reader;
35 | import java.io.Writer;
36 | import java.nio.charset.StandardCharsets;
37 | import java.nio.file.Files;
38 | import java.nio.file.Path;
39 | import java.nio.file.Paths;
40 |
41 | public final class JsonConfigurationLoader {
42 |
43 | private static final Path CONFIG_PATH = Paths.get("plugins/ps/config.json");
44 | private static final Gson GSON = new GsonBuilder().setPrettyPrinting().serializeNulls().disableHtmlEscaping().create();
45 |
46 | private JsonConfigurationLoader() {
47 | throw new UnsupportedOperationException();
48 | }
49 |
50 | public static Configuration loadConfiguration() {
51 | if (Files.notExists(CONFIG_PATH)) {
52 | try {
53 | if (CONFIG_PATH.getParent() != null) {
54 | Files.createDirectories(CONFIG_PATH.getParent());
55 | }
56 | } catch (IOException exception) {
57 | exception.printStackTrace();
58 | }
59 |
60 | try (Writer writer = new OutputStreamWriter(Files.newOutputStream(CONFIG_PATH), StandardCharsets.UTF_8)) {
61 | GSON.toJson(GSON.toJsonTree(new Configuration()), writer);
62 | } catch (IOException exception) {
63 | exception.printStackTrace();
64 | }
65 | }
66 |
67 | try (Reader reader = new InputStreamReader(Files.newInputStream(CONFIG_PATH), StandardCharsets.UTF_8)) {
68 | return GSON.fromJson(reader, Configuration.class);
69 | } catch (IOException exception) {
70 | throw new RuntimeException("Unable to read configuration", exception);
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/ps-plugin-spigot/src/main/java/com/github/derklaro/privateservers/event/BukkitEventUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.event;
26 |
27 | import org.bukkit.Bukkit;
28 | import org.bukkit.event.Event;
29 | import org.jetbrains.annotations.NotNull;
30 |
31 | public final class BukkitEventUtil {
32 |
33 | private BukkitEventUtil() {
34 | throw new UnsupportedOperationException();
35 | }
36 |
37 | public static @NotNull T fireEvent(@NotNull T event) {
38 | Bukkit.getPluginManager().callEvent(event);
39 | return event;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/ps-plugin-spigot/src/main/java/com/github/derklaro/privateservers/event/CloudSystemPickedEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.event;
26 |
27 | import com.github.derklaro.privateservers.api.cloud.CloudSystem;
28 | import org.bukkit.event.Event;
29 | import org.bukkit.event.HandlerList;
30 |
31 | public class CloudSystemPickedEvent extends Event {
32 |
33 | private static final HandlerList HANDLER_LIST = new HandlerList();
34 |
35 | private final CloudSystem cloudSystem;
36 |
37 | public CloudSystemPickedEvent(CloudSystem cloudSystem) {
38 | this.cloudSystem = cloudSystem;
39 | }
40 |
41 | public static HandlerList getHandlerList() {
42 | return HANDLER_LIST;
43 | }
44 |
45 | public CloudSystem getCloudSystem() {
46 | return this.cloudSystem;
47 | }
48 |
49 | @Override
50 | public HandlerList getHandlers() {
51 | return HANDLER_LIST;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/ps-plugin-spigot/src/main/java/com/github/derklaro/privateservers/event/TranslationManagerSetupEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.event;
26 |
27 | import com.github.derklaro.privateservers.api.translation.TranslationManager;
28 | import org.bukkit.event.Event;
29 | import org.bukkit.event.HandlerList;
30 |
31 | public class TranslationManagerSetupEvent extends Event {
32 |
33 | private static final HandlerList HANDLER_LIST = new HandlerList();
34 |
35 | private TranslationManager translationManager;
36 |
37 | public TranslationManagerSetupEvent(TranslationManager translationManager) {
38 | this.translationManager = translationManager;
39 | }
40 |
41 | public static HandlerList getHandlerList() {
42 | return HANDLER_LIST;
43 | }
44 |
45 | public TranslationManager getTranslationManager() {
46 | return this.translationManager;
47 | }
48 |
49 | public void setTranslationManager(TranslationManager translationManager) {
50 | this.translationManager = translationManager;
51 | }
52 |
53 | @Override
54 | public HandlerList getHandlers() {
55 | return HANDLER_LIST;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/ps-plugin-spigot/src/main/java/com/github/derklaro/privateservers/translation/BukkitComponentRenderer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.translation;
26 |
27 | import com.github.derklaro.privateservers.api.translation.ComponentRenderer;
28 | import net.kyori.adventure.text.Component;
29 | import org.bukkit.entity.Player;
30 | import org.jetbrains.annotations.NotNull;
31 |
32 | import java.lang.invoke.MethodHandle;
33 | import java.lang.invoke.MethodHandles;
34 | import java.lang.reflect.Method;
35 | import java.util.function.Function;
36 |
37 | public final class BukkitComponentRenderer {
38 |
39 | private static final Function GET_LOCALE;
40 |
41 | static {
42 | Function localeGetter;
43 | try {
44 | // legacy bukkit
45 | Player.Spigot.class.getMethod("getLocale");
46 | localeGetter = player -> player.spigot().getLocale();
47 | } catch (ReflectiveOperationException exception) {
48 | // modern bukkit
49 | try {
50 | Method getLocale = Player.class.getMethod("getLocale");
51 | MethodHandle getterHandle = MethodHandles.publicLookup().unreflect(getLocale);
52 |
53 | localeGetter = player -> {
54 | try {
55 | return (String) getterHandle.invoke(player);
56 | } catch (Throwable throwable) {
57 | return null;
58 | }
59 | };
60 | } catch (ReflectiveOperationException e) {
61 | // no other method is working, use fallback locale
62 | localeGetter = player -> null;
63 | }
64 | }
65 |
66 | GET_LOCALE = localeGetter;
67 | }
68 |
69 | private BukkitComponentRenderer() {
70 | throw new UnsupportedOperationException();
71 | }
72 |
73 | public static void renderAndSend(@NotNull Player player, @NotNull Component component) {
74 | player.sendMessage(ComponentRenderer.renderToString(component, GET_LOCALE.apply(player)));
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/ps-runner-spigot/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) $2020-today.year Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | plugins {
26 | id 'com.github.johnrengelman.shadow' version '7.1.2'
27 | }
28 |
29 | dependencies {
30 | compileOnly project(':ps-plugin-spigot')
31 | annotationProcessor project(':ps-api-annotation-processor')
32 | compileOnly 'org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT'
33 | }
34 |
35 | java {
36 | withJavadocJar()
37 | }
38 |
39 | shadowJar {
40 | archiveVersion.set(null)
41 | archiveFileName.set('ps-runner-spigot.jar')
42 | }
43 |
--------------------------------------------------------------------------------
/ps-runner-spigot/src/main/java/com/github/derklaro/privateservers/runner/command/PrivateServerInfoCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.runner.command;
26 |
27 | import com.github.derklaro.privateservers.api.Constants;
28 | import com.github.derklaro.privateservers.api.cloud.CloudServiceManager;
29 | import com.github.derklaro.privateservers.api.cloud.CloudSystem;
30 | import com.github.derklaro.privateservers.api.cloud.configuration.CloudServiceConfiguration;
31 | import com.github.derklaro.privateservers.api.cloud.service.CloudService;
32 | import com.github.derklaro.privateservers.common.translation.Message;
33 | import com.github.derklaro.privateservers.translation.BukkitComponentRenderer;
34 | import org.bukkit.command.Command;
35 | import org.bukkit.command.CommandExecutor;
36 | import org.bukkit.command.CommandSender;
37 | import org.bukkit.entity.Player;
38 |
39 | public class PrivateServerInfoCommand implements CommandExecutor {
40 |
41 | private final CloudServiceManager manager;
42 |
43 | public PrivateServerInfoCommand(CloudSystem cloudSystem) {
44 | this.manager = cloudSystem.getCloudServiceManager();
45 | }
46 |
47 | @Override
48 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
49 | CloudService cloudService = this.manager.getCurrentCloudService().orElse(null);
50 | if (cloudService == null || !(sender instanceof Player)) {
51 | sender.sendMessage("§cUnable to process command");
52 | return true;
53 | }
54 |
55 | Player player = (Player) sender;
56 | if (!player.hasPermission(Constants.SERVER_INFO_COMMAND_USE_PERM)) {
57 | BukkitComponentRenderer.renderAndSend(player, Message.COMMAND_NOT_ALLOWED.build());
58 | return true;
59 | }
60 |
61 | CloudServiceConfiguration config = cloudService.getCloudServiceConfiguration();
62 | BukkitComponentRenderer.renderAndSend(player, Message.PRIVATE_SERVER_INFO.build(
63 | cloudService.getOwnerName(),
64 | cloudService.getOwnerUniqueId(),
65 | config.isPublicService() ? Message.VISIBILITY_PUBLIC.build() : Message.VISIBILITY_PRIVATE.build(),
66 | config.isWhitelist() ? Message.WHITELIST_ON.build() : Message.WHITELIST_OFF.build()
67 | ));
68 | return true;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/ps-runner-spigot/src/main/java/com/github/derklaro/privateservers/runner/listeners/CloudSystemPickedListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.runner.listeners;
26 |
27 | import com.github.derklaro.privateservers.event.CloudSystemPickedEvent;
28 | import com.github.derklaro.privateservers.runner.PrivateServersSpigotRunner;
29 | import org.bukkit.event.EventHandler;
30 | import org.bukkit.event.Listener;
31 | import org.jetbrains.annotations.NotNull;
32 |
33 | public class CloudSystemPickedListener implements Listener {
34 |
35 | private final PrivateServersSpigotRunner runner;
36 |
37 | public CloudSystemPickedListener(PrivateServersSpigotRunner runner) {
38 | this.runner = runner;
39 | }
40 |
41 | @EventHandler
42 | public void handle(@NotNull CloudSystemPickedEvent event) {
43 | this.runner.handleCloudSystemPick(event.getCloudSystem());
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/ps-runner-spigot/src/main/java/com/github/derklaro/privateservers/runner/listeners/PlayerLoginListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.runner.listeners;
26 |
27 | import com.github.derklaro.privateservers.api.Constants;
28 | import com.github.derklaro.privateservers.api.cloud.CloudSystem;
29 | import com.github.derklaro.privateservers.api.cloud.service.CloudService;
30 | import com.github.derklaro.privateservers.api.translation.ComponentRenderer;
31 | import com.github.derklaro.privateservers.common.translation.Message;
32 | import org.bukkit.event.EventHandler;
33 | import org.bukkit.event.EventPriority;
34 | import org.bukkit.event.Listener;
35 | import org.bukkit.event.player.PlayerLoginEvent;
36 | import org.jetbrains.annotations.NotNull;
37 |
38 | public class PlayerLoginListener implements Listener {
39 |
40 | private final CloudSystem cloudSystem;
41 |
42 | public PlayerLoginListener(CloudSystem cloudSystem) {
43 | this.cloudSystem = cloudSystem;
44 | }
45 |
46 | @EventHandler(priority = EventPriority.HIGHEST)
47 | public void handle(@NotNull PlayerLoginEvent event) {
48 | if (event.getPlayer().hasPermission(Constants.WHITELIST_JOIN_PERM)) {
49 | return;
50 | }
51 |
52 | this.cloudSystem.getCloudServiceManager().getCurrentCloudService()
53 | .map(CloudService::getCloudServiceConfiguration)
54 | .ifPresent(cloudServiceConfiguration -> {
55 | if (cloudServiceConfiguration.getOwnerUniqueId().equals(event.getPlayer().getUniqueId())) {
56 | return;
57 | }
58 |
59 | if (cloudServiceConfiguration.isWhitelist() && !cloudServiceConfiguration.getWhitelistedPlayers().contains(event.getPlayer().getName())) {
60 | event.setResult(PlayerLoginEvent.Result.KICK_WHITELIST);
61 | event.setKickMessage(ComponentRenderer.renderToString(Message.NOT_WHITELISTED.build()));
62 | }
63 | });
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/ps-runner-spigot/src/main/java/com/github/derklaro/privateservers/runner/listeners/PlayerQuitListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ps-system, licensed under the MIT License (MIT).
3 | *
4 | * Copyright (c) 2020-2021 Pasqual K. and contributors
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package com.github.derklaro.privateservers.runner.listeners;
26 |
27 | import com.github.derklaro.privateservers.PrivateServersSpigot;
28 | import com.github.derklaro.privateservers.api.cloud.CloudSystem;
29 | import com.github.derklaro.privateservers.api.cloud.configuration.CloudServiceConfiguration;
30 | import org.bukkit.Bukkit;
31 | import org.bukkit.event.EventHandler;
32 | import org.bukkit.event.Listener;
33 | import org.bukkit.event.player.PlayerQuitEvent;
34 | import org.jetbrains.annotations.NotNull;
35 |
36 | public class PlayerQuitListener implements Listener {
37 |
38 | private final CloudSystem cloudSystem;
39 |
40 | public PlayerQuitListener(CloudSystem cloudSystem) {
41 | this.cloudSystem = cloudSystem;
42 | }
43 |
44 | @EventHandler
45 | public void handle(@NotNull PlayerQuitEvent event) {
46 | this.cloudSystem.getCloudServiceManager().getCurrentCloudService().ifPresent(cloudService -> {
47 | CloudServiceConfiguration configuration = cloudService.getCloudServiceConfiguration();
48 | if (event.getPlayer().getUniqueId().equals(configuration.getOwnerUniqueId())) {
49 | if (configuration.isAutoDeleteAfterOwnerLeave()) {
50 | cloudService.shutdown();
51 | } else {
52 | Bukkit.getScheduler().scheduleSyncDelayedTask(PrivateServersSpigot.getInstance(), () -> {
53 | // recheck if the owner is online again
54 | if (Bukkit.getPlayer(configuration.getOwnerUniqueId()) == null) {
55 | cloudService.shutdown();
56 | }
57 | }, configuration.getMaxIdleSeconds() * 20L);
58 | }
59 | }
60 | });
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'privateservers'
2 |
3 | /*
4 | * This file is part of ps-system, licensed under the MIT License (MIT).
5 | *
6 | * Copyright (c) 2020-2021 Pasqual K. and contributors
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to deal
10 | * in the Software without restriction, including without limitation the rights
11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | * copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | * THE SOFTWARE.
25 | */
26 |
27 | // api
28 | include(':ps-api')
29 | include(':ps-api-annotation-processor')
30 | // commons
31 | include(':ps-common')
32 | // spigot impl
33 | include(':ps-plugin-spigot')
34 | include(':ps-lobby-spigot')
35 | include(':ps-runner-spigot')
36 | // other modules
37 | include(':ps-cloudnet2')
38 | include(':ps-cloudnet3')
39 | include(':ps-cloudnet2-legacy')
40 |
--------------------------------------------------------------------------------