Skip to content

Commit

Permalink
NPE Check
Browse files Browse the repository at this point in the history
- Added a check to make sure that an item is enabled before trying to apply any innate enchantments
  • Loading branch information
chronosacaria committed Apr 21, 2024
1 parent 83d0482 commit 1699090
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 17 deletions.
4 changes: 3 additions & 1 deletion src/main/java/chronosacaria/mcdw/bases/McdwAxe.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public ItemStack getDefaultStack() {

@Override
public Map<Enchantment, Integer> getInnateEnchantments() {
return this.axeEnum.getInnateEnchantments();
if(this.axeEnum.getIsEnabled())
return this.axeEnum.getInnateEnchantments();
return Map.of();
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/chronosacaria/mcdw/bases/McdwBow.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ public ItemStack getDefaultStack() {

@Override
public Map<Enchantment, Integer> getInnateEnchantments() {
return this.bowsEnum.getInnateEnchantments();
if (this.bowsEnum.getIsEnabled())
return this.bowsEnum.getInnateEnchantments();
return Map.of();
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/chronosacaria/mcdw/bases/McdwCrossbow.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ public ItemStack getDefaultStack() {

@Override
public Map<Enchantment, Integer> getInnateEnchantments() {
return this.crossbowsEnum.getInnateEnchantments();
if (this.crossbowsEnum.getIsEnabled())
return this.crossbowsEnum.getInnateEnchantments();
return Map.of();
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/chronosacaria/mcdw/bases/McdwDagger.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ public ItemStack getDefaultStack() {

@Override
public @Nullable Map<Enchantment, Integer> getInnateEnchantments() {
return this.daggersEnum.getInnateEnchantments();
if (this.daggersEnum.getIsEnabled())
return this.daggersEnum.getInnateEnchantments();
return Map.of();
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/chronosacaria/mcdw/bases/McdwDoubleAxe.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public ItemStack getDefaultStack() {

@Override
public Map<Enchantment, Integer> getInnateEnchantments() {
return this.doubleAxesEnum.getInnateEnchantments();
if (this.doubleAxesEnum.getIsEnabled())
return this.doubleAxesEnum.getInnateEnchantments();
return Map.of();
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/chronosacaria/mcdw/bases/McdwGauntlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public ItemStack getDefaultStack() {

@Override
public Map<Enchantment, Integer> getInnateEnchantments() {
return this.gauntletsEnum.getInnateEnchantments();
if (this.gauntletsEnum.getIsEnabled())
return this.gauntletsEnum.getInnateEnchantments();
return Map.of();
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/chronosacaria/mcdw/bases/McdwGlaive.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ public ItemStack getDefaultStack() {

@Override
public Map<Enchantment, Integer> getInnateEnchantments() {
return this.glaivesEnum.getInnateEnchantments();
if (this.glaivesEnum.getIsEnabled())
return this.glaivesEnum.getInnateEnchantments();
return Map.of();
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/chronosacaria/mcdw/bases/McdwHammer.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public ItemStack getDefaultStack() {

@Override
public Map<Enchantment, Integer> getInnateEnchantments() {
return this.hammersEnum.getInnateEnchantments();
if (this.hammersEnum.getIsEnabled())
return this.hammersEnum.getInnateEnchantments();
return Map.of();
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/chronosacaria/mcdw/bases/McdwLongbow.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ public ItemStack getDefaultStack() {

@Override
public Map<Enchantment, Integer> getInnateEnchantments() {
return this.longbowsEnum.getInnateEnchantments();
if (this.longbowsEnum.getIsEnabled())
return this.longbowsEnum.getInnateEnchantments();
return Map.of();
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/chronosacaria/mcdw/bases/McdwScythe.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public ItemStack getDefaultStack() {

@Override
public Map<Enchantment, Integer> getInnateEnchantments() {
return this.scythesEnum.getInnateEnchantments();
if (this.scythesEnum.getIsEnabled())
return this.scythesEnum.getInnateEnchantments();
return Map.of();
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/chronosacaria/mcdw/bases/McdwShortbow.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ public ItemStack getDefaultStack() {

@Override
public Map<Enchantment, Integer> getInnateEnchantments() {
return this.shortbowsEnum.getInnateEnchantments();
if (this.shortbowsEnum.getIsEnabled())
return this.shortbowsEnum.getInnateEnchantments();
return Map.of();
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/chronosacaria/mcdw/bases/McdwSickle.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public ItemStack getDefaultStack() {

@Override
public Map<Enchantment, Integer> getInnateEnchantments() {
return this.sicklesEnum.getInnateEnchantments();
if (this.sicklesEnum.getIsEnabled())
return this.sicklesEnum.getInnateEnchantments();
return Map.of();
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/chronosacaria/mcdw/bases/McdwSoulDagger.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public ItemStack getDefaultStack() {

@Override
public Map<Enchantment, Integer> getInnateEnchantments() {
return this.soulDaggersEnum.getInnateEnchantments();
if (this.soulDaggersEnum.getIsEnabled())
return this.soulDaggersEnum.getInnateEnchantments();
return Map.of();
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/chronosacaria/mcdw/bases/McdwSpear.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ public ItemStack getDefaultStack() {

@Override
public Map<Enchantment, Integer> getInnateEnchantments() {
return this.spearsEnum.getInnateEnchantments();
if (this.spearsEnum.getIsEnabled())
return this.spearsEnum.getInnateEnchantments();
return Map.of();
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/chronosacaria/mcdw/bases/McdwStaff.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ public ItemStack getDefaultStack() {

@Override
public Map<Enchantment, Integer> getInnateEnchantments() {
return this.stavesEnum.getInnateEnchantments();
if (this.stavesEnum.getIsEnabled())
return this.stavesEnum.getInnateEnchantments();
return Map.of();
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/chronosacaria/mcdw/bases/McdwSword.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ public ItemStack getDefaultStack() {

@Override
public Map<Enchantment, Integer> getInnateEnchantments() {
return this.swordsEnum.getInnateEnchantments();
if (this.swordsEnum.getIsEnabled())
return this.swordsEnum.getInnateEnchantments();
return Map.of();
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/chronosacaria/mcdw/bases/McdwWhip.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ public ItemStack getDefaultStack() {

@Override
public Map<Enchantment, Integer> getInnateEnchantments() {
return this.whipsEnum.getInnateEnchantments();
if (this.whipsEnum.getIsEnabled())
return this.whipsEnum.getInnateEnchantments();
return Map.of();
}

@Override
Expand Down

0 comments on commit 1699090

Please sign in to comment.