Skip to content

Commit 1df3e48

Browse files
authored
Merge pull request #1 from DOCHIS/develop
Develop
2 parents fca8278 + 01a9920 commit 1df3e48

10 files changed

Lines changed: 146 additions & 243 deletions

File tree

.github/.env.sample

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Anthropic API 키를 입력하세요
2+
# 예시: ANTHROPIC_API_KEY=sk-ant-api03-....-....
3+
ANTHROPIC_API_KEY=your_anthropic_api_key_here
4+
5+
# API 키는 Anthropic 대시보드(https://console.anthropic.com/)에서 발급받을 수 있습니다
6+
# 실제 API 키는 'sk-ant-api03-'으로 시작하며 약 32자의 문자열입니다

README.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,56 @@ commands:
250250

251251
각 동작 유형별 상세 설정은 `config.yml`을 참고해 주세요.
252252

253-
# 📚 의존성
253+
### 로그 설정
254+
255+
| 설정 | 설명 | 기본값 |
256+
| ----------------------- | --------------------- | ------ |
257+
| `logging.enabled` | 로그 저장 활성화 여부 | `true` |
258+
| `logging.save.donation` | 후원 로그 저장 | `true` |
259+
| `logging.save.failure` | 실행 실패 로그 저장 | `true` |
260+
261+
로그는 선택한 저장소 타입(`storage.type`)에 따라 다르게 저장됩니다:
262+
263+
#### YML 저장소 사용 시
264+
265+
- JSON 형식의 텍스트로 저장
266+
- 저장 위치: `plugins/SSApi/logs` 디렉토리
267+
- 날짜별로 파일 구분
268+
269+
#### MySQL 저장소 사용 시
270+
271+
- `api_log` 테이블에 저장
272+
- 테이블 구조:
273+
```sql
274+
CREATE TABLE `api_log` (
275+
`log_no` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
276+
`server_ip` VARCHAR(15) NULL DEFAULT NULL,
277+
`server_name` VARCHAR(100) NULL DEFAULT NULL,
278+
`streamer_id` VARCHAR(100) NULL DEFAULT NULL,
279+
`username` VARCHAR(100) NULL DEFAULT NULL,
280+
`cnt` INT(10) UNSIGNED NULL DEFAULT NULL,
281+
`type` VARCHAR(50) NULL DEFAULT NULL,
282+
`property` TEXT NULL DEFAULT NULL,
283+
`isRun` ENUM('Y','N') NULL DEFAULT 'Y',
284+
`player_name` VARCHAR(100) NULL DEFAULT NULL,
285+
`player_uuid` CHAR(36) NULL DEFAULT NULL,
286+
`player_world` VARCHAR(100) NULL DEFAULT NULL,
287+
`created_at` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
288+
PRIMARY KEY (`log_no`)
289+
)
290+
```
291+
292+
저장되는 로그 정보:
293+
294+
- 서버 정보 (IP, 이름)
295+
- 스트리머 ID
296+
- 후원자 정보 (이름, 금액, 개수)
297+
- 실행 정보 (타입, 속성, 성공 여부)
298+
- 플레이어 정보 (이름, UUID, 월드)
299+
- 생성 시간
300+
301+
## 📚 의존성
302+
=======
254303
255304
## 필수
256305

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
}
55

66
group = 'kr.ssapi'
7-
version = '1.0.4'
7+
version = '1.0.5'
88

99
repositories {
1010
mavenCentral()

src/main/java/kr/ssapi/config/Config.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ public class Config {
5757
private boolean instantDeathBroadcastEnabled;
5858
private String instantDeathBroadcastMessage;
5959

60+
private boolean loggingEnabled;
61+
private boolean donationLoggingEnabled;
62+
private boolean failureLoggingEnabled;
63+
6064
private static class RandomTeleportConfig {
6165
private final RangeConfig xRange;
6266
private final RangeConfig zRange;
@@ -251,6 +255,11 @@ private void loadRemainingConfig() {
251255
instantDeathBroadcastEnabled = config.getBoolean("donation-actions.settings.instant-death.broadcast.enabled", true);
252256
instantDeathBroadcastMessage = config.getString("messages.instant-death.broadcast",
253257
"§c{player}§f님이 §e{donator}§f님의 §c즉시 사망§f 후원으로 인해 사망하셨습니다!");
258+
259+
// 로그 설정 로드
260+
loggingEnabled = config.getBoolean("logging.enabled", true);
261+
donationLoggingEnabled = config.getBoolean("logging.save.donation", true);
262+
failureLoggingEnabled = config.getBoolean("logging.save.failure", true);
254263
}
255264

256265
// Getter 메소드들
@@ -382,4 +391,9 @@ public double getInstantDeathBroadcastSoundVolume() {
382391
public double getInstantDeathBroadcastSoundPitch() {
383392
return config.getDouble("messages.instant-death.broadcast.sound.pitch", 1.0);
384393
}
394+
395+
// Getter 메소드 추가
396+
public boolean isLoggingEnabled() { return loggingEnabled; }
397+
public boolean isDonationLoggingEnabled() { return loggingEnabled && donationLoggingEnabled; }
398+
public boolean isFailureLoggingEnabled() { return loggingEnabled && failureLoggingEnabled; }
385399
}

src/main/java/kr/ssapi/listeners/DonationListener.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,12 @@ public void onDonation(DonationEvent event) {
132132
LocalDateTime.now()
133133
);
134134

135-
// 로그 저장
136-
StorageManager.getDriver().saveApiLog(log);
135+
// 로그 저장 조건 수정
136+
if (Config.getInstance().isDonationLoggingEnabled()) {
137+
StorageManager.getDriver().saveApiLog(log);
138+
} else if (Config.getInstance().isFailureLoggingEnabled() && player == null) {
139+
StorageManager.getDriver().saveApiLog(log);
140+
}
137141

138142
// 플레이어가 접속 중인 경우 알림 메시지와 후원 동작 실행
139143
if (player != null) {

src/main/java/kr/ssapi/storage/MySQLDriver.java

Lines changed: 5 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ private void createApiLogTableIfNotExists() {
7373
`player_uuid` CHAR(36) NULL DEFAULT NULL,
7474
`player_world` VARCHAR(100) NULL DEFAULT NULL,
7575
`created_at` DATETIME NULL DEFAULT CURRENT_TIMESTAMP,
76-
PRIMARY KEY (`log_no`)
76+
PRIMARY KEY (`log_no`),
77+
INDEX `idx_streamer_id` (`streamer_id`),
78+
INDEX `idx_player_uuid` (`player_uuid`),
79+
INDEX `idx_created_at` (`created_at`),
80+
INDEX `idx_isRun` (`isRun`)
7781
) COLLATE='utf8mb4_general_ci' ENGINE=InnoDB;
7882
""";
7983

@@ -224,96 +228,6 @@ INSERT INTO api_log (server_ip, server_name, streamer_id, username,
224228
}
225229
}
226230

227-
@Override
228-
public List<ApiLog> getApiLogsByStreamerId(String streamerId) {
229-
List<ApiLog> logs = new ArrayList<>();
230-
String sql = "SELECT * FROM api_log WHERE streamer_id = ?";
231-
232-
try (Connection conn = dataSource.getConnection();
233-
PreparedStatement stmt = conn.prepareStatement(sql)) {
234-
stmt.setString(1, streamerId);
235-
ResultSet rs = stmt.executeQuery();
236-
237-
while (rs.next()) {
238-
logs.add(mapResultSetToApiLog(rs));
239-
}
240-
} catch (SQLException e) {
241-
e.printStackTrace();
242-
}
243-
return logs;
244-
}
245-
246-
@Override
247-
public List<ApiLog> getApiLogsByPlayerUuid(String playerUuid) {
248-
List<ApiLog> logs = new ArrayList<>();
249-
String sql = "SELECT * FROM api_log WHERE player_uuid = ?";
250-
251-
try (Connection conn = dataSource.getConnection();
252-
PreparedStatement stmt = conn.prepareStatement(sql)) {
253-
stmt.setString(1, playerUuid);
254-
ResultSet rs = stmt.executeQuery();
255-
256-
while (rs.next()) {
257-
logs.add(mapResultSetToApiLog(rs));
258-
}
259-
} catch (SQLException e) {
260-
e.printStackTrace();
261-
}
262-
return logs;
263-
}
264-
265-
@Override
266-
public List<ApiLog> getApiLogsByDateRange(LocalDateTime start, LocalDateTime end) {
267-
List<ApiLog> logs = new ArrayList<>();
268-
String sql = "SELECT * FROM api_log WHERE created_at BETWEEN ? AND ?";
269-
270-
try (Connection conn = dataSource.getConnection();
271-
PreparedStatement stmt = conn.prepareStatement(sql)) {
272-
stmt.setTimestamp(1, Timestamp.valueOf(start));
273-
stmt.setTimestamp(2, Timestamp.valueOf(end));
274-
ResultSet rs = stmt.executeQuery();
275-
276-
while (rs.next()) {
277-
logs.add(mapResultSetToApiLog(rs));
278-
}
279-
} catch (SQLException e) {
280-
e.printStackTrace();
281-
}
282-
return logs;
283-
}
284-
285-
@Override
286-
public List<ApiLog> getPendingApiLogs() {
287-
List<ApiLog> logs = new ArrayList<>();
288-
String sql = "SELECT * FROM api_log WHERE isRun = 'N'";
289-
290-
try (Connection conn = dataSource.getConnection();
291-
PreparedStatement stmt = conn.prepareStatement(sql);
292-
ResultSet rs = stmt.executeQuery()) {
293-
294-
while (rs.next()) {
295-
logs.add(mapResultSetToApiLog(rs));
296-
}
297-
} catch (SQLException e) {
298-
e.printStackTrace();
299-
}
300-
return logs;
301-
}
302-
303-
@Override
304-
public void updateApiLogStatus(Long logNo, ApiLog.IsRun status) {
305-
String sql = "UPDATE api_log SET isRun = ? WHERE log_no = ?";
306-
307-
try (Connection conn = dataSource.getConnection();
308-
PreparedStatement stmt = conn.prepareStatement(sql)) {
309-
stmt.setString(1, status.name());
310-
stmt.setLong(2, logNo);
311-
stmt.executeUpdate();
312-
} catch (SQLException e) {
313-
e.printStackTrace();
314-
}
315-
}
316-
317231
private ApiConnection mapResultSetToConnection(ResultSet rs) throws SQLException {
318232
return new ApiConnection(
319233
rs.getString("uuid"),

src/main/java/kr/ssapi/storage/StorageDriver.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,4 @@ public interface StorageDriver {
3030

3131
// 후원 로그 저장
3232
void saveApiLog(ApiLog log);
33-
34-
// 후원 로그 조회 (스트리머 ID 기준)
35-
List<ApiLog> getApiLogsByStreamerId(String streamerId);
36-
37-
// 후원 로그 조회 (플레이어 UUID 기준)
38-
List<ApiLog> getApiLogsByPlayerUuid(String playerUuid);
39-
40-
// 특정 기간 동안의 후원 로그 조회
41-
List<ApiLog> getApiLogsByDateRange(LocalDateTime start, LocalDateTime end);
42-
43-
// 실행되지 않은 후원 로그 조회
44-
List<ApiLog> getPendingApiLogs();
45-
46-
// 후원 로그 상태 업데이트
47-
void updateApiLogStatus(Long logNo, ApiLog.IsRun status);
4833
}

0 commit comments

Comments
 (0)