Compare commits
11 Commits
77b31717f6
...
b7d12fde4d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7d12fde4d | ||
|
|
887468221e | ||
|
|
0d554ed8f3 | ||
|
|
7ce4389085 | ||
|
|
6985b56930 | ||
|
|
8476b14e4e | ||
|
|
b7a10d305b | ||
|
|
3a5f053940 | ||
|
|
f0f2476f06 | ||
|
|
314ff77855 | ||
|
|
bb19417b47 |
22
.github/workflows/gradle.yml
vendored
Normal file
22
.github/workflows/gradle.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
name: Verifying Everything Compiles
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "main" ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ "main" ]
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Set up JDK 25
|
||||||
|
uses: actions/setup-java@v5
|
||||||
|
with:
|
||||||
|
java-version: '25'
|
||||||
|
distribution: 'temurin'
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: gradle/actions/setup-gradle@v5
|
||||||
|
- name: Verify build is not broken
|
||||||
|
run: ./gradlew build
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,3 +9,4 @@ run/
|
|||||||
.classpath
|
.classpath
|
||||||
.project
|
.project
|
||||||
.settings/
|
.settings/
|
||||||
|
.vscode
|
||||||
@@ -41,6 +41,11 @@ repositories {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.named<Jar>("jar") {
|
||||||
|
archiveBaseName.set(project.property("mod_name").toString())
|
||||||
|
archiveVersion.set(project.property("version").toString())
|
||||||
|
}
|
||||||
|
|
||||||
// Uncomment if you are using IntelliJ.
|
// Uncomment if you are using IntelliJ.
|
||||||
// idea {
|
// idea {
|
||||||
// module {
|
// module {
|
||||||
|
|||||||
@@ -3,20 +3,32 @@ package dev.hytalemodding;
|
|||||||
import com.hypixel.hytale.server.core.event.events.player.PlayerReadyEvent;
|
import com.hypixel.hytale.server.core.event.events.player.PlayerReadyEvent;
|
||||||
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
|
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
|
||||||
import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
|
import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
|
||||||
|
import com.hypixel.hytale.server.core.util.Config;
|
||||||
import dev.hytalemodding.commands.ExampleCommand;
|
import dev.hytalemodding.commands.ExampleCommand;
|
||||||
|
import dev.hytalemodding.config.ExampleConfig;
|
||||||
import dev.hytalemodding.events.ExampleEvent;
|
import dev.hytalemodding.events.ExampleEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class ExamplePlugin extends JavaPlugin {
|
public class ExamplePlugin extends JavaPlugin {
|
||||||
|
|
||||||
|
private static Config<ExampleConfig> config = null;
|
||||||
|
|
||||||
public ExamplePlugin(@Nonnull JavaPluginInit init) {
|
public ExamplePlugin(@Nonnull JavaPluginInit init) {
|
||||||
super(init);
|
super(init);
|
||||||
|
config = this.withConfig("example_config", ExampleConfig.CODEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setup() {
|
protected void setup() {
|
||||||
|
config.save();
|
||||||
this.getCommandRegistry().registerCommand(new ExampleCommand("example", "An example command"));
|
this.getCommandRegistry().registerCommand(new ExampleCommand("example", "An example command"));
|
||||||
this.getEventRegistry().registerGlobal(PlayerReadyEvent.class, ExampleEvent::onPlayerReady);
|
if (getConfig().get().isEnabledWelcomeMessage()) {
|
||||||
|
this.getEventRegistry().registerGlobal(PlayerReadyEvent.class, ExampleEvent::onPlayerReady);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Config<ExampleConfig> getConfig() {
|
||||||
|
return config;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
25
src/main/java/dev/hytalemodding/config/ExampleConfig.java
Normal file
25
src/main/java/dev/hytalemodding/config/ExampleConfig.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package dev.hytalemodding.config;
|
||||||
|
|
||||||
|
import com.hypixel.hytale.codec.Codec;
|
||||||
|
import com.hypixel.hytale.codec.KeyedCodec;
|
||||||
|
import com.hypixel.hytale.codec.builder.BuilderCodec;
|
||||||
|
|
||||||
|
public class ExampleConfig {
|
||||||
|
|
||||||
|
public static final BuilderCodec<ExampleConfig> CODEC = BuilderCodec.builder(ExampleConfig.class, ExampleConfig::new)
|
||||||
|
.append(
|
||||||
|
new KeyedCodec<>("EnableWelcomeMessage", Codec.BOOLEAN),
|
||||||
|
(exConfig, aBoolean, extraInfo) -> exConfig.enabledWelcomeMessage = aBoolean,
|
||||||
|
(exConfig, extraInfo) -> exConfig.enabledWelcomeMessage
|
||||||
|
)
|
||||||
|
.add()
|
||||||
|
.build();
|
||||||
|
|
||||||
|
private boolean enabledWelcomeMessage;
|
||||||
|
|
||||||
|
private ExampleConfig() {}
|
||||||
|
|
||||||
|
public boolean isEnabledWelcomeMessage() {
|
||||||
|
return enabledWelcomeMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +1,24 @@
|
|||||||
package dev.hytalemodding.events;
|
package dev.hytalemodding.events;
|
||||||
|
|
||||||
|
import com.hypixel.hytale.component.Ref;
|
||||||
|
import com.hypixel.hytale.component.Store;
|
||||||
import com.hypixel.hytale.server.core.Message;
|
import com.hypixel.hytale.server.core.Message;
|
||||||
import com.hypixel.hytale.server.core.entity.entities.Player;
|
|
||||||
import com.hypixel.hytale.server.core.event.events.player.PlayerReadyEvent;
|
import com.hypixel.hytale.server.core.event.events.player.PlayerReadyEvent;
|
||||||
|
import com.hypixel.hytale.server.core.universe.PlayerRef;
|
||||||
|
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
|
||||||
|
|
||||||
public class ExampleEvent {
|
public class ExampleEvent {
|
||||||
|
|
||||||
public static void onPlayerReady(PlayerReadyEvent event) {
|
public static void onPlayerReady(PlayerReadyEvent event) {
|
||||||
Player player = event.getPlayer();
|
Ref<EntityStore> ref = event.getPlayerRef();
|
||||||
player.sendMessage(Message.raw("Welcome " + player.getDisplayName()));
|
|
||||||
|
if (ref.isValid()) {
|
||||||
|
Store<EntityStore> store = ref.getStore();
|
||||||
|
PlayerRef playerRef = store.getComponent(ref, PlayerRef.getComponentType());
|
||||||
|
if (playerRef != null) {
|
||||||
|
playerRef.sendMessage(Message.raw("Welcome " + playerRef.getUsername()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user