Init push
This commit is contained in:
commit
ba679e6f8d
42
.gitignore
vendored
Normal file
42
.gitignore
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
.gradle
|
||||||
|
build/
|
||||||
|
!gradle/wrapper/gradle-wrapper.jar
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
out/
|
||||||
|
!**/src/main/**/out/
|
||||||
|
!**/src/test/**/out/
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
bin/
|
||||||
|
!**/src/main/**/bin/
|
||||||
|
!**/src/test/**/bin/
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
||||||
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
49
.idea/gradle.xml
Normal file
49
.idea/gradle.xml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<compositeConfiguration>
|
||||||
|
<compositeBuild compositeDefinitionSource="SCRIPT">
|
||||||
|
<builds>
|
||||||
|
<build path="$PROJECT_DIR$/build-extensions" name="build-extensions">
|
||||||
|
<projects>
|
||||||
|
<project path="$PROJECT_DIR$/build-extensions" />
|
||||||
|
</projects>
|
||||||
|
</build>
|
||||||
|
</builds>
|
||||||
|
</compositeBuild>
|
||||||
|
</compositeConfiguration>
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="gradleJvm" value="corretto-21" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/bom" />
|
||||||
|
<option value="$PROJECT_DIR$/build-extensions" />
|
||||||
|
<option value="$PROJECT_DIR$/wcloud-api" />
|
||||||
|
<option value="$PROJECT_DIR$/wcloud-driver" />
|
||||||
|
<option value="$PROJECT_DIR$/wcloud-launcher" />
|
||||||
|
<option value="$PROJECT_DIR$/wcloud-modules" />
|
||||||
|
<option value="$PROJECT_DIR$/wcloud-modules/wmodule-cloudflare" />
|
||||||
|
<option value="$PROJECT_DIR$/wcloud-modules/wmodule-discord" />
|
||||||
|
<option value="$PROJECT_DIR$/wcloud-modules/wmodule-hub" />
|
||||||
|
<option value="$PROJECT_DIR$/wcloud-modules/wmodule-notify" />
|
||||||
|
<option value="$PROJECT_DIR$/wcloud-modules/wmodule-npc" />
|
||||||
|
<option value="$PROJECT_DIR$/wcloud-modules/wmodule-permissions" />
|
||||||
|
<option value="$PROJECT_DIR$/wcloud-modules/wmodule-reboot" />
|
||||||
|
<option value="$PROJECT_DIR$/wcloud-modules/wmodule-signs" />
|
||||||
|
<option value="$PROJECT_DIR$/wcloud-modules/wmodule-syncproxy" />
|
||||||
|
<option value="$PROJECT_DIR$/wcloud-networking" />
|
||||||
|
<option value="$PROJECT_DIR$/wcloud-plugin" />
|
||||||
|
<option value="$PROJECT_DIR$/wcloud-runnable" />
|
||||||
|
<option value="$PROJECT_DIR$/wcloud-runnable/wcloud-daemon" />
|
||||||
|
<option value="$PROJECT_DIR$/wcloud-runnable/wcloud-master" />
|
||||||
|
<option value="$PROJECT_DIR$/wcloud-utils" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
7
.idea/kotlinc.xml
Normal file
7
.idea/kotlinc.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="KotlinJpsPluginSettings">
|
||||||
|
<option name="externalSystemId" value="Gradle" />
|
||||||
|
<option name="version" value="2.4.10" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
7
.idea/misc.xml
Normal file
7
.idea/misc.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_25" project-jdk-name="corretto-21" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
124
.idea/uiDesigner.xml
Normal file
124
.idea/uiDesigner.xml
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Palette2">
|
||||||
|
<group name="Swing">
|
||||||
|
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Button" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="RadioButton" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="CheckBox" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Label" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||||
|
<preferred-size width="-1" height="20" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
</group>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
76
DEPENDENCY_UPDATES.md
Normal file
76
DEPENDENCY_UPDATES.md
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# Dependency-Update vom 06.11.2026
|
||||||
|
|
||||||
|
Paper und Velocity wurden auf Wunsch auf Paper API `26.3.build.244-stable` und Velocity API `4.3.1` migriert. Beide APIs veröffentlichen Java-25-Bytecode und verwenden Adventure 5.2.0. Deshalb verwenden die Java-Module jetzt eine Java-25-Toolchain und `--release 25`; zum Ausführen der Cloud wird Java 25 benötigt. Netty 4.1, JLine 3, JUnit 5 und Testcontainers 1 bleiben in ihren bisherigen Versionsreihen.
|
||||||
|
|
||||||
|
## Versionenkatalog
|
||||||
|
|
||||||
|
| Dependency | Vorher | Nachher |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| spotless | 7.0.2 | 8.11.0 |
|
||||||
|
| shadow | 8.3.6 | 9.6.1 |
|
||||||
|
| gson | 2.12.1 | 2.15.0 |
|
||||||
|
| guava | 33.4.0-jre | 33.8.0-jre |
|
||||||
|
| sqlite | 3.45.1.0 | 3.54.1.0 |
|
||||||
|
| junit | 5.11.4 | 5.14.4 |
|
||||||
|
| mockito | 5.15.2 | 5.24.0 |
|
||||||
|
| junitLauncher | 1.11.4 | 1.14.4 |
|
||||||
|
| testcontainers | 1.20.4 | 1.21.4 |
|
||||||
|
| lombok | 1.18.36 | 1.18.48 |
|
||||||
|
| jansi | 2.4.1 | 2.4.3 |
|
||||||
|
| jline | 3.29.0 | 3.30.17 |
|
||||||
|
| netty | 4.1.119.Final | 4.1.140.Final |
|
||||||
|
| vavr | 0.10.6 | 0.10.7 |
|
||||||
|
| annotations | 26.0.2 | 26.1.0 |
|
||||||
|
| slf4j | 2.0.16 | 2.0.20 |
|
||||||
|
| logback | 1.5.16 | 1.5.38 |
|
||||||
|
| velocity | 3.4.0-SNAPSHOT | 4.3.1 |
|
||||||
|
| bungeecord | 1.21-R0.2 | 1.21-R0.4 |
|
||||||
|
| paper | 1.21.4-R0.1-SNAPSHOT | 26.3.build.244-stable |
|
||||||
|
| adventure | 4.19.0 | 5.2.0 |
|
||||||
|
| adventurePlatform | 4.3.0 | 4.4.1 |
|
||||||
|
| npcLib | 3.0.0-beta10 | 3.0.0-beta.18 |
|
||||||
|
| packetEvents | 2.7.0 | 2.14.0 |
|
||||||
|
| placeholderApi | 2.11.6 | 2.12.3 |
|
||||||
|
| floodgate | 2.2.4-SNAPSHOT | 2.2.5-SNAPSHOT |
|
||||||
|
| cloudflareapi | 1.4.0 | 1.5.0 |
|
||||||
|
|
||||||
|
|
||||||
|
## Build-Werkzeuge
|
||||||
|
|
||||||
|
- Gradle-Wrapper: 8.13 → 9.8.2, einschließlich Wrapper-JAR und Startskripten. Der Distributionsdownload ist mit SHA-256 abgesichert; das Netzwerk-Timeout beträgt 60 Sekunden.
|
||||||
|
- Foojay Toolchain Resolver: 0.8.0 → 1.0.0.
|
||||||
|
- Build-Extensions: Indra 3.1.3 → 3.2.0 und Gson 2.12.1 → 2.15.0.
|
||||||
|
|
||||||
|
## Plattformmigration
|
||||||
|
|
||||||
|
- Java-25-Toolchain für Java-Module und angepasste Mindestversionsprüfung im Launcher.
|
||||||
|
- Jenkins verwendet jetzt den Tool-Namen `Java-25`; ein JDK 25 muss dort unter diesem Namen eingerichtet sein.
|
||||||
|
- Gradle 9.8.2 unterstützt Java 25; Shadow wurde dazu auf 9.6.1 aktualisiert.
|
||||||
|
- Die entfernte Feature-Preview `STABLE_CONFIGURATION_CACHE` wurde entfernt und der Zugriff auf Source-Sets von Projektabhängigkeiten für Gradle 9 angepasst.
|
||||||
|
- Paper ist auf einen konkreten stabilen Build festgelegt, ohne dynamische `+`-Version.
|
||||||
|
- `wcloud-driver:test` schließt ausschließlich `Main.class` aus: Das manuelle Sprachprogramm ist kein JUnit-Test. Die allgemeine Gradle-Prüfung auf fehlerhafte Testsuche bleibt aktiv.
|
||||||
|
|
||||||
|
## Weitere Änderungen
|
||||||
|
|
||||||
|
- Maven Central steht wieder vor den Spiegel-Repositories, damit Release-Abhängigkeiten direkt aufgelöst werden können.
|
||||||
|
- Die normalen JARs und Shadow-JARs überschrieben zuvor dieselbe Datei. Normale JARs erhalten jetzt den Klassifikator `plain`; die Shadow-JARs behalten ihre bisherigen Namen, etwa `wcloud-launcher.jar`. Sources-JARs behalten den Klassifikator `sources`.
|
||||||
|
- Der bereits eingetragene eigene Devlok-Stand `2026.11.06-01` bleibt erhalten. Für JavaPoet und java-string-similarity wurde keine neuere Version unter denselben Koordinaten gefunden.
|
||||||
|
- Einige Einträge (z. B. NPC-Lib, PacketEvents und PlaceholderAPI) werden derzeit von keinem Modul verwendet. Deren Katalogversionen wurden aktualisiert; sie werden dadurch nicht neu in die Cloud eingebunden.
|
||||||
|
|
||||||
|
## Prüfung der Plattformmigration
|
||||||
|
|
||||||
|
- `gradlew.bat clean assemble test shadowJar --console=plain --info`: **erfolgreich**, Gradle 9.8.2, Java-25-Toolchain; 87 Tasks (53 ausgeführt, 24 aus dem Cache, 10 aktuell).
|
||||||
|
- Alle Java-Module kompilieren. Die aufgelösten Abhängigkeiten bestätigen Paper API `26.3.build.244-stable`, Velocity API `4.3.1` und Adventure API `5.2.0`.
|
||||||
|
- 18 erzeugte JARs wurden auf ZIP-Integrität geprüft. Launcher und API enthalten Java-25-Bytecode (Classfile-Version 69); die Launcher-Main-Klasse ist korrekt.
|
||||||
|
- Es gibt weiterhin keine automatisierten JUnit-Tests. Alle Test-Tasks enden entsprechend mit `NO-SOURCE`. Ein laufender Minecraft-Verbund wurde nicht gestartet.
|
||||||
|
- `gradlew.bat build --continue :wcloud-api:dependencies --configuration compileClasspath`: scheitert ausschließlich an den 15 bestehenden `spotlessJavaCheck`-Tasks wegen fehlender Lizenzheader.
|
||||||
|
- Wrapper-JAR gegen die offizielle SHA-256-Prüfsumme von Gradle 9.8.2 geprüft; Distributionsprüfsumme und URL-Prüfung sind aktiv.
|
||||||
|
- Vollständige lokale Logs: [Build](build/dependency-update/build.log), [Checks und Dependency-Graph](build/dependency-update/checks.log).
|
||||||
|
|
||||||
|
## Quellen
|
||||||
|
|
||||||
|
- [Gradle 9.8.2 Release Notes](https://docs.gradle.org/9.8.2/release-notes.html)
|
||||||
|
- [Paper: Java-Voraussetzungen](https://docs.papermc.io/paper/getting-started/): Paper 1.21.11 verwendet Java 21; Paper 26.1+ benötigt Java 25.
|
||||||
|
- [Velocity: Java-Voraussetzungen](https://docs.papermc.io/velocity/faq/): Velocity 4.x benötigt Java 25.
|
||||||
|
- [Shadow-Kompatibilität](https://github.com/GradleUp/shadow/blob/main/README.md).
|
||||||
|
- Veröffentlichte Maven-Metadaten von [Maven Central](https://repo.maven.apache.org/maven2/), [Gradle Plugin Portal](https://plugins.gradle.org/m2/), [PaperMC](https://repo.papermc.io/repository/maven-public/), [OpenCollab](https://repo.opencollab.dev/maven-snapshots/), [CodeMC](https://repo.codemc.io/repository/maven-releases/), [PlaceholderAPI](https://repo.helpch.at/releases/) und [JitPack](https://jitpack.io/).
|
||||||
44
Jenkinsfile
vendored
Normal file
44
Jenkinsfile
vendored
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
|
||||||
|
tools {
|
||||||
|
jdk 'Java-25'
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('check java') {
|
||||||
|
steps {
|
||||||
|
sh 'java -version'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage("build") {
|
||||||
|
steps {
|
||||||
|
withCredentials([
|
||||||
|
usernamePassword(credentialsId: 'jf-repo',
|
||||||
|
usernameVariable: 'REPO_USER',
|
||||||
|
passwordVariable: 'REPO_PASS')
|
||||||
|
]) {
|
||||||
|
sh '''
|
||||||
|
echo "repoUser=$REPO_USER" > gradle.properties
|
||||||
|
echo "repoPassword=$REPO_PASS" >> gradle.properties
|
||||||
|
|
||||||
|
chmod +x ./gradlew
|
||||||
|
./gradlew clean shadowJar
|
||||||
|
|
||||||
|
rm -f gradle.properties
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('archive artifact') {
|
||||||
|
steps {
|
||||||
|
archiveArtifacts artifacts: 'wcloud-api/build/libs/*.jar', fingerprint: true
|
||||||
|
archiveArtifacts artifacts: 'wcloud-plugin/build/libs/*.jar', fingerprint: true
|
||||||
|
archiveArtifacts artifacts: 'wcloud-launcher/build/libs/*.jar', fingerprint: true
|
||||||
|
archiveArtifacts artifacts: 'wcloud-runnable/**/build/libs/*.jar', fingerprint: true
|
||||||
|
archiveArtifacts artifacts: 'wcloud-modules/**/build/libs/*.jar', fingerprint: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
15
LICENSE_HEADER
Normal file
15
LICENSE_HEADER
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2025 wCloud team & contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
20
bom/build.gradle.kts
Normal file
20
bom/build.gradle.kts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
plugins {
|
||||||
|
id("java-platform")
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
constraints {
|
||||||
|
collectSubProjects(rootProject, mutableListOf()).forEach {
|
||||||
|
api(project(it))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun collectSubProjects(root: Project, paths: MutableList<String>): List<String> {
|
||||||
|
root.subprojects.forEach {
|
||||||
|
paths.add(it.path)
|
||||||
|
collectSubProjects(it, paths)
|
||||||
|
}
|
||||||
|
// just to make it look cleaner :)
|
||||||
|
return paths
|
||||||
|
}
|
||||||
12
build-extensions/build.gradle.kts
Normal file
12
build-extensions/build.gradle.kts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
plugins {
|
||||||
|
`kotlin-dsl`
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation("net.kyori", "indra-common", "3.2.0")
|
||||||
|
implementation("com.google.code.gson", "gson", "2.15.0")
|
||||||
|
}
|
||||||
28
build-extensions/src/main/kotlin/ChecksumHelper.kt
Normal file
28
build-extensions/src/main/kotlin/ChecksumHelper.kt
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import java.io.File
|
||||||
|
import java.io.IOException
|
||||||
|
import java.security.MessageDigest
|
||||||
|
import java.security.NoSuchAlgorithmException
|
||||||
|
|
||||||
|
object ChecksumHelper {
|
||||||
|
|
||||||
|
@Throws(IOException::class)
|
||||||
|
fun fileShaSum(path: File): String {
|
||||||
|
return newSha3256Digest().run {
|
||||||
|
update(path.readBytes())
|
||||||
|
bytesToHex(digest())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Throws(NoSuchAlgorithmException::class)
|
||||||
|
private fun newSha3256Digest(): MessageDigest = MessageDigest.getInstance("SHA3-256")
|
||||||
|
|
||||||
|
private fun bytesToHex(input: ByteArray): String {
|
||||||
|
val buffer = StringBuilder()
|
||||||
|
for (b in input) {
|
||||||
|
buffer.append(Character.forDigit(b.toInt() shr 4 and 0xF, 16))
|
||||||
|
buffer.append(Character.forDigit(b.toInt() and 0xF, 16))
|
||||||
|
}
|
||||||
|
// convert to a string
|
||||||
|
return buffer.toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
22
build-extensions/src/main/kotlin/Files.kt
Normal file
22
build-extensions/src/main/kotlin/Files.kt
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
object Files {
|
||||||
|
|
||||||
|
const val api = "wcloud-api.jar"
|
||||||
|
const val driver = "wcloud-driver.jar"
|
||||||
|
const val networking = "wcloud-networking.jar"
|
||||||
|
const val launcher = "wcloud-launcher.jar"
|
||||||
|
const val master = "wcloud-master.jar"
|
||||||
|
const val daemon = "wcloud-daemon.jar"
|
||||||
|
const val plugin = "wcloud-plugin.jar"
|
||||||
|
|
||||||
|
const val cloudflare = "wmodule-cloudflare.jar"
|
||||||
|
const val discord = "wmodule-discord.jar"
|
||||||
|
const val hub = "wmodule-hub.jar"
|
||||||
|
const val notify = "wmodule-notify.jar"
|
||||||
|
const val npc = "wmodule-npc.jar"
|
||||||
|
const val permissions = "wmodule-permissions.jar"
|
||||||
|
const val reboot = "wmodule-reboot.jar"
|
||||||
|
const val signs = "wmodule-signs.jar"
|
||||||
|
const val syncproxy = "wmodule-syncproxy.jar"
|
||||||
|
const val friends = "wmodule-friends.jar"
|
||||||
|
|
||||||
|
}
|
||||||
4
build-extensions/src/main/kotlin/Versions.kt
Normal file
4
build-extensions/src/main/kotlin/Versions.kt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
object Versions {
|
||||||
|
const val wcloud = "1.0.0-RC2"
|
||||||
|
const val wCloudCodeName = "Sandstorm"
|
||||||
|
}
|
||||||
132
build-extensions/src/main/kotlin/extensions.kt
Normal file
132
build-extensions/src/main/kotlin/extensions.kt
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
import net.kyori.indra.git.IndraGitExtension
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.api.artifacts.ProjectDependency
|
||||||
|
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
|
||||||
|
import org.gradle.api.internal.artifacts.repositories.resolver.MavenUniqueSnapshotComponentIdentifier
|
||||||
|
import org.gradle.api.plugins.JavaPluginExtension
|
||||||
|
import org.gradle.api.tasks.SourceSetContainer
|
||||||
|
import org.gradle.jvm.tasks.Jar
|
||||||
|
import org.gradle.kotlin.dsl.attributes
|
||||||
|
import org.gradle.kotlin.dsl.findByType
|
||||||
|
import org.gradle.kotlin.dsl.named
|
||||||
|
import org.gradle.kotlin.dsl.the
|
||||||
|
import java.net.HttpURLConnection
|
||||||
|
|
||||||
|
fun Project.applyJarMetadata(mainClass: String, module: String) {
|
||||||
|
applyJarMetadata(mainClass, module, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.applyJarMetadata(mainClass: String, module: String, preMain: String?) {
|
||||||
|
if ("jar" in tasks.names) {
|
||||||
|
tasks.named<Jar>("jar") {
|
||||||
|
manifest.attributes(
|
||||||
|
"Main-Class" to mainClass,
|
||||||
|
"Automatic-Module-Name" to module,
|
||||||
|
"Implementation-Vendor" to "WCloudService",
|
||||||
|
"Implementation-Title" to Versions.wCloudCodeName,
|
||||||
|
"Implementation-Version" to project.version.toString() + "-${shortCommitHash()}")
|
||||||
|
// apply the pre-main class if given
|
||||||
|
if (preMain != null) {
|
||||||
|
manifest.attributes("Premain-Class" to preMain)
|
||||||
|
}
|
||||||
|
// apply git information to manifest
|
||||||
|
git()?.applyVcsInformationToManifest(manifest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.shortCommitHash(): String {
|
||||||
|
return git()?.commit()?.name?.substring(0, 8) ?: "unknown"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.git(): IndraGitExtension? = rootProject.extensions.findByType()
|
||||||
|
|
||||||
|
fun Project.sourceSets(): SourceSetContainer = the<JavaPluginExtension>().sourceSets
|
||||||
|
|
||||||
|
fun Project.sourceSets(dependency: ProjectDependency): SourceSetContainer = project(dependency.path).sourceSets()
|
||||||
|
|
||||||
|
fun Project.mavenRepositories(): Iterable<MavenArtifactRepository> = repositories.filterIsInstance<MavenArtifactRepository>()
|
||||||
|
|
||||||
|
fun releasesOnly(repository: MavenArtifactRepository) {
|
||||||
|
repository.mavenContent {
|
||||||
|
releasesOnly()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun snapshotsOnly(repository: MavenArtifactRepository) {
|
||||||
|
repository.mavenContent {
|
||||||
|
snapshotsOnly()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.exportLanguageFileInformation(): String {
|
||||||
|
val file = project.layout.buildDirectory.file("languages.txt").get().asFile
|
||||||
|
file.writeText(project.projectDir.resolve("src/main/resources/lang").listFiles()?.joinToString(separator = "\n") { it.name }!!)
|
||||||
|
|
||||||
|
return file.absolutePath
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.exportCnlFile(fileName: String, ignoredDependencyGroups: Array<String> = arrayOf()): String {
|
||||||
|
val stringBuilder = StringBuilder("# CloudNet ${Versions.wCloudCodeName} ${Versions.wcloud}\n\n")
|
||||||
|
.append("# repositories\n")
|
||||||
|
// add all repositories
|
||||||
|
mavenRepositories().forEach { repo ->
|
||||||
|
stringBuilder.append("repo ${repo.name} ${repo.url.toString().dropLastWhile { it == '/' }}\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
// add all dependencies
|
||||||
|
stringBuilder.append("\n\n# dependencies\n")
|
||||||
|
configurations.getByName("runtimeClasspath").resolvedConfiguration.resolvedArtifacts.forEach {
|
||||||
|
// get the module version from the artifact, stop if the dependency is ignored
|
||||||
|
val id = it.moduleVersion.id
|
||||||
|
if (id.group.equals(group) || ignoredDependencyGroups.contains(id.group)) {
|
||||||
|
return@forEach
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if the dependency is a snapshot version - in this case we need to use another artifact url
|
||||||
|
var version = id.version
|
||||||
|
if (id.version.endsWith("-SNAPSHOT") && it.id.componentIdentifier is MavenUniqueSnapshotComponentIdentifier) {
|
||||||
|
// little hack to get the timestamped ("snapshot") version of the identifier
|
||||||
|
version = (it.id.componentIdentifier as MavenUniqueSnapshotComponentIdentifier).timestampedVersion
|
||||||
|
}
|
||||||
|
|
||||||
|
// try to find the repository associated with the module
|
||||||
|
val repository = resolveRepository(
|
||||||
|
"${id.group.replace('.', '/')}/${id.name}/${id.version}/${id.name}-$version.jar",
|
||||||
|
mavenRepositories()
|
||||||
|
) ?: throw IllegalStateException("Unable to resolve repository for $id")
|
||||||
|
|
||||||
|
// add the repository
|
||||||
|
val cs = ChecksumHelper.fileShaSum(it.file)
|
||||||
|
stringBuilder.append("include ${repository.name} ${id.group} ${id.name} ${id.version} $version $cs ${it.classifier ?: ""}\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
// write to the output file
|
||||||
|
val target = project.layout.buildDirectory.file(fileName).get().asFile
|
||||||
|
target.writeText(stringBuilder.toString())
|
||||||
|
|
||||||
|
return target.absolutePath
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun resolveRepository(
|
||||||
|
testUrlPath: String,
|
||||||
|
repositories: Iterable<MavenArtifactRepository>
|
||||||
|
): MavenArtifactRepository? {
|
||||||
|
return repositories.firstOrNull {
|
||||||
|
val url = it.url.resolve(testUrlPath).toURL()
|
||||||
|
with(url.openConnection() as HttpURLConnection) {
|
||||||
|
useCaches = false
|
||||||
|
readTimeout = 30000
|
||||||
|
connectTimeout = 30000
|
||||||
|
instanceFollowRedirects = true
|
||||||
|
|
||||||
|
setRequestProperty(
|
||||||
|
"User-Agent",
|
||||||
|
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11"
|
||||||
|
)
|
||||||
|
|
||||||
|
connect()
|
||||||
|
responseCode == 200
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
plugins {
|
||||||
|
id("net.kyori.indra.git")
|
||||||
|
}
|
||||||
180
build.gradle.kts
Normal file
180
build.gradle.kts
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
import com.diffplug.gradle.spotless.SpotlessExtension
|
||||||
|
import org.gradle.api.credentials.PasswordCredentials
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("wcloud.parent-build-logic")
|
||||||
|
id("maven-publish")
|
||||||
|
alias(libs.plugins.spotless)
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultTasks("build", "test", "shadowJar")
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
|
||||||
|
version = Versions.wcloud
|
||||||
|
group = "de.wcloudservice"
|
||||||
|
description = "A modern application that can dynamically and easily deliver Minecraft oriented software"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
releasesOnly(mavenCentral())
|
||||||
|
|
||||||
|
// Prefer Maven Central over mirrors for release dependencies.
|
||||||
|
maven("https://repo.spongepowered.org/maven/")
|
||||||
|
|
||||||
|
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
|
||||||
|
maven("https://repo.papermc.io/repository/maven-public/")
|
||||||
|
|
||||||
|
maven("https://repo.opencollab.dev/main/")
|
||||||
|
|
||||||
|
maven("https://oss.sonatype.org/content/repositories/snapshots")
|
||||||
|
|
||||||
|
// ensure that we use these repositories for snapshots/releases only (improves lookup times)
|
||||||
|
maven {
|
||||||
|
name = "repo"
|
||||||
|
url = uri("https://repo.jfritzsche.de/private")
|
||||||
|
credentials(PasswordCredentials::class)
|
||||||
|
authentication {
|
||||||
|
create<BasicAuthentication>("basic")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
releasesOnly(maven("https://repo.jfritzsche.de/releases/"))
|
||||||
|
snapshotsOnly(maven("https://repo.jfritzsche.de/snapshots/"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
subprojects {
|
||||||
|
// these are top level projects which are configured separately
|
||||||
|
if (name == "wcloud-modules" || name == "wcloud-runnable") {
|
||||||
|
return@subprojects
|
||||||
|
}
|
||||||
|
|
||||||
|
// these are the plugins which we need to apply to all projects
|
||||||
|
apply(plugin = "signing")
|
||||||
|
apply(plugin = "maven-publish")
|
||||||
|
|
||||||
|
// skip further applying to bom - this project is a bit special as we're not allowed to
|
||||||
|
// apply the java plugin to it (that's why we need to stop here, but we need to publish
|
||||||
|
// at well (that's why we're applying the publish plugin)
|
||||||
|
if (name == "bom") {
|
||||||
|
return@subprojects
|
||||||
|
}
|
||||||
|
|
||||||
|
apply(plugin = "java-library")
|
||||||
|
apply(plugin = "com.diffplug.spotless")
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// the 'rootProject.libs.' prefix is needed here - see https://github.com/gradle/gradle/issues/16634
|
||||||
|
// lombok
|
||||||
|
"compileOnly"(rootProject.libs.lombok)
|
||||||
|
"annotationProcessor"(rootProject.libs.lombok)
|
||||||
|
// annotations
|
||||||
|
"compileOnly"(rootProject.libs.annotations)
|
||||||
|
// testing
|
||||||
|
"testImplementation"(rootProject.libs.mockito)
|
||||||
|
"testRuntimeOnly"(rootProject.libs.junitLauncher)
|
||||||
|
"testImplementation"(rootProject.libs.bundles.junit)
|
||||||
|
"testImplementation"(rootProject.libs.bundles.testContainers)
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations.all {
|
||||||
|
// unsure why but every project loves them, and they literally have an import for every letter I type - beware
|
||||||
|
exclude("org.checkerframework", "checker-qual")
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Todo: Add later
|
||||||
|
|
||||||
|
tasks.withType<Jar> {
|
||||||
|
from(rootProject.file("LICENSE"))
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
tasks.withType<Test> {
|
||||||
|
useJUnitPlatform()
|
||||||
|
testLogging {
|
||||||
|
events("started", "passed", "skipped", "failed")
|
||||||
|
}
|
||||||
|
|
||||||
|
// allow dynamic agent loading for mockito
|
||||||
|
jvmArgs(
|
||||||
|
"--enable-preview",
|
||||||
|
"-XX:+EnableDynamicAgentLoading",
|
||||||
|
"--add-opens=java.base/java.lang.invoke=ALL-UNNAMED"
|
||||||
|
)
|
||||||
|
|
||||||
|
// always pass down all given system properties
|
||||||
|
systemProperties(System.getProperties().mapKeys { it.key.toString() })
|
||||||
|
}
|
||||||
|
|
||||||
|
extensions.configure<JavaPluginExtension> {
|
||||||
|
toolchain.languageVersion.set(JavaLanguageVersion.of(25))
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<JavaCompile>().configureEach {
|
||||||
|
options.release.set(25)
|
||||||
|
|
||||||
|
options.encoding = "UTF-8"
|
||||||
|
options.isIncremental = true
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<Checkstyle> {
|
||||||
|
maxErrors = 0
|
||||||
|
maxWarnings = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
extensions.configure<SpotlessExtension> {
|
||||||
|
java {
|
||||||
|
licenseHeaderFile(rootProject.file("LICENSE_HEADER"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register<org.gradle.jvm.tasks.Jar>("sourcesJar") {
|
||||||
|
archiveClassifier.set("sources")
|
||||||
|
from(project.sourceSets()["main"].allJava)
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<JavaCompile> {
|
||||||
|
dependsOn(tasks.withType<ProcessResources>())
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name != "wcloud-api" && name != "wcloud-driver" && name != "wmodule-permissions" && name != "wcloud-utils" && name != "wcloud-networking") {
|
||||||
|
return@subprojects
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "repo"
|
||||||
|
url = uri("https://repo.jfritzsche.de/releases")
|
||||||
|
credentials(PasswordCredentials::class)
|
||||||
|
authentication {
|
||||||
|
create<BasicAuthentication>("basic")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
publications {
|
||||||
|
create<MavenPublication>("maven") {
|
||||||
|
from(components["java"])
|
||||||
|
groupId = "${project.group}"
|
||||||
|
artifactId = "${project.name}"
|
||||||
|
version = "${project.version}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gradle.projectsEvaluated {
|
||||||
|
tasks.register("genUpdaterInformation") {
|
||||||
|
subprojects.forEach {
|
||||||
|
// check if we need to depend on the plugin
|
||||||
|
if (!it.plugins.hasPlugin("java")) return@forEach
|
||||||
|
// depend this task on the build output of each subproject
|
||||||
|
dependsOn("${it.path}:build")
|
||||||
|
}
|
||||||
|
// generate the updater information
|
||||||
|
doLast {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
5
gradle.properties
Normal file
5
gradle.properties
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
org.gradle.caching=true
|
||||||
|
org.gradle.parallel=true
|
||||||
|
org.gradle.warning.mode=all
|
||||||
|
org.gradle.logging.level=info
|
||||||
|
org.gradle.jvmargs=-Xmx5G -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8
|
||||||
131
gradle/libs.versions.toml
Normal file
131
gradle/libs.versions.toml
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
[versions]
|
||||||
|
# plugins
|
||||||
|
spotless = "8.11.0"
|
||||||
|
shadow = "9.6.1"
|
||||||
|
|
||||||
|
# google libs
|
||||||
|
gson = "2.15.0"
|
||||||
|
guava = "33.8.0-jre"
|
||||||
|
sqlite = "3.54.1.0"
|
||||||
|
|
||||||
|
# testing
|
||||||
|
junit = "5.14.4"
|
||||||
|
mockito = "5.24.0"
|
||||||
|
junitLauncher = "1.14.4"
|
||||||
|
testcontainers = "1.21.4"
|
||||||
|
|
||||||
|
# compile time processing
|
||||||
|
lombok = "1.18.48"
|
||||||
|
javapoet = "1.13.0"
|
||||||
|
|
||||||
|
# console
|
||||||
|
jansi = "2.4.3"
|
||||||
|
jline = "3.30.17"
|
||||||
|
stringSimilarity = "2.0.0"
|
||||||
|
|
||||||
|
# general
|
||||||
|
netty = "4.1.140.Final"
|
||||||
|
devlok = "2026.11.06-01"
|
||||||
|
vavr = "0.10.7"
|
||||||
|
annotations = "26.1.0"
|
||||||
|
|
||||||
|
# logging
|
||||||
|
slf4j = "2.0.20"
|
||||||
|
logback = "1.5.38"
|
||||||
|
|
||||||
|
# platform api versions
|
||||||
|
velocity = "4.3.1"
|
||||||
|
bungeecord = "1.21-R0.4"
|
||||||
|
paper = "26.3.build.244-stable"
|
||||||
|
|
||||||
|
# platform extensions
|
||||||
|
adventure = "5.2.0"
|
||||||
|
adventurePlatform = "4.4.1"
|
||||||
|
npcLib = "3.0.0-beta.18"
|
||||||
|
packetEvents = "2.14.0"
|
||||||
|
placeholderApi = "2.12.3"
|
||||||
|
floodgate = "2.2.5-SNAPSHOT"
|
||||||
|
|
||||||
|
# modules
|
||||||
|
cloudflareapi = "1.5.0"
|
||||||
|
|
||||||
|
[libraries]
|
||||||
|
|
||||||
|
# compile time processing
|
||||||
|
lombok = { group = "org.projectlombok", name = "lombok", version.ref = "lombok" }
|
||||||
|
javapoet = { group = "com.squareup", name = "javapoet", version.ref = "javapoet" }
|
||||||
|
|
||||||
|
# google libs
|
||||||
|
guava = { group = "com.google.guava", name = "guava", version.ref = "guava" }
|
||||||
|
gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
|
||||||
|
sqlite = { group = "org.xerial", name = "sqlite-jdbc", version.ref = "sqlite" }
|
||||||
|
|
||||||
|
# console
|
||||||
|
jansi = { group = "org.fusesource.jansi", name = "jansi", version.ref = "jansi" }
|
||||||
|
jline = { group = "org.jline", name = "jline", version.ref = "jline" }
|
||||||
|
jlineReader = { group = "org.jline", name = "jline-reader", version.ref = "jline" }
|
||||||
|
jlineTerminal = { group = "org.jline", name = "jline-terminal-ffm", version.ref = "jline" }
|
||||||
|
stringSimilarity = { group = "info.debatty", name = "java-string-similarity", version.ref = "stringSimilarity" }
|
||||||
|
|
||||||
|
# junit
|
||||||
|
junitApi = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junit" }
|
||||||
|
junitParams = { group = "org.junit.jupiter", name = "junit-jupiter-params", version.ref = "junit" }
|
||||||
|
junitEngine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junit" }
|
||||||
|
junitLauncher = { group = "org.junit.platform", name = "junit-platform-launcher", version.ref = "junitLauncher" }
|
||||||
|
|
||||||
|
# general testing
|
||||||
|
mockito = { group = "org.mockito", name = "mockito-junit-jupiter", version.ref = "mockito" }
|
||||||
|
|
||||||
|
# testcontainers
|
||||||
|
testContainers = { group = "org.testcontainers", name = "testcontainers", version.ref = "testcontainers" }
|
||||||
|
testContainersJunit = { group = "org.testcontainers", name = "junit-jupiter", version.ref = "testcontainers" }
|
||||||
|
|
||||||
|
# logging
|
||||||
|
slf4jApi = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j" }
|
||||||
|
logbackCore = { group = "ch.qos.logback", name = "logback-core", version.ref = "logback" }
|
||||||
|
logbackClassic = { group = "ch.qos.logback", name = "logback-classic", version.ref = "logback" }
|
||||||
|
|
||||||
|
# general
|
||||||
|
netty = { group = "io.netty", name = "netty-all", version.ref = "netty" }
|
||||||
|
devlokNetty = { group = "de.weapie.devlok", name = "devlok-netty", version.ref = "devlok" }
|
||||||
|
devlokFiles = { group = "de.weapie.devlok", name = "devlok-files", version.ref = "devlok" }
|
||||||
|
devlokLogger = { group = "de.weapie.devlok", name = "devlok-logger", version.ref = "devlok" }
|
||||||
|
devlokRedis = { group = "de.weapie.devlok", name = "devlok-redis", version.ref = "devlok" }
|
||||||
|
devlokUtils = { group = "de.weapie.devlok", name = "devlok-utils", version.ref = "devlok" }
|
||||||
|
vavr = { group = "io.vavr", name = "vavr", version.ref = "vavr" }
|
||||||
|
annotations = { group = "org.jetbrains", name = "annotations", version.ref = "annotations" }
|
||||||
|
|
||||||
|
# platform api
|
||||||
|
velocity = { group = "com.velocitypowered", name = "velocity-api", version.ref = "velocity" }
|
||||||
|
bungeecord = { group = "net.md-5", name = "bungeecord-api", version.ref = "bungeecord" }
|
||||||
|
paper = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" }
|
||||||
|
|
||||||
|
# adventure
|
||||||
|
adventureApi = { group = "net.kyori", name = "adventure-api", version.ref = "adventure" }
|
||||||
|
adventurePlattformBungeecord = { group = "net.kyori", name = "adventure-platform-bungeecord", version.ref = "adventurePlatform" }
|
||||||
|
adventureMiniMessage = { group = "net.kyori", name = "adventure-text-minimessage", version.ref = "adventure" }
|
||||||
|
|
||||||
|
# platform extensions
|
||||||
|
placeholderApi = { group = "me.clip", name = "placeholderapi", version.ref = "placeholderApi" }
|
||||||
|
npcLib = { group = "io.github.juliarn", name = "npc-lib-bukkit", version.ref = "npcLib" }
|
||||||
|
packetEvents = { group = "com.github.retrooper", name = "packetevents-spigot", version.ref = "packetEvents" }
|
||||||
|
npcLibLabymod = { group = "io.github.juliarn", name = "npc-lib-labymod", version.ref = "npcLib" }
|
||||||
|
floodgate = { group = "org.geysermc.floodgate", name = "api", version.ref = "floodgate"}
|
||||||
|
|
||||||
|
# modules
|
||||||
|
cloudflareapi = { group = "com.github.robinbraemer", name = "cloudflareapi", version.ref = "cloudflareapi" }
|
||||||
|
|
||||||
|
[bundles]
|
||||||
|
devlok = ["devlokFiles", "devlokUtils"]
|
||||||
|
npcLib = ["npcLib", "npcLibLabymod"]
|
||||||
|
jline = ["jansi", "jline"]
|
||||||
|
junit = ["junitApi", "junitParams", "junitEngine"]
|
||||||
|
testContainers = ["testContainers", "testContainersJunit"]
|
||||||
|
adventure = ["adventureApi", "adventurePlattformBungeecord", "adventureMiniMessage"]
|
||||||
|
|
||||||
|
proxyPlatform = ["velocity", "bungeecord", "floodgate"]
|
||||||
|
serverPlatform = ["paper", "floodgate"]
|
||||||
|
|
||||||
|
[plugins]
|
||||||
|
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
|
||||||
|
shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
10
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
10
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionSha256Sum=a1bb7e9651ef09e4cd9a62d471564e0ee23b5757e5f21fd7358d7cfc21018fdf
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.2-all.zip
|
||||||
|
networkTimeout=60000
|
||||||
|
retries=0
|
||||||
|
retryBackOffMs=500
|
||||||
|
validateDistributionUrl=true
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
248
gradlew
vendored
Normal file
248
gradlew
vendored
Normal file
@ -0,0 +1,248 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015 the original authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# gradlew start up script for POSIX generated by Gradle.
|
||||||
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh gradlew
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD=maximum
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "$( uname )" in #(
|
||||||
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
|
Darwin* ) darwin=true ;; #(
|
||||||
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
|
NONSTOP* ) nonstop=true ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
|
else
|
||||||
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD=java
|
||||||
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
|
case $MAX_FD in #(
|
||||||
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
|
warn "Could not query maximum file descriptor limit"
|
||||||
|
esac
|
||||||
|
case $MAX_FD in #(
|
||||||
|
'' | soft) :;; #(
|
||||||
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
|
# * args from the command line
|
||||||
|
# * the main class name
|
||||||
|
# * -classpath
|
||||||
|
# * -D...appname settings
|
||||||
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
112
gradlew.bat
vendored
Normal file
112
gradlew.bat
vendored
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%"=="" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem gradlew startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables, and ensure extensions are enabled
|
||||||
|
setlocal EnableExtensions
|
||||||
|
|
||||||
|
@rem Catch executions from older scripts and ensure they exit cleanly.
|
||||||
|
@rem This can be removed once we can be reasonably confident that few people
|
||||||
|
@rem will be migrating directly to this new wrapper.
|
||||||
|
goto afterSafetyNet
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
goto exitWithErrorLevel
|
||||||
|
:afterSafetyNet
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
|
1>&2 echo.
|
||||||
|
1>&2 echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
1>&2 echo.
|
||||||
|
1>&2 echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
1>&2 echo location of your Java installation.
|
||||||
|
|
||||||
|
"%COMSPEC%" /c exit 1
|
||||||
|
goto exitWithErrorLevel
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
1>&2 echo.
|
||||||
|
1>&2 echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
1>&2 echo.
|
||||||
|
1>&2 echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
1>&2 echo location of your Java installation.
|
||||||
|
|
||||||
|
"%COMSPEC%" /c exit 1
|
||||||
|
goto exitWithErrorLevel
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute gradlew
|
||||||
|
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
|
||||||
|
@rem which allows us to clear the local environment before executing the java command
|
||||||
|
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel & goto exitWithErrorLevel
|
||||||
|
|
||||||
|
@rem This label must not be changed. We rely on old scripts being able to jump to this point.
|
||||||
|
:exitWithErrorLevel
|
||||||
|
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
|
||||||
|
"%COMSPEC%" /c exit %ERRORLEVEL%
|
||||||
52
settings.gradle.kts
Normal file
52
settings.gradle.kts
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||||
|
|
||||||
|
pluginManagement {
|
||||||
|
includeBuild("build-extensions")
|
||||||
|
repositories {
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
plugins {
|
||||||
|
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.name = "wcloud"
|
||||||
|
|
||||||
|
// top level project
|
||||||
|
include("bom")
|
||||||
|
|
||||||
|
include("wcloud-api")
|
||||||
|
include("wcloud-driver")
|
||||||
|
include("wcloud-launcher")
|
||||||
|
include("wcloud-networking")
|
||||||
|
include("wcloud-plugin")
|
||||||
|
include("wcloud-utils")
|
||||||
|
|
||||||
|
// runnable
|
||||||
|
initializeSubProjects(
|
||||||
|
"wcloud-runnable",
|
||||||
|
"wcloud-master",
|
||||||
|
"wcloud-daemon"
|
||||||
|
)
|
||||||
|
|
||||||
|
// modules
|
||||||
|
initializeSubProjects(
|
||||||
|
"wcloud-modules",
|
||||||
|
"wmodule-cloudflare",
|
||||||
|
"wmodule-discord",
|
||||||
|
"wmodule-hub",
|
||||||
|
"wmodule-notify",
|
||||||
|
"wmodule-npc",
|
||||||
|
"wmodule-permissions",
|
||||||
|
"wmodule-signs",
|
||||||
|
"wmodule-syncproxy",
|
||||||
|
"wmodule-reboot"
|
||||||
|
)
|
||||||
|
|
||||||
|
fun initializeSubProjects(rootProject: String, vararg names: String) {
|
||||||
|
names.forEach {
|
||||||
|
include("$rootProject:$it")
|
||||||
|
project(":$rootProject:$it").name = it
|
||||||
|
project(":$rootProject:$it").projectDir = file(rootProject).resolve(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
23
wcloud-api/build.gradle.kts
Normal file
23
wcloud-api/build.gradle.kts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
plugins {
|
||||||
|
alias(libs.plugins.shadow)
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<Jar> {
|
||||||
|
archiveBaseName.set(Files.api.removeSuffix(".jar"))
|
||||||
|
archiveVersion.set("")
|
||||||
|
if (name == "jar") archiveClassifier.set("plain")
|
||||||
|
if (name == "shadowJar") archiveClassifier.set("")
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
api(libs.bundles.adventure)
|
||||||
|
api(libs.bundles.proxyPlatform)
|
||||||
|
api(libs.bundles.serverPlatform)
|
||||||
|
|
||||||
|
implementation(projects.wcloudDriver)
|
||||||
|
implementation(projects.wcloudNetworking)
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named("shadowJar") {
|
||||||
|
dependsOn(":wcloud-driver:shadowJar")
|
||||||
|
}
|
||||||
229
wcloud-api/src/main/java/de/wcloudservice/api/CloudAPI.java
Normal file
229
wcloud-api/src/main/java/de/wcloudservice/api/CloudAPI.java
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
package de.wcloudservice.api;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.Message;
|
||||||
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
import de.wcloudservice.api.bootstrap.velocity.VelocityBootstrap;
|
||||||
|
import de.wcloudservice.api.bootstrap.velocity.listeners.CloudEvents;
|
||||||
|
import de.wcloudservice.api.bootstrap.velocity.networking.*;
|
||||||
|
import de.wcloudservice.api.networking.*;
|
||||||
|
import de.wcloudservice.api.pool.groups.GroupPool;
|
||||||
|
import de.wcloudservice.api.pool.messages.MessagePool;
|
||||||
|
import de.wcloudservice.api.pool.offlineplayer.OfflinePlayerPool;
|
||||||
|
import de.wcloudservice.api.pool.players.PlayerPool;
|
||||||
|
import de.wcloudservice.api.pool.services.ServicePool;
|
||||||
|
import de.wcloudservice.api.pool.services.entry.CloudService;
|
||||||
|
import de.wcloudservice.driver.Driver;
|
||||||
|
import de.wcloudservice.driver.configuration.service.ServiceConfig;
|
||||||
|
import de.wcloudservice.driver.event.interfaces.CloudListener;
|
||||||
|
import de.wcloudservice.driver.network.in.main.PacketInMainExecuteCommand;
|
||||||
|
import de.wcloudservice.driver.network.in.main.PacketInMainGroups;
|
||||||
|
import de.wcloudservice.driver.network.in.main.PacketInMainMessages;
|
||||||
|
import de.wcloudservice.driver.network.in.main.PacketInMainWhitelist;
|
||||||
|
import de.wcloudservice.driver.network.in.service.PacketInServiceChangeState;
|
||||||
|
import de.wcloudservice.driver.network.in.service.PacketInServiceConnect;
|
||||||
|
import de.wcloudservice.driver.network.in.service.PacketInServiceReaction;
|
||||||
|
import de.wcloudservice.driver.network.out.group.PacketOutGroupCreate;
|
||||||
|
import de.wcloudservice.driver.network.out.group.PacketOutGroupDelete;
|
||||||
|
import de.wcloudservice.driver.network.out.group.PacketOutGroupUpdate;
|
||||||
|
import de.wcloudservice.driver.network.out.main.PacketOutMainGroups;
|
||||||
|
import de.wcloudservice.driver.network.out.main.PacketOutMainMessages;
|
||||||
|
import de.wcloudservice.driver.network.out.main.PacketOutMainWhitelist;
|
||||||
|
import de.wcloudservice.driver.network.out.player.*;
|
||||||
|
import de.wcloudservice.driver.network.out.player.based.*;
|
||||||
|
import de.wcloudservice.driver.network.out.service.*;
|
||||||
|
import de.wcloudservice.driver.process.ServiceState;
|
||||||
|
import de.wcloudservice.driver.scheduler.CloudScheduler;
|
||||||
|
import de.wcloudservice.driver.scheduler.SchedulerUtil;
|
||||||
|
import de.wcloudservice.networking.NettyDriver;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
public class CloudAPI {
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private static CloudAPI instance;
|
||||||
|
|
||||||
|
private final GroupPool groupPool = new GroupPool();
|
||||||
|
private final PlayerPool playerPool = new PlayerPool();
|
||||||
|
private final OfflinePlayerPool offlinePlayerPool = new OfflinePlayerPool();
|
||||||
|
private final ServicePool servicePool = new ServicePool();
|
||||||
|
private final MessagePool messagePool = new MessagePool();
|
||||||
|
private List<String> whitelist = new ArrayList<>();
|
||||||
|
private ServiceConfig service;
|
||||||
|
|
||||||
|
public CloudAPI(boolean isVelocity) {
|
||||||
|
instance = this;
|
||||||
|
instance.initialize(isVelocity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initialize(boolean isVelocity) {
|
||||||
|
new Driver();
|
||||||
|
new NettyDriver();
|
||||||
|
|
||||||
|
this.service = Driver.instance().configDriver().read("./", ServiceConfig.class);
|
||||||
|
|
||||||
|
NettyDriver.instance().runNettyClient(this.service.masterAddress(), this.service.networkPort());
|
||||||
|
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutServiceCouldNotStart().packetUid(), PacketOutServiceCouldNotStart.class, new HandlePacketOutServiceCouldNotStart());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutServicePrepared().packetUid(), PacketOutServicePrepared.class, new HandlePacketOutServicePrepared());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutServiceLaunch().packetUid(), PacketOutServiceLaunch.class, new HandlePacketOutServiceLaunch());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutServiceConnected().packetUid(), PacketOutServiceConnected.class, new HandlePacketOutServiceConnected());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutServiceDisconnected().packetUid(), PacketOutServiceDisconnected.class, new HandlePacketOutServiceDisconnected());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutServiceChangeState().packetUid(), PacketOutServiceChangeState.class, new HandlePacketOutServiceChangeState());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutPlayerCache().packetUid(), PacketOutPlayerCache.class, new HandlePacketOutPlayerCache());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutPlayerConnect().packetUid(), PacketOutPlayerConnect.class, new HandlePacketOutPlayerConnect());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutPlayerDisconnect().packetUid(), PacketOutPlayerDisconnect.class, new HandlePacketOutPlayerDisconnect());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutPlayerSwitchService().packetUid(), PacketOutPlayerSwitchService.class, new HandlePacketOutPlayerSwitchService());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutGroupCreate().packetUid(), PacketOutGroupCreate.class, new HandlePacketOutGroupCreate());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutGroupDelete().packetUid(), PacketOutGroupDelete.class, new HandlePacketOutGroupDelete());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutGroupUpdate().packetUid(), PacketOutGroupUpdate.class, new HandlePacketOutGroupUpdate());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutMainGroups().packetUid(), PacketOutMainGroups.class, new HandlePacketOutMainGroups());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutMainMessages().packetUid(), PacketOutMainMessages.class, new HandlePacketOutMainMessages());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutMainWhitelist().packetUid(), PacketOutMainWhitelist.class, new HandlePacketOutMainWhitelist());
|
||||||
|
|
||||||
|
if(this.service.type().equals("PROXY")) {
|
||||||
|
if(isVelocity) {
|
||||||
|
Driver.instance().eventDriver().registerListener(new CloudEvents());
|
||||||
|
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutPlayerBasedConnect().packetUid(), PacketOutPlayerBasedConnect.class, new HandlePacketOutPlayerBasedConnect());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutPlayerBasedMessage().packetUid(), PacketOutPlayerBasedMessage.class, new HandlePacketOutPlayerBasedMessage());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutPlayerBasedTitle().packetUid(), PacketOutPlayerBasedTitle.class, new HandlePacketOutPlayerBasedTitle());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutPlayerBasedActionbar().packetUid(), PacketOutPlayerBasedActionbar.class, new HandlePacketOutPlayerBasedActionbar());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutPlayerBasedExecuteCommand().packetUid(), PacketOutPlayerBasedExecuteCommand.class, new HandlePacketOutPlayerBasedExecuteCommand());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutPlayerBasedKick().packetUid(), PacketOutPlayerBasedKick.class, new HandlePacketOutPlayerBasedKick());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutPlayerBasedTablist().packetUid(), PacketOutPlayerBasedTablist.class, new HandlePacketOutPlayerBasedTablist());
|
||||||
|
} else {
|
||||||
|
Driver.instance().eventDriver().registerListener(new de.wcloudservice.api.bootstrap.bungeecord.listeners.CloudEvents());
|
||||||
|
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutPlayerBasedConnect().packetUid(), PacketOutPlayerBasedConnect.class, new de.wcloudservice.api.bootstrap.bungeecord.networking.HandlePacketOutPlayerBasedConnect());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutPlayerBasedMessage().packetUid(), PacketOutPlayerBasedMessage.class, new de.wcloudservice.api.bootstrap.bungeecord.networking.HandlePacketOutPlayerBasedMessage());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutPlayerBasedTitle().packetUid(), PacketOutPlayerBasedTitle.class, new de.wcloudservice.api.bootstrap.bungeecord.networking.HandlePacketOutPlayerBasedTitle());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutPlayerBasedActionbar().packetUid(), PacketOutPlayerBasedActionbar.class, new de.wcloudservice.api.bootstrap.bungeecord.networking.HandlePacketOutPlayerBasedActionbar());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutPlayerBasedExecuteCommand().packetUid(), PacketOutPlayerBasedExecuteCommand.class, new de.wcloudservice.api.bootstrap.bungeecord.networking.HandlePacketOutPlayerBasedExecuteCommand());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutPlayerBasedKick().packetUid(), PacketOutPlayerBasedKick.class, new de.wcloudservice.api.bootstrap.bungeecord.networking.HandlePacketOutPlayerBasedKick());
|
||||||
|
NettyDriver.instance().packetDriver().listen(new PacketOutPlayerBasedTablist().packetUid(), PacketOutPlayerBasedTablist.class, new de.wcloudservice.api.bootstrap.bungeecord.networking.HandlePacketOutPlayerBasedTablist());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NettyDriver.instance().client().sendPacket(new PacketInMainGroups());
|
||||||
|
NettyDriver.instance().client().sendPacket(new PacketInMainMessages());
|
||||||
|
NettyDriver.instance().client().sendPacket(new PacketInMainWhitelist());
|
||||||
|
NettyDriver.instance().client().sendPacket(new PacketInServiceConnect(this.service.service()));
|
||||||
|
|
||||||
|
new CloudScheduler().schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!NettyDriver.instance().client().channel().isOpen()) {
|
||||||
|
System.exit(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NettyDriver.instance().client().sendPacket(new PacketInServiceReaction(service.service()));
|
||||||
|
}
|
||||||
|
}, 5, 30, SchedulerUtil.SECONDS);
|
||||||
|
|
||||||
|
new CloudScheduler().schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!NettyDriver.instance().client().channel().isOpen()) {
|
||||||
|
System.exit(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
state(ServiceState.LOBBY, service.service());
|
||||||
|
}
|
||||||
|
}, 10, SchedulerUtil.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void executeCommand(String command) {
|
||||||
|
NettyDriver.instance().client().sendPacket(new PacketInMainExecuteCommand(command));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerListener(CloudListener cloudListener) {
|
||||||
|
Driver.instance().eventDriver().registerListener(cloudListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void state(ServiceState state) {
|
||||||
|
this.state(state, this.service.service());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void state(ServiceState state, String service) {
|
||||||
|
NettyDriver.instance().client().sendPacket(new PacketInServiceChangeState(service, state));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendPacket(Packet packet) {
|
||||||
|
NettyDriver.instance().client().sendPacket(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendAsyncPacket(Packet packet) {
|
||||||
|
NettyDriver.instance().client().sendAsyncPacket(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CloudService findLobby(Player player, String excludedServer) {
|
||||||
|
List<CloudService> cloudServices = CloudAPI.instance().servicePool().connectedServices().stream()
|
||||||
|
.filter(service -> service.group().type().equals("LOBBY"))
|
||||||
|
.filter(service -> !service.group().maintenance())
|
||||||
|
.filter(service -> !service.name().equals(excludedServer))
|
||||||
|
.filter(service -> service.state() == ServiceState.LOBBY)
|
||||||
|
.filter(service -> service.group().permission().isEmpty() || player.hasPermission(service.group().permission()))
|
||||||
|
.sorted(Comparator.comparingInt(service -> service.group().priority()))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
if (cloudServices.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
int highestPriority = cloudServices.getLast().group().priority();
|
||||||
|
List<CloudService> highestPriorityLobbies = cloudServices.stream()
|
||||||
|
.filter(service -> service.group().priority() == highestPriority)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
return highestPriorityLobbies.get(new Random().nextInt(highestPriorityLobbies.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public CloudService getLobby(Player player) {
|
||||||
|
return this.getLobby(player, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CloudService getLobby(Player player, String kicked) {
|
||||||
|
return this.findLobby(player, kicked);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CloudService findLobby(ProxiedPlayer player, String excludedServer) {
|
||||||
|
List<CloudService> cloudServices = CloudAPI.instance().servicePool().connectedServices().stream()
|
||||||
|
.filter(service -> service.group().type().equals("LOBBY"))
|
||||||
|
.filter(service -> !service.group().maintenance())
|
||||||
|
.filter(service -> !service.name().equals(excludedServer))
|
||||||
|
.filter(service -> service.state() == ServiceState.LOBBY)
|
||||||
|
.filter(service -> service.group().permission().isEmpty() || player.hasPermission(service.group().permission()))
|
||||||
|
.sorted(Comparator.comparingInt(service -> service.group().priority()))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
if (cloudServices.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
int highestPriority = cloudServices.getLast().group().priority();
|
||||||
|
List<CloudService> highestPriorityLobbies = cloudServices.stream()
|
||||||
|
.filter(service -> service.group().priority() == highestPriority)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
return highestPriorityLobbies.get(new Random().nextInt(highestPriorityLobbies.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public CloudService getLobby(ProxiedPlayer player) {
|
||||||
|
return this.getLobby(player, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CloudService getLobby(ProxiedPlayer player, String kicked) {
|
||||||
|
return this.findLobby(player, kicked);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,55 @@
|
|||||||
|
package de.wcloudservice.api.bedrock;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.geysermc.floodgate.api.FloodgateApi;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class PlayerResolverBukkit {
|
||||||
|
|
||||||
|
private boolean floodgateAvailable = false;
|
||||||
|
private FloodgateApi floodgateApi = null;
|
||||||
|
|
||||||
|
public PlayerResolverBukkit() {
|
||||||
|
if (Bukkit.getPluginManager().getPlugin("floodgate") != null) {
|
||||||
|
try {
|
||||||
|
this.floodgateApi = FloodgateApi.getInstance();
|
||||||
|
this.floodgateAvailable = (this.floodgateApi != null);
|
||||||
|
} catch (NoClassDefFoundError | Exception e) {
|
||||||
|
this. floodgateAvailable = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt die Floodgate-kompatible UUID eines Spielers zurück.
|
||||||
|
* Falls Java-Spieler → normale UUID.
|
||||||
|
*/
|
||||||
|
public UUID getEffectiveUuid(Player player) {
|
||||||
|
if (this.floodgateAvailable && this.floodgateApi.isFloodgatePlayer(player.getUniqueId())) {
|
||||||
|
return this.floodgateApi.getPlayer(player.getUniqueId()).getCorrectUniqueId();
|
||||||
|
}
|
||||||
|
return player.getUniqueId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holt einen Spieler anhand der UUID, wenn er online ist.
|
||||||
|
*/
|
||||||
|
public Optional<Player> resolve(UUID uuid) {
|
||||||
|
return Optional.ofNullable(Bukkit.getPlayer(uuid));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holt Spieler anhand UUID oder Name (Fallback), wenn online.
|
||||||
|
*/
|
||||||
|
public Optional<Player> resolve(UUID uuid, String name) {
|
||||||
|
Player player = Bukkit.getPlayer(uuid);
|
||||||
|
if (player == null) {
|
||||||
|
player = Bukkit.getPlayer(name);
|
||||||
|
}
|
||||||
|
return Optional.ofNullable(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
package de.wcloudservice.api.bedrock;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import org.geysermc.floodgate.api.FloodgateApi;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class PlayerResolverBungeeCord {
|
||||||
|
|
||||||
|
private final ProxyServer proxy;
|
||||||
|
private boolean floodgateAvailable = false;
|
||||||
|
private FloodgateApi floodgateApi = null;
|
||||||
|
|
||||||
|
public PlayerResolverBungeeCord(ProxyServer proxy) {
|
||||||
|
this.proxy = proxy;
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.floodgateApi = FloodgateApi.getInstance();
|
||||||
|
this.floodgateAvailable = (this.floodgateApi != null);
|
||||||
|
} catch (NoClassDefFoundError | Exception e) {
|
||||||
|
this.floodgateAvailable = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt die Floodgate-kompatible UUID eines Spielers zurück.
|
||||||
|
* Falls Java-Spieler → normale UUID.
|
||||||
|
*/
|
||||||
|
public UUID getEffectiveUuid(ProxiedPlayer player) {
|
||||||
|
if (this.floodgateAvailable && this.floodgateApi.isFloodgatePlayer(player.getUniqueId())) {
|
||||||
|
return this.floodgateApi.getPlayer(player.getUniqueId()).getCorrectUniqueId();
|
||||||
|
}
|
||||||
|
return player.getUniqueId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holt einen Online-Spieler anhand seiner UUID (egal ob Java oder Bedrock).
|
||||||
|
*/
|
||||||
|
public Optional<ProxiedPlayer> resolve(UUID uuid) {
|
||||||
|
return Optional.ofNullable(proxy.getPlayer(uuid));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holt einen Online-Spieler anhand UUID oder Name (Fallback).
|
||||||
|
*/
|
||||||
|
public Optional<ProxiedPlayer> resolve(UUID uuid, String name) {
|
||||||
|
ProxiedPlayer player = proxy.getPlayer(uuid);
|
||||||
|
if (player == null) {
|
||||||
|
return Optional.ofNullable(proxy.getPlayer(name));
|
||||||
|
}
|
||||||
|
return Optional.of(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
package de.wcloudservice.api.bedrock;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.plugin.PluginContainer;
|
||||||
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
import org.geysermc.floodgate.api.FloodgateApi;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class PlayerResolverVelocity {
|
||||||
|
|
||||||
|
private final ProxyServer proxy;
|
||||||
|
private boolean floodgateAvailable = false;
|
||||||
|
private FloodgateApi floodgateApi = null;
|
||||||
|
|
||||||
|
public PlayerResolverVelocity(ProxyServer proxy) {
|
||||||
|
this.proxy = proxy;
|
||||||
|
|
||||||
|
Optional<PluginContainer> floodgatePlugin = proxy.getPluginManager().getPlugin("floodgate");
|
||||||
|
if (floodgatePlugin.isPresent()) {
|
||||||
|
try {
|
||||||
|
this.floodgateApi = FloodgateApi.getInstance();
|
||||||
|
this.floodgateAvailable = (this.floodgateApi != null);
|
||||||
|
} catch (NoClassDefFoundError | Exception e) {
|
||||||
|
this.floodgateAvailable = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt die Floodgate-kompatible UUID eines Spielers zurück.
|
||||||
|
* Falls Java-Spieler → normale UUID.
|
||||||
|
*/
|
||||||
|
public UUID getEffectiveUuid(Player player) {
|
||||||
|
if (this.floodgateAvailable && this.floodgateApi.isFloodgatePlayer(player.getUniqueId())) {
|
||||||
|
return this.floodgateApi.getPlayer(player.getUniqueId()).getCorrectUniqueId();
|
||||||
|
}
|
||||||
|
return player.getUniqueId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holt einen Online-Spieler anhand seiner UUID (egal ob Java oder Bedrock).
|
||||||
|
*/
|
||||||
|
public Optional<Player> resolve(UUID uuid) {
|
||||||
|
return proxy.getPlayer(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holt einen Online-Spieler anhand UUID oder Name (Fallback).
|
||||||
|
*/
|
||||||
|
public Optional<Player> resolve(UUID uuid, String name) {
|
||||||
|
Optional<Player> player = proxy.getPlayer(uuid);
|
||||||
|
if (player.isEmpty()) {
|
||||||
|
return proxy.getPlayer(name);
|
||||||
|
}
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package de.wcloudservice.api.bootstrap.bukkit;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.driver.minimessage.CloudMessage;
|
||||||
|
import de.wcloudservice.driver.network.in.service.PacketInServiceDisconnect;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public class BukkitBootstrap extends JavaPlugin {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad() {
|
||||||
|
new CloudAPI(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "save-all");
|
||||||
|
Bukkit.getOnlinePlayers().forEach(player -> player.kick(CloudMessage.colorizeComponent("cloudservice-shutdown")));
|
||||||
|
CloudAPI.instance().sendPacket(new PacketInServiceDisconnect(CloudAPI.instance().service().service()));
|
||||||
|
Bukkit.getScheduler().runTaskLater(this, Bukkit::shutdown, 60L);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
package de.wcloudservice.api.bootstrap.bungeecord;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.driver.minimessage.CloudMessage;
|
||||||
|
import de.wcloudservice.driver.network.in.service.PacketInServiceDisconnect;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
|
||||||
|
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
public class BungeeCordBootstrap extends Plugin {
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private static BungeeCordBootstrap instance;
|
||||||
|
|
||||||
|
private BungeeAudiences adventure;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
instance = this;
|
||||||
|
|
||||||
|
this.adventure = BungeeAudiences.create(this);
|
||||||
|
|
||||||
|
new CloudAPI(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
for (ProxiedPlayer player : getProxy().getPlayers()) {
|
||||||
|
player.disconnect(BungeeComponentSerializer.legacy().serialize(CloudMessage.colorizeComponent("cloudservice-shutdown")));
|
||||||
|
}
|
||||||
|
|
||||||
|
CloudAPI.instance().sendPacket(new PacketInServiceDisconnect(CloudAPI.instance().service().service()));
|
||||||
|
|
||||||
|
if (this.adventure != null) {
|
||||||
|
this.adventure.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
package de.wcloudservice.api.bootstrap.bungeecord.listeners;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.api.bootstrap.bungeecord.BungeeCordBootstrap;
|
||||||
|
import de.wcloudservice.api.bootstrap.bungeecord.utils.ServerConfig;
|
||||||
|
import de.wcloudservice.driver.event.annotations.Priority;
|
||||||
|
import de.wcloudservice.driver.event.annotations.Subscribe;
|
||||||
|
import de.wcloudservice.driver.event.events.service.CloudServiceConnectedEvent;
|
||||||
|
import de.wcloudservice.driver.event.events.service.CloudServiceDisconnectedEvent;
|
||||||
|
import de.wcloudservice.driver.event.interfaces.CloudListener;
|
||||||
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
|
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class CloudEvents implements CloudListener {
|
||||||
|
|
||||||
|
@Subscribe(priority = Priority.HIGHEST)
|
||||||
|
public void handle(CloudServiceConnectedEvent event) {
|
||||||
|
String serviceName = event.service().serviceName();
|
||||||
|
|
||||||
|
InetSocketAddress address = new InetSocketAddress(
|
||||||
|
CloudAPI.instance().service().masterAddress(),
|
||||||
|
event.service().usedPort()
|
||||||
|
);
|
||||||
|
|
||||||
|
ServerInfo serverInfo = BungeeCordBootstrap.instance().getProxy().constructServerInfo(serviceName, address, "", false);
|
||||||
|
BungeeCordBootstrap.instance().getProxy().getServers().put(serviceName, serverInfo);
|
||||||
|
ServerConfig.addToConfig(serverInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void handle(CloudServiceDisconnectedEvent event) {
|
||||||
|
String serviceName = event.service().serviceName();
|
||||||
|
Map<String, ServerInfo> servers = BungeeCordBootstrap.instance().getProxy().getServers();
|
||||||
|
|
||||||
|
if (!servers.containsKey(serviceName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
servers.remove(serviceName);
|
||||||
|
ServerConfig.removeFromConfig(serviceName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
package de.wcloudservice.api.bootstrap.bungeecord.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.bootstrap.bungeecord.BungeeCordBootstrap;
|
||||||
|
import de.wcloudservice.api.bootstrap.velocity.VelocityBootstrap;
|
||||||
|
import de.wcloudservice.driver.minimessage.CloudMessage;
|
||||||
|
import de.wcloudservice.driver.network.out.player.based.PacketOutPlayerBasedActionbar;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
import net.kyori.adventure.audience.Audience;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
public class HandlePacketOutPlayerBasedActionbar implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutPlayerBasedActionbar packet) {
|
||||||
|
ProxiedPlayer player = BungeeCordBootstrap.instance().getProxy().getPlayer(packet.uniqueId());
|
||||||
|
if (player == null) return;
|
||||||
|
|
||||||
|
Audience audience = BungeeCordBootstrap.instance().adventure().player(player);
|
||||||
|
audience.sendActionBar(CloudMessage.colorizeComponent(packet.message()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
package de.wcloudservice.api.bootstrap.bungeecord.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.bootstrap.bungeecord.BungeeCordBootstrap;
|
||||||
|
import de.wcloudservice.driver.network.out.player.based.PacketOutPlayerBasedConnect;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
public class HandlePacketOutPlayerBasedConnect implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutPlayerBasedConnect packet) {
|
||||||
|
ProxiedPlayer player = BungeeCordBootstrap.instance().getProxy().getPlayer(packet.name());
|
||||||
|
if (player == null) return;
|
||||||
|
|
||||||
|
ServerInfo targetServer = BungeeCordBootstrap.instance().getProxy().getServerInfo(packet.service());
|
||||||
|
if (targetServer == null) return;
|
||||||
|
|
||||||
|
player.connect(targetServer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package de.wcloudservice.api.bootstrap.bungeecord.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.bootstrap.bungeecord.BungeeCordBootstrap;
|
||||||
|
import de.wcloudservice.driver.network.out.player.based.PacketOutPlayerBasedExecuteCommand;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
public class HandlePacketOutPlayerBasedExecuteCommand implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutPlayerBasedExecuteCommand packet) {
|
||||||
|
ProxiedPlayer player = BungeeCordBootstrap.instance().getProxy().getPlayer(packet.name());
|
||||||
|
if (player == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BungeeCordBootstrap.instance().getProxy().getPluginManager().dispatchCommand(player, packet.command());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package de.wcloudservice.api.bootstrap.bungeecord.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.bootstrap.bungeecord.BungeeCordBootstrap;
|
||||||
|
import de.wcloudservice.driver.minimessage.CloudMessage;
|
||||||
|
import de.wcloudservice.driver.network.out.player.based.PacketOutPlayerBasedKick;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
public class HandlePacketOutPlayerBasedKick implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutPlayerBasedKick packet) {
|
||||||
|
ProxiedPlayer player = BungeeCordBootstrap.instance().getProxy().getPlayer(packet.uniqueId());
|
||||||
|
if (player == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Component message = CloudMessage.colorizeComponent(packet.message());
|
||||||
|
player.disconnect(BungeeComponentSerializer.legacy().serialize(message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package de.wcloudservice.api.bootstrap.bungeecord.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.bootstrap.bungeecord.BungeeCordBootstrap;
|
||||||
|
import de.wcloudservice.driver.minimessage.CloudMessage;
|
||||||
|
import de.wcloudservice.driver.network.out.player.based.PacketOutPlayerBasedMessage;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
import net.kyori.adventure.audience.Audience;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
public class HandlePacketOutPlayerBasedMessage implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutPlayerBasedMessage packet) {
|
||||||
|
ProxiedPlayer player = BungeeCordBootstrap.instance().getProxy().getPlayer(packet.uniqueId());
|
||||||
|
if (player == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Component message = CloudMessage.colorizeComponent(packet.message());
|
||||||
|
Audience audience = BungeeCordBootstrap.instance().adventure().player(player);
|
||||||
|
audience.sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
package de.wcloudservice.api.bootstrap.bungeecord.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.bootstrap.bungeecord.BungeeCordBootstrap;
|
||||||
|
import de.wcloudservice.driver.minimessage.CloudMessage;
|
||||||
|
import de.wcloudservice.driver.network.out.player.based.PacketOutPlayerBasedTablist;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
import net.kyori.adventure.audience.Audience;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
public class HandlePacketOutPlayerBasedTablist implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutPlayerBasedTablist packet) {
|
||||||
|
ProxiedPlayer player = BungeeCordBootstrap.instance().getProxy().getPlayer(packet.uniqueId());
|
||||||
|
if (player == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Audience audience = BungeeCordBootstrap.instance().adventure().player(player);
|
||||||
|
Component header = CloudMessage.colorizeComponent(packet.header());
|
||||||
|
Component footer = CloudMessage.colorizeComponent(packet.footer());
|
||||||
|
|
||||||
|
audience.sendPlayerListHeaderAndFooter(header, footer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
package de.wcloudservice.api.bootstrap.bungeecord.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.bootstrap.bungeecord.BungeeCordBootstrap;
|
||||||
|
import de.wcloudservice.driver.minimessage.CloudMessage;
|
||||||
|
import de.wcloudservice.driver.network.out.player.based.PacketOutPlayerBasedTitle;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
import net.kyori.adventure.title.Title;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
|
public class HandlePacketOutPlayerBasedTitle implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutPlayerBasedTitle packet) {
|
||||||
|
ProxiedPlayer player = BungeeCordBootstrap.instance().getProxy().getPlayer(packet.uniqueId());
|
||||||
|
if (player == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Title title = Title.title(
|
||||||
|
CloudMessage.colorizeComponent(packet.title()),
|
||||||
|
CloudMessage.colorizeComponent(packet.subtitle()),
|
||||||
|
Title.Times.times(
|
||||||
|
Duration.ofSeconds(packet.fadeIn()),
|
||||||
|
Duration.ofSeconds(packet.stay()),
|
||||||
|
Duration.ofSeconds(packet.fadeOut())
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
BungeeCordBootstrap.instance().adventure().player(player).showTitle(title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,85 @@
|
|||||||
|
package de.wcloudservice.api.bootstrap.bungeecord.utils;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.bootstrap.bungeecord.BungeeCordBootstrap;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
|
import net.md_5.bungee.config.Configuration;
|
||||||
|
import net.md_5.bungee.config.YamlConfiguration;
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
|
||||||
|
public class ServerConfig {
|
||||||
|
|
||||||
|
private static File file;
|
||||||
|
private static Configuration bungeeConfig;
|
||||||
|
private static boolean locked;
|
||||||
|
|
||||||
|
static {
|
||||||
|
setupConfig();
|
||||||
|
if (locked) {
|
||||||
|
ProxyServer.getInstance().getScheduler().schedule(BungeeCordBootstrap.instance(), ServerConfig::setupConfig, 5L, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addToConfig(ServerInfo serverInfo) {
|
||||||
|
if (locked) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bungeeConfig.set("servers." + serverInfo.getName() + ".motd", serverInfo.getMotd().replace(ChatColor.COLOR_CHAR, '&'));
|
||||||
|
bungeeConfig.set("servers." + serverInfo.getName() + ".address", serverInfo.getSocketAddress().toString());
|
||||||
|
bungeeConfig.set("servers." + serverInfo.getName() + ".restricted", false);
|
||||||
|
saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeFromConfig(String name) {
|
||||||
|
if (locked) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bungeeConfig.set("servers." + name, null);
|
||||||
|
saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void saveConfig() {
|
||||||
|
if (locked) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
YamlConfiguration.getProvider(YamlConfiguration.class).save(bungeeConfig, file);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setupConfig() {
|
||||||
|
FileInputStream fis = null;
|
||||||
|
InputStreamReader isr = null;
|
||||||
|
try {
|
||||||
|
file = new File(ProxyServer.getInstance().getPluginsFolder().getParentFile(), "config.yml");
|
||||||
|
|
||||||
|
fis = new FileInputStream(file);
|
||||||
|
isr = new InputStreamReader(fis, StandardCharsets.ISO_8859_1);
|
||||||
|
|
||||||
|
bungeeConfig = YamlConfiguration.getProvider(YamlConfiguration.class).load(isr);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (fis != null) {
|
||||||
|
fis.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isr != null) {
|
||||||
|
isr.close();
|
||||||
|
}
|
||||||
|
} catch (IOException ignored) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
locked = bungeeConfig == null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
package de.wcloudservice.api.bootstrap.velocity;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
|
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||||
|
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
|
||||||
|
import com.velocitypowered.api.plugin.Plugin;
|
||||||
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.driver.minimessage.CloudMessage;
|
||||||
|
import de.wcloudservice.driver.network.in.service.PacketInServiceDisconnect;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@Plugin(id = "wcloudapi", name = "wcloud-api", version = "1.0.0-SNAPSHOT", authors = "Weapie")
|
||||||
|
public class VelocityBootstrap {
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private static VelocityBootstrap instance;
|
||||||
|
|
||||||
|
private ProxyServer proxyServer;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public VelocityBootstrap(ProxyServer proxyServer, Logger logger) {
|
||||||
|
instance = this;
|
||||||
|
this.proxyServer = proxyServer;
|
||||||
|
new CloudAPI(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onProxyInject(ProxyInitializeEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onDisable(ProxyShutdownEvent event) {
|
||||||
|
this.proxyServer.getAllPlayers().forEach(player -> player.disconnect(CloudMessage.colorizeComponent("cloudservice-shutdown")));
|
||||||
|
CloudAPI.instance().sendPacket(new PacketInServiceDisconnect(CloudAPI.instance().service().service()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
package de.wcloudservice.api.bootstrap.velocity.listeners;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.proxy.server.ServerInfo;
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.api.bootstrap.velocity.VelocityBootstrap;
|
||||||
|
import de.wcloudservice.driver.event.annotations.Priority;
|
||||||
|
import de.wcloudservice.driver.event.annotations.Subscribe;
|
||||||
|
import de.wcloudservice.driver.event.events.service.CloudServiceConnectedEvent;
|
||||||
|
import de.wcloudservice.driver.event.events.service.CloudServiceDisconnectedEvent;
|
||||||
|
import de.wcloudservice.driver.event.interfaces.CloudListener;
|
||||||
|
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class CloudEvents implements CloudListener {
|
||||||
|
|
||||||
|
@Subscribe(priority = Priority.HIGHEST)
|
||||||
|
public void handle(CloudServiceConnectedEvent event) {
|
||||||
|
VelocityBootstrap.instance().proxyServer().registerServer(
|
||||||
|
new ServerInfo(
|
||||||
|
event.service().serviceName(),
|
||||||
|
new InetSocketAddress(
|
||||||
|
CloudAPI.instance().service().masterAddress(),
|
||||||
|
event.service().usedPort()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void handle(CloudServiceDisconnectedEvent event) {
|
||||||
|
if (VelocityBootstrap.instance().proxyServer().getServer(event.service().serviceName()).isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VelocityBootstrap.instance().proxyServer().unregisterServer(VelocityBootstrap.instance().proxyServer().getServer(event.service().serviceName()).get().getServerInfo());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package de.wcloudservice.api.bootstrap.velocity.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.bootstrap.velocity.VelocityBootstrap;
|
||||||
|
import de.wcloudservice.driver.minimessage.CloudMessage;
|
||||||
|
import de.wcloudservice.driver.network.out.player.based.PacketOutPlayerBasedActionbar;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
public class HandlePacketOutPlayerBasedActionbar implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutPlayerBasedActionbar packet) {
|
||||||
|
if(!VelocityBootstrap.instance().proxyServer().getPlayer(packet.uniqueId()).isPresent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VelocityBootstrap.instance().proxyServer().getPlayer(packet.uniqueId()).get().sendActionBar(CloudMessage.colorizeComponent(packet.message()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package de.wcloudservice.api.bootstrap.velocity.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.bootstrap.velocity.VelocityBootstrap;
|
||||||
|
import de.wcloudservice.driver.network.out.player.based.PacketOutPlayerBasedConnect;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
public class HandlePacketOutPlayerBasedConnect implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutPlayerBasedConnect packet) {
|
||||||
|
if(VelocityBootstrap.instance().proxyServer().getPlayer(packet.name()).isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VelocityBootstrap.instance().proxyServer().getPlayer(packet.name()).get().createConnectionRequest(
|
||||||
|
VelocityBootstrap.instance().proxyServer().getServer(packet.service()).get()
|
||||||
|
).connect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
package de.wcloudservice.api.bootstrap.velocity.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.bootstrap.velocity.VelocityBootstrap;
|
||||||
|
import de.wcloudservice.driver.network.out.player.based.PacketOutPlayerBasedExecuteCommand;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
public class HandlePacketOutPlayerBasedExecuteCommand implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutPlayerBasedExecuteCommand packet) {
|
||||||
|
if(!VelocityBootstrap.instance().proxyServer().getPlayer(packet.name()).isPresent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VelocityBootstrap.instance().proxyServer().getCommandManager().executeAsync(
|
||||||
|
VelocityBootstrap.instance().proxyServer().getPlayer(packet.name()).get(),
|
||||||
|
packet.command()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package de.wcloudservice.api.bootstrap.velocity.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.bootstrap.velocity.VelocityBootstrap;
|
||||||
|
import de.wcloudservice.driver.minimessage.CloudMessage;
|
||||||
|
import de.wcloudservice.driver.network.out.player.based.PacketOutPlayerBasedKick;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
public class HandlePacketOutPlayerBasedKick implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutPlayerBasedKick packet) {
|
||||||
|
if(!VelocityBootstrap.instance().proxyServer().getPlayer(packet.uniqueId()).isPresent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VelocityBootstrap.instance().proxyServer().getPlayer(packet.uniqueId()).get().disconnect(CloudMessage.colorizeComponent(packet.message()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package de.wcloudservice.api.bootstrap.velocity.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.bootstrap.velocity.VelocityBootstrap;
|
||||||
|
import de.wcloudservice.driver.minimessage.CloudMessage;
|
||||||
|
import de.wcloudservice.driver.network.out.player.based.PacketOutPlayerBasedMessage;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
public class HandlePacketOutPlayerBasedMessage implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutPlayerBasedMessage packet) {
|
||||||
|
if(VelocityBootstrap.instance().proxyServer().getPlayer(packet.uniqueId()).isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VelocityBootstrap.instance().proxyServer().getPlayer(packet.uniqueId()).get().sendMessage(CloudMessage.colorizeComponent(packet.message()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
package de.wcloudservice.api.bootstrap.velocity.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.bootstrap.velocity.VelocityBootstrap;
|
||||||
|
import de.wcloudservice.driver.minimessage.CloudMessage;
|
||||||
|
import de.wcloudservice.driver.network.out.player.based.PacketOutPlayerBasedTablist;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
public class HandlePacketOutPlayerBasedTablist implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutPlayerBasedTablist packet) {
|
||||||
|
if(!VelocityBootstrap.instance().proxyServer().getPlayer(packet.uniqueId()).isPresent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VelocityBootstrap.instance().proxyServer().getPlayer(packet.uniqueId()).get().getTabList().setHeaderAndFooter(
|
||||||
|
CloudMessage.colorizeComponent(packet.header()),
|
||||||
|
CloudMessage.colorizeComponent(packet.footer())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
package de.wcloudservice.api.bootstrap.velocity.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.bootstrap.velocity.VelocityBootstrap;
|
||||||
|
import de.wcloudservice.driver.minimessage.CloudMessage;
|
||||||
|
import de.wcloudservice.driver.network.out.player.based.PacketOutPlayerBasedTitle;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
import net.kyori.adventure.title.Title;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
|
public class HandlePacketOutPlayerBasedTitle implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutPlayerBasedTitle packet) {
|
||||||
|
if(!VelocityBootstrap.instance().proxyServer().getPlayer(packet.uniqueId()).isPresent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Title title = Title.title(
|
||||||
|
CloudMessage.colorizeComponent(packet.title()),
|
||||||
|
CloudMessage.colorizeComponent(packet.subtitle()),
|
||||||
|
Title.Times.times(
|
||||||
|
Duration.ofSeconds(packet.fadeIn()),
|
||||||
|
Duration.ofSeconds(packet.stay()),
|
||||||
|
Duration.ofSeconds(packet.fadeOut())
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
VelocityBootstrap.instance().proxyServer().getPlayer(packet.uniqueId()).get().showTitle(title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package de.wcloudservice.api.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.driver.Driver;
|
||||||
|
import de.wcloudservice.driver.event.events.group.CloudGroupCreateEvent;
|
||||||
|
import de.wcloudservice.driver.network.out.group.PacketOutGroupCreate;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
public class HandlePacketOutGroupCreate implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutGroupCreate packet) {
|
||||||
|
CloudAPI.instance().groupPool().groups().add(packet.group());
|
||||||
|
|
||||||
|
Driver.instance().eventDriver().executeEvent(new CloudGroupCreateEvent(packet.group()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package de.wcloudservice.api.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.driver.Driver;
|
||||||
|
import de.wcloudservice.driver.event.events.group.CloudGroupDeleteEvent;
|
||||||
|
import de.wcloudservice.driver.network.out.group.PacketOutGroupDelete;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
public class HandlePacketOutGroupDelete implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutGroupDelete packet) {
|
||||||
|
CloudAPI.instance().groupPool().groups().removeIf(group -> group.name().equals(packet.group().name()));
|
||||||
|
|
||||||
|
Driver.instance().eventDriver().executeEvent(new CloudGroupDeleteEvent(packet.group()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package de.wcloudservice.api.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.driver.Driver;
|
||||||
|
import de.wcloudservice.driver.event.events.group.CloudGroupUpdateEditEvent;
|
||||||
|
import de.wcloudservice.driver.network.out.group.PacketOutGroupUpdate;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
public class HandlePacketOutGroupUpdate implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutGroupUpdate packet) {
|
||||||
|
CloudAPI.instance().groupPool().groups().removeIf(group -> group.name().equals(packet.group().name()));
|
||||||
|
CloudAPI.instance().groupPool().groups().add(packet.group());
|
||||||
|
|
||||||
|
Driver.instance().eventDriver().executeEvent(new CloudGroupUpdateEditEvent(packet.group()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
package de.wcloudservice.api.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.driver.network.out.main.PacketOutMainGroups;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
public class HandlePacketOutMainGroups implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutMainGroups packet) {
|
||||||
|
CloudAPI.instance().groupPool().groups().clear();
|
||||||
|
CloudAPI.instance().groupPool().groups().addAll(packet.group());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package de.wcloudservice.api.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.driver.network.out.main.PacketOutMainMessages;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
public class HandlePacketOutMainMessages implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutMainMessages packet) {
|
||||||
|
CloudAPI.instance().messagePool().messageConfig(packet.messageConfig());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package de.wcloudservice.api.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.driver.network.in.player.based.PacketInPlayerBasedKick;
|
||||||
|
import de.wcloudservice.driver.network.out.main.PacketOutMainWhitelist;
|
||||||
|
import de.wcloudservice.driver.network.out.player.based.PacketOutPlayerBasedConnect;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
public class HandlePacketOutMainWhitelist implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutMainWhitelist packet) {
|
||||||
|
CloudAPI.instance().whitelist().clear();
|
||||||
|
CloudAPI.instance().whitelist().addAll(packet.whitelist());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package de.wcloudservice.api.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.api.pool.offlineplayer.entrys.OfflinePlayer;
|
||||||
|
import de.wcloudservice.driver.network.out.player.PacketOutPlayerCache;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
public class HandlePacketOutPlayerCache implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutPlayerCache packet) {
|
||||||
|
packet.playerCache().forEach(playerCache -> {
|
||||||
|
OfflinePlayer offlinePlayer = new OfflinePlayer(playerCache.name(), playerCache.uniqueId(), playerCache.firstConnected(), playerCache.lastConnected(), playerCache.lastProxy(), playerCache.lastService());
|
||||||
|
CloudAPI.instance().offlinePlayerPool().offlinePlayers().add(offlinePlayer);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package de.wcloudservice.api.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.api.pool.players.entry.CloudPlayer;
|
||||||
|
import de.wcloudservice.driver.Driver;
|
||||||
|
import de.wcloudservice.driver.event.events.player.CloudPlayerConnectedEvent;
|
||||||
|
import de.wcloudservice.driver.network.out.player.PacketOutPlayerConnect;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
public class HandlePacketOutPlayerConnect implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutPlayerConnect packet) {
|
||||||
|
CloudAPI.instance().playerPool().register(new CloudPlayer(packet.uniqueId(), packet.name(), packet.proxy(), ""));
|
||||||
|
Driver.instance().eventDriver().executeEvent(new CloudPlayerConnectedEvent(packet.name(), packet.uniqueId(), packet.proxy()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package de.wcloudservice.api.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.driver.Driver;
|
||||||
|
import de.wcloudservice.driver.event.events.player.CloudPlayerDisconnectedEvent;
|
||||||
|
import de.wcloudservice.driver.network.out.player.PacketOutPlayerDisconnect;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
public class HandlePacketOutPlayerDisconnect implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutPlayerDisconnect packet) {
|
||||||
|
CloudAPI.instance().playerPool().unregister(packet.uniqueId());
|
||||||
|
Driver.instance().eventDriver().executeEvent(new CloudPlayerDisconnectedEvent(packet.name(), packet.uniqueId()));
|
||||||
|
|
||||||
|
System.out.println(CloudAPI.instance().playerPool().connectedPlayers().size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package de.wcloudservice.api.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.api.pool.players.entry.CloudPlayer;
|
||||||
|
import de.wcloudservice.driver.Driver;
|
||||||
|
import de.wcloudservice.driver.event.events.player.CloudPlayerConnectedEvent;
|
||||||
|
import de.wcloudservice.driver.event.events.player.CloudPlayerSwitchEvent;
|
||||||
|
import de.wcloudservice.driver.network.out.player.PacketOutPlayerSwitchService;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
public class HandlePacketOutPlayerSwitchService implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutPlayerSwitchService packet) {
|
||||||
|
if(!CloudAPI.instance().playerPool().playerExists(packet.uniqueId())) {
|
||||||
|
CloudAPI.instance().playerPool().register(new CloudPlayer(packet.uniqueId(), packet.name(), packet.proxy(), packet.to()));
|
||||||
|
Driver.instance().eventDriver().executeEvent(new CloudPlayerConnectedEvent(packet.name(), packet.uniqueId(), packet.proxy()));
|
||||||
|
} else {
|
||||||
|
CloudAPI.instance().playerPool().cloudPlayer(packet.uniqueId()).service(packet.to());
|
||||||
|
}
|
||||||
|
|
||||||
|
Driver.instance().eventDriver().executeEvent(new CloudPlayerSwitchEvent(packet.name(), packet.uniqueId(), packet.from(), packet.to()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package de.wcloudservice.api.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.driver.Driver;
|
||||||
|
import de.wcloudservice.driver.event.events.service.CloudProxyChangeStateEvent;
|
||||||
|
import de.wcloudservice.driver.event.events.service.CloudServiceChangeStateEvent;
|
||||||
|
import de.wcloudservice.driver.network.out.service.PacketOutServiceChangeState;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
public class HandlePacketOutServiceChangeState implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutServiceChangeState packet) {
|
||||||
|
if(CloudAPI.instance().servicePool().serviceExists(packet.service())) {
|
||||||
|
CloudAPI.instance().servicePool().service(packet.service()).state(packet.state());
|
||||||
|
|
||||||
|
if(packet.proxy()) {
|
||||||
|
Driver.instance().eventDriver().executeEvent(new CloudProxyChangeStateEvent(packet.service(), packet.state(), packet.daemon()));
|
||||||
|
} else {
|
||||||
|
Driver.instance().eventDriver().executeEvent(new CloudServiceChangeStateEvent(packet.service(), packet.state(), packet.daemon()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
package de.wcloudservice.api.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.api.pool.services.entry.CloudService;
|
||||||
|
import de.wcloudservice.driver.Driver;
|
||||||
|
import de.wcloudservice.driver.event.events.service.CloudProxyConnectedEvent;
|
||||||
|
import de.wcloudservice.driver.event.events.service.CloudServiceConnectedEvent;
|
||||||
|
import de.wcloudservice.driver.network.in.main.PacketInMainGroups;
|
||||||
|
import de.wcloudservice.driver.network.out.service.PacketOutServiceConnected;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class HandlePacketOutServiceConnected implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutServiceConnected packet) {
|
||||||
|
if (!CloudAPI.instance().servicePool().serviceExists(packet.service().serviceName())) {
|
||||||
|
CloudAPI.instance().servicePool().register(new CloudService(packet.service().serviceName(), packet.service().groupName(), packet.service().status(), CloudAPI.instance().service().masterAddress(), packet.service().usedPort()));
|
||||||
|
|
||||||
|
if(CloudAPI.instance().groupPool().groups().stream().noneMatch(group -> group.name().equals(packet.service().groupName()))) {
|
||||||
|
System.out.println("Can't get group " + packet.service().groupName());
|
||||||
|
CloudAPI.instance().sendPacket(new PacketInMainGroups());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CloudAPI.instance().servicePool().service(packet.service().serviceName()).typeProxy()) {
|
||||||
|
Driver.instance().eventDriver().executeEvent(new CloudProxyConnectedEvent(packet.service()));
|
||||||
|
} else {
|
||||||
|
Driver.instance().eventDriver().executeEvent(new CloudServiceConnectedEvent(packet.service()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package de.wcloudservice.api.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.driver.Driver;
|
||||||
|
import de.wcloudservice.driver.event.events.service.CloudProxyCouldNotStartEvent;
|
||||||
|
import de.wcloudservice.driver.event.events.service.CloudServiceCouldNotStartEvent;
|
||||||
|
import de.wcloudservice.driver.network.out.service.PacketOutServiceCouldNotStart;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
public class HandlePacketOutServiceCouldNotStart implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutServiceCouldNotStart packet) {
|
||||||
|
if(packet.proxy()) {
|
||||||
|
Driver.instance().eventDriver().executeEvent(new CloudProxyCouldNotStartEvent(packet.service(), packet.daemon()));
|
||||||
|
} else {
|
||||||
|
Driver.instance().eventDriver().executeEvent(new CloudServiceCouldNotStartEvent(packet.service(), packet.daemon()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
package de.wcloudservice.api.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.api.pool.services.entry.CloudService;
|
||||||
|
import de.wcloudservice.driver.Driver;
|
||||||
|
import de.wcloudservice.driver.event.events.service.*;
|
||||||
|
import de.wcloudservice.driver.network.out.service.PacketOutServiceDisconnected;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
public class HandlePacketOutServiceDisconnected implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutServiceDisconnected packet) {
|
||||||
|
if (CloudAPI.instance().servicePool().serviceExists(packet.service().serviceName())) {
|
||||||
|
CloudService cloudService = CloudAPI.instance().servicePool().service(packet.service().serviceName());
|
||||||
|
if (cloudService.typeProxy()) {
|
||||||
|
Driver.instance().eventDriver().executeEvent(new CloudProxyDisconnectedEvent(packet.service()));
|
||||||
|
} else {
|
||||||
|
Driver.instance().eventDriver().executeEvent(new CloudServiceDisconnectedEvent(packet.service()));
|
||||||
|
}
|
||||||
|
|
||||||
|
CloudAPI.instance().servicePool().unregister(packet.service().serviceName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package de.wcloudservice.api.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.driver.Driver;
|
||||||
|
import de.wcloudservice.driver.event.events.service.CloudProxyLaunchEvent;
|
||||||
|
import de.wcloudservice.driver.event.events.service.CloudServiceLaunchEvent;
|
||||||
|
import de.wcloudservice.driver.network.out.service.PacketOutServiceLaunch;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
public class HandlePacketOutServiceLaunch implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutServiceLaunch packet) {
|
||||||
|
if (packet.proxy()) {
|
||||||
|
Driver.instance().eventDriver().executeEvent(new CloudProxyLaunchEvent(packet.serviceName(), packet.groupName(), packet.daemon()));
|
||||||
|
} else {
|
||||||
|
Driver.instance().eventDriver().executeEvent(new CloudServiceLaunchEvent(packet.serviceName(), packet.groupName(), packet.daemon()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package de.wcloudservice.api.networking;
|
||||||
|
|
||||||
|
import de.wcloudservice.driver.Driver;
|
||||||
|
import de.wcloudservice.driver.event.events.service.*;
|
||||||
|
import de.wcloudservice.driver.network.out.service.PacketOutServicePrepared;
|
||||||
|
import de.wcloudservice.networking.packet.NettyAdapter;
|
||||||
|
import de.wcloudservice.networking.packet.Packet;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
public class HandlePacketOutServicePrepared implements NettyAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <P extends Packet> void handle(Channel channel, P handlePacket) {
|
||||||
|
if (handlePacket instanceof PacketOutServicePrepared packet) {
|
||||||
|
if (packet.proxy()) {
|
||||||
|
Driver.instance().eventDriver().executeEvent(new CloudProxyPreparedEvent(packet.serviceName(), packet.groupName(), packet.daemon()));
|
||||||
|
} else {
|
||||||
|
Driver.instance().eventDriver().executeEvent(new CloudServicePreparedEvent(packet.serviceName(), packet.groupName(), packet.daemon()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
package de.wcloudservice.api.pool.groups;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.driver.configuration.group.Group;
|
||||||
|
import de.wcloudservice.driver.network.in.group.PacketInGroupStop;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
public class GroupPool {
|
||||||
|
|
||||||
|
private List<Group> groups = new ArrayList<>();
|
||||||
|
|
||||||
|
public List<String> groupNames() {
|
||||||
|
List<String> names = new ArrayList<>();
|
||||||
|
this.groups.forEach(group -> names.add(group.name()));
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean groupExists(String groupName) {
|
||||||
|
return this.groups.stream().anyMatch(group -> group.name().equals(groupName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void groupStop(String groupName) {
|
||||||
|
CloudAPI.instance().sendPacket(new PacketInGroupStop(groupName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Group group(String groupName) {
|
||||||
|
return this.groups.stream().filter(group -> group.name().equals(groupName)).findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Group> groups(String[] groupNames) {
|
||||||
|
return this.groups.stream().filter(group1 -> Arrays.stream(groupNames).anyMatch(s -> group1.name().equals(s))).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
package de.wcloudservice.api.pool.messages;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.driver.configuration.message.MessageConfig;
|
||||||
|
import de.wcloudservice.driver.network.in.main.PacketInMainMessages;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
public class MessagePool {
|
||||||
|
|
||||||
|
private MessageConfig messageConfig;
|
||||||
|
|
||||||
|
public boolean messageExists(String key) {
|
||||||
|
return this.messageConfig.messages().keySet().stream().anyMatch(s -> s.equals(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String message(String key) {
|
||||||
|
String message = this.messageConfig.messages().get(key);
|
||||||
|
|
||||||
|
for (String s : this.messageConfig.messages().keySet()) {
|
||||||
|
String s1 = this.messageConfig.messages().get(s);
|
||||||
|
message = message.replaceAll("%" + s.toUpperCase() + "%", s1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateMessages() {
|
||||||
|
CloudAPI.instance().sendPacket(new PacketInMainMessages());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
package de.wcloudservice.api.pool.offlineplayer;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.pool.offlineplayer.entrys.OfflinePlayer;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
public class OfflinePlayerPool {
|
||||||
|
|
||||||
|
private List<OfflinePlayer> offlinePlayers = new ArrayList<>();
|
||||||
|
|
||||||
|
public OfflinePlayer offlinePlayer(String name) {
|
||||||
|
return this.offlinePlayers.stream().filter(offlinePlayer -> offlinePlayer.name().equals(name)).findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OfflinePlayer offlinePlayer(UUID uniqueId) {
|
||||||
|
return this.offlinePlayers.stream().filter(offlinePlayer -> offlinePlayer.uniqueId().equals(uniqueId)).findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<OfflinePlayer> offlinePlayerFromProxy(String proxy) {
|
||||||
|
return this.offlinePlayers.stream().filter(offlinePlayer -> offlinePlayer.lastProxy().equals(proxy)).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<OfflinePlayer> offlinePlayerFromService(String service) {
|
||||||
|
return this.offlinePlayers.stream().filter(offlinePlayer -> offlinePlayer.lastService().equals(service)).toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package de.wcloudservice.api.pool.offlineplayer.entrys;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class OfflinePlayer {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private UUID uniqueId;
|
||||||
|
private long firstConnected;
|
||||||
|
private long lastConnected;
|
||||||
|
private String lastProxy;
|
||||||
|
private String lastService;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,72 @@
|
|||||||
|
package de.wcloudservice.api.pool.players;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.pool.players.entry.CloudPlayer;
|
||||||
|
import de.wcloudservice.driver.process.ServiceState;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NonNull;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
public class PlayerPool {
|
||||||
|
|
||||||
|
private final List<CloudPlayer> connectedPlayers = new ArrayList<>();
|
||||||
|
|
||||||
|
public CloudPlayer cloudPlayer(String username) {
|
||||||
|
return this.connectedPlayers.stream().filter(cloudPlayer -> cloudPlayer.name().equals(username)).findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CloudPlayer cloudPlayer(UUID uniqueId) {
|
||||||
|
return this.connectedPlayers.stream().filter(cloudPlayer -> cloudPlayer.uniqueId().equals(uniqueId)).findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CloudPlayer> playersFromService(@NonNull String service) {
|
||||||
|
return this.connectedPlayers.stream().filter(cloudPlayer -> cloudPlayer.server().name().equals(service)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CloudPlayer> playersFromProxy(@NonNull String proxyService) {
|
||||||
|
return this.connectedPlayers.stream().filter(cloudPlayer -> cloudPlayer.proxyServer().name().equals(proxyService)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CloudPlayer> playersByServiceGroup(@NonNull String group) {
|
||||||
|
return this.connectedPlayers.stream().filter(cloudPlayer -> cloudPlayer.server().group().name().equals(group)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CloudPlayer> playersByProxyGroup(@NonNull String group) {
|
||||||
|
return this.connectedPlayers.stream().filter(cloudPlayer -> cloudPlayer.proxyServer().group().name().equals(group)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CloudPlayer> playersFromServiceGroupByState(@NonNull String group, ServiceState state) {
|
||||||
|
return this.connectedPlayers.stream().filter(cloudPlayer -> cloudPlayer.server().group().name().equals(group))
|
||||||
|
.filter(cloudPlayer -> cloudPlayer.server().state() == state)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CloudPlayer> getPlayersFromProxyGroupByState(@NonNull String group, ServiceState state) {
|
||||||
|
return this.connectedPlayers.stream().filter(cloudPlayer -> cloudPlayer.proxyServer().group().name().equals(group))
|
||||||
|
.filter(cloudPlayer -> cloudPlayer.proxyServer().state() == state)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean playerExists(@NonNull UUID uniqueId) {
|
||||||
|
return this.connectedPlayers.stream().anyMatch(cloudPlayer -> cloudPlayer.uniqueId().equals(uniqueId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void register(@NonNull CloudPlayer cloudPlayer) {
|
||||||
|
if (!this.playerExists(cloudPlayer.uniqueId())) {
|
||||||
|
this.connectedPlayers.add(cloudPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unregister(@NonNull UUID uniqueId) {
|
||||||
|
this.connectedPlayers.removeIf(cloudPlayer -> cloudPlayer.uniqueId().equals(uniqueId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,133 @@
|
|||||||
|
package de.wcloudservice.api.pool.players.entry;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.api.pool.services.entry.CloudService;
|
||||||
|
import de.wcloudservice.driver.minimessage.CloudMessage;
|
||||||
|
import de.wcloudservice.driver.network.in.player.based.*;
|
||||||
|
import de.wcloudservice.driver.network.out.player.based.PacketOutPlayerBasedExecuteCommand;
|
||||||
|
import de.wcloudservice.driver.playercache.codec.gamemode.GameMode;
|
||||||
|
import de.wcloudservice.driver.playercache.codec.sounds.Sounds;
|
||||||
|
import de.wcloudservice.driver.playercache.codec.teleport.Teleport;
|
||||||
|
import de.wcloudservice.driver.playercache.codec.title.Title;
|
||||||
|
import de.wcloudservice.driver.process.ServiceState;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CloudPlayer {
|
||||||
|
|
||||||
|
private final UUID uniqueId;
|
||||||
|
private final String name;
|
||||||
|
private String proxyService;
|
||||||
|
@Setter
|
||||||
|
private String service;
|
||||||
|
|
||||||
|
public void performMore(Consumer<CloudPlayer> cloudPlayerConsumer) {
|
||||||
|
cloudPlayerConsumer.accept(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CloudService proxyServer() {
|
||||||
|
return CloudAPI.instance().servicePool().service(this.proxyService);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CloudService server() {
|
||||||
|
return CloudAPI.instance().servicePool().service(this.service);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sound(Sounds sound, int volume, int pitch) {
|
||||||
|
this.server().executeCommand("playsound " + sound.toString().toUpperCase() + " " + this.name + " " + volume + " " + pitch);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void teleport(Teleport teleport) {
|
||||||
|
if (teleport.player() != null) {
|
||||||
|
this.server().executeCommand("tp " + this.name + " " + teleport.player());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.server().executeCommand("tp " + this.name + " " + teleport.x() + " " + teleport.y() + " " + teleport.z());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void connectRanked(String group) {
|
||||||
|
CloudAPI.instance()
|
||||||
|
.servicePool()
|
||||||
|
.servicesByGroup(group)
|
||||||
|
.stream()
|
||||||
|
.filter(cloudService -> (cloudService.state() == ServiceState.LOBBY))
|
||||||
|
.min(Comparator.comparingInt(CloudService::playerCount))
|
||||||
|
.ifPresent(service -> CloudAPI.instance().sendPacket(new PacketInPlayerBasedConnect(this.name, service.name())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void changeGameMode(GameMode gameMode) {
|
||||||
|
switch (gameMode) {
|
||||||
|
case ADVENTURE -> this.server().executeCommand("gamemode ADVENTURE " + this.name);
|
||||||
|
case CREATIVE -> this.server().executeCommand("gamemode CREATIVE " + this.name);
|
||||||
|
case SURVIVAL -> this.server().executeCommand("gamemode SURVIVAL " + this.name);
|
||||||
|
case SPECTATOR -> this.server().executeCommand("gamemode SPECTATOR " + this.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void connect(CloudService cloudService) {
|
||||||
|
CloudAPI.instance().sendPacket(new PacketInPlayerBasedConnect(this.name, cloudService.name()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void connectRandom(String group) {
|
||||||
|
CloudService cloudService = CloudAPI.instance().servicePool().servicesByGroup(group).get(new Random().nextInt(CloudAPI.instance().servicePool().servicesByGroup(group).size()));
|
||||||
|
CloudAPI.instance().sendPacket(new PacketInPlayerBasedConnect(this.name, cloudService.name()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void executeCommand(String command) {
|
||||||
|
CloudAPI.instance().sendPacket(new PacketOutPlayerBasedExecuteCommand(this.name, command));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void xp(int amount) {
|
||||||
|
this.server().executeCommand("xp " + this.name + " " + amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void connect(CloudPlayer cloudPlayer) {
|
||||||
|
CloudAPI.instance().sendPacket(new PacketInPlayerBasedConnect(this.name, cloudPlayer.server().name()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disconnect(String message) {
|
||||||
|
CloudAPI.instance().sendPacket(new PacketInPlayerBasedKick(this.uniqueId, message));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disconnect(){
|
||||||
|
this.disconnect("<red>Your kicked from the Network");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendTitle(Title title) {
|
||||||
|
CloudAPI.instance().sendPacket(new PacketInPlayerBasedTitle(this.uniqueId, title.title(), title.subtitle(), title.fadeIn(), title.stay(), title.fadeOut()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendTabList(String header, String footer) {
|
||||||
|
CloudAPI.instance().sendPacket(new PacketInPlayerBasedTablist(this.uniqueId, header, footer));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendActionBar(String message) {
|
||||||
|
CloudAPI.instance().sendPacket(new PacketInPlayerBasedActionbar(this.uniqueId, message));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendMessage(String message) {
|
||||||
|
CloudAPI.instance().sendPacket(new PacketInPlayerBasedMessage(this.uniqueId, message));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendMessage(String... messages) {
|
||||||
|
for (String message : messages) {
|
||||||
|
this.sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean connectedOnFallback() {
|
||||||
|
return this.server().typeLobby();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,64 @@
|
|||||||
|
package de.wcloudservice.api.pool.services;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.api.pool.services.entry.CloudService;
|
||||||
|
import de.wcloudservice.driver.network.in.service.PacketInServiceStop;
|
||||||
|
import de.wcloudservice.driver.process.ServiceState;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
public class ServicePool {
|
||||||
|
|
||||||
|
private List<CloudService> connectedServices = new ArrayList<>();
|
||||||
|
|
||||||
|
public CloudService service(String serviceName) {
|
||||||
|
return this.connectedServices.stream().filter(cloudService -> cloudService.name().equals(serviceName)).findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean serviceExists(String serviceName) {
|
||||||
|
return this.connectedServices.stream().anyMatch(cloudService -> cloudService.name().equals(serviceName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CloudService> servicesByGroup(String groupName) {
|
||||||
|
return this.connectedServices.stream().filter(cloudService -> cloudService.group().name().equals(groupName)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CloudService> servicesByState(ServiceState state) {
|
||||||
|
return this.connectedServices.stream().filter(cloudService -> cloudService.state().equals(state)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CloudService> servicesByGroupAndState(String groupName, ServiceState state) {
|
||||||
|
return this.servicesByGroup(groupName).stream().filter(cloudService -> cloudService.state().equals(state)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean register(CloudService service) {
|
||||||
|
if (!this.serviceExists(service.name())) {
|
||||||
|
this.connectedServices.add(service);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean unregister(String serviceName) {
|
||||||
|
if (this.serviceExists(serviceName)) {
|
||||||
|
this.connectedServices.removeIf(service -> service.name().equals(serviceName));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stop(String serviceName) {
|
||||||
|
CloudAPI.instance().sendPacket(new PacketInServiceStop(serviceName));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,88 @@
|
|||||||
|
package de.wcloudservice.api.pool.services.entry;
|
||||||
|
|
||||||
|
import de.wcloudservice.api.CloudAPI;
|
||||||
|
import de.wcloudservice.api.pool.players.entry.CloudPlayer;
|
||||||
|
import de.wcloudservice.driver.configuration.group.Group;
|
||||||
|
import de.wcloudservice.driver.network.in.service.PacketInServiceExecuteCommand;
|
||||||
|
import de.wcloudservice.driver.process.ServiceState;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CloudService {
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private final String groupName;
|
||||||
|
@Setter
|
||||||
|
private ServiceState state;
|
||||||
|
private String host;
|
||||||
|
private int port;
|
||||||
|
|
||||||
|
public void performMore(Consumer<CloudService> cloudServiceConsumer) {
|
||||||
|
cloudServiceConsumer.accept(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateState(ServiceState state) {
|
||||||
|
CloudAPI.instance().state(state, this.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Group group() {
|
||||||
|
return CloudAPI.instance().groupPool().group(this.groupName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sync() {
|
||||||
|
CloudAPI.instance().executeCommand("service copy " + this.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void executeCommand(String command) {
|
||||||
|
CloudAPI.instance().sendPacket(new PacketInServiceExecuteCommand(this.name, command));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void shutdown() {
|
||||||
|
CloudAPI.instance().servicePool().stop(this.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean typeProxy() {
|
||||||
|
return this.group().type().equals("PROXY");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean typeLobby() {
|
||||||
|
return this.group().type().equals("LOBBY");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean typeGame() {
|
||||||
|
return this.group().type().equals("GAME");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean runStatic() {
|
||||||
|
return this.group().runStatic();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void connect(String playerName) {
|
||||||
|
CloudAPI.instance().playerPool().cloudPlayer(playerName).connect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int playerCount() {
|
||||||
|
if(this.typeProxy()) {
|
||||||
|
return CloudAPI.instance().playerPool().playersFromProxy(this.name).size();
|
||||||
|
}
|
||||||
|
|
||||||
|
return CloudAPI.instance().playerPool().playersFromService(this.name).size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CloudPlayer> players() {
|
||||||
|
if (this.typeProxy()){
|
||||||
|
return CloudAPI.instance().playerPool().playersFromProxy(this.name);
|
||||||
|
} else {
|
||||||
|
return CloudAPI.instance().playerPool().playersFromService(this.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
4
wcloud-api/src/main/resources/bungee.yml
Normal file
4
wcloud-api/src/main/resources/bungee.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
name: wcloud-api
|
||||||
|
main: de.wcloudservice.api.bootstrap.bungeecord.BungeeCordBootstrap
|
||||||
|
version: 1.0.0-SNAPSHOT
|
||||||
|
author: Weapie
|
||||||
11
wcloud-api/src/main/resources/plugin.yml
Normal file
11
wcloud-api/src/main/resources/plugin.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
main: de.wcloudservice.api.bootstrap.bukkit.BukkitBootstrap
|
||||||
|
name: wcloud-api
|
||||||
|
version: 1.0.0-SNAPSHOT
|
||||||
|
author: Weapie
|
||||||
|
load: STARTUP
|
||||||
|
|
||||||
|
description: This is the api of wcloud
|
||||||
|
website: https://wcloudservice.weapie.de
|
||||||
|
|
||||||
|
softdepend:
|
||||||
|
- floodgate
|
||||||
13
wcloud-api/src/main/resources/velocity-plugin.json
Normal file
13
wcloud-api/src/main/resources/velocity-plugin.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"id": "wcloudapi",
|
||||||
|
"name": "wcloud-api",
|
||||||
|
"version": "1.0.0-SNAPSHOT",
|
||||||
|
"authors": ["Weapie"],
|
||||||
|
"main": "de.wcloudservice.api.bootstrap.velocity.VelocityBootstrap",
|
||||||
|
"dependencies": [
|
||||||
|
{
|
||||||
|
"id": "floodgate",
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
32
wcloud-driver/build.gradle.kts
Normal file
32
wcloud-driver/build.gradle.kts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
plugins {
|
||||||
|
alias(libs.plugins.shadow)
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<Jar> {
|
||||||
|
archiveBaseName.set(Files.driver.removeSuffix(".jar"))
|
||||||
|
archiveVersion.set("")
|
||||||
|
if (name == "jar") archiveClassifier.set("plain")
|
||||||
|
if (name == "shadowJar") archiveClassifier.set("")
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
"implementation"(projects.wcloudUtils)
|
||||||
|
"implementation"(projects.wcloudNetworking)
|
||||||
|
|
||||||
|
"implementation"(libs.gson)
|
||||||
|
"implementation"(libs.guava)
|
||||||
|
"implementation"(libs.sqlite)
|
||||||
|
|
||||||
|
"implementation"(libs.bundles.jline)
|
||||||
|
"implementation"(libs.bundles.devlok)
|
||||||
|
"implementation"(libs.bundles.adventure)
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named("shadowJar") {
|
||||||
|
dependsOn(":wcloud-networking:shadowJar")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named<Test>("test") {
|
||||||
|
// Main is a manual language runner, not a JUnit test.
|
||||||
|
exclude("Main.class")
|
||||||
|
}
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
package de.wcloudservice.driver;
|
||||||
|
|
||||||
|
import de.wcloudservice.driver.configuration.daemon.DaemonConfig;
|
||||||
|
import de.wcloudservice.driver.playercache.PlayerCacheDriver;
|
||||||
|
import de.wcloudservice.driver.configuration.ConfigDriver;
|
||||||
|
import de.wcloudservice.driver.event.EventDriver;
|
||||||
|
import de.wcloudservice.driver.group.GroupDriver;
|
||||||
|
import de.wcloudservice.driver.group.TemplateDriver;
|
||||||
|
import de.wcloudservice.driver.language.LanguageDriver;
|
||||||
|
import de.wcloudservice.driver.module.ModuleDriver;
|
||||||
|
import de.wcloudservice.driver.storage.service.DaemonSafe;
|
||||||
|
import de.wcloudservice.driver.terminal.TerminalDriver;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
public final class Driver {
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private static Driver instance;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private boolean ready = false;
|
||||||
|
|
||||||
|
private final ConfigDriver configDriver = new ConfigDriver();
|
||||||
|
private final EventDriver eventDriver = new EventDriver();
|
||||||
|
private final TerminalDriver terminalDriver = new TerminalDriver();
|
||||||
|
private final ModuleDriver moduleDriver = new ModuleDriver();
|
||||||
|
private final GroupDriver groupDriver = new GroupDriver();
|
||||||
|
private final TemplateDriver templateDriver = new TemplateDriver();
|
||||||
|
private final LanguageDriver languageDriver = new LanguageDriver();
|
||||||
|
|
||||||
|
private DaemonSafe daemonSafe;
|
||||||
|
|
||||||
|
private PlayerCacheDriver playerCacheDriver;
|
||||||
|
|
||||||
|
public Driver() {
|
||||||
|
instance = this;
|
||||||
|
System.setProperty("java.net.useSystemProxies", "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startDaemonSafe(DaemonSafe daemonSafe) {
|
||||||
|
this.daemonSafe = daemonSafe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startPlayerCache() {
|
||||||
|
this.playerCacheDriver = new PlayerCacheDriver();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startTerminal() {
|
||||||
|
this.terminalDriver.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startLanguage() {
|
||||||
|
this.languageDriver.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
package de.wcloudservice.driver.configuration;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import de.weapie.devlok.files.config.DevlokConfig;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
public class ConfigDriver {
|
||||||
|
|
||||||
|
protected final Gson GSON = (new GsonBuilder()).serializeNulls().setPrettyPrinting().disableHtmlEscaping().create();
|
||||||
|
|
||||||
|
public <T> T read(String path, Class<T> clazz) {
|
||||||
|
return DevlokConfig.builder(clazz).withPath(path).build().read();
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> boolean exists(String path, Class<T> clazz) {
|
||||||
|
return DevlokConfig.builder(clazz).withPath(path).build().exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void save(String path, T config) {
|
||||||
|
Class<T> clazz = (Class<T>) config.getClass();
|
||||||
|
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
|
DevlokConfig devlokConfig = DevlokConfig.builder(clazz)
|
||||||
|
.withDefault(() -> {
|
||||||
|
try {
|
||||||
|
return clazz.getDeclaredConstructor().newInstance();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Failed to create default instance of " + clazz.getName(), e);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.withPath(path)
|
||||||
|
.build();
|
||||||
|
devlokConfig.value(config);
|
||||||
|
devlokConfig.write(true, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> String convertToString(T t) {
|
||||||
|
return GSON.toJson(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package de.wcloudservice.driver.configuration.daemon;
|
||||||
|
|
||||||
|
import de.weapie.devlok.files.config.annotations.Config;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Config(id = "daemon")
|
||||||
|
public class DaemonConfig {
|
||||||
|
|
||||||
|
private String language;
|
||||||
|
private String masterAddress;
|
||||||
|
private int masterPort;
|
||||||
|
private String javaCommand;
|
||||||
|
private String connectionKey;
|
||||||
|
private int processorUsage;
|
||||||
|
private int memoryUsage;
|
||||||
|
private boolean patcher;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
package de.wcloudservice.driver.configuration.group;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class Group {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String type;
|
||||||
|
private int usedMemory;
|
||||||
|
private boolean maintenance;
|
||||||
|
private boolean runStatic;
|
||||||
|
private int priority;
|
||||||
|
private String permission;
|
||||||
|
private int maxPlayers;
|
||||||
|
private int minimalOnline;
|
||||||
|
private int maximalOnline;
|
||||||
|
private int startNewPercent;
|
||||||
|
private int over100AtGroup;
|
||||||
|
private int over100AtNetwork;
|
||||||
|
private boolean platformUpdate;
|
||||||
|
private GroupStorage storage;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package de.wcloudservice.driver.configuration.group;
|
||||||
|
|
||||||
|
import de.weapie.devlok.files.config.annotations.Config;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Config(id = "groups")
|
||||||
|
public class GroupConfig {
|
||||||
|
|
||||||
|
private List<Group> groups;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package de.wcloudservice.driver.configuration.group;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class GroupStorage {
|
||||||
|
|
||||||
|
private String template;
|
||||||
|
private String javaEnvironment;
|
||||||
|
private String runningDaemon;
|
||||||
|
private String startArguments;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package de.wcloudservice.driver.configuration.master;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class Daemon {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String address;
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
package de.wcloudservice.driver.configuration.master;
|
||||||
|
|
||||||
|
import de.weapie.devlok.files.config.annotations.Config;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Config(id = "master")
|
||||||
|
public class MasterConfig {
|
||||||
|
|
||||||
|
private boolean debug;
|
||||||
|
private String language;
|
||||||
|
private String address;
|
||||||
|
private String splitter;
|
||||||
|
private String uniqueId;
|
||||||
|
private boolean useProtocol;
|
||||||
|
private int processorUsage;
|
||||||
|
private int memoryUsage;
|
||||||
|
private int serviceStartupCount;
|
||||||
|
private boolean showConnectingPlayers;
|
||||||
|
private int proxyPort;
|
||||||
|
private int servicePort;
|
||||||
|
private String proxyVersion;
|
||||||
|
private String serviceVersion;
|
||||||
|
private String javaCommand;
|
||||||
|
private int networkPort;
|
||||||
|
private int checkTimeout;
|
||||||
|
private boolean copyLogs;
|
||||||
|
private boolean patcher;
|
||||||
|
private List<String> whitelist;
|
||||||
|
private List<Daemon> daemons;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package de.wcloudservice.driver.configuration.message;
|
||||||
|
|
||||||
|
import de.weapie.devlok.files.config.annotations.Config;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Config(id = "message")
|
||||||
|
public class MessageConfig {
|
||||||
|
|
||||||
|
private Map<String, String> messages;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
package de.wcloudservice.driver.configuration.service;
|
||||||
|
|
||||||
|
import de.weapie.devlok.files.config.annotations.Config;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Config(id = "service")
|
||||||
|
public class ServiceConfig {
|
||||||
|
|
||||||
|
private String daemon;
|
||||||
|
private String service;
|
||||||
|
private String group;
|
||||||
|
private String type;
|
||||||
|
private String masterAddress;
|
||||||
|
private int port;
|
||||||
|
private int networkPort;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,95 @@
|
|||||||
|
package de.wcloudservice.driver.event;
|
||||||
|
|
||||||
|
import de.wcloudservice.driver.event.annotations.Subscribe;
|
||||||
|
import de.wcloudservice.driver.event.interfaces.CloudListener;
|
||||||
|
import de.wcloudservice.driver.event.interfaces.EventAdapter;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
public class EventDriver {
|
||||||
|
|
||||||
|
public static final int PRE = -1;
|
||||||
|
public static final int ALL = 0;
|
||||||
|
public static final int POST = 1;
|
||||||
|
|
||||||
|
private final Map<Class<? extends EventAdapter>, Collection<EventProcessor>> bindings = new ConcurrentHashMap<>();
|
||||||
|
private final Set<CloudListener> registeredListeners = new HashSet<>();
|
||||||
|
|
||||||
|
public List<EventProcessor> getListenersFor(Class<? extends EventAdapter> clazz) {
|
||||||
|
if (!this.bindings.containsKey(clazz)) return new ArrayList<>();
|
||||||
|
return new ArrayList<>(this.bindings.get(clazz));
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends EventAdapter> T executeEvent(T event, int i) {
|
||||||
|
Collection<EventProcessor> handlers = this.bindings.get(event.getClass());
|
||||||
|
|
||||||
|
if (handlers == null) return event;
|
||||||
|
|
||||||
|
for (EventProcessor handler : handlers) {
|
||||||
|
if (i == PRE && handler.priority() >= 0) continue;
|
||||||
|
if (i == POST && handler.priority() < 0) continue;
|
||||||
|
handler.execute(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
public <T extends EventAdapter> T executeEvent(T event) {
|
||||||
|
return this.executeEvent(event, ALL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerListener(final CloudListener listener) {
|
||||||
|
if (this.registeredListeners.contains(listener)) return;
|
||||||
|
|
||||||
|
Method[] methods = listener.getClass().getDeclaredMethods();
|
||||||
|
this.registeredListeners.add(listener);
|
||||||
|
|
||||||
|
for (final Method method : methods) {
|
||||||
|
Subscribe annotation = method.getAnnotation(Subscribe.class);
|
||||||
|
if (annotation == null) continue;
|
||||||
|
|
||||||
|
Class<?>[] parameters = method.getParameterTypes();
|
||||||
|
if (parameters.length != 1) continue;
|
||||||
|
|
||||||
|
Class<?> param = parameters[0];
|
||||||
|
|
||||||
|
if (!method.getReturnType().equals(void.class)) continue;
|
||||||
|
|
||||||
|
if (!EventAdapter.class.isAssignableFrom(param)) return;
|
||||||
|
|
||||||
|
Class<? extends EventAdapter> realParam = (Class<? extends EventAdapter>) param;
|
||||||
|
|
||||||
|
if (!this.bindings.containsKey(realParam)) this.bindings.put(realParam, new TreeSet<>());
|
||||||
|
|
||||||
|
Collection<EventProcessor> eventHandlersForEvent = this.bindings.get(realParam);
|
||||||
|
eventHandlersForEvent.add(createEventHandler(listener, method, annotation));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private EventProcessor createEventHandler(final CloudListener listener, final Method method, final Subscribe annotation) {
|
||||||
|
return new EventProcessor(listener, method, annotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearListeners() {
|
||||||
|
this.bindings.clear();
|
||||||
|
this.registeredListeners.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeListener(CloudListener listener) {
|
||||||
|
for (Map.Entry<Class<? extends EventAdapter>, Collection<EventProcessor>> entry : this.bindings.entrySet()) {
|
||||||
|
entry.getValue().removeIf(curr -> curr.listener() == listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.registeredListeners.remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Class<? extends EventAdapter>, Collection<EventProcessor>> getBindings() {
|
||||||
|
return new HashMap<>(this.bindings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<CloudListener> getRegisteredListeners() {
|
||||||
|
return new HashSet<>(this.registeredListeners);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
package de.wcloudservice.driver.event;
|
||||||
|
|
||||||
|
import de.wcloudservice.driver.event.annotations.Subscribe;
|
||||||
|
import de.wcloudservice.driver.event.interfaces.CloudListener;
|
||||||
|
import de.wcloudservice.driver.event.interfaces.EventAdapter;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ToString
|
||||||
|
public class EventProcessor implements Comparable<EventProcessor> {
|
||||||
|
|
||||||
|
private final CloudListener listener;
|
||||||
|
private final Method method;
|
||||||
|
private final Subscribe annotation;
|
||||||
|
|
||||||
|
public void execute(EventAdapter event) {
|
||||||
|
if (this.annotation.async()) {
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
|
try {
|
||||||
|
this.method.invoke(this.listener, event);
|
||||||
|
} catch (IllegalAccessException | InvocationTargetException ignored) {}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.method.invoke(this.listener, event);
|
||||||
|
} catch (IllegalAccessException | InvocationTargetException ignored) {};
|
||||||
|
}
|
||||||
|
|
||||||
|
public int priority() {
|
||||||
|
return this.annotation.priority();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(EventProcessor other) {
|
||||||
|
int annotation = this.annotation.priority() - other.annotation.priority();
|
||||||
|
if (annotation == 0) annotation = this.listener.hashCode() - other.listener.hashCode();
|
||||||
|
return annotation == 0 ? this.hashCode() - other.hashCode() : annotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
package de.wcloudservice.driver.event.annotations;
|
||||||
|
|
||||||
|
public class Priority {
|
||||||
|
|
||||||
|
public static final int HIGHEST = 20;
|
||||||
|
public static final int HIGH = 15;
|
||||||
|
public static final int MEDIUM = 10;
|
||||||
|
public static final int LOW = 5;
|
||||||
|
public static final int LOWEST = 0;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package de.wcloudservice.driver.event.annotations;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Retention(value = RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
public @interface Subscribe {
|
||||||
|
|
||||||
|
int priority() default Priority.MEDIUM;
|
||||||
|
boolean async() default false;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package de.wcloudservice.driver.event.events.group;
|
||||||
|
|
||||||
|
import de.wcloudservice.driver.configuration.group.Group;
|
||||||
|
import de.wcloudservice.driver.event.interfaces.EventAdapter;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CloudGroupCreateEvent extends EventAdapter {
|
||||||
|
|
||||||
|
private final Group group;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package de.wcloudservice.driver.event.events.group;
|
||||||
|
|
||||||
|
import de.wcloudservice.driver.configuration.group.Group;
|
||||||
|
import de.wcloudservice.driver.event.interfaces.EventAdapter;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CloudGroupDeleteEvent extends EventAdapter {
|
||||||
|
|
||||||
|
private final Group group;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package de.wcloudservice.driver.event.events.group;
|
||||||
|
|
||||||
|
import de.wcloudservice.driver.configuration.group.Group;
|
||||||
|
import de.wcloudservice.driver.event.interfaces.EventAdapter;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CloudGroupUpdateEditEvent extends EventAdapter {
|
||||||
|
|
||||||
|
private final Group group;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
package de.wcloudservice.driver.event.events.player;
|
||||||
|
|
||||||
|
import de.wcloudservice.driver.event.interfaces.EventAdapter;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CloudPlayerConnectedEvent extends EventAdapter {
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private final UUID uniqueId;
|
||||||
|
private final String proxy;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package de.wcloudservice.driver.event.events.player;
|
||||||
|
|
||||||
|
import de.wcloudservice.driver.event.interfaces.EventAdapter;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CloudPlayerDisconnectedEvent extends EventAdapter {
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private final UUID uniqueId;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package de.wcloudservice.driver.event.events.player;
|
||||||
|
|
||||||
|
import de.wcloudservice.driver.event.interfaces.EventAdapter;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CloudPlayerSwitchEvent extends EventAdapter {
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private final UUID uniqueId;
|
||||||
|
private final String from;
|
||||||
|
private final String to;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
package de.wcloudservice.driver.event.events.service;
|
||||||
|
|
||||||
|
import de.wcloudservice.driver.event.interfaces.EventAdapter;
|
||||||
|
import de.wcloudservice.driver.process.ServiceState;
|
||||||
|
import de.wcloudservice.driver.storage.service.RunningService;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CloudProxyChangeStateEvent extends EventAdapter {
|
||||||
|
|
||||||
|
private final String service;
|
||||||
|
private final ServiceState state;
|
||||||
|
private final String daemon;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package de.wcloudservice.driver.event.events.service;
|
||||||
|
|
||||||
|
import de.wcloudservice.driver.event.interfaces.EventAdapter;
|
||||||
|
import de.wcloudservice.driver.storage.service.RunningService;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CloudProxyConnectedEvent extends EventAdapter {
|
||||||
|
|
||||||
|
private final RunningService service;
|
||||||
|
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user