Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,33 @@
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>1.9.23</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<args>
<arg>-Xjvm-default=all</arg>
</args>
<jvmTarget>1.8</jvmTarget>
</configuration>
</plugin>

<plugin>
Expand Down Expand Up @@ -286,9 +313,9 @@
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<groupId>net.dmulloy2</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.4.0</version>
<version>5.4.0</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -297,16 +324,10 @@
<version>1.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>lk.vexview</groupId>
<artifactId>VexView</artifactId>
<version>2.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.10.9</version>
<version>2.11.6</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/Br/API/ActionBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ public static void sendActionBar(Player p, String msg) {
} catch (Throwable e) {
pc.getBytes().write(0, (byte) 2);
}
try {
pm.sendServerPacket(p, pc);
} catch (InvocationTargetException ex) {
Logger.getLogger(ActionBar.class.getName()).log(Level.SEVERE, null, ex);
}
pm.sendServerPacket(p, pc);
}

}
90 changes: 0 additions & 90 deletions src/main/java/Br/API/Data/ProxyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/
package Br.API.Data;

import Br.API.Scripts.ScriptLoader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
Expand All @@ -26,7 +25,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.script.ScriptException;
import jdk.nashorn.api.scripting.NashornScriptEngine;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;

Expand Down Expand Up @@ -94,94 +92,6 @@ public static void addProxy(Plugin plugin, Class<? extends ProxyUtil> cls) {
list.add(cls);
}

public static void proxy(Plugin plugin) {
List<Class<? extends ProxyUtil>> list = Proxied.get(plugin.getName());
if (list == null) {
return;
}
File folder = new File(plugin.getDataFolder(), File.separator + "Proxy" + File.separator);
if (!folder.exists()) {
folder.mkdirs();
}
for (Class<? extends ProxyUtil> cls : list) {
if (!cls.isAnnotationPresent(ProxyInfo.class)) {
continue;
}
ProxyInfo pi = cls.getAnnotation(ProxyInfo.class);
File file = Util.getFile(folder, pi.value());
YamlConfiguration config;
if (!file.exists()) {
config = new YamlConfiguration();
} else {
config = YamlConfiguration.loadConfiguration(file);
}
String[] patharr = pi.value().split("\\.");
String root = patharr[patharr.length - 1];
boolean edit = false;
for (Field f : Util.getAllDeclaredFields(cls)) {
if (!Modifier.isStatic(f.getModifiers())) {
continue;
}
f.setAccessible(true);
if (f.isAnnotationPresent(ProxyScript.class)) {
if (!ProxiedScript.class.isAssignableFrom(f.getType())) {
continue;
}
ProxyScript ps = f.getAnnotation(ProxyScript.class);
File jsFile = Util.getJsFile(folder, ps.file());
if (!jsFile.exists()) {
try {
Util.OutputFile(plugin, ps.fromJarFile(), jsFile);
} catch (IOException ex) {
Logger.getLogger(ProxyUtil.class.getName()).log(Level.SEVERE, null, ex);
}
}
ProxiedScript pds = new ProxiedScript() {
private String Function = ps.function();
private NashornScriptEngine Engine = ScriptLoader.evalAsUTF8(plugin, jsFile);

@Override
public Object proxy(Object... args) {
try {
return Engine.invokeFunction(Function, args);
} catch (ScriptException | NoSuchMethodException ex) {
Logger.getLogger(ProxyUtil.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
};
try {
f.set(pds, null);
} catch (IllegalArgumentException | IllegalAccessException ex) {
Logger.getLogger(ProxyUtil.class.getName()).log(Level.SEVERE, null, ex);
}
continue;
}
if (!f.isAnnotationPresent(Proxy.class)) {
continue;
}
Proxy p = f.getAnnotation(Proxy.class);
String path = root + '.' + (p.value().isEmpty() ? f.getName() : p.value());
try {
if (config.contains(path)) {
f.set(config.get(path), null);
} else {
config.set(path, f.get(null));
edit = true;
}
} catch (IllegalArgumentException | IllegalAccessException ex) {
Logger.getLogger(ProxyUtil.class.getName()).log(Level.SEVERE, null, ex);
}
}
if (edit) {
try {
config.save(file);
} catch (IOException ex) {
Logger.getLogger(ProxyUtil.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}

static class Util {

Expand Down
46 changes: 0 additions & 46 deletions src/main/java/Br/API/Scripts/ScriptListener.java

This file was deleted.

34 changes: 0 additions & 34 deletions src/main/java/Br/API/Scripts/ScriptListenerManager.java

This file was deleted.

100 changes: 0 additions & 100 deletions src/main/java/Br/API/Scripts/ScriptLoader.java

This file was deleted.

6 changes: 1 addition & 5 deletions src/main/java/Br/API/SignUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ public void sendSignRequest(Player p, String id) {
PacketContainer pc = new PacketContainer(PacketType.Play.Server.OPEN_SIGN_EDITOR);
Location loc = p.getLocation();
pc.getBlockPositionModifier().write(0, new BlockPosition(loc.getBlockX(), loc.getBlockY() + 1, loc.getBlockZ()));
try {
pm.sendServerPacket(p, pc, false);
} catch (InvocationTargetException ex) {
Logger.getLogger(SignUtils.class.getName()).log(Level.SEVERE, null, ex);
}
pm.sendServerPacket(p, pc, false);
}

private static Map<String, Map.Entry<String, BiConsumer<Player, String>>> Callbacks = new HashMap<>();
Expand Down
Loading