From 8774e24b5ff1ed17716bcb4ac4e568da60e56eee Mon Sep 17 00:00:00 2001 From: Mads Boddum Date: Wed, 19 Oct 2016 12:32:54 +0200 Subject: [PATCH] Added more logging to BuffService --- src/services/commands/BuffService.java | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/services/commands/BuffService.java b/src/services/commands/BuffService.java index cea73d653..c6c109850 100644 --- a/src/services/commands/BuffService.java +++ b/src/services/commands/BuffService.java @@ -193,19 +193,21 @@ public class BuffService extends Service { } String groupName = buffData.getGroupName(); + + // Let's see if they have any buffs in this group already + Stream buffsToRemove = receiver.getBuffs().keySet().stream().filter(candidate -> checkGroup(groupName, candidate, buffData)); + long groupBuffCount = buffsToRemove.count(); - if (!groupName.isEmpty()) { - // Let's see if they have any buffs in this group already - Stream buffCrcStream = receiver.getBuffs().keySet().stream().filter(candidate -> checkGroup(groupName, candidate, buffData)); - - // If not, let's just stop here. No reason to increase network traffic with effects and deltas. - if(buffCrcStream.count() <= 0) { - return; - } - - buffCrcStream.forEach(crc -> removeBuff(receiver, crc, false)); + // If not, let's just stop here + if (groupBuffCount <= 0) { + return; + } else if (groupBuffCount > 1) { + // Only one buff per group should be possible + Log.e(this, "%s had multiple buffs from the same group %s!", receiver, groupName); } - + + buffsToRemove.forEach(crc -> removeBuff(receiver, crc, false)); + // The client-side timer hinges on the playTime of the PlayerObject. // We therefore must update it to current time, so the timer starts from full duration receiver.getPlayerObject().updatePlayTime();