mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-04 23:32:55 +08:00
refactor: replace size() == 0
with isEmpty()
This commit is contained in:
parent
da61d30f44
commit
ef58ab3e5a
@ -69,7 +69,7 @@ public final class AchievementCommand implements CommandHandler {
|
||||
|
||||
@Override
|
||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
||||
if (args.size() < 1) {
|
||||
if (args.isEmpty()) {
|
||||
this.sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
@ -88,7 +88,7 @@ public final class AchievementCommand implements CommandHandler {
|
||||
|
||||
private void grant(
|
||||
Player sender, Player targetPlayer, Achievements achievements, List<String> args) {
|
||||
if (args.size() < 1) {
|
||||
if (args.isEmpty()) {
|
||||
this.sendUsageMessage(sender);
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ public final class AchievementCommand implements CommandHandler {
|
||||
|
||||
private void revoke(
|
||||
Player sender, Player targetPlayer, Achievements achievements, List<String> args) {
|
||||
if (args.size() < 1) {
|
||||
if (args.isEmpty()) {
|
||||
this.sendUsageMessage(sender);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ public final class AnnounceCommand implements CommandHandler {
|
||||
@Override
|
||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
||||
var manager = Grasscutter.getGameServer().getAnnouncementSystem();
|
||||
if (args.size() < 1) {
|
||||
if (args.isEmpty()) {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public final class ClearCommand implements CommandHandler {
|
||||
// Extract any tagged int arguments (e.g. "lv90", "x100", "r5")
|
||||
parseIntParameters(args, param, intCommandHandlers);
|
||||
|
||||
if (args.size() < 1) {
|
||||
if (args.isEmpty()) {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public final class EnterDungeonCommand implements CommandHandler {
|
||||
|
||||
@Override
|
||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
||||
if (args.size() < 1) {
|
||||
if (args.isEmpty()) {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ public final class GiveCommand implements CommandHandler {
|
||||
parseIntParameters(args, param, intCommandHandlers);
|
||||
|
||||
// At this point, first remaining argument MUST be itemId/avatarId
|
||||
if (args.size() < 1) {
|
||||
if (args.isEmpty()) {
|
||||
sendUsageMessage(sender); // Reachable if someone does `/give lv90` or similar
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
@ -362,7 +362,7 @@ public final class GiveCommand implements CommandHandler {
|
||||
|
||||
@Override
|
||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
||||
if (args.size() < 1) { // *No args*
|
||||
if (args.isEmpty()) { // *No args*
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
@ -19,14 +19,14 @@ public final class ListCommand implements CommandHandler {
|
||||
Map<Integer, Player> playersMap = Grasscutter.getGameServer().getPlayers();
|
||||
boolean needUID = false;
|
||||
|
||||
if (args.size() > 0) {
|
||||
if (!args.isEmpty()) {
|
||||
needUID = args.get(0).equals("uid");
|
||||
}
|
||||
|
||||
CommandHandler.sendMessage(
|
||||
sender, translate(sender, "commands.list.success", playersMap.size()));
|
||||
|
||||
if (playersMap.size() != 0) {
|
||||
if (!playersMap.isEmpty()) {
|
||||
StringBuilder playerSet = new StringBuilder();
|
||||
boolean finalNeedUID = needUID;
|
||||
|
||||
|
@ -18,7 +18,7 @@ public final class ResetConstCommand implements CommandHandler {
|
||||
|
||||
@Override
|
||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
||||
if (args.size() > 0 && args.get(0).equalsIgnoreCase("all")) {
|
||||
if (!args.isEmpty() && args.get(0).equalsIgnoreCase("all")) {
|
||||
targetPlayer.getAvatars().forEach(this::resetConstellation);
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.resetConst.reset_all"));
|
||||
} else {
|
||||
|
@ -69,7 +69,7 @@ public final class SendMailCommand implements CommandHandler {
|
||||
} else {
|
||||
MailBuilder mailBuilder = mailBeingConstructed.get(senderId);
|
||||
|
||||
if (args.size() >= 1) {
|
||||
if (!args.isEmpty()) {
|
||||
switch (args.get(0).toLowerCase()) {
|
||||
case "stop" -> {
|
||||
mailBeingConstructed.remove(senderId);
|
||||
|
@ -17,7 +17,7 @@ public final class SendMessageCommand implements CommandHandler {
|
||||
|
||||
@Override
|
||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
||||
if (args.size() == 0) {
|
||||
if (args.isEmpty()) {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import java.util.List;
|
||||
public final class SetConstCommand implements CommandHandler {
|
||||
@Override
|
||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
||||
if (args.size() < 1) {
|
||||
if (args.isEmpty()) {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public final class SpawnCommand implements CommandHandler {
|
||||
parseIntParameters(args, param, intCommandHandlers);
|
||||
|
||||
// At this point, first remaining argument MUST be the id and the rest the pos
|
||||
if (args.size() < 1) {
|
||||
if (args.isEmpty()) {
|
||||
sendUsageMessage(sender); // Reachable if someone does `/give lv90` or similar
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public final class TalentCommand implements CommandHandler {
|
||||
|
||||
@Override
|
||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
||||
if (args.size() < 1) {
|
||||
if (args.isEmpty()) {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class GameDepot {
|
||||
list.add(data);
|
||||
}
|
||||
// Let the server owner know if theyre missing weights
|
||||
if (relicMainPropDepot.size() == 0 || relicAffixDepot.size() == 0) {
|
||||
if (relicMainPropDepot.isEmpty() || relicAffixDepot.isEmpty()) {
|
||||
Grasscutter.getLogger()
|
||||
.error(
|
||||
"Relic properties are missing weights! Please check your ReliquaryMainPropExcelConfigData or ReliquaryAffixExcelConfigData files in your ExcelBinOutput folder.");
|
||||
|
@ -413,7 +413,7 @@ public final class ResourceLoader {
|
||||
GameData.getAbilityHashes().put(Utils.abilityHash(data.abilityName), data.abilityName);
|
||||
|
||||
var modifiers = data.modifiers;
|
||||
if (modifiers == null || modifiers.size() == 0) return;
|
||||
if (modifiers == null || modifiers.isEmpty()) return;
|
||||
|
||||
var name = data.abilityName;
|
||||
var modifierEntry = new AbilityModifierEntry(name);
|
||||
@ -647,7 +647,7 @@ public final class ResourceLoader {
|
||||
path -> {
|
||||
try {
|
||||
val data = JsonUtils.loadToClass(path, SceneNpcBornData.class);
|
||||
if (data.getBornPosList() == null || data.getBornPosList().size() == 0) {
|
||||
if (data.getBornPosList() == null || data.getBornPosList().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -25,11 +25,11 @@ public class OpenConfigEntry {
|
||||
}
|
||||
}
|
||||
|
||||
if (abilityList.size() > 0) {
|
||||
if (!abilityList.isEmpty()) {
|
||||
this.addAbilities = abilityList.toArray(new String[0]);
|
||||
}
|
||||
|
||||
if (modList.size() > 0) {
|
||||
if (!modList.isEmpty()) {
|
||||
this.skillPointModifiers = modList.toArray(new SkillPointModifier[0]);
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,6 @@ public class EnvAnimalGatherConfigData extends GameResource {
|
||||
}
|
||||
|
||||
public ItemParamData getGatherItem() {
|
||||
return gatherItemId.size() > 0 ? gatherItemId.get(0) : null;
|
||||
return !gatherItemId.isEmpty() ? gatherItemId.get(0) : null;
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class RefreshPolicyExcelConfigData extends GameResource {
|
||||
return (params.get(upper_bound_idx - 1) - params.get(0));
|
||||
}
|
||||
case REFRESH_DAYBEGIN_INTERVAL:
|
||||
if (params.size() == 0) return -1;
|
||||
if (params.isEmpty()) return -1;
|
||||
return params.get(0) * 60 * 60 * 24;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -52,7 +52,7 @@ public class AvatarSkillDepotData extends GameResource {
|
||||
this.elementType = ElementType.None;
|
||||
}
|
||||
// Set embryo abilities (if player skill depot)
|
||||
if (getSkillDepotAbilityGroup() != null && getSkillDepotAbilityGroup().length() > 0) {
|
||||
if (getSkillDepotAbilityGroup() != null && !getSkillDepotAbilityGroup().isEmpty()) {
|
||||
AvatarConfig config = GameDepot.getPlayerAbilities().get(getSkillDepotAbilityGroup());
|
||||
|
||||
if (config != null) {
|
||||
|
@ -19,7 +19,7 @@ public class TowerScheduleData extends GameResource {
|
||||
public void onLoad() {
|
||||
super.onLoad();
|
||||
this.schedules =
|
||||
this.schedules.stream().filter(item -> item.getFloorList().size() > 0).toList();
|
||||
this.schedules.stream().filter(item -> !item.getFloorList().isEmpty()).toList();
|
||||
}
|
||||
|
||||
public int getScheduleId() {
|
||||
|
@ -83,14 +83,12 @@ public final class AbilityManager extends BasePlayerManager {
|
||||
boolean skillInvincibility = modifier.state == AbilityModifier.State.Invincible;
|
||||
if (modifier.onAdded != null) {
|
||||
skillInvincibility |=
|
||||
Arrays.stream(modifier.onAdded)
|
||||
.filter(
|
||||
action ->
|
||||
action.type == AbilityModifierAction.Type.AttachAbilityStateResistance
|
||||
&& action.resistanceListID == 11002)
|
||||
.toList()
|
||||
.size()
|
||||
> 0;
|
||||
!Arrays.stream(modifier.onAdded)
|
||||
.filter(
|
||||
action ->
|
||||
action.type == AbilityModifierAction.Type.AttachAbilityStateResistance
|
||||
&& action.resistanceListID == 11002)
|
||||
.toList().isEmpty();
|
||||
}
|
||||
|
||||
if (this.burstCasterId == entityId
|
||||
|
@ -636,7 +636,7 @@ public class Avatar {
|
||||
}
|
||||
}
|
||||
// Add weapon skill from affixes
|
||||
if (weapon.getAffixes() != null && weapon.getAffixes().size() > 0) {
|
||||
if (weapon.getAffixes() != null && !weapon.getAffixes().isEmpty()) {
|
||||
// Weapons usually dont have more than one affix but just in case...
|
||||
for (int af : weapon.getAffixes()) {
|
||||
if (af == 0) {
|
||||
@ -740,7 +740,7 @@ public class Avatar {
|
||||
}
|
||||
|
||||
public void addToExtraAbilityEmbryos(String openConfig, boolean forceAdd) {
|
||||
if (openConfig == null || openConfig.length() == 0) {
|
||||
if (openConfig == null || openConfig.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -801,7 +801,7 @@ public class Avatar {
|
||||
.filter(Objects::nonNull)
|
||||
.map(AvatarTalentData::getOpenConfig)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(openConfig -> openConfig.length() > 0)
|
||||
.filter(openConfig -> !openConfig.isEmpty())
|
||||
.map(GameData.getOpenConfigEntries()::get)
|
||||
.filter(Objects::nonNull)
|
||||
.forEach(e -> this.calcConstellation(e, false));
|
||||
@ -830,7 +830,7 @@ public class Avatar {
|
||||
case 2 -> (this.skillDepot.getSkills().size() >= 2)
|
||||
? this.skillDepot.getSkills().get(1)
|
||||
: 0; // E skill
|
||||
case 1 -> (this.skillDepot.getSkills().size() >= 1)
|
||||
case 1 -> (!this.skillDepot.getSkills().isEmpty())
|
||||
? this.skillDepot.getSkills().get(0)
|
||||
: 0; // Normal Attack (Liney)
|
||||
default -> 0;
|
||||
|
@ -176,7 +176,7 @@ public class BattlePassManager extends BasePlayerDataManager {
|
||||
private void takeRewardsFromSelectChest(
|
||||
ItemData rewardItemData, int index, ItemParamData entry, List<GameItem> rewardItems) {
|
||||
// Sanity checks.
|
||||
if (rewardItemData.getItemUse().size() < 1) {
|
||||
if (rewardItemData.getItemUse().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ public class ChatSystem implements ChatSystemHandler {
|
||||
********************/
|
||||
public void sendPrivateMessageFromServer(int targetUid, String message) {
|
||||
// Sanity checks.
|
||||
if (message == null || message.length() == 0) {
|
||||
if (message == null || message.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ public class ChatSystem implements ChatSystemHandler {
|
||||
|
||||
public void sendPrivateMessage(Player player, int targetUid, String message) {
|
||||
// Sanity checks.
|
||||
if (message == null || message.length() == 0) {
|
||||
if (message == null || message.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ public class ChatSystem implements ChatSystemHandler {
|
||||
|
||||
// Fetch the new message.
|
||||
message = event.getMessage();
|
||||
if (message == null || message.length() == 0) return;
|
||||
if (message == null || message.isEmpty()) return;
|
||||
|
||||
// Create chat packet.
|
||||
var packet = new PacketPrivateChatNotify(player.getUid(), targetUid, message);
|
||||
@ -200,7 +200,7 @@ public class ChatSystem implements ChatSystemHandler {
|
||||
|
||||
public void sendTeamMessage(Player player, int channel, String message) {
|
||||
// Sanity checks
|
||||
if (message == null || message.length() == 0) {
|
||||
if (message == null || message.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -216,7 +216,7 @@ public class ChatSystem implements ChatSystemHandler {
|
||||
|
||||
// Fetch the new message.
|
||||
message = event.getMessage();
|
||||
if (message == null || message.length() == 0) return;
|
||||
if (message == null || message.isEmpty()) return;
|
||||
// Fetch the new channel.
|
||||
channel = event.getChannel();
|
||||
if (channel == -1) return;
|
||||
@ -254,7 +254,7 @@ public class ChatSystem implements ChatSystemHandler {
|
||||
joinOptions.welcomeEmotes[Utils.randomRange(0, joinOptions.welcomeEmotes.length - 1)]);
|
||||
}
|
||||
|
||||
if (joinOptions.welcomeMessage != null && joinOptions.welcomeMessage.length() > 0) {
|
||||
if (joinOptions.welcomeMessage != null && !joinOptions.welcomeMessage.isEmpty()) {
|
||||
this.sendPrivateMessageFromServer(player.getUid(), joinOptions.welcomeMessage);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class DropSystemLegacy extends BaseGameSystem {
|
||||
getDropData().clear();
|
||||
try {
|
||||
List<DropInfo> banners = DataLoader.loadList("Drop.json", DropInfo.class);
|
||||
if (banners.size() > 0) {
|
||||
if (!banners.isEmpty()) {
|
||||
for (DropInfo di : banners) {
|
||||
getDropData().put(di.getMonsterId(), di.getDropDataList());
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public final class DungeonSystem extends BaseGameSystem {
|
||||
|
||||
// Check if the player has quests with dungeon IDs.
|
||||
var questDungeons = player.getQuestManager().questsForDungeon(entry);
|
||||
if (questDungeons.size() > 0) {
|
||||
if (!questDungeons.isEmpty()) {
|
||||
player.sendPacket(new PacketDungeonEntryInfoRsp(entry.getPointData(), questDungeons));
|
||||
} else {
|
||||
player.sendPacket(new PacketDungeonEntryInfoRsp(entry.getPointData()));
|
||||
|
@ -363,7 +363,7 @@ public class EntityAvatar extends GameEntity {
|
||||
}
|
||||
}
|
||||
// Add equip abilities
|
||||
if (this.getAvatar().getExtraAbilityEmbryos().size() > 0) {
|
||||
if (!this.getAvatar().getExtraAbilityEmbryos().isEmpty()) {
|
||||
for (String skill : this.getAvatar().getExtraAbilityEmbryos()) {
|
||||
AbilityEmbryo emb =
|
||||
AbilityEmbryo.newBuilder()
|
||||
|
@ -24,7 +24,7 @@ public class ExpeditionSystem extends BaseGameSystem {
|
||||
try {
|
||||
List<ExpeditionRewardInfo> banners =
|
||||
DataLoader.loadList("ExpeditionReward.json", ExpeditionRewardInfo.class);
|
||||
if (banners.size() > 0) {
|
||||
if (!banners.isEmpty()) {
|
||||
for (ExpeditionRewardInfo di : banners) {
|
||||
getExpeditionRewardDataList().put(di.getExpId(), di.getExpeditionRewardDataList());
|
||||
}
|
||||
|
@ -277,9 +277,9 @@ public class GameItem {
|
||||
.setGuid(this.getGuid())
|
||||
.setLevel(this.getLevel())
|
||||
.setGadgetId(this.getItemData().getGadgetId())
|
||||
.setAbilityInfo(AbilitySyncStateInfo.newBuilder().setIsInited(getAffixes().size() > 0));
|
||||
.setAbilityInfo(AbilitySyncStateInfo.newBuilder().setIsInited(!getAffixes().isEmpty()));
|
||||
|
||||
if (this.getAffixes() != null && this.getAffixes().size() > 0) {
|
||||
if (this.getAffixes() != null && !this.getAffixes().isEmpty()) {
|
||||
for (int affix : this.getAffixes()) {
|
||||
weaponInfo.putAffixMap(affix, this.getRefinement());
|
||||
}
|
||||
@ -306,7 +306,7 @@ public class GameItem {
|
||||
.setExp(this.getExp())
|
||||
.setPromoteLevel(this.getPromoteLevel());
|
||||
|
||||
if (this.getAffixes() != null && this.getAffixes().size() > 0) {
|
||||
if (this.getAffixes() != null && !this.getAffixes().isEmpty()) {
|
||||
for (int affix : this.getAffixes()) {
|
||||
weapon.putAffixMap(affix, this.getRefinement());
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
|
||||
changedItems.add(result);
|
||||
}
|
||||
}
|
||||
if (changedItems.size() == 0) {
|
||||
if (changedItems.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (reason != null) {
|
||||
|
@ -36,13 +36,13 @@ public class InvokeHandler<T> {
|
||||
}
|
||||
|
||||
try {
|
||||
if (entryListForwardAll.size() > 0) {
|
||||
if (!entryListForwardAll.isEmpty()) {
|
||||
BasePacket packet =
|
||||
packetClass.getDeclaredConstructor(List.class).newInstance(this.entryListForwardAll);
|
||||
player.getScene().broadcastPacket(packet);
|
||||
this.entryListForwardAll.clear();
|
||||
}
|
||||
if (entryListForwardAllExceptCur.size() > 0) {
|
||||
if (!entryListForwardAllExceptCur.isEmpty()) {
|
||||
BasePacket packet =
|
||||
packetClass
|
||||
.getDeclaredConstructor(List.class)
|
||||
@ -50,7 +50,7 @@ public class InvokeHandler<T> {
|
||||
player.getScene().broadcastPacketToOthers(player, packet);
|
||||
this.entryListForwardAllExceptCur.clear();
|
||||
}
|
||||
if (entryListForwardHost.size() > 0) {
|
||||
if (!entryListForwardHost.isEmpty()) {
|
||||
BasePacket packet =
|
||||
packetClass.getDeclaredConstructor(List.class).newInstance(this.entryListForwardHost);
|
||||
player.getWorld().getHost().sendPacket(packet);
|
||||
|
@ -178,7 +178,7 @@ public final class PlayerBuffManager extends BasePlayerManager {
|
||||
return true;
|
||||
});
|
||||
|
||||
if (this.pendingBuffs.size() > 0) {
|
||||
if (!this.pendingBuffs.isEmpty()) {
|
||||
// Send packet
|
||||
getPlayer()
|
||||
.sendPacket(
|
||||
|
@ -98,7 +98,7 @@ public final class TeamManager extends BasePlayerDataManager {
|
||||
}
|
||||
|
||||
// same as avatar ability hash (add frm levelEntityConfig data)
|
||||
if (this.getTeamAbilityEmbryos().size() > 0) {
|
||||
if (!this.getTeamAbilityEmbryos().isEmpty()) {
|
||||
for (String skill : this.getTeamAbilityEmbryos()) {
|
||||
AbilityEmbryoOuterClass.AbilityEmbryo emb =
|
||||
AbilityEmbryoOuterClass.AbilityEmbryo.newBuilder()
|
||||
@ -495,7 +495,7 @@ public final class TeamManager extends BasePlayerDataManager {
|
||||
|
||||
public void setupMpTeam(List<Long> list) {
|
||||
// Sanity checks
|
||||
if (list.size() == 0
|
||||
if (list.isEmpty()
|
||||
|| list.size() > this.getMaxTeamSize()
|
||||
|| !this.getPlayer().isInMultiplayer()) {
|
||||
return;
|
||||
@ -696,7 +696,7 @@ public final class TeamManager extends BasePlayerDataManager {
|
||||
.map(
|
||||
list -> {
|
||||
// Sanity checks
|
||||
if (list.size() == 0 || list.size() > this.getMaxTeamSize()) {
|
||||
if (list.isEmpty() || list.size() > this.getMaxTeamSize()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -744,7 +744,7 @@ public final class TeamManager extends BasePlayerDataManager {
|
||||
|
||||
// Get team
|
||||
TeamInfo teamInfo = this.getTeams().get(teamId);
|
||||
if (teamInfo == null || teamInfo.getAvatars().size() == 0) {
|
||||
if (teamInfo == null || teamInfo.getAvatars().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1054,7 +1054,7 @@ public final class TeamManager extends BasePlayerDataManager {
|
||||
var avatarIds = scene.getSceneData().getSpecifiedAvatarList();
|
||||
var specifiedAvatarList = this.getActiveTeam();
|
||||
|
||||
if (avatarIds != null && avatarIds.size() > 0) {
|
||||
if (avatarIds != null && !avatarIds.isEmpty()) {
|
||||
// certain scene could limit specific avatars' entry
|
||||
specifiedAvatarList.clear();
|
||||
for (int id : avatarIds) {
|
||||
|
@ -67,7 +67,7 @@ public class GameQuest {
|
||||
questData.getFinishCond().stream()
|
||||
.filter(p -> p.getType() == QuestContent.QUEST_CONTENT_TRIGGER_FIRE)
|
||||
.toList();
|
||||
if (triggerCond.size() > 0) {
|
||||
if (!triggerCond.isEmpty()) {
|
||||
for (val cond : triggerCond) {
|
||||
var newTrigger = GameData.getTriggerExcelConfigDataMap().get(cond.getParam()[0]);
|
||||
if (newTrigger != null) {
|
||||
@ -158,14 +158,14 @@ public class GameQuest {
|
||||
public boolean clearProgress(boolean notifyDelete) {
|
||||
// TODO improve
|
||||
var oldState = state;
|
||||
if (questData.getAcceptCond() != null && questData.getAcceptCond().size() != 0) {
|
||||
if (questData.getAcceptCond() != null && !questData.getAcceptCond().isEmpty()) {
|
||||
this.getMainQuest()
|
||||
.getQuestManager()
|
||||
.getAcceptProgressLists()
|
||||
.put(this.getSubQuestId(), new int[questData.getAcceptCond().size()]);
|
||||
}
|
||||
|
||||
if (questData.getFinishCond() != null && questData.getFinishCond().size() != 0) {
|
||||
if (questData.getFinishCond() != null && !questData.getFinishCond().isEmpty()) {
|
||||
for (var condition : questData.getFinishCond()) {
|
||||
if (condition.getType() == QuestContent.QUEST_CONTENT_LUA_NOTIFY) {
|
||||
this.getOwner().getPlayerProgress().resetCurrentProgress(condition.getParamStr());
|
||||
@ -174,7 +174,7 @@ public class GameQuest {
|
||||
this.finishProgressList = new int[questData.getFinishCond().size()];
|
||||
}
|
||||
|
||||
if (questData.getFailCond() != null && questData.getFailCond().size() != 0) {
|
||||
if (questData.getFailCond() != null && !questData.getFailCond().isEmpty()) {
|
||||
for (var condition : questData.getFailCond()) {
|
||||
if (condition.getType() == QuestContent.QUEST_CONTENT_LUA_NOTIFY) {
|
||||
this.getOwner().getPlayerProgress().resetCurrentProgress(condition.getParamStr());
|
||||
|
@ -48,7 +48,7 @@ public class ShopSystem extends BaseGameSystem {
|
||||
getShopData().clear();
|
||||
try {
|
||||
List<ShopTable> banners = DataLoader.loadList("Shop.json", ShopTable.class);
|
||||
if (banners.size() > 0) {
|
||||
if (!banners.isEmpty()) {
|
||||
for (ShopTable shopTable : banners) {
|
||||
shopTable.getItems().forEach(ShopInfo::removeVirtualCosts);
|
||||
getShopData().put(shopTable.getShopId(), shopTable.getItems());
|
||||
|
@ -44,7 +44,7 @@ public class AnnouncementSystem extends BaseGameSystem {
|
||||
}
|
||||
|
||||
public void broadcast(List<AnnounceConfigItem> tpl) {
|
||||
if (tpl == null || tpl.size() == 0) {
|
||||
if (tpl == null || tpl.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -482,7 +482,7 @@ public class InventorySystem extends BaseGameSystem {
|
||||
|
||||
if (weapon.getRefinement() >= 4
|
||||
|| weapon.getAffixes() == null
|
||||
|| weapon.getAffixes().size() == 0) {
|
||||
|| weapon.getAffixes().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -818,7 +818,7 @@ public class InventorySystem extends BaseGameSystem {
|
||||
}
|
||||
|
||||
// Give back items
|
||||
if (returnMaterialMap.size() > 0) {
|
||||
if (!returnMaterialMap.isEmpty()) {
|
||||
returnMaterialMap.forEach((id, count) -> inventory.addItem(new GameItem(id, count)));
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class TowerManager extends BasePlayerManager {
|
||||
|
||||
public Map<Integer, TowerLevelRecord> getRecordMap() {
|
||||
Map<Integer, TowerLevelRecord> recordMap = getTowerData().recordMap;
|
||||
if (recordMap == null || recordMap.size() == 0) {
|
||||
if (recordMap == null || recordMap.isEmpty()) {
|
||||
recordMap = new HashMap<>();
|
||||
recordMap.put(1001, new TowerLevelRecord(1001));
|
||||
getTowerData().recordMap = recordMap;
|
||||
|
@ -882,12 +882,12 @@ public class Scene {
|
||||
}
|
||||
}
|
||||
|
||||
if (toAdd.size() > 0) {
|
||||
if (!toAdd.isEmpty()) {
|
||||
toAdd.forEach(this::addEntityDirectly);
|
||||
this.broadcastPacket(new PacketSceneEntityAppearNotify(toAdd, VisionType.VISION_TYPE_BORN));
|
||||
}
|
||||
|
||||
if (toRemove.size() > 0) {
|
||||
if (!toRemove.isEmpty()) {
|
||||
toRemove.forEach(this::removeEntityDirectly);
|
||||
this.broadcastPacket(
|
||||
new PacketSceneEntityDisappearNotify(toRemove, VisionType.VISION_TYPE_REMOVE));
|
||||
@ -1110,7 +1110,7 @@ public class Scene {
|
||||
.filter(e -> e != null && (e.getBlockId() == block.id && e.getGroupId() == group_id))
|
||||
.toList();
|
||||
|
||||
if (toRemove.size() > 0) {
|
||||
if (!toRemove.isEmpty()) {
|
||||
toRemove.forEach(this::removeEntityDirectly);
|
||||
this.broadcastPacket(
|
||||
new PacketSceneEntityDisappearNotify(toRemove, VisionType.VISION_TYPE_REMOVE));
|
||||
@ -1253,7 +1253,7 @@ public class Scene {
|
||||
sceneNpcBornEntries.add(i);
|
||||
});
|
||||
|
||||
if (sceneNpcBornEntries.size() > 0) {
|
||||
if (!sceneNpcBornEntries.isEmpty()) {
|
||||
this.broadcastPacket(new PacketGroupSuiteNotify(sceneNpcBornEntries));
|
||||
Grasscutter.getLogger().trace("Loaded Npc Group Suite {}", sceneNpcBornEntries);
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ public class World implements Iterable<Player> {
|
||||
scene.removePlayer(player);
|
||||
|
||||
// Info packet for other players
|
||||
if (this.getPlayers().size() > 0) {
|
||||
if (!this.getPlayers().isEmpty()) {
|
||||
this.updatePlayerInfos(player);
|
||||
}
|
||||
|
||||
|
@ -678,7 +678,7 @@ public class SceneScriptManager {
|
||||
}
|
||||
|
||||
public void checkRegions() {
|
||||
if (this.regions.size() == 0) {
|
||||
if (this.regions.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -239,7 +239,7 @@ public class LuaSerializer implements Serializer {
|
||||
}
|
||||
|
||||
public String getSetterName(String fieldName) {
|
||||
if (fieldName == null || fieldName.length() == 0) {
|
||||
if (fieldName == null || fieldName.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (fieldName.length() == 1) {
|
||||
|
@ -53,12 +53,12 @@ public final class RegionHandler implements Router {
|
||||
var usedNames = new ArrayList<String>(); // List to check for potential naming conflicts.
|
||||
|
||||
var configuredRegions = new ArrayList<>(DISPATCH_INFO.regions);
|
||||
if (Grasscutter.getRunMode() != ServerRunMode.HYBRID && configuredRegions.size() == 0) {
|
||||
if (Grasscutter.getRunMode() != ServerRunMode.HYBRID && configuredRegions.isEmpty()) {
|
||||
Grasscutter.getLogger()
|
||||
.error(
|
||||
"[Dispatch] There are no game servers available. Exiting due to unplayable state.");
|
||||
System.exit(1);
|
||||
} else if (configuredRegions.size() == 0)
|
||||
} else if (configuredRegions.isEmpty())
|
||||
configuredRegions.add(
|
||||
new Region(
|
||||
"os_usa",
|
||||
|
@ -26,7 +26,7 @@ public final class HandbookHandler implements Router {
|
||||
*/
|
||||
public HandbookHandler() {
|
||||
this.handbook = new String(FileUtils.readResource("/html/handbook.html"));
|
||||
this.serve = HANDBOOK.enable && this.handbook.length() > 0;
|
||||
this.serve = HANDBOOK.enable && !this.handbook.isEmpty();
|
||||
|
||||
var server = HANDBOOK.server;
|
||||
if (this.serve && server.enforced) {
|
||||
|
@ -26,7 +26,7 @@ public class HandlerClientAbilitiesInitFinishCombineNotify extends PacketHandler
|
||||
player.getClientAbilityInitFinishHandler().addEntry(ability.getForwardType(), ability);
|
||||
}
|
||||
|
||||
if (entry.getInvokesList().size() > 0) {
|
||||
if (!entry.getInvokesList().isEmpty()) {
|
||||
session.getPlayer().getClientAbilityInitFinishHandler().update(session.getPlayer());
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class HandlerClientAbilityInitFinishNotify extends PacketHandler {
|
||||
player.getClientAbilityInitFinishHandler().addEntry(entry.getForwardType(), entry);
|
||||
}
|
||||
|
||||
if (notif.getInvokesList().size() > 0) {
|
||||
if (!notif.getInvokesList().isEmpty()) {
|
||||
session.getPlayer().getClientAbilityInitFinishHandler().update(session.getPlayer());
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class HandlerQueryPathReq extends PacketHandler {
|
||||
var req = QueryPathReq.parseFrom(payload);
|
||||
|
||||
/** It is not the actual work */
|
||||
if (req.getDestinationPosList().size() > 0) {
|
||||
if (!req.getDestinationPosList().isEmpty()) {
|
||||
session.send(new PacketQueryPathRsp(req));
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class HandlerSetPlayerNameReq extends PacketHandler {
|
||||
// Auto template
|
||||
SetPlayerNameReq req = SetPlayerNameReq.parseFrom(payload);
|
||||
|
||||
if (req.getNickName() != null && req.getNickName().length() > 0) {
|
||||
if (req.getNickName() != null && !req.getNickName().isEmpty()) {
|
||||
session.getPlayer().setNickname(req.getNickName());
|
||||
session.send(new PacketSetPlayerNameRsp(session.getPlayer()));
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class HandlerSetPlayerSignatureReq extends PacketHandler {
|
||||
// Auto template
|
||||
SetPlayerSignatureReq req = SetPlayerSignatureReq.parseFrom(payload);
|
||||
|
||||
if (req.getSignature() != null && req.getSignature().length() > 0) {
|
||||
if (req.getSignature() != null && !req.getSignature().isEmpty()) {
|
||||
session.getPlayer().setSignature(req.getSignature());
|
||||
session.send(new PacketSetPlayerSignatureRsp(session.getPlayer()));
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class PacketClientAbilityInitFinishNotify extends BasePacket {
|
||||
|
||||
int entityId = 0;
|
||||
|
||||
if (entries.size() > 0) {
|
||||
if (!entries.isEmpty()) {
|
||||
AbilityInvokeEntry entry = entries.get(0);
|
||||
entityId = entry.getEntityId();
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public final class PacketGetAllMailResultNotify extends BasePacket {
|
||||
.setPacketNum(1);
|
||||
|
||||
var inbox = player.getAllMail();
|
||||
if (!gifts && inbox.size() > 0) {
|
||||
if (!gifts && !inbox.isEmpty()) {
|
||||
packet.addAllMailList(
|
||||
inbox.stream()
|
||||
.filter(mail -> mail.stateValue == 1)
|
||||
|
@ -15,7 +15,7 @@ public class PacketGetOnlinePlayerListRsp extends BasePacket {
|
||||
|
||||
GetOnlinePlayerListRsp.Builder proto = GetOnlinePlayerListRsp.newBuilder();
|
||||
|
||||
if (players.size() != 0) {
|
||||
if (!players.isEmpty()) {
|
||||
for (Player player : players) {
|
||||
if (player.getUid() == session.getUid()) continue;
|
||||
|
||||
|
@ -12,7 +12,7 @@ public class PacketGetScenePointRsp extends BasePacket {
|
||||
|
||||
GetScenePointRsp.Builder p = GetScenePointRsp.newBuilder().setSceneId(sceneId);
|
||||
|
||||
if (GameData.getScenePointIdList().size() == 0) {
|
||||
if (GameData.getScenePointIdList().isEmpty()) {
|
||||
for (int i = 1; i < 1000; i++) {
|
||||
p.addUnlockedPointList(i);
|
||||
p.addUnhidePointList(i);
|
||||
|
@ -23,7 +23,7 @@ public final class ServerTaskScheduler {
|
||||
*/
|
||||
public void runTasks() {
|
||||
// Skip if there are no tasks.
|
||||
if (this.tasks.size() == 0) return;
|
||||
if (this.tasks.isEmpty()) return;
|
||||
|
||||
// Run all tasks.
|
||||
for (ServerTask task : this.tasks.values()) {
|
||||
|
@ -169,7 +169,7 @@ public interface Dumpers {
|
||||
Language.getTextMapKey(item.getNameTextMapHash()).get(locale),
|
||||
Quality.from(item.getRankLevel()),
|
||||
item.getItemType(),
|
||||
item.getIcon().length() > 0 ? item.getIcon().substring(3) : "")));
|
||||
!item.getIcon().isEmpty() ? item.getIcon().substring(3) : "")));
|
||||
|
||||
// Create a new dump with filtered duplicates.
|
||||
var names = new ArrayList<String>();
|
||||
|
Loading…
Reference in New Issue
Block a user