package com.yutian.minerwar.liveevent;

import com.io.yutian.mclive.event.LiveGiftEvents;
import com.yutian.minerwar.util.GiftUtil;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import tools.GameUtil;
import tools.RandomUtil;

public class GiftListener implements Listener {
    @EventHandler
    public void onGfit(LiveGiftEvents e) {
        Player zhubo = e.getPlayer();
        String userName = ""+ RandomUtil.getRandomInt(10000,90000);
        if(e.getUser().nickName() != null) {
            userName = e.getUser().nickName();
        }
        String giftName = e.getName();
        int amount = (int) e.getAmount();
        if (amount <= 0) {
            amount = 1;
        }
        String show_userName = GameUtil.hideName(userName);
        GiftUtil.simulatedGiftEffect(zhubo,show_userName,giftName,amount);
    }
}
