테스트

aion-server 4.8

Gitteol
최고관리자 · 1 · 💬 0 클론/새로받기
 4.8 61f661d · 1 commits 새로받기(Pull)
game-server/data/handlers/playercommands/Symphony.java
package playercommands;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.aionemu.gameserver.model.gameobjects.player.Player;
import com.aionemu.gameserver.services.item.ItemPacketService.ItemAddType;
import com.aionemu.gameserver.services.item.ItemPacketService.ItemUpdateType;
import com.aionemu.gameserver.services.item.ItemService;
import com.aionemu.gameserver.services.item.ItemService.ItemUpdatePredicate;
import com.aionemu.gameserver.utils.ChatUtil;
import com.aionemu.gameserver.utils.chathandlers.PlayerCommand;

/**
 * @author Pad
 */
public class Symphony extends PlayerCommand {

    private static final Logger log = LoggerFactory.getLogger(Symphony.class);
    private static final int requiredItem = 182007170;
    private static final int[][] rewards = {
            // COLLECTION_COUNT, REWARD_ID, REWARD_COUNT
            { 3, 186000236, 10 }, // Blood Mark
            { 5, 186000399, 10 }, // Honorable Conqueror's Mark
            { 15, 166000195, 5 }, // Epsilon Enchantment Stone
            { 30, 186000055, 5 }, // Major Ancient Goblet
            { 50, 188053610, 3 }, // [Event] Level 70 Composite Manastone Bundle
            { 60, 188053295, 1 }, // Empyrean Plume Chest
            { 75, 188053903, 1 }, // Honorable Equipment of Conquest Box
            { 80, 166020000, 10 }, // Omega Enchantment Stone
            { 80, 166500002, 10 }, // Amplification Stone
            { 80, 166030005, 10 }, // Tempering Solution
            { 100, 188950015, 2 }, // Special Courier Pass (Eternal/Lv. 61-65)
            { 250, 187000090, 1 }, // Tiamat's Spectral Wings
            { 300, 188054238, 1 }, // Iron Wall Armor Box
    };

    public Symphony() {
        super("symphony", "Exchanges " + ChatUtil.item(requiredItem) + " for prizes.");

        setSyntaxInfo("Type .symphony <id> to get your reward:",
                "[1] - (" + rewards[0][0] + " copies): " + rewards[0][2] + "x " + ChatUtil.item(rewards[0][1]),
                "[2] - (" + rewards[1][0] + " copies): " + rewards[1][2] + "x " + ChatUtil.item(rewards[1][1]),
                "[3] - (" + rewards[2][0] + " copies): " + rewards[2][2] + "x " + ChatUtil.item(rewards[2][1]),
                "[4] - (" + rewards[3][0] + " copies): " + rewards[3][2] + "x " + ChatUtil.item(rewards[3][1]),
                "[5] - (" + rewards[4][0] + " copies): " + rewards[4][2] + "x " + ChatUtil.item(rewards[4][1]),
                "[6] - (" + rewards[5][0] + " copies): " + rewards[5][2] + "x " + ChatUtil.item(rewards[5][1]),
                "[7] - (" + rewards[6][0] + " copies): " + rewards[6][2] + "x " + ChatUtil.item(rewards[6][1]),
                "[8] - (" + rewards[7][0] + " copies): " + rewards[7][2] + "x " + ChatUtil.item(rewards[7][1]),
                "[9] - (" + rewards[8][0] + " copies): " + rewards[8][2] + "x " + ChatUtil.item(rewards[8][1]),
                "[10] - (" + rewards[9][0] + " copies): " + rewards[9][2] + "x " + ChatUtil.item(rewards[9][1]),
                "[11] - (" + rewards[10][0] + " copies): " + rewards[10][2] + "x " + ChatUtil.item(rewards[10][1]),
                "[12] - (" + rewards[11][0] + " copies): " + rewards[11][2] + "x " + ChatUtil.item(rewards[11][1]),
                "[13] - (" + rewards[12][0] + " copies): " + rewards[12][2] + "x " + ChatUtil.item(rewards[12][1]));
    }

    @Override
    public void execute(Player player, String... params) {
        if (params.length == 0) {
            sendInfo(player);
            return;
        }

        try {
            int rewardIndex = Integer.parseInt(params[0]) - 1;
            if (rewardIndex < 0 || rewardIndex >= rewards.length)
                throw new IllegalArgumentException();

            int cost = rewards[rewardIndex][0];
            if (player.getInventory().getItemCountByItemId(requiredItem) < cost || !player.getInventory().decreaseByItemId(requiredItem, cost))
                throw new IllegalArgumentException("You need " + cost + " " + ChatUtil.item(requiredItem) + " for this.");

            int itemId = rewards[rewardIndex][1];
            int itemCount = rewards[rewardIndex][2];

            long notAddedCount = ItemService.addItem(player, itemId, itemCount, true,
                    new ItemUpdatePredicate(ItemAddType.DECOMPOSABLE, ItemUpdateType.INC_CASH_ITEM));
            if (notAddedCount > 0) {
                log.warn("[Legendary Symphony Event] " + notAddedCount + "x " + itemId + " could not be added to " + player.getName() + "'s inventory.");
            }
        } catch (IllegalArgumentException e) {
            sendInfo(player, e instanceof NumberFormatException ? "Invalid prize." : e.getMessage());
        }
    }
}

📎 첨부파일

댓글 작성 권한이 없습니다.
🏆 포인트 랭킹 TOP 10
순위 닉네임 포인트
1 no_profile 타키야겐지쪽지보내기 자기소개 아이디로 검색 전체게시물 100,792
2 no_profile 동가리쪽지보내기 자기소개 아이디로 검색 전체게시물 58,079
3 no_profile 라프텔쪽지보내기 자기소개 아이디로 검색 전체게시물 51,771
4 no_profile 불멸의행복쪽지보내기 자기소개 아이디로 검색 전체게시물 36,923
5 서번트쪽지보내기 자기소개 아이디로 검색 전체게시물 35,011
6 no_profile 보거스쪽지보내기 자기소개 아이디로 검색 전체게시물 29,969
7 no_profile 닥터스쪽지보내기 자기소개 아이디로 검색 전체게시물 29,470
8 no_profile 검은고양이쪽지보내기 자기소개 아이디로 검색 전체게시물 29,077
9 no_profile Revolution쪽지보내기 자기소개 아이디로 검색 전체게시물 28,199
10 no_profile 호롤롤로쪽지보내기 자기소개 아이디로 검색 전체게시물 17,020
알림 0