mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-10 09:22:49 +00:00
Chat logging implementation and chat service improvements
Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
@@ -37,7 +37,9 @@ import com.l2jserver.service.game.admin.AdministratorService;
|
||||
import com.l2jserver.service.game.admin.AdministratorServiceImpl;
|
||||
import com.l2jserver.service.game.character.CharacterService;
|
||||
import com.l2jserver.service.game.character.CharacterServiceImpl;
|
||||
import com.l2jserver.service.game.chat.ChatLoggingService;
|
||||
import com.l2jserver.service.game.chat.ChatService;
|
||||
import com.l2jserver.service.game.chat.DatabaseChatLoggingService;
|
||||
import com.l2jserver.service.game.chat.SimpleChatService;
|
||||
import com.l2jserver.service.game.map.pathing.MapperPathingService;
|
||||
import com.l2jserver.service.game.map.pathing.PathingService;
|
||||
@@ -104,6 +106,8 @@ public class ServiceModule extends AbstractModule {
|
||||
|
||||
bind(ChatService.class).to(SimpleChatService.class)
|
||||
.in(Scopes.SINGLETON);
|
||||
bind(ChatLoggingService.class).to(DatabaseChatLoggingService.class).in(
|
||||
Scopes.SINGLETON);
|
||||
bind(AdministratorService.class).to(AdministratorServiceImpl.class).in(
|
||||
Scopes.SINGLETON);
|
||||
bind(SpawnService.class).to(SpawnServiceImpl.class)
|
||||
|
||||
@@ -41,7 +41,6 @@ import org.apache.log4j.helpers.LogLog;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class TruncateToZipFileAppender extends FileAppender {
|
||||
|
||||
/**
|
||||
* String that points to root directory for backups
|
||||
*/
|
||||
|
||||
@@ -67,7 +67,7 @@ import com.l2jserver.util.ClassUtils;
|
||||
import com.l2jserver.util.factory.CollectionFactory;
|
||||
|
||||
/**
|
||||
* The database service implementation for MySQL database
|
||||
* The database service implementation for JDBC database
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
@@ -325,6 +325,7 @@ public class JDBCDatabaseService extends AbstractService implements
|
||||
this.iterator = iterator;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Integer query(Connection conn) throws SQLException {
|
||||
Preconditions.checkNotNull(conn, "conn");
|
||||
@@ -336,15 +337,17 @@ public class JDBCDatabaseService extends AbstractService implements
|
||||
rows += st.executeUpdate();
|
||||
|
||||
// update object desire --it has been realized
|
||||
if (object instanceof Model)
|
||||
if (object instanceof Model) {
|
||||
((Model<?>) object).setObjectDesire(ObjectDesire.NONE);
|
||||
|
||||
final Mapper<T> mapper = keyMapper(object);
|
||||
if (mapper == null)
|
||||
continue;
|
||||
final ResultSet rs = st.getGeneratedKeys();
|
||||
while (rs.next()) {
|
||||
mapper.map(rs);
|
||||
final Mapper<? extends ID<?>> mapper = keyMapper();
|
||||
if (mapper == null)
|
||||
continue;
|
||||
final ResultSet rs = st.getGeneratedKeys();
|
||||
while (rs.next()) {
|
||||
((Model<ID<?>>) object).setID(mapper.map(rs));
|
||||
mapper.map(rs);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rows;
|
||||
@@ -377,7 +380,7 @@ public class JDBCDatabaseService extends AbstractService implements
|
||||
* the object
|
||||
* @return the key mapper
|
||||
*/
|
||||
protected Mapper<T> keyMapper(T object) {
|
||||
protected Mapper<? extends ID<?>> keyMapper() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.l2jserver.game.net.packet.server.SM_MOVE;
|
||||
import com.l2jserver.game.net.packet.server.SM_MOVE_TYPE;
|
||||
import com.l2jserver.game.net.packet.server.SM_TARGET;
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.model.server.ChatMessage;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.Actor.ActorState;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
@@ -49,7 +50,7 @@ import com.l2jserver.service.AbstractService.Depends;
|
||||
import com.l2jserver.service.game.AttackService;
|
||||
import com.l2jserver.service.game.chat.ChatChannel;
|
||||
import com.l2jserver.service.game.chat.ChatChannelListener;
|
||||
import com.l2jserver.service.game.chat.ChatMessageDestination;
|
||||
import com.l2jserver.service.game.chat.ChatMessageType;
|
||||
import com.l2jserver.service.game.chat.ChatService;
|
||||
import com.l2jserver.service.game.npc.NPCService;
|
||||
import com.l2jserver.service.game.npc.NotAttackableNPCServiceException;
|
||||
@@ -148,18 +149,16 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
// chat listener
|
||||
final ChatChannelListener globalChatListener = new ChatChannelListener() {
|
||||
@Override
|
||||
public void onMessage(ChatChannel channel, CharacterID source,
|
||||
String message) {
|
||||
conn.write(new SM_CHAT(source.getObject(),
|
||||
ChatMessageDestination.ALL, message));
|
||||
public void onMessage(ChatChannel channel, ChatMessage message) {
|
||||
conn.write(new SM_CHAT(message.getSender().getObject(),
|
||||
ChatMessageType.ALL, message.getMessage()));
|
||||
}
|
||||
};
|
||||
final ChatChannelListener tradeChatListener = new ChatChannelListener() {
|
||||
@Override
|
||||
public void onMessage(ChatChannel channel, CharacterID source,
|
||||
String message) {
|
||||
conn.write(new SM_CHAT(source.getObject(),
|
||||
ChatMessageDestination.TRADE, message));
|
||||
public void onMessage(ChatChannel channel, ChatMessage message) {
|
||||
conn.write(new SM_CHAT(message.getSender().getObject(),
|
||||
ChatMessageType.TRADE, message.getMessage()));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -205,7 +204,7 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
|
||||
// start broadcasting -- will broadcast all nearby objects
|
||||
broadcastService.broadcast(conn);
|
||||
|
||||
|
||||
conn.write(new SM_ITEM_GROUND());
|
||||
|
||||
// characters start in run mode
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.l2jserver.service.game.chat;
|
||||
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.model.server.ChatMessage;
|
||||
|
||||
/**
|
||||
* The {@link ChatChannel} object is used to send messages to a channel.
|
||||
@@ -29,7 +30,10 @@ import com.l2jserver.model.id.object.CharacterID;
|
||||
*/
|
||||
public interface ChatChannel {
|
||||
/**
|
||||
* Sends a message to this channel
|
||||
* Sends a message to this channel.
|
||||
* <p>
|
||||
* Unless otherwise stated, all messages sent will be automatically logged
|
||||
* using {@link ChatLoggingService}.
|
||||
*
|
||||
* @param sender
|
||||
* the character sending the message
|
||||
@@ -40,8 +44,10 @@ public interface ChatChannel {
|
||||
* @throws ChatTargetOfflineServiceException
|
||||
* if the target is offline. Will be be thrown in
|
||||
* {@link PrivateChatChannel}.
|
||||
* @return the created {@link ChatMessage}. The object will be created by
|
||||
* {@link ChatLoggingService}.
|
||||
*/
|
||||
void send(CharacterID sender, String message)
|
||||
ChatMessage send(CharacterID sender, String message)
|
||||
throws ChatBanActiveChatServiceException,
|
||||
ChatTargetOfflineServiceException;
|
||||
|
||||
@@ -61,4 +67,19 @@ public interface ChatChannel {
|
||||
* the listener
|
||||
*/
|
||||
void removeChatChannelListener(ChatChannelListener listener);
|
||||
|
||||
/**
|
||||
* @return the chat channel numeric ID
|
||||
*/
|
||||
int getChannelID();
|
||||
|
||||
/**
|
||||
* @return the chat message type accepted by this channel
|
||||
*/
|
||||
ChatMessageType getMessageType();
|
||||
|
||||
/**
|
||||
* @return the chat channel name
|
||||
*/
|
||||
String getChannelName();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
package com.l2jserver.service.game.chat;
|
||||
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.model.server.ChatMessage;
|
||||
|
||||
/**
|
||||
* This listener is used to received notifications once a new message is sent to
|
||||
@@ -30,10 +30,8 @@ public interface ChatChannelListener {
|
||||
*
|
||||
* @param channel
|
||||
* the chat channel
|
||||
* @param source
|
||||
* the character sending this message
|
||||
* @param message
|
||||
* the message
|
||||
*/
|
||||
void onMessage(ChatChannel channel, CharacterID source, String message);
|
||||
void onMessage(ChatChannel channel, ChatMessage message);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
* l2jserver is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.game.chat;
|
||||
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.model.server.ChatMessage;
|
||||
import com.l2jserver.service.Service;
|
||||
|
||||
/**
|
||||
* This service logs each message sent in the server. Implementarions may choose
|
||||
* to store in a database, plain text, XML or any other form of logging.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface ChatLoggingService extends Service {
|
||||
/**
|
||||
* Sends a message to a public chat channel.
|
||||
*
|
||||
* @param sender
|
||||
* the sender
|
||||
* @param channel
|
||||
* the chat channel
|
||||
* @param message
|
||||
* the message
|
||||
* @return the new ChatMessage created
|
||||
*/
|
||||
ChatMessage log(CharacterID sender, ChatChannel channel, String message);
|
||||
}
|
||||
@@ -17,11 +17,11 @@
|
||||
package com.l2jserver.service.game.chat;
|
||||
|
||||
/**
|
||||
* Enumeration of all possible message destinations
|
||||
* Enumeration of all possible message types
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public enum ChatMessageDestination {
|
||||
public enum ChatMessageType {
|
||||
/**
|
||||
* Everyone
|
||||
*/
|
||||
@@ -63,12 +63,12 @@ public enum ChatMessageDestination {
|
||||
|
||||
public final int id;
|
||||
|
||||
ChatMessageDestination(int id) {
|
||||
ChatMessageType(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static ChatMessageDestination fromID(int id) {
|
||||
for (final ChatMessageDestination dest : values()) {
|
||||
public static ChatMessageType fromID(int id) {
|
||||
for (final ChatMessageType dest : values()) {
|
||||
if (dest.id == id)
|
||||
return dest;
|
||||
}
|
||||
@@ -18,18 +18,22 @@ package com.l2jserver.service.game.chat;
|
||||
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.model.id.object.ClanID;
|
||||
import com.l2jserver.model.server.ChatMessage;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.service.Service;
|
||||
|
||||
/**
|
||||
* This service chatting in the server. Implementations can be local or can use
|
||||
* another service like an IRC server.
|
||||
* This service provides chatting in the server. Implementations can be local or
|
||||
* can use another service like an IRC server.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface ChatService extends Service {
|
||||
/**
|
||||
* Sends a message to a public chat channel.
|
||||
* <p>
|
||||
* Messages sent will be automatically logged using
|
||||
* {@link ChatLoggingService}.
|
||||
*
|
||||
* @param sender
|
||||
* the sender
|
||||
@@ -47,8 +51,10 @@ public interface ChatService extends Service {
|
||||
* if there is chat ban active
|
||||
* @throws ChatTargetOfflineServiceException
|
||||
* if the chat target is offline
|
||||
* @return the created {@link ChatMessage}. The object will be created by
|
||||
* {@link ChatLoggingService}.
|
||||
*/
|
||||
void send(CharacterID sender, ChatMessageDestination chat, String message,
|
||||
ChatMessage send(CharacterID sender, ChatMessageType chat, String message,
|
||||
String extra) throws TargetNotFoundChatServiceException,
|
||||
CannotChatToSelfChatServiceException,
|
||||
ChatBanActiveChatServiceException,
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
* l2jserver is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.game.chat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.db.dao.ChatMessageDAO;
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
|
||||
import com.l2jserver.model.server.ChatMessage;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
|
||||
/**
|
||||
* {@link ChatLoggingService} implementation that stores logs in the database
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class DatabaseChatLoggingService extends AbstractService implements
|
||||
ChatLoggingService {
|
||||
/**
|
||||
* The {@link ChatMessage} DAO
|
||||
*/
|
||||
private final ChatMessageDAO chatMessageDao;
|
||||
/**
|
||||
* The {@link CharacterID} provider
|
||||
*/
|
||||
private final CharacterIDProvider charIdProvider;
|
||||
|
||||
@Inject
|
||||
protected DatabaseChatLoggingService(ChatMessageDAO chatMessageDao,
|
||||
CharacterIDProvider charIdProvider) {
|
||||
this.chatMessageDao = chatMessageDao;
|
||||
this.charIdProvider = charIdProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatMessage log(CharacterID sender, ChatChannel channel,
|
||||
String messageText) {
|
||||
final ChatMessage message = new ChatMessage();
|
||||
|
||||
// message type and destination
|
||||
message.setType(channel.getMessageType());
|
||||
switch (channel.getMessageType()) {
|
||||
case SHOUT: // if type is SHOUT the ChannelID is the CharacterID
|
||||
// (target)
|
||||
message.setTarget(charIdProvider.createID(channel.getChannelID()));
|
||||
break;
|
||||
default:
|
||||
message.setChannelID(channel.getChannelID());
|
||||
break;
|
||||
}
|
||||
|
||||
// message information
|
||||
message.setSender(sender);
|
||||
message.setDate(new Date());
|
||||
message.setMessage(messageText);
|
||||
|
||||
// save in database
|
||||
chatMessageDao.save(message, true);
|
||||
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import com.google.inject.Inject;
|
||||
import com.l2jserver.db.dao.CharacterDAO;
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.model.id.object.ClanID;
|
||||
import com.l2jserver.model.server.ChatMessage;
|
||||
import com.l2jserver.model.world.Clan;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
@@ -40,6 +41,8 @@ import com.l2jserver.util.factory.CollectionFactory;
|
||||
*/
|
||||
// @Depends(RegionService.class)
|
||||
public class SimpleChatService extends AbstractService implements ChatService {
|
||||
private final ChatLoggingService chatLoggingService;
|
||||
|
||||
/**
|
||||
* The {@link RegionService}
|
||||
*/
|
||||
@@ -83,7 +86,9 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
||||
* the region service
|
||||
*/
|
||||
@Inject
|
||||
public SimpleChatService(CharacterDAO charDao) {
|
||||
public SimpleChatService(ChatLoggingService chatLogService,
|
||||
CharacterDAO charDao) {
|
||||
this.chatLoggingService = chatLogService;
|
||||
// this.regionService = regionService;
|
||||
this.regionService = null;
|
||||
this.charDao = charDao;
|
||||
@@ -100,11 +105,11 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(CharacterID sender, ChatMessageDestination chat,
|
||||
String message, String extra)
|
||||
throws TargetNotFoundChatServiceException,
|
||||
public ChatMessage send(CharacterID sender, ChatMessageType chat, String message,
|
||||
String extra) throws TargetNotFoundChatServiceException,
|
||||
CannotChatToSelfChatServiceException,
|
||||
ChatBanActiveChatServiceException, ChatTargetOfflineServiceException {
|
||||
ChatBanActiveChatServiceException,
|
||||
ChatTargetOfflineServiceException {
|
||||
Preconditions.checkNotNull(sender, "sender");
|
||||
Preconditions.checkNotNull(message, "message");
|
||||
|
||||
@@ -131,9 +136,9 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
||||
channel = getAnnouncementChannel();
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
channel.send(sender, message);
|
||||
return channel.send(sender, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -210,13 +215,20 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
||||
.newSet();
|
||||
|
||||
@Override
|
||||
public void send(CharacterID sender, String message) {
|
||||
public ChatMessage send(CharacterID sender, String textMessage) {
|
||||
Preconditions.checkNotNull(sender, "sender");
|
||||
Preconditions.checkNotNull(message, "message");
|
||||
Preconditions.checkNotNull(textMessage, "message");
|
||||
// TODO throw exception if sender is banned from chat
|
||||
|
||||
// log this chat message
|
||||
ChatMessage message = chatLoggingService.log(sender, this,
|
||||
textMessage);
|
||||
|
||||
for (final ChatChannelListener listener : listeners) {
|
||||
listener.onMessage(this, sender, message);
|
||||
listener.onMessage(this, message);
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -230,6 +242,16 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
||||
Preconditions.checkNotNull(listener, "listener");
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChannelName() {
|
||||
return getMessageType().name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChannelID() {
|
||||
return getMessageType().id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -250,6 +272,16 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
||||
public CharacterID getDestination() {
|
||||
return character;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChannelID() {
|
||||
return character.getID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatMessageType getMessageType() {
|
||||
return ChatMessageType.SHOUT;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,6 +291,10 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
||||
*/
|
||||
private class GlobalChatChannelImpl extends ChatChannelImpl implements
|
||||
PublicChatChannel {
|
||||
@Override
|
||||
public ChatMessageType getMessageType() {
|
||||
return ChatMessageType.ALL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,6 +304,10 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
||||
*/
|
||||
private class TradeChatChannelImpl extends ChatChannelImpl implements
|
||||
PublicChatChannel {
|
||||
@Override
|
||||
public ChatMessageType getMessageType() {
|
||||
return ChatMessageType.TRADE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,6 +317,10 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
||||
*/
|
||||
private class AnnouncementChatChannelImpl extends ChatChannelImpl implements
|
||||
PublicChatChannel {
|
||||
@Override
|
||||
public ChatMessageType getMessageType() {
|
||||
return ChatMessageType.ANNOUNCEMENT;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,6 +345,11 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
||||
Preconditions.checkNotNull(clanID, "clanID");
|
||||
this.clanID = clanID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatMessageType getMessageType() {
|
||||
return ChatMessageType.CLAN;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -325,5 +374,10 @@ public class SimpleChatService extends AbstractService implements ChatService {
|
||||
Preconditions.checkNotNull(region, "region");
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatMessageType getMessageType() {
|
||||
return ChatMessageType.ALL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,13 +43,19 @@ import com.l2jserver.util.factory.CollectionFactory;
|
||||
public class GameGuardServiceImpl extends AbstractService implements
|
||||
GameGuardService {
|
||||
/**
|
||||
* The valid GG SHA1 response
|
||||
* The static key used to validate game guards
|
||||
*/
|
||||
private static final int[] STATIC_KEY = { 0x27533DD9, 0x2E72A51D,
|
||||
0x2017038B, 0xC35B1EA3 };
|
||||
/**
|
||||
* The valid GG SHA1 response -- for a single key, the answer must be always
|
||||
* the same
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private static final byte[] VALID_KEY_SHA1 = { (byte) 0x88, 0x40, 0x1c,
|
||||
(byte) 0xa7, (byte) 0x83, 0x42, (byte) 0xe9, 0x15, (byte) 0xde,
|
||||
(byte) 0xc3, 0x68, (byte) 0xf6, 0x2d, 0x23, (byte) 0xf1, 0x3f,
|
||||
(byte) 0xee, 0x68, 0x5b, (byte) 0xc5 };
|
||||
private static final byte[] STATIC_KEY_VALIDATION = { (byte) 0x88, 0x40,
|
||||
0x1c, (byte) 0xa7, (byte) 0x83, 0x42, (byte) 0xe9, 0x15,
|
||||
(byte) 0xde, (byte) 0xc3, 0x68, (byte) 0xf6, 0x2d, 0x23,
|
||||
(byte) 0xf1, 0x3f, (byte) 0xee, 0x68, 0x5b, (byte) 0xc5 };
|
||||
|
||||
/**
|
||||
* The map containing all pending futures
|
||||
@@ -75,15 +81,16 @@ public class GameGuardServiceImpl extends AbstractService implements
|
||||
|
||||
@Override
|
||||
public Future<GameGuardResponse> query(final Lineage2Client conn) {
|
||||
conn.write(new SM_GG_QUERY()).addListener(new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture future)
|
||||
throws Exception {
|
||||
if (future.getCause() != null) {
|
||||
futures.remove(conn);
|
||||
}
|
||||
}
|
||||
});
|
||||
conn.write(new SM_GG_QUERY(STATIC_KEY)).addListener(
|
||||
new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture future)
|
||||
throws Exception {
|
||||
if (future.getCause() != null) {
|
||||
futures.remove(conn);
|
||||
}
|
||||
}
|
||||
});
|
||||
final GGFuture future = new GGFuture();
|
||||
futures.put(conn, future);
|
||||
return future;
|
||||
|
||||
@@ -50,7 +50,8 @@ public class SecureBlowfishKeygenService extends AbstractService implements
|
||||
key[i] = (byte) random.nextSecureInt(0, 255);
|
||||
}
|
||||
|
||||
// the last 8 bytes are static
|
||||
// the last 8 bytes are static and are assumed by the client, they are
|
||||
// never sent in the SM_KEY packet
|
||||
key[8] = (byte) 0xc8;
|
||||
key[9] = (byte) 0x27;
|
||||
key[10] = (byte) 0x93;
|
||||
|
||||
Reference in New Issue
Block a user