Skip to content

Commit 7f71d04

Browse files
committed
Yeet config since show-emotes is now a Geyser config option
1 parent a38d2cd commit 7f71d04

3 files changed

Lines changed: 2 additions & 63 deletions

File tree

build.gradle.kts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2-
31
plugins {
42
id("java")
5-
id("com.gradleup.shadow") version "9.2.2"
63
}
74

85
group = "org.geysermc.extension.emoteoffhand"
@@ -15,32 +12,19 @@ repositories {
1512

1613
dependencies {
1714
compileOnly("org.geysermc.geyser:api:2.9.0-SNAPSHOT")
18-
19-
implementation("org.yaml:snakeyaml:2.5")
20-
shadow("org.yaml:snakeyaml:2.5")
2115
}
2216

2317
tasks {
2418
named<Jar>("jar") {
2519
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
26-
archiveFileName.set("${project.name}-${project.version}-nonrelocated.jar")
20+
archiveFileName.set("${project.name}.jar")
2721

2822
from({
2923
configurations.runtimeClasspath.get().map { file ->
3024
if (file.isDirectory) file else zipTree(file)
3125
}
3226
}, project.rootProject.file("LICENSE"))
3327
}
34-
35-
val shadowJar = named<ShadowJar>("shadowJar") {
36-
archiveFileName.set("${project.name}.jar")
37-
from(project.rootProject.file("LICENSE"))
38-
relocate("org.yaml.snakeyaml", "org.geysermc.extension.emoteoffhand.shadow.snakeyaml")
39-
}
40-
41-
named("build") {
42-
dependsOn(shadowJar)
43-
}
4428
}
4529

4630
java {

src/main/java/org/geysermc/extension/emoteoffhand/EmoteOffhand.java

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,59 +4,16 @@
44
import org.geysermc.geyser.api.event.bedrock.ClientEmoteEvent;
55
import org.geysermc.geyser.api.event.lifecycle.GeyserPostInitializeEvent;
66
import org.geysermc.geyser.api.extension.Extension;
7-
import org.yaml.snakeyaml.Yaml;
8-
9-
import java.io.FileReader;
10-
import java.io.IOException;
11-
import java.io.InputStream;
12-
import java.nio.file.Files;
13-
import java.nio.file.Path;
14-
import java.util.Map;
157

168
public class EmoteOffhand implements Extension {
17-
private static final Yaml YAML = new Yaml();
18-
19-
private boolean passthroughEmotes = false;
209

2110
@Subscribe
22-
public void onPostInitialize(GeyserPostInitializeEvent event) {
23-
this.logger().info("Loading EmoteOffhand...");
24-
25-
try {
26-
Path configPath = this.dataFolder().resolve("config.yml");
27-
if (Files.notExists(configPath)) createConfig();
28-
Map<String, Object> config = YAML.load(new FileReader(configPath.toFile()));
29-
if (!config.containsKey("passthrough-emotes") || !(config.get("passthrough-emotes") instanceof Boolean)) {
30-
this.logger().warning("Invalid config found! Config will be rewritten.");
31-
createConfig();
32-
} else {
33-
this.passthroughEmotes = (boolean) config.get("passthrough-emotes");
34-
}
35-
} catch (IOException e) {
36-
this.logger().error("Unable to load config! Will use the default config.", e);
37-
}
38-
11+
public void onPostInitialize(GeyserPostInitializeEvent ignored) {
3912
this.logger().info("Loaded EmoteOffhand!");
4013
}
4114

4215
@Subscribe
4316
public void onEmote(ClientEmoteEvent event) {
44-
if (!this.passthroughEmotes) event.setCancelled(true);
45-
4617
event.connection().entities().switchHands();
4718
}
48-
49-
private void createConfig() throws IOException {
50-
if (Files.notExists(this.dataFolder())) Files.createDirectories(this.dataFolder());
51-
Path configPath = this.dataFolder().resolve("config.yml");
52-
53-
InputStream internalConfig = EmoteOffhand.class.getResourceAsStream("/extension-config.yml");
54-
if (internalConfig == null) {
55-
throw new IOException("`extension-config.yml` not found within the JAR file. The extension JAR file may be corrupt.");
56-
}
57-
58-
Files.write(configPath, internalConfig.readAllBytes());
59-
60-
internalConfig.close();
61-
}
6219
}

src/main/resources/extension-config.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)