001package com.ericlam.mc.minigames.core.manager; 002 003import com.ericlam.mc.minigames.core.arena.Arena; 004import com.ericlam.mc.minigames.core.arena.CreateArena; 005import com.ericlam.mc.minigames.core.exception.NoMoreElementException; 006import com.ericlam.mc.minigames.core.exception.arena.create.*; 007import com.google.common.collect.ImmutableList; 008import org.bukkit.Location; 009import org.bukkit.World; 010import org.bukkit.entity.Player; 011 012import java.io.File; 013import java.util.List; 014import java.util.concurrent.CompletableFuture; 015 016/** 017 * 場地設置管理器 018 */ 019public interface ArenaCreateManager { 020 021 /** 022 * 設置作者 023 * 024 * @param arena 場地 025 * @param author 作者 026 * @throws ArenaNotExistException 場地不存在時 027 */ 028 void setAuthor(String arena, String author) throws ArenaNotExistException; 029 030 /** 031 * 設置顯示名稱 032 * 033 * @param arena 場地 034 * @param displayName 顯示名稱 035 * @throws ArenaNotExistException 場地不存在時 036 */ 037 void setDisplayName(String arena, String displayName) throws ArenaNotExistException; 038 039 /** 040 * 設置場地名稱 041 * 042 * @param arena 場地 043 * @param newName 名稱 044 * @throws ArenaNotExistException 場地不存在時 045 * @throws ArenaNameExistException 場地名與其他場地重複時 046 */ 047 void setName(String arena, String newName) throws ArenaNotExistException, ArenaNameExistException; 048 049 /** 050 * 添加位置 051 * 052 * @param arena 場地 053 * @param warp 地標 054 * @param location 新位置 055 * @throws ArenaNotExistException 場地不存在時 056 * @throws WarpNotExistException 地標不存在時 057 * @throws LocationMaxReachedException 最大設置數達到時 058 */ 059 void addSpawn(String arena, String warp, Location location) throws ArenaNotExistException, WarpNotExistException, LocationMaxReachedException; 060 061 /** 062 * 刪除上一個位置 063 * 064 * @param arena 場地 065 * @param warp 地標 066 * @throws ArenaNotExistException 場地不存在時 067 * @throws WarpNotExistException 地標不存在時 068 * @throws NoMoreLocationException 沒有更多位置時 069 */ 070 void removeSpawn(String arena, String warp) throws ArenaNotExistException, WarpNotExistException, NoMoreLocationException; 071 072 /** 073 * 新增地標 074 * 075 * @param arena 場地 076 * @param warp 新地標 077 * @throws ArenaNotExistException 場地不存在時 078 * @throws WarpExistException 地標已存在時 079 * @throws IllegalWarpException 地標不符合規範時 080 */ 081 void createWarp(String arena, String warp) throws ArenaNotExistException, WarpExistException, IllegalWarpException; 082 083 /** 084 * 刪除地標 085 * 086 * @param arena 場地 087 * @param warp 地標 088 * @throws ArenaNotExistException 場地不存在時 089 * @throws WarpNotExistException 地標不存在時 090 */ 091 void removeWarp(String arena, String warp) throws ArenaNotExistException, WarpNotExistException; 092 093 /** 094 * 保存場地 095 * 096 * @param arena 場地 097 * @return 異步保存 098 * @throws SetUpNotFinishException 設置尚未完成時 099 * @throws ArenaNotExistException 場地不存在時 100 * @throws ArenaUnchangedExcpetion 場地沒有被變更時 101 * @throws ArenaNotBackupException 場地尚未備份時 102 */ 103 CompletableFuture<Boolean> saveArena(String arena) throws SetUpNotFinishException, ArenaNotExistException, ArenaUnchangedExcpetion, ArenaNotBackupException; 104 105 106 /** 107 * @param arena 場地 108 * @return 異步備份地圖 109 * @throws ArenaNotExistException 場地不存在時 110 * @throws BackupNotAllowedException 遊戲場地恢復機制未被啟用時 111 */ 112 CompletableFuture<File> backupArena(String arena) throws ArenaNotExistException, BackupNotAllowedException; 113 114 /** 115 * 獲取場地資訊 116 * 117 * @param arena 場地 118 * @return 資訊列 119 * @throws ArenaNotExistException 場地不存在時 120 */ 121 String[] getArenaInfo(String arena) throws ArenaNotExistException; 122 123 /** 124 * 刪除場地 125 * 126 * @param arena 場地 127 * @return 異步運作 128 * @throws ArenaNotExistException 場地不存在時 129 */ 130 CompletableFuture<Boolean> deleteArena(String arena) throws ArenaNotExistException; 131 132 /** 133 * 創建場地 134 * 135 * @param name 場地名稱 136 * @param player 玩家 137 * @throws ArenaExistException 場地名稱已存在時 138 */ 139 void createArena(String name, Player player) throws ArenaExistException; 140 141 /** 142 * 獲取該世界內存在的場地列 143 * 144 * @param world 世界 145 * @return 該世界內存在的場地列 146 */ 147 Arena[] getArenasFromWorld(World world); 148 149 /** 150 * 獲取所有場地列表 151 * 152 * @return 無法被變更的場地列表 153 */ 154 ImmutableList<Arena> getArenaList(); 155 156 /** 157 * 獲取地標列表 158 * 159 * @param arena 場地 160 * @return 地標列表 161 * @throws ArenaNotExistException 場地不存在時 162 */ 163 List<String> getWarpList(String arena) throws ArenaNotExistException; 164 165 /** 166 * 獲取該場地的編輯容器 167 * 168 * @param arena 場地 169 * @return 可編輯的場地容器 170 * @throws ArenaNotExistException 場地不存在時 171 */ 172 CreateArena getCreateArena(String arena) throws ArenaNotExistException; 173 174 /** 175 * 新增場地描述 176 * 177 * @param arena 場地 178 * @param text 文字內容 179 * @throws ArenaNotExistException 場地不存在時 180 */ 181 void addDescriptionLine(String arena, String text) throws ArenaNotExistException; 182 183 /** 184 * 刪除上一個場地描述 185 * 186 * @param arena 場地 187 * @throws NoMoreElementException 沒有更多描述時 188 * @throws ArenaNotExistException 場地不存在時 189 */ 190 void removeDescriptionLine(String arena) throws NoMoreElementException, ArenaNotExistException; 191}