private async void OnEvent_ChatMessage(ChatType chatType, string msg, Player player) { try { switch (msg) { case "/votereward": { _traceSource.TraceInformation("{0} is trying to claim a voting reward.", player); if (await DoesPlayerHaveReward(player)) { _traceSource.TraceInformation("{0} has a voting reward to claim; show reward to player.", player); //--- find reward level int rewardLevel = 0; ItemStacks rewardList = new ItemStacks(); for (var idx = 0; idx < _config.VotingRewards.Count; idx++) { var reward = _config.VotingRewards[idx]; if (playerVotes >= reward.MinVotesNeeded) { if (!_config.Cumulative) { rewardList.Clear(); } rewardList.AddStacks(reward.Rewards); } } var rewardItems = rewardList.ToEleonArray(); var itemExchangeInfo = await player.DoItemExchange("Voting Reward", "Remember to vote everyday. Enjoy!", "Close", rewardItems); _traceSource.TraceInformation("{0} has closed the voting reward UI.", player); if (!rewardItems.AreTheSame(itemExchangeInfo.items)) { _traceSource.TraceInformation("{0} took at least some of the voting reward.", player); await MarkRewardClaimed(player); _traceSource.TraceInformation("{0} claimed a voting reward.", player); } else { _traceSource.TraceInformation("{0} didn't claim any reward items.", player); } } else { await MarkRewardClaimed(player); _traceSource.TraceInformation("No unclaimed voting reward found for {0}.", player); await player.SendAlarmMessage("No unclaimed voting reward found."); } } break; } } catch (Exception ex) { _traceSource.TraceEvent(TraceEventType.Error, 1, ex.ToString()); } }