Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59f43ad200 | ||
|
|
6cc87f8fc0 |
No files matched your search
+12
-19
@@ -1,46 +1,39 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
charset=utf-8
|
||||
end_of_line=lf
|
||||
insert_final_newline=true
|
||||
indent_style=space
|
||||
indent_size=4
|
||||
ij_any_block_comment_add_space = false
|
||||
ij_any_block_comment_at_first_column = false
|
||||
ij_any_line_comment_at_first_column = false
|
||||
ij_any_line_comment_add_space = true
|
||||
|
||||
[*.tiny]
|
||||
indent_style = tab
|
||||
indent_style=tab
|
||||
|
||||
[*.bat]
|
||||
end_of_line = crlf
|
||||
end_of_line=crlf
|
||||
|
||||
[*.yml]
|
||||
indent_size = 2
|
||||
indent_size=2
|
||||
|
||||
[*.patch]
|
||||
trim_trailing_whitespace = false
|
||||
trim_trailing_whitespace=false
|
||||
|
||||
[*.java]
|
||||
ij_continuation_indent_size = 4
|
||||
ij_java_class_count_to_use_import_on_demand = 999999
|
||||
ij_java_insert_inner_class_imports = false
|
||||
ij_java_names_count_to_use_import_on_demand = 999999
|
||||
ij_java_imports_layout = *, |, $*
|
||||
ij_java_imports_layout = *,|,$*
|
||||
ij_java_generate_final_locals = true
|
||||
ij_java_generate_final_parameters = true
|
||||
ij_java_method_parameters_new_line_after_left_paren = true
|
||||
ij_java_method_parameters_right_paren_on_new_line = true
|
||||
ij_java_use_fq_class_names = false
|
||||
ij_java_class_names_in_javadoc = 1
|
||||
|
||||
[paper-server/src/minecraft/java/**/*.java]
|
||||
ij_java_use_fq_class_names = true
|
||||
|
||||
[paper-server/src/minecraft/resources/data/**/*.json]
|
||||
indent_size = 2
|
||||
|
||||
[paper-{server,api}/src/generated/java/**/*.java]
|
||||
ij_java_imports_layout = $*, |, *
|
||||
[paper-api-generator/generated/**/*.java]
|
||||
ij_java_imports_layout = $*,|,*
|
||||
@@ -16,17 +16,8 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# The goal of the build workflow is split into multiple requirements.
|
||||
# 1. Run on pushes to same repo.
|
||||
# 2. Run on PR open/reopen/syncs from repos that are not the same (PRs from the same repo are covered by 1)
|
||||
# 3. Run on labeled PRs that have the build-pr-jar flag.
|
||||
if: >
|
||||
(
|
||||
(github.event_name == 'push')
|
||||
|| (github.event_name == 'pull_request' && github.repository != github.event.pull_request.head.repo.full_name && contains(fromJSON('["opened", "reopened", "synchronize"]'), github.event.action))
|
||||
|| (github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == 'build-pr-jar')
|
||||
)
|
||||
|
||||
# Run on all label events (won't be duplicated) or all push events or on PR syncs not from the same repo
|
||||
if: (github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == 'build-pr-jar') || github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ logs/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
test-plugin.settings.gradle.kts
|
||||
paper-generator.settings.gradle.kts
|
||||
paper-api-generator.settings.gradle.kts
|
||||
|
||||
# Don't track patched vanilla submodules
|
||||
paper-server/src/minecraft/
|
||||
+1
-2
@@ -208,8 +208,7 @@ required.
|
||||
with `// Paper end - <COMMIT DESCRIPTION>`.
|
||||
- One-line changes should have `// Paper - <COMMIT DESCRIPTION>` at the end of the line.
|
||||
|
||||
> [!NOTE]
|
||||
> These comments are incredibly important to be able to keep track of changes
|
||||
> [!NOTE] These comments are incredibly important to be able to keep track of changes
|
||||
> across files and to remember what they are for, even a decade into the future.
|
||||
|
||||
Here's an example of how to mark changes by Paper:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tiny 2 0 spigot mojang
|
||||
tiny 2 0 spigot mojang+yarn
|
||||
|
||||
# Originally DistanceManager, which also implements DistanceManager, so clashes since the implemented class
|
||||
# is imported and not fully qualified. Easiest fix is to just change the name
|
||||
|
||||
@@ -110,8 +110,6 @@ public net.minecraft.server.network.ServerLoginPacketListenerImpl connection
|
||||
public net.minecraft.server.network.ServerLoginPacketListenerImpl state
|
||||
public net.minecraft.server.network.ServerLoginPacketListenerImpl$State
|
||||
public net.minecraft.server.packs.VanillaPackResourcesBuilder safeGetPath(Ljava/net/URI;)Ljava/nio/file/Path;
|
||||
public net.minecraft.server.packs.repository.FolderRepositorySource$FolderPackDetector
|
||||
public net.minecraft.server.packs.repository.FolderRepositorySource$FolderPackDetector <init>(Lnet/minecraft/world/level/validation/DirectoryValidator;)V
|
||||
public net.minecraft.server.packs.repository.Pack resources
|
||||
public net.minecraft.server.players.PlayerList playerIo
|
||||
public net.minecraft.server.players.PlayerList players
|
||||
@@ -186,7 +184,6 @@ public net.minecraft.world.entity.Entity getEncodeId()Ljava/lang/String;
|
||||
public net.minecraft.world.entity.Entity getFireImmuneTicks()I
|
||||
public net.minecraft.world.entity.Entity getSharedFlag(I)Z
|
||||
public net.minecraft.world.entity.Entity hasVisualFire
|
||||
public net.minecraft.world.entity.Entity isAffectedByBlocks()Z
|
||||
public net.minecraft.world.entity.Entity isInBubbleColumn()Z
|
||||
public net.minecraft.world.entity.Entity isInRain()Z
|
||||
public net.minecraft.world.entity.Entity isInvulnerableToBase(Lnet/minecraft/world/damagesource/DamageSource;)Z
|
||||
@@ -197,7 +194,6 @@ public net.minecraft.world.entity.Entity random
|
||||
public net.minecraft.world.entity.Entity setLevel(Lnet/minecraft/world/level/Level;)V
|
||||
public net.minecraft.world.entity.Entity setRot(FF)V
|
||||
public net.minecraft.world.entity.Entity setSharedFlag(IZ)V
|
||||
public net.minecraft.world.entity.Entity teleportPassengers()V
|
||||
public net.minecraft.world.entity.Entity unsetRemoved()V
|
||||
public net.minecraft.world.entity.Entity wasTouchingWater
|
||||
public net.minecraft.world.entity.ExperienceOrb count
|
||||
@@ -505,7 +501,6 @@ public net.minecraft.world.item.ItemStackLinkedSet TYPE_AND_TAG
|
||||
public net.minecraft.world.item.JukeboxSongPlayer song
|
||||
public net.minecraft.world.item.MapItem createNewSavedData(Lnet/minecraft/world/level/Level;IIIZZLnet/minecraft/resources/ResourceKey;)Lnet/minecraft/world/level/saveddata/maps/MapId;
|
||||
public net.minecraft.world.item.StandingAndWallBlockItem wallBlock
|
||||
public net.minecraft.world.item.component.BundleContents$Mutable getMaxAmountToAdd(Lnet/minecraft/world/item/ItemStack;)I
|
||||
public net.minecraft.world.item.component.ItemContainerContents MAX_SIZE
|
||||
public net.minecraft.world.item.component.ItemContainerContents items
|
||||
public net.minecraft.world.item.context.UseOnContext <init>(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/phys/BlockHitResult;)V
|
||||
@@ -625,16 +620,9 @@ public net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity exitPorta
|
||||
public net.minecraft.world.level.block.entity.TrialSpawnerBlockEntity trialSpawner
|
||||
public net.minecraft.world.level.block.entity.trialspawner.TrialSpawner isOminous
|
||||
public net.minecraft.world.level.block.entity.trialspawner.TrialSpawner stateAccessor
|
||||
public net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerData cooldownEndsAt
|
||||
public net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerData currentMobs
|
||||
public net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerData detectedPlayers
|
||||
public net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerData nextMobSpawnsAt
|
||||
public net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerData nextSpawnData
|
||||
public net.minecraft.world.level.block.entity.vault.VaultBlockEntity serverData
|
||||
public net.minecraft.world.level.block.entity.vault.VaultServerData getRewardedPlayers()Ljava/util/Set;
|
||||
public net.minecraft.world.level.block.entity.vault.VaultServerData pauseStateUpdatingUntil(J)V
|
||||
public net.minecraft.world.level.block.entity.vault.VaultServerData stateUpdatingResumesAt()J
|
||||
public net.minecraft.world.level.block.entity.vault.VaultSharedData getConnectedPlayers()Ljava/util/Set;
|
||||
public net.minecraft.world.level.block.state.BlockBehaviour getMenuProvider(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/MenuProvider;
|
||||
public net.minecraft.world.level.block.state.BlockBehaviour hasCollision
|
||||
public net.minecraft.world.level.block.state.BlockBehaviour$BlockStateBase destroySpeed
|
||||
@@ -733,7 +721,6 @@ public-f net.minecraft.world.item.trading.MerchantOffer rewardExp
|
||||
public-f net.minecraft.world.item.trading.MerchantOffer xp
|
||||
public-f net.minecraft.world.level.LevelSettings hardcore
|
||||
public-f net.minecraft.world.level.LevelSettings levelName
|
||||
public-f net.minecraft.world.level.block.ChestBlock MENU_PROVIDER_COMBINER
|
||||
public-f net.minecraft.world.level.block.entity.BannerBlockEntity baseColor
|
||||
public-f net.minecraft.world.level.block.entity.trialspawner.TrialSpawner normalConfig
|
||||
public-f net.minecraft.world.level.block.entity.trialspawner.TrialSpawner ominousConfig
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
# a significant amount of time for us to track down every possible issue, so this file will likely be around and in
|
||||
# use - at least in some capacity - for a long time.
|
||||
|
||||
tiny 2 0 mojang spigot
|
||||
tiny 2 0 mojang+yarn spigot
|
||||
|
||||
# CraftBukkit changes type
|
||||
c net/minecraft/server/level/ServerLevel net/minecraft/server/level/WorldServer
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import java.nio.file.Path
|
||||
import kotlin.random.Random
|
||||
|
||||
plugins {
|
||||
id("io.papermc.paperweight.core") version "2.0.0-beta.14" apply false
|
||||
id("io.papermc.paperweight.core") version "2.0.0-beta.8" apply false
|
||||
}
|
||||
|
||||
subprojects {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import io.papermc.paperweight.util.defaultJavaLauncher
|
||||
|
||||
plugins {
|
||||
java
|
||||
id("io.papermc.paperweight.source-generator")
|
||||
}
|
||||
|
||||
paperweight {
|
||||
atFile.set(layout.projectDirectory.file("wideners.at"))
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraftJar(project(":paper-server", "mappedJarOutgoing"))
|
||||
implementation(project(":paper-server", "macheMinecraftLibraries"))
|
||||
|
||||
implementation("com.squareup:javapoet:1.13.0")
|
||||
implementation(project(":paper-api"))
|
||||
implementation("io.github.classgraph:classgraph:4.8.47")
|
||||
implementation("org.jetbrains:annotations:24.1.0")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
}
|
||||
|
||||
tasks.register<JavaExec>("generate") {
|
||||
dependsOn(tasks.check)
|
||||
mainClass.set("io.papermc.generator.Main")
|
||||
classpath(sourceSets.main.map { it.runtimeClasspath })
|
||||
args(projectDir.toPath().resolve("generated").toString())
|
||||
javaLauncher = javaToolchains.defaultJavaLauncher(project)
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
group = "io.papermc.paper"
|
||||
version = "1.0-SNAPSHOT"
|
||||
+1
-1
@@ -66,8 +66,8 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
public interface VanillaGoal<T extends Mob> extends Goal<T> {
|
||||
GoalKey<AbstractHorse> RANDOM_STAND = create("random_stand", AbstractHorse.class);
|
||||
|
||||
+3
-1
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class AttributeKeys {
|
||||
/**
|
||||
* {@code minecraft:armor}
|
||||
+5
-2
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.block.banner.PatternType;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class BannerPatternKeys {
|
||||
/**
|
||||
* {@code minecraft:base}
|
||||
@@ -330,11 +332,12 @@ public final class BannerPatternKeys {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a typed key for {@link PatternType} in the registry {@code minecraft:banner_pattern}.
|
||||
* Creates a key for {@link PatternType} in the registry {@code minecraft:banner_pattern}.
|
||||
*
|
||||
* @param key the value's key in the registry
|
||||
* @return a new typed key
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
public static TypedKey<PatternType> create(final Key key) {
|
||||
return TypedKey.create(RegistryKey.BANNER_PATTERN, key);
|
||||
}
|
||||
+5
-2
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class BiomeKeys {
|
||||
/**
|
||||
* {@code minecraft:badlands}
|
||||
@@ -484,11 +486,12 @@ public final class BiomeKeys {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a typed key for {@link Biome} in the registry {@code minecraft:worldgen/biome}.
|
||||
* Creates a key for {@link Biome} in the registry {@code minecraft:worldgen/biome}.
|
||||
*
|
||||
* @param key the value's key in the registry
|
||||
* @return a new typed key
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
public static TypedKey<Biome> create(final Key key) {
|
||||
return TypedKey.create(RegistryKey.BIOME, key);
|
||||
}
|
||||
+3
-1
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.block.BlockType;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class BlockTypeKeys {
|
||||
/**
|
||||
* {@code minecraft:acacia_button}
|
||||
+3
-1
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.entity.Cat;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class CatVariantKeys {
|
||||
/**
|
||||
* {@code minecraft:all_black}
|
||||
+5
-2
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.damage.DamageType;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class DamageTypeKeys {
|
||||
/**
|
||||
* {@code minecraft:arrow}
|
||||
@@ -372,11 +374,12 @@ public final class DamageTypeKeys {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a typed key for {@link DamageType} in the registry {@code minecraft:damage_type}.
|
||||
* Creates a key for {@link DamageType} in the registry {@code minecraft:damage_type}.
|
||||
*
|
||||
* @param key the value's key in the registry
|
||||
* @return a new typed key
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
public static TypedKey<DamageType> create(final Key key) {
|
||||
return TypedKey.create(RegistryKey.DAMAGE_TYPE, key);
|
||||
}
|
||||
+5
-2
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class EnchantmentKeys {
|
||||
/**
|
||||
* {@code minecraft:aqua_affinity}
|
||||
@@ -323,11 +325,12 @@ public final class EnchantmentKeys {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a typed key for {@link Enchantment} in the registry {@code minecraft:enchantment}.
|
||||
* Creates a key for {@link Enchantment} in the registry {@code minecraft:enchantment}.
|
||||
*
|
||||
* @param key the value's key in the registry
|
||||
* @return a new typed key
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
public static TypedKey<Enchantment> create(final Key key) {
|
||||
return TypedKey.create(RegistryKey.ENCHANTMENT, key);
|
||||
}
|
||||
+3
-1
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.Fluid;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class FluidKeys {
|
||||
/**
|
||||
* {@code minecraft:empty}
|
||||
+3
-1
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.entity.Frog;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class FrogVariantKeys {
|
||||
/**
|
||||
* {@code minecraft:cold}
|
||||
+5
-2
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.GameEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class GameEventKeys {
|
||||
/**
|
||||
* {@code minecraft:block_activate}
|
||||
@@ -449,11 +451,12 @@ public final class GameEventKeys {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a typed key for {@link GameEvent} in the registry {@code minecraft:game_event}.
|
||||
* Creates a key for {@link GameEvent} in the registry {@code minecraft:game_event}.
|
||||
*
|
||||
* @param key the value's key in the registry
|
||||
* @return a new typed key
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
public static TypedKey<GameEvent> create(final Key key) {
|
||||
return TypedKey.create(RegistryKey.GAME_EVENT, key);
|
||||
}
|
||||
+5
-2
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.MusicInstrument;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class InstrumentKeys {
|
||||
/**
|
||||
* {@code minecraft:admire_goat_horn}
|
||||
@@ -85,11 +87,12 @@ public final class InstrumentKeys {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a typed key for {@link MusicInstrument} in the registry {@code minecraft:instrument}.
|
||||
* Creates a key for {@link MusicInstrument} in the registry {@code minecraft:instrument}.
|
||||
*
|
||||
* @param key the value's key in the registry
|
||||
* @return a new typed key
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
public static TypedKey<MusicInstrument> create(final Key key) {
|
||||
return TypedKey.create(RegistryKey.INSTRUMENT, key);
|
||||
}
|
||||
+3
-1
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.inventory.ItemType;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class ItemTypeKeys {
|
||||
/**
|
||||
* {@code minecraft:acacia_boat}
|
||||
+5
-2
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.JukeboxSong;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class JukeboxSongKeys {
|
||||
/**
|
||||
* {@code minecraft:11}
|
||||
@@ -162,11 +164,12 @@ public final class JukeboxSongKeys {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a typed key for {@link JukeboxSong} in the registry {@code minecraft:jukebox_song}.
|
||||
* Creates a key for {@link JukeboxSong} in the registry {@code minecraft:jukebox_song}.
|
||||
*
|
||||
* @param key the value's key in the registry
|
||||
* @return a new typed key
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
public static TypedKey<JukeboxSong> create(final Key key) {
|
||||
return TypedKey.create(RegistryKey.JUKEBOX_SONG, key);
|
||||
}
|
||||
+3
-1
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.map.MapCursor;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class MapDecorationTypeKeys {
|
||||
/**
|
||||
* {@code minecraft:banner_black}
|
||||
+3
-1
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.inventory.MenuType;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class MenuTypeKeys {
|
||||
/**
|
||||
* {@code minecraft:anvil}
|
||||
+3
-1
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class MobEffectKeys {
|
||||
/**
|
||||
* {@code minecraft:absorption}
|
||||
+5
-2
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.Art;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class PaintingVariantKeys {
|
||||
/**
|
||||
* {@code minecraft:alban}
|
||||
@@ -379,11 +381,12 @@ public final class PaintingVariantKeys {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a typed key for {@link Art} in the registry {@code minecraft:painting_variant}.
|
||||
* Creates a key for {@link Art} in the registry {@code minecraft:painting_variant}.
|
||||
*
|
||||
* @param key the value's key in the registry
|
||||
* @return a new typed key
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
public static TypedKey<Art> create(final Key key) {
|
||||
return TypedKey.create(RegistryKey.PAINTING_VARIANT, key);
|
||||
}
|
||||
+3
-1
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.Sound;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class SoundEventKeys {
|
||||
/**
|
||||
* {@code minecraft:ambient.basalt_deltas.additions}
|
||||
+5
-2
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.generator.structure.Structure;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class StructureKeys {
|
||||
/**
|
||||
* {@code minecraft:ancient_city}
|
||||
@@ -267,11 +269,12 @@ public final class StructureKeys {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a typed key for {@link Structure} in the registry {@code minecraft:worldgen/structure}.
|
||||
* Creates a key for {@link Structure} in the registry {@code minecraft:worldgen/structure}.
|
||||
*
|
||||
* @param key the value's key in the registry
|
||||
* @return a new typed key
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
public static TypedKey<Structure> create(final Key key) {
|
||||
return TypedKey.create(RegistryKey.STRUCTURE, key);
|
||||
}
|
||||
+3
-1
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.generator.structure.StructureType;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class StructureTypeKeys {
|
||||
/**
|
||||
* {@code minecraft:buried_treasure}
|
||||
+5
-2
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.inventory.meta.trim.TrimMaterial;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class TrimMaterialKeys {
|
||||
/**
|
||||
* {@code minecraft:amethyst}
|
||||
@@ -106,11 +108,12 @@ public final class TrimMaterialKeys {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a typed key for {@link TrimMaterial} in the registry {@code minecraft:trim_material}.
|
||||
* Creates a key for {@link TrimMaterial} in the registry {@code minecraft:trim_material}.
|
||||
*
|
||||
* @param key the value's key in the registry
|
||||
* @return a new typed key
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
public static TypedKey<TrimMaterial> create(final Key key) {
|
||||
return TypedKey.create(RegistryKey.TRIM_MATERIAL, key);
|
||||
}
|
||||
+5
-2
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.inventory.meta.trim.TrimPattern;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class TrimPatternKeys {
|
||||
/**
|
||||
* {@code minecraft:bolt}
|
||||
@@ -155,11 +157,12 @@ public final class TrimPatternKeys {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a typed key for {@link TrimPattern} in the registry {@code minecraft:trim_pattern}.
|
||||
* Creates a key for {@link TrimPattern} in the registry {@code minecraft:trim_pattern}.
|
||||
*
|
||||
* @param key the value's key in the registry
|
||||
* @return a new typed key
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
public static TypedKey<TrimPattern> create(final Key key) {
|
||||
return TypedKey.create(RegistryKey.TRIM_PATTERN, key);
|
||||
}
|
||||
+3
-1
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class VillagerProfessionKeys {
|
||||
/**
|
||||
* {@code minecraft:armorer}
|
||||
+3
-1
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class VillagerTypeKeys {
|
||||
/**
|
||||
* {@code minecraft:desert}
|
||||
+5
-2
@@ -7,6 +7,7 @@ import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -22,8 +23,9 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class WolfVariantKeys {
|
||||
/**
|
||||
* {@code minecraft:ashen}
|
||||
@@ -92,11 +94,12 @@ public final class WolfVariantKeys {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a typed key for {@link Wolf.Variant} in the registry {@code minecraft:wolf_variant}.
|
||||
* Creates a key for {@link Wolf.Variant} in the registry {@code minecraft:wolf_variant}.
|
||||
*
|
||||
* @param key the value's key in the registry
|
||||
* @return a new typed key
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
public static TypedKey<Wolf.Variant> create(final Key key) {
|
||||
return TypedKey.create(RegistryKey.WOLF_VARIANT, key);
|
||||
}
|
||||
+2
-2
@@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Vanilla tag keys for {@link RegistryKey#BANNER_PATTERN}.
|
||||
* Vanilla keys for {@link RegistryKey#BANNER_PATTERN}.
|
||||
*
|
||||
* @apiNote The fields provided here are a direct representation of
|
||||
* what is available from the vanilla game source. They may be
|
||||
@@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class BannerPatternTagKeys {
|
||||
/**
|
||||
+2
-2
@@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Vanilla tag keys for {@link RegistryKey#BIOME}.
|
||||
* Vanilla keys for {@link RegistryKey#BIOME}.
|
||||
*
|
||||
* @apiNote The fields provided here are a direct representation of
|
||||
* what is available from the vanilla game source. They may be
|
||||
@@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class BiomeTagKeys {
|
||||
/**
|
||||
+2
-2
@@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Vanilla tag keys for {@link RegistryKey#BLOCK}.
|
||||
* Vanilla keys for {@link RegistryKey#BLOCK}.
|
||||
*
|
||||
* @apiNote The fields provided here are a direct representation of
|
||||
* what is available from the vanilla game source. They may be
|
||||
@@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class BlockTypeTagKeys {
|
||||
/**
|
||||
+2
-2
@@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Vanilla tag keys for {@link RegistryKey#CAT_VARIANT}.
|
||||
* Vanilla keys for {@link RegistryKey#CAT_VARIANT}.
|
||||
*
|
||||
* @apiNote The fields provided here are a direct representation of
|
||||
* what is available from the vanilla game source. They may be
|
||||
@@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class CatVariantTagKeys {
|
||||
/**
|
||||
+2
-2
@@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Vanilla tag keys for {@link RegistryKey#DAMAGE_TYPE}.
|
||||
* Vanilla keys for {@link RegistryKey#DAMAGE_TYPE}.
|
||||
*
|
||||
* @apiNote The fields provided here are a direct representation of
|
||||
* what is available from the vanilla game source. They may be
|
||||
@@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class DamageTypeTagKeys {
|
||||
/**
|
||||
+2
-2
@@ -12,7 +12,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Vanilla tag keys for {@link RegistryKey#ENCHANTMENT}.
|
||||
* Vanilla keys for {@link RegistryKey#ENCHANTMENT}.
|
||||
*
|
||||
* @apiNote The fields provided here are a direct representation of
|
||||
* what is available from the vanilla game source. They may be
|
||||
@@ -24,8 +24,8 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class EnchantmentTagKeys {
|
||||
/**
|
||||
+2
-2
@@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Vanilla tag keys for {@link RegistryKey#FLUID}.
|
||||
* Vanilla keys for {@link RegistryKey#FLUID}.
|
||||
*
|
||||
* @apiNote The fields provided here are a direct representation of
|
||||
* what is available from the vanilla game source. They may be
|
||||
@@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class FluidTagKeys {
|
||||
/**
|
||||
+2
-2
@@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Vanilla tag keys for {@link RegistryKey#GAME_EVENT}.
|
||||
* Vanilla keys for {@link RegistryKey#GAME_EVENT}.
|
||||
*
|
||||
* @apiNote The fields provided here are a direct representation of
|
||||
* what is available from the vanilla game source. They may be
|
||||
@@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class GameEventTagKeys {
|
||||
/**
|
||||
+2
-2
@@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Vanilla tag keys for {@link RegistryKey#INSTRUMENT}.
|
||||
* Vanilla keys for {@link RegistryKey#INSTRUMENT}.
|
||||
*
|
||||
* @apiNote The fields provided here are a direct representation of
|
||||
* what is available from the vanilla game source. They may be
|
||||
@@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class InstrumentTagKeys {
|
||||
/**
|
||||
+2
-2
@@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Vanilla tag keys for {@link RegistryKey#ITEM}.
|
||||
* Vanilla keys for {@link RegistryKey#ITEM}.
|
||||
*
|
||||
* @apiNote The fields provided here are a direct representation of
|
||||
* what is available from the vanilla game source. They may be
|
||||
@@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class ItemTypeTagKeys {
|
||||
/**
|
||||
+2
-2
@@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Vanilla tag keys for {@link RegistryKey#PAINTING_VARIANT}.
|
||||
* Vanilla keys for {@link RegistryKey#PAINTING_VARIANT}.
|
||||
*
|
||||
* @apiNote The fields provided here are a direct representation of
|
||||
* what is available from the vanilla game source. They may be
|
||||
@@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class PaintingVariantTagKeys {
|
||||
/**
|
||||
+2
-2
@@ -12,7 +12,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Vanilla tag keys for {@link RegistryKey#STRUCTURE}.
|
||||
* Vanilla keys for {@link RegistryKey#STRUCTURE}.
|
||||
*
|
||||
* @apiNote The fields provided here are a direct representation of
|
||||
* what is available from the vanilla game source. They may be
|
||||
@@ -24,8 +24,8 @@ import org.jspecify.annotations.NullMarked;
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@NullMarked
|
||||
@ApiStatus.Experimental
|
||||
public final class StructureTagKeys {
|
||||
/**
|
||||
@@ -0,0 +1,92 @@
|
||||
package io.papermc.generator;
|
||||
|
||||
import io.papermc.generator.types.GeneratedKeyType;
|
||||
import io.papermc.generator.types.GeneratedTagKeyType;
|
||||
import io.papermc.generator.types.SourceGenerator;
|
||||
import io.papermc.generator.types.goal.MobGoalGenerator;
|
||||
import io.papermc.paper.registry.RegistryKey;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import org.bukkit.Art;
|
||||
import org.bukkit.Fluid;
|
||||
import org.bukkit.GameEvent;
|
||||
import org.bukkit.JukeboxSong;
|
||||
import org.bukkit.MusicInstrument;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.BlockType;
|
||||
import org.bukkit.block.banner.PatternType;
|
||||
import org.bukkit.damage.DamageType;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Cat;
|
||||
import org.bukkit.entity.Frog;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.generator.structure.Structure;
|
||||
import org.bukkit.generator.structure.StructureType;
|
||||
import org.bukkit.inventory.ItemType;
|
||||
import org.bukkit.inventory.MenuType;
|
||||
import org.bukkit.inventory.meta.trim.TrimMaterial;
|
||||
import org.bukkit.inventory.meta.trim.TrimPattern;
|
||||
import org.bukkit.map.MapCursor;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public interface Generators {
|
||||
|
||||
SourceGenerator[] API = {
|
||||
// built-ins
|
||||
simpleKey("GameEventKeys", GameEvent.class, Registries.GAME_EVENT, RegistryKey.GAME_EVENT, true),
|
||||
simpleKey("StructureTypeKeys", StructureType.class, Registries.STRUCTURE_TYPE, RegistryKey.STRUCTURE_TYPE, false),
|
||||
simpleKey("MobEffectKeys", PotionEffectType.class, Registries.MOB_EFFECT, RegistryKey.MOB_EFFECT, false),
|
||||
simpleKey("BlockTypeKeys", BlockType.class, Registries.BLOCK, RegistryKey.BLOCK, false),
|
||||
simpleKey("ItemTypeKeys", ItemType.class, Registries.ITEM, RegistryKey.ITEM, false),
|
||||
simpleKey("CatVariantKeys", Cat.Type.class, Registries.CAT_VARIANT, RegistryKey.CAT_VARIANT, false),
|
||||
simpleKey("FrogVariantKeys", Frog.Variant.class, Registries.FROG_VARIANT, RegistryKey.FROG_VARIANT, false),
|
||||
simpleKey("VillagerProfessionKeys", Villager.Profession.class, Registries.VILLAGER_PROFESSION, RegistryKey.VILLAGER_PROFESSION, false),
|
||||
simpleKey("VillagerTypeKeys", Villager.Type.class, Registries.VILLAGER_TYPE, RegistryKey.VILLAGER_TYPE, false),
|
||||
simpleKey("MapDecorationTypeKeys", MapCursor.Type.class, Registries.MAP_DECORATION_TYPE, RegistryKey.MAP_DECORATION_TYPE, false),
|
||||
simpleKey("MenuTypeKeys", MenuType.class, Registries.MENU, RegistryKey.MENU, false),
|
||||
simpleKey("AttributeKeys", Attribute.class, Registries.ATTRIBUTE, RegistryKey.ATTRIBUTE, false),
|
||||
simpleKey("FluidKeys", Fluid.class, Registries.FLUID, RegistryKey.FLUID, false),
|
||||
simpleKey("SoundEventKeys", Sound.class, Registries.SOUND_EVENT, RegistryKey.SOUND_EVENT, false),
|
||||
|
||||
// data-driven
|
||||
simpleKey("BiomeKeys", Biome.class, Registries.BIOME, RegistryKey.BIOME, true),
|
||||
simpleKey("StructureKeys", Structure.class, Registries.STRUCTURE, RegistryKey.STRUCTURE, true),
|
||||
simpleKey("TrimMaterialKeys", TrimMaterial.class, Registries.TRIM_MATERIAL, RegistryKey.TRIM_MATERIAL, true),
|
||||
simpleKey("TrimPatternKeys", TrimPattern.class, Registries.TRIM_PATTERN, RegistryKey.TRIM_PATTERN, true),
|
||||
simpleKey("DamageTypeKeys", DamageType.class, Registries.DAMAGE_TYPE, RegistryKey.DAMAGE_TYPE, true),
|
||||
simpleKey("WolfVariantKeys", Wolf.Variant.class, Registries.WOLF_VARIANT, RegistryKey.WOLF_VARIANT, true),
|
||||
simpleKey("EnchantmentKeys", Enchantment.class, Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT, true),
|
||||
simpleKey("JukeboxSongKeys", JukeboxSong.class, Registries.JUKEBOX_SONG, RegistryKey.JUKEBOX_SONG, true),
|
||||
simpleKey("BannerPatternKeys", PatternType.class, Registries.BANNER_PATTERN, RegistryKey.BANNER_PATTERN, true),
|
||||
simpleKey("PaintingVariantKeys", Art.class, Registries.PAINTING_VARIANT, RegistryKey.PAINTING_VARIANT, true),
|
||||
simpleKey("InstrumentKeys", MusicInstrument.class, Registries.INSTRUMENT, RegistryKey.INSTRUMENT, true),
|
||||
|
||||
// tags
|
||||
simpleTagKey("GameEventTagKeys", GameEvent.class, Registries.GAME_EVENT, RegistryKey.GAME_EVENT),
|
||||
simpleTagKey("BlockTypeTagKeys", BlockType.class, Registries.BLOCK, RegistryKey.BLOCK),
|
||||
simpleTagKey("ItemTypeTagKeys", ItemType.class, Registries.ITEM, RegistryKey.ITEM),
|
||||
simpleTagKey("CatVariantTagKeys", Cat.Type.class, Registries.CAT_VARIANT, RegistryKey.CAT_VARIANT),
|
||||
simpleTagKey("FluidTagKeys", Fluid.class, Registries.FLUID, RegistryKey.FLUID),
|
||||
|
||||
simpleTagKey("BiomeTagKeys", Biome.class, Registries.BIOME, RegistryKey.BIOME),
|
||||
simpleTagKey("StructureTagKeys", Structure.class, Registries.STRUCTURE, RegistryKey.STRUCTURE),
|
||||
simpleTagKey("DamageTypeTagKeys", DamageType.class, Registries.DAMAGE_TYPE, RegistryKey.DAMAGE_TYPE),
|
||||
simpleTagKey("EnchantmentTagKeys", Enchantment.class, Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT),
|
||||
simpleTagKey("BannerPatternTagKeys", PatternType.class, Registries.BANNER_PATTERN, RegistryKey.BANNER_PATTERN),
|
||||
simpleTagKey("PaintingVariantTagKeys", Art.class, Registries.PAINTING_VARIANT, RegistryKey.PAINTING_VARIANT),
|
||||
simpleTagKey("InstrumentTagKeys", MusicInstrument.class, Registries.INSTRUMENT, RegistryKey.INSTRUMENT),
|
||||
new MobGoalGenerator("VanillaGoal", "com.destroystokyo.paper.entity.ai")
|
||||
};
|
||||
|
||||
private static <T, A> SourceGenerator simpleKey(final String className, final Class<A> apiType, final ResourceKey<? extends Registry<T>> registryKey, final RegistryKey<A> apiRegistryKey, final boolean publicCreateKeyMethod) {
|
||||
return new GeneratedKeyType<>(className, apiType, "io.papermc.paper.registry.keys", registryKey, apiRegistryKey, publicCreateKeyMethod);
|
||||
}
|
||||
|
||||
private static <T, A> SourceGenerator simpleTagKey(final String className, final Class<A> apiType, final ResourceKey<? extends Registry<T>> registryKey, final RegistryKey<A> apiRegistryKey) {
|
||||
return new GeneratedTagKeyType<>(className, apiType, "io.papermc.paper.registry.keys.tags", registryKey, apiRegistryKey, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package io.papermc.generator;
|
||||
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import io.papermc.generator.types.SourceGenerator;
|
||||
import io.papermc.generator.utils.TagCollector;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.LayeredRegistryAccess;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.resources.RegistryDataLoader;
|
||||
import net.minecraft.server.Bootstrap;
|
||||
import net.minecraft.server.RegistryLayer;
|
||||
import net.minecraft.server.ReloadableServerResources;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraft.server.packs.repository.Pack;
|
||||
import net.minecraft.server.packs.repository.PackRepository;
|
||||
import net.minecraft.server.packs.repository.ServerPacksSource;
|
||||
import net.minecraft.server.packs.resources.MultiPackResourceManager;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.tags.TagLoader;
|
||||
import net.minecraft.world.flag.FeatureFlags;
|
||||
import org.apache.commons.io.file.PathUtils;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
public final class Main {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
public static final RegistryAccess.Frozen REGISTRY_ACCESS;
|
||||
public static final Map<TagKey<?>, String> EXPERIMENTAL_TAGS;
|
||||
|
||||
static {
|
||||
SharedConstants.tryDetectVersion();
|
||||
Bootstrap.bootStrap();
|
||||
Bootstrap.validate();
|
||||
|
||||
final PackRepository resourceRepository = ServerPacksSource.createVanillaTrustedRepository();
|
||||
resourceRepository.reload();
|
||||
final MultiPackResourceManager resourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, resourceRepository.getAvailablePacks().stream().map(Pack::open).toList());
|
||||
LayeredRegistryAccess<RegistryLayer> layers = RegistryLayer.createRegistryAccess();
|
||||
final List<Registry.PendingTags<?>> pendingTags = TagLoader.loadTagsForExistingRegistries(resourceManager, layers.getLayer(RegistryLayer.STATIC));
|
||||
final List<HolderLookup.RegistryLookup<?>> worldGenLayer = TagLoader.buildUpdatedLookups(layers.getAccessForLoading(RegistryLayer.WORLDGEN), pendingTags);
|
||||
final RegistryAccess.Frozen frozenWorldgenRegistries = RegistryDataLoader.load(resourceManager, worldGenLayer, RegistryDataLoader.WORLDGEN_REGISTRIES);
|
||||
layers = layers.replaceFrom(RegistryLayer.WORLDGEN, frozenWorldgenRegistries);
|
||||
REGISTRY_ACCESS = layers.compositeAccess().freeze();
|
||||
final ReloadableServerResources reloadableServerResources = ReloadableServerResources.loadResources(
|
||||
resourceManager,
|
||||
layers,
|
||||
pendingTags,
|
||||
FeatureFlags.VANILLA_SET,
|
||||
Commands.CommandSelection.DEDICATED,
|
||||
0,
|
||||
MoreExecutors.directExecutor(),
|
||||
MoreExecutors.directExecutor()
|
||||
).join();
|
||||
reloadableServerResources.updateStaticRegistryTags();
|
||||
EXPERIMENTAL_TAGS = TagCollector.grabExperimental(resourceManager);
|
||||
}
|
||||
|
||||
private Main() {
|
||||
}
|
||||
|
||||
public static void main(final String[] args) {
|
||||
LOGGER.info("Running API generators...");
|
||||
generate(Paths.get(args[0]), Generators.API);
|
||||
// LOGGER.info("Running Server generators...");
|
||||
// generate(Paths.get(args[1]), Generators.SERVER);
|
||||
}
|
||||
|
||||
private static void generate(Path output, SourceGenerator[] generators) {
|
||||
try {
|
||||
if (Files.exists(output)) {
|
||||
PathUtils.deleteDirectory(output);
|
||||
}
|
||||
Files.createDirectories(output);
|
||||
|
||||
for (final SourceGenerator generator : generators) {
|
||||
generator.writeToFile(output);
|
||||
}
|
||||
|
||||
LOGGER.info("Files written to {}", output.toAbsolutePath());
|
||||
} catch (final Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
package io.papermc.generator.types;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.squareup.javapoet.FieldSpec;
|
||||
import com.squareup.javapoet.JavaFile;
|
||||
import com.squareup.javapoet.MethodSpec;
|
||||
import com.squareup.javapoet.ParameterSpec;
|
||||
import com.squareup.javapoet.ParameterizedTypeName;
|
||||
import com.squareup.javapoet.TypeName;
|
||||
import com.squareup.javapoet.TypeSpec;
|
||||
import io.papermc.generator.Main;
|
||||
import io.papermc.generator.utils.Annotations;
|
||||
import io.papermc.generator.utils.CollectingContext;
|
||||
import io.papermc.generator.utils.Formatting;
|
||||
import io.papermc.generator.utils.Javadocs;
|
||||
import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistrySetBuilder;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.registries.VanillaRegistries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.flag.FeatureElement;
|
||||
import net.minecraft.world.flag.FeatureFlags;
|
||||
import org.bukkit.MinecraftExperimental;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
import static com.squareup.javapoet.TypeSpec.classBuilder;
|
||||
import static io.papermc.generator.utils.Annotations.EXPERIMENTAL_API_ANNOTATION;
|
||||
import static io.papermc.generator.utils.Annotations.experimentalAnnotations;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static javax.lang.model.element.Modifier.FINAL;
|
||||
import static javax.lang.model.element.Modifier.PRIVATE;
|
||||
import static javax.lang.model.element.Modifier.PUBLIC;
|
||||
import static javax.lang.model.element.Modifier.STATIC;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public class GeneratedKeyType<T, A> extends SimpleGenerator {
|
||||
|
||||
private static final Map<ResourceKey<? extends Registry<?>>, RegistrySetBuilder.RegistryBootstrap<?>> VANILLA_REGISTRY_ENTRIES = VanillaRegistries.BUILDER.entries.stream()
|
||||
.collect(Collectors.toMap(RegistrySetBuilder.RegistryStub::key, RegistrySetBuilder.RegistryStub::bootstrap));
|
||||
|
||||
private static final Map<ResourceKey<? extends Registry<?>>, RegistrySetBuilder.RegistryBootstrap<?>> EXPERIMENTAL_REGISTRY_ENTRIES = Map.of(); // Update for Experimental API
|
||||
private static final Map<RegistryKey<?>, String> REGISTRY_KEY_FIELD_NAMES;
|
||||
static {
|
||||
final Map<RegistryKey<?>, String> map = new HashMap<>();
|
||||
try {
|
||||
for (final Field field : RegistryKey.class.getFields()) {
|
||||
if (!Modifier.isStatic(field.getModifiers()) || !Modifier.isFinal(field.getModifiers()) || field.getType() != RegistryKey.class) {
|
||||
continue;
|
||||
}
|
||||
map.put((RegistryKey<?>) field.get(null), field.getName());
|
||||
}
|
||||
REGISTRY_KEY_FIELD_NAMES = Map.copyOf(map);
|
||||
} catch (final ReflectiveOperationException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String CREATE_JAVADOC = """
|
||||
Creates a key for {@link $T} in the registry {@code $L}.
|
||||
|
||||
@param key the value's key in the registry
|
||||
@return a new typed key
|
||||
""";
|
||||
|
||||
private final Class<A> apiType;
|
||||
private final ResourceKey<? extends Registry<T>> registryKey;
|
||||
private final RegistryKey<A> apiRegistryKey;
|
||||
private final boolean publicCreateKeyMethod;
|
||||
|
||||
public GeneratedKeyType(final String keysClassName, final Class<A> apiType, final String pkg, final ResourceKey<? extends Registry<T>> registryKey, final RegistryKey<A> apiRegistryKey, final boolean publicCreateKeyMethod) {
|
||||
super(keysClassName, pkg);
|
||||
this.apiType = apiType;
|
||||
this.registryKey = registryKey;
|
||||
this.apiRegistryKey = apiRegistryKey;
|
||||
this.publicCreateKeyMethod = publicCreateKeyMethod;
|
||||
}
|
||||
|
||||
private MethodSpec.Builder createMethod(final TypeName returnType) {
|
||||
final TypeName keyType = TypeName.get(Key.class);
|
||||
|
||||
final ParameterSpec keyParam = ParameterSpec.builder(keyType, "key", FINAL).build();
|
||||
final MethodSpec.Builder create = MethodSpec.methodBuilder("create")
|
||||
.addModifiers(this.publicCreateKeyMethod ? PUBLIC : PRIVATE, STATIC)
|
||||
.addParameter(keyParam)
|
||||
.addCode("return $T.create($T.$L, $N);", TypedKey.class, RegistryKey.class, requireNonNull(REGISTRY_KEY_FIELD_NAMES.get(this.apiRegistryKey), "Missing field for " + this.apiRegistryKey), keyParam)
|
||||
.returns(returnType);
|
||||
if (this.publicCreateKeyMethod) {
|
||||
create.addAnnotation(EXPERIMENTAL_API_ANNOTATION); // TODO remove once not experimental
|
||||
create.addJavadoc(CREATE_JAVADOC, this.apiType, this.registryKey.location().toString());
|
||||
}
|
||||
return create;
|
||||
}
|
||||
|
||||
private TypeSpec.Builder keyHolderType() {
|
||||
return classBuilder(this.className)
|
||||
.addModifiers(PUBLIC, FINAL)
|
||||
.addJavadoc(Javadocs.getVersionDependentClassHeader("{@link $T#$L}"), RegistryKey.class, REGISTRY_KEY_FIELD_NAMES.get(this.apiRegistryKey))
|
||||
.addAnnotations(Annotations.CLASS_HEADER)
|
||||
.addMethod(MethodSpec.constructorBuilder()
|
||||
.addModifiers(PRIVATE)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private static final Map<String, String> JUKEBOX_SONG_NAMES = Map.of(
|
||||
"5", "FIVE",
|
||||
"11", "ELEVEN",
|
||||
"13", "THIRTEEN"
|
||||
);
|
||||
|
||||
@Override
|
||||
protected TypeSpec getTypeSpec() {
|
||||
final TypeName typedKey = ParameterizedTypeName.get(TypedKey.class, this.apiType);
|
||||
|
||||
final TypeSpec.Builder typeBuilder = this.keyHolderType();
|
||||
final MethodSpec.Builder createMethod = this.createMethod(typedKey);
|
||||
|
||||
final Registry<T> registry = Main.REGISTRY_ACCESS.lookupOrThrow(this.registryKey);
|
||||
final Set<ResourceKey<T>> experimental = this.collectExperimentalKeys(registry);
|
||||
|
||||
boolean allExperimental = true;
|
||||
for (final Holder.Reference<T> reference : registry.listElements().sorted(Formatting.alphabeticKeyOrder(reference -> reference.key().location().getPath())).toList()) {
|
||||
final ResourceKey<T> key = reference.key();
|
||||
final String keyPath = key.location().getPath();
|
||||
String fieldName = Formatting.formatKeyAsField(keyPath);
|
||||
if (!SourceVersion.isIdentifier(fieldName) && this.registryKey.equals(Registries.JUKEBOX_SONG) && JUKEBOX_SONG_NAMES.containsKey(fieldName)) {
|
||||
fieldName = JUKEBOX_SONG_NAMES.get(fieldName);
|
||||
}
|
||||
|
||||
final FieldSpec.Builder fieldBuilder = FieldSpec.builder(typedKey, fieldName, PUBLIC, STATIC, FINAL)
|
||||
.initializer("$N(key($S))", createMethod.build(), keyPath)
|
||||
.addJavadoc(Javadocs.getVersionDependentField("{@code $L}"), key.location().toString());
|
||||
if (experimental.contains(key)) {
|
||||
fieldBuilder.addAnnotations(experimentalAnnotations(null)); // Update for Experimental API
|
||||
} else {
|
||||
allExperimental = false;
|
||||
}
|
||||
typeBuilder.addField(fieldBuilder.build());
|
||||
}
|
||||
if (allExperimental) {
|
||||
typeBuilder.addAnnotations(experimentalAnnotations(null)); // Update for Experimental API
|
||||
createMethod.addAnnotations(experimentalAnnotations(null)); // Update for Experimental API
|
||||
} else {
|
||||
typeBuilder.addAnnotation(EXPERIMENTAL_API_ANNOTATION); // TODO experimental API
|
||||
}
|
||||
return typeBuilder.addMethod(createMethod.build()).build();
|
||||
}
|
||||
|
||||
// todo at some point this should be per feature data pack not all merged
|
||||
private Set<ResourceKey<T>> collectExperimentalKeys(final Registry<T> registry) {
|
||||
if (FeatureElement.FILTERED_REGISTRIES.contains(registry.key())) {
|
||||
return this.collectExperimentalKeysBuiltIn(registry);
|
||||
} else {
|
||||
return this.collectExperimentalKeysDataDriven(registry);
|
||||
}
|
||||
}
|
||||
|
||||
private Set<ResourceKey<T>> collectExperimentalKeysBuiltIn(final Registry<T> registry) {
|
||||
final HolderLookup.RegistryLookup<T> filteredLookup = registry.filterElements(v -> {
|
||||
return v instanceof final FeatureElement featureElement && FeatureFlags.isExperimental(featureElement.requiredFeatures()); // Update for Experimental API
|
||||
});
|
||||
return filteredLookup.listElementIds().collect(Collectors.toUnmodifiableSet());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Set<ResourceKey<T>> collectExperimentalKeysDataDriven(final Registry<T> registry) {
|
||||
final RegistrySetBuilder.@Nullable RegistryBootstrap<T> experimentalBootstrap = (RegistrySetBuilder.RegistryBootstrap<T>) EXPERIMENTAL_REGISTRY_ENTRIES.get(this.registryKey);
|
||||
if (experimentalBootstrap == null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
final Set<ResourceKey<T>> experimental = Collections.newSetFromMap(new IdentityHashMap<>());
|
||||
final CollectingContext<T> experimentalCollector = new CollectingContext<>(experimental, registry);
|
||||
experimentalBootstrap.run(experimentalCollector);
|
||||
|
||||
final RegistrySetBuilder.@Nullable RegistryBootstrap<T> vanillaBootstrap = (RegistrySetBuilder.RegistryBootstrap<T>) VANILLA_REGISTRY_ENTRIES.get(this.registryKey);
|
||||
if (vanillaBootstrap != null) {
|
||||
final Set<ResourceKey<T>> vanilla = Collections.newSetFromMap(new IdentityHashMap<>());
|
||||
final CollectingContext<T> vanillaCollector = new CollectingContext<>(vanilla, registry);
|
||||
vanillaBootstrap.run(vanillaCollector);
|
||||
return Sets.difference(experimental, vanilla);
|
||||
}
|
||||
return experimental;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JavaFile.Builder file(final JavaFile.Builder builder) {
|
||||
return builder
|
||||
.addStaticImport(Key.class, "key");
|
||||
}
|
||||
}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
package io.papermc.generator.types;
|
||||
|
||||
import com.squareup.javapoet.FieldSpec;
|
||||
import com.squareup.javapoet.JavaFile;
|
||||
import com.squareup.javapoet.MethodSpec;
|
||||
import com.squareup.javapoet.ParameterSpec;
|
||||
import com.squareup.javapoet.ParameterizedTypeName;
|
||||
import com.squareup.javapoet.TypeName;
|
||||
import com.squareup.javapoet.TypeSpec;
|
||||
import io.papermc.generator.Main;
|
||||
import io.papermc.generator.utils.Annotations;
|
||||
import io.papermc.generator.utils.Formatting;
|
||||
import io.papermc.generator.utils.Javadocs;
|
||||
import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.tag.TagKey;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import org.bukkit.MinecraftExperimental;
|
||||
|
||||
import static com.squareup.javapoet.TypeSpec.classBuilder;
|
||||
import static io.papermc.generator.utils.Annotations.EXPERIMENTAL_API_ANNOTATION;
|
||||
import static io.papermc.generator.utils.Annotations.experimentalAnnotations;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static javax.lang.model.element.Modifier.FINAL;
|
||||
import static javax.lang.model.element.Modifier.PRIVATE;
|
||||
import static javax.lang.model.element.Modifier.PUBLIC;
|
||||
import static javax.lang.model.element.Modifier.STATIC;
|
||||
|
||||
public class GeneratedTagKeyType<T, A> extends SimpleGenerator {
|
||||
|
||||
private static final Map<RegistryKey<?>, String> REGISTRY_KEY_FIELD_NAMES;
|
||||
static {
|
||||
final Map<RegistryKey<?>, String> map = new HashMap<>();
|
||||
try {
|
||||
for (final Field field : RegistryKey.class.getFields()) {
|
||||
if (!Modifier.isStatic(field.getModifiers()) || !Modifier.isFinal(field.getModifiers()) || field.getType() != RegistryKey.class) {
|
||||
continue;
|
||||
}
|
||||
map.put((RegistryKey<?>) field.get(null), field.getName());
|
||||
}
|
||||
REGISTRY_KEY_FIELD_NAMES = Map.copyOf(map);
|
||||
} catch (final ReflectiveOperationException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String CREATE_JAVADOC = """
|
||||
Creates a tag key for {@link $T} in the registry {@code $L}.
|
||||
|
||||
@param key the tag key's key
|
||||
@return a new tag key
|
||||
""";
|
||||
|
||||
private final Class<A> apiType;
|
||||
private final ResourceKey<? extends Registry<T>> registryKey;
|
||||
private final RegistryKey<A> apiRegistryKey;
|
||||
private final boolean publicCreateKeyMethod;
|
||||
|
||||
public GeneratedTagKeyType(final String keysClassName, final Class<A> apiType, final String pkg, final ResourceKey<? extends Registry<T>> registryKey, final RegistryKey<A> apiRegistryKey, final boolean publicCreateKeyMethod) {
|
||||
super(keysClassName, pkg);
|
||||
this.apiType = apiType;
|
||||
this.registryKey = registryKey;
|
||||
this.apiRegistryKey = apiRegistryKey;
|
||||
this.publicCreateKeyMethod = publicCreateKeyMethod;
|
||||
}
|
||||
|
||||
private MethodSpec.Builder createMethod(final TypeName returnType) {
|
||||
final TypeName keyType = TypeName.get(Key.class);
|
||||
|
||||
final ParameterSpec keyParam = ParameterSpec.builder(keyType, "key", FINAL).build();
|
||||
final MethodSpec.Builder create = MethodSpec.methodBuilder("create")
|
||||
.addModifiers(this.publicCreateKeyMethod ? PUBLIC : PRIVATE, STATIC)
|
||||
.addParameter(keyParam)
|
||||
.addCode("return $T.create($T.$L, $N);", TagKey.class, RegistryKey.class, requireNonNull(REGISTRY_KEY_FIELD_NAMES.get(this.apiRegistryKey), "Missing field for " + this.apiRegistryKey), keyParam)
|
||||
.returns(returnType);
|
||||
if (this.publicCreateKeyMethod) {
|
||||
create.addAnnotation(EXPERIMENTAL_API_ANNOTATION); // TODO remove once not experimental
|
||||
create.addJavadoc(CREATE_JAVADOC, this.apiType, this.registryKey.location().toString());
|
||||
}
|
||||
return create;
|
||||
}
|
||||
|
||||
private TypeSpec.Builder keyHolderType() {
|
||||
return classBuilder(this.className)
|
||||
.addModifiers(PUBLIC, FINAL)
|
||||
.addJavadoc(Javadocs.getVersionDependentClassHeader("{@link $T#$L}"), RegistryKey.class, REGISTRY_KEY_FIELD_NAMES.get(this.apiRegistryKey))
|
||||
.addAnnotations(Annotations.CLASS_HEADER)
|
||||
.addMethod(MethodSpec.constructorBuilder()
|
||||
.addModifiers(PRIVATE)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TypeSpec getTypeSpec() {
|
||||
final TypeName tagKey = ParameterizedTypeName.get(TagKey.class, this.apiType);
|
||||
|
||||
final TypeSpec.Builder typeBuilder = this.keyHolderType();
|
||||
final MethodSpec.Builder createMethod = this.createMethod(tagKey);
|
||||
|
||||
final Registry<T> registry = Main.REGISTRY_ACCESS.lookupOrThrow(this.registryKey);
|
||||
|
||||
final AtomicBoolean allExperimental = new AtomicBoolean(true);
|
||||
registry.listTagIds().sorted(Formatting.alphabeticKeyOrder(nmsTagKey -> nmsTagKey.location().getPath())).forEach(nmsTagKey -> {
|
||||
final String fieldName = Formatting.formatKeyAsField(nmsTagKey.location().getPath());
|
||||
final FieldSpec.Builder fieldBuilder = FieldSpec.builder(tagKey, fieldName, PUBLIC, STATIC, FINAL)
|
||||
.initializer("$N(key($S))", createMethod.build(), nmsTagKey.location().getPath())
|
||||
.addJavadoc(Javadocs.getVersionDependentField("{@code $L}"), "#" + nmsTagKey.location());
|
||||
final String featureFlagName = Main.EXPERIMENTAL_TAGS.get(nmsTagKey);
|
||||
if (featureFlagName != null) {
|
||||
fieldBuilder.addAnnotations(experimentalAnnotations(MinecraftExperimental.Requires.valueOf(featureFlagName.toUpperCase(Locale.ENGLISH)))); // Update for Experimental API
|
||||
} else {
|
||||
allExperimental.set(false);
|
||||
}
|
||||
typeBuilder.addField(fieldBuilder.build());
|
||||
});
|
||||
if (allExperimental.get()) {
|
||||
typeBuilder.addAnnotations(experimentalAnnotations(null)); // Update for Experimental API
|
||||
createMethod.addAnnotations(experimentalAnnotations(null)); // Update for Experimental API
|
||||
} else {
|
||||
typeBuilder.addAnnotation(EXPERIMENTAL_API_ANNOTATION); // TODO experimental API
|
||||
}
|
||||
return typeBuilder.addMethod(createMethod.build()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JavaFile.Builder file(final JavaFile.Builder builder) {
|
||||
return builder
|
||||
.addStaticImport(Key.class, "key");
|
||||
}
|
||||
}
|
||||
+4
-8
@@ -2,16 +2,13 @@ package io.papermc.generator.types;
|
||||
|
||||
import com.squareup.javapoet.JavaFile;
|
||||
import com.squareup.javapoet.TypeSpec;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public abstract class SimpleGenerator implements SourceGenerator {
|
||||
|
||||
public static final String INDENT_UNIT = " ";
|
||||
|
||||
protected final String className;
|
||||
protected final String packageName;
|
||||
|
||||
@@ -22,15 +19,14 @@ public abstract class SimpleGenerator implements SourceGenerator {
|
||||
|
||||
protected abstract TypeSpec getTypeSpec();
|
||||
|
||||
protected JavaFile.Builder file(JavaFile.Builder builder) {
|
||||
return builder;
|
||||
}
|
||||
protected abstract JavaFile.Builder file(JavaFile.Builder builder);
|
||||
|
||||
@Override
|
||||
public void writeToFile(Path parent) throws IOException {
|
||||
|
||||
JavaFile.Builder builder = JavaFile.builder(this.packageName, this.getTypeSpec());
|
||||
this.file(builder)
|
||||
.indent(INDENT_UNIT)
|
||||
.indent(" ")
|
||||
.skipJavaLangImports(true);
|
||||
|
||||
builder.build().writeTo(parent, StandardCharsets.UTF_8);
|
||||
-2
@@ -2,9 +2,7 @@ package io.papermc.generator.types;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public interface SourceGenerator {
|
||||
|
||||
void writeToFile(Path parent) throws IOException;
|
||||
+26
-17
@@ -3,6 +3,7 @@ package io.papermc.generator.types.goal;
|
||||
import com.destroystokyo.paper.entity.ai.GoalKey;
|
||||
import com.squareup.javapoet.ClassName;
|
||||
import com.squareup.javapoet.FieldSpec;
|
||||
import com.squareup.javapoet.JavaFile;
|
||||
import com.squareup.javapoet.MethodSpec;
|
||||
import com.squareup.javapoet.ParameterSpec;
|
||||
import com.squareup.javapoet.ParameterizedTypeName;
|
||||
@@ -15,29 +16,28 @@ import io.papermc.generator.types.SimpleGenerator;
|
||||
import io.papermc.generator.utils.Annotations;
|
||||
import io.papermc.generator.utils.Formatting;
|
||||
import io.papermc.generator.utils.Javadocs;
|
||||
import io.papermc.typewriter.util.ClassHelper;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.world.entity.ai.goal.Goal;
|
||||
import net.minecraft.world.entity.ai.goal.GoalSelector;
|
||||
import net.minecraft.world.entity.ai.goal.WrappedGoal;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Mob;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static javax.lang.model.element.Modifier.FINAL;
|
||||
import static javax.lang.model.element.Modifier.PRIVATE;
|
||||
import static javax.lang.model.element.Modifier.PUBLIC;
|
||||
import static javax.lang.model.element.Modifier.STATIC;
|
||||
|
||||
@NullMarked
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public class MobGoalGenerator extends SimpleGenerator {
|
||||
|
||||
private static final String CLASS_HEADER = Javadocs.getVersionDependentClassHeader("keys", "Mob Goals");
|
||||
private static final String CLASS_HEADER = Javadocs.getVersionDependentClassHeader("Mob Goals");
|
||||
|
||||
public MobGoalGenerator(String className, String packageName) {
|
||||
super(className, packageName);
|
||||
public MobGoalGenerator(final String keysClassName, final String pkg) {
|
||||
super(keysClassName, pkg);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,8 +51,9 @@ public class MobGoalGenerator extends SimpleGenerator {
|
||||
.addJavadoc(CLASS_HEADER);
|
||||
|
||||
TypeName mobType = ParameterizedTypeName.get(ClassName.get(Class.class), type);
|
||||
TypeName keyType = TypeName.get(String.class);
|
||||
|
||||
ParameterSpec keyParam = ParameterSpec.builder(String.class, "key", FINAL).build();
|
||||
ParameterSpec keyParam = ParameterSpec.builder(keyType, "key", FINAL).build();
|
||||
ParameterSpec typeParam = ParameterSpec.builder(mobType, "type", FINAL).build();
|
||||
MethodSpec.Builder createMethod = MethodSpec.methodBuilder("create")
|
||||
.addModifiers(PRIVATE, STATIC)
|
||||
@@ -67,25 +68,33 @@ public class MobGoalGenerator extends SimpleGenerator {
|
||||
classes = scanResult.getSubclasses(Goal.class.getName()).loadClasses(Goal.class);
|
||||
}
|
||||
|
||||
Stream<GoalKey<Mob>> vanillaGoals = classes.stream()
|
||||
List<GoalKey<Mob>> vanillaNames = classes.stream()
|
||||
.filter(clazz -> !java.lang.reflect.Modifier.isAbstract(clazz.getModifiers()))
|
||||
.filter(clazz -> !clazz.isAnonymousClass() || ClassHelper.getTopLevelClass(clazz) != GoalSelector.class)
|
||||
.filter(clazz -> !WrappedGoal.class.equals(clazz)) // TODO - properly fix
|
||||
.map(MobGoalNames::getKey)
|
||||
.map(goalClass -> MobGoalNames.getKey(goalClass.getName(), goalClass))
|
||||
.filter((key) -> !MobGoalNames.isIgnored(key.getNamespacedKey().getKey()))
|
||||
.sorted(Comparator.<GoalKey<?>, String>comparing(o -> o.getEntityClass().getSimpleName())
|
||||
.thenComparing(vanillaGoalKey -> vanillaGoalKey.getNamespacedKey().getKey())
|
||||
);
|
||||
)
|
||||
.toList();
|
||||
|
||||
vanillaGoals.forEach(goalKey -> {
|
||||
String keyPath = goalKey.getNamespacedKey().getKey();
|
||||
String fieldName = Formatting.formatKeyAsField(keyPath);
|
||||
|
||||
for (final GoalKey<?> goalKey : vanillaNames) {
|
||||
TypeName typedKey = ParameterizedTypeName.get(GoalKey.class, goalKey.getEntityClass());
|
||||
NamespacedKey key = goalKey.getNamespacedKey();
|
||||
|
||||
String keyPath = key.getKey();
|
||||
String fieldName = Formatting.formatKeyAsField(keyPath);
|
||||
FieldSpec.Builder fieldBuilder = FieldSpec.builder(typedKey, fieldName, PUBLIC, STATIC, FINAL)
|
||||
.initializer("$N($S, $T.class)", createMethod.build(), keyPath, goalKey.getEntityClass());
|
||||
typeBuilder.addField(fieldBuilder.build());
|
||||
});
|
||||
}
|
||||
|
||||
return typeBuilder.addMethod(createMethod.build()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JavaFile.Builder file(JavaFile.Builder builder) {
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
+208
-77
@@ -2,32 +2,140 @@ package io.papermc.generator.types.goal;
|
||||
|
||||
import com.destroystokyo.paper.entity.RangedEntity;
|
||||
import com.destroystokyo.paper.entity.ai.GoalKey;
|
||||
import com.google.common.base.CaseFormat;
|
||||
import io.papermc.generator.utils.Formatting;
|
||||
import io.papermc.paper.entity.SchoolableFish;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import net.minecraft.world.entity.FlyingMob;
|
||||
import net.minecraft.world.entity.PathfinderMob;
|
||||
import net.minecraft.world.entity.TamableAnimal;
|
||||
import net.minecraft.world.entity.ai.goal.Goal;
|
||||
import net.minecraft.world.entity.ambient.AmbientCreature;
|
||||
import net.minecraft.world.entity.animal.AbstractFish;
|
||||
import net.minecraft.world.entity.animal.AbstractGolem;
|
||||
import net.minecraft.world.entity.animal.AbstractSchoolingFish;
|
||||
import net.minecraft.world.entity.animal.Animal;
|
||||
import net.minecraft.world.entity.animal.Pufferfish;
|
||||
import net.minecraft.world.entity.animal.ShoulderRidingEntity;
|
||||
import net.minecraft.world.entity.animal.SnowGolem;
|
||||
import net.minecraft.world.entity.animal.WaterAnimal;
|
||||
import net.minecraft.world.entity.animal.horse.AbstractChestedHorse;
|
||||
import net.minecraft.world.entity.boss.wither.WitherBoss;
|
||||
import net.minecraft.world.entity.monster.AbstractIllager;
|
||||
import net.minecraft.world.entity.monster.EnderMan;
|
||||
import net.minecraft.world.entity.monster.PatrollingMonster;
|
||||
import net.minecraft.world.entity.monster.RangedAttackMob;
|
||||
import net.minecraft.world.entity.monster.SpellcasterIllager;
|
||||
import net.minecraft.world.entity.monster.ZombifiedPiglin;
|
||||
import net.minecraft.world.entity.monster.piglin.AbstractPiglin;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.AbstractHorse;
|
||||
import org.bukkit.entity.AbstractSkeleton;
|
||||
import org.bukkit.entity.AbstractVillager;
|
||||
import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.Ambient;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Bat;
|
||||
import org.bukkit.entity.Bee;
|
||||
import org.bukkit.entity.Blaze;
|
||||
import org.bukkit.entity.Cat;
|
||||
import org.bukkit.entity.CaveSpider;
|
||||
import org.bukkit.entity.ChestedHorse;
|
||||
import org.bukkit.entity.Chicken;
|
||||
import org.bukkit.entity.Cod;
|
||||
import org.bukkit.entity.Cow;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Dolphin;
|
||||
import org.bukkit.entity.Donkey;
|
||||
import org.bukkit.entity.Drowned;
|
||||
import org.bukkit.entity.ElderGuardian;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.Enderman;
|
||||
import org.bukkit.entity.Endermite;
|
||||
import org.bukkit.entity.Evoker;
|
||||
import org.bukkit.entity.Fish;
|
||||
import org.bukkit.entity.Flying;
|
||||
import org.bukkit.entity.Fox;
|
||||
import org.bukkit.entity.Ghast;
|
||||
import org.bukkit.entity.Giant;
|
||||
import org.bukkit.entity.Golem;
|
||||
import org.bukkit.entity.Guardian;
|
||||
import org.bukkit.entity.Hoglin;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Husk;
|
||||
import org.bukkit.entity.Illager;
|
||||
import org.bukkit.entity.Illusioner;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
import org.bukkit.entity.Llama;
|
||||
import org.bukkit.entity.MagmaCube;
|
||||
import org.bukkit.entity.Mob;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Mule;
|
||||
import org.bukkit.entity.MushroomCow;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
import org.bukkit.entity.Panda;
|
||||
import org.bukkit.entity.Parrot;
|
||||
import org.bukkit.entity.Phantom;
|
||||
import org.bukkit.entity.Pig;
|
||||
import org.bukkit.entity.PigZombie;
|
||||
import org.bukkit.entity.Piglin;
|
||||
import org.bukkit.entity.PiglinAbstract;
|
||||
import org.bukkit.entity.PiglinBrute;
|
||||
import org.bukkit.entity.Pillager;
|
||||
import org.bukkit.entity.PolarBear;
|
||||
import org.bukkit.entity.PufferFish;
|
||||
import org.bukkit.entity.Rabbit;
|
||||
import org.bukkit.entity.Raider;
|
||||
import org.bukkit.entity.Ravager;
|
||||
import org.bukkit.entity.Salmon;
|
||||
import org.bukkit.entity.Sheep;
|
||||
import org.bukkit.entity.Shulker;
|
||||
import org.bukkit.entity.Silverfish;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.SkeletonHorse;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.entity.Snowman;
|
||||
import org.bukkit.entity.Spellcaster;
|
||||
import org.bukkit.entity.Spider;
|
||||
import org.bukkit.entity.Squid;
|
||||
import org.bukkit.entity.Stray;
|
||||
import org.bukkit.entity.Strider;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.TraderLlama;
|
||||
import org.bukkit.entity.TropicalFish;
|
||||
import org.bukkit.entity.Turtle;
|
||||
import org.bukkit.entity.Vex;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.entity.Vindicator;
|
||||
import org.bukkit.entity.WanderingTrader;
|
||||
import org.bukkit.entity.WaterMob;
|
||||
import org.bukkit.entity.Witch;
|
||||
import org.bukkit.entity.Wither;
|
||||
import org.bukkit.entity.WitherSkeleton;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.entity.Zoglin;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.entity.ZombieHorse;
|
||||
import org.bukkit.entity.ZombieVillager;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import net.minecraft.world.entity.ai.goal.Goal;
|
||||
import net.minecraft.world.entity.monster.RangedAttackMob;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.*;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import java.util.Set;
|
||||
|
||||
@NullMarked
|
||||
public final class MobGoalNames { // todo sync with MobGoalHelper ideally this should not be duplicated
|
||||
public class MobGoalNames {
|
||||
|
||||
private static final Map<Class<? extends Goal>, Class<? extends Mob>> entityClassCache = new HashMap<>();
|
||||
public static final Map<Class<? extends net.minecraft.world.entity.Mob>, Class<? extends Mob>> bukkitMap = new LinkedHashMap<>();
|
||||
public static final Map<Class<? extends net.minecraft.world.entity.Mob>, Class<? extends Mob>> bukkitMap = new HashMap<>();
|
||||
|
||||
|
||||
static {
|
||||
//<editor-fold defaultstate="collapsed" desc="bukkitMap Entities">
|
||||
bukkitMap.put(net.minecraft.world.entity.Mob.class, Mob.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.AgeableMob.class, Ageable.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.ambient.AmbientCreature.class, Ambient.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.Animal.class, Animals.class);
|
||||
bukkitMap.put(AmbientCreature.class, Ambient.class);
|
||||
bukkitMap.put(Animal.class, Animals.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.ambient.Bat.class, Bat.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.Bee.class, Bee.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Blaze.class, Blaze.class);
|
||||
@@ -36,51 +144,51 @@ public final class MobGoalNames { // todo sync with MobGoalHelper ideally this s
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.Chicken.class, Chicken.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.Cod.class, Cod.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.Cow.class, Cow.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.PathfinderMob.class, Creature.class);
|
||||
bukkitMap.put(PathfinderMob.class, Creature.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Creeper.class, Creeper.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.Dolphin.class, Dolphin.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Drowned.class, Drowned.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.boss.enderdragon.EnderDragon.class, EnderDragon.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.EnderMan.class, Enderman.class);
|
||||
bukkitMap.put(EnderMan.class, Enderman.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Endermite.class, Endermite.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Evoker.class, Evoker.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.AbstractFish.class, Fish.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.AbstractSchoolingFish.class, SchoolableFish.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.FlyingMob.class, Flying.class);
|
||||
bukkitMap.put(AbstractFish.class, Fish.class);
|
||||
bukkitMap.put(AbstractSchoolingFish.class, io.papermc.paper.entity.SchoolableFish.class);
|
||||
bukkitMap.put(FlyingMob.class, Flying.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.Fox.class, Fox.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Ghast.class, Ghast.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Giant.class, Giant.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.AbstractGolem.class, Golem.class);
|
||||
bukkitMap.put(AbstractGolem.class, Golem.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Guardian.class, Guardian.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.ElderGuardian.class, ElderGuardian.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.horse.Horse.class, Horse.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.horse.AbstractHorse.class, AbstractHorse.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.horse.AbstractChestedHorse.class, ChestedHorse.class);
|
||||
bukkitMap.put(AbstractChestedHorse.class, ChestedHorse.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.horse.Donkey.class, Donkey.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.horse.Mule.class, Mule.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.horse.SkeletonHorse.class, SkeletonHorse.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.horse.ZombieHorse.class, ZombieHorse.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.camel.Camel.class, org.bukkit.entity.Camel.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.AbstractIllager.class, Illager.class);
|
||||
bukkitMap.put(AbstractIllager.class, Illager.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Illusioner.class, Illusioner.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.SpellcasterIllager.class, Spellcaster.class);
|
||||
bukkitMap.put(SpellcasterIllager.class, Spellcaster.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.IronGolem.class, IronGolem.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.horse.Llama.class, Llama.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.horse.TraderLlama.class, TraderLlama.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.MagmaCube.class, MagmaCube.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Monster.class, Monster.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.PatrollingMonster.class, Raider.class); // close enough
|
||||
bukkitMap.put(PatrollingMonster.class, Raider.class); // close enough
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.MushroomCow.class, MushroomCow.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.Ocelot.class, Ocelot.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.Panda.class, Panda.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.Parrot.class, Parrot.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.ShoulderRidingEntity.class, Parrot.class); // close enough
|
||||
bukkitMap.put(ShoulderRidingEntity.class, Parrot.class); // close enough
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Phantom.class, Phantom.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.Pig.class, Pig.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.ZombifiedPiglin.class, PigZombie.class);
|
||||
bukkitMap.put(ZombifiedPiglin.class, PigZombie.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Pillager.class, Pillager.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.PolarBear.class, PolarBear.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.Pufferfish.class, PufferFish.class);
|
||||
bukkitMap.put(Pufferfish.class, PufferFish.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.Rabbit.class, Rabbit.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.raid.Raider.class, Raider.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Ravager.class, Ravager.class);
|
||||
@@ -93,10 +201,10 @@ public final class MobGoalNames { // todo sync with MobGoalHelper ideally this s
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Stray.class, Stray.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.WitherSkeleton.class, WitherSkeleton.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Slime.class, Slime.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.SnowGolem.class, Snowman.class);
|
||||
bukkitMap.put(SnowGolem.class, Snowman.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Spider.class, Spider.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.Squid.class, Squid.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.TamableAnimal.class, Tameable.class);
|
||||
bukkitMap.put(TamableAnimal.class, Tameable.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.TropicalFish.class, TropicalFish.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.Turtle.class, Turtle.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Vex.class, Vex.class);
|
||||
@@ -104,85 +212,108 @@ public final class MobGoalNames { // todo sync with MobGoalHelper ideally this s
|
||||
bukkitMap.put(net.minecraft.world.entity.npc.AbstractVillager.class, AbstractVillager.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.npc.WanderingTrader.class, WanderingTrader.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Vindicator.class, Vindicator.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.WaterAnimal.class, WaterMob.class);
|
||||
bukkitMap.put(WaterAnimal.class, WaterMob.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Witch.class, Witch.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.boss.wither.WitherBoss.class, Wither.class);
|
||||
bukkitMap.put(WitherBoss.class, Wither.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.Wolf.class, Wolf.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Zombie.class, Zombie.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Husk.class, Husk.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.ZombieVillager.class, ZombieVillager.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.hoglin.Hoglin.class, Hoglin.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.piglin.Piglin.class, Piglin.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.piglin.AbstractPiglin.class, PiglinAbstract.class);
|
||||
bukkitMap.put(AbstractPiglin.class, PiglinAbstract.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.piglin.PiglinBrute.class, PiglinBrute.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Strider.class, Strider.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Zoglin.class, Zoglin.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.GlowSquid.class, GlowSquid.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.axolotl.Axolotl.class, Axolotl.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.goat.Goat.class, Goat.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.frog.Frog.class, Frog.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.frog.Tadpole.class, Tadpole.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.warden.Warden.class, Warden.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.allay.Allay.class, Allay.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.sniffer.Sniffer.class, Sniffer.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.breeze.Breeze.class, Breeze.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.armadillo.Armadillo.class, Armadillo.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Bogged.class, Bogged.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.creaking.Creaking.class, Creaking.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.AgeableWaterCreature.class, Squid.class); // close enough
|
||||
bukkitMap.put(net.minecraft.world.entity.GlowSquid.class, org.bukkit.entity.GlowSquid.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.axolotl.Axolotl.class, org.bukkit.entity.Axolotl.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.goat.Goat.class, org.bukkit.entity.Goat.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.frog.Frog.class, org.bukkit.entity.Frog.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.frog.Tadpole.class, org.bukkit.entity.Tadpole.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.warden.Warden.class, org.bukkit.entity.Warden.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.allay.Allay.class, org.bukkit.entity.Allay.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.sniffer.Sniffer.class, org.bukkit.entity.Sniffer.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.breeze.Breeze.class, org.bukkit.entity.Breeze.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.armadillo.Armadillo.class, org.bukkit.entity.Armadillo.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.Bogged.class, org.bukkit.entity.Bogged.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.monster.creaking.Creaking.class, org.bukkit.entity.Creaking.class);
|
||||
bukkitMap.put(net.minecraft.world.entity.animal.AgeableWaterCreature.class, org.bukkit.entity.Squid.class); // close enough
|
||||
//</editor-fold>
|
||||
}
|
||||
|
||||
private static final Map<String, String> deobfuscationMap = new HashMap<>();
|
||||
private static final BiMap<String, String> deobfuscationMap = HashBiMap.create();
|
||||
static final Set<String> ignored = new HashSet<>();
|
||||
|
||||
static {
|
||||
// TODO these kinda should be checked on each release, in case obfuscation changes
|
||||
deobfuscationMap.put("abstract_skeleton_1", "abstract_skeleton_melee");
|
||||
|
||||
ignored.add("goal_selector_1");
|
||||
ignored.add("goal_selector_2");
|
||||
ignored.add("selector_1");
|
||||
ignored.add("selector_2");
|
||||
ignored.add("wrapped");
|
||||
}
|
||||
|
||||
private static String getPathName(String name) {
|
||||
String pathName = name.substring(name.lastIndexOf('.') + 1);
|
||||
boolean needDeobfMap = false;
|
||||
|
||||
public static String getUsableName(String name) {
|
||||
final String original = name;
|
||||
name = name.substring(name.lastIndexOf(".") + 1);
|
||||
boolean flag = false;
|
||||
// inner classes
|
||||
int firstInnerDelimiter = pathName.indexOf('$');
|
||||
if (firstInnerDelimiter != -1) {
|
||||
String innerClassName = pathName.substring(firstInnerDelimiter + 1);
|
||||
for (String nestedClass : innerClassName.split("\\$")) {
|
||||
if (NumberUtils.isDigits(nestedClass)) {
|
||||
needDeobfMap = true;
|
||||
break;
|
||||
}
|
||||
if (name.contains("$")) {
|
||||
String cut = name.substring(name.indexOf("$") + 1);
|
||||
if (cut.length() <= 2) {
|
||||
name = name.replace("Entity", "");
|
||||
name = name.replace("$", "_");
|
||||
flag = true;
|
||||
} else {
|
||||
// mapped, wooo
|
||||
name = cut;
|
||||
}
|
||||
if (!needDeobfMap) {
|
||||
pathName = innerClassName;
|
||||
}
|
||||
pathName = pathName.replace('$', '_');
|
||||
// mapped, wooo!
|
||||
}
|
||||
|
||||
pathName = Formatting.stripWordOfCamelCaseName(pathName, "TargetGoal", true); // replace last? reverse search?
|
||||
pathName = Formatting.stripWordOfCamelCaseName(pathName, "Goal", true);
|
||||
pathName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, pathName);
|
||||
name = name.replace("PathfinderGoal", "");
|
||||
name = name.replace("TargetGoal", "");
|
||||
name = name.replace("Goal", "");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (char c : name.toCharArray()) {
|
||||
if (c >= 'A' && c <= 'Z') {
|
||||
sb.append("_");
|
||||
sb.append(Character.toLowerCase(c));
|
||||
} else {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
name = sb.toString();
|
||||
name = name.replaceFirst("_", "");
|
||||
|
||||
if (needDeobfMap && !deobfuscationMap.containsKey(pathName)) {
|
||||
System.err.println("need to map " + name + " (" + pathName + ")");
|
||||
if (flag && !deobfuscationMap.containsKey(name.toLowerCase(Locale.ROOT)) && !ignored.contains(name)) {
|
||||
System.out.println("need to map " + original + " (" + name.toLowerCase(Locale.ROOT) + ")");
|
||||
}
|
||||
|
||||
// did we rename this key?
|
||||
return deobfuscationMap.getOrDefault(pathName, pathName);
|
||||
return deobfuscationMap.getOrDefault(name, name);
|
||||
}
|
||||
|
||||
public static <T extends Mob> GoalKey<T> getKey(Class<? extends Goal> goalClass) {
|
||||
String name = getPathName(goalClass.getName());
|
||||
public static boolean isIgnored(String name) {
|
||||
return ignored.contains(name);
|
||||
}
|
||||
|
||||
|
||||
public static <T extends Mob> GoalKey<T> getKey(String clazzName, Class<? extends Goal> goalClass) {
|
||||
String name = getUsableName(clazzName);
|
||||
if (MobGoalNames.isIgnored(name)) {
|
||||
//noinspection unchecked
|
||||
return (GoalKey<T>) GoalKey.of(Mob.class, NamespacedKey.minecraft(name));
|
||||
}
|
||||
return GoalKey.of(getEntity(goalClass), NamespacedKey.minecraft(name));
|
||||
}
|
||||
|
||||
private static <T extends Mob> Class<T> getEntity(Class<? extends Goal> goalClass) {
|
||||
public static <T extends Mob> Class<T> getEntity(Class<? extends Goal> goalClass) {
|
||||
//noinspection unchecked
|
||||
return (Class<T>) entityClassCache.computeIfAbsent(goalClass, key -> {
|
||||
for (Constructor<?> ctor : key.getDeclaredConstructors()) {
|
||||
for (Class<?> param : ctor.getParameterTypes()) {
|
||||
for (int i = 0; i < ctor.getParameterCount(); i++) {
|
||||
Class<?> param = ctor.getParameterTypes()[i];
|
||||
if (net.minecraft.world.entity.Mob.class.isAssignableFrom(param)) {
|
||||
//noinspection unchecked
|
||||
return toBukkitClass((Class<? extends net.minecraft.world.entity.Mob>) param);
|
||||
@@ -191,11 +322,11 @@ public final class MobGoalNames { // todo sync with MobGoalHelper ideally this s
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("Can't figure out applicable entity for mob goal " + goalClass); // maybe just return Mob?
|
||||
throw new RuntimeException("Can't figure out applicable entity for mob goal " + goalClass); // maybe just return EntityInsentient?
|
||||
});
|
||||
}
|
||||
|
||||
private static Class<? extends Mob> toBukkitClass(Class<? extends net.minecraft.world.entity.Mob> nmsClass) {
|
||||
public static Class<? extends Mob> toBukkitClass(Class<? extends net.minecraft.world.entity.Mob> nmsClass) {
|
||||
Class<? extends Mob> bukkitClass = bukkitMap.get(nmsClass);
|
||||
if (bukkitClass == null) {
|
||||
throw new RuntimeException("Can't figure out applicable bukkit entity for nms entity " + nmsClass); // maybe just return Mob?
|
||||
@@ -0,0 +1,65 @@
|
||||
package io.papermc.generator.utils;
|
||||
|
||||
import com.squareup.javapoet.AnnotationSpec;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.papermc.paper.generated.GeneratedFrom;
|
||||
import net.minecraft.SharedConstants;
|
||||
import org.bukkit.MinecraftExperimental;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
public final class Annotations {
|
||||
|
||||
public static List<AnnotationSpec> experimentalAnnotations(final MinecraftExperimental.@Nullable Requires requiredFeatureFlag) {
|
||||
final List<AnnotationSpec> annotationSpecs = new ArrayList<>();
|
||||
annotationSpecs.add(AnnotationSpec.builder(ApiStatus.Experimental.class).build());
|
||||
if (requiredFeatureFlag != null) {
|
||||
annotationSpecs.add(AnnotationSpec.builder(MinecraftExperimental.class)
|
||||
.addMember("value", "$T.$L", MinecraftExperimental.Requires.class, requiredFeatureFlag.name())
|
||||
.build());
|
||||
} else {
|
||||
annotationSpecs.add(AnnotationSpec.builder(MinecraftExperimental.class).build());
|
||||
}
|
||||
return annotationSpecs;
|
||||
}
|
||||
|
||||
public static AnnotationSpec deprecatedVersioned(final @Nullable String version, final boolean forRemoval) {
|
||||
final AnnotationSpec.Builder annotationSpec = AnnotationSpec.builder(Deprecated.class);
|
||||
if (forRemoval) {
|
||||
annotationSpec.addMember("forRemoval", "$L", true);
|
||||
}
|
||||
if (version != null) {
|
||||
annotationSpec.addMember("since", "$S", version);
|
||||
}
|
||||
|
||||
return annotationSpec.build();
|
||||
}
|
||||
|
||||
public static AnnotationSpec scheduledRemoval(final @Nullable String version) {
|
||||
return AnnotationSpec.builder(ApiStatus.ScheduledForRemoval.class)
|
||||
.addMember("inVersion", "$S", version)
|
||||
.build();
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static final AnnotationSpec EXPERIMENTAL_API_ANNOTATION = AnnotationSpec.builder(ApiStatus.Experimental.class).build();
|
||||
public static final AnnotationSpec NULL_MARKED = AnnotationSpec.builder(NullMarked.class).build();
|
||||
private static final AnnotationSpec SUPPRESS_WARNINGS = AnnotationSpec.builder(SuppressWarnings.class)
|
||||
.addMember("value", "$S", "unused")
|
||||
.addMember("value", "$S", "SpellCheckingInspection")
|
||||
.build();
|
||||
private static final AnnotationSpec GENERATED_FROM = AnnotationSpec.builder(GeneratedFrom.class)
|
||||
.addMember("value", "$S", SharedConstants.getCurrentVersion().getName())
|
||||
.build();
|
||||
public static final Iterable<AnnotationSpec> CLASS_HEADER = List.of(
|
||||
SUPPRESS_WARNINGS,
|
||||
GENERATED_FROM,
|
||||
NULL_MARKED
|
||||
);
|
||||
|
||||
private Annotations() {
|
||||
}
|
||||
}
|
||||
+9
-8
@@ -1,4 +1,4 @@
|
||||
package io.papermc.generator.utils.experimental;
|
||||
package io.papermc.generator.utils;
|
||||
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
import io.papermc.generator.Main;
|
||||
@@ -8,20 +8,21 @@ import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.data.worldgen.BootstrapContext;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@NullMarked
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public record CollectingContext<T>(Set<ResourceKey<T>> registered,
|
||||
Registry<T> registry) implements BootstrapContext<T> {
|
||||
|
||||
@Override
|
||||
public Holder.Reference<T> register(ResourceKey<T> key, T value, Lifecycle lifecycle) {
|
||||
this.registered.add(key);
|
||||
return Holder.Reference.createStandAlone(this.registry, key);
|
||||
public Holder.Reference<T> register(final ResourceKey<T> resourceKey, final @NonNull T t, final Lifecycle lifecycle) {
|
||||
this.registered.add(resourceKey);
|
||||
return Holder.Reference.createStandAlone(this.registry, resourceKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S> HolderGetter<S> lookup(ResourceKey<? extends Registry<? extends S>> key) {
|
||||
return Main.REGISTRY_ACCESS.lookupOrThrow(key);
|
||||
public <S> HolderGetter<S> lookup(final ResourceKey<? extends Registry<? extends S>> resourceKey) {
|
||||
return Main.REGISTRY_ACCESS.lookupOrThrow(resourceKey);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package io.papermc.generator.utils;
|
||||
|
||||
import java.util.Optional;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import java.util.Comparator;
|
||||
import java.util.Locale;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public final class Formatting {
|
||||
|
||||
private static final Pattern ILLEGAL_FIELD_CHARACTERS = Pattern.compile("[.-/]");
|
||||
|
||||
public static String formatKeyAsField(String path) {
|
||||
return ILLEGAL_FIELD_CHARACTERS.matcher(path.toUpperCase(Locale.ROOT)).replaceAll("_");
|
||||
}
|
||||
|
||||
public static Optional<String> formatTagKey(String tagDir, String resourcePath) {
|
||||
int tagsIndex = resourcePath.indexOf(tagDir);
|
||||
int dotIndex = resourcePath.lastIndexOf('.');
|
||||
if (tagsIndex == -1 || dotIndex == -1) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of(resourcePath.substring(tagsIndex + tagDir.length() + 1, dotIndex)); // namespace/tags/registry_key/[tag_key].json
|
||||
}
|
||||
|
||||
public static Comparator<String> ALPHABETIC_KEY_ORDER = alphabeticKeyOrder(path -> path);
|
||||
|
||||
public static <T> Comparator<T> alphabeticKeyOrder(Function<T, String> mapper) {
|
||||
return (o1, o2) -> {
|
||||
String path1 = mapper.apply(o1);
|
||||
String path2 = mapper.apply(o2);
|
||||
|
||||
OptionalInt trailingInt1 = tryParseTrailingInt(path1);
|
||||
OptionalInt trailingInt2 = tryParseTrailingInt(path2);
|
||||
|
||||
if (trailingInt1.isPresent() && trailingInt2.isPresent()) {
|
||||
return Integer.compare(trailingInt1.getAsInt(), trailingInt2.getAsInt());
|
||||
}
|
||||
|
||||
return path1.compareTo(path2);
|
||||
};
|
||||
}
|
||||
|
||||
private static OptionalInt tryParseTrailingInt(String path) {
|
||||
int delimiterIndex = path.lastIndexOf('_');
|
||||
if (delimiterIndex != -1) {
|
||||
String score = path.substring(delimiterIndex + 1);
|
||||
if (NumberUtils.isDigits(score)) {
|
||||
return OptionalInt.of(Integer.parseInt(score));
|
||||
}
|
||||
}
|
||||
return OptionalInt.empty();
|
||||
}
|
||||
|
||||
private Formatting() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package io.papermc.generator.utils;
|
||||
|
||||
public final class Javadocs {
|
||||
|
||||
public static String getVersionDependentClassHeader(String headerIdentifier) {
|
||||
return """
|
||||
Vanilla keys for %s.
|
||||
|
||||
@apiNote The fields provided here are a direct representation of
|
||||
what is available from the vanilla game source. They may be
|
||||
changed (including removals) on any Minecraft version
|
||||
bump, so cross-version compatibility is not provided on the
|
||||
same level as it is on most of the other API.
|
||||
""".formatted(headerIdentifier);
|
||||
}
|
||||
|
||||
public static String getVersionDependentField(String headerIdentifier) {
|
||||
return """
|
||||
%s
|
||||
|
||||
@apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
""".formatted(headerIdentifier);
|
||||
}
|
||||
|
||||
private Javadocs() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package io.papermc.generator.utils;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import io.papermc.generator.Main;
|
||||
import java.util.Collections;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.packs.PackResources;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraft.server.packs.repository.BuiltInPackSource;
|
||||
import net.minecraft.server.packs.resources.MultiPackResourceManager;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
// collect all the tags by grabbing the json from the data-packs
|
||||
// another (probably) way is to hook into the data generator like the typed keys generator
|
||||
public final class TagCollector {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
|
||||
public static Map<TagKey<?>, String> grabExperimental(final MultiPackResourceManager resourceManager) {
|
||||
Map<TagKey<?>, String> result = new IdentityHashMap<>();
|
||||
|
||||
// collect all vanilla tags
|
||||
Multimap<ResourceKey<? extends Registry<?>>, String> vanillaTags = HashMultimap.create();
|
||||
PackResources vanillaPack = resourceManager.listPacks()
|
||||
.filter(packResources -> packResources.packId().equals(BuiltInPackSource.VANILLA_ID))
|
||||
.findFirst()
|
||||
.orElseThrow();
|
||||
collectFromPack(vanillaPack, (entry, path) -> vanillaTags.put(entry.key(), path));
|
||||
|
||||
// then distinct with other data-pack tags to know for sure newly created tags and so experimental one
|
||||
resourceManager.listPacks().forEach(pack -> {
|
||||
String packId = pack.packId();
|
||||
if (packId.equals(BuiltInPackSource.VANILLA_ID)) return;
|
||||
|
||||
collectFromPack(pack, (entry, path) -> {
|
||||
if (vanillaTags.get(entry.key()).contains(path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
result.put(entry.value().listTagIds()
|
||||
.filter(tagKey -> tagKey.location().getPath().equals(path))
|
||||
.findFirst()
|
||||
.orElseThrow(), packId);
|
||||
});
|
||||
});
|
||||
return Collections.unmodifiableMap(result);
|
||||
}
|
||||
|
||||
private static void collectFromPack(PackResources pack, BiConsumer<RegistryAccess.RegistryEntry<?>, String> output) {
|
||||
Set<String> namespaces = pack.getNamespaces(PackType.SERVER_DATA);
|
||||
|
||||
for (String namespace : namespaces) {
|
||||
Main.REGISTRY_ACCESS.registries().forEach(entry -> {
|
||||
// this is probably expensive but can't find another way around and data-pack loader has similar logic
|
||||
// the issue is that registry key can have parent/key (and custom folder too) but tag key can also have parent/key so parsing become a mess
|
||||
// without having at least one of the two values
|
||||
String tagDir = Registries.tagsDirPath(entry.key());
|
||||
pack.listResources(PackType.SERVER_DATA, namespace, tagDir, (id, supplier) -> {
|
||||
Formatting.formatTagKey(tagDir, id.getPath()).ifPresentOrElse(path -> output.accept(entry, path), () -> {
|
||||
LOGGER.warn("Unable to parse the path: {}/{}/{}.json in the data-pack {} into a tag key", namespace, tagDir, id.getPath(), pack.packId());
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private TagCollector() {
|
||||
}
|
||||
}
|
||||
+7
-5
@@ -3,21 +3,21 @@ package io.papermc.generator;
|
||||
import io.github.classgraph.ClassGraph;
|
||||
import io.github.classgraph.ScanResult;
|
||||
import io.papermc.generator.types.goal.MobGoalNames;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
public class MobGoalConverterTest {
|
||||
|
||||
@Test
|
||||
public void testBukkitMap() {
|
||||
final List<Class<Mob>> classes;
|
||||
try (ScanResult scanResult = new ClassGraph().enableClassInfo().whitelistPackages(Entity.class.getPackageName()).scan()) {
|
||||
try (ScanResult scanResult = new ClassGraph().enableAllInfo().whitelistPackages(Entity.class.getPackageName()).scan()) {
|
||||
classes = scanResult.getSubclasses(Mob.class.getName()).loadClasses(Mob.class);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ public class MobGoalConverterTest {
|
||||
}
|
||||
}
|
||||
|
||||
assertTrue(missingClasses.isEmpty(), () -> "Missing some entity classes in the bukkit map: " + String.join(", ", missingClasses));
|
||||
if (!missingClasses.isEmpty()) {
|
||||
fail("Missing some entity classes in the bukkit map: " + String.join(", ", missingClasses));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,6 @@
|
||||
public net/minecraft/world/level/material/MapColor MATERIAL_COLORS
|
||||
public net/minecraft/world/level/block/state/properties/IntegerProperty min
|
||||
|
||||
# for auto-marking experimental stuff
|
||||
public net/minecraft/core/RegistrySetBuilder entries
|
||||
public net/minecraft/core/RegistrySetBuilder$RegistryStub
|
||||
public net/minecraft/data/registries/VanillaRegistries BUILDER
|
||||
public net/minecraft/data/registries/WinterDropRegistries BUILDER
|
||||
public net/minecraft/data/registries/TradeRebalanceRegistries BUILDER
|
||||
public net/minecraft/world/flag/FeatureFlagRegistry names
|
||||
public net/minecraft/world/flag/FeatureFlagSet mask
|
||||
+19
-18
@@ -9,9 +9,9 @@ java {
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
val annotationsVersion = "26.0.1"
|
||||
val annotationsVersion = "24.1.0"
|
||||
val bungeeCordChatVersion = "1.20-R0.2"
|
||||
val adventureVersion = "4.18.0"
|
||||
val adventureVersion = "4.17.0"
|
||||
val slf4jVersion = "2.0.9"
|
||||
val log4jVersion = "2.17.1"
|
||||
|
||||
@@ -68,6 +68,9 @@ dependencies {
|
||||
apiAndDocs("net.kyori:adventure-text-serializer-plain")
|
||||
apiAndDocs("net.kyori:adventure-text-logger-slf4j")
|
||||
|
||||
implementation("org.ow2.asm:asm:9.7.1")
|
||||
implementation("org.ow2.asm:asm-commons:9.7.1")
|
||||
|
||||
api("org.apache.maven:maven-resolver-provider:3.9.6") // make API dependency for Paper Plugins
|
||||
compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.18")
|
||||
compileOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.18")
|
||||
@@ -93,16 +96,16 @@ dependencies {
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
}
|
||||
|
||||
val generatedDir: java.nio.file.Path = layout.projectDirectory.dir("src/generated/java").asFile.toPath()
|
||||
val generatedApiPath: java.nio.file.Path = rootProject.projectDir.toPath().resolve("paper-api-generator/generated")
|
||||
idea {
|
||||
module {
|
||||
generatedSourceDirs.add(generatedDir.toFile())
|
||||
generatedSourceDirs.add(generatedApiPath.toFile())
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDir(generatedDir)
|
||||
srcDir(generatedApiPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -176,7 +179,7 @@ tasks.withType<Javadoc> {
|
||||
"https://guava.dev/releases/33.3.1-jre/api/docs/",
|
||||
"https://javadoc.io/doc/org.yaml/snakeyaml/2.2/",
|
||||
"https://javadoc.io/doc/org.jetbrains/annotations/$annotationsVersion/",
|
||||
"https://javadoc.io/doc/org.joml/joml/1.10.8/",
|
||||
"https://javadoc.io/doc/org.joml/joml/1.10.8/index.html",
|
||||
"https://www.javadoc.io/doc/com.google.code.gson/gson/2.11.0",
|
||||
"https://jspecify.dev/docs/api/",
|
||||
"https://jd.advntr.dev/api/$adventureVersion/",
|
||||
@@ -228,23 +231,21 @@ tasks.compileTestJava {
|
||||
options.compilerArgs.add("-parameters")
|
||||
}
|
||||
|
||||
val scanJarForBadCalls by tasks.registering(io.papermc.paperweight.tasks.ScanJarForBadCalls::class) {
|
||||
val scanJar = tasks.register("scanJarForBadCalls", io.papermc.paperweight.tasks.ScanJarForBadCalls::class) {
|
||||
badAnnotations.add("Lio/papermc/paper/annotation/DoNotUse;")
|
||||
jarToScan.set(tasks.jar.flatMap { it.archiveFile })
|
||||
classpath.from(configurations.compileClasspath)
|
||||
}
|
||||
tasks.check {
|
||||
dependsOn(scanJarForBadCalls)
|
||||
dependsOn(scanJar)
|
||||
}
|
||||
|
||||
if (providers.gradleProperty("updatingMinecraft").getOrElse("false").toBoolean()) {
|
||||
val scanJarForOldGeneratedCode by tasks.registering(io.papermc.paperweight.tasks.ScanJarForOldGeneratedCode::class) {
|
||||
mcVersion.set(providers.gradleProperty("mcVersion"))
|
||||
annotation.set("Lio/papermc/paper/generated/GeneratedFrom;")
|
||||
jarToScan.set(tasks.jar.flatMap { it.archiveFile })
|
||||
classpath.from(configurations.compileClasspath)
|
||||
}
|
||||
tasks.check {
|
||||
dependsOn(scanJarForOldGeneratedCode)
|
||||
}
|
||||
val scanJarForOldGeneratedCode = tasks.register("scanJarForOldGeneratedCode", io.papermc.paperweight.tasks.ScanJarForOldGeneratedCode::class) {
|
||||
mcVersion.set(providers.gradleProperty("mcVersion"))
|
||||
annotation.set("Lio/papermc/paper/generated/GeneratedFrom;")
|
||||
jarToScan.set(tasks.jar.flatMap { it.archiveFile })
|
||||
classpath.from(configurations.compileClasspath)
|
||||
}
|
||||
tasks.check {
|
||||
dependsOn(scanJarForOldGeneratedCode)
|
||||
}
|
||||
-503
@@ -1,503 +0,0 @@
|
||||
package io.papermc.paper.registry.keys;
|
||||
|
||||
import static net.kyori.adventure.key.Key.key;
|
||||
|
||||
import io.papermc.paper.datacomponent.DataComponentType;
|
||||
import io.papermc.paper.generated.GeneratedFrom;
|
||||
import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Vanilla keys for {@link RegistryKey#DATA_COMPONENT_TYPE}.
|
||||
*
|
||||
* @apiNote The fields provided here are a direct representation of
|
||||
* what is available from the vanilla game source. They may be
|
||||
* changed (including removals) on any Minecraft version
|
||||
* bump, so cross-version compatibility is not provided on the
|
||||
* same level as it is on most of the other API.
|
||||
*/
|
||||
@SuppressWarnings({
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
public final class DataComponentTypeKeys {
|
||||
/**
|
||||
* {@code minecraft:attribute_modifiers}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> ATTRIBUTE_MODIFIERS = create(key("attribute_modifiers"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:banner_patterns}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> BANNER_PATTERNS = create(key("banner_patterns"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:base_color}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> BASE_COLOR = create(key("base_color"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:bees}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> BEES = create(key("bees"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:block_entity_data}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> BLOCK_ENTITY_DATA = create(key("block_entity_data"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:block_state}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> BLOCK_STATE = create(key("block_state"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:bucket_entity_data}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> BUCKET_ENTITY_DATA = create(key("bucket_entity_data"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:bundle_contents}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> BUNDLE_CONTENTS = create(key("bundle_contents"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:can_break}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> CAN_BREAK = create(key("can_break"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:can_place_on}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> CAN_PLACE_ON = create(key("can_place_on"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:charged_projectiles}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> CHARGED_PROJECTILES = create(key("charged_projectiles"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:consumable}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> CONSUMABLE = create(key("consumable"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:container}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> CONTAINER = create(key("container"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:container_loot}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> CONTAINER_LOOT = create(key("container_loot"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:creative_slot_lock}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> CREATIVE_SLOT_LOCK = create(key("creative_slot_lock"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:custom_data}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> CUSTOM_DATA = create(key("custom_data"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:custom_model_data}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> CUSTOM_MODEL_DATA = create(key("custom_model_data"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:custom_name}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> CUSTOM_NAME = create(key("custom_name"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:damage}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> DAMAGE = create(key("damage"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:damage_resistant}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> DAMAGE_RESISTANT = create(key("damage_resistant"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:death_protection}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> DEATH_PROTECTION = create(key("death_protection"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:debug_stick_state}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> DEBUG_STICK_STATE = create(key("debug_stick_state"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:dyed_color}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> DYED_COLOR = create(key("dyed_color"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:enchantable}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> ENCHANTABLE = create(key("enchantable"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:enchantment_glint_override}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> ENCHANTMENT_GLINT_OVERRIDE = create(key("enchantment_glint_override"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:enchantments}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> ENCHANTMENTS = create(key("enchantments"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:entity_data}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> ENTITY_DATA = create(key("entity_data"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:equippable}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> EQUIPPABLE = create(key("equippable"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:firework_explosion}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> FIREWORK_EXPLOSION = create(key("firework_explosion"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:fireworks}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> FIREWORKS = create(key("fireworks"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:food}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> FOOD = create(key("food"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:glider}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> GLIDER = create(key("glider"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:hide_additional_tooltip}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> HIDE_ADDITIONAL_TOOLTIP = create(key("hide_additional_tooltip"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:hide_tooltip}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> HIDE_TOOLTIP = create(key("hide_tooltip"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:instrument}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> INSTRUMENT = create(key("instrument"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:intangible_projectile}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> INTANGIBLE_PROJECTILE = create(key("intangible_projectile"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:item_model}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> ITEM_MODEL = create(key("item_model"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:item_name}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> ITEM_NAME = create(key("item_name"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:jukebox_playable}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> JUKEBOX_PLAYABLE = create(key("jukebox_playable"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:lock}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> LOCK = create(key("lock"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:lodestone_tracker}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> LODESTONE_TRACKER = create(key("lodestone_tracker"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:lore}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> LORE = create(key("lore"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:map_color}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> MAP_COLOR = create(key("map_color"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:map_decorations}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> MAP_DECORATIONS = create(key("map_decorations"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:map_id}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> MAP_ID = create(key("map_id"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:map_post_processing}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> MAP_POST_PROCESSING = create(key("map_post_processing"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:max_damage}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> MAX_DAMAGE = create(key("max_damage"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:max_stack_size}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> MAX_STACK_SIZE = create(key("max_stack_size"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:note_block_sound}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> NOTE_BLOCK_SOUND = create(key("note_block_sound"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:ominous_bottle_amplifier}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> OMINOUS_BOTTLE_AMPLIFIER = create(key("ominous_bottle_amplifier"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:pot_decorations}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> POT_DECORATIONS = create(key("pot_decorations"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:potion_contents}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> POTION_CONTENTS = create(key("potion_contents"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:profile}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> PROFILE = create(key("profile"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:rarity}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> RARITY = create(key("rarity"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:recipes}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> RECIPES = create(key("recipes"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:repair_cost}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> REPAIR_COST = create(key("repair_cost"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:repairable}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> REPAIRABLE = create(key("repairable"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:stored_enchantments}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> STORED_ENCHANTMENTS = create(key("stored_enchantments"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:suspicious_stew_effects}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> SUSPICIOUS_STEW_EFFECTS = create(key("suspicious_stew_effects"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:tool}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> TOOL = create(key("tool"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:tooltip_style}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> TOOLTIP_STYLE = create(key("tooltip_style"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:trim}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> TRIM = create(key("trim"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:unbreakable}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> UNBREAKABLE = create(key("unbreakable"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:use_cooldown}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> USE_COOLDOWN = create(key("use_cooldown"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:use_remainder}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> USE_REMAINDER = create(key("use_remainder"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:writable_book_content}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> WRITABLE_BOOK_CONTENT = create(key("writable_book_content"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:written_book_content}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TypedKey<DataComponentType> WRITTEN_BOOK_CONTENT = create(key("written_book_content"));
|
||||
|
||||
private DataComponentTypeKeys() {
|
||||
}
|
||||
|
||||
private static TypedKey<DataComponentType> create(final Key key) {
|
||||
return TypedKey.create(RegistryKey.DATA_COMPONENT_TYPE, key);
|
||||
}
|
||||
}
|
||||
-288
@@ -1,288 +0,0 @@
|
||||
package io.papermc.paper.registry.keys.tags;
|
||||
|
||||
import static net.kyori.adventure.key.Key.key;
|
||||
|
||||
import io.papermc.paper.generated.GeneratedFrom;
|
||||
import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.tag.TagKey;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Vanilla tag keys for {@link RegistryKey#ENTITY_TYPE}.
|
||||
*
|
||||
* @apiNote The fields provided here are a direct representation of
|
||||
* what is available from the vanilla game source. They may be
|
||||
* changed (including removals) on any Minecraft version
|
||||
* bump, so cross-version compatibility is not provided on the
|
||||
* same level as it is on most of the other API.
|
||||
*/
|
||||
@SuppressWarnings({
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@NullMarked
|
||||
@GeneratedFrom("1.21.4")
|
||||
@ApiStatus.Experimental
|
||||
public final class EntityTypeTagKeys {
|
||||
/**
|
||||
* {@code #minecraft:aquatic}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> AQUATIC = create(key("aquatic"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:arrows}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> ARROWS = create(key("arrows"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:arthropod}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> ARTHROPOD = create(key("arthropod"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:axolotl_always_hostiles}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> AXOLOTL_ALWAYS_HOSTILES = create(key("axolotl_always_hostiles"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:axolotl_hunt_targets}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> AXOLOTL_HUNT_TARGETS = create(key("axolotl_hunt_targets"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:beehive_inhabitors}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> BEEHIVE_INHABITORS = create(key("beehive_inhabitors"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:boat}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> BOAT = create(key("boat"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:can_breathe_under_water}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> CAN_BREATHE_UNDER_WATER = create(key("can_breathe_under_water"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:can_turn_in_boats}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> CAN_TURN_IN_BOATS = create(key("can_turn_in_boats"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:deflects_projectiles}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> DEFLECTS_PROJECTILES = create(key("deflects_projectiles"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:dismounts_underwater}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> DISMOUNTS_UNDERWATER = create(key("dismounts_underwater"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:fall_damage_immune}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> FALL_DAMAGE_IMMUNE = create(key("fall_damage_immune"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:freeze_hurts_extra_types}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> FREEZE_HURTS_EXTRA_TYPES = create(key("freeze_hurts_extra_types"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:freeze_immune_entity_types}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> FREEZE_IMMUNE_ENTITY_TYPES = create(key("freeze_immune_entity_types"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:frog_food}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> FROG_FOOD = create(key("frog_food"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:ignores_poison_and_regen}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> IGNORES_POISON_AND_REGEN = create(key("ignores_poison_and_regen"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:illager}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> ILLAGER = create(key("illager"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:illager_friends}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> ILLAGER_FRIENDS = create(key("illager_friends"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:immune_to_infested}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> IMMUNE_TO_INFESTED = create(key("immune_to_infested"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:immune_to_oozing}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> IMMUNE_TO_OOZING = create(key("immune_to_oozing"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:impact_projectiles}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> IMPACT_PROJECTILES = create(key("impact_projectiles"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:inverted_healing_and_harm}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> INVERTED_HEALING_AND_HARM = create(key("inverted_healing_and_harm"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:no_anger_from_wind_charge}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> NO_ANGER_FROM_WIND_CHARGE = create(key("no_anger_from_wind_charge"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:non_controlling_rider}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> NON_CONTROLLING_RIDER = create(key("non_controlling_rider"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:not_scary_for_pufferfish}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> NOT_SCARY_FOR_PUFFERFISH = create(key("not_scary_for_pufferfish"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:powder_snow_walkable_mobs}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> POWDER_SNOW_WALKABLE_MOBS = create(key("powder_snow_walkable_mobs"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:raiders}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> RAIDERS = create(key("raiders"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:redirectable_projectile}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> REDIRECTABLE_PROJECTILE = create(key("redirectable_projectile"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:sensitive_to_bane_of_arthropods}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> SENSITIVE_TO_BANE_OF_ARTHROPODS = create(key("sensitive_to_bane_of_arthropods"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:sensitive_to_impaling}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> SENSITIVE_TO_IMPALING = create(key("sensitive_to_impaling"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:sensitive_to_smite}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> SENSITIVE_TO_SMITE = create(key("sensitive_to_smite"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:skeletons}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> SKELETONS = create(key("skeletons"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:undead}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> UNDEAD = create(key("undead"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:wither_friends}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> WITHER_FRIENDS = create(key("wither_friends"));
|
||||
|
||||
/**
|
||||
* {@code #minecraft:zombies}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final TagKey<EntityType> ZOMBIES = create(key("zombies"));
|
||||
|
||||
private EntityTypeTagKeys() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a tag key for {@link EntityType} in the registry {@code minecraft:entity_type}.
|
||||
*
|
||||
* @param key the tag key's key
|
||||
* @return a new tag key
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
public static TagKey<EntityType> create(final Key key) {
|
||||
return TagKey.create(RegistryKey.ENTITY_TYPE, key);
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package com.destroystokyo.paper.event.executor;
|
||||
|
||||
import com.destroystokyo.paper.util.SneakyThrow;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.Method;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventException;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.EventExecutor;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@NullMarked
|
||||
public class MethodHandleEventExecutor implements EventExecutor {
|
||||
|
||||
private final Class<? extends Event> eventClass;
|
||||
private final MethodHandle handle;
|
||||
private final @Nullable Method method;
|
||||
|
||||
public MethodHandleEventExecutor(final Class<? extends Event> eventClass, final MethodHandle handle) {
|
||||
this.eventClass = eventClass;
|
||||
this.handle = handle;
|
||||
this.method = null;
|
||||
}
|
||||
|
||||
public MethodHandleEventExecutor(final Class<? extends Event> eventClass, final Method m) {
|
||||
this.eventClass = eventClass;
|
||||
try {
|
||||
m.setAccessible(true);
|
||||
this.handle = MethodHandles.lookup().unreflect(m);
|
||||
} catch (final IllegalAccessException e) {
|
||||
throw new AssertionError("Unable to set accessible", e);
|
||||
}
|
||||
this.method = m;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final Listener listener, final Event event) throws EventException {
|
||||
if (!this.eventClass.isInstance(event)) return;
|
||||
try {
|
||||
this.handle.invoke(listener, event);
|
||||
} catch (final Throwable t) {
|
||||
SneakyThrow.sneaky(t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MethodHandleEventExecutor['" + this.method + "']";
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package com.destroystokyo.paper.event.executor;
|
||||
|
||||
import com.destroystokyo.paper.util.SneakyThrow;
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventException;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.EventExecutor;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@NullMarked
|
||||
public class StaticMethodHandleEventExecutor implements EventExecutor {
|
||||
|
||||
private final Class<? extends Event> eventClass;
|
||||
private final MethodHandle handle;
|
||||
private final Method method;
|
||||
|
||||
public StaticMethodHandleEventExecutor(final Class<? extends Event> eventClass, final Method m) {
|
||||
Preconditions.checkArgument(Modifier.isStatic(m.getModifiers()), "Not a static method: %s", m);
|
||||
Preconditions.checkArgument(eventClass != null, "eventClass is null");
|
||||
this.eventClass = eventClass;
|
||||
try {
|
||||
m.setAccessible(true);
|
||||
this.handle = MethodHandles.lookup().unreflect(m);
|
||||
} catch (final IllegalAccessException e) {
|
||||
throw new AssertionError("Unable to set accessible", e);
|
||||
}
|
||||
this.method = m;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final Listener listener, final Event event) throws EventException {
|
||||
if (!this.eventClass.isInstance(event)) return;
|
||||
try {
|
||||
this.handle.invoke(event);
|
||||
} catch (final Throwable throwable) {
|
||||
SneakyThrow.sneaky(throwable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StaticMethodHandleEventExecutor['" + this.method + "']";
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.destroystokyo.paper.event.executor.asm;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.bukkit.plugin.EventExecutor;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.commons.GeneratorAdapter;
|
||||
|
||||
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
|
||||
import static org.objectweb.asm.Opcodes.INVOKEINTERFACE;
|
||||
import static org.objectweb.asm.Opcodes.INVOKESPECIAL;
|
||||
import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
|
||||
import static org.objectweb.asm.Opcodes.V1_8;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@NullMarked
|
||||
public final class ASMEventExecutorGenerator {
|
||||
|
||||
private static final String EXECUTE_DESCRIPTOR = "(Lorg/bukkit/event/Listener;Lorg/bukkit/event/Event;)V";
|
||||
|
||||
public static byte[] generateEventExecutor(final Method m, final String name) {
|
||||
final ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||
writer.visit(V1_8, ACC_PUBLIC, name.replace('.', '/'), null, Type.getInternalName(Object.class), new String[]{Type.getInternalName(EventExecutor.class)});
|
||||
// Generate constructor
|
||||
GeneratorAdapter methodGenerator = new GeneratorAdapter(writer.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null), ACC_PUBLIC, "<init>", "()V");
|
||||
methodGenerator.loadThis();
|
||||
methodGenerator.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(Object.class), "<init>", "()V", false); // Invoke the super class (Object) constructor
|
||||
methodGenerator.returnValue();
|
||||
methodGenerator.endMethod();
|
||||
// Generate the execute method
|
||||
methodGenerator = new GeneratorAdapter(writer.visitMethod(ACC_PUBLIC, "execute", EXECUTE_DESCRIPTOR, null, null), ACC_PUBLIC, "execute", EXECUTE_DESCRIPTOR);
|
||||
methodGenerator.loadArg(0);
|
||||
methodGenerator.checkCast(Type.getType(m.getDeclaringClass()));
|
||||
methodGenerator.loadArg(1);
|
||||
methodGenerator.checkCast(Type.getType(m.getParameterTypes()[0]));
|
||||
methodGenerator.visitMethodInsn(m.getDeclaringClass().isInterface() ? INVOKEINTERFACE : INVOKEVIRTUAL, Type.getInternalName(m.getDeclaringClass()), m.getName(), Type.getMethodDescriptor(m), m.getDeclaringClass().isInterface());
|
||||
// The only purpose of this switch statement is to generate the correct pop instruction, should the event handler method return something other than void.
|
||||
// Non-void event handlers will be unsupported in a future release.
|
||||
switch (Type.getType(m.getReturnType()).getSize()) {
|
||||
// case 0 is omitted because the only type that has size 0 is void - no pop instruction needed.
|
||||
case 1 -> methodGenerator.pop(); // handles reference types and most primitives
|
||||
case 2 -> methodGenerator.pop2(); // handles long and double
|
||||
}
|
||||
methodGenerator.returnValue();
|
||||
methodGenerator.endMethod();
|
||||
writer.visitEnd();
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
public static AtomicInteger NEXT_ID = new AtomicInteger(1);
|
||||
|
||||
public static String generateName() {
|
||||
final int id = NEXT_ID.getAndIncrement();
|
||||
return "com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor" + id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.destroystokyo.paper.event.executor.asm;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@NullMarked
|
||||
public interface ClassDefiner {
|
||||
|
||||
/**
|
||||
* Returns if the defined classes can bypass access checks
|
||||
*
|
||||
* @return if classes bypass access checks
|
||||
*/
|
||||
default boolean isBypassAccessChecks() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define a class
|
||||
*
|
||||
* @param parentLoader the parent classloader
|
||||
* @param name the name of the class
|
||||
* @param data the class data to load
|
||||
* @return the defined class
|
||||
* @throws ClassFormatError if the class data is invalid
|
||||
* @throws NullPointerException if any of the arguments are null
|
||||
*/
|
||||
Class<?> defineClass(ClassLoader parentLoader, String name, byte[] data);
|
||||
|
||||
static ClassDefiner getInstance() {
|
||||
return SafeClassDefiner.INSTANCE;
|
||||
}
|
||||
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package com.destroystokyo.paper.event.executor.asm;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@NullMarked
|
||||
public class SafeClassDefiner implements ClassDefiner {
|
||||
|
||||
/* default */ static final SafeClassDefiner INSTANCE = new SafeClassDefiner();
|
||||
|
||||
private SafeClassDefiner() {
|
||||
}
|
||||
|
||||
private final ConcurrentMap<ClassLoader, GeneratedClassLoader> loaders = new MapMaker().weakKeys().makeMap();
|
||||
|
||||
@Override
|
||||
public Class<?> defineClass(final ClassLoader parentLoader, final String name, final byte[] data) {
|
||||
final GeneratedClassLoader loader = this.loaders.computeIfAbsent(parentLoader, GeneratedClassLoader::new);
|
||||
synchronized (loader.getClassLoadingLock(name)) {
|
||||
Preconditions.checkState(!loader.hasClass(name), "%s already defined", name);
|
||||
final Class<?> c = loader.define(name, data);
|
||||
assert c.getName().equals(name);
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
private static class GeneratedClassLoader extends ClassLoader {
|
||||
|
||||
static {
|
||||
ClassLoader.registerAsParallelCapable();
|
||||
}
|
||||
|
||||
protected GeneratedClassLoader(final ClassLoader parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
private Class<?> define(final String name, final byte[] data) {
|
||||
synchronized (this.getClassLoadingLock(name)) {
|
||||
assert !this.hasClass(name);
|
||||
final Class<?> c = this.defineClass(name, data, 0, data.length);
|
||||
this.resolveClass(c);
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClassLoadingLock(final String name) {
|
||||
return super.getClassLoadingLock(name);
|
||||
}
|
||||
|
||||
public boolean hasClass(final String name) {
|
||||
synchronized (this.getClassLoadingLock(name)) {
|
||||
try {
|
||||
Class.forName(name);
|
||||
return true;
|
||||
} catch (final ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-23
@@ -5,7 +5,6 @@ import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
@@ -17,10 +16,8 @@ import static org.bukkit.Material.*;
|
||||
* Called when the player themselves change their armor items
|
||||
* <p>
|
||||
* Not currently called for environmental factors though it <strong>MAY BE IN THE FUTURE</strong>
|
||||
* @apiNote Use {@link io.papermc.paper.event.entity.EntityEquipmentChangedEvent} for all entity equipment changes
|
||||
*/
|
||||
@NullMarked
|
||||
@ApiStatus.Obsolete(since = "1.21.4")
|
||||
public class PlayerArmorChangeEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
@@ -41,27 +38,11 @@ public class PlayerArmorChangeEvent extends PlayerEvent {
|
||||
* Gets the type of slot being altered.
|
||||
*
|
||||
* @return type of slot being altered
|
||||
* @deprecated {@link SlotType} does not accurately represent what item types are valid in each slot. Use {@link #getSlot()} instead.
|
||||
*/
|
||||
@Deprecated(since = "1.21.4")
|
||||
public SlotType getSlotType() {
|
||||
return this.slotType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the slot being altered.
|
||||
*
|
||||
* @return slot being altered
|
||||
*/
|
||||
public EquipmentSlot getSlot() {
|
||||
return switch (this.slotType) {
|
||||
case HEAD -> EquipmentSlot.HEAD;
|
||||
case CHEST -> EquipmentSlot.CHEST;
|
||||
case LEGS -> EquipmentSlot.LEGS;
|
||||
case FEET -> EquipmentSlot.FEET;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the existing item that's being replaced
|
||||
*
|
||||
@@ -89,10 +70,6 @@ public class PlayerArmorChangeEvent extends PlayerEvent {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated {@link SlotType} does not accurately represent what item types are valid in each slot.
|
||||
*/
|
||||
@Deprecated(since = "1.21.4")
|
||||
public enum SlotType {
|
||||
HEAD(NETHERITE_HELMET, DIAMOND_HELMET, GOLDEN_HELMET, IRON_HELMET, CHAINMAIL_HELMET, LEATHER_HELMET, CARVED_PUMPKIN, PLAYER_HEAD, SKELETON_SKULL, ZOMBIE_HEAD, CREEPER_HEAD, WITHER_SKELETON_SKULL, TURTLE_HELMET, DRAGON_HEAD, PIGLIN_HEAD),
|
||||
CHEST(NETHERITE_CHESTPLATE, DIAMOND_CHESTPLATE, GOLDEN_CHESTPLATE, IRON_CHESTPLATE, CHAINMAIL_CHESTPLATE, LEATHER_CHESTPLATE, ELYTRA),
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents an event that is called when a player clicks an unknown entity.
|
||||
* Represents an event that is called when a player right-clicks an unknown entity.
|
||||
* Useful for plugins dealing with virtual entities (entities that aren't actually spawned on the server).
|
||||
* <br>
|
||||
* This event may be called multiple times per interaction with different interaction hands
|
||||
|
||||
+2
-1
@@ -304,7 +304,8 @@ public class PaperServerListPingEvent extends ServerListPingEvent implements Can
|
||||
return new PlayerIterator();
|
||||
}
|
||||
|
||||
protected @NotNull Object @NotNull [] getOnlinePlayers() {
|
||||
@NotNull
|
||||
protected Object[] getOnlinePlayers() {
|
||||
return Bukkit.getOnlinePlayers().toArray();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
package io.papermc.paper;
|
||||
|
||||
import net.kyori.adventure.util.Services;
|
||||
import org.bukkit.damage.DamageEffect;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Static bridge to the server internals.
|
||||
* <p>
|
||||
* Any and all methods in here are *not* to be called by plugin developers, may change at any time and may generally
|
||||
* cause issues when called under unexpected circumstances.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
@NullMarked
|
||||
public interface InternalAPIBridge {
|
||||
|
||||
/**
|
||||
* Yields the instance of this API bridge by lazily requesting it from the java service loader API.
|
||||
*
|
||||
* @return the instance.
|
||||
*/
|
||||
static InternalAPIBridge get() {
|
||||
class Holder {
|
||||
public static final InternalAPIBridge INSTANCE = Services.service(InternalAPIBridge.class).orElseThrow();
|
||||
}
|
||||
|
||||
return Holder.INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a damage effect instance for the passed key.
|
||||
*
|
||||
* @param key the string key.
|
||||
* @return the damage effect.
|
||||
*/
|
||||
DamageEffect getDamageEffect(String key);
|
||||
}
|
||||
|
||||
-5
@@ -10,10 +10,5 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public enum CommandRegistrationFlag {
|
||||
|
||||
/**
|
||||
* @deprecated This is the default behavior now.
|
||||
*/
|
||||
@Deprecated(since = "1.21.4")
|
||||
FLATTEN_ALIASES
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package io.papermc.paper.command.brigadier;
|
||||
|
||||
import com.mojang.brigadier.RedirectModifier;
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -50,24 +48,4 @@ public interface CommandSourceStack {
|
||||
* @return entity that executes this command
|
||||
*/
|
||||
@Nullable Entity getExecutor();
|
||||
|
||||
/**
|
||||
* Creates a new CommandSourceStack object with a different location for redirecting commands to other nodes.
|
||||
*
|
||||
* @param location The location to create a new CommandSourceStack object with
|
||||
* @return The newly created CommandSourceStack
|
||||
* @see #getLocation()
|
||||
* @see com.mojang.brigadier.builder.ArgumentBuilder#fork(CommandNode, RedirectModifier)
|
||||
*/
|
||||
CommandSourceStack withLocation(Location location);
|
||||
|
||||
/**
|
||||
* Creates a new CommandSourceStack object with a different executor for redirecting commands to other nodes.
|
||||
*
|
||||
* @param executor The executing entity to create a new CommandSourceStack object with
|
||||
* @return The newly created CommandSourceStack
|
||||
* @see #getExecutor()
|
||||
* @see com.mojang.brigadier.builder.ArgumentBuilder#fork(CommandNode, RedirectModifier)
|
||||
*/
|
||||
CommandSourceStack withExecutor(Entity executor);
|
||||
}
|
||||
@@ -113,7 +113,6 @@ public interface Commands extends Registrar {
|
||||
* <p>Commands have certain overriding behavior:
|
||||
* <ul>
|
||||
* <li>Aliases will not override already existing commands (excluding namespaced ones)</li>
|
||||
* <li>Aliases are <b>not</b> Brigadier redirects, they just copy the command to a different label</li>
|
||||
* <li>The main command/namespaced label will override already existing commands</li>
|
||||
* </ul>
|
||||
*
|
||||
@@ -130,7 +129,6 @@ public interface Commands extends Registrar {
|
||||
* <p>Commands have certain overriding behavior:
|
||||
* <ul>
|
||||
* <li>Aliases will not override already existing commands (excluding namespaced ones)</li>
|
||||
* <li>Aliases are <b>not</b> Brigadier redirects, they just copy the command to a different label</li>
|
||||
* <li>The main command/namespaced label will override already existing commands</li>
|
||||
* </ul>
|
||||
*
|
||||
@@ -148,7 +146,6 @@ public interface Commands extends Registrar {
|
||||
* <p>Commands have certain overriding behavior:
|
||||
* <ul>
|
||||
* <li>Aliases will not override already existing commands (excluding namespaced ones)</li>
|
||||
* <li>Aliases are <b>not</b> Brigadier redirects, they just copy the command to a different label</li>
|
||||
* <li>The main command/namespaced label will override already existing commands</li>
|
||||
* </ul>
|
||||
*
|
||||
@@ -166,7 +163,6 @@ public interface Commands extends Registrar {
|
||||
* <p>Commands have certain overriding behavior:
|
||||
* <ul>
|
||||
* <li>Aliases will not override already existing commands (excluding namespaced ones)</li>
|
||||
* <li>Aliases are <b>not</b> Brigadier redirects, they just copy the command to a different label</li>
|
||||
* <li>The main command/namespaced label will override already existing commands</li>
|
||||
* </ul>
|
||||
*
|
||||
@@ -183,7 +179,6 @@ public interface Commands extends Registrar {
|
||||
* <p>Commands have certain overriding behavior:
|
||||
* <ul>
|
||||
* <li>Aliases will not override already existing commands (excluding namespaced ones)</li>
|
||||
* <li>Aliases are <b>not</b> Brigadier redirects, they just copy the command to a different label</li>
|
||||
* <li>The main command/namespaced label will override already existing commands</li>
|
||||
* </ul>
|
||||
*
|
||||
|
||||
-10
@@ -7,7 +7,6 @@ import io.papermc.paper.command.brigadier.argument.range.IntegerRangeProvider;
|
||||
import io.papermc.paper.command.brigadier.argument.resolvers.BlockPositionResolver;
|
||||
import io.papermc.paper.command.brigadier.argument.resolvers.FinePositionResolver;
|
||||
import io.papermc.paper.command.brigadier.argument.resolvers.PlayerProfileListResolver;
|
||||
import io.papermc.paper.command.brigadier.argument.resolvers.RotationResolver;
|
||||
import io.papermc.paper.command.brigadier.argument.resolvers.selector.EntitySelectorArgumentResolver;
|
||||
import io.papermc.paper.command.brigadier.argument.resolvers.selector.PlayerSelectorArgumentResolver;
|
||||
import io.papermc.paper.entity.LookAnchor;
|
||||
@@ -124,15 +123,6 @@ public final class ArgumentTypes {
|
||||
return provider().finePosition(centerIntegers);
|
||||
}
|
||||
|
||||
/**
|
||||
* A rotation argument.
|
||||
*
|
||||
* @return rotation argument
|
||||
*/
|
||||
public static ArgumentType<RotationResolver> rotation() {
|
||||
return provider().rotation();
|
||||
}
|
||||
|
||||
/**
|
||||
* A blockstate argument which will provide rich parsing for specifying
|
||||
* the specific block variant and then the block entity NBT if applicable.
|
||||
|
||||
-3
@@ -7,7 +7,6 @@ import io.papermc.paper.command.brigadier.argument.range.IntegerRangeProvider;
|
||||
import io.papermc.paper.command.brigadier.argument.resolvers.BlockPositionResolver;
|
||||
import io.papermc.paper.command.brigadier.argument.resolvers.FinePositionResolver;
|
||||
import io.papermc.paper.command.brigadier.argument.resolvers.PlayerProfileListResolver;
|
||||
import io.papermc.paper.command.brigadier.argument.resolvers.RotationResolver;
|
||||
import io.papermc.paper.command.brigadier.argument.resolvers.selector.EntitySelectorArgumentResolver;
|
||||
import io.papermc.paper.command.brigadier.argument.resolvers.selector.PlayerSelectorArgumentResolver;
|
||||
import io.papermc.paper.entity.LookAnchor;
|
||||
@@ -58,8 +57,6 @@ interface VanillaArgumentProvider {
|
||||
|
||||
ArgumentType<FinePositionResolver> finePosition(boolean centerIntegers);
|
||||
|
||||
ArgumentType<RotationResolver> rotation();
|
||||
|
||||
ArgumentType<BlockState> blockState();
|
||||
|
||||
ArgumentType<ItemStack> itemStack();
|
||||
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
package io.papermc.paper.command.brigadier.argument.resolvers;
|
||||
|
||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||
import io.papermc.paper.math.Rotation;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* An {@link ArgumentResolver} that's capable of resolving
|
||||
* a rotation argument value using a {@link CommandSourceStack}.
|
||||
*
|
||||
* @see io.papermc.paper.command.brigadier.argument.ArgumentTypes#rotation()
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
@ApiStatus.NonExtendable
|
||||
public interface RotationResolver extends ArgumentResolver<Rotation> {
|
||||
}
|
||||
@@ -63,76 +63,21 @@ import static java.util.Objects.requireNonNull;
|
||||
@ApiStatus.Experimental
|
||||
public final class DataComponentTypes {
|
||||
|
||||
// Start generate - DataComponentTypes
|
||||
// @GeneratedFrom 1.21.4
|
||||
/**
|
||||
* Holds attribute modifiers applied to any item,
|
||||
* if not set, has an implicit default value based on the item type's
|
||||
* default attributes (e.g. attack damage for weapons).
|
||||
* Controls the maximum stacking size of this item.
|
||||
* <br>
|
||||
* Values greater than 1 are mutually exclusive with the {@link #MAX_DAMAGE} component.
|
||||
*/
|
||||
public static final DataComponentType.Valued<ItemAttributeModifiers> ATTRIBUTE_MODIFIERS = valued("attribute_modifiers");
|
||||
|
||||
public static final DataComponentType.Valued<@IntRange(from = 1, to = 99) Integer> MAX_STACK_SIZE = valued("max_stack_size");
|
||||
/**
|
||||
* Stores the additional patterns applied to a Banner or Shield.
|
||||
*/
|
||||
public static final DataComponentType.Valued<BannerPatternLayers> BANNER_PATTERNS = valued("banner_patterns");
|
||||
|
||||
/**
|
||||
* Stores the base color for a Shield.
|
||||
*/
|
||||
public static final DataComponentType.Valued<DyeColor> BASE_COLOR = valued("base_color");
|
||||
|
||||
/**
|
||||
* Holds block state properties to apply when placing a block.
|
||||
*/
|
||||
public static final DataComponentType.Valued<BlockItemDataProperties> BLOCK_DATA = valued("block_state");
|
||||
|
||||
/**
|
||||
* Holds all items stored inside a Bundle.
|
||||
* If removed, items cannot be added to the Bundle.
|
||||
*/
|
||||
public static final DataComponentType.Valued<BundleContents> BUNDLE_CONTENTS = valued("bundle_contents");
|
||||
|
||||
/**
|
||||
* Controls which blocks a player in Adventure mode can break with this item.
|
||||
*/
|
||||
public static final DataComponentType.Valued<ItemAdventurePredicate> CAN_BREAK = valued("can_break");
|
||||
|
||||
/**
|
||||
* Controls which blocks a player in Adventure mode can place on with this item.
|
||||
*/
|
||||
public static final DataComponentType.Valued<ItemAdventurePredicate> CAN_PLACE_ON = valued("can_place_on");
|
||||
|
||||
/**
|
||||
* Holds all projectiles that have been loaded into a Crossbow.
|
||||
* If not present, the Crossbow is not charged.
|
||||
*/
|
||||
public static final DataComponentType.Valued<ChargedProjectiles> CHARGED_PROJECTILES = valued("charged_projectiles");
|
||||
|
||||
public static final DataComponentType.Valued<Consumable> CONSUMABLE = valued("consumable");
|
||||
|
||||
/**
|
||||
* Holds the contents of container blocks (Chests, Shulker Boxes) in item form.
|
||||
*/
|
||||
public static final DataComponentType.Valued<ItemContainerContents> CONTAINER = valued("container");
|
||||
|
||||
/**
|
||||
* Holds the unresolved loot table and seed of a container-like block.
|
||||
*/
|
||||
public static final DataComponentType.Valued<SeededContainerLoot> CONTAINER_LOOT = valued("container_loot");
|
||||
|
||||
/**
|
||||
* Controls the minecraft:custom_model_data property in the item model.
|
||||
*/
|
||||
public static final DataComponentType.Valued<CustomModelData> CUSTOM_MODEL_DATA = valued("custom_model_data");
|
||||
|
||||
/**
|
||||
* Custom name override for an item (as set by renaming with an Anvil).
|
||||
* Controls the maximum amount of damage than an item can take,
|
||||
* if not present, the item cannot be damaged.
|
||||
* <br>
|
||||
* Mutually exclusive with the {@link #MAX_STACK_SIZE} component greater than 1.
|
||||
*
|
||||
* @see #ITEM_NAME
|
||||
* @see #DAMAGE
|
||||
*/
|
||||
public static final DataComponentType.Valued<Component> CUSTOM_NAME = valued("custom_name");
|
||||
|
||||
public static final DataComponentType.Valued<@Positive Integer> MAX_DAMAGE = valued("max_damage");
|
||||
/**
|
||||
* The amount of durability removed from an item,
|
||||
* for damageable items (with the {@link #MAX_DAMAGE} component), has an implicit default value of: {@code 0}.
|
||||
@@ -140,80 +85,16 @@ public final class DataComponentTypes {
|
||||
* @see #MAX_DAMAGE
|
||||
*/
|
||||
public static final DataComponentType.Valued<@NonNegative Integer> DAMAGE = valued("damage");
|
||||
|
||||
/**
|
||||
* If present, this item will not take damage from the specified damage types.
|
||||
* If set, the item will not lose any durability when used.
|
||||
*/
|
||||
public static final DataComponentType.Valued<DamageResistant> DAMAGE_RESISTANT = valued("damage_resistant");
|
||||
|
||||
public static final DataComponentType.Valued<DeathProtection> DEATH_PROTECTION = valued("death_protection");
|
||||
|
||||
public static final DataComponentType.Valued<Unbreakable> UNBREAKABLE = valued("unbreakable");
|
||||
/**
|
||||
* Represents a color applied to a dyeable item (in the {@link io.papermc.paper.registry.keys.tags.ItemTypeTagKeys#DYEABLE} item tag).
|
||||
*/
|
||||
public static final DataComponentType.Valued<DyedItemColor> DYED_COLOR = valued("dyed_color");
|
||||
|
||||
public static final DataComponentType.Valued<Enchantable> ENCHANTABLE = valued("enchantable");
|
||||
|
||||
/**
|
||||
* Overrides the enchantment glint effect on an item.
|
||||
* If not present, default behaviour is used.
|
||||
*/
|
||||
public static final DataComponentType.Valued<Boolean> ENCHANTMENT_GLINT_OVERRIDE = valued("enchantment_glint_override");
|
||||
|
||||
/**
|
||||
* Controls the enchantments on an item.
|
||||
* <br>
|
||||
* If not present on a non-enchantment book, this item will not work in an anvil.
|
||||
* Custom name override for an item (as set by renaming with an Anvil).
|
||||
*
|
||||
* @see #STORED_ENCHANTMENTS
|
||||
* @see #ITEM_NAME
|
||||
*/
|
||||
public static final DataComponentType.Valued<ItemEnchantments> ENCHANTMENTS = valued("enchantments");
|
||||
|
||||
public static final DataComponentType.Valued<Equippable> EQUIPPABLE = valued("equippable");
|
||||
|
||||
/**
|
||||
* Stores the explosion crafted in a Firework Star.
|
||||
*/
|
||||
public static final DataComponentType.Valued<FireworkEffect> FIREWORK_EXPLOSION = valued("firework_explosion");
|
||||
|
||||
/**
|
||||
* Stores all explosions crafted into a Firework Rocket, as well as flight duration.
|
||||
*/
|
||||
public static final DataComponentType.Valued<Fireworks> FIREWORKS = valued("fireworks");
|
||||
|
||||
/**
|
||||
* Controls potential food benefits gained when consuming the item the component is applied on.
|
||||
* Requires the {@link #CONSUMABLE} component to allow consumption in the first place.
|
||||
*/
|
||||
public static final DataComponentType.Valued<FoodProperties> FOOD = valued("food");
|
||||
|
||||
public static final DataComponentType.NonValued GLIDER = unvalued("glider");
|
||||
|
||||
/**
|
||||
* If set, disables 'additional' tooltip part which comes from the item type
|
||||
* (e.g. content of a shulker).
|
||||
*/
|
||||
public static final DataComponentType.NonValued HIDE_ADDITIONAL_TOOLTIP = unvalued("hide_additional_tooltip");
|
||||
|
||||
/**
|
||||
* If set, it will completely hide whole item tooltip (that includes item name).
|
||||
*/
|
||||
public static final DataComponentType.NonValued HIDE_TOOLTIP = unvalued("hide_tooltip");
|
||||
|
||||
/**
|
||||
* Holds the instrument type used by a Goat Horn.
|
||||
*/
|
||||
public static final DataComponentType.Valued<MusicInstrument> INSTRUMENT = valued("instrument");
|
||||
|
||||
/**
|
||||
* Marks that a projectile item would be intangible when fired
|
||||
* (i.e. can only be picked up by a creative mode player).
|
||||
*/
|
||||
public static final DataComponentType.NonValued INTANGIBLE_PROJECTILE = unvalued("intangible_projectile");
|
||||
|
||||
public static final DataComponentType.Valued<Key> ITEM_MODEL = valued("item_model");
|
||||
|
||||
public static final DataComponentType.Valued<Component> CUSTOM_NAME = valued("custom_name");
|
||||
/**
|
||||
* When present, replaces default item name with contained chat component.
|
||||
* <p>
|
||||
@@ -228,100 +109,91 @@ public final class DataComponentTypes {
|
||||
* @see #CUSTOM_NAME
|
||||
*/
|
||||
public static final DataComponentType.Valued<Component> ITEM_NAME = valued("item_name");
|
||||
|
||||
public static final DataComponentType.Valued<JukeboxPlayable> JUKEBOX_PLAYABLE = valued("jukebox_playable");
|
||||
|
||||
/**
|
||||
* If present, specifies that the Compass is a Lodestone Compass.
|
||||
*/
|
||||
public static final DataComponentType.Valued<LodestoneTracker> LODESTONE_TRACKER = valued("lodestone_tracker");
|
||||
|
||||
public static final DataComponentType.Valued<Key> ITEM_MODEL = valued("item_model");
|
||||
/**
|
||||
* Additional lines to include in an item's tooltip.
|
||||
*/
|
||||
public static final DataComponentType.Valued<ItemLore> LORE = valued("lore");
|
||||
|
||||
/**
|
||||
* Represents the tint of the decorations on the {@link org.bukkit.inventory.ItemType#FILLED_MAP} item.
|
||||
*/
|
||||
public static final DataComponentType.Valued<MapItemColor> MAP_COLOR = valued("map_color");
|
||||
|
||||
/**
|
||||
* Holds a list of markers to be placed on a {@link org.bukkit.inventory.ItemType#FILLED_MAP} (used for Explorer Maps).
|
||||
*/
|
||||
public static final DataComponentType.Valued<MapDecorations> MAP_DECORATIONS = valued("map_decorations");
|
||||
|
||||
/**
|
||||
* References the shared map state holding map contents and markers for a {@link org.bukkit.inventory.ItemType#FILLED_MAP}.
|
||||
*/
|
||||
public static final DataComponentType.Valued<MapId> MAP_ID = valued("map_id");
|
||||
|
||||
/**
|
||||
* Internal map item state used in the map crafting recipe.
|
||||
*/
|
||||
public static final DataComponentType.Valued<MapPostProcessing> MAP_POST_PROCESSING = valued("map_post_processing");
|
||||
|
||||
/**
|
||||
* Controls the maximum amount of damage than an item can take,
|
||||
* if not present, the item cannot be damaged.
|
||||
* <br>
|
||||
* Mutually exclusive with the {@link #MAX_STACK_SIZE} component greater than 1.
|
||||
*
|
||||
* @see #DAMAGE
|
||||
*/
|
||||
public static final DataComponentType.Valued<@Positive Integer> MAX_DAMAGE = valued("max_damage");
|
||||
|
||||
/**
|
||||
* Controls the maximum stacking size of this item.
|
||||
* <br>
|
||||
* Values greater than 1 are mutually exclusive with the {@link #MAX_DAMAGE} component.
|
||||
*/
|
||||
public static final DataComponentType.Valued<Integer> MAX_STACK_SIZE = valued("max_stack_size");
|
||||
|
||||
/**
|
||||
* Controls the sound played by a Player Head when placed on a Note Block.
|
||||
*/
|
||||
public static final DataComponentType.Valued<Key> NOTE_BLOCK_SOUND = valued("note_block_sound");
|
||||
|
||||
/**
|
||||
* Controls the amplifier amount for an Ominous Bottle's Bad Omen effect.
|
||||
*/
|
||||
public static final DataComponentType.Valued<OminousBottleAmplifier> OMINOUS_BOTTLE_AMPLIFIER = valued("ominous_bottle_amplifier");
|
||||
|
||||
/**
|
||||
* Stores the Sherds applied to each side of a Decorated Pot.
|
||||
*/
|
||||
public static final DataComponentType.Valued<PotDecorations> POT_DECORATIONS = valued("pot_decorations");
|
||||
|
||||
/**
|
||||
* Holds the contents of a potion (Potion, Splash Potion, Lingering Potion),
|
||||
* or potion applied to a Tipped Arrow.
|
||||
*/
|
||||
public static final DataComponentType.Valued<PotionContents> POTION_CONTENTS = valued("potion_contents");
|
||||
|
||||
/**
|
||||
* Controls the skin displayed on a Player Head.
|
||||
*/
|
||||
public static final DataComponentType.Valued<ResolvableProfile> PROFILE = valued("profile");
|
||||
|
||||
/**
|
||||
* Controls the color of the item name.
|
||||
*/
|
||||
public static final DataComponentType.Valued<ItemRarity> RARITY = valued("rarity");
|
||||
|
||||
/**
|
||||
* List of recipes that should be unlocked when using the Knowledge Book item.
|
||||
* Controls the enchantments on an item.
|
||||
* <br>
|
||||
* If not present on a non-enchantment book, this item will not work in an anvil.
|
||||
*
|
||||
* @see #STORED_ENCHANTMENTS
|
||||
*/
|
||||
public static final DataComponentType.Valued<List<Key>> RECIPES = valued("recipes");
|
||||
|
||||
public static final DataComponentType.Valued<ItemEnchantments> ENCHANTMENTS = valued("enchantments");
|
||||
/**
|
||||
* Controls which blocks a player in Adventure mode can place on with this item.
|
||||
*/
|
||||
public static final DataComponentType.Valued<ItemAdventurePredicate> CAN_PLACE_ON = valued("can_place_on");
|
||||
/**
|
||||
* Controls which blocks a player in Adventure mode can break with this item.
|
||||
*/
|
||||
public static final DataComponentType.Valued<ItemAdventurePredicate> CAN_BREAK = valued("can_break");
|
||||
/**
|
||||
* Holds attribute modifiers applied to any item,
|
||||
* if not set, has an implicit default value based on the item type's
|
||||
* default attributes (e.g. attack damage for weapons).
|
||||
*/
|
||||
public static final DataComponentType.Valued<ItemAttributeModifiers> ATTRIBUTE_MODIFIERS = valued("attribute_modifiers");
|
||||
/**
|
||||
* Controls the minecraft:custom_model_data property in the item model.
|
||||
*/
|
||||
public static final DataComponentType.Valued<CustomModelData> CUSTOM_MODEL_DATA = valued("custom_model_data");
|
||||
/**
|
||||
* If set, disables 'additional' tooltip part which comes from the item type
|
||||
* (e.g. content of a shulker).
|
||||
*/
|
||||
public static final DataComponentType.NonValued HIDE_ADDITIONAL_TOOLTIP = unvalued("hide_additional_tooltip");
|
||||
/**
|
||||
* If set, it will completely hide whole item tooltip (that includes item name).
|
||||
*/
|
||||
public static final DataComponentType.NonValued HIDE_TOOLTIP = unvalued("hide_tooltip");
|
||||
/**
|
||||
* The additional experience cost required to modify an item in an Anvil.
|
||||
* If not present, has an implicit default value of: {@code 0}.
|
||||
*/
|
||||
public static final DataComponentType.Valued<@NonNegative Integer> REPAIR_COST = valued("repair_cost");
|
||||
|
||||
// /**
|
||||
// * Causes an item to not be pickable in the creative menu, currently not very useful.
|
||||
// */
|
||||
// public static final DataComponentType.NonValued CREATIVE_SLOT_LOCK = unvalued("creative_slot_lock");
|
||||
/**
|
||||
* Overrides the enchantment glint effect on an item.
|
||||
* If not present, default behaviour is used.
|
||||
*/
|
||||
public static final DataComponentType.Valued<Boolean> ENCHANTMENT_GLINT_OVERRIDE = valued("enchantment_glint_override");
|
||||
/**
|
||||
* Marks that a projectile item would be intangible when fired
|
||||
* (i.e. can only be picked up by a creative mode player).
|
||||
*/
|
||||
public static final DataComponentType.NonValued INTANGIBLE_PROJECTILE = unvalued("intangible_projectile");
|
||||
/**
|
||||
* Controls potential food benefits gained when consuming the item the component is applied on.
|
||||
* Requires the {@link #CONSUMABLE} component to allow consumption in the first place.
|
||||
*/
|
||||
public static final DataComponentType.Valued<FoodProperties> FOOD = valued("food");
|
||||
public static final DataComponentType.Valued<Consumable> CONSUMABLE = valued("consumable");
|
||||
public static final DataComponentType.Valued<UseRemainder> USE_REMAINDER = valued("use_remainder");
|
||||
public static final DataComponentType.Valued<UseCooldown> USE_COOLDOWN = valued("use_cooldown");
|
||||
/**
|
||||
* If present, this item will not take damage from the specified damage types.
|
||||
*/
|
||||
public static final DataComponentType.Valued<DamageResistant> DAMAGE_RESISTANT = valued("damage_resistant");
|
||||
/**
|
||||
* Controls the behavior of the item as a tool.
|
||||
*/
|
||||
public static final DataComponentType.Valued<Tool> TOOL = valued("tool");
|
||||
public static final DataComponentType.Valued<Enchantable> ENCHANTABLE = valued("enchantable");
|
||||
public static final DataComponentType.Valued<Equippable> EQUIPPABLE = valued("equippable");
|
||||
public static final DataComponentType.Valued<Repairable> REPAIRABLE = valued("repairable");
|
||||
|
||||
public static final DataComponentType.NonValued GLIDER = unvalued("glider");
|
||||
public static final DataComponentType.Valued<Key> TOOLTIP_STYLE = valued("tooltip_style");
|
||||
public static final DataComponentType.Valued<DeathProtection> DEATH_PROTECTION = valued("death_protection");
|
||||
/**
|
||||
* Stores list of enchantments and their levels for an Enchanted Book.
|
||||
* Unlike {@link #ENCHANTMENTS}, the effects provided by enchantments
|
||||
@@ -336,51 +208,114 @@ public final class DataComponentTypes {
|
||||
* @see #ENCHANTMENTS
|
||||
*/
|
||||
public static final DataComponentType.Valued<ItemEnchantments> STORED_ENCHANTMENTS = valued("stored_enchantments");
|
||||
|
||||
/**
|
||||
* Represents a color applied to a dyeable item (in the {@link io.papermc.paper.registry.keys.tags.ItemTypeTagKeys#DYEABLE} item tag).
|
||||
*/
|
||||
public static final DataComponentType.Valued<DyedItemColor> DYED_COLOR = valued("dyed_color");
|
||||
/**
|
||||
* Represents the tint of the decorations on the {@link org.bukkit.inventory.ItemType#FILLED_MAP} item.
|
||||
*/
|
||||
public static final DataComponentType.Valued<MapItemColor> MAP_COLOR = valued("map_color");
|
||||
/**
|
||||
* References the shared map state holding map contents and markers for a {@link org.bukkit.inventory.ItemType#FILLED_MAP}.
|
||||
*/
|
||||
public static final DataComponentType.Valued<MapId> MAP_ID = valued("map_id");
|
||||
/**
|
||||
* Holds a list of markers to be placed on a {@link org.bukkit.inventory.ItemType#FILLED_MAP} (used for Explorer Maps).
|
||||
*/
|
||||
public static final DataComponentType.Valued<MapDecorations> MAP_DECORATIONS = valued("map_decorations");
|
||||
/**
|
||||
* Internal map item state used in the map crafting recipe.
|
||||
*/
|
||||
public static final DataComponentType.Valued<MapPostProcessing> MAP_POST_PROCESSING = valued("map_post_processing");
|
||||
/**
|
||||
* Holds all projectiles that have been loaded into a Crossbow.
|
||||
* If not present, the Crossbow is not charged.
|
||||
*/
|
||||
public static final DataComponentType.Valued<ChargedProjectiles> CHARGED_PROJECTILES = valued("charged_projectiles");
|
||||
/**
|
||||
* Holds all items stored inside a Bundle.
|
||||
* If removed, items cannot be added to the Bundle.
|
||||
*/
|
||||
public static final DataComponentType.Valued<BundleContents> BUNDLE_CONTENTS = valued("bundle_contents");
|
||||
/**
|
||||
* Holds the contents of a potion (Potion, Splash Potion, Lingering Potion),
|
||||
* or potion applied to a Tipped Arrow.
|
||||
*/
|
||||
public static final DataComponentType.Valued<PotionContents> POTION_CONTENTS = valued("potion_contents");
|
||||
/**
|
||||
* Holds the effects that will be applied when consuming Suspicious Stew.
|
||||
*/
|
||||
public static final DataComponentType.Valued<SuspiciousStewEffects> SUSPICIOUS_STEW_EFFECTS = valued("suspicious_stew_effects");
|
||||
|
||||
/**
|
||||
* Controls the behavior of the item as a tool.
|
||||
*/
|
||||
public static final DataComponentType.Valued<Tool> TOOL = valued("tool");
|
||||
|
||||
public static final DataComponentType.Valued<Key> TOOLTIP_STYLE = valued("tooltip_style");
|
||||
|
||||
/**
|
||||
* Holds the trims applied to an item in recipes
|
||||
*/
|
||||
public static final DataComponentType.Valued<ItemArmorTrim> TRIM = valued("trim");
|
||||
|
||||
/**
|
||||
* If set, the item will not lose any durability when used.
|
||||
*/
|
||||
public static final DataComponentType.Valued<Unbreakable> UNBREAKABLE = valued("unbreakable");
|
||||
|
||||
public static final DataComponentType.Valued<UseCooldown> USE_COOLDOWN = valued("use_cooldown");
|
||||
|
||||
public static final DataComponentType.Valued<UseRemainder> USE_REMAINDER = valued("use_remainder");
|
||||
|
||||
/**
|
||||
* Holds the contents in a Book and Quill.
|
||||
*/
|
||||
public static final DataComponentType.Valued<WritableBookContent> WRITABLE_BOOK_CONTENT = valued("writable_book_content");
|
||||
|
||||
/**
|
||||
* Holds the contents and metadata of a Written Book.
|
||||
*/
|
||||
public static final DataComponentType.Valued<WrittenBookContent> WRITTEN_BOOK_CONTENT = valued("written_book_content");
|
||||
// End generate - DataComponentTypes
|
||||
// /**
|
||||
// * Causes an item to not be pickable in the creative menu, currently not very useful.
|
||||
// */
|
||||
// public static final DataComponentType.NonValued CREATIVE_SLOT_LOCK = unvalued("creative_slot_lock");
|
||||
/**
|
||||
* Holds the trims applied to an item in recipes
|
||||
*/
|
||||
public static final DataComponentType.Valued<ItemArmorTrim> TRIM = valued("trim");
|
||||
// debug_stick_state - Block Property API
|
||||
// entity_data
|
||||
// bucket_entity_data
|
||||
// block_entity_data
|
||||
/**
|
||||
* Holds the instrument type used by a Goat Horn.
|
||||
*/
|
||||
public static final DataComponentType.Valued<MusicInstrument> INSTRUMENT = valued("instrument");
|
||||
/**
|
||||
* Controls the amplifier amount for an Ominous Bottle's Bad Omen effect.
|
||||
*/
|
||||
public static final DataComponentType.Valued<OminousBottleAmplifier> OMINOUS_BOTTLE_AMPLIFIER = valued("ominous_bottle_amplifier");
|
||||
public static final DataComponentType.Valued<JukeboxPlayable> JUKEBOX_PLAYABLE = valued("jukebox_playable");
|
||||
/**
|
||||
* List of recipes that should be unlocked when using the Knowledge Book item.
|
||||
*/
|
||||
public static final DataComponentType.Valued<List<Key>> RECIPES = valued("recipes");
|
||||
/**
|
||||
* If present, specifies that the Compass is a Lodestone Compass.
|
||||
*/
|
||||
public static final DataComponentType.Valued<LodestoneTracker> LODESTONE_TRACKER = valued("lodestone_tracker");
|
||||
/**
|
||||
* Stores the explosion crafted in a Firework Star.
|
||||
*/
|
||||
public static final DataComponentType.Valued<FireworkEffect> FIREWORK_EXPLOSION = valued("firework_explosion");
|
||||
/**
|
||||
* Stores all explosions crafted into a Firework Rocket, as well as flight duration.
|
||||
*/
|
||||
public static final DataComponentType.Valued<Fireworks> FIREWORKS = valued("fireworks");
|
||||
/**
|
||||
* Controls the skin displayed on a Player Head.
|
||||
*/
|
||||
public static final DataComponentType.Valued<ResolvableProfile> PROFILE = valued("profile");
|
||||
/**
|
||||
* Controls the sound played by a Player Head when placed on a Note Block.
|
||||
*/
|
||||
public static final DataComponentType.Valued<Key> NOTE_BLOCK_SOUND = valued("note_block_sound");
|
||||
/**
|
||||
* Stores the additional patterns applied to a Banner or Shield.
|
||||
*/
|
||||
public static final DataComponentType.Valued<BannerPatternLayers> BANNER_PATTERNS = valued("banner_patterns");
|
||||
/**
|
||||
* Stores the base color for a Shield.
|
||||
*/
|
||||
public static final DataComponentType.Valued<DyeColor> BASE_COLOR = valued("base_color");
|
||||
/**
|
||||
* Stores the Sherds applied to each side of a Decorated Pot.
|
||||
*/
|
||||
public static final DataComponentType.Valued<PotDecorations> POT_DECORATIONS = valued("pot_decorations");
|
||||
/**
|
||||
* Holds the contents of container blocks (Chests, Shulker Boxes) in item form.
|
||||
*/
|
||||
public static final DataComponentType.Valued<ItemContainerContents> CONTAINER = valued("container");
|
||||
/**
|
||||
* Holds block state properties to apply when placing a block.
|
||||
*/
|
||||
public static final DataComponentType.Valued<BlockItemDataProperties> BLOCK_DATA = valued("block_state");
|
||||
// bees
|
||||
// /**
|
||||
// * Holds the lock state of a container-like block,
|
||||
@@ -390,6 +325,10 @@ public final class DataComponentTypes {
|
||||
// * to open this container.
|
||||
// */
|
||||
// public static final DataComponentType.Valued<LockCode> LOCK = valued("lock");
|
||||
/**
|
||||
* Holds the unresolved loot table and seed of a container-like block.
|
||||
*/
|
||||
public static final DataComponentType.Valued<SeededContainerLoot> CONTAINER_LOOT = valued("container_loot");
|
||||
|
||||
private static DataComponentType.NonValued unvalued(final String name) {
|
||||
return (DataComponentType.NonValued) requireNonNull(Registry.DATA_COMPONENT_TYPE.get(NamespacedKey.minecraft(name)), name + " unvalued data component type couldn't be found, this is a bug.");
|
||||
|
||||
@@ -21,9 +21,9 @@ public interface DamageResistant {
|
||||
}
|
||||
|
||||
/**
|
||||
* The types that this damage type is invincible to.
|
||||
* The types that this damage type is invincible tp.
|
||||
*
|
||||
* @return the key of the tag holding the respective damage types.
|
||||
* @return item
|
||||
*/
|
||||
@Contract(value = "-> new", pure = true)
|
||||
TagKey<DamageType> types();
|
||||
|
||||
+18
-21
@@ -21,7 +21,7 @@ public interface ConsumeEffect {
|
||||
* Creates a consume effect that randomly teleports the entity on consumption.
|
||||
*
|
||||
* @param diameter diameter of random teleportation
|
||||
* @return the effect instance
|
||||
* @return the effect
|
||||
*/
|
||||
@Contract(value = "_ -> new", pure = true)
|
||||
static TeleportRandomly teleportRandomlyEffect(final float diameter) {
|
||||
@@ -29,21 +29,21 @@ public interface ConsumeEffect {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a consume effect that removes status effects on consumption.
|
||||
* Creates a consume effect that gives status effects on consumption.
|
||||
*
|
||||
* @param effects the potion effects to remove
|
||||
* @return the effect instance
|
||||
* @param key the sound effect to play
|
||||
* @return the effect
|
||||
*/
|
||||
@Contract(value = "_ -> new", pure = true)
|
||||
static RemoveStatusEffects removeEffects(final RegistryKeySet<PotionEffectType> effects) {
|
||||
return ConsumableTypesBridge.bridge().removeStatusEffects(effects);
|
||||
static RemoveStatusEffects removeEffects(final RegistryKeySet<PotionEffectType> key) {
|
||||
return ConsumableTypesBridge.bridge().removeStatusEffects(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a consume effect that plays a sound on consumption.
|
||||
*
|
||||
* @param key the key sound effect to play
|
||||
* @return the effect instance
|
||||
* @param key the sound effect to play
|
||||
* @return the effect
|
||||
*/
|
||||
@Contract(value = "_ -> new", pure = true)
|
||||
static PlaySound playSoundConsumeEffect(final Key key) {
|
||||
@@ -53,7 +53,7 @@ public interface ConsumeEffect {
|
||||
/**
|
||||
* Creates a consume effect that clears all status effects.
|
||||
*
|
||||
* @return the effect instance
|
||||
* @return effect instance
|
||||
*/
|
||||
@Contract(value = "-> new", pure = true)
|
||||
static ClearAllStatusEffects clearAllStatusEffects() {
|
||||
@@ -61,20 +61,17 @@ public interface ConsumeEffect {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a consume effect that gives potion effects on consumption.
|
||||
* Creates a consume effect that gives status effects on consumption.
|
||||
*
|
||||
* @param effects the potion effects to apply
|
||||
* @param probability the probability of these effects being applied, between 0 and 1 inclusive
|
||||
* @return the effect instance
|
||||
* @param probability the probability of these effects being applied, between 0 and 1 inclusive.
|
||||
* @return the effect
|
||||
*/
|
||||
@Contract(value = "_, _ -> new", pure = true)
|
||||
static ApplyStatusEffects applyStatusEffects(final List<PotionEffect> effects, final float probability) {
|
||||
return ConsumableTypesBridge.bridge().applyStatusEffects(effects, probability);
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a consumable effect that randomly teleports the entity on consumption.
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
@ApiStatus.NonExtendable
|
||||
interface TeleportRandomly extends ConsumeEffect {
|
||||
@@ -88,14 +85,14 @@ public interface ConsumeEffect {
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a consumable effect that removes status effects on consumption.
|
||||
* Represents a consumable effect that removes status effects on consumption
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
@ApiStatus.NonExtendable
|
||||
interface RemoveStatusEffects extends ConsumeEffect {
|
||||
|
||||
/**
|
||||
* Potion effects to remove.
|
||||
* Potion effects to remove
|
||||
*
|
||||
* @return effects
|
||||
*/
|
||||
@@ -110,7 +107,7 @@ public interface ConsumeEffect {
|
||||
interface PlaySound extends ConsumeEffect {
|
||||
|
||||
/**
|
||||
* Sound effect to play in the world.
|
||||
* Sound effect to play in the world
|
||||
*
|
||||
* @return sound effect
|
||||
*/
|
||||
@@ -127,16 +124,16 @@ public interface ConsumeEffect {
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a consumable effect that applies potion effects based on a probability on consumption.
|
||||
* Represents a consumable effect that applies effects based on a probability on consumption.
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
@ApiStatus.NonExtendable
|
||||
interface ApplyStatusEffects extends ConsumeEffect {
|
||||
|
||||
/**
|
||||
* Potion effect instances to grant.
|
||||
* Effect instances to grant
|
||||
*
|
||||
* @return potion effects
|
||||
* @return effect
|
||||
*/
|
||||
List<PotionEffect> effects();
|
||||
|
||||
|
||||
+1
-4
@@ -4,8 +4,6 @@ package io.papermc.paper.datacomponent.item.consumable;
|
||||
* Represents the hand animation that is used when a player is consuming this item.
|
||||
*/
|
||||
public enum ItemUseAnimation {
|
||||
// Start generate - ItemUseAnimation
|
||||
// @GeneratedFrom 1.21.4
|
||||
NONE,
|
||||
EAT,
|
||||
DRINK,
|
||||
@@ -16,6 +14,5 @@ public enum ItemUseAnimation {
|
||||
SPYGLASS,
|
||||
TOOT_HORN,
|
||||
BRUSH,
|
||||
BUNDLE;
|
||||
// End generate - ItemUseAnimation
|
||||
BUNDLE
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package io.papermc.paper.datapack;
|
||||
|
||||
import java.util.Set;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.bukkit.FeatureFlag;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
@@ -10,8 +12,50 @@ import org.jspecify.annotations.NullMarked;
|
||||
* won't be updated as datapacks are updated.
|
||||
*/
|
||||
@NullMarked
|
||||
@ApiStatus.NonExtendable
|
||||
public interface Datapack extends DiscoveredDatapack {
|
||||
public interface Datapack {
|
||||
|
||||
/**
|
||||
* Gets the name/id of this datapack.
|
||||
*
|
||||
* @return the name of the pack
|
||||
*/
|
||||
@Contract(pure = true)
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Gets the title component of this datapack.
|
||||
*
|
||||
* @return the title
|
||||
*/
|
||||
Component getTitle();
|
||||
|
||||
/**
|
||||
* Gets the description component of this datapack.
|
||||
*
|
||||
* @return the description
|
||||
*/
|
||||
Component getDescription();
|
||||
|
||||
/**
|
||||
* Gets if this datapack is required to be enabled.
|
||||
*
|
||||
* @return true if the pack is required
|
||||
*/
|
||||
boolean isRequired();
|
||||
|
||||
/**
|
||||
* Gets the compatibility status of this pack.
|
||||
*
|
||||
* @return the compatibility of the pack
|
||||
*/
|
||||
Compatibility getCompatibility();
|
||||
|
||||
/**
|
||||
* Gets the set of required features for this datapack.
|
||||
*
|
||||
* @return the set of required features
|
||||
*/
|
||||
@Unmodifiable Set<FeatureFlag> getRequiredFeatures();
|
||||
|
||||
/**
|
||||
* Gets the enabled state of this pack.
|
||||
@@ -30,6 +74,13 @@ public interface Datapack extends DiscoveredDatapack {
|
||||
*/
|
||||
void setEnabled(boolean enabled);
|
||||
|
||||
/**
|
||||
* Gets the source for this datapack.
|
||||
*
|
||||
* @return the pack source
|
||||
*/
|
||||
DatapackSource getSource();
|
||||
|
||||
/**
|
||||
* Computes the component vanilla Minecraft uses
|
||||
* to display this datapack. Includes the {@link #getSource()},
|
||||
@@ -45,11 +96,4 @@ public interface Datapack extends DiscoveredDatapack {
|
||||
TOO_NEW,
|
||||
COMPATIBLE,
|
||||
}
|
||||
|
||||
/**
|
||||
* Position of the pack in the load order.
|
||||
*/
|
||||
enum Position {
|
||||
TOP, BOTTOM
|
||||
}
|
||||
}
|
||||
@@ -1,205 +0,0 @@
|
||||
package io.papermc.paper.datapack;
|
||||
|
||||
import io.papermc.paper.plugin.configuration.PluginMeta;
|
||||
import io.papermc.paper.plugin.lifecycle.event.registrar.Registrar;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* The registrar for datapacks. The event for this registrar
|
||||
* is called anytime the game tries to discover datapacks at any of the
|
||||
* configured locations. This means that if a datapack should stay available to the server,
|
||||
* it must always be discovered whenever this event fires.
|
||||
* <p>
|
||||
* An example of a plugin loading a datapack from within its own jar is below,
|
||||
* assuming the datapack is included under {@code resources/pack} folder:
|
||||
* <pre>{@code
|
||||
* public class YourPluginBootstrap implements PluginBootstrap {
|
||||
* @Override
|
||||
* public void bootstrap(BootstrapContext context) {
|
||||
* final LifecycleEventManager<BootstrapContext> manager = context.getLifecycleManager();
|
||||
* manager.registerEventHandler(LifecycleEvents.DATAPACK_DISCOVERY, event -> {
|
||||
* DatapackRegistrar registrar = event.registrar();
|
||||
* try {
|
||||
* final URI uri = Objects.requireNonNull(
|
||||
* YourPluginBootstrap.class.getResource("/pack")
|
||||
* ).toURI();
|
||||
* registrar.discoverPack(uri, "packId");
|
||||
* } catch (final URISyntaxException | IOException e) {
|
||||
* throw new RuntimeException(e);
|
||||
* }
|
||||
* });
|
||||
* }
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
* @see io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents#DATAPACK_DISCOVERY
|
||||
*/
|
||||
@ApiStatus.NonExtendable
|
||||
@ApiStatus.Experimental
|
||||
@NullMarked
|
||||
public interface DatapackRegistrar extends Registrar {
|
||||
|
||||
/**
|
||||
* Checks if a datapack with the specified name has been discovered.
|
||||
*
|
||||
* @param name the name of the pack
|
||||
* @return true if the pack has been discovered
|
||||
* @see Datapack#getName()
|
||||
*/
|
||||
@Contract(pure = true)
|
||||
boolean hasPackDiscovered(String name);
|
||||
|
||||
/**
|
||||
* Gets a discovered datapack by its name.
|
||||
*
|
||||
* @param name the name of the pack
|
||||
* @return the datapack
|
||||
* @throws java.util.NoSuchElementException if the pack is not discovered
|
||||
* @see Datapack#getName()
|
||||
*/
|
||||
@Contract(pure = true)
|
||||
DiscoveredDatapack getDiscoveredPack(String name);
|
||||
|
||||
/**
|
||||
* Removes a discovered datapack by its name.
|
||||
*
|
||||
* @param name the name of the pack
|
||||
* @return true if the pack was removed
|
||||
* @see Datapack#getName()
|
||||
*/
|
||||
@Contract(mutates = "this")
|
||||
boolean removeDiscoveredPack(String name);
|
||||
|
||||
/**
|
||||
* Gets all discovered datapacks.
|
||||
*
|
||||
* @return an unmodifiable map of discovered packs
|
||||
*/
|
||||
@Contract(pure = true)
|
||||
@Unmodifiable Map<String, DiscoveredDatapack> getDiscoveredPacks();
|
||||
|
||||
/**
|
||||
* Discovers a datapack at the specified {@link URI} with the id.
|
||||
* <p>Symlinks obey the {@code allowed_symlinks.txt} in the server root directory.</p>
|
||||
*
|
||||
* @param uri the location of the pack
|
||||
* @param id a unique id (will be combined with plugin for the datapacks name)
|
||||
* @return the discovered datapack (or null if it failed)
|
||||
* @throws IOException if any IO error occurs
|
||||
*/
|
||||
default @Nullable DiscoveredDatapack discoverPack(final URI uri, final String id) throws IOException {
|
||||
return this.discoverPack(uri, id, c -> {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Discovers a datapack at the specified {@link URI} with the id.
|
||||
* <p>Symlinks obey the {@code allowed_symlinks.txt} in the server root directory.</p>
|
||||
*
|
||||
* @param uri the location of the pack
|
||||
* @param id a unique id (will be combined with plugin for the datapacks name)
|
||||
* @param configurer a configurer for extra options
|
||||
* @return the discovered datapack (or null if it failed)
|
||||
* @throws IOException if any IO error occurs
|
||||
*/
|
||||
@Nullable DiscoveredDatapack discoverPack(URI uri, String id, Consumer<Configurer> configurer) throws IOException;
|
||||
|
||||
/**
|
||||
* Discovers a datapack at the specified {@link Path} with the id.
|
||||
* <p>Symlinks obey the {@code allowed_symlinks.txt} in the server root directory.</p>
|
||||
*
|
||||
* @param path the location of the pack
|
||||
* @param id a unique id (will be combined with plugin for the datapacks name)
|
||||
* @return the discovered datapack (or null if it failed)
|
||||
* @throws IOException if any IO error occurs
|
||||
*/
|
||||
default @Nullable DiscoveredDatapack discoverPack(final Path path, final String id) throws IOException {
|
||||
return this.discoverPack(path, id, c -> {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Discovers a datapack at the specified {@link Path} with the id.
|
||||
* <p>Symlinks obey the {@code allowed_symlinks.txt} in the server root directory.</p>
|
||||
*
|
||||
* @param path the location of the pack
|
||||
* @param id a unique id (will be combined with plugin for the datapacks name)
|
||||
* @param configurer a configurer for extra options
|
||||
* @return the discovered datapack (or null if it failed)
|
||||
* @throws IOException if any IO error occurs
|
||||
*/
|
||||
@Nullable DiscoveredDatapack discoverPack(Path path, String id, Consumer<Configurer> configurer) throws IOException;
|
||||
|
||||
/**
|
||||
* Discovers a datapack at the specified {@link URI} with the id.
|
||||
* <p>Symlinks obey the {@code allowed_symlinks.txt} in the server root directory.</p>
|
||||
*
|
||||
* @param pluginMeta the plugin which will be the "owner" of this datapack
|
||||
* @param uri the location of the pack
|
||||
* @param id a unique id (will be combined with plugin for the datapacks name)
|
||||
* @param configurer a configurer for extra options
|
||||
* @return the discovered datapack (or null if it failed)
|
||||
* @throws IOException if any IO error occurs
|
||||
*/
|
||||
@Nullable DiscoveredDatapack discoverPack(PluginMeta pluginMeta, URI uri, String id, Consumer<Configurer> configurer) throws IOException;
|
||||
|
||||
/**
|
||||
* Discovers a datapack at the specified {@link Path} with the id.
|
||||
* <p>Symlinks obey the {@code allowed_symlinks.txt} in the server root directory.</p>
|
||||
*
|
||||
* @param pluginMeta the plugin which will be the "owner" of this datapack
|
||||
* @param path the location of the pack
|
||||
* @param id a unique id (will be combined with plugin for the datapacks name)
|
||||
* @param configurer a configurer for extra options
|
||||
* @return the discovered datapack (or null if it failed)
|
||||
* @throws IOException if any IO error occurs
|
||||
*/
|
||||
@Nullable DiscoveredDatapack discoverPack(PluginMeta pluginMeta, Path path, String id, Consumer<Configurer> configurer) throws IOException;
|
||||
|
||||
/**
|
||||
* Configures additional, optional, details about a datapack.
|
||||
*/
|
||||
@ApiStatus.NonExtendable
|
||||
@ApiStatus.Experimental
|
||||
interface Configurer {
|
||||
|
||||
/**
|
||||
* Changes the title of the datapack from the default which
|
||||
* is just the "id" in the {@code registerPack} methods.
|
||||
*
|
||||
* @param title the new title
|
||||
* @return the configurer for chaining
|
||||
*/
|
||||
@Contract(value = "_ -> this", mutates = "this")
|
||||
Configurer title(Component title);
|
||||
|
||||
/**
|
||||
* Sets whether this pack is going to be automatically enabled on server starts even if previously disabled.
|
||||
* Defaults to false.
|
||||
*
|
||||
* @param autoEnableOnServerStart true to ensure the pack is enabled on server starts.
|
||||
* @return the configurer for chaining
|
||||
*/
|
||||
@Contract(value = "_ -> this", mutates = "this")
|
||||
Configurer autoEnableOnServerStart(boolean autoEnableOnServerStart);
|
||||
|
||||
/**
|
||||
* Configures the position in the
|
||||
* load order of this datapack.
|
||||
*
|
||||
* @param fixed won't move around in the load order as packs are added/removed
|
||||
* @param position try to insert at the top of the order or bottom
|
||||
* @return the configurer for chaining
|
||||
*/
|
||||
@Contract(value = "_, _ -> this", mutates = "this")
|
||||
Configurer position(boolean fixed, Datapack.Position position);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ public sealed interface DatapackSource permits DatapackSourceImpl {
|
||||
DatapackSource FEATURE = create("feature");
|
||||
DatapackSource WORLD = create("world");
|
||||
DatapackSource SERVER = create("server");
|
||||
DatapackSource PLUGIN = create("plugin");
|
||||
|
||||
private static DatapackSource create(final String name) {
|
||||
return new DatapackSourceImpl(name);
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
package io.papermc.paper.datapack;
|
||||
|
||||
import java.util.Set;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.FeatureFlag;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Represents a snapshot of a datapack that the server has found by
|
||||
* searching available sources. It may or may not be enabled and isn't
|
||||
* guaranteed to be available. This object won't be
|
||||
* updated as datapacks are updated.
|
||||
* @see DatapackRegistrar
|
||||
*/
|
||||
@NullMarked
|
||||
@ApiStatus.NonExtendable
|
||||
public interface DiscoveredDatapack {
|
||||
|
||||
/**
|
||||
* Gets the name/id of this datapack.
|
||||
*
|
||||
* @return the name of the pack
|
||||
*/
|
||||
@Contract(pure = true)
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Gets the title component of this datapack.
|
||||
*
|
||||
* @return the title
|
||||
*/
|
||||
Component getTitle();
|
||||
|
||||
/**
|
||||
* Gets the description component of this datapack.
|
||||
*
|
||||
* @return the description
|
||||
*/
|
||||
Component getDescription();
|
||||
|
||||
/**
|
||||
* Gets if this datapack is required.
|
||||
* <p>
|
||||
* A "required" datapack will always be enabled on server startup, even if previously disabled.
|
||||
*
|
||||
* @return true if the pack is required
|
||||
*/
|
||||
boolean isRequired();
|
||||
|
||||
/**
|
||||
* Gets the compatibility status of this pack.
|
||||
*
|
||||
* @return the compatibility of the pack
|
||||
*/
|
||||
Datapack.Compatibility getCompatibility();
|
||||
|
||||
/**
|
||||
* Gets the set of required features for this datapack.
|
||||
*
|
||||
* @return the set of required features
|
||||
*/
|
||||
@Unmodifiable
|
||||
Set<FeatureFlag> getRequiredFeatures();
|
||||
|
||||
/**
|
||||
* Gets the source for this datapack.
|
||||
*
|
||||
* @return the pack source
|
||||
*/
|
||||
DatapackSource getSource();
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package io.papermc.paper.entity;
|
||||
|
||||
import org.bukkit.UnsafeValues;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Represents flags for entity serialization.
|
||||
*
|
||||
* @see UnsafeValues#serializeEntity(Entity, EntitySerializationFlag... serializationFlags)
|
||||
* @since 1.21.4
|
||||
*/
|
||||
public enum EntitySerializationFlag {
|
||||
|
||||
/**
|
||||
* Serialize entities that wouldn't be serialized normally
|
||||
* (e.g. dead, despawned, non-persistent, etc.).
|
||||
*
|
||||
* @see Entity#isValid()
|
||||
* @see Entity#isPersistent()
|
||||
*/
|
||||
FORCE,
|
||||
/**
|
||||
* Serialize misc non-saveable entities like lighting bolts, fishing bobbers, etc.
|
||||
* <br>Note: players require a separate flag: {@link #PLAYER}.
|
||||
*/
|
||||
MISC,
|
||||
/**
|
||||
* Include passengers in the serialized data.
|
||||
*/
|
||||
PASSENGERS,
|
||||
/**
|
||||
* Allow serializing {@link Player}s.
|
||||
* <p>Note: deserializing player data will always fail.
|
||||
*/
|
||||
PLAYER
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package io.papermc.paper.entity;
|
||||
|
||||
import java.util.Collection;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* A result type used by {@link org.bukkit.entity.Player#give(ItemStack...)} and its overloads.
|
||||
*/
|
||||
@NullMarked
|
||||
public interface PlayerGiveResult {
|
||||
|
||||
/**
|
||||
* A collection of itemstacks that were not added to the player's inventory as they did not fit.
|
||||
* The collection is derived from the collections of items to add by creating copies of each stack that was not
|
||||
* fully added to the inventory and assigning the non-added count as their amount.
|
||||
* <p>
|
||||
* Itemstacks found here *may* also be found as item entities in the {@link #drops()} collection, as the
|
||||
* give logic may have dropped them.
|
||||
*
|
||||
* @return the unmodifiable collection of itemstacks that are leftover as they could not be added. Each element is a
|
||||
* copy of the input stack they are derived from.
|
||||
*/
|
||||
@Unmodifiable
|
||||
Collection<ItemStack> leftovers();
|
||||
|
||||
/**
|
||||
* A collection of item entities dropped as a result of this call to {@link org.bukkit.entity.Player#give(ItemStack...)}.
|
||||
* The item entities contained here are not guaranteed to match the {@link #leftovers()} as plugins may cancel the
|
||||
* spawning of item entities.
|
||||
*
|
||||
* @return the unmodifiable collection of dropped item entities.
|
||||
*/
|
||||
@Unmodifiable
|
||||
Collection<Item> drops();
|
||||
|
||||
}
|
||||
@@ -12,10 +12,10 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called when a player uses shears on a block.
|
||||
* Called when a player uses sheers on a block.
|
||||
* <p>
|
||||
* This event is <b>not</b> called when a player breaks blocks with shears, but rather when a
|
||||
* player uses the shears on a block to collect drops from it and/or modify its state.
|
||||
* This event is <b>not</b> called when breaking blocks with shears but instead only when a
|
||||
* player uses the sheer item on a block to garner drops from said block and/or change its state.
|
||||
* <p>
|
||||
* Examples include shearing a pumpkin to turn it into a carved pumpkin or shearing a beehive to get honeycomb.
|
||||
*/
|
||||
|
||||
-103
@@ -1,103 +0,0 @@
|
||||
package io.papermc.paper.event.entity;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called when an entity attempts to perform a smash attack.
|
||||
*/
|
||||
@NullMarked
|
||||
public class EntityAttemptSmashAttackEvent extends EntityEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final LivingEntity target;
|
||||
private final ItemStack weapon;
|
||||
private final boolean originalResult;
|
||||
private Result result = Result.DEFAULT;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public EntityAttemptSmashAttackEvent(
|
||||
final LivingEntity attacker,
|
||||
final LivingEntity target,
|
||||
final ItemStack weapon,
|
||||
final boolean originalResult
|
||||
) {
|
||||
super(attacker);
|
||||
this.target = target;
|
||||
this.weapon = weapon;
|
||||
this.originalResult = originalResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Yields the target of the attempted smash attack.
|
||||
*
|
||||
* @return the target entity
|
||||
*/
|
||||
public LivingEntity getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Yields a copy of the itemstack used in the smash attack attempt.
|
||||
*
|
||||
* @return the itemstack
|
||||
*/
|
||||
public ItemStack getWeapon() {
|
||||
return weapon.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Yields the original result the server computed.
|
||||
*
|
||||
* @return {@code true} if this attempt would have been successful by vanilla's logic, {@code false} otherwise.
|
||||
*/
|
||||
public boolean getOriginalResult() {
|
||||
return originalResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Yields the effective result of this event.
|
||||
* The result may take one of three values:
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@link Result#ALLOW}: The attempt will succeed.</li>
|
||||
* <li>{@link Result#DENY}: The attempt will fail.</li>
|
||||
* <li>{@link Result#DEFAULT}: The attempt will succeed if {@link #getOriginalResult()} is {@code true} and fail otherwise.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @return the result.
|
||||
*/
|
||||
public Result getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures a new result for this event.
|
||||
* The passes result may take one of three values:
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@link Result#ALLOW}: The attempt will succeed.</li>
|
||||
* <li>{@link Result#DENY}: The attempt will fail.</li>
|
||||
* <li>{@link Result#DEFAULT}: The attempt will succeed if {@link #getOriginalResult()} is {@code true} and fail otherwise.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param result the new result of the event.
|
||||
*/
|
||||
public void setResult(final Result result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package io.papermc.paper.event.entity;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* An event that is triggered when an entity receives a potion effect instantly
|
||||
* or when the potion effect is applied on each tick (e.g. every 25 ticks for Poison level 1).
|
||||
* <p>
|
||||
* For example, this event may be called when an entity regenerates health
|
||||
* or takes poison damage as a result of a potion effect.
|
||||
*/
|
||||
@NullMarked
|
||||
public class EntityEffectTickEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final PotionEffectType type;
|
||||
private final int amplifier;
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public EntityEffectTickEvent(final LivingEntity entity, final PotionEffectType type, final int amplifier) {
|
||||
super(entity);
|
||||
this.type = type;
|
||||
this.amplifier = amplifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LivingEntity getEntity() {
|
||||
return (LivingEntity) super.getEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type of the potion effect associated with this event.
|
||||
*
|
||||
* @return the {@link PotionEffectType} of the effect
|
||||
*/
|
||||
public PotionEffectType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the amplifier level of the potion effect associated with this event.
|
||||
*
|
||||
* @return the amplifier level of the potion effect
|
||||
*/
|
||||
public int getAmplifier() {
|
||||
return amplifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
-89
@@ -1,89 +0,0 @@
|
||||
package io.papermc.paper.event.entity;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called whenever a change to an entity's equipment has been detected. This event is called after effects from
|
||||
* attribute modifiers and enchantments have been updated.
|
||||
* <p>
|
||||
* Examples of actions that can trigger this event:
|
||||
* <ul>
|
||||
* <li>An entity being added to a world.</li>
|
||||
* <li>A player logging in.</li>
|
||||
* <li>The durability of an equipment item changing.</li>
|
||||
* <li>A dispenser equipping an item onto an entity.</li>
|
||||
* <li>An entity picking up an armor or weapon item from the ground.</li>
|
||||
* <li>A player changing their equipped armor.</li>
|
||||
* <li>A player changes their currently held item.</li>
|
||||
* </ul>
|
||||
*/
|
||||
@NullMarked
|
||||
public class EntityEquipmentChangedEvent extends EntityEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Map<EquipmentSlot, EquipmentChange> equipmentChanges;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public EntityEquipmentChangedEvent(final LivingEntity entity, final Map<EquipmentSlot, EquipmentChange> equipmentChanges) {
|
||||
super(entity);
|
||||
|
||||
this.equipmentChanges = equipmentChanges;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LivingEntity getEntity() {
|
||||
return (LivingEntity) this.entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a map of changed slots to their respective equipment changes.
|
||||
*
|
||||
* @return the equipment changes map
|
||||
*/
|
||||
public @Unmodifiable Map<EquipmentSlot, EquipmentChange> getEquipmentChanges() {
|
||||
return Collections.unmodifiableMap(this.equipmentChanges);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a change in equipment for a single equipment slot.
|
||||
*/
|
||||
@ApiStatus.NonExtendable
|
||||
public interface EquipmentChange {
|
||||
|
||||
/**
|
||||
* Gets the existing item that is being replaced.
|
||||
*
|
||||
* @return the existing item
|
||||
*/
|
||||
@Contract(pure = true, value = "-> new")
|
||||
ItemStack oldItem();
|
||||
|
||||
/**
|
||||
* Gets the new item that is replacing the existing item.
|
||||
*
|
||||
* @return the new item
|
||||
*/
|
||||
@Contract(pure = true, value = "-> new")
|
||||
ItemStack newItem();
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package io.papermc.paper.event.executor;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.EventExecutor;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.constant.ConstantDescs;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@NullMarked
|
||||
public final class EventExecutorFactory {
|
||||
private static final byte[] TEMPLATE_CLASS_BYTES;
|
||||
|
||||
static {
|
||||
try (final InputStream is = EventExecutorFactory.class.getResourceAsStream("MethodHandleEventExecutorTemplate.class")) {
|
||||
TEMPLATE_CLASS_BYTES = Objects.requireNonNull(is, "template class is missing").readAllBytes();
|
||||
} catch (IOException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private EventExecutorFactory() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return an {@link EventExecutor} implemented by a hidden class calling a method handle}
|
||||
*
|
||||
* @param method the method to be invoked by the created event executor
|
||||
* @param eventClass the class of the event to handle
|
||||
*/
|
||||
public static EventExecutor create(final Method method, final Class<? extends Event> eventClass) {
|
||||
final List<?> classData = List.of(method, eventClass);
|
||||
try {
|
||||
final MethodHandles.Lookup newClass = MethodHandles.lookup().defineHiddenClassWithClassData(TEMPLATE_CLASS_BYTES, classData, true);
|
||||
return newClass.lookupClass().asSubclass(EventExecutor.class).getDeclaredConstructor().newInstance();
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
record ClassData(Method method, MethodHandle methodHandle, Class<? extends Event> eventClass) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the class data and creates an adjusted MethodHandle directly usable by the lookup class.
|
||||
* The logic is kept here to minimize memory usage per created class.
|
||||
*/
|
||||
static ClassData classData(final MethodHandles.Lookup lookup) {
|
||||
try {
|
||||
final Method method = MethodHandles.classDataAt(lookup, ConstantDescs.DEFAULT_NAME, Method.class, 0);
|
||||
MethodHandle mh = lookup.unreflect(method);
|
||||
if (Modifier.isStatic(method.getModifiers())) {
|
||||
mh = MethodHandles.dropArguments(mh, 0, Listener.class);
|
||||
}
|
||||
mh = mh.asType(MethodType.methodType(void.class, Listener.class, Event.class));
|
||||
final Class<?> eventClass = MethodHandles.classDataAt(lookup, ConstantDescs.DEFAULT_NAME, Class.class, 1);
|
||||
return new ClassData(method, mh, eventClass.asSubclass(Event.class));
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
package io.papermc.paper.event.executor;
|
||||
|
||||
import com.destroystokyo.paper.util.SneakyThrow;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventException;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.EventExecutor;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* This class is designed to be used as hidden class template.
|
||||
* Initializing the class directly will fail due to missing {@code classData}.
|
||||
* Instead, {@link java.lang.invoke.MethodHandles.Lookup#defineHiddenClassWithClassData(byte[], Object, boolean, MethodHandles.Lookup.ClassOption...)}
|
||||
* must be used, with the {@code classData} object being a list consisting of two elements:
|
||||
* <ol>
|
||||
* <li>A {@link Method} representing the event handler method</li>
|
||||
* <li>A {@link Class} representing the event type</li>
|
||||
* </ol>
|
||||
* The method must take {@link Event} or a subtype of it as its single parameter.
|
||||
* If the method is non-static, it also needs to reside in a class implementing {@link Listener}.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@ApiStatus.Internal
|
||||
@NullMarked
|
||||
class MethodHandleEventExecutorTemplate implements EventExecutor {
|
||||
private static final Method METHOD;
|
||||
private static final MethodHandle HANDLE;
|
||||
private static final Class<? extends Event> EVENT_CLASS;
|
||||
|
||||
static {
|
||||
final MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
final EventExecutorFactory.ClassData classData = EventExecutorFactory.classData(lookup);
|
||||
METHOD = classData.method();
|
||||
HANDLE = classData.methodHandle();
|
||||
EVENT_CLASS = classData.eventClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final Listener listener, final Event event) throws EventException {
|
||||
if (!EVENT_CLASS.isInstance(event)) return;
|
||||
try {
|
||||
HANDLE.invokeExact(listener, event);
|
||||
} catch (Throwable t) {
|
||||
SneakyThrow.sneaky(t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MethodHandleEventExecutorTemplate['" + METHOD + "']";
|
||||
}
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
package io.papermc.paper.event.player;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called when a player is marked as loaded.
|
||||
* <p>
|
||||
* This either happens when the player notifies the server after loading the world (closing the downloading terrain screen)
|
||||
* or when the player has not done so for 60 ticks after joining the server or respawning.
|
||||
*/
|
||||
@NullMarked
|
||||
public class PlayerClientLoadedWorldEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final boolean timeout;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayerClientLoadedWorldEvent(final Player who, final boolean timeout) {
|
||||
super(who);
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if the event was triggered because the server has not been notified by the player
|
||||
* for 60 ticks after the player joined the server or respawned.
|
||||
*
|
||||
* @return true if the event was triggered because of a timeout
|
||||
*/
|
||||
public boolean isTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package io.papermc.paper.math;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Represents a rotation with specified pitch and yaw values.
|
||||
*/
|
||||
@NullMarked
|
||||
public interface Rotation {
|
||||
/**
|
||||
* Creates a new rotation with the specified yaw and pitch values.
|
||||
*
|
||||
* @param yaw the yaw component of the rotation, measured in degrees
|
||||
* @param pitch the pitch component of the rotation, measured in degrees
|
||||
* @return a new {@code Rotation} instance with the specified yaw and pitch
|
||||
*/
|
||||
static Rotation rotation(float yaw, float pitch) {
|
||||
return new RotationImpl(yaw, pitch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the pitch component of the rotation, measured in degrees.
|
||||
*
|
||||
* @return the pitch value in degrees
|
||||
*/
|
||||
float pitch();
|
||||
|
||||
/**
|
||||
* Retrieves the yaw component of the rotation, measured in degrees.
|
||||
*
|
||||
* @return the yaw value in degrees
|
||||
*/
|
||||
float yaw();
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package io.papermc.paper.math;
|
||||
|
||||
record RotationImpl(float yaw, float pitch) implements Rotation {
|
||||
}
|
||||
-10
@@ -1,12 +1,10 @@
|
||||
package io.papermc.paper.plugin.lifecycle.event.types;
|
||||
|
||||
import io.papermc.paper.command.brigadier.Commands;
|
||||
import io.papermc.paper.datapack.DatapackRegistrar;
|
||||
import io.papermc.paper.plugin.bootstrap.BootstrapContext;
|
||||
import io.papermc.paper.plugin.lifecycle.event.LifecycleEvent;
|
||||
import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager;
|
||||
import io.papermc.paper.plugin.lifecycle.event.LifecycleEventOwner;
|
||||
import io.papermc.paper.plugin.lifecycle.event.registrar.RegistrarEvent;
|
||||
import io.papermc.paper.plugin.lifecycle.event.registrar.ReloadableRegistrarEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -34,14 +32,6 @@ public final class LifecycleEvents {
|
||||
*/
|
||||
public static final TagEventTypeProvider TAGS = LifecycleEventTypeProvider.provider().tagProvider();
|
||||
|
||||
|
||||
/**
|
||||
* This event is for informing the server about any available datapacks from other sources such as inside a plugin's jar. You
|
||||
* can register a handler for this event only in {@link io.papermc.paper.plugin.bootstrap.PluginBootstrap#bootstrap(BootstrapContext)}.
|
||||
* @see DatapackRegistrar an example of a datapack being discovered
|
||||
*/
|
||||
public static final LifecycleEventType.Prioritizable<BootstrapContext, RegistrarEvent<DatapackRegistrar>> DATAPACK_DISCOVERY = bootstrapPrioritized("datapack_discovery");
|
||||
|
||||
//<editor-fold desc="helper methods" defaultstate="collapsed">
|
||||
@ApiStatus.Internal
|
||||
static <E extends LifecycleEvent> LifecycleEventType.Monitorable<Plugin, E> plugin(final String name) {
|
||||
|
||||
Loaded 100 of 1086 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user