 | [color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]package l1j.server.server.utils;
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]import l1j.server.server.model.Instance.L1PcInstance;
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]import l1j.server.server.serverpackets.S_SystemMessage;
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]import java.util.logging.Level;
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]import java.util.logging.Logger;
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]/**
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] * WHO功能統一錯誤處理器
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] * 處理WHO相關功能的各種錯誤情況
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] */
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]public class WhoErrorHandler {
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] private static final Logger _log = Logger.getLogger(WhoErrorHandler.class.getName());
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] // 錯誤類型枚舉
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] public enum ErrorType {
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] PLAYER_NOT_FOUND,
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] PERMISSION_DENIED,
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] NETWORK_ERROR,
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] DATABASE_ERROR,
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] VALIDATION_ERROR,
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] TIMEOUT_ERROR,
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] UNKNOWN_ERROR
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] }
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] /**
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] * 處理錯誤並發送適當的訊息給玩家
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] */
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] public static void handleError(L1PcInstance pc, Exception e, String operation) {
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] if (pc == null) {
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] _log.log(Level.WARNING, "WHO操作失敗(玩家為null): " + operation, e);
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] return;
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] }
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] _log.log(Level.WARNING, "WHO功能執行失敗: " + operation + " - 玩家: " + pc.getName(), e);
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] ErrorType errorType = classifyError(e);
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] String message = getErrorMessage(errorType);
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] pc.sendPackets(new S_SystemMessage(message));
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] }
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] /**
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] * 處理特定錯誤類型
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] */
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] public static void handleError(L1PcInstance pc, ErrorType errorType, String details) {
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] if (pc == null) {
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] _log.log(Level.WARNING, "WHO操作失敗(玩家為null): " + details);
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] return;
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] }
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] _log.log(Level.WARNING, "WHO操作失敗: " + errorType + " - " + details + " - 玩家: " + pc.getName());
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] String message = getErrorMessage(errorType);
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] if (details != null && !details.isEmpty()) {
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] message += " (" + details + ")";
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] }
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] pc.sendPackets(new S_SystemMessage(message));
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] }
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] /**
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] * 處理玩家未找到的錯誤
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] */
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] public static void handlePlayerNotFound(L1PcInstance pc, String targetName) {
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] if (pc == null) return;
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] _log.log(Level.INFO, "玩家未找到: " + targetName + " - 查詢者: " + pc.getName());
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] pc.sendPackets(new S_SystemMessage("找不到玩家: " + targetName));
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] }
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)]
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] /**
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] * 處理權限不足的錯誤
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] */
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)] public static void handlePermissionDenied(L1PcInstance pc, String action) {
[color=rgba(252, 249, 249, 0.698)][backcolor=rgba(14, 11, 11, 0.498)][backcolor=lab(99.9988 0.0188053 -0.00110865 / 0.09)] if (pc == null) return;
| |