Skip to content

Commit

Permalink
chore: use MINECRAFT_NAMESPACE for keys directly
Browse files Browse the repository at this point in the history
  • Loading branch information
RealBauHD committed Dec 15, 2023
1 parent 0363af3 commit a1acbcd
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.github.sculkpowered.server.damage;

import static net.kyori.adventure.key.Key.MINECRAFT_NAMESPACE;

import io.github.sculkpowered.server.registry.Registry.Entry;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.nbt.CompoundBinaryTag;
Expand All @@ -8,50 +10,50 @@
public final class DamageType implements Entry {

// START
public static final DamageType ARROW = builder(Key.key("arrow")).exhaustion(0.1).messageId("arrow").scaling("when_caused_by_living_non_player").build();
public static final DamageType BAD_RESPAWN_POINT = builder(Key.key("bad_respawn_point")).exhaustion(0.1).messageId("badRespawnPoint").scaling("always").deathMessageType("intentional_game_design").build();
public static final DamageType CACTUS = builder(Key.key("cactus")).exhaustion(0.1).messageId("cactus").scaling("when_caused_by_living_non_player").build();
public static final DamageType CRAMMING = builder(Key.key("cramming")).exhaustion(0.0).messageId("cramming").scaling("when_caused_by_living_non_player").build();
public static final DamageType DRAGON_BREATH = builder(Key.key("dragon_breath")).exhaustion(0.0).messageId("dragonBreath").scaling("when_caused_by_living_non_player").build();
public static final DamageType DROWN = builder(Key.key("drown")).exhaustion(0.0).effects("drowning").messageId("drown").scaling("when_caused_by_living_non_player").build();
public static final DamageType DRY_OUT = builder(Key.key("dry_out")).exhaustion(0.1).messageId("dryout").scaling("when_caused_by_living_non_player").build();
public static final DamageType EXPLOSION = builder(Key.key("explosion")).exhaustion(0.1).messageId("explosion").scaling("always").build();
public static final DamageType FALL = builder(Key.key("fall")).exhaustion(0.0).messageId("fall").scaling("when_caused_by_living_non_player").deathMessageType("fall_variants").build();
public static final DamageType FALLING_ANVIL = builder(Key.key("falling_anvil")).exhaustion(0.1).messageId("anvil").scaling("when_caused_by_living_non_player").build();
public static final DamageType FALLING_BLOCK = builder(Key.key("falling_block")).exhaustion(0.1).messageId("fallingBlock").scaling("when_caused_by_living_non_player").build();
public static final DamageType FALLING_STALACTITE = builder(Key.key("falling_stalactite")).exhaustion(0.1).messageId("fallingStalactite").scaling("when_caused_by_living_non_player").build();
public static final DamageType FIREBALL = builder(Key.key("fireball")).exhaustion(0.1).effects("burning").messageId("fireball").scaling("when_caused_by_living_non_player").build();
public static final DamageType FIREWORKS = builder(Key.key("fireworks")).exhaustion(0.1).messageId("fireworks").scaling("when_caused_by_living_non_player").build();
public static final DamageType FLY_INTO_WALL = builder(Key.key("fly_into_wall")).exhaustion(0.0).messageId("flyIntoWall").scaling("when_caused_by_living_non_player").build();
public static final DamageType FREEZE = builder(Key.key("freeze")).exhaustion(0.0).effects("freezing").messageId("freeze").scaling("when_caused_by_living_non_player").build();
public static final DamageType GENERIC = builder(Key.key("generic")).exhaustion(0.0).messageId("generic").scaling("when_caused_by_living_non_player").build();
public static final DamageType GENERIC_KILL = builder(Key.key("generic_kill")).exhaustion(0.0).messageId("genericKill").scaling("when_caused_by_living_non_player").build();
public static final DamageType HOT_FLOOR = builder(Key.key("hot_floor")).exhaustion(0.1).effects("burning").messageId("hotFloor").scaling("when_caused_by_living_non_player").build();
public static final DamageType INDIRECT_MAGIC = builder(Key.key("indirect_magic")).exhaustion(0.0).messageId("indirectMagic").scaling("when_caused_by_living_non_player").build();
public static final DamageType IN_FIRE = builder(Key.key("in_fire")).exhaustion(0.1).effects("burning").messageId("inFire").scaling("when_caused_by_living_non_player").build();
public static final DamageType IN_WALL = builder(Key.key("in_wall")).exhaustion(0.0).messageId("inWall").scaling("when_caused_by_living_non_player").build();
public static final DamageType LAVA = builder(Key.key("lava")).exhaustion(0.1).effects("burning").messageId("lava").scaling("when_caused_by_living_non_player").build();
public static final DamageType LIGHTNING_BOLT = builder(Key.key("lightning_bolt")).exhaustion(0.1).messageId("lightningBolt").scaling("when_caused_by_living_non_player").build();
public static final DamageType MAGIC = builder(Key.key("magic")).exhaustion(0.0).messageId("magic").scaling("when_caused_by_living_non_player").build();
public static final DamageType MOB_ATTACK = builder(Key.key("mob_attack")).exhaustion(0.1).messageId("mob").scaling("when_caused_by_living_non_player").build();
public static final DamageType MOB_ATTACK_NO_AGGRO = builder(Key.key("mob_attack_no_aggro")).exhaustion(0.1).messageId("mob").scaling("when_caused_by_living_non_player").build();
public static final DamageType MOB_PROJECTILE = builder(Key.key("mob_projectile")).exhaustion(0.1).messageId("mob").scaling("when_caused_by_living_non_player").build();
public static final DamageType ON_FIRE = builder(Key.key("on_fire")).exhaustion(0.0).effects("burning").messageId("onFire").scaling("when_caused_by_living_non_player").build();
public static final DamageType OUTSIDE_BORDER = builder(Key.key("outside_border")).exhaustion(0.0).messageId("outsideBorder").scaling("when_caused_by_living_non_player").build();
public static final DamageType OUT_OF_WORLD = builder(Key.key("out_of_world")).exhaustion(0.0).messageId("outOfWorld").scaling("when_caused_by_living_non_player").build();
public static final DamageType PLAYER_ATTACK = builder(Key.key("player_attack")).exhaustion(0.1).messageId("player").scaling("when_caused_by_living_non_player").build();
public static final DamageType PLAYER_EXPLOSION = builder(Key.key("player_explosion")).exhaustion(0.1).messageId("explosion.player").scaling("always").build();
public static final DamageType SONIC_BOOM = builder(Key.key("sonic_boom")).exhaustion(0.0).messageId("sonic_boom").scaling("always").build();
public static final DamageType STALAGMITE = builder(Key.key("stalagmite")).exhaustion(0.0).messageId("stalagmite").scaling("when_caused_by_living_non_player").build();
public static final DamageType STARVE = builder(Key.key("starve")).exhaustion(0.0).messageId("starve").scaling("when_caused_by_living_non_player").build();
public static final DamageType STING = builder(Key.key("sting")).exhaustion(0.1).messageId("sting").scaling("when_caused_by_living_non_player").build();
public static final DamageType SWEET_BERRY_BUSH = builder(Key.key("sweet_berry_bush")).exhaustion(0.1).effects("poking").messageId("sweetBerryBush").scaling("when_caused_by_living_non_player").build();
public static final DamageType THORNS = builder(Key.key("thorns")).exhaustion(0.1).effects("thorns").messageId("thorns").scaling("when_caused_by_living_non_player").build();
public static final DamageType THROWN = builder(Key.key("thrown")).exhaustion(0.1).messageId("thrown").scaling("when_caused_by_living_non_player").build();
public static final DamageType TRIDENT = builder(Key.key("trident")).exhaustion(0.1).messageId("trident").scaling("when_caused_by_living_non_player").build();
public static final DamageType UNATTRIBUTED_FIREBALL = builder(Key.key("unattributed_fireball")).exhaustion(0.1).effects("burning").messageId("onFire").scaling("when_caused_by_living_non_player").build();
public static final DamageType WITHER = builder(Key.key("wither")).exhaustion(0.0).messageId("wither").scaling("when_caused_by_living_non_player").build();
public static final DamageType WITHER_SKULL = builder(Key.key("wither_skull")).exhaustion(0.1).messageId("witherSkull").scaling("when_caused_by_living_non_player").build();
public static final DamageType ARROW = builder(Key.key(MINECRAFT_NAMESPACE, "arrow")).exhaustion(0.1).messageId("arrow").scaling("when_caused_by_living_non_player").build();
public static final DamageType BAD_RESPAWN_POINT = builder(Key.key(MINECRAFT_NAMESPACE, "bad_respawn_point")).exhaustion(0.1).messageId("badRespawnPoint").scaling("always").deathMessageType("intentional_game_design").build();
public static final DamageType CACTUS = builder(Key.key(MINECRAFT_NAMESPACE, "cactus")).exhaustion(0.1).messageId("cactus").scaling("when_caused_by_living_non_player").build();
public static final DamageType CRAMMING = builder(Key.key(MINECRAFT_NAMESPACE, "cramming")).exhaustion(0.0).messageId("cramming").scaling("when_caused_by_living_non_player").build();
public static final DamageType DRAGON_BREATH = builder(Key.key(MINECRAFT_NAMESPACE, "dragon_breath")).exhaustion(0.0).messageId("dragonBreath").scaling("when_caused_by_living_non_player").build();
public static final DamageType DROWN = builder(Key.key(MINECRAFT_NAMESPACE, "drown")).exhaustion(0.0).effects("drowning").messageId("drown").scaling("when_caused_by_living_non_player").build();
public static final DamageType DRY_OUT = builder(Key.key(MINECRAFT_NAMESPACE, "dry_out")).exhaustion(0.1).messageId("dryout").scaling("when_caused_by_living_non_player").build();
public static final DamageType EXPLOSION = builder(Key.key(MINECRAFT_NAMESPACE, "explosion")).exhaustion(0.1).messageId("explosion").scaling("always").build();
public static final DamageType FALL = builder(Key.key(MINECRAFT_NAMESPACE, "fall")).exhaustion(0.0).messageId("fall").scaling("when_caused_by_living_non_player").deathMessageType("fall_variants").build();
public static final DamageType FALLING_ANVIL = builder(Key.key(MINECRAFT_NAMESPACE, "falling_anvil")).exhaustion(0.1).messageId("anvil").scaling("when_caused_by_living_non_player").build();
public static final DamageType FALLING_BLOCK = builder(Key.key(MINECRAFT_NAMESPACE, "falling_block")).exhaustion(0.1).messageId("fallingBlock").scaling("when_caused_by_living_non_player").build();
public static final DamageType FALLING_STALACTITE = builder(Key.key(MINECRAFT_NAMESPACE, "falling_stalactite")).exhaustion(0.1).messageId("fallingStalactite").scaling("when_caused_by_living_non_player").build();
public static final DamageType FIREBALL = builder(Key.key(MINECRAFT_NAMESPACE, "fireball")).exhaustion(0.1).effects("burning").messageId("fireball").scaling("when_caused_by_living_non_player").build();
public static final DamageType FIREWORKS = builder(Key.key(MINECRAFT_NAMESPACE, "fireworks")).exhaustion(0.1).messageId("fireworks").scaling("when_caused_by_living_non_player").build();
public static final DamageType FLY_INTO_WALL = builder(Key.key(MINECRAFT_NAMESPACE, "fly_into_wall")).exhaustion(0.0).messageId("flyIntoWall").scaling("when_caused_by_living_non_player").build();
public static final DamageType FREEZE = builder(Key.key(MINECRAFT_NAMESPACE, "freeze")).exhaustion(0.0).effects("freezing").messageId("freeze").scaling("when_caused_by_living_non_player").build();
public static final DamageType GENERIC = builder(Key.key(MINECRAFT_NAMESPACE, "generic")).exhaustion(0.0).messageId("generic").scaling("when_caused_by_living_non_player").build();
public static final DamageType GENERIC_KILL = builder(Key.key(MINECRAFT_NAMESPACE, "generic_kill")).exhaustion(0.0).messageId("genericKill").scaling("when_caused_by_living_non_player").build();
public static final DamageType HOT_FLOOR = builder(Key.key(MINECRAFT_NAMESPACE, "hot_floor")).exhaustion(0.1).effects("burning").messageId("hotFloor").scaling("when_caused_by_living_non_player").build();
public static final DamageType INDIRECT_MAGIC = builder(Key.key(MINECRAFT_NAMESPACE, "indirect_magic")).exhaustion(0.0).messageId("indirectMagic").scaling("when_caused_by_living_non_player").build();
public static final DamageType IN_FIRE = builder(Key.key(MINECRAFT_NAMESPACE, "in_fire")).exhaustion(0.1).effects("burning").messageId("inFire").scaling("when_caused_by_living_non_player").build();
public static final DamageType IN_WALL = builder(Key.key(MINECRAFT_NAMESPACE, "in_wall")).exhaustion(0.0).messageId("inWall").scaling("when_caused_by_living_non_player").build();
public static final DamageType LAVA = builder(Key.key(MINECRAFT_NAMESPACE, "lava")).exhaustion(0.1).effects("burning").messageId("lava").scaling("when_caused_by_living_non_player").build();
public static final DamageType LIGHTNING_BOLT = builder(Key.key(MINECRAFT_NAMESPACE, "lightning_bolt")).exhaustion(0.1).messageId("lightningBolt").scaling("when_caused_by_living_non_player").build();
public static final DamageType MAGIC = builder(Key.key(MINECRAFT_NAMESPACE, "magic")).exhaustion(0.0).messageId("magic").scaling("when_caused_by_living_non_player").build();
public static final DamageType MOB_ATTACK = builder(Key.key(MINECRAFT_NAMESPACE, "mob_attack")).exhaustion(0.1).messageId("mob").scaling("when_caused_by_living_non_player").build();
public static final DamageType MOB_ATTACK_NO_AGGRO = builder(Key.key(MINECRAFT_NAMESPACE, "mob_attack_no_aggro")).exhaustion(0.1).messageId("mob").scaling("when_caused_by_living_non_player").build();
public static final DamageType MOB_PROJECTILE = builder(Key.key(MINECRAFT_NAMESPACE, "mob_projectile")).exhaustion(0.1).messageId("mob").scaling("when_caused_by_living_non_player").build();
public static final DamageType ON_FIRE = builder(Key.key(MINECRAFT_NAMESPACE, "on_fire")).exhaustion(0.0).effects("burning").messageId("onFire").scaling("when_caused_by_living_non_player").build();
public static final DamageType OUTSIDE_BORDER = builder(Key.key(MINECRAFT_NAMESPACE, "outside_border")).exhaustion(0.0).messageId("outsideBorder").scaling("when_caused_by_living_non_player").build();
public static final DamageType OUT_OF_WORLD = builder(Key.key(MINECRAFT_NAMESPACE, "out_of_world")).exhaustion(0.0).messageId("outOfWorld").scaling("when_caused_by_living_non_player").build();
public static final DamageType PLAYER_ATTACK = builder(Key.key(MINECRAFT_NAMESPACE, "player_attack")).exhaustion(0.1).messageId("player").scaling("when_caused_by_living_non_player").build();
public static final DamageType PLAYER_EXPLOSION = builder(Key.key(MINECRAFT_NAMESPACE, "player_explosion")).exhaustion(0.1).messageId("explosion.player").scaling("always").build();
public static final DamageType SONIC_BOOM = builder(Key.key(MINECRAFT_NAMESPACE, "sonic_boom")).exhaustion(0.0).messageId("sonic_boom").scaling("always").build();
public static final DamageType STALAGMITE = builder(Key.key(MINECRAFT_NAMESPACE, "stalagmite")).exhaustion(0.0).messageId("stalagmite").scaling("when_caused_by_living_non_player").build();
public static final DamageType STARVE = builder(Key.key(MINECRAFT_NAMESPACE, "starve")).exhaustion(0.0).messageId("starve").scaling("when_caused_by_living_non_player").build();
public static final DamageType STING = builder(Key.key(MINECRAFT_NAMESPACE, "sting")).exhaustion(0.1).messageId("sting").scaling("when_caused_by_living_non_player").build();
public static final DamageType SWEET_BERRY_BUSH = builder(Key.key(MINECRAFT_NAMESPACE, "sweet_berry_bush")).exhaustion(0.1).effects("poking").messageId("sweetBerryBush").scaling("when_caused_by_living_non_player").build();
public static final DamageType THORNS = builder(Key.key(MINECRAFT_NAMESPACE, "thorns")).exhaustion(0.1).effects("thorns").messageId("thorns").scaling("when_caused_by_living_non_player").build();
public static final DamageType THROWN = builder(Key.key(MINECRAFT_NAMESPACE, "thrown")).exhaustion(0.1).messageId("thrown").scaling("when_caused_by_living_non_player").build();
public static final DamageType TRIDENT = builder(Key.key(MINECRAFT_NAMESPACE, "trident")).exhaustion(0.1).messageId("trident").scaling("when_caused_by_living_non_player").build();
public static final DamageType UNATTRIBUTED_FIREBALL = builder(Key.key(MINECRAFT_NAMESPACE, "unattributed_fireball")).exhaustion(0.1).effects("burning").messageId("onFire").scaling("when_caused_by_living_non_player").build();
public static final DamageType WITHER = builder(Key.key(MINECRAFT_NAMESPACE, "wither")).exhaustion(0.0).messageId("wither").scaling("when_caused_by_living_non_player").build();
public static final DamageType WITHER_SKULL = builder(Key.key(MINECRAFT_NAMESPACE, "wither_skull")).exhaustion(0.1).messageId("witherSkull").scaling("when_caused_by_living_non_player").build();
// END

private static int CURRENT_ID = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
public final class Dimension implements Registry.Entry {

public static final Dimension OVERWORLD = builder(Key.key("overworld"))
public static final Dimension OVERWORLD = builder(Key.key(Key.MINECRAFT_NAMESPACE, "overworld"))
.piglinSafe(false)
.hasRaids(true)
.monsterSpawnLightLevel(CompoundBinaryTag.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ private void generate(final Path generated) throws IOException {
try (final var reader = Files.newBufferedReader(path)) {
final var damageData = Constants.GSON.fromJson(reader, JsonObject.class);
final var stringBuilder = new StringBuilder(
"public static final DamageType " + upperCaseName + " = builder(Key.key(\""
+ name + "\"))");
"public static final DamageType " + upperCaseName +
" = builder(Key.key(MINECRAFT_NAMESPACE, \"" + name + "\"))");
if (damageData.has("exhaustion")) {
stringBuilder.append(".exhaustion(").append(damageData.get("exhaustion").getAsDouble())
.append(")");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static void addBlocks() {
final var entryArray = new Map.Entry<?, ?>[0];
while ((line = reader.readLine()) != null) {
@Subst("") final var split = line.split(",");
final var block = new BlockParent(Key.key(split[0]));
final var block = new BlockParent(Key.key(Key.MINECRAFT_NAMESPACE, split[0]));
var id = Integer.parseInt(split[2]);
final var defId = Integer.parseInt(split[3]);
var capacity = split.length - 4;
Expand Down

0 comments on commit a1acbcd

Please sign in to comment.