Skip to content

Commit d6c3c82

Browse files
committed
Initial commit
0 parents  commit d6c3c82

18 files changed

+1127
-0
lines changed

.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
!**/src/main/**/target/
4+
!**/src/test/**/target/
5+
6+
### IntelliJ IDEA ###
7+
.idea/modules.xml
8+
.idea/jarRepositories.xml
9+
.idea/compiler.xml
10+
.idea/libraries/
11+
*.iws
12+
*.iml
13+
*.ipr
14+
15+
### Eclipse ###
16+
.apt_generated
17+
.classpath
18+
.factorypath
19+
.project
20+
.settings
21+
.springBeans
22+
.sts4-cache
23+
24+
### NetBeans ###
25+
/nbproject/private/
26+
/nbbuild/
27+
/dist/
28+
/nbdist/
29+
/.nb-gradle/
30+
build/
31+
!**/src/main/**/build/
32+
!**/src/test/**/build/
33+
34+
### VS Code ###
35+
.vscode/
36+
37+
### Mac OS ###
38+
.DS_Store

.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/artifacts/skript_pk.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dependency-reduced-pom.xml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>me.anxelok</groupId>
5+
<artifactId>skript-pk</artifactId>
6+
<name>skript-pk</name>
7+
<version>1.0</version>
8+
<build>
9+
<sourceDirectory>${project.basedir}/src/</sourceDirectory>
10+
<defaultGoal>clean package install</defaultGoal>
11+
<resources>
12+
<resource>
13+
<targetPath>.</targetPath>
14+
<directory>${project.basedir}/src/</directory>
15+
<includes>
16+
<include>**/*.yml</include>
17+
</includes>
18+
</resource>
19+
</resources>
20+
<finalName>${project.name}-${project.version}</finalName>
21+
<plugins>
22+
<plugin>
23+
<artifactId>maven-compiler-plugin</artifactId>
24+
<version>3.8.0</version>
25+
<configuration>
26+
<release>8</release>
27+
</configuration>
28+
</plugin>
29+
<plugin>
30+
<artifactId>maven-shade-plugin</artifactId>
31+
<version>3.5.1</version>
32+
<executions>
33+
<execution>
34+
<phase>package</phase>
35+
<goals>
36+
<goal>shade</goal>
37+
</goals>
38+
<configuration>
39+
<relocations>
40+
<relocation>
41+
<pattern>net.bytebuddy</pattern>
42+
<shadedPattern>me.anxelok.shaded.bytebuddy</shadedPattern>
43+
</relocation>
44+
</relocations>
45+
</configuration>
46+
</execution>
47+
</executions>
48+
<dependencies>
49+
<dependency>
50+
<groupId>org.ow2.asm</groupId>
51+
<artifactId>asm</artifactId>
52+
<version>9.7.1</version>
53+
</dependency>
54+
<dependency>
55+
<groupId>org.ow2.asm</groupId>
56+
<artifactId>asm-commons</artifactId>
57+
<version>9.7.1</version>
58+
</dependency>
59+
</dependencies>
60+
</plugin>
61+
</plugins>
62+
</build>
63+
<repositories>
64+
<repository>
65+
<id>spigot-repo</id>
66+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
67+
</repository>
68+
<repository>
69+
<id>central</id>
70+
<url>https://repo.maven.apache.org/maven2/</url>
71+
</repository>
72+
</repositories>
73+
<pluginRepositories>
74+
<pluginRepository>
75+
<id>central</id>
76+
<url>https://repo.maven.apache.org/maven2/</url>
77+
</pluginRepository>
78+
</pluginRepositories>
79+
<dependencies>
80+
<dependency>
81+
<groupId>org.spigotmc</groupId>
82+
<artifactId>spigot-api</artifactId>
83+
<version>1.15-R0.1-SNAPSHOT</version>
84+
<scope>provided</scope>
85+
</dependency>
86+
<dependency>
87+
<groupId>io.github.skriptlang</groupId>
88+
<artifactId>skript</artifactId>
89+
<version>2.10.1</version>
90+
<scope>provided</scope>
91+
</dependency>
92+
<dependency>
93+
<groupId>com.projectkorra</groupId>
94+
<artifactId>projectkorra</artifactId>
95+
<version>1.11.1</version>
96+
<scope>provided</scope>
97+
</dependency>
98+
</dependencies>
99+
<properties>
100+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
101+
<dir>${project.build.directory}</dir>
102+
</properties>
103+
</project>

pom.xml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
4+
http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>me.anxelok</groupId>
8+
<artifactId>skript-pk</artifactId>
9+
<version>1.0</version>
10+
<packaging>jar</packaging>
11+
<name>skript-pk</name>
12+
13+
<repositories>
14+
<repository>
15+
<id>spigot-repo</id>
16+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
17+
</repository>
18+
<repository>
19+
<id>central</id>
20+
<url>https://repo.maven.apache.org/maven2/</url>
21+
</repository>
22+
</repositories>
23+
24+
<pluginRepositories>
25+
<pluginRepository>
26+
<id>central</id>
27+
<url>https://repo.maven.apache.org/maven2/</url>
28+
</pluginRepository>
29+
</pluginRepositories>
30+
31+
<dependencies>
32+
<!-- Spigot API -->
33+
<dependency>
34+
<groupId>org.spigotmc</groupId>
35+
<artifactId>spigot-api</artifactId>
36+
<version>1.15-R0.1-SNAPSHOT</version>
37+
<scope>provided</scope>
38+
</dependency>
39+
<!-- Skript API -->
40+
<dependency>
41+
<groupId>io.github.skriptlang</groupId>
42+
<artifactId>skript</artifactId>
43+
<version>2.10.1</version>
44+
<scope>provided</scope>
45+
</dependency>
46+
<!-- ProjectKorra -->
47+
<dependency>
48+
<groupId>com.projectkorra</groupId>
49+
<artifactId>projectkorra</artifactId>
50+
<version>1.11.1</version>
51+
<scope>provided</scope>
52+
</dependency>
53+
</dependencies>
54+
55+
<build>
56+
<defaultGoal>clean package install</defaultGoal>
57+
<finalName>${project.name}-${project.version}</finalName>
58+
<sourceDirectory>${project.basedir}/src/</sourceDirectory>
59+
60+
<resources>
61+
<resource>
62+
<directory>${project.basedir}/src/</directory>
63+
<targetPath>.</targetPath>
64+
<includes>
65+
<include>**/*.yml</include>
66+
</includes>
67+
</resource>
68+
</resources>
69+
70+
<plugins>
71+
<!-- Maven Compiler Plugin -->
72+
<plugin>
73+
<groupId>org.apache.maven.plugins</groupId>
74+
<artifactId>maven-compiler-plugin</artifactId>
75+
<version>3.8.0</version>
76+
<configuration>
77+
<release>8</release>
78+
</configuration>
79+
</plugin>
80+
</plugins>
81+
</build>
82+
83+
<properties>
84+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
85+
<dir>${project.build.directory}</dir>
86+
</properties>
87+
</project>

src/me/anxelok/Main.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package me.anxelok;
2+
3+
import ch.njol.skript.Skript;
4+
import ch.njol.skript.SkriptAddon;
5+
import org.bukkit.plugin.java.JavaPlugin;
6+
7+
import java.io.IOException;
8+
9+
public class Main extends JavaPlugin {
10+
11+
@Override
12+
public void onEnable() {
13+
getLogger().info("[Skript-PK] Enabling Skript-PK...");
14+
15+
if (getServer().getPluginManager().getPlugin("Skript") == null) {
16+
getLogger().severe("[Skript-PK] ERROR: Skript not found! Disabling plugin.");
17+
getServer().getPluginManager().disablePlugin(this);
18+
return;
19+
}
20+
if (getServer().getPluginManager().getPlugin("ProjectKorra") == null) {
21+
getLogger().severe("[Skript-PK] ERROR: ProjectKorra not found! Disabling plugin.");
22+
getServer().getPluginManager().disablePlugin(this);
23+
return;
24+
}
25+
26+
getLogger().info("[Skript-PK] Registering ability structure...");
27+
28+
// Register all Skript syntax via the Skript addon system.
29+
getLogger().info("[Skript-PK] Registering Skript syntax...");
30+
SkriptAddon addon = Skript.registerAddon(this);
31+
32+
try {
33+
// Load all classes within the "me.anxelok.syntax" package and its subpackages.
34+
addon.loadClasses("me.anxelok.syntax");
35+
} catch (IOException error) {
36+
error.printStackTrace();
37+
getServer().getPluginManager().disablePlugin(this);
38+
return;
39+
}
40+
}
41+
42+
@Override
43+
public void onDisable() {
44+
getLogger().info("[Skript-PK] Disabling Skript-PK...");
45+
}
46+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package me.anxelok.syntax.conditions;
2+
3+
import ch.njol.skript.Skript;
4+
import ch.njol.skript.doc.*;
5+
import ch.njol.skript.lang.Condition;
6+
import ch.njol.skript.lang.Expression;
7+
import ch.njol.skript.lang.SkriptParser;
8+
import ch.njol.util.Kleenean;
9+
import com.projectkorra.projectkorra.BendingPlayer;
10+
import org.bukkit.entity.Player;
11+
import org.bukkit.event.Event;
12+
import org.jetbrains.annotations.Nullable;
13+
14+
@Name("Bending Toggled")
15+
@Description("Checks if a player's bending is enabled or disabled.")
16+
@Examples({
17+
"if player's bending is on:",
18+
"if player's bending is off:"
19+
})
20+
@Since("1.0")
21+
public class CondBendingToggled extends Condition {
22+
23+
private Expression<Player> playerExpr;
24+
private boolean shouldBeOn; // true if checking for "on", false for "off"
25+
26+
static {
27+
// Register two patterns: one for on, one for off.
28+
Skript.registerCondition(CondBendingToggled.class,
29+
"%player%'s bending is on",
30+
"%player%'s bending is off");
31+
}
32+
33+
@Override
34+
@SuppressWarnings("unchecked")
35+
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) {
36+
playerExpr = (Expression<Player>) exprs[0];
37+
// Using matchedPattern: 0 for "on", 1 for "off"
38+
shouldBeOn = matchedPattern == 0;
39+
return true;
40+
}
41+
42+
@Override
43+
public boolean check(Event e) {
44+
Player player = playerExpr.getSingle(e);
45+
if (player == null) return false;
46+
47+
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
48+
if (bPlayer == null) return false;
49+
50+
return bPlayer.isToggled() == shouldBeOn;
51+
}
52+
53+
@Override
54+
public String toString(@Nullable Event e, boolean debug) {
55+
return playerExpr.toString(e, debug) + "'s bending is " + (shouldBeOn ? "on" : "off");
56+
}
57+
}

0 commit comments

Comments
 (0)