-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: New conditions for titles, added support for Lucky's Armory
- Loading branch information
Showing
22 changed files
with
570 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.0.9 | ||
1.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/com/seniors/justlevelingfork/config/conditions/AdvancementCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.seniors.justlevelingfork.config.conditions; | ||
|
||
import com.seniors.justlevelingfork.JustLevelingFork; | ||
import com.seniors.justlevelingfork.config.models.TitleModel; | ||
import net.minecraft.advancements.Advancement; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.server.level.ServerPlayer; | ||
|
||
import java.util.Objects; | ||
|
||
public class AdvancementCondition extends ConditionImpl<Boolean> { | ||
|
||
public AdvancementCondition(){ | ||
super("Advancement"); | ||
} | ||
|
||
@Override | ||
public void ProcessVariable(String value, ServerPlayer serverPlayer) { | ||
Advancement advancement = Objects.requireNonNull(serverPlayer.getServer()).getAdvancements().getAdvancement(new ResourceLocation(value.replace("-", "/"))); | ||
if (advancement == null){ | ||
JustLevelingFork.getLOGGER().error(">> Error! Advancement name {} not found!", value); | ||
setProcessedValue(false); | ||
return; | ||
} | ||
|
||
setProcessedValue(serverPlayer.getAdvancements().getOrStartProgress(advancement).isDone()); | ||
} | ||
|
||
@Override | ||
public boolean MeetCondition(String value, TitleModel.EComparator comparator) { | ||
return getProcessedValue(); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/seniors/justlevelingfork/config/conditions/AptitudeCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.seniors.justlevelingfork.config.conditions; | ||
|
||
import com.seniors.justlevelingfork.common.capability.AptitudeCapability; | ||
import com.seniors.justlevelingfork.config.models.EAptitude; | ||
import com.seniors.justlevelingfork.config.models.TitleModel; | ||
import com.seniors.justlevelingfork.registry.RegistryAptitudes; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
public class AptitudeCondition extends ConditionImpl<Integer> { | ||
|
||
public AptitudeCondition() { | ||
super("Aptitude"); | ||
} | ||
|
||
@Override | ||
public void ProcessVariable(String value, ServerPlayer serverPlayer) { | ||
EAptitude aptitude = EAptitude.valueOf(StringUtils.capitalize(value)); | ||
int aptitudeLevel = AptitudeCapability.get(serverPlayer).getAptitudeLevel(RegistryAptitudes.getAptitude(aptitude.toString())); | ||
|
||
setProcessedValue(aptitudeLevel); | ||
} | ||
|
||
@Override | ||
public boolean MeetCondition(String value, TitleModel.EComparator comparator) { | ||
int parsedValue = Integer.parseInt(value); | ||
|
||
return switch (comparator) { | ||
case EQUALS -> getProcessedValue().equals(parsedValue); | ||
case GREATER -> getProcessedValue() > parsedValue; | ||
case LESS -> getProcessedValue() < parsedValue; | ||
case GREATER_OR_EQUAL -> getProcessedValue() >= parsedValue; | ||
case LESS_OR_EQUAL -> getProcessedValue() <= parsedValue; | ||
default -> false; | ||
}; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/com/seniors/justlevelingfork/config/conditions/BlockMinedCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.seniors.justlevelingfork.config.conditions; | ||
|
||
import com.seniors.justlevelingfork.JustLevelingFork; | ||
import com.seniors.justlevelingfork.config.models.TitleModel; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.stats.Stats; | ||
|
||
import java.util.Optional; | ||
|
||
public class BlockMinedCondition extends ConditionImpl<Integer> { | ||
|
||
public BlockMinedCondition(){ | ||
super("BlockMined"); | ||
} | ||
|
||
@Override | ||
public void ProcessVariable(String value, ServerPlayer serverPlayer) { | ||
var optionalStat = Optional.ofNullable(ResourceLocation.tryParse(value.toLowerCase())).flatMap(Stats.BLOCK_MINED.getRegistry()::getOptional).map(Stats.BLOCK_MINED::get); | ||
if (optionalStat.isEmpty()) { | ||
JustLevelingFork.getLOGGER().error(">> Error! Block name {} not found!", value); | ||
setProcessedValue(0); | ||
return; | ||
} | ||
|
||
setProcessedValue(serverPlayer.getStats().getValue(Stats.BLOCK_MINED, optionalStat.get().getValue())); | ||
} | ||
|
||
@Override | ||
public boolean MeetCondition(String value, TitleModel.EComparator comparator) { | ||
int parsedValue = Integer.parseInt(value); | ||
|
||
return switch (comparator) { | ||
case EQUALS -> getProcessedValue().equals(parsedValue); | ||
case GREATER -> getProcessedValue() > parsedValue; | ||
case LESS -> getProcessedValue() < parsedValue; | ||
case GREATER_OR_EQUAL -> getProcessedValue() >= parsedValue; | ||
case LESS_OR_EQUAL -> getProcessedValue() <= parsedValue; | ||
default -> false; | ||
}; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/com/seniors/justlevelingfork/config/conditions/ConditionImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.seniors.justlevelingfork.config.conditions; | ||
|
||
import com.seniors.justlevelingfork.config.models.TitleModel; | ||
import net.minecraft.server.level.ServerPlayer; | ||
|
||
public abstract class ConditionImpl<T> { | ||
|
||
private String _conditionName; | ||
public String getConditionName(){ | ||
return _conditionName; | ||
} | ||
|
||
private T _processedValue; | ||
public T getProcessedValue(){ | ||
return _processedValue; | ||
} | ||
public void setProcessedValue(T value) | ||
{ | ||
_processedValue = value; | ||
} | ||
|
||
public ConditionImpl(String conditionName){ | ||
_conditionName = conditionName; | ||
} | ||
|
||
public abstract void ProcessVariable(String value, ServerPlayer serverPlayer); | ||
|
||
public abstract boolean MeetCondition(String value, TitleModel.EComparator comparator); | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/seniors/justlevelingfork/config/conditions/DimensionCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.seniors.justlevelingfork.config.conditions; | ||
|
||
import com.seniors.justlevelingfork.config.models.TitleModel; | ||
import net.minecraft.server.level.ServerPlayer; | ||
|
||
public class DimensionCondition extends ConditionImpl<String> { | ||
|
||
public DimensionCondition(){ | ||
super("Special"); | ||
} | ||
|
||
@Override | ||
public void ProcessVariable(String value, ServerPlayer serverPlayer) { | ||
setProcessedValue(serverPlayer.level().dimension().location().toString()); | ||
} | ||
|
||
@Override | ||
public boolean MeetCondition(String value, TitleModel.EComparator comparator) { | ||
return getProcessedValue().equalsIgnoreCase(value); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/com/seniors/justlevelingfork/config/conditions/EntityKilledByCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.seniors.justlevelingfork.config.conditions; | ||
|
||
import com.seniors.justlevelingfork.JustLevelingFork; | ||
import com.seniors.justlevelingfork.config.models.TitleModel; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.stats.Stats; | ||
import net.minecraft.world.entity.EntityType; | ||
|
||
public class EntityKilledByCondition extends ConditionImpl<Integer> { | ||
|
||
public EntityKilledByCondition(){ | ||
super("EntiyKilledBy"); | ||
} | ||
|
||
@Override | ||
public void ProcessVariable(String value, ServerPlayer serverPlayer) { | ||
var entityType = EntityType.byString(value); | ||
if (entityType.isEmpty()) { | ||
setProcessedValue(0); | ||
JustLevelingFork.getLOGGER().error(">> Error! Entity name {} not found!", value); | ||
return; | ||
} | ||
|
||
setProcessedValue(serverPlayer.getStats().getValue(Stats.ENTITY_KILLED_BY.get(entityType.get()))); | ||
} | ||
|
||
@Override | ||
public boolean MeetCondition(String value, TitleModel.EComparator comparator) { | ||
int parsedValue = Integer.parseInt(value); | ||
|
||
return switch (comparator) { | ||
case EQUALS -> getProcessedValue().equals(parsedValue); | ||
case GREATER -> getProcessedValue() > parsedValue; | ||
case LESS -> getProcessedValue() < parsedValue; | ||
case GREATER_OR_EQUAL -> getProcessedValue() >= parsedValue; | ||
case LESS_OR_EQUAL -> getProcessedValue() <= parsedValue; | ||
default -> false; | ||
}; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/com/seniors/justlevelingfork/config/conditions/EntityKilledCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.seniors.justlevelingfork.config.conditions; | ||
|
||
import com.seniors.justlevelingfork.JustLevelingFork; | ||
import com.seniors.justlevelingfork.config.models.TitleModel; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.stats.Stats; | ||
import net.minecraft.world.entity.EntityType; | ||
|
||
public class EntityKilledCondition extends ConditionImpl<Integer> { | ||
|
||
public EntityKilledCondition(){ | ||
super("EntityKilled"); | ||
} | ||
|
||
@Override | ||
public void ProcessVariable(String value, ServerPlayer serverPlayer) { | ||
var entityType = EntityType.byString(value); | ||
if (entityType.isEmpty()) { | ||
JustLevelingFork.getLOGGER().error(">> Error! Entity name {} not found!", value); | ||
setProcessedValue(0); | ||
return; | ||
} | ||
|
||
setProcessedValue(serverPlayer.getStats().getValue(Stats.ENTITY_KILLED.get(entityType.get()))); | ||
} | ||
|
||
@Override | ||
public boolean MeetCondition(String value, TitleModel.EComparator comparator) { | ||
int parsedValue = Integer.parseInt(value); | ||
|
||
return switch (comparator) { | ||
case EQUALS -> getProcessedValue().equals(parsedValue); | ||
case GREATER -> getProcessedValue() > parsedValue; | ||
case LESS -> getProcessedValue() < parsedValue; | ||
case GREATER_OR_EQUAL -> getProcessedValue() >= parsedValue; | ||
case LESS_OR_EQUAL -> getProcessedValue() <= parsedValue; | ||
default -> false; | ||
}; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/com/seniors/justlevelingfork/config/conditions/ItemBrokenCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.seniors.justlevelingfork.config.conditions; | ||
|
||
import com.seniors.justlevelingfork.JustLevelingFork; | ||
import com.seniors.justlevelingfork.config.models.TitleModel; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.stats.Stats; | ||
|
||
import java.util.Optional; | ||
|
||
public class ItemBrokenCondition extends ConditionImpl<Integer> { | ||
public ItemBrokenCondition(){ | ||
super("ItemBroken"); | ||
} | ||
|
||
@Override | ||
public void ProcessVariable(String value, ServerPlayer serverPlayer) { | ||
var optionalStat = Optional.ofNullable(ResourceLocation.tryParse(value.toLowerCase())).flatMap(Stats.ITEM_BROKEN.getRegistry()::getOptional).map(Stats.ITEM_BROKEN::get); | ||
if (optionalStat.isEmpty()) { | ||
JustLevelingFork.getLOGGER().error(">> Error! Item name {} not found!", value); | ||
setProcessedValue(0); | ||
return; | ||
} | ||
|
||
setProcessedValue(serverPlayer.getStats().getValue(Stats.ITEM_BROKEN, optionalStat.get().getValue())); | ||
} | ||
|
||
@Override | ||
public boolean MeetCondition(String value, TitleModel.EComparator comparator) { | ||
int parsedValue = Integer.parseInt(value); | ||
|
||
return switch (comparator) { | ||
case EQUALS -> getProcessedValue().equals(parsedValue); | ||
case GREATER -> getProcessedValue() > parsedValue; | ||
case LESS -> getProcessedValue() < parsedValue; | ||
case GREATER_OR_EQUAL -> getProcessedValue() >= parsedValue; | ||
case LESS_OR_EQUAL -> getProcessedValue() <= parsedValue; | ||
default -> false; | ||
}; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/com/seniors/justlevelingfork/config/conditions/ItemCraftedCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.seniors.justlevelingfork.config.conditions; | ||
|
||
import com.seniors.justlevelingfork.JustLevelingFork; | ||
import com.seniors.justlevelingfork.config.models.TitleModel; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.stats.Stats; | ||
|
||
import java.util.Optional; | ||
|
||
public class ItemCraftedCondition extends ConditionImpl<Integer> { | ||
|
||
public ItemCraftedCondition(){ | ||
super("ItemCrafted"); | ||
} | ||
|
||
@Override | ||
public void ProcessVariable(String value, ServerPlayer serverPlayer) { | ||
var optionalStat = Optional.ofNullable(ResourceLocation.tryParse(value.toLowerCase())).flatMap(Stats.ITEM_CRAFTED.getRegistry()::getOptional).map(Stats.ITEM_CRAFTED::get); | ||
if (optionalStat.isEmpty()) { | ||
JustLevelingFork.getLOGGER().error(">> Error! Item name {} not found!", value); | ||
setProcessedValue(0); | ||
return; | ||
} | ||
|
||
setProcessedValue(serverPlayer.getStats().getValue(Stats.ITEM_CRAFTED, optionalStat.get().getValue())); | ||
} | ||
|
||
@Override | ||
public boolean MeetCondition(String value, TitleModel.EComparator comparator) { | ||
int parsedValue = Integer.parseInt(value); | ||
|
||
return switch (comparator) { | ||
case EQUALS -> getProcessedValue().equals(parsedValue); | ||
case GREATER -> getProcessedValue() > parsedValue; | ||
case LESS -> getProcessedValue() < parsedValue; | ||
case GREATER_OR_EQUAL -> getProcessedValue() >= parsedValue; | ||
case LESS_OR_EQUAL -> getProcessedValue() <= parsedValue; | ||
default -> false; | ||
}; | ||
} | ||
} |
Oops, something went wrong.