+ exp4j
This commit is contained in:
parent
df51e398b1
commit
4ee0a555aa
6
pom.xml
6
pom.xml
@ -88,6 +88,7 @@
|
|||||||
<include>com.ilummc.eagletdl</include>
|
<include>com.ilummc.eagletdl</include>
|
||||||
<include>org.ow2.asm</include>
|
<include>org.ow2.asm</include>
|
||||||
<include>com.google.code.gson</include>
|
<include>com.google.code.gson</include>
|
||||||
|
<include>net.objecthunter</include>
|
||||||
</includes>
|
</includes>
|
||||||
</artifactSet>
|
</artifactSet>
|
||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||||
@ -154,6 +155,11 @@
|
|||||||
<artifactId>scala-library</artifactId>
|
<artifactId>scala-library</artifactId>
|
||||||
<version>2.12.7</version>
|
<version>2.12.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.objecthunter</groupId>
|
||||||
|
<artifactId>exp4j</artifactId>
|
||||||
|
<version>0.4.8</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>bukkit</groupId>
|
<groupId>bukkit</groupId>
|
||||||
<artifactId>bukkit1_12</artifactId>
|
<artifactId>bukkit1_12</artifactId>
|
||||||
|
@ -302,76 +302,15 @@ public class FileUtils {
|
|||||||
* @param file2 文件2
|
* @param file2 文件2
|
||||||
*/
|
*/
|
||||||
public static void fileChannelCopy(File file1, File file2) {
|
public static void fileChannelCopy(File file1, File file2) {
|
||||||
FileInputStream fileIn = null;
|
try (FileInputStream fileIn = new FileInputStream(file1);
|
||||||
FileOutputStream fileOut = null;
|
FileOutputStream fileOut = new FileOutputStream(file2);
|
||||||
FileChannel channelIn = null;
|
FileChannel channelIn = fileIn.getChannel();
|
||||||
FileChannel channelOut = null;
|
FileChannel channelOut = fileOut.getChannel()) {
|
||||||
try {
|
|
||||||
fileIn = new FileInputStream(file1);
|
|
||||||
fileOut = new FileOutputStream(file2);
|
|
||||||
channelIn = fileIn.getChannel();
|
|
||||||
channelOut = fileOut.getChannel();
|
|
||||||
channelIn.transferTo(0, channelIn.size(), channelOut);
|
channelIn.transferTo(0, channelIn.size(), channelOut);
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
} finally {
|
|
||||||
IOUtils.closeQuietly(channelIn);
|
|
||||||
IOUtils.closeQuietly(channelOut);
|
|
||||||
IOUtils.closeQuietly(fileIn);
|
|
||||||
IOUtils.closeQuietly(fileOut);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过输入流读取文本
|
|
||||||
*
|
|
||||||
* @param in 输入流
|
|
||||||
* @param size 大小
|
|
||||||
* @param encode 编码
|
|
||||||
* @return 文本
|
|
||||||
*/
|
|
||||||
public static String getStringFromInputStream(InputStream in, int size, String encode) {
|
|
||||||
try {
|
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
|
||||||
byte[] b = new byte[size];
|
|
||||||
int i;
|
|
||||||
while ((i = in.read(b)) > 0) {
|
|
||||||
bos.write(b, 0, i);
|
|
||||||
}
|
|
||||||
return new String(bos.toByteArray(), encode);
|
|
||||||
} catch (IOException ignored) {
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过文件读取文本
|
|
||||||
*
|
|
||||||
* @param file 文件
|
|
||||||
* @param size 大小
|
|
||||||
* @param encode 编码
|
|
||||||
* @return 文本
|
|
||||||
*/
|
|
||||||
public static String getStringFromFile(File file, int size, String encode) {
|
|
||||||
FileInputStream fin = null;
|
|
||||||
BufferedInputStream bin = null;
|
|
||||||
try {
|
|
||||||
fin = new FileInputStream(file);
|
|
||||||
bin = new BufferedInputStream(fin);
|
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
|
||||||
byte[] b = new byte[size];
|
|
||||||
int i;
|
|
||||||
while ((i = bin.read(b)) > 0) {
|
|
||||||
bos.write(b, 0, i);
|
|
||||||
}
|
|
||||||
return new String(bos.toByteArray(), encode);
|
|
||||||
} catch (IOException ignored) {
|
|
||||||
} finally {
|
|
||||||
IOUtils.closeQuietly(bin);
|
|
||||||
IOUtils.closeQuietly(fin);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过 URL 读取文本
|
* 通过 URL 读取文本
|
||||||
*
|
*
|
||||||
@ -397,14 +336,9 @@ public class FileUtils {
|
|||||||
try {
|
try {
|
||||||
conn = new URL(url).openConnection();
|
conn = new URL(url).openConnection();
|
||||||
bin = new BufferedInputStream(conn.getInputStream());
|
bin = new BufferedInputStream(conn.getInputStream());
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
return getStringFromInputStream(bin, size, conn.getContentEncoding() == null ? "UTF-8" : conn.getContentEncoding());
|
||||||
byte[] b = new byte[size];
|
} catch (IOException e) {
|
||||||
int i;
|
e.printStackTrace();
|
||||||
while ((i = bin.read(b)) > 0) {
|
|
||||||
bos.write(b, 0, i);
|
|
||||||
}
|
|
||||||
return new String(bos.toByteArray(), conn.getContentEncoding() == null ? "UTF-8" : conn.getContentEncoding());
|
|
||||||
} catch (IOException ignored) {
|
|
||||||
} finally {
|
} finally {
|
||||||
IOUtils.close(conn);
|
IOUtils.close(conn);
|
||||||
IOUtils.closeQuietly(bin);
|
IOUtils.closeQuietly(bin);
|
||||||
@ -412,6 +346,55 @@ public class FileUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过文件读取文本
|
||||||
|
*
|
||||||
|
* @param file 文件
|
||||||
|
* @param size 大小
|
||||||
|
* @param encode 编码
|
||||||
|
* @return 文本
|
||||||
|
*/
|
||||||
|
public static String getStringFromFile(File file, int size, String encode) {
|
||||||
|
try (FileInputStream fin = new FileInputStream(file); BufferedInputStream bin = new BufferedInputStream(fin)) {
|
||||||
|
return getStringFromInputStream(fin, size, encode);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过输入流读取文本
|
||||||
|
*
|
||||||
|
* @param in 输入流
|
||||||
|
* @param size 大小
|
||||||
|
* @param encode 编码
|
||||||
|
* @return 文本
|
||||||
|
*/
|
||||||
|
public static String getStringFromInputStream(InputStream in, int size, String encode) {
|
||||||
|
try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
|
||||||
|
byte[] b = new byte[size];
|
||||||
|
int i;
|
||||||
|
while ((i = in.read(b)) > 0) {
|
||||||
|
bos.write(b, 0, i);
|
||||||
|
}
|
||||||
|
return new String(bos.toByteArray(), encode);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载文件
|
||||||
|
*
|
||||||
|
* @param url 下载地址
|
||||||
|
* @param file 下载位置
|
||||||
|
*/
|
||||||
|
public static void download(String url, File file) {
|
||||||
|
download(url, file, false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载文件
|
* 下载文件
|
||||||
*
|
*
|
||||||
@ -440,10 +423,6 @@ public class FileUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void download(String url, File file) {
|
|
||||||
download(url, file, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void download(String url, String filename, File saveDir) {
|
public static void download(String url, String filename, File saveDir) {
|
||||||
download(url, new File(saveDir, filename));
|
download(url, new File(saveDir, filename));
|
||||||
|
@ -18,7 +18,6 @@ public class ScriptHandler {
|
|||||||
|
|
||||||
private static ScriptEngine scriptEngine;
|
private static ScriptEngine scriptEngine;
|
||||||
private static ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
|
private static ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
|
||||||
private static FileConfiguration scriptsFile;
|
|
||||||
|
|
||||||
public static void inst() {
|
public static void inst() {
|
||||||
try {
|
try {
|
||||||
@ -31,8 +30,7 @@ public class ScriptHandler {
|
|||||||
|
|
||||||
public static CompiledScript compile(String script) {
|
public static CompiledScript compile(String script) {
|
||||||
try {
|
try {
|
||||||
Compilable compilable = (Compilable) scriptEngine;
|
return ((Compilable) scriptEngine).compile(script);
|
||||||
return compilable.compile(script);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
TLogger.getGlobalLogger().info("§4JavaScript §c" + script + "§4 Compile Failed: §c" + e.toString());
|
TLogger.getGlobalLogger().info("§4JavaScript §c" + script + "§4 Compile Failed: §c" + e.toString());
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user