Support for 1.20+ vanilla stats (size, range etc)

This commit is contained in:
Jules 2024-06-13 19:28:40 -07:00
parent b8a178837e
commit c9cd7727ae
21 changed files with 218 additions and 12 deletions

View File

@ -120,6 +120,18 @@ public class ItemStats {
DROP_ON_DEATH = new DisableDeathDrop(),
DURABILITY_BAR = new DurabilityBar(),
// Extra Attributes (1.20.2+)
MAX_ABSORPTION = new MaxAbsorption(),
BLOCK_BREAK_SPEED = new BlockBreakSpeed(),
BLOCK_INTERACTION_RANGE = new BlockInteractionRange(),
ENTITY_INTERACTION_RANGE = new EntityInteractionRange(),
FALL_DAMAGE_MULTIPLIER = new FallDamageMultiplier(),
GRAVITY = new Gravity(),
JUMP_STRENGTH = new JumpStrength(),
SAFE_FALL_DISTANCE = new SafeFallDistance(),
SCALE = new Scale(),
STEP_HEIGHT = new StepHeight(),
// Permanent Effects
PERM_EFFECTS = new PermanentEffects(),
GRANTED_PERMISSIONS = new GrantedPermissions(),

View File

@ -0,0 +1,13 @@
package net.Indyuce.mmoitems.stat;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import net.Indyuce.mmoitems.util.VersionDependant;
import org.bukkit.Material;
@VersionDependant(version = {1, 20, 5})
public class BlockBreakSpeed extends DoubleStat {
public BlockBreakSpeed() {
super("BLOCK_BREAK_SPEED", Material.IRON_PICKAXE,
"Mining Speed", new String[]{"Additional block breaking speed.", "Bare hands have a mining speed of 1"});
}
}

View File

@ -0,0 +1,13 @@
package net.Indyuce.mmoitems.stat;
import io.lumine.mythic.lib.version.VMaterial;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import net.Indyuce.mmoitems.util.VersionDependant;
@VersionDependant(version = {1, 20, 5})
public class BlockInteractionRange extends DoubleStat {
public BlockInteractionRange() {
super("BLOCK_INTERACTION_RANGE", VMaterial.SPYGLASS.get(),
"Block Interaction Range", new String[]{"Additional range for breaking or interacting", "with blocks. Player's default is set to 5", "in creative mode, or 4.5 otherwise."});
}
}

View File

@ -0,0 +1,13 @@
package net.Indyuce.mmoitems.stat;
import io.lumine.mythic.lib.version.VMaterial;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import net.Indyuce.mmoitems.util.VersionDependant;
@VersionDependant(version = {1, 20, 5})
public class EntityInteractionRange extends DoubleStat {
public EntityInteractionRange() {
super("ENTITY_INTERACTION_RANGE", VMaterial.SPYGLASS.get(),
"Entity Interaction Range", new String[]{"Additional range for damaging or interacting with entities.", "Player's default is set to 5 in creative,", "and 4.5 in survival."});
}
}

View File

@ -0,0 +1,18 @@
package net.Indyuce.mmoitems.stat;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import net.Indyuce.mmoitems.util.VersionDependant;
import org.bukkit.Material;
@VersionDependant(version = {1, 20, 5})
public class FallDamageMultiplier extends DoubleStat {
public FallDamageMultiplier() {
super("FALL_DAMAGE_MULTIPLIER", Material.DAMAGED_ANVIL,
"Fall Damage Multiplier", new String[]{"Increases fall damage by a certain %.", "Player's default is set to 100%"});
}
@Override
public double multiplyWhenDisplaying() {
return 100;
}
}

View File

@ -0,0 +1,18 @@
package net.Indyuce.mmoitems.stat;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import net.Indyuce.mmoitems.util.VersionDependant;
import org.bukkit.Material;
@VersionDependant(version = {1, 20, 5})
public class Gravity extends DoubleStat {
public Gravity() {
super("GRAVITY", Material.STONE,
"Gravity", new String[]{"Increases force of gravity.", "Player's default is set to 1"});
}
@Override
public double multiplyWhenDisplaying() {
return 100;
}
}

View File

@ -18,7 +18,7 @@ import java.util.ArrayList;
* @deprecated Merge with other Hide- stats
*/
@Deprecated
@VersionDependant(minor = 16, patch = 3)
@VersionDependant(version = {1, 16, 3})
public class HideDye extends BooleanStat {
public HideDye() {
super("HIDE_DYE", Material.CYAN_DYE, "Hide Dyed", new String[] { "Enable to hide the 'Dyed' tag from the item." }, new String[0],

View File

@ -18,7 +18,7 @@ import java.util.ArrayList;
* @deprecated Merge with other Hide- stats
*/
@Deprecated
@VersionDependant(minor = 20)
@VersionDependant(version = {1, 20})
public class HideTrim extends BooleanStat {
public HideTrim() {
super("HIDE_ARMOR_TRIM", Material.LEATHER_CHESTPLATE, "Hide Armor Trim", new String[]{"Hides armor trim from item lore."}, new String[]{"armor", "skin"});

View File

@ -0,0 +1,13 @@
package net.Indyuce.mmoitems.stat;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import net.Indyuce.mmoitems.util.VersionDependant;
import org.bukkit.Material;
@VersionDependant(version = {1, 20, 5})
public class JumpStrength extends DoubleStat {
public JumpStrength() {
super("JUMP_STRENGTH", Material.SADDLE,
"Jump Strength", new String[]{"Additional jump height in blocks.", "Player's default is set to 1.25"});
}
}

View File

@ -0,0 +1,13 @@
package net.Indyuce.mmoitems.stat;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import net.Indyuce.mmoitems.util.VersionDependant;
import org.bukkit.Material;
@VersionDependant(version = {1, 20, 2})
public class MaxAbsorption extends DoubleStat {
public MaxAbsorption() {
super("MAX_ABSORPTION", Material.ENCHANTED_GOLDEN_APPLE,
"Max Absorption", new String[]{"This does not provide permanent absorption", "but rather increases your maximum amount", "of absorption hearts you can have at any time."});
}
}

View File

@ -0,0 +1,12 @@
package net.Indyuce.mmoitems.stat;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import net.Indyuce.mmoitems.util.VersionDependant;
import org.bukkit.Material;
@VersionDependant(version = {1, 20, 5})
public class SafeFallDistance extends DoubleStat {
public SafeFallDistance() {
super("SAFE_FALL_DISTANCE", Material.RED_BED, "Safe Fall Distance", new String[]{"Additional blocks that you can fall", "down, without taking any fall damage.", "Player's default is set to 3"});
}
}

View File

@ -0,0 +1,17 @@
package net.Indyuce.mmoitems.stat;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import net.Indyuce.mmoitems.util.VersionDependant;
import org.bukkit.Material;
@VersionDependant(version = {1, 20, 5})
public class Scale extends DoubleStat {
public Scale() {
super("SCALE", Material.STONE, "Scale", new String[]{"Increases player size.", "Player's default is 1"});
}
@Override
public double multiplyWhenDisplaying() {
return 100;
}
}

View File

@ -0,0 +1,13 @@
package net.Indyuce.mmoitems.stat;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import net.Indyuce.mmoitems.util.VersionDependant;
import org.bukkit.Material;
@VersionDependant(version = {1, 20, 5})
public class StepHeight extends DoubleStat {
public StepHeight() {
super("STEP_HEIGHT", Material.GOLDEN_BOOTS,
"Step Height", new String[]{"Additional number of blocks that you can climb", "without jumping when walking or sprinting.", "Player's default is 0.6 i.e just higher than one slab."});
}
}

View File

@ -20,7 +20,7 @@ import org.jetbrains.annotations.Nullable;
/**
* @author Jules
*/
@VersionDependant(minor = 20)
@VersionDependant(version = {1, 20})
public class TrimMaterialStat extends ChooseStat implements GemStoneStat {
public TrimMaterialStat() {
super("TRIM_MATERIAL", Material.LEATHER_CHESTPLATE, "Trim Material", new String[]{"Material to trim your armor with."}, new String[]{"armor", "skin"});

View File

@ -20,7 +20,7 @@ import org.jetbrains.annotations.Nullable;
/**
* @author Jules
*/
@VersionDependant(minor = 20)
@VersionDependant(version = {1, 20})
public class TrimPatternStat extends ChooseStat implements GemStoneStat {
public TrimPatternStat() {
super("TRIM_PATTERN", Material.LEATHER_CHESTPLATE, "Trim Pattern", new String[]{"Pattern of trimmed armor."}, new String[]{"armor", "skin"});

View File

@ -64,8 +64,7 @@ public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData>
// Version dependency
if (getClass().isAnnotationPresent(VersionDependant.class)) {
final VersionDependant implVersion = getClass().getAnnotation(VersionDependant.class);
if (MythicLib.plugin.getVersion().isBelowOrEqual(implVersion.major(), implVersion.minor(), implVersion.patch() - 1))
disable();
if (MythicLib.plugin.getVersion().isUnder(implVersion.version())) disable();
}
}

View File

@ -16,9 +16,5 @@ import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface VersionDependant {
public int major() default 1;
public int minor();
public int patch() default 0;
public int[] version();
}

View File

@ -1214,3 +1214,30 @@ SHADOWBOOTS:
max-health: 8.0
movement-speed: 0.01
dye-color: 0 0 0
GARGOYLE_CHESTPLATE:
base:
material: IRON_CHESTPLATE
scale: 1.0
name: Gargoyle Chestplate
trim-material: netherite
trim-pattern: silence
hide-armor-trim: true
max-health: 10.0
armor: 6.0
movement-speed: -0.02
SHRINKING_BOOTS:
base:
material: GOLDEN_BOOTS
trim-material: redstone
trim-pattern: silence
hide-armor-trim: true
scale: -0.5
movement-speed: 0.02
required-class:
- Mage
skill-damage: -50.0
max-health: -10.0
name: Boots of Shrinking
lore:
- '&7&oMay this item help you get'
- '&7&othrough the narrowest paths...'

View File

@ -191,3 +191,10 @@ ICE_GOLEM_HEART:
defense: 100.0
handworn: true
fire-damage-reduction: 100.0
SHRINKIFIKATOR:
base:
material: PRISMARINE_SHARD
name: Shrinkificator
scale: -0.5
max-health: -10.0
movement-speed: -0.03

View File

@ -82,6 +82,16 @@ lore-format:
- '#mana-regeneration#'
- '#stamina-regeneration#'
- '#movement-speed#'
- '#block-break-speed#'
- '#block-interaction-range#'
- '#entity-interaction-range#'
- '#fall-damage-multiplier#'
- '#gravity#'
- '#jump-strength#'
- '#max-absorption#'
- '#safe-fall-distance#'
- '#scale#'
- '#step-height#'
- '#lute-attack-effect#'
- '#two-handed#'
- '#handworn#'

View File

@ -5,7 +5,7 @@ critical-strike-chance: '&3 &7■ Crit Strike Chance: &f<plus>{value}%'
critical-strike-power: '&3 &7■ Crit Strike Power: &f<plus>{value}%'
skill-critical-strike-chance: '&3 &7■ Skill Crit Chance: &f<plus>{value}%'
skill-critical-strike-power: '&3 &7■ Skill Crit Power: &f<plus>{value}%'
range: '&3 &7■ Range: &f{value}'
range: '&3 &7■ Range: &f{value}' # Combat range for ranged weapons
mana-cost: '&3 &7■ Uses &9{value} Mana'
stamina-cost: '&3 &7■ Uses &9{value} Stamina'
arrow-velocity: '&3 &7■ Arrow Velocity: &f{value}'
@ -83,6 +83,18 @@ additional-experience-smelting: '&7■ Additional Smelting Experience: &f<plus>{
additional-experience-smithing: '&7■ Additional Smithing Experience: &f<plus>{value}%'
additional-experience-woodcutting: '&7■ Additional Woodcutting Experience: &f<plus>{value}%'
# 1.20.2+ Attributes
block-break-speed: '&3 &7■ Mining Speed: &f<plus>{value}'
block-interaction-range: '&3 &7■ Range: &f<plus>{value}' # Range for interacting with blocks & mining.
entity-interaction-range: '&3 &7■ Combat Range: &f<plus>{value}'
fall-damage-multiplier: '&3 &7■ Fall Damage: &f<plus>{value}%'
gravity: '&3 &7■ Force of Gravity: &f<plus>{value}%'
jump-strength: '&3 &7■ Jump Strength: &f<plus>{value}'
max-absorption: '&3 &7■ Max Absorption: &f<plus>{value}'
safe-fall-distance: '&3 &7■ Safe Fall Distance: &f<plus>{value}'
scale: '&3 &7■ Size: &f<plus>{value}%'
step-height: '&3 &7■ Smooth Walking: &f<plus>{value}'
# Extra Options
perm-effects: '&3 &7■ Permanent &f{effect}'
commands: '&3 &7■ Command: &f{format} &3 &7(&f{cooldown}&3 &7s)'