mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-16 17:05:20 +01:00
Fix whitespace [skip actions]
This commit is contained in:
@@ -31,59 +31,59 @@ import java.util.List;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
public class CombineManger extends BaseGameSystem {
|
||||
private final static Int2ObjectMap<List<Integer>> reliquaryDecomposeData = new Int2ObjectOpenHashMap<>();
|
||||
private final static Int2ObjectMap<List<Integer>> reliquaryDecomposeData = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
public CombineManger(GameServer server) {
|
||||
super(server);
|
||||
}
|
||||
|
||||
public static void initialize() {
|
||||
// Read the data we need for strongbox.
|
||||
try (Reader fileReader = DataLoader.loadReader("ReliquaryDecompose.json")) {
|
||||
List<ReliquaryDecomposeEntry> decomposeEntries = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, ReliquaryDecomposeEntry.class).getType());
|
||||
// Read the data we need for strongbox.
|
||||
try (Reader fileReader = DataLoader.loadReader("ReliquaryDecompose.json")) {
|
||||
List<ReliquaryDecomposeEntry> decomposeEntries = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, ReliquaryDecomposeEntry.class).getType());
|
||||
|
||||
for (ReliquaryDecomposeEntry entry : decomposeEntries) {
|
||||
reliquaryDecomposeData.put(entry.getConfigId(), entry.getItems());
|
||||
}
|
||||
for (ReliquaryDecomposeEntry entry : decomposeEntries) {
|
||||
reliquaryDecomposeData.put(entry.getConfigId(), entry.getItems());
|
||||
}
|
||||
|
||||
Grasscutter.getLogger().debug("Loaded {} reliquary decompose entries.", reliquaryDecomposeData.size());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Grasscutter.getLogger().error("Unable to load reliquary decompose data.", ex);
|
||||
}
|
||||
}
|
||||
Grasscutter.getLogger().debug("Loaded {} reliquary decompose entries.", reliquaryDecomposeData.size());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Grasscutter.getLogger().error("Unable to load reliquary decompose data.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean unlockCombineDiagram(Player player, GameItem diagramItem) {
|
||||
// Make sure this is actually a diagram.
|
||||
if (!diagramItem.getItemData().getItemUse().get(0).getUseOp().equals("ITEM_USE_UNLOCK_COMBINE")) {
|
||||
return false;
|
||||
}
|
||||
// Make sure this is actually a diagram.
|
||||
if (!diagramItem.getItemData().getItemUse().get(0).getUseOp().equals("ITEM_USE_UNLOCK_COMBINE")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Determine the combine item we should unlock.
|
||||
int combineId = Integer.parseInt(diagramItem.getItemData().getItemUse().get(0).getUseParam().get(0));
|
||||
// Determine the combine item we should unlock.
|
||||
int combineId = Integer.parseInt(diagramItem.getItemData().getItemUse().get(0).getUseParam().get(0));
|
||||
|
||||
// Remove the diagram from the player's inventory.
|
||||
// We need to do this here, before sending CombineFormulaDataNotify, or the the combine UI won't correctly
|
||||
// update when unlocking the diagram.
|
||||
player.getInventory().removeItem(diagramItem, 1);
|
||||
// Remove the diagram from the player's inventory.
|
||||
// We need to do this here, before sending CombineFormulaDataNotify, or the the combine UI won't correctly
|
||||
// update when unlocking the diagram.
|
||||
player.getInventory().removeItem(diagramItem, 1);
|
||||
|
||||
// Tell the client that this diagram is now unlocked and add the unlocked item to the player.
|
||||
player.getUnlockedCombines().add(combineId);
|
||||
player.sendPacket(new PacketCombineFormulaDataNotify(combineId));
|
||||
// Tell the client that this diagram is now unlocked and add the unlocked item to the player.
|
||||
player.getUnlockedCombines().add(combineId);
|
||||
player.sendPacket(new PacketCombineFormulaDataNotify(combineId));
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public CombineResult combineItem(Player player, int cid, int count){
|
||||
public CombineResult combineItem(Player player, int cid, int count) {
|
||||
// check config exist
|
||||
if(!GameData.getCombineDataMap().containsKey(cid)){
|
||||
if (!GameData.getCombineDataMap().containsKey(cid)) {
|
||||
player.getWorld().getHost().sendPacket(new PacketCombineRsp());
|
||||
return null;
|
||||
}
|
||||
|
||||
CombineData combineData = GameData.getCombineDataMap().get(cid);
|
||||
|
||||
if(combineData.getPlayerLevel() > player.getLevel()){
|
||||
if (combineData.getPlayerLevel() > player.getLevel()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class CombineManger extends BaseGameSystem {
|
||||
player.sendPacket(new PacketReliquaryDecomposeRsp(Retcode.RET_RELIQUARY_DECOMPOSE_PARAM_ERROR));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Check if the number of input items matches the output count.
|
||||
if (input.size() != count * 3) {
|
||||
player.sendPacket(new PacketReliquaryDecomposeRsp(Retcode.RET_RELIQUARY_DECOMPOSE_PARAM_ERROR));
|
||||
@@ -144,7 +144,7 @@ public class CombineManger extends BaseGameSystem {
|
||||
List<Long> resultItems = new ArrayList<>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
int itemId = Utils.drawRandomListElement(possibleDrops);
|
||||
GameItem newReliquary = new GameItem(itemId, 1);
|
||||
GameItem newReliquary = new GameItem(itemId, 1);
|
||||
|
||||
player.getInventory().addItem(newReliquary);
|
||||
resultItems.add(newReliquary.getGuid());
|
||||
|
||||
Reference in New Issue
Block a user