mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-20 10:55:08 +01:00
Run spotlessApply
This commit is contained in:
@@ -45,7 +45,6 @@ import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -138,17 +137,17 @@ public class Avatar {
|
||||
|
||||
// Combat properties
|
||||
Stream.of(FightProperty.values())
|
||||
.map(FightProperty::getId)
|
||||
.filter(id -> (id > 0) && (id < 3000))
|
||||
.forEach(id -> this.setFightProperty(id, 0f));
|
||||
.map(FightProperty::getId)
|
||||
.filter(id -> (id > 0) && (id < 3000))
|
||||
.forEach(id -> this.setFightProperty(id, 0f));
|
||||
|
||||
this.setSkillDepotData(switch (this.getAvatarId()) {
|
||||
case GameConstants.MAIN_CHARACTER_MALE ->
|
||||
GameData.getAvatarSkillDepotDataMap().get(501);
|
||||
case GameConstants.MAIN_CHARACTER_FEMALE ->
|
||||
GameData.getAvatarSkillDepotDataMap().get(701);
|
||||
default -> data.getSkillDepot();
|
||||
});
|
||||
this.setSkillDepotData(
|
||||
switch (this.getAvatarId()) {
|
||||
case GameConstants.MAIN_CHARACTER_MALE -> GameData.getAvatarSkillDepotDataMap().get(501);
|
||||
case GameConstants.MAIN_CHARACTER_FEMALE -> GameData.getAvatarSkillDepotDataMap()
|
||||
.get(701);
|
||||
default -> data.getSkillDepot();
|
||||
});
|
||||
|
||||
// Set stats
|
||||
this.recalcStats();
|
||||
@@ -180,10 +179,8 @@ public class Avatar {
|
||||
* @return True if the avatar is a main character.
|
||||
*/
|
||||
public boolean isMainCharacter() {
|
||||
return List.of(
|
||||
GameConstants.MAIN_CHARACTER_MALE,
|
||||
GameConstants.MAIN_CHARACTER_FEMALE
|
||||
).contains(this.getAvatarId());
|
||||
return List.of(GameConstants.MAIN_CHARACTER_MALE, GameConstants.MAIN_CHARACTER_FEMALE)
|
||||
.contains(this.getAvatarId());
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
@@ -289,8 +286,8 @@ public class Avatar {
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the avatar's element to the target element.
|
||||
* Only applies if the avatar has the element in its 'candSkillDepot's.
|
||||
* Changes the avatar's element to the target element. Only applies if the avatar has the element
|
||||
* in its 'candSkillDepot's.
|
||||
*
|
||||
* @param newElement The new element to change to.
|
||||
* @return True if the element was changed, false otherwise.
|
||||
@@ -300,8 +297,8 @@ public class Avatar {
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the avatar's element to the target element.
|
||||
* Only applies if the avatar has the element in its 'candSkillDepot's.
|
||||
* Changes the avatar's element to the target element. Only applies if the avatar has the element
|
||||
* in its 'candSkillDepot's.
|
||||
*
|
||||
* @param elementTypeToChange The new element to change to.
|
||||
* @param notify Whether to notify the player of the change.
|
||||
|
||||
@@ -18,7 +18,6 @@ import emu.grasscutter.server.game.GameServer;
|
||||
import emu.grasscutter.server.packet.send.PacketDropHintNotify;
|
||||
import emu.grasscutter.server.packet.send.PacketGadgetAutoPickDropInfoNotify;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public final class DropSystem extends BaseGameSystem {
|
||||
@@ -47,7 +46,8 @@ public final class DropSystem extends BaseGameSystem {
|
||||
chestReward.get(i.getIndex()).add(i);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
Grasscutter.getLogger().error("Unable to load chest drop data. Please place ChestDrop.json in data folder.");
|
||||
Grasscutter.getLogger()
|
||||
.error("Unable to load chest drop data. Please place ChestDrop.json in data folder.");
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -59,7 +59,8 @@ public final class DropSystem extends BaseGameSystem {
|
||||
monsterDrop.get(i.getIndex()).add(i);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
Grasscutter.getLogger().error("Unable to load monster drop data. Please place MonsterDrop.json in data folder.");
|
||||
Grasscutter.getLogger()
|
||||
.error("Unable to load monster drop data. Please place MonsterDrop.json in data folder.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +98,8 @@ public final class DropSystem extends BaseGameSystem {
|
||||
List<GameItem> items = new ArrayList<>();
|
||||
processDrop(dropData, 1, items);
|
||||
if (dropData.isFallToGround()) {
|
||||
dropItems(items, ActionReason.MonsterDie, monster, monster.getScene().getPlayers().get(0), true);
|
||||
dropItems(
|
||||
items, ActionReason.MonsterDie, monster, monster.getScene().getPlayers().get(0), true);
|
||||
} else {
|
||||
for (Player p : monster.getScene().getPlayers()) {
|
||||
p.getInventory().addItems(items, ActionReason.MonsterDie);
|
||||
@@ -137,8 +139,8 @@ public final class DropSystem extends BaseGameSystem {
|
||||
}
|
||||
|
||||
private void processDrop(DropTableData dropData, int count, List<GameItem> items) {
|
||||
//TODO:Not clear on the meaning of some fields,like "dropLevel".Will ignore them.
|
||||
//TODO:solve drop limits,like everydayLimit.
|
||||
// TODO:Not clear on the meaning of some fields,like "dropLevel".Will ignore them.
|
||||
// TODO:solve drop limits,like everydayLimit.
|
||||
if (count > 1) {
|
||||
for (int i = 0; i < count; i++) processDrop(dropData, 1, items);
|
||||
return;
|
||||
@@ -158,7 +160,7 @@ public final class DropSystem extends BaseGameSystem {
|
||||
if (id == 0) continue;
|
||||
sum += i.getWeight();
|
||||
if (weight < sum) {
|
||||
//win the item
|
||||
// win the item
|
||||
int amount = calculateDropAmount(i) * count;
|
||||
if (amount <= 0) break;
|
||||
if (dropTable.containsKey(id)) {
|
||||
@@ -220,17 +222,25 @@ public final class DropSystem extends BaseGameSystem {
|
||||
/**
|
||||
* @param share Whether other players in the scene could see the drop items.
|
||||
*/
|
||||
private void dropItem(GameItem item, ActionReason reason, Player player, GameEntity bornFrom, boolean share) {
|
||||
private void dropItem(
|
||||
GameItem item, ActionReason reason, Player player, GameEntity bornFrom, boolean share) {
|
||||
DropMaterialData drop = GameData.getDropMaterialDataMap().get(item.getItemId());
|
||||
if ((drop != null && drop.isAutoPick()) || (item.getItemData().getItemType() == ItemType.ITEM_VIRTUAL && item.getItemData().getGadgetId() == 0)) {
|
||||
if ((drop != null && drop.isAutoPick())
|
||||
|| (item.getItemData().getItemType() == ItemType.ITEM_VIRTUAL
|
||||
&& item.getItemData().getGadgetId() == 0)) {
|
||||
giveItem(item, reason, player, share);
|
||||
} else {
|
||||
//TODO:solve share problem
|
||||
// TODO:solve share problem
|
||||
player.getScene().addDropEntity(item, bornFrom, player, share);
|
||||
}
|
||||
}
|
||||
|
||||
private void dropItems(List<GameItem> items, ActionReason reason, GameEntity bornFrom, Player player, boolean share) {
|
||||
private void dropItems(
|
||||
List<GameItem> items,
|
||||
ActionReason reason,
|
||||
GameEntity bornFrom,
|
||||
Player player,
|
||||
boolean share) {
|
||||
for (var i : items) {
|
||||
dropItem(i, reason, player, bornFrom, share);
|
||||
}
|
||||
@@ -249,7 +259,7 @@ public final class DropSystem extends BaseGameSystem {
|
||||
}
|
||||
|
||||
private void giveItems(List<GameItem> items, ActionReason reason, Player player, boolean share) {
|
||||
//don't know whether we need PacketDropHintNotify.
|
||||
// don't know whether we need PacketDropHintNotify.
|
||||
if (share) {
|
||||
for (var p : player.getScene().getPlayers()) {
|
||||
p.getInventory().addItems(items, reason);
|
||||
@@ -260,5 +270,4 @@ public final class DropSystem extends BaseGameSystem {
|
||||
player.sendPacket(new PacketDropHintNotify(items, player.getPosition().toProto()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import emu.grasscutter.utils.Position;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DropSystemLegacy extends BaseGameSystem {
|
||||
@@ -49,20 +48,27 @@ public class DropSystemLegacy extends BaseGameSystem {
|
||||
Grasscutter.getLogger().error("Unable to load drop data.", e);
|
||||
}
|
||||
}
|
||||
private void addDropEntity(DropData dd, Scene dropScene, ItemData itemData, Position pos, int num, Player target) {
|
||||
if (!dd.isGive() && (itemData.getItemType() != ItemType.ITEM_VIRTUAL || itemData.getGadgetId() != 0)) {
|
||||
|
||||
private void addDropEntity(
|
||||
DropData dd, Scene dropScene, ItemData itemData, Position pos, int num, Player target) {
|
||||
if (!dd.isGive()
|
||||
&& (itemData.getItemType() != ItemType.ITEM_VIRTUAL || itemData.getGadgetId() != 0)) {
|
||||
EntityItem entity = new EntityItem(dropScene, target, itemData, pos, num, dd.isShare());
|
||||
if (!dd.isShare())
|
||||
dropScene.addEntityToSingleClient(target, entity);
|
||||
else
|
||||
dropScene.addEntity(entity);
|
||||
if (!dd.isShare()) dropScene.addEntityToSingleClient(target, entity);
|
||||
else dropScene.addEntity(entity);
|
||||
} else {
|
||||
if (target != null) {
|
||||
target.getInventory().addItem(new GameItem(itemData, num), ActionReason.SubfieldDrop, true);
|
||||
} else {
|
||||
// target is null if items will be added are shared. no one could pick it up because of the combination(give + shared)
|
||||
// target is null if items will be added are shared. no one could pick it up because of the
|
||||
// combination(give + shared)
|
||||
// so it will be sent to all players' inventories directly.
|
||||
dropScene.getPlayers().forEach(x -> x.getInventory().addItem(new GameItem(itemData, num), ActionReason.SubfieldDrop, true));
|
||||
dropScene
|
||||
.getPlayers()
|
||||
.forEach(
|
||||
x ->
|
||||
x.getInventory()
|
||||
.addItem(new GameItem(itemData, num), ActionReason.SubfieldDrop, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,8 +99,7 @@ public class DropSystemLegacy extends BaseGameSystem {
|
||||
int id = em.getMonsterData().getId();
|
||||
if (getDropData().containsKey(id)) {
|
||||
for (DropData dd : getDropData().get(id)) {
|
||||
if (dd.isShare())
|
||||
processDrop(dd, em, null);
|
||||
if (dd.isShare()) processDrop(dd, em, null);
|
||||
else {
|
||||
for (Player gp : em.getScene().getPlayers()) {
|
||||
processDrop(dd, em, gp);
|
||||
|
||||
@@ -28,31 +28,46 @@ public class GadgetChest extends GadgetContent {
|
||||
* @return Whether we should remove the gadget.
|
||||
*/
|
||||
public boolean onInteract(Player player, GadgetInteractReq req) {
|
||||
//If bigWorldScript enabled,use new drop system.
|
||||
// If bigWorldScript enabled,use new drop system.
|
||||
if (Grasscutter.getConfig().server.game.enableScriptInBigWorld) {
|
||||
SceneGadget chest = getGadget().getMetaGadget();
|
||||
DropSystem dropSystem = player.getServer().getDropSystem();
|
||||
if (chest.boss_chest != null && chest.drop_tag != null) {
|
||||
//Boss chest drop
|
||||
//TODO:check for blossom chests
|
||||
// Boss chest drop
|
||||
// TODO:check for blossom chests
|
||||
if (req.getOpType() == InterOpType.INTER_OP_TYPE_START) {
|
||||
//Two steps
|
||||
player.sendPacket(new PacketGadgetInteractRsp(getGadget(), InteractType.INTERACT_TYPE_OPEN_CHEST, InterOpType.INTER_OP_TYPE_START));
|
||||
// Two steps
|
||||
player.sendPacket(
|
||||
new PacketGadgetInteractRsp(
|
||||
getGadget(),
|
||||
InteractType.INTERACT_TYPE_OPEN_CHEST,
|
||||
InterOpType.INTER_OP_TYPE_START));
|
||||
return false;
|
||||
}
|
||||
//TODO:check for take_num.(some boss rewards can only be claimed once a week.). Handle boss respawn.
|
||||
//TODO:should return Retcode.RET_RESIN_NOT_ENOUGH ?
|
||||
if (player.getResinManager().useResin(chest.boss_chest.resin) && dropSystem.handleBossChestDrop(chest.drop_tag, player)) {
|
||||
//Is it correct?
|
||||
player.getBattlePassManager().triggerMission(WatcherTriggerType.TRIGGER_WORLD_BOSS_REWARD, chest.boss_chest.monster_config_id, 1);
|
||||
// TODO:check for take_num.(some boss rewards can only be claimed once a week.). Handle boss
|
||||
// respawn.
|
||||
// TODO:should return Retcode.RET_RESIN_NOT_ENOUGH ?
|
||||
if (player.getResinManager().useResin(chest.boss_chest.resin)
|
||||
&& dropSystem.handleBossChestDrop(chest.drop_tag, player)) {
|
||||
// Is it correct?
|
||||
player
|
||||
.getBattlePassManager()
|
||||
.triggerMission(
|
||||
WatcherTriggerType.TRIGGER_WORLD_BOSS_REWARD,
|
||||
chest.boss_chest.monster_config_id,
|
||||
1);
|
||||
getGadget().updateState(ScriptGadgetState.ChestOpened);
|
||||
player.sendPacket(new PacketGadgetInteractRsp(this.getGadget(), InteractTypeOuterClass.InteractType.INTERACT_TYPE_OPEN_CHEST, InterOpType.INTER_OP_TYPE_FINISH));
|
||||
player.sendPacket(
|
||||
new PacketGadgetInteractRsp(
|
||||
this.getGadget(),
|
||||
InteractTypeOuterClass.InteractType.INTERACT_TYPE_OPEN_CHEST,
|
||||
InterOpType.INTER_OP_TYPE_FINISH));
|
||||
return true;
|
||||
}
|
||||
//if failed,fallback to legacy drop system.
|
||||
// if failed,fallback to legacy drop system.
|
||||
} else {
|
||||
//Normal chest drop
|
||||
//only the owner of the world can open chests.
|
||||
// Normal chest drop
|
||||
// only the owner of the world can open chests.
|
||||
if (player != player.getWorld().getHost()) return false;
|
||||
boolean status = false;
|
||||
if (chest.drop_tag != null) {
|
||||
@@ -62,31 +77,56 @@ public class GadgetChest extends GadgetContent {
|
||||
}
|
||||
if (status) {
|
||||
getGadget().updateState(ScriptGadgetState.ChestOpened);
|
||||
player.sendPacket(new PacketGadgetInteractRsp(getGadget(), InteractType.INTERACT_TYPE_OPEN_CHEST, InterOpType.INTER_OP_TYPE_FINISH));
|
||||
player.sendPacket(new PacketWorldChestOpenNotify(getGadget().getGroupId(), player.getSceneId(), chest.config_id));
|
||||
player.sendPacket(
|
||||
new PacketGadgetInteractRsp(
|
||||
getGadget(),
|
||||
InteractType.INTERACT_TYPE_OPEN_CHEST,
|
||||
InterOpType.INTER_OP_TYPE_FINISH));
|
||||
player.sendPacket(
|
||||
new PacketWorldChestOpenNotify(
|
||||
getGadget().getGroupId(), player.getSceneId(), chest.config_id));
|
||||
return true;
|
||||
}
|
||||
//if failed,fallback to legacy drop system.
|
||||
// if failed,fallback to legacy drop system.
|
||||
}
|
||||
Grasscutter.getLogger().warn("Can not solve chest drop: chest_drop_id = {} , drop_tag = {}.Fallback to legacy drop system.", chest.chest_drop_id, chest.drop_tag);
|
||||
Grasscutter.getLogger()
|
||||
.warn(
|
||||
"Can not solve chest drop: chest_drop_id = {} , drop_tag = {}.Fallback to legacy drop system.",
|
||||
chest.chest_drop_id,
|
||||
chest.drop_tag);
|
||||
}
|
||||
|
||||
//Legacy chest drop system
|
||||
var chestInteractHandlerMap = getGadget().getScene().getWorld().getServer().getWorldDataSystem().getChestInteractHandlerMap();
|
||||
// Legacy chest drop system
|
||||
var chestInteractHandlerMap =
|
||||
getGadget()
|
||||
.getScene()
|
||||
.getWorld()
|
||||
.getServer()
|
||||
.getWorldDataSystem()
|
||||
.getChestInteractHandlerMap();
|
||||
var handler = chestInteractHandlerMap.get(getGadget().getGadgetData().getJsonName());
|
||||
if (handler == null) {
|
||||
Grasscutter.getLogger().warn("Could not found the handler of this type of Chests {}", getGadget().getGadgetData().getJsonName());
|
||||
Grasscutter.getLogger()
|
||||
.warn(
|
||||
"Could not found the handler of this type of Chests {}",
|
||||
getGadget().getGadgetData().getJsonName());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (req.getOpType() == InterOpType.INTER_OP_TYPE_START && handler.isTwoStep()) {
|
||||
player.sendPacket(new PacketGadgetInteractRsp(getGadget(), InteractType.INTERACT_TYPE_OPEN_CHEST, InterOpType.INTER_OP_TYPE_START));
|
||||
player.sendPacket(
|
||||
new PacketGadgetInteractRsp(
|
||||
getGadget(), InteractType.INTERACT_TYPE_OPEN_CHEST, InterOpType.INTER_OP_TYPE_START));
|
||||
return false;
|
||||
} else {
|
||||
boolean success;
|
||||
if (handler instanceof BossChestInteractHandler bossChestInteractHandler) {
|
||||
success = bossChestInteractHandler.onInteract(this, player,
|
||||
req.getResinCostType() == ResinCostTypeOuterClass.ResinCostType.RESIN_COST_TYPE_CONDENSE);
|
||||
success =
|
||||
bossChestInteractHandler.onInteract(
|
||||
this,
|
||||
player,
|
||||
req.getResinCostType()
|
||||
== ResinCostTypeOuterClass.ResinCostType.RESIN_COST_TYPE_CONDENSE);
|
||||
} else {
|
||||
success = handler.onInteract(this, player);
|
||||
}
|
||||
@@ -95,7 +135,11 @@ public class GadgetChest extends GadgetContent {
|
||||
}
|
||||
|
||||
getGadget().updateState(ScriptGadgetState.ChestOpened);
|
||||
player.sendPacket(new PacketGadgetInteractRsp(this.getGadget(), InteractTypeOuterClass.InteractType.INTERACT_TYPE_OPEN_CHEST, InterOpType.INTER_OP_TYPE_FINISH));
|
||||
player.sendPacket(
|
||||
new PacketGadgetInteractRsp(
|
||||
this.getGadget(),
|
||||
InteractTypeOuterClass.InteractType.INTERACT_TYPE_OPEN_CHEST,
|
||||
InterOpType.INTER_OP_TYPE_FINISH));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -110,13 +154,13 @@ public class GadgetChest extends GadgetContent {
|
||||
if (bossChest != null) {
|
||||
var players = getGadget().getScene().getPlayers().stream().map(Player::getUid).toList();
|
||||
|
||||
gadgetInfo.setBossChest(BossChestInfo.newBuilder()
|
||||
.setMonsterConfigId(bossChest.monster_config_id)
|
||||
.setResin(bossChest.resin)
|
||||
.addAllQualifyUidList(players)
|
||||
.addAllRemainUidList(players)
|
||||
.build());
|
||||
gadgetInfo.setBossChest(
|
||||
BossChestInfo.newBuilder()
|
||||
.setMonsterConfigId(bossChest.monster_config_id)
|
||||
.setResin(bossChest.resin)
|
||||
.addAllQualifyUidList(players)
|
||||
.addAllRemainUidList(players)
|
||||
.build());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package emu.grasscutter.game.managers;
|
||||
|
||||
import static emu.grasscutter.config.Configuration.GAME_OPTIONS;
|
||||
|
||||
import emu.grasscutter.game.inventory.GameItem;
|
||||
import emu.grasscutter.game.player.BasePlayerManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
@@ -11,12 +13,10 @@ import emu.grasscutter.server.packet.send.PacketItemAddHintNotify;
|
||||
import emu.grasscutter.server.packet.send.PacketResinChangeNotify;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
|
||||
import static emu.grasscutter.config.Configuration.GAME_OPTIONS;
|
||||
|
||||
public class ResinManager extends BasePlayerManager {
|
||||
public static final int MAX_RESIN_BUYING_COUNT = 6;
|
||||
public static final int AMOUNT_TO_ADD = 60;
|
||||
public static final int[] HCOIN_NUM_TO_BUY_RESIN = new int[]{50, 100, 100, 150, 200, 200};
|
||||
public static final int[] HCOIN_NUM_TO_BUY_RESIN = new int[] {50, 100, 100, 150, 200, 200};
|
||||
|
||||
public ResinManager(Player player) {
|
||||
super(player);
|
||||
@@ -53,7 +53,10 @@ public class ResinManager extends BasePlayerManager {
|
||||
this.player.sendPacket(new PacketResinChangeNotify(this.player));
|
||||
|
||||
// Battle Pass trigger
|
||||
this.player.getBattlePassManager().triggerMission(WatcherTriggerType.TRIGGER_COST_MATERIAL, 106, amount); // Resin item id = 106
|
||||
this.player
|
||||
.getBattlePassManager()
|
||||
.triggerMission(
|
||||
WatcherTriggerType.TRIGGER_COST_MATERIAL, 106, amount); // Resin item id = 106
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -110,7 +113,11 @@ public class ResinManager extends BasePlayerManager {
|
||||
// Calculate how much resin we need to refill and update player.
|
||||
// Note that this can be more than one in case the player
|
||||
// logged off with uncapped resin and is now logging in again.
|
||||
int recharge = 1 + (int)((currentTime - this.player.getNextResinRefresh()) / GAME_OPTIONS.resinOptions.rechargeTime);
|
||||
int recharge =
|
||||
1
|
||||
+ (int)
|
||||
((currentTime - this.player.getNextResinRefresh())
|
||||
/ GAME_OPTIONS.resinOptions.rechargeTime);
|
||||
int newResin = Math.min(GAME_OPTIONS.resinOptions.cap, currentResin + recharge);
|
||||
int resinChange = newResin - currentResin;
|
||||
|
||||
@@ -120,9 +127,9 @@ public class ResinManager extends BasePlayerManager {
|
||||
// Set to zero to disable recharge (because on/over cap.)
|
||||
if (newResin >= GAME_OPTIONS.resinOptions.cap) {
|
||||
this.player.setNextResinRefresh(0);
|
||||
}
|
||||
else {
|
||||
int nextRecharge = this.player.getNextResinRefresh() + resinChange * GAME_OPTIONS.resinOptions.rechargeTime;
|
||||
} else {
|
||||
int nextRecharge =
|
||||
this.player.getNextResinRefresh() + resinChange * GAME_OPTIONS.resinOptions.rechargeTime;
|
||||
this.player.setNextResinRefresh(nextRecharge);
|
||||
}
|
||||
|
||||
@@ -158,7 +165,10 @@ public class ResinManager extends BasePlayerManager {
|
||||
return RetcodeOuterClass.Retcode.RET_RESIN_BOUGHT_COUNT_EXCEEDED_VALUE;
|
||||
}
|
||||
|
||||
var res = this.player.getInventory().payItem(201, HCOIN_NUM_TO_BUY_RESIN[this.player.getResinBuyCount()]);
|
||||
var res =
|
||||
this.player
|
||||
.getInventory()
|
||||
.payItem(201, HCOIN_NUM_TO_BUY_RESIN[this.player.getResinBuyCount()]);
|
||||
if (!res) {
|
||||
return RetcodeOuterClass.Retcode.RET_HCOIN_NOT_ENOUGH_VALUE;
|
||||
}
|
||||
@@ -166,7 +176,8 @@ public class ResinManager extends BasePlayerManager {
|
||||
this.player.setResinBuyCount(this.player.getResinBuyCount() + 1);
|
||||
this.player.setProperty(PlayerProperty.PROP_PLAYER_WAIT_SUB_HCOIN, 0);
|
||||
this.addResin(AMOUNT_TO_ADD);
|
||||
this.player.sendPacket(new PacketItemAddHintNotify(new GameItem(106, AMOUNT_TO_ADD), ActionReason.BuyResin));
|
||||
this.player.sendPacket(
|
||||
new PacketItemAddHintNotify(new GameItem(106, AMOUNT_TO_ADD), ActionReason.BuyResin));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -15,11 +15,15 @@ public class ItemUseAddItem extends ItemUseInt {
|
||||
super(useParam);
|
||||
try {
|
||||
this.count = Integer.parseInt(useParam[1]);
|
||||
} catch (NumberFormatException | ArrayIndexOutOfBoundsException ignored) {}
|
||||
} catch (NumberFormatException | ArrayIndexOutOfBoundsException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useItem(UseItemParams params) {
|
||||
return params.player.getInventory().addItem(this.i, this.count * params.count, ActionReason.PlayerUseItem);
|
||||
return params
|
||||
.player
|
||||
.getInventory()
|
||||
.addItem(this.i, this.count * params.count, ActionReason.PlayerUseItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,7 +303,15 @@ public class GameMainQuest {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasTeleportPostion(int subId, List<Position> posAndRot) {
|
||||
/**
|
||||
* Checks if the quest has a teleport position. Returns true if it does & adds the target position
|
||||
* & rotation to the list.
|
||||
*
|
||||
* @param subId The sub-quest ID.
|
||||
* @param posAndRot A list which will contain the position & rotation if the quest has a teleport.
|
||||
* @return True if the quest has a teleport position. False otherwise.
|
||||
*/
|
||||
public boolean hasTeleportPosition(int subId, List<Position> posAndRot) {
|
||||
TeleportData questTransmit = GameData.getTeleportDataMap().get(subId);
|
||||
if (questTransmit == null) return false;
|
||||
|
||||
@@ -338,7 +346,7 @@ public class GameMainQuest {
|
||||
1,
|
||||
new Position(
|
||||
transmitPosRot.get(0), transmitPosRot.get(1), transmitPosRot.get(2))); // rotation
|
||||
Grasscutter.getLogger().info("Succesfully loaded teleport data for subQuest {}", subId);
|
||||
Grasscutter.getLogger().debug("Successfully loaded teleport data for sub-quest {}.", subId);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,12 +20,11 @@ import emu.grasscutter.server.packet.send.PacketChapterStateNotify;
|
||||
import emu.grasscutter.server.packet.send.PacketDelQuestNotify;
|
||||
import emu.grasscutter.server.packet.send.PacketQuestListUpdateNotify;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
import it.unimi.dsi.fastutil.ints.IntIntImmutablePair;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.script.Bindings;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntIntImmutablePair;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.val;
|
||||
@@ -227,8 +226,9 @@ public class GameQuest {
|
||||
}
|
||||
|
||||
// Give items for completing the quest.
|
||||
this.getQuestData().getGainItems().forEach(item ->
|
||||
this.getOwner().getInventory().addItem(item, ActionReason.QuestItem));
|
||||
this.getQuestData()
|
||||
.getGainItems()
|
||||
.forEach(item -> this.getOwner().getInventory().addItem(item, ActionReason.QuestItem));
|
||||
|
||||
this.save();
|
||||
Grasscutter.getLogger().debug("Quest {} was completed.", subQuestId);
|
||||
@@ -283,23 +283,26 @@ public class GameQuest {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A list of dungeon IDs associated with the quest's 'QUEST_CONTENT_ENTER_DUNGEON' triggers.
|
||||
* The first element of the pair is the dungeon ID.
|
||||
* The second element of the pair is the dungeon's scene point.
|
||||
* @return A list of dungeon IDs associated with the quest's 'QUEST_CONTENT_ENTER_DUNGEON'
|
||||
* triggers. The first element of the pair is the dungeon ID. The second element of the pair
|
||||
* is the dungeon's scene point.
|
||||
*/
|
||||
public List<IntIntImmutablePair> getDungeonIds() {
|
||||
var conditions = this.getQuestData().getFinishCond().stream()
|
||||
.filter(cond -> cond.getType() == QuestContent.QUEST_CONTENT_ENTER_DUNGEON)
|
||||
.toList();
|
||||
var conditions =
|
||||
this.getQuestData().getFinishCond().stream()
|
||||
.filter(cond -> cond.getType() == QuestContent.QUEST_CONTENT_ENTER_DUNGEON)
|
||||
.toList();
|
||||
|
||||
return conditions.stream()
|
||||
.map(condition -> {
|
||||
var params = condition.getParam();
|
||||
// The first parameter is the ID of the dungeon.
|
||||
// The second parameter is the dungeon entry's scene point.
|
||||
// ex. [1, 1] = dungeon ID 1, scene point 1 or 'KaeyaDungeon'.
|
||||
return new IntIntImmutablePair(params[0], params[1]);
|
||||
}).toList();
|
||||
.map(
|
||||
condition -> {
|
||||
var params = condition.getParam();
|
||||
// The first parameter is the ID of the dungeon.
|
||||
// The second parameter is the dungeon entry's scene point.
|
||||
// ex. [1, 1] = dungeon ID 1, scene point 1 or 'KaeyaDungeon'.
|
||||
return new IntIntImmutablePair(params[0], params[1]);
|
||||
})
|
||||
.toList();
|
||||
}
|
||||
|
||||
public void save() {
|
||||
|
||||
@@ -52,7 +52,9 @@ public class ExecNotifyGroupLua extends QuestExecHandler {
|
||||
quest.getState() == QuestState.QUEST_STATE_FINISHED
|
||||
? EventType.EVENT_QUEST_FINISH
|
||||
: EventType.EVENT_QUEST_START;
|
||||
scriptManager.callEvent(new ScriptArgs(groupId, eventType, quest.getSubQuestId()).setEventSource(String.valueOf(quest.getSubQuestId())));
|
||||
scriptManager.callEvent(
|
||||
new ScriptArgs(groupId, eventType, quest.getSubQuestId())
|
||||
.setEventSource(String.valueOf(quest.getSubQuestId())));
|
||||
});
|
||||
|
||||
return true;
|
||||
|
||||
@@ -40,17 +40,11 @@ import emu.grasscutter.server.packet.send.*;
|
||||
import emu.grasscutter.utils.KahnsSort;
|
||||
import emu.grasscutter.utils.Position;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.val;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.val;
|
||||
@@ -311,8 +305,7 @@ public final class Scene {
|
||||
// TODO:optimize EntityItem.java. Maybe we should make other players can't see
|
||||
// the ItemEntity.
|
||||
ItemData itemData = GameData.getItemDataMap().get(item.getItemId());
|
||||
if (itemData == null)
|
||||
return;
|
||||
if (itemData == null) return;
|
||||
if (itemData.isEquip()) {
|
||||
float range = (1.5f + (.05f * item.getCount()));
|
||||
for (int j = 0; j < item.getCount(); j++) {
|
||||
@@ -321,11 +314,16 @@ public final class Scene {
|
||||
addEntity(entity);
|
||||
}
|
||||
} else {
|
||||
EntityItem entity = new EntityItem(this, player, itemData, bornForm.getPosition().clone().addY(0.5f),
|
||||
item.getCount(), share);
|
||||
EntityItem entity =
|
||||
new EntityItem(
|
||||
this,
|
||||
player,
|
||||
itemData,
|
||||
bornForm.getPosition().clone().addY(0.5f),
|
||||
item.getCount(),
|
||||
share);
|
||||
addEntity(entity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addEntities(Collection<? extends GameEntity> entities) {
|
||||
@@ -333,7 +331,7 @@ public final class Scene {
|
||||
}
|
||||
|
||||
public synchronized void addEntities(
|
||||
Collection<? extends GameEntity> entities, VisionType visionType) {
|
||||
Collection<? extends GameEntity> entities, VisionType visionType) {
|
||||
if (entities == null || entities.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -448,8 +446,13 @@ public final class Scene {
|
||||
// Reward drop
|
||||
var world = this.getWorld();
|
||||
if (target instanceof EntityMonster monster && this.getSceneType() != SceneType.SCENE_DUNGEON) {
|
||||
if (monster.getMetaMonster() != null && !world.getServer().getDropSystem().handleMonsterDrop(monster)) {
|
||||
Grasscutter.getLogger().debug("Can not solve monster drop: drop_id = {}, drop_tag = {}. Falling back to legacy drop system.", monster.getMetaMonster().drop_id, monster.getMetaMonster().drop_tag);
|
||||
if (monster.getMetaMonster() != null
|
||||
&& !world.getServer().getDropSystem().handleMonsterDrop(monster)) {
|
||||
Grasscutter.getLogger()
|
||||
.debug(
|
||||
"Can not solve monster drop: drop_id = {}, drop_tag = {}. Falling back to legacy drop system.",
|
||||
monster.getMetaMonster().drop_id,
|
||||
monster.getMetaMonster().drop_tag);
|
||||
getWorld().getServer().getDropSystemLegacy().callDrop(monster);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,10 +279,10 @@ public class World implements Iterable<Player> {
|
||||
|
||||
val sceneData = GameData.getSceneDataMap().get(sceneId);
|
||||
if (dungeonData != null) {
|
||||
teleportProps.teleportTo(dungeonData.getStartPosition())
|
||||
.teleportRot(dungeonData.getStartRotation());
|
||||
teleportProps.enterType(EnterType.ENTER_TYPE_DUNGEON)
|
||||
.enterReason(EnterReason.DungeonEnter);
|
||||
teleportProps
|
||||
.teleportTo(dungeonData.getStartPosition())
|
||||
.teleportRot(dungeonData.getStartRotation());
|
||||
teleportProps.enterType(EnterType.ENTER_TYPE_DUNGEON).enterReason(EnterReason.DungeonEnter);
|
||||
} else if (player.getSceneId() == sceneId) {
|
||||
teleportProps.enterType(EnterType.ENTER_TYPE_GOTO);
|
||||
} else if (sceneData != null && sceneData.getSceneType() == SceneType.SCENE_HOME_WORLD) {
|
||||
|
||||
Reference in New Issue
Block a user