Skip to content

Commit 3f4c3a4

Browse files
committed
feat(integration): Import skript dependency + some code
1 parent 9feb5f6 commit 3f4c3a4

5 files changed

Lines changed: 161 additions & 0 deletions

File tree

bukkit-impl/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ repositories {
3838
maven("https://mvn.lumine.io/repository/maven-public/")
3939
maven("https://storehouse.okaeri.eu/repository/maven-public/")
4040
maven("https://repo.faststats.dev/releases")
41+
maven("https://repo.skriptlang.org/releases")
4142
}
4243

4344
dependencies {
@@ -84,6 +85,7 @@ dependencies {
8485
compileOnly(libs.griefdefender)
8586
compileOnly(libs.gsit)
8687
compileOnly(libs.bodyhealth)
88+
compileOnly(libs.skript)
8789

8890
// other
8991
compileOnly(libs.jetbrains.annotations)
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package dev.jsinco.brewery.bukkit.integration.event.skript;
2+
3+
import ch.njol.skript.Skript;
4+
import dev.jsinco.brewery.api.event.EventData;
5+
import dev.jsinco.brewery.api.event.EventProbability;
6+
import dev.jsinco.brewery.api.event.IntegrationEvent;
7+
import dev.jsinco.brewery.api.util.BreweryKey;
8+
import dev.jsinco.brewery.api.util.Holder;
9+
import dev.jsinco.brewery.bukkit.TheBrewingProject;
10+
import dev.jsinco.brewery.bukkit.api.integration.EventIntegration;
11+
import dev.jsinco.brewery.util.ClassUtil;
12+
import net.kyori.adventure.text.Component;
13+
import org.skriptlang.skript.addon.SkriptAddon;
14+
import org.skriptlang.skript.bukkit.lang.eventvalue.EventValueRegistry;
15+
import org.skriptlang.skript.lang.properties.PropertyRegistry;
16+
17+
import java.util.List;
18+
import java.util.Optional;
19+
20+
public class SkriptIntegration implements EventIntegration<SkriptIntegration.SkriptIntegrationEvent> {
21+
22+
23+
@Override
24+
public Class<SkriptIntegrationEvent> eClass() {
25+
return SkriptIntegrationEvent.class;
26+
}
27+
28+
@Override
29+
public List<BreweryKey> listEventKeys() {
30+
return List.of();
31+
}
32+
33+
@Override
34+
public Optional<SkriptIntegrationEvent> convertToEvent(EventData eventData) {
35+
return Optional.empty();
36+
}
37+
38+
@Override
39+
public EventData convertToData(SkriptIntegrationEvent event) {
40+
return null;
41+
}
42+
43+
@Override
44+
public String getId() {
45+
return "skript";
46+
}
47+
48+
@Override
49+
public boolean isEnabled() {
50+
return ClassUtil.exists("org.skriptlang.skript.addon.SkriptAddon");
51+
}
52+
53+
@Override
54+
public void onLoad() {
55+
SkriptAddon skriptAddon = Skript.instance().registerAddon(TheBrewingProject.class, "TheBrewingProject-Skript");
56+
PropertyRegistry propertyRegistry = skriptAddon.registry(PropertyRegistry.class);
57+
propertyRegistry.register()
58+
TbpSyntaxRegistry tbpRegistry = skriptAddon.registry(TbpSyntaxRegistry.class, TbpSyntaxRegistry::new);
59+
EventValueRegistry eventRegistry = skriptAddon.registry(EventValueRegistry.class);
60+
}
61+
62+
public record SkriptIntegrationEvent() implements IntegrationEvent {
63+
64+
@Override
65+
public void run(Holder.Player player) {
66+
67+
}
68+
69+
@Override
70+
public BreweryKey key() {
71+
return null;
72+
}
73+
74+
@Override
75+
public Component displayName() {
76+
return null;
77+
}
78+
79+
@Override
80+
public EventProbability probability() {
81+
return null;
82+
}
83+
}
84+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package dev.jsinco.brewery.bukkit.integration.event.skript;
2+
3+
import ch.njol.skript.Skript;
4+
import ch.njol.skript.lang.Literal;
5+
import ch.njol.skript.lang.SkriptParser;
6+
import dev.jsinco.brewery.api.util.BreweryKey;
7+
import net.kyori.adventure.text.Component;
8+
import org.bukkit.event.Event;
9+
import org.jetbrains.annotations.Nullable;
10+
import org.jetbrains.annotations.UnknownNullability;
11+
import org.skriptlang.skript.lang.entry.EntryContainer;
12+
import org.skriptlang.skript.lang.structure.Structure;
13+
14+
public class TbpSkriptEventStructure extends Structure {
15+
16+
17+
@Override
18+
public String toString(@Nullable Event event, boolean debug) {
19+
return "";
20+
}
21+
22+
@Override
23+
public boolean init(Literal<?>[] args, int matchedPattern, SkriptParser.ParseResult parseResult, @UnknownNullability EntryContainer entryContainer) {
24+
BreweryKey key = null;
25+
Component displayName = null;
26+
for (Literal<?> argument : args) {
27+
Literal<? extends String> converted = argument.getConvertedExpression(String.class);
28+
if (converted == null) {
29+
Skript.error("[TBP] Could not parse argument of event; could not convert value to string.");
30+
return false;
31+
}
32+
}
33+
}
34+
35+
@Override
36+
public boolean load() {
37+
return false;
38+
}
39+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package dev.jsinco.brewery.bukkit.integration.event.skript;
2+
3+
import org.jetbrains.annotations.Unmodifiable;
4+
import org.skriptlang.skript.registration.SyntaxInfo;
5+
import org.skriptlang.skript.registration.SyntaxRegistry;
6+
7+
import java.util.Collection;
8+
import java.util.List;
9+
10+
public class TbpSyntaxRegistry implements SyntaxRegistry {
11+
@Override
12+
public @Unmodifiable <I extends SyntaxInfo<?>> Collection<I> syntaxes(Key<I> key) {
13+
return List.of();
14+
}
15+
16+
@Override
17+
public <I extends SyntaxInfo<?>> void register(Key<I> key, I info) {
18+
19+
}
20+
21+
@Override
22+
public void unregister(SyntaxInfo<?> info) {
23+
24+
}
25+
26+
@Override
27+
public <I extends SyntaxInfo<?>> void unregister(Key<I> key, I info) {
28+
29+
}
30+
31+
@Override
32+
public @Unmodifiable Collection<SyntaxInfo<?>> elements() {
33+
return List.of();
34+
}
35+
}

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ mythic-crucible = { group = "io.lumine", name = "MythicCrucible-Dist", version.r
8585
griefdefender = { group = "com.griefdefender", name = "api", version.ref = "griefdefender" }
8686
gsit = { group = "com.github.gecolay.GSit", name = "core", version.ref = "gsit" }
8787
bodyhealth = { group = "com.github.Mitality", name = "BodyHealth", version = "4.1.0" }
88+
skript = { group = "com.github.SkriptLang", name = "Skript", version = "2.15.0" }
8889
# other
8990
jetbrains-annotations = { group = "org.jetbrains", name = "annotations", version.ref = "jetbrainsAnnotations" }
9091

0 commit comments

Comments
 (0)