Skip to content

Commit

Permalink
Update DodoOpenJava.java
Browse files Browse the repository at this point in the history
  • Loading branch information
mcchampions committed Feb 2, 2024
1 parent 80e90d8 commit 5f27a0e
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.minecraftchampions.dodoopenjava;

import lombok.Getter;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;

Expand All @@ -18,8 +17,7 @@ public class DodoOpenJava {

private static final HashSet<Bot> bots = new HashSet<>();

@Getter
private static final Map<String, ApiResultsLogger> logMap = new ConcurrentHashMap<>();
public static final Map<String, ApiResultsLogger> LOGGER_MAP = new ConcurrentHashMap<>();

/**
* 新建 Bot
Expand All @@ -37,6 +35,7 @@ public static synchronized Bot createBot(@NonNull String clientId, @NonNull Stri
public static Set<Bot> getBots() {
return (HashSet<Bot>) bots.clone();
}


/**
* 卸载Bot
Expand Down Expand Up @@ -66,12 +65,12 @@ public static void enableApiResultsLogger(Bot bot) {
* @param authorization authorization
*/
public static void enableApiResultsLogger(String authorization) {
synchronized (logMap) {
if (logMap.containsKey(authorization)) {
synchronized (LOGGER_MAP) {
if (LOGGER_MAP.containsKey(authorization)) {
log.warn("已经调用过DodoOpenJava#enableApiResultsLogger");
return;
}
logMap.put(authorization, new ApiResultsLogger(authorization));
LOGGER_MAP.put(authorization, new ApiResultsLogger(authorization));
}
}

Expand All @@ -90,8 +89,8 @@ public static void disableApiResultsLogger(Bot bot) {
* @param authorization authorization
*/
public static void disableApiResultsLogger(String authorization) {
synchronized (logMap) {
logMap.remove(authorization);
synchronized (LOGGER_MAP) {
LOGGER_MAP.remove(authorization);
}
}
}

0 comments on commit 5f27a0e

Please sign in to comment.