Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
shulng committed Jul 12, 2024
1 parent ecfbd07 commit 51a87b0
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 24 deletions.
20 changes: 20 additions & 0 deletions a.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import os

def change_extension_in_directory(directory, old_ext, new_ext):
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith(old_ext):
# 构造原始文件的完整路径
original_path = os.path.join(root, file)
# 构造新的文件名
new_name = file[:-len(old_ext)] + new_ext
new_path = os.path.join(root, new_name)
# 重命名文件
os.rename(original_path, new_path)
print(f'Renamed "{original_path}" to "{new_path}"')

# 使用示例
current_directory = '.' # 当前目录
old_extension = '.java'
new_extension = '.kt'
change_extension_in_directory(current_directory, old_extension, new_extension)
55 changes: 31 additions & 24 deletions src/main/java/cc/baka9/catseedlogin/bukkit/Communication.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
package cc.baka9.catseedlogin.bukkit;

import cc.baka9.catseedlogin.bukkit.database.Cache;
import cc.baka9.catseedlogin.bukkit.object.LoginPlayer;
import cc.baka9.catseedlogin.bukkit.object.LoginPlayerHelper;
import cc.baka9.catseedlogin.util.CommunicationAuth;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
Expand All @@ -15,6 +8,14 @@
import java.net.Socket;
import java.net.UnknownHostException;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

import cc.baka9.catseedlogin.bukkit.database.Cache;
import cc.baka9.catseedlogin.bukkit.object.LoginPlayer;
import cc.baka9.catseedlogin.bukkit.object.LoginPlayerHelper;
import cc.baka9.catseedlogin.util.CommunicationAuth;

/**
* bukkit 与 bc 的通讯交流
*/
Expand Down Expand Up @@ -75,24 +76,30 @@ private static void socketServerStart() {
/**
* 处理请求
*/
private static void handleRequest(Socket socket) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String requestType = bufferedReader.readLine();
String playerName = bufferedReader.readLine();
switch (requestType) {
case "Connect":
handleConnectRequest(socket, playerName);
break;
case "KeepLoggedIn":
String time = bufferedReader.readLine();
String sign = bufferedReader.readLine();
handleKeepLoggedInRequest(playerName, time, sign);
socket.close();
break;
default:
break;
}
private static void handleRequest(Socket socket) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String requestType = bufferedReader.readLine();
String playerName = bufferedReader.readLine();
switch (requestType) {
case "Connect":
handleConnectRequest(socket, playerName);
break;
case "KeepLoggedIn":
String time = bufferedReader.readLine();
String sign = bufferedReader.readLine();
handleKeepLoggedInRequest(playerName, time, sign);
socket.close();
break;
default:
break;
}

if (playerName != null) {
playerName.hashCode();
} else {
// 处理空值情况,例如打印日志或返回默认值
}
}

private static void handleKeepLoggedInRequest(String playerName, String time, String sign) {
// 验证请求的合法性
Expand Down

0 comments on commit 51a87b0

Please sign in to comment.