公会仅剩1人时,立刻解散公会

master_haizei
grimm 2023-12-27 16:32:19 +08:00
parent 6de440fb67
commit 416da4f2ad
4 changed files with 25 additions and 16 deletions

View File

@ -36,7 +36,6 @@ public class Cmd_updateguild extends GmAbstract {
case "dissolution":
guildInfo.setLevelTime(1);
GuilidManager.addGuildToRelease(guildInfo);
GuilidManager.saveOrUpdateGuildInfo(guildInfo);
break;
default:
throw new ErrorCodeException("修改公会,类型错误,公会id:"+guildId+",类型:"+parm);

View File

@ -190,7 +190,7 @@ public class GuilidManager {
RedisUtil.getInstence().zsetRemoveOne(key,Integer.toString(guildInfo.getId()));
return;
}
levelTime+= SGuildSetting.sGuildSetting.getDestroyTime();
levelTime += SGuildSetting.sGuildSetting.getDestroyTime();
RedisUtil.getInstence().zsetAddOne(key,Integer.toString(guildInfo.getId()),levelTime);
}
}

View File

@ -28,7 +28,7 @@ public class GuildInfo extends MongoBase {
private int joinType ; //加入类型 1:直接加入 2:申请加入 3:禁止加入
private Map<Integer, Set<Integer>> members ;
private Map<Integer, Set<Integer>> members;
private int levelTime;

View File

@ -116,7 +116,7 @@ public class GuildLogic {
int[][] reward = sGuildSacrificeRewardConfig.getReward();
itemArrs.add(reward);
}
if (itemArrs.size() == 0) {
if (itemArrs.isEmpty()) {
return;
}
String title = SErrorCodeEerverConfig.getI18NMessage("guildsacrifice_reward_title");
@ -194,7 +194,7 @@ public class GuildLogic {
if(StringUtil.isEmpty(announce)){
announce= SGuildSetting.sGuildSetting.getDefaultDeclaration();
}
if(announce.length()==0||announce.length()>32){
if(announce.isEmpty() ||announce.length()>32){
throw new ErrorCodeException(ErrorCode.ANNOUNCE_SIZE);
}
// 创建公会
@ -249,7 +249,7 @@ public class GuildLogic {
Family.FamilyRecommandResponse.Builder builder = Family.FamilyRecommandResponse.newBuilder();
Map<Integer, GuildApply> applyGuildInfos = GuilidManager.getApplyGuildInfos(uid, 1);
int now = TimeUtils.nowInt();
if(applyGuildInfos.size()>0){
if(!applyGuildInfos.isEmpty()){
Iterator<Map.Entry<Integer, GuildApply>> iterator = applyGuildInfos.entrySet().iterator();
while (iterator.hasNext()){
Map.Entry<Integer, GuildApply> next = iterator.next();
@ -315,7 +315,7 @@ public class GuildLogic {
throw new ErrorCodeException(ErrorCode.FAMILY_HAD_APPLY);
}
for(Integer applyGuildId : applyGuilds){
if(GuilidManager.getGuildInfo(applyGuildId).getJoinType()!=0&&applyGuilds.size()==0){
if(GuilidManager.getGuildInfo(applyGuildId).getJoinType()!=0&& applyGuilds.isEmpty()){
continue;
}
GuildApply guildApply = new GuildApply(uid,applyGuildId);
@ -329,7 +329,7 @@ public class GuildLogic {
GuilidManager.addApplyGuildInfo(guildApply);
Map<Integer, Set<Integer>> members = GuilidManager.getGuildInfo(applyGuildId).getMembers();
for(Map.Entry<Integer, Set<Integer>> entry: members.entrySet()){
if(entry.getValue().size()<1){
if(entry.getValue().isEmpty()){
continue;
}
if (entry.getKey()==GlobalsDef.MEMBER){
@ -726,6 +726,7 @@ public class GuildLogic {
/**
*
* @param type 1: 2
*/
public static void dissolution(ISession session,int type) throws Exception {
int msgId = MessageTypeProto.MessageType.FAMILY_DISSOLUTION_RESPONSE_VALUE;
@ -737,21 +738,29 @@ public class GuildLogic {
}
GuildInfo guildInfo = GuilidManager.getGuildInfo(guildId);
int uidType = getMemberType(uid, guildInfo.getMembers());
if(uidType!=1){
if(uidType != 1){
throw new ErrorCodeException(ErrorCode.FAMILY_NO_ACCESS);
}
if(type == 1 && guildInfo.getLevelTime()>0){
if(type == 1 && guildInfo.getLevelTime() > 0){
throw new ErrorCodeException(ErrorCode.newDefineCode("已操作过了"));
}
if(type == 1&&GuildFightLogic.getStatus()!=0){
if(type == 1&&GuildFightLogic.getStatus() != 0){
throw new ErrorCodeException(ErrorCode.FAMILY_DESTROY_IN_WAR);
}
//解散公会
int time = 0;
if(type == 1){
guildInfo.setLevelTime(TimeUtils.nowInt());
}else{
guildInfo.setLevelTime(0);
int num = 0;
for (Set<Integer> set : guildInfo.getMembers().values()) {
num += set.size();
}
if (num == 1){
time = 1;
}else {
time = TimeUtils.nowInt();
}
}
guildInfo.setLevelTime(time);
GuilidManager.saveOrUpdateGuildInfo(guildInfo);
sendFamilyBaseUpdateIndication(guildInfo);
GuilidManager.addGuildToRelease(guildInfo);
@ -910,7 +919,9 @@ public class GuildLogic {
MessageUtil.sendMessage(session,1,msgId,null,true);
}
/**
* 退
*/
public static void levelFamily(ISession session) throws Exception {
int msgId = MessageTypeProto.MessageType.FAMILY_LEVEL_RESPONSE_VALUE;
int uid = session.getUid();
@ -928,7 +939,6 @@ public class GuildLogic {
guildInfo.removeDefendInfo(uid);
}
//TODO lock check
OnUserLeveFamily(user);
guildInfo.removeMember(uidType,uid);
user.getPlayerInfoManager().setGuildId(0);