Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/main/java/dev/walshy/hardcoreslimefun/events/Events.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class Events implements Listener {
public void onDeath(@Nonnull PlayerDeathEvent event) {
PlayerProfile.get(event.getEntity(), profile -> {
final boolean shouldResetAllResearches = Utils.chance(Config.INSTANCE.getResetAllResearchesOnDeath());
final boolean shouldResetOneResearch = Utils.chance(Config.INSTANCE.getResetResearchChance());
Comment thread
wcy6457 marked this conversation as resolved.
Outdated

// If we should reset all researches, do it
if (shouldResetAllResearches) {
Expand All @@ -30,11 +31,11 @@ public void onDeath(@Nonnull PlayerDeathEvent event) {
}
Utils.send(event.getEntity(), Config.INSTANCE.getLostAllResearch());

} else if (Config.INSTANCE.isResetResearchOnDeath()) {
} else if (shouldResetOneResearch) {
// If we should reset a random one, do it
final Research randomResearch = Utils.randomValue(profile.getResearches());
if (randomResearch == null) return;

Comment thread
wcy6457 marked this conversation as resolved.
Outdated
Comment thread
wcy6457 marked this conversation as resolved.
Outdated
profile.setResearched(randomResearch, false);
String message = Config.INSTANCE.getLostRandomResearch().replace("%research%", randomResearch.getName(event.getEntity()));
Utils.send(event.getEntity(), message);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/dev/walshy/hardcoreslimefun/utils/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Config {
public static final Config INSTANCE = new Config();

// on-death.reset-random-research
private boolean resetResearchOnDeath;
private double resetResearchOnDeath;
// on-death.chance-to-reset-all-researches
private double resetAllResearchesOnDeath;

Expand All @@ -36,7 +36,7 @@ public class Config {
private String androidMalfunctioned;

public void load(@Nonnull FileConfiguration config) {
resetResearchOnDeath = config.getBoolean("on-death.reset-random-research", true);
resetResearchOnDeath = getPercent(config,"on-death.resetResearchChance",70);
Comment thread
wcy6457 marked this conversation as resolved.
resetAllResearchesOnDeath = getPercent(config, "on-death.chance-to-reset-all-researches", 5);

researchFailChance = getPercent(config, "on-research.chance-of-failure", 10);
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# If the plugin should auto-update
auto-update: true
on-death:
# If true, a player will lose a random research every death
reset-random-research: true
# Chance to reset one player's researches on death. Percent scale of 0 to 100.
# 100 will always fire and 0 will never fire.
chance-to-reset-random-research: 70
# Chance to reset all the player's researches on death. Percent scale of 0 to 100.
# 100 will always fire and 0 will never fire.
chance-to-reset-all-researches: 5
Expand Down