mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
refactor: use pattern matching for null checks (is null / is not null)
Convert remaining == null to is null and != null to is not null across 17 files in CommandHandler/ArgumentType, StructuredComponents, and DeclareCommands for idiomatic C# style. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
c7bc25aa17
commit
94bf42710a
17 changed files with 33 additions and 33 deletions
|
|
@ -17,7 +17,7 @@ public class BundleContentsComponent(DataTypes dataTypes, ItemPalette itemPalett
|
|||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var item = dataTypes.ReadNextItemSlot(data, itemPalette);
|
||||
if (item != null)
|
||||
if (item is not null)
|
||||
Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public class ChargedProjectilesComponent(DataTypes dataTypes, ItemPalette itemPa
|
|||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var item = dataTypes.ReadNextItemSlot(data, itemPalette);
|
||||
if (item != null)
|
||||
if (item is not null)
|
||||
Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ public class ConsumableComponent(DataTypes dataTypes, ItemPalette itemPalette, S
|
|||
var data = new List<byte>();
|
||||
data.AddRange(DataTypes.GetFloat(ConsumeSeconds));
|
||||
data.AddRange(DataTypes.GetVarInt(Animation));
|
||||
if (Sound != null) data.AddRange(Sound.Serialize());
|
||||
if (Sound is not null) data.AddRange(Sound.Serialize());
|
||||
data.AddRange(DataTypes.GetBool(HasConsumeParticles));
|
||||
data.AddRange(DataTypes.GetVarInt(Effects.Count));
|
||||
foreach (var effect in Effects)
|
||||
|
|
|
|||
|
|
@ -61,25 +61,25 @@ public class EquippableComponent(DataTypes dataTypes, ItemPalette itemPalette, S
|
|||
{
|
||||
var data = new List<byte>();
|
||||
data.AddRange(DataTypes.GetVarInt(Slot));
|
||||
if (EquipSound != null) data.AddRange(EquipSound.Serialize());
|
||||
if (EquipSound is not null) data.AddRange(EquipSound.Serialize());
|
||||
|
||||
data.AddRange(DataTypes.GetBool(HasModel));
|
||||
if (HasModel && Model != null)
|
||||
if (HasModel && Model is not null)
|
||||
data.AddRange(DataTypes.GetString(Model));
|
||||
|
||||
data.AddRange(DataTypes.GetBool(HasCameraOverlay));
|
||||
if (HasCameraOverlay && CameraOverlay != null)
|
||||
if (HasCameraOverlay && CameraOverlay is not null)
|
||||
data.AddRange(DataTypes.GetString(CameraOverlay));
|
||||
|
||||
data.AddRange(DataTypes.GetBool(HasAllowedEntities));
|
||||
if (HasAllowedEntities)
|
||||
{
|
||||
data.AddRange(DataTypes.GetVarInt(AllowedEntitiesType));
|
||||
if (AllowedEntitiesType == 0 && AllowedEntitiesTag != null)
|
||||
if (AllowedEntitiesType == 0 && AllowedEntitiesTag is not null)
|
||||
{
|
||||
data.AddRange(DataTypes.GetString(AllowedEntitiesTag));
|
||||
}
|
||||
else if (AllowedEntitiesIds != null)
|
||||
else if (AllowedEntitiesIds is not null)
|
||||
{
|
||||
foreach (var id in AllowedEntitiesIds)
|
||||
data.AddRange(DataTypes.GetVarInt(id));
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ public class RepairableComponent(DataTypes dataTypes, ItemPalette itemPalette, S
|
|||
{
|
||||
var data = new List<byte>();
|
||||
data.AddRange(DataTypes.GetVarInt(Type));
|
||||
if (Type == 0 && TagName != null)
|
||||
if (Type == 0 && TagName is not null)
|
||||
{
|
||||
data.AddRange(DataTypes.GetString(TagName));
|
||||
}
|
||||
else if (ItemIds != null)
|
||||
else if (ItemIds is not null)
|
||||
{
|
||||
foreach (var id in ItemIds)
|
||||
data.AddRange(DataTypes.GetVarInt(id));
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class UseCooldownComponent(DataTypes dataTypes, ItemPalette itemPalette,
|
|||
var data = new List<byte>();
|
||||
data.AddRange(DataTypes.GetFloat(Seconds));
|
||||
data.AddRange(DataTypes.GetBool(HasCooldownGroup));
|
||||
if (HasCooldownGroup && CooldownGroup != null)
|
||||
if (HasCooldownGroup && CooldownGroup is not null)
|
||||
data.AddRange(DataTypes.GetString(CooldownGroup));
|
||||
return new Queue<byte>(data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class BlockPredicateSubcomponent(DataTypes dataTypes, SubComponentRegistr
|
|||
data.AddRange(DataTypes.GetBool(HasBlocks));
|
||||
if (HasBlocks)
|
||||
{
|
||||
if(BlockSet == null)
|
||||
if(BlockSet is null)
|
||||
throw new ArgumentNullException($"Can not serialize a BlockPredicate when the BlockSet is empty but HasBlocks is true!");
|
||||
|
||||
data.AddRange(BlockSet.Serialize());
|
||||
|
|
@ -54,7 +54,7 @@ public class BlockPredicateSubcomponent(DataTypes dataTypes, SubComponentRegistr
|
|||
data.AddRange(DataTypes.GetBool(HasProperities));
|
||||
if (HasProperities)
|
||||
{
|
||||
if(Properties == null || Properties.Count == 0)
|
||||
if(Properties is null || Properties.Count == 0)
|
||||
throw new ArgumentNullException($"Can not serialize a BlockPredicate when the Properties is empty but HasProperties is true!");
|
||||
|
||||
data.AddRange(DataTypes.GetVarInt(Properties.Count));
|
||||
|
|
@ -66,7 +66,7 @@ public class BlockPredicateSubcomponent(DataTypes dataTypes, SubComponentRegistr
|
|||
data.AddRange(DataTypes.GetBool(HasNbt));
|
||||
if (HasNbt)
|
||||
{
|
||||
if(Nbt == null)
|
||||
if(Nbt is null)
|
||||
throw new ArgumentNullException($"Can not serialize a BlockPredicate when the Nbt is empty but HasNbt is true!");
|
||||
|
||||
data.AddRange(DataTypes.GetNbt(Nbt));
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class BlockSetSubcomponent(DataTypes dataTypes, SubComponentRegistry subC
|
|||
|
||||
if (Type == 0) return new Queue<byte>(data);
|
||||
|
||||
if(BlockIds == null || BlockIds.Count == 0)
|
||||
if(BlockIds is null || BlockIds.Count == 0)
|
||||
throw new ArgumentNullException($"Can not serialize an empty list of Block IDs in a Block Set when the type is not 0!");
|
||||
|
||||
for(var i = 0; i < Type - 1; i++)
|
||||
|
|
|
|||
|
|
@ -47,12 +47,12 @@ public class PropertySubComponent(DataTypes dataTypes, SubComponentRegistry subC
|
|||
}
|
||||
else
|
||||
{
|
||||
data.AddRange(DataTypes.GetBool(MinValue != null));
|
||||
if (MinValue != null)
|
||||
data.AddRange(DataTypes.GetBool(MinValue is not null));
|
||||
if (MinValue is not null)
|
||||
data.AddRange(DataTypes.GetString(MinValue));
|
||||
|
||||
data.AddRange(DataTypes.GetBool(MaxValue != null));
|
||||
if (MaxValue != null)
|
||||
data.AddRange(DataTypes.GetBool(MaxValue is not null));
|
||||
if (MaxValue is not null)
|
||||
data.AddRange(DataTypes.GetString(MaxValue));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue