forked from FTBTeam/FTB-Chunks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added optional gamestage requirement
"require_game_stage" server config setting, defaults to false If true, players need the "ftbchunks_mapping" game stage to be able to open the map or see the minimap KubeJS and/or Gamestages are required to support this FTBTeam/FTB-Mods-Issues#580
- Loading branch information
Showing
12 changed files
with
172 additions
and
5 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
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
21 changes: 21 additions & 0 deletions
21
common/src/main/java/dev/ftb/mods/ftbchunks/integration/stages/EntityTagStageHelper.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 dev.ftb.mods.ftbchunks.integration.stages; | ||
|
||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.entity.player.Player; | ||
|
||
public class EntityTagStageHelper extends StageHelper { | ||
@Override | ||
public boolean has(Player player, String stage) { | ||
return player.getTags().contains(stage); | ||
} | ||
|
||
@Override | ||
public void add(ServerPlayer player, String stage) { | ||
player.addTag(stage); | ||
} | ||
|
||
@Override | ||
public void remove(ServerPlayer player, String stage) { | ||
player.removeTag(stage); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
common/src/main/java/dev/ftb/mods/ftbchunks/integration/stages/GameStagesStageHelper.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 dev.ftb.mods.ftbchunks.integration.stages; | ||
|
||
import dev.architectury.injectables.annotations.ExpectPlatform; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.entity.player.Player; | ||
|
||
public class GameStagesStageHelper extends StageHelper { | ||
@Override | ||
public boolean has(Player player, String stage) { | ||
return hasStage(player, stage); | ||
} | ||
|
||
@Override | ||
public void add(ServerPlayer player, String stage) { | ||
addStage(player, stage); | ||
} | ||
|
||
@Override | ||
public void remove(ServerPlayer player, String stage) { | ||
removeStage(player, stage); | ||
} | ||
|
||
@ExpectPlatform | ||
public static boolean hasStage(Player player, String stage) { | ||
throw new AssertionError(); | ||
} | ||
|
||
@ExpectPlatform | ||
public static void addStage(Player player, String stage) { | ||
throw new AssertionError(); | ||
} | ||
|
||
@ExpectPlatform | ||
public static void removeStage(Player player, String stage) { | ||
throw new AssertionError(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
common/src/main/java/dev/ftb/mods/ftbchunks/integration/stages/KubeJSStageHelper.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,22 @@ | ||
package dev.ftb.mods.ftbchunks.integration.stages; | ||
|
||
import dev.latvian.mods.kubejs.stages.Stages; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.entity.player.Player; | ||
|
||
public class KubeJSStageHelper extends StageHelper { | ||
@Override | ||
public boolean has(Player player, String stage) { | ||
return Stages.get(player).has(stage); | ||
} | ||
|
||
@Override | ||
public void add(ServerPlayer player, String stage) { | ||
Stages.get(player).add(stage); | ||
} | ||
|
||
@Override | ||
public void remove(ServerPlayer player, String stage) { | ||
Stages.get(player).remove(stage); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
common/src/main/java/dev/ftb/mods/ftbchunks/integration/stages/StageHelper.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,27 @@ | ||
package dev.ftb.mods.ftbchunks.integration.stages; | ||
|
||
import com.google.common.base.Suppliers; | ||
import dev.architectury.platform.Platform; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.entity.player.Player; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public abstract class StageHelper { | ||
public static final Supplier<StageHelper> INSTANCE = Suppliers.memoize(() -> { | ||
if (Platform.isModLoaded("kubejs")) { | ||
return new KubeJSStageHelper(); | ||
} else if (Platform.isModLoaded("gamestages")) { | ||
return new GameStagesStageHelper(); | ||
} else { | ||
return new EntityTagStageHelper(); | ||
} | ||
} | ||
); | ||
|
||
public abstract boolean has(Player player, String stage); | ||
|
||
public abstract void add(ServerPlayer player, String stage); | ||
|
||
public abstract void remove(ServerPlayer player, String stage); | ||
} |
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
19 changes: 19 additions & 0 deletions
19
...main/java/dev/ftb/mods/ftbchunks/integration/stages/fabric/GameStagesStageHelperImpl.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,19 @@ | ||
package dev.ftb.mods.ftbchunks.integration.stages.fabric; | ||
|
||
import net.minecraft.world.entity.player.Player; | ||
|
||
/** | ||
* Dummy no-op implementation since there's no Gamestages on Fabric. | ||
* This shouldn't ever get loaded, but just in case... | ||
*/ | ||
public class GameStagesStageHelperImpl { | ||
public static boolean hasStage(Player player, String stage) { | ||
return false; | ||
} | ||
|
||
public static void addStage(Player player, String stage) { | ||
} | ||
|
||
public static void removeStage(Player player, String stage) { | ||
} | ||
} |
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
19 changes: 19 additions & 0 deletions
19
.../main/java/dev/ftb/mods/ftbchunks/integration/stages/forge/GameStagesStageHelperImpl.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,19 @@ | ||
package dev.ftb.mods.ftbchunks.integration.stages.forge; | ||
|
||
import net.darkhax.gamestages.GameStageHelper; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.entity.player.Player; | ||
|
||
public class GameStagesStageHelperImpl { | ||
public static boolean hasStage(Player player, String stage) { | ||
return GameStageHelper.hasStage(player, stage); | ||
} | ||
|
||
public static void addStage(Player player, String stage) { | ||
if (player instanceof ServerPlayer sp) GameStageHelper.addStage(sp, stage); | ||
} | ||
|
||
public static void removeStage(Player player, String stage) { | ||
if (player instanceof ServerPlayer sp) GameStageHelper.removeStage(sp, stage); | ||
} | ||
} |
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