Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
szumielxd authored Aug 10, 2020
1 parent bc53b9b commit 41d3a8e
Show file tree
Hide file tree
Showing 11 changed files with 692 additions and 0 deletions.
Binary file added libs/Skript 2.4.1.jar
Binary file not shown.
87 changes: 87 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>me.szumielxd</groupId>
<artifactId>MVdWPlaceholderSK</artifactId>
<version>1.0</version>
<name>MVdWPlaceholderSK</name>
<properties>
<author>szumielxd</author>
<mainClass>me.szumielxd.MVdWPlaceholderSK.MVdWPlaceholderSK</mainClass>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>plugin.yml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/*.java</exclude>
<exclude>plugin.yml</exclude>
</excludes>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>destroystokyo-repo</id>
<url>https://repo.destroystokyo.com/content/repositories/snapshots/</url>
</repository>
<repository>
<id>mvdw-software</id>
<name>MVdW Public Repositories</name>
<url>http://repo.mvdw-software.be/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>ch.njol</groupId>
<artifactId>Skript</artifactId>
<version>2.4.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/Skript 2.4.1.jar</systemPath>
</dependency>
<dependency>
<groupId>be.maximvdw</groupId>
<artifactId>MVdWPlaceholderAPI</artifactId>
<version>3.1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.9-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package me.szumielxd.MVdWPlaceholderSK;

import java.io.IOException;
import java.lang.reflect.Field;

import org.bukkit.plugin.java.JavaPlugin;

import be.maximvdw.placeholderapi.PlaceholderAPI;
import be.maximvdw.placeholderapi.internal.PlaceholderPack;
import ch.njol.skript.Skript;
import ch.njol.skript.SkriptAddon;

public class MVdWPlaceholderSK extends JavaPlugin {


private static MVdWPlaceholderSK instance;
private SkriptAddon addon;


public void onEnable() {

instance = this;
try {
getSkriptInstance();
(this.addon = getSkriptInstance()).loadClasses("me.szumielxd.MVdWPlaceholderSK.skript", "events", "expressions");
} catch (IOException e) {
e.printStackTrace();
}

}


public static MVdWPlaceholderSK getInstance() {

if (instance == null) throw new IllegalStateException();
return instance;

}


public SkriptAddon getSkriptInstance() {

if(addon == null) addon = Skript.registerAddon(this);
return addon;

}


public static boolean isPlaceholderRegistered(String prefix) {
try {
Field f = PlaceholderAPI.class.getDeclaredField("customPlaceholders");
f.setAccessible(true);
PlaceholderPack pack = (PlaceholderPack) f.get(null);
f.setAccessible(false);
return pack.getPlaceholderReplacer("{"+prefix+"}") != null;
} catch (NoSuchFieldException|SecurityException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
return false;
}


public static void unregisterPlaceholder(String prefix) {
try {
Field f = PlaceholderAPI.class.getDeclaredField("customPlaceholders");
f.setAccessible(true);
PlaceholderPack pack = (PlaceholderPack) f.get(null);
pack.removePlaceholder("{"+prefix+"}");
f.setAccessible(false);
} catch (NoSuchFieldException|SecurityException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package me.szumielxd.MVdWPlaceholderSK.placeholderAPI;

import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

public class MVdWPAPIEvent extends Event {


private static HandlerList handlerList = new HandlerList();
private Player player;
private String identifier;
private String result;
private String prefix;


@Override
public HandlerList getHandlers() {
return handlerList;
}


public static HandlerList getHandlerList() {
return handlerList;
}

public MVdWPAPIEvent(Player p, String prefix, String identifier) {
this.identifier = identifier;
this.player = p;
this.prefix = prefix;
}

public MVdWPAPIEvent(Player p, String prefix, String identifier, boolean async) {
super(async);
this.identifier = identifier;
this.player = p;
this.prefix = prefix;
}


public void setResult(String result) {
this.result = result;
}


public String getResult() {
return this.result;
}


public String getIdentifier() {
return this.identifier;
}


public Player getPlayer() {
return this.player;
}


public String getPrefix() {
return this.prefix;
}




}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package me.szumielxd.MVdWPlaceholderSK.placeholderAPI;

import org.bukkit.Bukkit;
import be.maximvdw.placeholderapi.PlaceholderReplaceEvent;
import be.maximvdw.placeholderapi.PlaceholderReplacer;

public class MVdWPAPIListener implements PlaceholderReplacer {


private String identifier;


public MVdWPAPIListener(String prefix) {
this.identifier = prefix;
}


@Override
public String onPlaceholderReplace(PlaceholderReplaceEvent e) {
MVdWPAPIEvent event;
if(Bukkit.isPrimaryThread()) {
event = new MVdWPAPIEvent(e.getPlayer(), identifier, e.getPlaceholder());
}else {
event = new MVdWPAPIEvent(e.getPlayer(), identifier, e.getPlaceholder(), true);
}
Bukkit.getPluginManager().callEvent(event);
return event.getResult();
}

}
Loading

0 comments on commit 41d3a8e

Please sign in to comment.