Skip to content

Commit 7281244

Browse files
authored
Merge pull request #1 from DomiIRL/feat/1.2
Release v1.2
2 parents 363f8b6 + c9d6d04 commit 7281244

File tree

59 files changed

+1695
-299
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1695
-299
lines changed

.github/workflows/build.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: build
2+
on: [pull_request, push]
3+
jobs:
4+
build:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- name: checkout repository
8+
uses: actions/checkout@v2
9+
- name: setup jdk 21
10+
uses: actions/setup-java@v4
11+
with:
12+
distribution: temurin
13+
java-version: 21
14+
- name: Exec flag
15+
run: chmod +x ./gradlew
16+
- name: build
17+
run: ./gradlew build --stacktrace
18+
- name: capture build artifacts
19+
uses: actions/upload-artifact@v4
20+
with:
21+
name: Artifacts
22+
# only include non javadoc and non-source jars
23+
path: |
24+
build/libs/*.jar
25+
!build/libs/*-javadoc.jar
26+
!build/libs/*-sources.jar

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ libs/
1616

1717
### Local Server ###
1818
/Server/
19+
/run/
1920

2021
### IntelliJ IDEA ###
2122
.idea

build.gradle

Lines changed: 60 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,85 @@
11
plugins {
22
id 'java'
3-
id 'com.gradleup.shadow' version '9.3.1'
3+
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.3'
44
}
55

6-
group = 'dev.svrt.dominik'
7-
version = '1.1'
6+
ext {
7+
if (System.getProperty("os.name").toLowerCase().contains("win")) {
8+
hytaleHome = "${System.getProperty("user.home")}/AppData/Roaming/Hytale"
9+
} else {
10+
hytaleHome = "${System.getProperty("user.home")}/.var/app/com.hypixel.HytaleLauncher/data/Hytale"
11+
}
12+
}
813

914
java {
10-
toolchain {
11-
languageVersion = JavaLanguageVersion.of(25)
12-
}
15+
toolchain.languageVersion = JavaLanguageVersion.of(java_version)
16+
withSourcesJar()
17+
withJavadocJar()
18+
}
19+
20+
// Quiet warnings about missing Javadocs.
21+
javadoc {
22+
options.addStringOption('Xdoclint:-missing', '-quiet')
1323
}
1424

1525
repositories {
1626
mavenCentral()
27+
maven {
28+
name = 'HytaleRepo'
29+
url = uri('https://maven.hytale.com/release')
30+
}
1731
}
1832

33+
// Adds the Hytale server as a build dependency, allowing you to reference and
34+
// compile against their code. This requires you to have Hytale installed using
35+
// the official launcher for now.
1936
dependencies {
20-
// Local HytaleServer dependency
21-
compileOnly files('libs/HytaleServer.jar')
37+
implementation('com.hypixel.hytale:Server:+')
2238
}
2339

24-
// Configure the JAR task
25-
jar {
26-
archiveFileName = "${project.name}-${project.version}.jar"
40+
// Create the working directory to run the server if it does not already exist.
41+
def serverRunDir = file("$projectDir/run")
42+
if (!serverRunDir.exists()) {
43+
serverRunDir.mkdirs()
2744
}
2845

29-
// Configure Shadow JAR to create a single JAR with resources
30-
shadowJar {
31-
archiveFileName = "${project.name}-${project.version}.jar"
32-
archiveClassifier = ''
33-
34-
// Exclude the HytaleServer from being bundled
35-
dependencies {
36-
exclude(dependency(files('libs/HytaleServer.jar')))
37-
}
38-
}
39-
40-
// Make build task use shadowJar
41-
build.dependsOn shadowJar
42-
43-
// Task to run the Hytale server
44-
tasks.register('runServer', Exec) {
45-
description = 'Builds plugin, deploys to Server/mods and starts the Hytale server'
46-
group = 'application'
47-
48-
dependsOn build
49-
50-
workingDir = file('Server')
51-
commandLine 'java', '-jar', '../libs/HytaleServer.jar', '--assets', '../libs/Assets.zip'
52-
53-
// Enable interactive console
54-
standardInput = System.in
55-
standardOutput = System.out
56-
errorOutput = System.err
57-
58-
doFirst {
59-
// Ensure Server/mods directory exists
60-
def modsDir = file('Server/mods')
61-
modsDir.mkdirs()
62-
63-
// Copy the built JAR to Server/mods
64-
def sourceJar = file("build/libs/${project.name}-${project.version}.jar")
65-
if (sourceJar.exists()) {
66-
copy {
67-
from sourceJar
68-
into modsDir
69-
}
70-
println "Copied ${sourceJar.name} to ${modsDir.absolutePath}"
71-
} else {
72-
println "Warning: Built JAR not found at ${sourceJar}"
46+
// Updates the manifest.json file with the latest properties defined in the
47+
// build.properties file. Currently we update the version and if packs are
48+
// included with the plugin.
49+
tasks.register('updatePluginManifest') {
50+
def manifestFile = file('src/main/resources/manifest.json')
51+
doLast {
52+
if (!manifestFile.exists()) {
53+
throw new GradleException("Could not find manifest.json at ${manifestFile.path}!")
7354
}
74-
75-
println "Starting Hytale Server..."
76-
println "Working directory: ${workingDir.absolutePath}"
77-
println "Command: java -jar ../libs/HytaleServer.jar --assets ../libs/Assets.zip"
55+
def manifestJson = new groovy.json.JsonSlurper().parseText(manifestFile.text)
56+
manifestJson.Version = version
57+
manifestJson.IncludesAssetPack = includes_pack.toBoolean()
58+
manifestFile.text = groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(manifestJson))
7859
}
7960
}
8061

81-
// Task to just deploy the plugin without running the server
82-
tasks.register('deployPlugin') {
83-
description = 'Copies the built plugin JAR to Server/mods folder'
84-
group = 'deployment'
85-
86-
dependsOn build
87-
88-
doLast {
89-
def modsDir = file('Server/mods')
90-
modsDir.mkdirs()
62+
// Makes sure the plugin manifest is up to date.
63+
tasks.named('processResources') {
64+
dependsOn 'updatePluginManifest'
65+
}
9166

92-
def sourceJar = file("build/libs/${project.name}-${project.version}.jar")
93-
if (sourceJar.exists()) {
94-
copy {
95-
from sourceJar
96-
into modsDir
97-
}
98-
println "Plugin deployed to ${modsDir.absolutePath}"
99-
} else {
100-
println "Warning: Built JAR not found at ${sourceJar}"
67+
// Creates a run configuration in IDEA that will run the Hytale server with
68+
// your plugin and the default assets.
69+
idea.project.settings.runConfigurations {
70+
'HytaleServer'(org.jetbrains.gradle.ext.Application) {
71+
mainClass = 'com.hypixel.hytale.Main'
72+
moduleName = project.idea.module.name + '.main'
73+
programParameters = "--allow-op --assets=$hytaleHome/install/$patchline/package/game/latest/Assets.zip"
74+
if (includes_pack.toBoolean()) {
75+
programParameters += " --mods=${sourceSets.main.java.srcDirs.first().parentFile.absolutePath}"
76+
}
77+
if (load_user_mods.toBoolean()) {
78+
programParameters += " --mods=$hytaleHome/UserData/Mods"
10179
}
80+
if (use_insecure_auth.toBoolean()) {
81+
programParameters += " --auth-mode=insecure"
82+
}
83+
workingDirectory = serverRunDir.absolutePath
10284
}
10385
}
104-
105-
106-
107-
108-

gradle.properties

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
1-
org.gradle.jvmargs=-Xmx4096m
2-
org.gradle.parallel=true
3-
org.gradle.caching=true
1+
# The current version of your project. Please use semantic versioning!
2+
version=1.2
43

4+
# The group ID used for maven publishing. Usually the same as your package name
5+
# but not the same as your plugin group!
6+
maven_group=dev.svrt.dominik
7+
8+
# The version of Java used by your plugin. The game is built on Java 21 but
9+
# actually runs on Java 25.
10+
java_version=25
11+
12+
# Determines if your plugin should also be loaded as an asset pack. If your
13+
# pack contains assets, or you intend to use the in-game asset editor, you
14+
# want this to be true.
15+
includes_pack=true
16+
17+
# The release channel your plugin should be built and ran against. This is
18+
# usually release or pre-release. You can verify your settings in the
19+
# official launcher.
20+
patchline=release
21+
22+
# Determines if the development server should also load mods from the user's
23+
# standard mods folder. This lets you test mods by installing them where a
24+
# normal player would, instead of adding them as dependencies or adding them
25+
# to the development server manually.
26+
load_user_mods=false
27+
28+
# Determines if the insecure auth mode should be used when authenticating
29+
# connections to the development server. There are some scenarios where
30+
# this may be required.
31+
use_insecure_auth=false

src/main/java/dev/svrt/dominik/warpbook/WarpBookMod.java

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
11
package dev.svrt.dominik.warpbook;
22

3+
import com.hypixel.hytale.codec.Codec;
4+
import com.hypixel.hytale.component.ComponentRegistryProxy;
35
import com.hypixel.hytale.logger.HytaleLogger;
6+
import com.hypixel.hytale.server.core.event.events.BootEvent;
47
import com.hypixel.hytale.server.core.modules.interaction.interaction.config.Interaction;
58
import com.hypixel.hytale.server.core.modules.interaction.interaction.config.server.OpenCustomUIInteraction;
69
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
710
import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
811
import com.hypixel.hytale.server.core.plugin.registry.CodecMapRegistry;
12+
import com.hypixel.hytale.component.ComponentType;
13+
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
914
import com.hypixel.hytale.server.core.util.Config;
15+
import dev.svrt.dominik.warpbook.components.WarpPageTeleporter;
1016
import dev.svrt.dominik.warpbook.config.WarpBookConfig;
1117
import dev.svrt.dominik.warpbook.interactions.OpenWarpBookInteraction;
1218
import dev.svrt.dominik.warpbook.interactions.TeleportWarpPageInteraction;
19+
import dev.svrt.dominik.warpbook.interactions.WarpPageTeleporterInteraction;
20+
import dev.svrt.dominik.warpbook.listener.RandomWarpPagesDropListAdder;
1321
import dev.svrt.dominik.warpbook.services.*;
1422
import dev.svrt.dominik.warpbook.systems.TeleportCancelSystem;
1523
import dev.svrt.dominik.warpbook.ui.BindWarpPageUISupplier;
1624
import dev.svrt.dominik.warpbook.ui.WarpBookUISupplier;
25+
import dev.svrt.dominik.warpbook.ui.WarpPageTeleporterUISupplier;
1726

1827
import javax.annotation.Nonnull;
19-
import java.util.logging.Level;
2028

2129
public class WarpBookMod extends JavaPlugin {
2230

2331
public static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
32+
public static ComponentType<ChunkStore, WarpPageTeleporter> TELEPORTER_COMPONENT_TYPE;
2433

2534
private static WarpBookMod instance;
2635

@@ -30,6 +39,7 @@ public class WarpBookMod extends JavaPlugin {
3039
private WarpPageUsageService warpPageUsageService;
3140
private WarpBookService warpBookService;
3241
private TeleportationService teleportationService;
42+
private RandomDestinationService randomDestinationService;
3343
private PaymentService paymentService;
3444

3545
public WarpBookMod(@Nonnull JavaPluginInit init) {
@@ -45,19 +55,33 @@ protected void setup() {
4555
this.warpPageBindingService = new WarpPageBindingService();
4656
this.warpPageUsageService = new WarpPageUsageService();
4757
this.warpBookService = new WarpBookService();
58+
this.randomDestinationService = new RandomDestinationService();
4859
this.teleportationService = new TeleportationService();
4960
this.paymentService = new PaymentService();
5061

62+
ComponentRegistryProxy<ChunkStore> chunkStoreRegistry = getChunkStoreRegistry();
63+
TELEPORTER_COMPONENT_TYPE = chunkStoreRegistry.registerComponent(WarpPageTeleporter.class, "AWBWarpPageTeleporter", WarpPageTeleporter.CODEC);
64+
5165
CodecMapRegistry.Assets<Interaction, ?> interactionRegistry = getCodecRegistry(Interaction.CODEC);
52-
interactionRegistry.register("TeleportWarpPageInteraction", TeleportWarpPageInteraction.class, TeleportWarpPageInteraction.CODEC);
53-
interactionRegistry.register("OpenWarpBookInteraction", OpenWarpBookInteraction.class, OpenWarpBookInteraction.CODEC);
66+
interactionRegistry.register("AWBTeleportWarpPage", TeleportWarpPageInteraction.class, TeleportWarpPageInteraction.CODEC);
67+
interactionRegistry.register("AWBOpenWarpBook", OpenWarpBookInteraction.class, OpenWarpBookInteraction.CODEC);
68+
interactionRegistry.register("AWBWarpPageTeleporter", WarpPageTeleporterInteraction.class, WarpPageTeleporterInteraction.CODEC);
69+
70+
CodecMapRegistry<OpenCustomUIInteraction.CustomPageSupplier, Codec<? extends OpenCustomUIInteraction.CustomPageSupplier>> customPageRegistry = getCodecRegistry(OpenCustomUIInteraction.PAGE_CODEC);
71+
customPageRegistry.register("AWBWarpBook", WarpBookUISupplier.class, WarpBookUISupplier.CODEC);
72+
customPageRegistry.register("AWBBindWarpPage", BindWarpPageUISupplier.class, BindWarpPageUISupplier.CODEC);
73+
customPageRegistry.register("AWBWarpPageTeleporter", WarpPageTeleporterUISupplier.class, WarpPageTeleporterUISupplier.CODEC);
5474

55-
getCodecRegistry(OpenCustomUIInteraction.PAGE_CODEC).register("Warp_Book_UI", WarpBookUISupplier.class, WarpBookUISupplier.CODEC);
56-
getCodecRegistry(OpenCustomUIInteraction.PAGE_CODEC).register("Bind_Warp_Page_UI", BindWarpPageUISupplier.class, BindWarpPageUISupplier.CODEC);
75+
getEventRegistry().registerGlobal(BootEvent.class, RandomWarpPagesDropListAdder::onBoot);
76+
77+
LOGGER.atInfo().log("Warp Book plugin loaded!");
78+
}
5779

80+
@Override
81+
protected void start() {
5882
getEntityStoreRegistry().registerSystem(new TeleportCancelSystem());
5983

60-
LOGGER.at(Level.INFO).log("Warp Book plugin loaded!");
84+
LOGGER.atInfo().log("Warp Book plugin started!");
6185
}
6286

6387
@Override
@@ -85,11 +109,15 @@ public TeleportationService getTeleportationService() {
85109
return teleportationService;
86110
}
87111

112+
public RandomDestinationService getRandomDestinationService() {
113+
return randomDestinationService;
114+
}
115+
88116
public PaymentService getPaymentService() {
89117
return paymentService;
90118
}
91119

92120
public static WarpBookMod getInstance() {
93121
return instance;
94122
}
95-
}
123+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package dev.svrt.dominik.warpbook.components;
2+
3+
import com.hypixel.hytale.codec.builder.BuilderCodec;
4+
import com.hypixel.hytale.component.Component;
5+
import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
6+
import dev.svrt.dominik.warpbook.data.WarpPageBinding;
7+
8+
import javax.annotation.Nonnull;
9+
import javax.annotation.Nullable;
10+
11+
public class WarpPageTeleporter implements Component<ChunkStore> {
12+
13+
@Nullable
14+
private WarpPageBinding warpPageBinding;
15+
16+
public static final BuilderCodec<WarpPageTeleporter> CODEC = BuilderCodec.builder(WarpPageTeleporter.class, WarpPageTeleporter::new)
17+
.append(WarpPageBinding.KEYED_CODEC, (c, v) -> c.warpPageBinding = v, c -> c.warpPageBinding)
18+
.add()
19+
.build();
20+
21+
@Nonnull
22+
@Override
23+
public Component<ChunkStore> clone() {
24+
WarpPageTeleporter warpPageTeleporter = new WarpPageTeleporter();
25+
if (this.warpPageBinding != null) {
26+
warpPageTeleporter.warpPageBinding = this.warpPageBinding.clone();
27+
}
28+
return warpPageTeleporter;
29+
}
30+
}
31+

0 commit comments

Comments
 (0)