Skip to content
This repository has been archived by the owner on Dec 5, 2020. It is now read-only.

Commit

Permalink
english version
Browse files Browse the repository at this point in the history
  • Loading branch information
Arasple committed Jan 15, 2020
1 parent f938b5e commit 12ec33d
Show file tree
Hide file tree
Showing 17 changed files with 345 additions and 279 deletions.
11 changes: 11 additions & 0 deletions UPDATES.md → UPDATES_CN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# TrChat Update Logs #

#### VERSION 1.7
- #### 1.70
- Since: 2020.1.15
- Updates:
- 新增 en_US 语言,默认
- 更新 TabooLib 至 5.14
- 相关配置文件的默认注释更改为英文
- 发布至 SpigotMC
- 修复了 v1.62 中的空指针报错
- 默认情况下关闭云端词库

#### VERSION 1.6
- ##### 1.62
- DATE: 2019.12.1
Expand Down
9 changes: 9 additions & 0 deletions UPDATES_EN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# TrChat Update Logs #

#### VERSION 1.7
- #### 1.70
- Since: 2020.1.15
- Updates:
- Added en_US locale as default
- Update TabooLib to 5.14
- Fixed a error in v1.62
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {

configurations {
group = 'me.arasple.mc.trchat'
version = '1.62-R8'
version = '1.7-R1'

sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand All @@ -27,8 +27,8 @@ repositories {
}

dependencies {
compile 'org.spigotmc:spigot:1.15-R0.1-SNAPSHOT'
compile 'io.izzel.taboolib:TabooLib:5.13:all'
compile 'org.spigotmc:spigot:1.15.1-R0.1-SNAPSHOT'
compile 'io.izzel.taboolib:TabooLib:5.14:all'
compile 'io.izzel.taboolib.loader:TabooLibloader:1.2:all'
compile "org.jetbrains.kotlin:kotlin-stdlib:1.2.41"
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.41"
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/me/arasple/mc/trchat/TrChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
/**
* @author Arasple
*/
@TrChatPlugin.Version(5.13)
@TrChatPlugin.Version(5.14)
public final class TrChat extends TrChatPlugin {

@TInject(state = TInject.State.LOADING, init = "init", active = "load", cancel = "unload")
@TInject(state = TInject.State.STARTING, init = "init", active = "load", cancel = "unload")
private static TrChatLoader loader;

public static double getTrVersion() {
return 1.62;
return 1.7;
}

}
13 changes: 6 additions & 7 deletions src/main/java/me/arasple/mc/trchat/TrChatFiles.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package me.arasple.mc.trchat;

import io.izzel.taboolib.module.config.TConfig;
import io.izzel.taboolib.module.inject.TFunction;
import io.izzel.taboolib.module.inject.TInject;
import io.izzel.taboolib.module.inject.TSchedule;
import me.arasple.mc.trchat.chat.ChatFormats;
import me.arasple.mc.trchat.filter.ChatFilter;
import me.arasple.mc.trchat.func.ChatFunctions;
import org.bukkit.Bukkit;

/**
* @author Arasple
* @date 2019/11/30 9:59
*/
public class TrChatFiles {

@TInject("settings.yml")
@TInject(value = "settings.yml", locale = "LOCALE-PRIORITY")
private static TConfig settings;
@TInject("formats.yml")
private static TConfig formats;
Expand All @@ -25,11 +24,11 @@ public class TrChatFiles {
@TInject("channels.yml")
private static TConfig channels;

@TFunction.Init
@TSchedule
public static void init() {
filter.listener(() -> ChatFilter.loadFilter(false, Bukkit.getConsoleSender())).runListener();
formats.listener(() -> ChatFormats.loadFormats(Bukkit.getConsoleSender())).runListener();
function.listener(() -> ChatFunctions.loadFunctions(Bukkit.getConsoleSender())).runListener();
filter.listener(() -> ChatFilter.loadFilter(false)).runListener();
formats.listener(ChatFormats::loadFormats).runListener();
function.listener(ChatFunctions::loadFunctions).runListener();
}

public static TConfig getSettings() {
Expand Down
53 changes: 10 additions & 43 deletions src/main/java/me/arasple/mc/trchat/TrChatLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import me.arasple.mc.trchat.chat.ChatFormats;
import me.arasple.mc.trchat.filter.ChatFilter;
import me.arasple.mc.trchat.func.ChatFunctions;
import me.arasple.mc.trchat.updater.Updater;
import me.arasple.mc.trchat.utils.Bungees;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;

Expand All @@ -28,66 +30,31 @@ public class TrChatLoader {
"§3 \\/ \\/ \\/ ");

void init() {
if (isAbandoned()) {
return;
}

if (!new File(TrChat.getPlugin().getDataFolder(), "do_not_notify").exists()) {
motd.forEach(l -> Bukkit.getConsoleSender().sendMessage(l));
TLocale.sendToConsole("PLUGIN.LOADED");
}
motd.forEach(l -> Bukkit.getConsoleSender().sendMessage(l));
TLocale.sendToConsole("PLUGIN.LOADED");

if (hookPlaceholderAPI()) {
return;
}

// Updater
Updater.init(TrChat.getPlugin());
// Chat Filter
ChatFilter.loadFilter(true, Bukkit.getConsoleSender());
// Chat Formats
ChatFormats.loadFormats(Bukkit.getConsoleSender());
// Chat Functions
ChatFunctions.loadFunctions(Bukkit.getConsoleSender());
// Bungees
Bungees.init();
}


void load() {
if (!new File(TrChat.getPlugin().getDataFolder(), "do_not_notify").exists()) {
TLocale.sendToConsole("PLUGIN.ENABLED", TrChat.getPlugin().getDescription().getVersion());
}
TLocale.sendToConsole("PLUGIN.ENABLED", TrChat.getPlugin().getDescription().getVersion());
}

void unload() {
if (!new File(TrChat.getPlugin().getDataFolder(), "do_not_notify").exists()) {
TLocale.sendToConsole("PLUGIN.DISABLED");
}
}

/**
* 判断是否为低于 2.0 的旧版本
*
* @return result
*/
private boolean isAbandoned() {
if (new File("plugins/TrChat/functions.yml").exists()) {
Arrays.asList(
"§8--------------------------------------------------",
"§r",
"§8# §4为了您能够顺利升级到 §cTrChat 1.6 §4,",
"§8# §4需要备份并删除旧的 TrChat 文件夹. 然后重新启动",
"§8# §r",
"§8# §4本次将关闭服务器...",
"§r",
"§8--------------------------------------------------"
).forEach(l -> Bukkit.getConsoleSender().sendMessage(l));
try {
Thread.sleep(5 * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Bukkit.shutdown();
return true;
}
return false;
TLocale.sendToConsole("PLUGIN.DISABLED");
}

/**
Expand Down
81 changes: 34 additions & 47 deletions src/main/java/me/arasple/mc/trchat/TrChatPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ public static double getVersion() {
try {
ZipFile zipFile = new ZipFile(libFile);
return NumberConversions.toDouble(readFully(zipFile.getInputStream(zipFile.getEntry("__resources__/version")), StandardCharsets.UTF_8));
} catch (Throwable t) {
t.printStackTrace();
} catch (Throwable ignored) {
}
return -1;
}
Expand All @@ -92,16 +91,11 @@ public static double getVersion() {
*/
public static String[] getNewVersion() {
for (String[] url : URL) {
String read = null;
try {
read = readFromURL(url[0]);
} catch (IOException e) {
e.printStackTrace();
}
if (read == null) {
continue;
}
try {
String read = readFromURL(url[0]);
if (read == null) {
continue;
}
JsonObject jsonObject = (JsonObject) new JsonParser().parse(read);
if (jsonObject.has("tag_name")) {
return new String[]{jsonObject.get("tag_name").getAsString(), url[0], url[1]};
Expand All @@ -113,12 +107,6 @@ public static String[] getNewVersion() {
return null;
}

public static void downloadFromURL(String in, File file) throws Throwable {
InputStream inputStream = new URL(in).openStream();
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
toFile(bufferedInputStream, file);
}

private static boolean downloadFile(String in, File file) {
try (InputStream inputStream = new URL(in).openStream(); BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream)) {
toFile(bufferedInputStream, file);
Expand Down Expand Up @@ -165,10 +153,10 @@ public static String readFully(InputStream inputStream, Charset charset) throws
return new String(readFully(inputStream), charset);
}

public static byte[] readFully(InputStream inputStream) throws IOException {
private static byte[] readFully(InputStream inputStream) throws IOException {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int len;
int len = 0;
while ((len = inputStream.read(buf)) > 0) {
stream.write(buf, 0, len);
}
Expand Down Expand Up @@ -235,7 +223,7 @@ private static void LoadByPlugin() {
plugin.onLoad();
Bukkit.getPluginManager().enablePlugin(plugin);
} catch (Throwable t) {
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c主运行库未完成初始化, 插件停止加载.");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §cThe main runtime is not initialized and the plugin stops loading.");
initFailed = true;
}
}
Expand All @@ -245,7 +233,7 @@ private static File checkLibPlugin() {
for (File plugin : pluginDir.listFiles()) {
if (plugin.getName().endsWith(".jar")) {
PluginDescriptionFile desc = getPluginDescription(plugin);
if (desc != null && desc.getName().equals("TabooLib5")) {
if (desc != null && "TabooLib5".equals(desc.getName())) {
return plugin;
}
}
Expand Down Expand Up @@ -310,14 +298,15 @@ else if (!download()) {
// 如果插件使用不合理的版本则跳过下载防止死循环
// 并跳过插件加载
if (requireVersion > NumberConversions.toDouble(newVersion[0])) {
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c无效的依赖版本...");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §cInvalid dependency version...");
initFailed = true;
return;
}
Bukkit.getConsoleSender().sendMessage("§f[TabooLib] §7正在下载资源文件...");
Bukkit.getConsoleSender().sendMessage("§f[TabooLib] §7Downloading dependencies...");
if (downloadFile(newVersion[2], file(libFile))) {
// 如果资源下载成功则重启服务器
restart();
init();
return;
}
return;
}
Expand All @@ -327,7 +316,7 @@ else if (!download()) {
if (forge) {
// 检查 TabooLib5 是否已经被加载
if (Bukkit.getPluginManager().getPlugin("TabooLib5") == null) {
Bukkit.getConsoleSender().sendMessage("§f[TabooLib] §7检测到当前为 Forge 服务端, 主运行库将以插件模式启动.");
Bukkit.getConsoleSender().sendMessage("§f[TabooLib] §7Forge server. TabooLib will load as plugin...");
// 将 TabooLib 通过插件方式加载到服务端
LoadByPlugin();
}
Expand All @@ -346,7 +335,7 @@ else if (!download()) {
Loader.addPath(libFile);
// 初始化 TabooLib 主类
if (Loader.forName("io.izzel.taboolib.TabooLib", true, Bukkit.class.getClassLoader()) == null) {
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c主运行库未完成初始化, 插件停止加载.");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §cFailed to load.");
initFailed = true;
}
}
Expand All @@ -356,7 +345,7 @@ else if (!download()) {
}

private static boolean download() {
Bukkit.getConsoleSender().sendMessage("§f[TabooLib] §7正在下载资源文件...");
Bukkit.getConsoleSender().sendMessage("§f[TabooLib] §7Downloading TabooLib (Tr Plugin's dependency)...");
String[] newVersion = getNewVersion();
if (newVersion == null || !downloadFile(newVersion[2], file(libFile))) {
close();
Expand All @@ -367,20 +356,20 @@ private static boolean download() {

private static void close() {
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c#################### 错误 ####################");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c#################### ERROR ####################");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c 初始化 §4TabooLib §c失败!");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c 无法获取版本信息或下载时出现错误.");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c Failed to load §4TabooLib §c!");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c Can not get the version information or download error.");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c 请检查服务器的互联网连接是否有效.");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c 手动将 §4TabooLib.jar §c放入服务端根目录.");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c Please check if the server's internet connection is valid.");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c Or drop §4TabooLib.jar §cinto libs folder manually");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c 服务端将在 5 秒后继续启动.");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c Server will restart in 5 secs");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c 下载地址:");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c Download:");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c §4https://github.com/Bkm016/TabooLib/releases");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c#################### 错误 ####################");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c#################### ERROR ####################");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c");
try {
Thread.sleep(5000L);
Expand All @@ -392,15 +381,14 @@ private static void close() {

private static void restart() {
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c#################### 警告 ####################");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §2#################### WARNING ####################");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c 初始化 §4TabooLib §c失败!");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c 当前运行的版本低于插件所需版本.");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c The required §4TabooLib version is higher than the present");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c 已下载最新版.");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c 服务端将在 5 秒后重新启动.");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c The latest TabooLib has been downloaded.");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c Server will restart in 5 secs");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c#################### 警告 ####################");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §2#################### WARNING ####################");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c");
try {
Thread.sleep(5000L);
Expand All @@ -413,14 +401,14 @@ private static void restart() {

private static void restartDuplicate(String name) {
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c#################### 警告 ####################");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c#################### WARNING ####################");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c 请勿将 §4TabooLib 5.0 §c放入插件文件夹中.");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c Do not put §4TabooLib 5.0 §cinto plugins folder.");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c 已删除 §4" + name);
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c 服务端将在 5 秒后重新启动.");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c Deleted §4" + name);
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c Server will restart in 5 secs");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c#################### 警告 ####################");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c#################### WARNING ####################");
Bukkit.getConsoleSender().sendMessage("§4[TabooLib] §c");
try {
Thread.sleep(5000L);
Expand Down Expand Up @@ -562,5 +550,4 @@ public static Class forName(String name, boolean initialize, ClassLoader loader)
return null;
}
}

}
Loading

0 comments on commit 12ec33d

Please sign in to comment.