|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.ljsd.jieling.handler.GameGM;
|
|
|
|
|
|
|
|
|
|
import com.ljsd.GameApplication;
|
|
|
|
|
import com.ljsd.jieling.config.*;
|
|
|
|
|
import com.ljsd.jieling.core.GlobalsDef;
|
|
|
|
|
import com.ljsd.jieling.db.mongo.MongoUtil;
|
|
|
|
@ -8,9 +9,6 @@ import com.ljsd.jieling.globals.GlobalGm;
|
|
|
|
|
import com.ljsd.jieling.globals.GlobalItemType;
|
|
|
|
|
import com.ljsd.jieling.handler.BaseHandler;
|
|
|
|
|
import com.ljsd.jieling.handler.map.MapLogic;
|
|
|
|
|
import com.ljsd.jieling.handler.map.MapManager;
|
|
|
|
|
import com.ljsd.jieling.handler.map.MapMission;
|
|
|
|
|
import com.ljsd.jieling.handler.mission.Mission;
|
|
|
|
|
import com.ljsd.jieling.logic.dao.*;
|
|
|
|
|
import com.ljsd.jieling.logic.dao.root.User;
|
|
|
|
|
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
|
|
|
@ -18,19 +16,23 @@ import com.ljsd.jieling.network.session.ISession;
|
|
|
|
|
import com.ljsd.jieling.protocols.CommonProto;
|
|
|
|
|
import com.ljsd.jieling.protocols.MessageTypeProto;
|
|
|
|
|
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
|
|
|
|
import com.ljsd.jieling.util.CBean2Proto;
|
|
|
|
|
import com.ljsd.jieling.util.ItemUtil;
|
|
|
|
|
import com.ljsd.jieling.util.MessageUtil;
|
|
|
|
|
import com.ljsd.jieling.util.TimeUtils;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
import sun.misc.MessageUtils;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
|
|
|
|
@Component
|
|
|
|
|
public class GMRequestHandler extends BaseHandler{
|
|
|
|
|
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(GMRequestHandler.class);
|
|
|
|
|
|
|
|
|
|
private String osName = System.getProperty("os.name");
|
|
|
|
|
@Override
|
|
|
|
|
public MessageTypeProto.MessageType getMessageCode() {
|
|
|
|
|
return MessageTypeProto.MessageType.GM_REQUEST;
|
|
|
|
@ -61,13 +63,13 @@ public class GMRequestHandler extends BaseHandler{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
User cUser = UserManager.getUser(uid);
|
|
|
|
|
CommonProto.GmResponse.Builder gmBuilder = CommonProto.GmResponse.newBuilder();
|
|
|
|
|
switch (gmCommandType){
|
|
|
|
|
case GlobalGm.ADD_ITEM:
|
|
|
|
|
ItemUtil.drop(cUser,new int[][]{{prarm1,prarm2}});
|
|
|
|
|
// giveItem(cUser,prarm1,prarm2);
|
|
|
|
|
gmBuilder.setDrop(ItemUtil.drop(cUser,new int[][]{{prarm1,prarm2}}));
|
|
|
|
|
break;
|
|
|
|
|
case GlobalGm.ADD_CARD:
|
|
|
|
|
giveHero(cUser,prarm1,prarm2);
|
|
|
|
|
gmBuilder.setDrop(giveHero(cUser,prarm1,prarm2));
|
|
|
|
|
break;
|
|
|
|
|
case GlobalGm.SEND_MAIIL:
|
|
|
|
|
int nowTime =(int) (TimeUtils.now()/1000);
|
|
|
|
@ -90,6 +92,8 @@ public class GMRequestHandler extends BaseHandler{
|
|
|
|
|
hero.setLevel(scHeroRankUpConfig.getLimitLevel());
|
|
|
|
|
hero.setBreakId(scHeroRankUpConfig.getId());
|
|
|
|
|
}
|
|
|
|
|
CommonProto.Hero finalHeroProto = CBean2Proto.getHero(hero);
|
|
|
|
|
gmBuilder.setDrop( CommonProto.Drop.newBuilder().addHero(finalHeroProto).build());
|
|
|
|
|
break;
|
|
|
|
|
case GlobalGm.OPEN_MAP:
|
|
|
|
|
MapLogic.getInstance().gmCrossFight(uid, prarm1);
|
|
|
|
@ -138,20 +142,44 @@ public class GMRequestHandler extends BaseHandler{
|
|
|
|
|
length++;
|
|
|
|
|
int itemId = sItem.getId();
|
|
|
|
|
int itemType = sItem.getItemType();
|
|
|
|
|
int itemNum = 999;
|
|
|
|
|
int itemNum = 9999;
|
|
|
|
|
if(itemType == GlobalItemType.CARD ||itemType == GlobalItemType.EQUIP){
|
|
|
|
|
itemNum =1;
|
|
|
|
|
}
|
|
|
|
|
gmDrop[i++] = new int[]{itemId,itemNum};
|
|
|
|
|
}
|
|
|
|
|
ItemUtil.drop(cUser,gmDrop);
|
|
|
|
|
gmBuilder.setDrop(ItemUtil.drop(cUser, gmDrop));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
//1:获取当前服务器时间 2: 获取服务器开服时间 3 : 获取玩家创建角色时间 4:修改服务器时间
|
|
|
|
|
case GlobalGm.TIME_INFO:
|
|
|
|
|
switch (prarm1){
|
|
|
|
|
case 1:
|
|
|
|
|
gmBuilder.setInfo(parseTimeToString(System.currentTimeMillis()));
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
gmBuilder.setInfo(GameApplication.serverConfig.getOpenTime());
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
gmBuilder.setInfo(parseTimeToString(cUser.getPlayerInfoManager().getCreateTime()));
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
long targetTime = TimeUtils.stringToTimeLong(commandArray[2],"yyyyMMddHHmmss");
|
|
|
|
|
long now = TimeUtils.now();
|
|
|
|
|
if (now > targetTime) {
|
|
|
|
|
MessageUtil.sendErrorResponse(iSession,0, MessageTypeProto.MessageType.GM_RESPONSE_VALUE,"时间只能往未来调");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
update(targetTime,uid);
|
|
|
|
|
gmBuilder.setInfo(parseTimeToString(System.currentTimeMillis()));
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GM_RESPONSE_VALUE, null, true);
|
|
|
|
|
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GM_RESPONSE_VALUE, gmBuilder.build(), true);
|
|
|
|
|
LOGGER.info("back to client!");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
@ -165,6 +193,11 @@ public class GMRequestHandler extends BaseHandler{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String parseTimeToString(long time){
|
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
return simpleDateFormat.format(time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//开启所有关卡
|
|
|
|
|
private void openFightids(LevelDifficultyManager levelDifficultyManager,int level) {
|
|
|
|
|
Map<Integer, LevelDifficulty> levelDifficultyMap = SLevelDifficultyConfig.getLevelDifficultyMap();
|
|
|
|
@ -178,11 +211,12 @@ public class GMRequestHandler extends BaseHandler{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void giveHero(User cUser, int cardId, int cardNum) throws Exception {
|
|
|
|
|
private CommonProto.Drop.Builder giveHero(User cUser, int cardId, int cardNum) throws Exception {
|
|
|
|
|
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
|
|
|
|
|
Map<Integer,Integer> cardMap = new ConcurrentHashMap<>();
|
|
|
|
|
cardMap.put(cardId,cardNum);
|
|
|
|
|
ItemUtil.addCard(cUser,cardMap,dropBuilder);
|
|
|
|
|
return dropBuilder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void giveItem(User cUser,int itemId,int itemNum) throws Exception {
|
|
|
|
@ -191,4 +225,37 @@ public class GMRequestHandler extends BaseHandler{
|
|
|
|
|
itemMap.put(itemId,itemNum);
|
|
|
|
|
ItemUtil.addItem(cUser,itemMap,dropBuilder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void update(long newTime,int uid) {
|
|
|
|
|
LOGGER.error("update->uid={},newTime={}", uid, newTime);
|
|
|
|
|
Date currentTime = new Date();
|
|
|
|
|
currentTime.setTime(newTime);
|
|
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
String dateString = formatter.format(currentTime);
|
|
|
|
|
String dataWindows = dateString.substring(0,10);
|
|
|
|
|
String dataLinux = dateString.substring(0,10).replaceAll("-","");
|
|
|
|
|
String time = dateString.substring(11,19);
|
|
|
|
|
|
|
|
|
|
String cmd = "";
|
|
|
|
|
try {
|
|
|
|
|
if (osName.matches("^(?i)Windows.*$")) {// Window 系统
|
|
|
|
|
// 格式 HH:mm:ss
|
|
|
|
|
cmd = " cmd /c time "+ time;
|
|
|
|
|
Runtime.getRuntime().exec(cmd);
|
|
|
|
|
// 格式:yyyy-MM-dd
|
|
|
|
|
cmd = " cmd /c date "+ dataWindows;
|
|
|
|
|
Runtime.getRuntime().exec(cmd);
|
|
|
|
|
} else {// Linux 系统
|
|
|
|
|
// 格式:yyyyMMdd
|
|
|
|
|
cmd = " date -s "+ dataLinux;
|
|
|
|
|
Runtime.getRuntime().exec(cmd);
|
|
|
|
|
// 格式 HH:mm:ss
|
|
|
|
|
cmd = " date -s "+ time;
|
|
|
|
|
Runtime.getRuntime().exec(cmd);
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
LOGGER.error("update->uid={},msg={}", uid, e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|