Skip to content

Commit

Permalink
It is now possible to set the default state that players without mod …
Browse files Browse the repository at this point in the history
…installed will have set.
  • Loading branch information
Szum123321 committed May 10, 2020
1 parent 801b9ae commit 6dc538f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
28 changes: 23 additions & 5 deletions src/main/java/net/szum123321/elytra_swap/core/ConfigHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,33 @@ public class ConfigHandler {
)
public int noModPlayersHandlingMethod = 1;

@Comment(value = "\nThis is how much vertical speed player will gain as a result of using firework rocket\n" +
"default: 1.7\n")
@Comment(value = "\nThis is how much vertical speed player will gain as a result of using firework rocket.\n" +
"Default: 1.7\n")
public float kickSpeed = 1.7F;

@Comment(value = "\nMinimal height that player has to have above him in order to use firework\n" +
"default: 15\n")
@Comment(value = "\nMinimal height that player has to have above him in order to use firework.\n" +
"Default: 15\n")
public int requiredHeightAbovePlayer = 15;

@Comment(value = "\nIf you set this to false Elytra Swap won't look for chestplate or elytra inside shulker boxes.\n" +
"default: true\n")
"Default: true\n")
public boolean lookThroughShulkers = true;

@Comment(value = "\nThis is the default state, that would be given to the players which do not have Elytra Swap installed.\n" +
"Available: ENABLE, DISABLE\n" +
"Default: ENABLE\n")
public EnableDisableEnum noModPlayersDefaultState = EnableDisableEnum.ENABLE;

enum EnableDisableEnum {
ENABLE(true),
DISABLE(false);

public boolean getState() { return state; }

private final boolean state;

private EnableDisableEnum(boolean state) {
this.state = state;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ public void addPlayer(PlayerEntity player, boolean val, Tristate trinkets){
data.put(player.getName().asString(), new Pair<>(val, trinkets));
}

public void addDefaultPlayer(PlayerEntity player) {
addPlayer(player, ElytraSwap.config.noModPlayersDefaultState.getState(), Tristate.UNKNOWN);
}

public Tristate getTrinketsSupport(PlayerEntity player) {
if(isMapped(player)) {
return data.get(player.getName().asString()).getSecond();
} else {
addPlayer(player, true, Tristate.UNKNOWN);
addDefaultPlayer(player);
return Tristate.UNKNOWN;
}
}
Expand All @@ -64,8 +68,8 @@ public boolean getSwapState(PlayerEntity player) {
if(isMapped(player)) {
return data.get(player.getName().asString()).getFirst();
} else {
addPlayer(player, true, Tristate.UNKNOWN);
return true;
addDefaultPlayer(player);
return ElytraSwap.config.noModPlayersDefaultState.getState();
}
}

Expand Down

0 comments on commit 6dc538f

Please sign in to comment.