mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
Some changes to logged data and a NPE prevention.
This commit is contained in:
parent
3e4c9dc645
commit
41ba4c9540
3 changed files with 19 additions and 14 deletions
|
@ -24,8 +24,7 @@
|
|||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
*/
|
||||
package mage.server;
|
||||
|
||||
import java.text.DateFormat;
|
||||
|
@ -153,22 +152,22 @@ public class ChatSession {
|
|||
if (!message.isEmpty()) {
|
||||
boolean remove = false;
|
||||
final String msg = message;
|
||||
final String time = (withTime ? timeFormatter.format(new Date()):"");
|
||||
final String time = (withTime ? timeFormatter.format(new Date()) : "");
|
||||
final String username = userName;
|
||||
logger.trace("Broadcasting '" + msg + "' for " + chatId);
|
||||
for (UUID userId: clients.keySet()) {
|
||||
for (UUID userId : clients.keySet()) {
|
||||
User user = UserManager.getInstance().getUser(userId);
|
||||
if (user != null) {
|
||||
user.fireCallback(new ClientCallback("chatMessage", chatId, new ChatMessage(username, msg, time, color, messageType, soundToPlay)));
|
||||
}
|
||||
else {
|
||||
logger.error("User not found but connected to chat - userId: " + userId + " chatId: " + chatId);
|
||||
} else {
|
||||
// Happens when a user post to a chat while other users left chat at nearly the same time
|
||||
logger.trace("User not found but connected to chat - userId: " + userId + " chatId: " + chatId);
|
||||
clientsToRemove.add(userId);
|
||||
remove = true;
|
||||
}
|
||||
}
|
||||
if (remove) {
|
||||
for (UUID userIdToRemove: clientsToRemove) {
|
||||
for (UUID userIdToRemove : clientsToRemove) {
|
||||
clients.remove(userIdToRemove);
|
||||
}
|
||||
clientsToRemove.clear();
|
||||
|
|
|
@ -1159,6 +1159,9 @@ public abstract class AbilityImpl implements Ability {
|
|||
public MageObject getSourceObject(Game game) {
|
||||
if (sourceObject == null) {
|
||||
setSourceObject(null, game);
|
||||
if (sourceObject == null) {
|
||||
logger.warn("Source object could not be retrieved: " + this.getRule());
|
||||
}
|
||||
}
|
||||
return sourceObject;
|
||||
}
|
||||
|
|
|
@ -106,7 +106,10 @@ public class ManaPoolItem implements Serializable {
|
|||
}
|
||||
|
||||
public UUID getSourceId() {
|
||||
return sourceObject.getId();
|
||||
if (sourceObject != null) {
|
||||
return sourceObject.getId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public UUID getOriginalId() {
|
||||
|
|
Loading…
Reference in a new issue