From 6dc538f84b4fe4335f71b340a5247bb8cb292373 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Mon, 11 May 2020 00:03:55 +0200 Subject: [PATCH] It is now possible to set the default state that players without mod installed will have set. --- .../elytra_swap/core/ConfigHandler.java | 28 +++++++++++++++---- .../core/ServerSwapStateHandler.java | 10 +++++-- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/szum123321/elytra_swap/core/ConfigHandler.java b/src/main/java/net/szum123321/elytra_swap/core/ConfigHandler.java index b205e53..b5ef4f0 100644 --- a/src/main/java/net/szum123321/elytra_swap/core/ConfigHandler.java +++ b/src/main/java/net/szum123321/elytra_swap/core/ConfigHandler.java @@ -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; + } + } } diff --git a/src/main/java/net/szum123321/elytra_swap/core/ServerSwapStateHandler.java b/src/main/java/net/szum123321/elytra_swap/core/ServerSwapStateHandler.java index db88158..ec75b62 100644 --- a/src/main/java/net/szum123321/elytra_swap/core/ServerSwapStateHandler.java +++ b/src/main/java/net/szum123321/elytra_swap/core/ServerSwapStateHandler.java @@ -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; } } @@ -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(); } }