Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
realJustinLee committed Dec 14, 2024
1 parent 7955811 commit 118528b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 31 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ anytime, anywhere. You can also quickly deploy a custom LiMe server for private
- JDK 23
> This project is compiled with Temurin.
> ```
> openjdk 23 2024-09-17
> OpenJDK Runtime Environment Temurin-23+37 (build 23+37)
> OpenJDK 64-Bit Server VM Temurin-23+37 (build 23+37, mixed mode, sharing)
> openjdk 23.0.1 2024-10-15
> OpenJDK Runtime Environment Temurin-23.0.1+11 (build 23.0.1+11)
> OpenJDK 64-Bit Server VM Temurin-23.0.1+11 (build 23.0.1+11, mixed mode, sharing)
> ```
> If you would like to adapt this project to business use.
> Please use this project with `Temurin`, `Microsoft OpenJDK`, `OpenJDK` or any Non-Oracle JDK, Thanks.
Expand Down
1 change: 1 addition & 0 deletions src/com/justin/deprecated/LiMeSeed2LiMe.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*
* @author Justin Lee
*/
@Deprecated
public class LiMeSeed2LiMe extends LiMeSeed {
/**
* @param action 命令
Expand Down
1 change: 1 addition & 0 deletions src/com/justin/deprecated/LiMeTextFieldHintListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/**
* @author Justin Lee
*/
@Deprecated
public class LiMeTextFieldHintListener implements FocusListener {
private final String hintText;
private final JTextField textField;
Expand Down
10 changes: 5 additions & 5 deletions src/com/justin/lime/client/controller/LiMeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ public void newFriendList(LiMeSeed seed) {

@Override
public synchronized void newLiMeFile(LiMeSeed seed) {
// recv and store the file
// receive and store the file
LiMeSeedFile seedFile = (LiMeSeedFile) seed;
File fileRecv = seedFile.getFile();
File fileReceive = seedFile.getFile();
// 选择路径
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
Expand All @@ -325,14 +325,14 @@ public synchronized void newLiMeFile(LiMeSeed seed) {
}
try {
// 如果文件不存在就创建
File fileDest = new File(folder.getAbsolutePath() + "/" + fileRecv.getName());
File fileDest = new File(folder.getAbsolutePath() + "/" + fileReceive.getName());
System.out.println(fileDest.getAbsolutePath());
if (!fileDest.exists()) {
boolean res = fileDest.createNewFile();
}
// 写入文件
try (FileChannel outputChannel = new FileOutputStream(fileDest).getChannel()) {
try (FileChannel inputChannel = new FileInputStream(fileRecv).getChannel()) {
try (FileChannel inputChannel = new FileInputStream(fileReceive).getChannel()) {
outputChannel.transferFrom(inputChannel, 0, inputChannel.size());
}
}
Expand All @@ -343,7 +343,7 @@ public synchronized void newLiMeFile(LiMeSeed seed) {
String time = getLiMeTime();
HashMap<String, String> history = chatFrame.getHistory();
String sender = seed.getSender();
String msgLog = history.get(sender) + "< " + sender + " > | < " + time + " >\n" + fileRecv.getName() + "\n\n";
String msgLog = history.get(sender) + "< " + sender + " > | < " + time + " >\n" + fileReceive.getName() + "\n\n";
history.put(sender, msgLog);
// Update UI from history
chatFrame.updateTextAreaHistory();
Expand Down
40 changes: 17 additions & 23 deletions src/com/justin/lime/protocol/util/factory/LiMeExceptionFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,23 @@ public class LiMeExceptionFactory {
* ERROR_UNKNOWN 未知错误
*/
public static LiMeException newLiMeException(int errorCode) {
switch (errorCode) {
case ERROR_ADMIN_BANNED:
return new LiMeException("账号被被封禁", "您因违反 " + THE_BRAND + " 用户协议,账号已被永久封禁");
case ERROR_ADMIN_KICKED:
return new LiMeException("账号被踢", "您已被 " + THE_BRAND + " 管理员从服务器中移除");
case ERROR_CONFIG_FILE:
return new LiMeException("无法创建或修改设置文件", "无法创建或修改设置文件");
case ERROR_UPDATE_CONFIG:
return new LiMeException("Config File Not Initiated", "Please amend the config file");
case ERROR_REGISTER_CONFLICT:
return new LiMeException("注册信息冲突", "您的用户名或者邮箱已被用于注册 " + THE_BRAND);
case ERROR_LOGIN_CONFLICT:
return new LiMeException("重复登录", "您已在另一计算机上登录 " + THE_BRAND);
case ERROR_LOGIN_PASSWORD:
return new LiMeException("用户名或密码错误", "请输入正确的用户名和密码");
case ERROR_CONNECTION:
return new LiMeException("连接错误", THE_BRAND + " 找不到服务器,请检查网络连接\n" +
"正在使用的服务器地址为 <" + URL_LIME_HOMEPAGE + "> 如需自建服务器请参阅官网文档");
case ERROR_UNKNOWN:
return new LiMeException("未知错误", THE_BRAND + " 发生了一个未知错误");
default:
return switch (errorCode) {
case ERROR_ADMIN_BANNED ->
new LiMeException("账号被被封禁", "您因违反 " + THE_BRAND + " 用户协议,账号已被永久封禁");
case ERROR_ADMIN_KICKED -> new LiMeException("账号被踢", "您已被 " + THE_BRAND + " 管理员从服务器中移除");
case ERROR_CONFIG_FILE -> new LiMeException("无法创建或修改设置文件", "无法创建或修改设置文件");
case ERROR_UPDATE_CONFIG -> new LiMeException("Config File Not Initiated", "Please amend the config file");
case ERROR_REGISTER_CONFLICT ->
new LiMeException("注册信息冲突", "您的用户名或者邮箱已被用于注册 " + THE_BRAND);
case ERROR_LOGIN_CONFLICT -> new LiMeException("重复登录", "您已在另一计算机上登录 " + THE_BRAND);
case ERROR_LOGIN_PASSWORD -> new LiMeException("用户名或密码错误", "请输入正确的用户名和密码");
case ERROR_CONNECTION -> new LiMeException("连接错误", THE_BRAND + " 找不到服务器,请检查网络连接\n" +
"正在使用的服务器地址为 <" + URL_LIME_HOMEPAGE + "> 如需自建服务器请参阅官网文档");
case ERROR_UNKNOWN -> new LiMeException("未知错误", THE_BRAND + " 发生了一个未知错误");
default -> {
limeInternalError(LiMeExceptionFactory.class.getCanonicalName(), String.valueOf(errorCode));
return new LiMeException("未知错误", THE_BRAND + " 发生了一个未知错误");
}
yield new LiMeException("未知错误", THE_BRAND + " 发生了一个未知错误");
}
};
}
}

0 comments on commit 118528b

Please sign in to comment.