Skip to content

Commit

Permalink
修复FFA模式重复给物品
Browse files Browse the repository at this point in the history
  • Loading branch information
lt-name committed Jan 9, 2024
1 parent 48ad999 commit 7ff30dd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
5 changes: 0 additions & 5 deletions src/main/java/cn/lanink/gunwar/room/base/RoomConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,30 +97,25 @@ public RoomConfig(@NotNull Level level, @NotNull Config config) {
"DemoFlashbang&1@weapon_projectile",
"DemoGun&1@weapon_gun"));
config.set("initialItems", defaultItems);
config.save();
}
this.initialItems.addAll(config.getStringList("initialItems"));
if (!config.exists("redTeamInitialItems")) {
config.set("redTeamInitialItems", new ArrayList<>());
config.save();
}
this.redTeamInitialItems.addAll(config.getStringList("redTeamInitialItems"));
if (!config.exists("blueTeamInitialItems")) {
config.set("blueTeamInitialItems", new ArrayList<>());
config.save();
}
this.blueTeamInitialItems.addAll(config.getStringList("blueTeamInitialItems"));

this.supplyType = SupplyType.valueOf(config.getString("supplyType", "ALL_ROUND").toUpperCase());
this.defaultSupplyConfig = SupplyConfigManager.getSupplyConfig(config.getString("supply", "DefaultSupply"));
if (!config.exists("redTeamSupply")) {
config.set("redTeamSupply", config.getString("supply", "DefaultSupply"));
config.save();
}
this.redTeamSupplyConfig = SupplyConfigManager.getSupplyConfig(config.getString("redTeamSupply"));
if (!config.exists("blueTeamSupply")) {
config.set("blueTeamSupply", config.getString("supply", "DefaultSupply"));
config.save();
}
this.blueTeamSupplyConfig = SupplyConfigManager.getSupplyConfig(config.getString("blueTeamSupply"));
this.supplyEnableTime = config.getInt("supplyEnableTime", 10); //商店启用时间 单位:秒 仅ONLY_ROUND_START商店模式有效
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import cn.lanink.gunwar.utils.Tools;
import cn.nukkit.Player;
import cn.nukkit.Server;
import cn.nukkit.inventory.PlayerInventory;
import cn.nukkit.level.Level;
import cn.nukkit.level.Position;
import cn.nukkit.math.Vector3;
Expand Down Expand Up @@ -37,11 +36,6 @@ public class FreeForAllModeRoom extends BaseRespawnModeRoom {
public FreeForAllModeRoom(@NotNull Level level, @NotNull Config config) throws RoomLoadException {
super(level, config);

//移除FFA模式不需要的配置
config.remove("redTeamInitialItems");
config.remove("blueTeamInitialItems");
config.save();

//针对未配置的情况,缩短默认的时间
this.respawnNeedTime = config.getInt("respawn-need-time", 3);

Expand All @@ -53,6 +47,18 @@ public FreeForAllModeRoom(@NotNull Level level, @NotNull Config config) throws R
}
}

@Override
public void saveConfig() {
super.saveConfig();

//移除FFA模式不需要的配置
config.remove("redTeamInitialItems");
config.remove("blueTeamInitialItems");
config.remove("roundEndCleanItem");

config.save();
}

@Override
public boolean canDamageTeammates() {
return true;
Expand Down Expand Up @@ -107,18 +113,8 @@ public void roundEnd(Team victory) {
public void playerRespawn(Player player) {
super.playerRespawn(player);

if (this.isRoundEndCleanItem()) {
player.getInventory().clearAll();
player.getUIInventory().clearAll();
} else {
//清除一些必须清除的特殊物品
PlayerInventory inventory = player.getInventory();
Tools.removeGunWarItem(inventory, Tools.getItem(10));
Tools.removeGunWarItem(inventory, Tools.getItem(11));
Tools.removeGunWarItem(inventory, Tools.getItem(12));
Tools.removeGunWarItem(inventory, Tools.getItem(13));
Tools.removeGunWarItem(inventory, Tools.getItem(201));
}
player.getInventory().clearAll();
player.getUIInventory().clearAll();

Tools.giveItem(this, player, Team.NULL, !this.isRoundEndCleanItem());

Expand Down

0 comments on commit 7ff30dd

Please sign in to comment.