Skip to content

Commit 8554df7

Browse files
committed
v12.0.0 Final Candidate
* Fixed XBiome support for v1.21.3 (Fixes #308) * Fixed XTag.ORES not including diamonds and emeralds (Fixes #311) * Fixed XItemStack support for v1.8.8 (Fixes #303)
1 parent 1100e88 commit 8554df7

22 files changed

+605
-384
lines changed

pom.xml

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.github.cryptomorin</groupId>
88
<artifactId>XSeries</artifactId>
9-
<version>11.3.0</version>
9+
<version>12.0.0</version>
1010

1111
<name>XSeries</name>
1212
<description>A set of utilities for Minecraft plugins</description>
@@ -87,30 +87,19 @@
8787
<!-- 1.21.1-R0.1-SNAPSHOT -->
8888
<!-- 1.21.3-R0.1-SNAPSHOT -->
8989
<!-- mvn install:install-file "-Dfile=server.jar" -DgroupId=org.spigotmc -DartifactId=spigot -Dversion=1.21.3-R0.1-EXPR -Dpackaging=jar -DgeneratePom=true -->
90-
<spigotVersion>1.21.3-R0.1-EXPR</spigotVersion>
90+
<!-- <spigotVersion>1.21.3-R0.1-EXPR</spigotVersion> -->
91+
<spigotVersion>1.21.3-R0.1-SNAPSHOT</spigotVersion>
9192
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
9293
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
9394
</properties>
9495

9596
<dependencies>
96-
<dependency>
97-
<groupId>net.sf.jopt-simple</groupId>
98-
<artifactId>jopt-simple</artifactId>
99-
<version>5.0.4</version>
100-
<scope>compile</scope>
101-
</dependency>
102-
<dependency>
103-
<groupId>org.apache.logging.log4j</groupId>
104-
<artifactId>log4j-iostreams</artifactId>
105-
<version>2.22.1</version>
106-
<scope>compile</scope>
107-
</dependency>
108-
<dependency>
109-
<groupId>com.mojang</groupId>
110-
<artifactId>authlib</artifactId>
111-
<version>6.0.55</version>
112-
<scope>provided</scope>
113-
</dependency>
97+
<!-- <dependency>-->
98+
<!-- <groupId>com.mojang</groupId>-->
99+
<!-- <artifactId>authlib</artifactId>-->
100+
<!-- <version>6.0.55</version>-->
101+
<!-- <scope>provided</scope>-->
102+
<!-- </dependency>-->
114103
<dependency>
115104
<groupId>org.spigotmc</groupId>
116105
<artifactId>spigot</artifactId>
@@ -272,6 +261,8 @@
272261
<artifactId>maven-compiler-plugin</artifactId>
273262
<version>3.13.0</version>
274263
<configuration>
264+
<encoding>UTF-8</encoding>
265+
<proc>none</proc>
275266
<source>21</source>
276267
<target>21</target>
277268
</configuration>

src/main/java/com/cryptomorin/xseries/XAttribute.java

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
import org.bukkit.attribute.Attribute;
88
import org.bukkit.attribute.AttributeModifier;
99
import org.bukkit.inventory.EquipmentSlot;
10+
import org.bukkit.inventory.EquipmentSlotGroup;
1011
import org.jetbrains.annotations.NotNull;
12+
import org.jetbrains.annotations.Nullable;
1113

14+
import java.util.Objects;
1215
import java.util.Optional;
1316
import java.util.UUID;
1417

@@ -17,38 +20,38 @@ public final class XAttribute extends XModule<XAttribute, Attribute> {
1720
new XRegistry<>(Attribute.class, XAttribute.class, () -> Registry.ATTRIBUTE, XAttribute::new, XAttribute[]::new);
1821

1922
public static final XAttribute
20-
MAX_HEALTH = std(/* v1.20.3+ */ "max_health", "generic_max_health"),
21-
FOLLOW_RANGE = std("follow_range"),
22-
KNOCKBACK_RESISTANCE = std("knockback_resistance"),
23-
MOVEMENT_SPEED = std("movement_speed"),
24-
FLYING_SPEED = std("flying_speed"),
25-
ATTACK_DAMAGE = std("attack_damage"),
26-
ATTACK_KNOCKBACK = std("attack_knockback"),
27-
ATTACK_SPEED = std("attack_speed"),
28-
ARMOR = std("armor"),
29-
ARMOR_TOUGHNESS = std("armor_toughness"),
30-
FALL_DAMAGE_MULTIPLIER = std("fall_damage_multiplier"),
31-
LUCK = std("luck"),
32-
MAX_ABSORPTION = std("max_absorption"),
33-
SAFE_FALL_DISTANCE = std("safe_fall_distance"),
34-
SCALE = std("scale"),
35-
STEP_HEIGHT = std("step_height"),
36-
GRAVITY = std("gravity"),
37-
JUMP_STRENGTH = std("jump_strength"),
38-
BURNING_TIME = std("burning_time"),
39-
EXPLOSION_KNOCKBACK_RESISTANCE = std("explosion_knockback_resistance"),
40-
MOVEMENT_EFFICIENCY = std("movement_efficiency"),
41-
OXYGEN_BONUS = std("oxygen_bonus"),
42-
WATER_MOVEMENT_EFFICIENCY = std("water_movement_efficiency"),
43-
TEMPT_RANGE = std("tempt_range"),
44-
BLOCK_INTERACTION_RANGE = std("block_interaction_range"),
45-
ENTITY_INTERACTION_RANGE = std("entity_interaction_range"),
46-
BLOCK_BREAK_SPEED = std("block_break_speed"),
47-
MINING_EFFICIENCY = std("mining_efficiency"),
48-
SNEAKING_SPEED = std("sneaking_speed"),
49-
SUBMERGED_MINING_SPEED = std("submerged_mining_speed"),
50-
SWEEPING_DAMAGE_RATIO = std("sweeping_damage_ratio"),
51-
SPAWN_REINFORCEMENTS = std("spawn_reinforcements");
23+
MAX_HEALTH = std(/* v1.20.3+ */ "max_health", "GENERIC_MAX_HEALTH"),
24+
FOLLOW_RANGE = std(/* v1.20.3+ */ "follow_range", "GENERIC_FOLLOW_RANGE"),
25+
KNOCKBACK_RESISTANCE = std(/* v1.20.3+ */ "knockback_resistance", "GENERIC_KNOCKBACK_RESISTANCE"),
26+
MOVEMENT_SPEED = std(/* v1.20.3+ */ "movement_speed", "GENERIC_MOVEMENT_SPEED"),
27+
FLYING_SPEED = std(/* v1.20.3+ */ "flying_speed", "GENERIC_FLYING_SPEED"),
28+
ATTACK_DAMAGE = std(/* v1.20.3+ */ "attack_damage", "GENERIC_ATTACK_DAMAGE"),
29+
ATTACK_KNOCKBACK = std(/* v1.20.3+ */ "attack_knockback", "GENERIC_ATTACK_KNOCKBACK"),
30+
ATTACK_SPEED = std(/* v1.20.3+ */"attack_speed", "GENERIC_ATTACK_SPEED"),
31+
ARMOR = std(/* v1.20.3+ */ "armor", "GENERIC_ARMOR"),
32+
ARMOR_TOUGHNESS = std(/* v1.20.3+ */ "armor_toughness", "GENERIC_ARMOR_TOUGHNESS"),
33+
FALL_DAMAGE_MULTIPLIER = std(/* v1.20.3+ */ "fall_damage_multiplier", "GENERIC_FALL_DAMAGE_MULTIPLIER"),
34+
LUCK = std(/* v1.20.3+ */ "luck", "GENERIC_LUCK"),
35+
MAX_ABSORPTION = std(/* v1.20.3+ */ "max_absorption", "GENERIC_MAX_ABSORPTION"),
36+
SAFE_FALL_DISTANCE = std(/* v1.20.3+ */ "safe_fall_distance", "GENERIC_SAFE_FALL_DISTANCE"),
37+
SCALE = std(/* v1.20.3+ */ "scale", "GENERIC_SCALE"),
38+
STEP_HEIGHT = std(/* v1.20.3+ */ "step_height", "GENERIC_STEP_HEIGHT"),
39+
GRAVITY = std(/* v1.20.3+ */ "gravity", "GENERIC_GRAVITY"),
40+
JUMP_STRENGTH = std(/* v1.20.3+ */ "jump_strength", "GENERIC_JUMP_STRENGTH"),
41+
BURNING_TIME = std(/* v1.20.3+ */ "burning_time", "GENERIC_BURNING_TIME"),
42+
EXPLOSION_KNOCKBACK_RESISTANCE = std(/* v1.20.3+ */"explosion_knockback_resistance", "GENERIC_EXPLOSION_KNOCKBACK_RESISTANCE"),
43+
MOVEMENT_EFFICIENCY = std(/* v1.20.3+ */"movement_efficiency", "GENERIC_MOVEMENT_EFFICIENCY"),
44+
OXYGEN_BONUS = std(/* v1.20.3+ */"oxygen_bonus", "GENERIC_OXYGEN_BONUS"),
45+
WATER_MOVEMENT_EFFICIENCY = std(/* v1.20.3+ */"water_movement_efficiency", "GENERIC_WATER_MOVEMENT_EFFICIENCY"),
46+
TEMPT_RANGE = std(/* v1.20.3+ */"tempt_range", "GENERIC_TEMPT_RANGE"),
47+
BLOCK_INTERACTION_RANGE = std(/* v1.20.3+ */"block_interaction_range", "PLAYER_BLOCK_INTERACTION_RANGE"),
48+
ENTITY_INTERACTION_RANGE = std(/* v1.20.3+ */"entity_interaction_range", "PLAYER_ENTITY_INTERACTION_RANGE"),
49+
BLOCK_BREAK_SPEED = std(/* v1.20.3+ */"block_break_speed", "PLAYER_BLOCK_BREAK_SPEED"),
50+
MINING_EFFICIENCY = std(/* v1.20.3+ */"mining_efficiency", "PLAYER_MINING_EFFICIENCY"),
51+
SNEAKING_SPEED = std(/* v1.20.3+ */"sneaking_speed", "PLAYER_SNEAKING_SPEED"),
52+
SUBMERGED_MINING_SPEED = std(/* v1.20.3+ */"submerged_mining_speed", "PLAYER_SUBMERGED_MINING_SPEED"),
53+
SWEEPING_DAMAGE_RATIO = std(/* v1.20.3+ */"sweeping_damage_ratio", "PLAYER_SWEEPING_DAMAGE_RATIO"),
54+
SPAWN_REINFORCEMENTS = std(/* v1.20.3+ */"spawn_reinforcements", "ZOMBIE_SPAWN_REINFORCEMENTS");
5255

5356
private static final boolean SUPPORTS_MODERN_MODIFIERS;
5457

@@ -74,10 +77,17 @@ private XAttribute(Attribute attribute, String[] names) {
7477
super(attribute, names);
7578
}
7679

77-
public AttributeModifier createModifier(@NotNull String key, double amount, @NotNull AttributeModifier.Operation operation, @NotNull EquipmentSlot slot) {
80+
/**
81+
* @param slot when null, defaults to {@link org.bukkit.inventory.EquipmentSlotGroup#ANY}
82+
*/
83+
public AttributeModifier createModifier(@NotNull String key, double amount, @NotNull AttributeModifier.Operation operation, @Nullable EquipmentSlot slot) {
84+
Objects.requireNonNull(key, "Key is null");
85+
Objects.requireNonNull(operation, "Operation is null");
86+
7887
if (SUPPORTS_MODERN_MODIFIERS) {
88+
NamespacedKey ns = Objects.requireNonNull(NamespacedKey.fromString(key), () -> "Invalid namespace: " + key);
7989
// noinspection UnstableApiUsage
80-
return new AttributeModifier(NamespacedKey.fromString(key), amount, operation, slot.getGroup());
90+
return new AttributeModifier(ns, amount, operation, (slot == null ? EquipmentSlotGroup.ANY : slot.getGroup()));
8191
} else {
8292
// noinspection removal
8393
return new AttributeModifier(UUID.randomUUID(), key, amount, operation, slot);

0 commit comments

Comments
 (0)