[NOJANG] New GameRules API to access game rules in mods and fix paper command issues with LuckPerms

This commit is contained in:
2025-03-09 17:13:18 +02:00
parent 770f214dcf
commit fdbadd6696
61 changed files with 1545 additions and 94 deletions

View File

@@ -0,0 +1,67 @@
--- a/Common/src/main/java/com/hypherionmc/craterlib/nojang/world/level/BridgedGameRules.java
+++ b/Common/src/main/java/com/hypherionmc/craterlib/nojang/world/level/BridgedGameRules.java
@@ -10,12 +10,12 @@
// Wrapped Mojang Rules for convenience
public static final WrappedBooleanKey RULE_DOFIRETICK = WrappedBooleanKey.wrap(GameRules.RULE_DOFIRETICK);
- public static final WrappedBooleanKey RULE_ALLOWFIRETICKAWAYFROMPLAYERS = WrappedBooleanKey.wrap(GameRules.RULE_ALLOWFIRETICKAWAYFROMPLAYERS);
+ public static final WrappedBooleanKey RULE_ALLOWFIRETICKAWAYFROMPLAYERS = WrappedBooleanKey.wrap(null);
public static final WrappedBooleanKey RULE_MOBGRIEFING = WrappedBooleanKey.wrap(GameRules.RULE_MOBGRIEFING);
public static final WrappedBooleanKey RULE_KEEPINVENTORY = WrappedBooleanKey.wrap(GameRules.RULE_KEEPINVENTORY);
public static final WrappedBooleanKey RULE_DOMOBSPAWNING = WrappedBooleanKey.wrap(GameRules.RULE_DOMOBSPAWNING);
public static final WrappedBooleanKey RULE_DOMOBLOOT = WrappedBooleanKey.wrap(GameRules.RULE_DOMOBLOOT);
- public static final WrappedBooleanKey RULE_PROJECTILESCANBREAKBLOCKS = WrappedBooleanKey.wrap(GameRules.RULE_PROJECTILESCANBREAKBLOCKS);
+ public static final WrappedBooleanKey RULE_PROJECTILESCANBREAKBLOCKS = WrappedBooleanKey.wrap(null);
public static final WrappedBooleanKey RULE_DOBLOCKDROPS = WrappedBooleanKey.wrap(GameRules.RULE_DOBLOCKDROPS);
public static final WrappedBooleanKey RULE_DOENTITYDROPS = WrappedBooleanKey.wrap(GameRules.RULE_DOENTITYDROPS);
public static final WrappedBooleanKey RULE_COMMANDBLOCKOUTPUT = WrappedBooleanKey.wrap(GameRules.RULE_COMMANDBLOCKOUTPUT);
@@ -28,20 +28,20 @@
public static final WrappedBooleanKey RULE_REDUCEDDEBUGINFO = WrappedBooleanKey.wrap(GameRules.RULE_REDUCEDDEBUGINFO);
public static final WrappedBooleanKey RULE_SPECTATORSGENERATECHUNKS = WrappedBooleanKey.wrap(GameRules.RULE_SPECTATORSGENERATECHUNKS);
public static final WrappedIntegerKey RULE_SPAWN_RADIUS = WrappedIntegerKey.wrap(GameRules.RULE_SPAWN_RADIUS);
- public static final WrappedBooleanKey RULE_DISABLE_PLAYER_MOVEMENT_CHECK = WrappedBooleanKey.wrap(GameRules.RULE_DISABLE_PLAYER_MOVEMENT_CHECK);
+ public static final WrappedBooleanKey RULE_DISABLE_PLAYER_MOVEMENT_CHECK = WrappedBooleanKey.wrap(null);
public static final WrappedBooleanKey RULE_DISABLE_ELYTRA_MOVEMENT_CHECK = WrappedBooleanKey.wrap(GameRules.RULE_DISABLE_ELYTRA_MOVEMENT_CHECK);
public static final WrappedIntegerKey RULE_MAX_ENTITY_CRAMMING = WrappedIntegerKey.wrap(GameRules.RULE_MAX_ENTITY_CRAMMING);
public static final WrappedBooleanKey RULE_WEATHER_CYCLE = WrappedBooleanKey.wrap(GameRules.RULE_WEATHER_CYCLE);
public static final WrappedBooleanKey RULE_LIMITED_CRAFTING = WrappedBooleanKey.wrap(GameRules.RULE_LIMITED_CRAFTING);
public static final WrappedIntegerKey RULE_MAX_COMMAND_CHAIN_LENGTH = WrappedIntegerKey.wrap(GameRules.RULE_MAX_COMMAND_CHAIN_LENGTH);
- public static final WrappedIntegerKey RULE_MAX_COMMAND_FORK_COUNT = WrappedIntegerKey.wrap(GameRules.RULE_MAX_COMMAND_FORK_COUNT);
+ public static final WrappedIntegerKey RULE_MAX_COMMAND_FORK_COUNT = WrappedIntegerKey.wrap(null);
public static final WrappedIntegerKey RULE_COMMAND_MODIFICATION_BLOCK_LIMIT = WrappedIntegerKey.wrap(GameRules.RULE_COMMAND_MODIFICATION_BLOCK_LIMIT);
public static final WrappedBooleanKey RULE_ANNOUNCE_ADVANCEMENTS = WrappedBooleanKey.wrap(GameRules.RULE_ANNOUNCE_ADVANCEMENTS);
public static final WrappedBooleanKey RULE_DISABLE_RAIDS = WrappedBooleanKey.wrap(GameRules.RULE_DISABLE_RAIDS);
public static final WrappedBooleanKey RULE_DOINSOMNIA = WrappedBooleanKey.wrap(GameRules.RULE_DOINSOMNIA);
public static final WrappedBooleanKey RULE_DO_IMMEDIATE_RESPAWN = WrappedBooleanKey.wrap(GameRules.RULE_DO_IMMEDIATE_RESPAWN);
- public static final WrappedIntegerKey RULE_PLAYERS_NETHER_PORTAL_DEFAULT_DELAY = WrappedIntegerKey.wrap(GameRules.RULE_PLAYERS_NETHER_PORTAL_DEFAULT_DELAY);
- public static final WrappedIntegerKey RULE_PLAYERS_NETHER_PORTAL_CREATIVE_DELAY = WrappedIntegerKey.wrap(GameRules.RULE_PLAYERS_NETHER_PORTAL_CREATIVE_DELAY);
+ public static final WrappedIntegerKey RULE_PLAYERS_NETHER_PORTAL_DEFAULT_DELAY = WrappedIntegerKey.wrap(null);
+ public static final WrappedIntegerKey RULE_PLAYERS_NETHER_PORTAL_CREATIVE_DELAY = WrappedIntegerKey.wrap(null);
public static final WrappedBooleanKey RULE_DROWNING_DAMAGE = WrappedBooleanKey.wrap(GameRules.RULE_DROWNING_DAMAGE);
public static final WrappedBooleanKey RULE_FALL_DAMAGE = WrappedBooleanKey.wrap(GameRules.RULE_FALL_DAMAGE);
public static final WrappedBooleanKey RULE_FIRE_DAMAGE = WrappedBooleanKey.wrap(GameRules.RULE_FIRE_DAMAGE);
@@ -61,15 +61,21 @@
public static final WrappedBooleanKey RULE_GLOBAL_SOUND_EVENTS = WrappedBooleanKey.wrap(GameRules.RULE_GLOBAL_SOUND_EVENTS);
public static final WrappedBooleanKey RULE_DO_VINES_SPREAD = WrappedBooleanKey.wrap(GameRules.RULE_DO_VINES_SPREAD);
public static final WrappedBooleanKey RULE_ENDER_PEARLS_VANISH_ON_DEATH = WrappedBooleanKey.wrap(GameRules.RULE_ENDER_PEARLS_VANISH_ON_DEATH);
- public static final WrappedIntegerKey RULE_MINECART_MAX_SPEED = WrappedIntegerKey.wrap(GameRules.RULE_MINECART_MAX_SPEED);
- public static final WrappedIntegerKey RULE_SPAWN_CHUNK_RADIUS = WrappedIntegerKey.wrap(GameRules.RULE_SPAWN_CHUNK_RADIUS);
- public static final WrappedBooleanKey RULE_TNT_EXPLODES = WrappedBooleanKey.wrap(GameRules.RULE_TNT_EXPLODES);
+ public static final WrappedIntegerKey RULE_MINECART_MAX_SPEED = WrappedIntegerKey.wrap(null);
+ public static final WrappedIntegerKey RULE_SPAWN_CHUNK_RADIUS = WrappedIntegerKey.wrap(null);
+ public static final WrappedBooleanKey RULE_TNT_EXPLODES = WrappedBooleanKey.wrap(null);
public boolean getBoolean(WrappedBooleanKey key) {
+ if (key.toMojang() == null)
+ return false;
+
return internal.getBoolean(key.toMojang());
}
public int getInt(WrappedIntegerKey key) {
+ if (key.toMojang() == null)
+ return 0;
+
return internal.getInt(key.toMojang());
}

View File

@@ -1,6 +1,6 @@
--- a/Paper/src/main/resources/paper-plugin.yml
+++ b/Paper/src/main/resources/paper-plugin.yml
@@ -3,6 +3,6 @@
@@ -3,7 +3,7 @@
description: "A Modding API used to create 'universal' mods"
main: com.hypherionmc.craterlib.paper.CraterLibPlugin
author: HypherionSA
@@ -8,3 +8,4 @@
+api-version: '1.20'
bootstrapper: com.hypherionmc.craterlib.paper.CraterLibBootstrap
load: STARTUP