代码可读性修改

back_recharge
duhui 2022-08-24 09:57:06 +08:00
parent aace2dae75
commit 258d1e88ce
2 changed files with 12 additions and 23 deletions

View File

@ -174,15 +174,12 @@ public class PlayerLogic {
User user = UserManager.getUser(uid); User user = UserManager.getUser(uid);
PlayerManager playerInfoManager = user.getPlayerInfoManager(); PlayerManager playerInfoManager = user.getPlayerInfoManager();
TeamPosManager teamPosManager = user.getTeamPosManager(); TeamPosManager teamPosManager = user.getTeamPosManager();
if (checkName(iSession, name, msgId)){ if (checkName(iSession, name, msgId)){
return; return;
} }
if (type == 1||type == 3) { if (type == 1||type == 3) {
// 检查名字是否被占用 // 检查名字是否被占用
if (PlayerLogic.getInstance().isExistName(name)) { if (PlayerLogic.getInstance().isExistName(name)) {
// MessageUtil.sendErrorResponse(iSession, 0, msgId, SErrorCodeEerverConfig.getI18NMessage("name_repeat_txt"));
// return;
throw new ErrorCodeException(name,ErrorCode.NAME_USE); throw new ErrorCodeException(name,ErrorCode.NAME_USE);
} }
if (!playerInfoManager.getNickName().equals(String.valueOf(uid))){ if (!playerInfoManager.getNickName().equals(String.valueOf(uid))){
@ -231,18 +228,13 @@ public class PlayerLogic {
} }
private boolean checkName(ISession iSession, String name, int msgId) throws Exception { private boolean checkName(ISession iSession, String name, int msgId) throws Exception {
// if(!Repot37EventUtil.Report37Chat(UserManager.getUser(iSession.getUid()), ChatContentType.ROLE_NAME,name)){
// throw new ErrorCodeException(ErrorCode.NAME_ILLEGAL);
// }
int length = getStrLength(name); int length = getStrLength(name);
if (length == -1) { if (length == -1) {
throw new ErrorCodeException(ErrorCode.NAME_ILLEGAL); throw new ErrorCodeException(ErrorCode.NAME_ILLEGAL);
} }
// STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getMaxNameLength()
if (length > 18 || length < 1) { if (length > 18 || length < 1) {
throw new ErrorCodeException(ErrorCode.NAME_LENTH); throw new ErrorCodeException(ErrorCode.NAME_LENTH);
} }
;
boolean result = ShieldedWordUtils.checkName(UserManager.getUser(iSession.getUid()),name,true,ChatContentType.ROLE_NAME); boolean result = ShieldedWordUtils.checkName(UserManager.getUser(iSession.getUid()),name,true,ChatContentType.ROLE_NAME);
if (!result) { if (!result) {
throw new ErrorCodeException(ErrorCode.NAME_ILLEGAL); throw new ErrorCodeException(ErrorCode.NAME_ILLEGAL);

View File

@ -17,25 +17,22 @@ public class ShieldedWordUtils {
return checkName(user,name,validateSpecStr,chatContentType); return checkName(user,name,validateSpecStr,chatContentType);
} }
public static boolean checkName(User user , String name,boolean validateSpecStr,ChatContentType chatContentType){ public static boolean checkName(User user,String name,boolean validateSpecStr,ChatContentType chatContentType){
boolean result; boolean result = true;
// 校验特殊符号
if(validateSpecStr){ if(validateSpecStr){
result = validateUserName(name); result = validateUserName(name);
if(!result){ }
return false; // 校验违禁字符
if (result == true){
try {
result = isContaintSensitiveWord(name);
} catch (Exception e) {
LOGGER.error("检查名称,报错:"+e.getMessage());
result = false;
} }
} }
return result;
try {
result = isContaintSensitiveWord(name);
} catch (Exception e) {
LOGGER.error("检查名称,报错:"+e.getMessage());
return false;
}
if(result){
return false;
}
return true;
} }