Skip to content

Commit 41d3a8e

Browse files
authored
Add files via upload
1 parent bc53b9b commit 41d3a8e

File tree

11 files changed

+692
-0
lines changed

11 files changed

+692
-0
lines changed

libs/Skript 2.4.1.jar

2.31 MB
Binary file not shown.

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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>me.szumielxd</groupId>
4+
<artifactId>MVdWPlaceholderSK</artifactId>
5+
<version>1.0</version>
6+
<name>MVdWPlaceholderSK</name>
7+
<properties>
8+
<author>szumielxd</author>
9+
<mainClass>me.szumielxd.MVdWPlaceholderSK.MVdWPlaceholderSK</mainClass>
10+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
11+
</properties>
12+
<build>
13+
<plugins>
14+
<plugin>
15+
<groupId>org.apache.maven.plugins</groupId>
16+
<artifactId>maven-compiler-plugin</artifactId>
17+
<version>3.8.1</version>
18+
<configuration>
19+
<source>1.8</source>
20+
<target>1.8</target>
21+
</configuration>
22+
</plugin>
23+
<plugin>
24+
<groupId>org.apache.maven.plugins</groupId>
25+
<artifactId>maven-shade-plugin</artifactId>
26+
<version>1.4</version>
27+
<executions>
28+
<execution>
29+
<phase>package</phase>
30+
<goals>
31+
<goal>shade</goal>
32+
</goals>
33+
</execution>
34+
</executions>
35+
</plugin>
36+
</plugins>
37+
<resources>
38+
<resource>
39+
<directory>src/main/resources</directory>
40+
<filtering>true</filtering>
41+
<includes>
42+
<include>plugin.yml</include>
43+
</includes>
44+
</resource>
45+
<resource>
46+
<directory>src/main/resources</directory>
47+
<filtering>false</filtering>
48+
<excludes>
49+
<exclude>**/*.java</exclude>
50+
<exclude>plugin.yml</exclude>
51+
</excludes>
52+
</resource>
53+
</resources>
54+
</build>
55+
<repositories>
56+
<repository>
57+
<id>destroystokyo-repo</id>
58+
<url>https://repo.destroystokyo.com/content/repositories/snapshots/</url>
59+
</repository>
60+
<repository>
61+
<id>mvdw-software</id>
62+
<name>MVdW Public Repositories</name>
63+
<url>http://repo.mvdw-software.be/content/groups/public/</url>
64+
</repository>
65+
</repositories>
66+
<dependencies>
67+
<dependency>
68+
<groupId>ch.njol</groupId>
69+
<artifactId>Skript</artifactId>
70+
<version>2.4.1</version>
71+
<scope>system</scope>
72+
<systemPath>${project.basedir}/libs/Skript 2.4.1.jar</systemPath>
73+
</dependency>
74+
<dependency>
75+
<groupId>be.maximvdw</groupId>
76+
<artifactId>MVdWPlaceholderAPI</artifactId>
77+
<version>3.1.1-SNAPSHOT</version>
78+
<scope>provided</scope>
79+
</dependency>
80+
<dependency>
81+
<groupId>org.spigotmc</groupId>
82+
<artifactId>spigot</artifactId>
83+
<version>1.9-R0.1-SNAPSHOT</version>
84+
<scope>provided</scope>
85+
</dependency>
86+
</dependencies>
87+
</project>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package me.szumielxd.MVdWPlaceholderSK;
2+
3+
import java.io.IOException;
4+
import java.lang.reflect.Field;
5+
6+
import org.bukkit.plugin.java.JavaPlugin;
7+
8+
import be.maximvdw.placeholderapi.PlaceholderAPI;
9+
import be.maximvdw.placeholderapi.internal.PlaceholderPack;
10+
import ch.njol.skript.Skript;
11+
import ch.njol.skript.SkriptAddon;
12+
13+
public class MVdWPlaceholderSK extends JavaPlugin {
14+
15+
16+
private static MVdWPlaceholderSK instance;
17+
private SkriptAddon addon;
18+
19+
20+
public void onEnable() {
21+
22+
instance = this;
23+
try {
24+
getSkriptInstance();
25+
(this.addon = getSkriptInstance()).loadClasses("me.szumielxd.MVdWPlaceholderSK.skript", "events", "expressions");
26+
} catch (IOException e) {
27+
e.printStackTrace();
28+
}
29+
30+
}
31+
32+
33+
public static MVdWPlaceholderSK getInstance() {
34+
35+
if (instance == null) throw new IllegalStateException();
36+
return instance;
37+
38+
}
39+
40+
41+
public SkriptAddon getSkriptInstance() {
42+
43+
if(addon == null) addon = Skript.registerAddon(this);
44+
return addon;
45+
46+
}
47+
48+
49+
public static boolean isPlaceholderRegistered(String prefix) {
50+
try {
51+
Field f = PlaceholderAPI.class.getDeclaredField("customPlaceholders");
52+
f.setAccessible(true);
53+
PlaceholderPack pack = (PlaceholderPack) f.get(null);
54+
f.setAccessible(false);
55+
return pack.getPlaceholderReplacer("{"+prefix+"}") != null;
56+
} catch (NoSuchFieldException|SecurityException | IllegalArgumentException | IllegalAccessException e) {
57+
e.printStackTrace();
58+
}
59+
return false;
60+
}
61+
62+
63+
public static void unregisterPlaceholder(String prefix) {
64+
try {
65+
Field f = PlaceholderAPI.class.getDeclaredField("customPlaceholders");
66+
f.setAccessible(true);
67+
PlaceholderPack pack = (PlaceholderPack) f.get(null);
68+
pack.removePlaceholder("{"+prefix+"}");
69+
f.setAccessible(false);
70+
} catch (NoSuchFieldException|SecurityException | IllegalArgumentException | IllegalAccessException e) {
71+
e.printStackTrace();
72+
}
73+
}
74+
75+
76+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package me.szumielxd.MVdWPlaceholderSK.placeholderAPI;
2+
3+
import org.bukkit.entity.Player;
4+
import org.bukkit.event.Event;
5+
import org.bukkit.event.HandlerList;
6+
7+
public class MVdWPAPIEvent extends Event {
8+
9+
10+
private static HandlerList handlerList = new HandlerList();
11+
private Player player;
12+
private String identifier;
13+
private String result;
14+
private String prefix;
15+
16+
17+
@Override
18+
public HandlerList getHandlers() {
19+
return handlerList;
20+
}
21+
22+
23+
public static HandlerList getHandlerList() {
24+
return handlerList;
25+
}
26+
27+
public MVdWPAPIEvent(Player p, String prefix, String identifier) {
28+
this.identifier = identifier;
29+
this.player = p;
30+
this.prefix = prefix;
31+
}
32+
33+
public MVdWPAPIEvent(Player p, String prefix, String identifier, boolean async) {
34+
super(async);
35+
this.identifier = identifier;
36+
this.player = p;
37+
this.prefix = prefix;
38+
}
39+
40+
41+
public void setResult(String result) {
42+
this.result = result;
43+
}
44+
45+
46+
public String getResult() {
47+
return this.result;
48+
}
49+
50+
51+
public String getIdentifier() {
52+
return this.identifier;
53+
}
54+
55+
56+
public Player getPlayer() {
57+
return this.player;
58+
}
59+
60+
61+
public String getPrefix() {
62+
return this.prefix;
63+
}
64+
65+
66+
67+
68+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package me.szumielxd.MVdWPlaceholderSK.placeholderAPI;
2+
3+
import org.bukkit.Bukkit;
4+
import be.maximvdw.placeholderapi.PlaceholderReplaceEvent;
5+
import be.maximvdw.placeholderapi.PlaceholderReplacer;
6+
7+
public class MVdWPAPIListener implements PlaceholderReplacer {
8+
9+
10+
private String identifier;
11+
12+
13+
public MVdWPAPIListener(String prefix) {
14+
this.identifier = prefix;
15+
}
16+
17+
18+
@Override
19+
public String onPlaceholderReplace(PlaceholderReplaceEvent e) {
20+
MVdWPAPIEvent event;
21+
if(Bukkit.isPrimaryThread()) {
22+
event = new MVdWPAPIEvent(e.getPlayer(), identifier, e.getPlaceholder());
23+
}else {
24+
event = new MVdWPAPIEvent(e.getPlayer(), identifier, e.getPlaceholder(), true);
25+
}
26+
Bukkit.getPluginManager().callEvent(event);
27+
return event.getResult();
28+
}
29+
30+
}

0 commit comments

Comments
 (0)