From 26ba3f356dd4b9ca3445f1c846ebdd32dafd2cb6 Mon Sep 17 00:00:00 2001 From: ShaneBeee Date: Sun, 29 Dec 2024 18:04:59 -0800 Subject: [PATCH] Skript 2.10 prep --- .../shanebeestudios/skbee/api/util/Util.java | 1 + .../conditions/CondFishHookInOpenWater.java | 10 +- .../other/conditions/CondEntityTicking.java | 9 +- .../elements/other/events/OtherEvents.java | 146 ++++----- .../elements/other/events/PaperEvents.java | 280 +++++++++--------- .../other/expressions/ExprBreedEntities.java | 12 +- .../other/expressions/ExprItemFlags.java | 22 +- .../other/expressions/ExprItemFlagsItem.java | 18 +- .../expressions/ExprLastDeathLocation.java | 13 +- .../skbee/elements/other/type/Types.java | 52 ++-- .../expressions/ExprVillagerLevel.java | 16 +- .../expressions/ExprVillagerProfession.java | 10 +- .../expressions/ExprVillagerType.java | 12 +- .../skbee/elements/villager/type/Types.java | 58 ++-- 14 files changed, 361 insertions(+), 298 deletions(-) diff --git a/src/main/java/com/shanebeestudios/skbee/api/util/Util.java b/src/main/java/com/shanebeestudios/skbee/api/util/Util.java index 721a5a7bc..5abc1fd6c 100644 --- a/src/main/java/com/shanebeestudios/skbee/api/util/Util.java +++ b/src/main/java/com/shanebeestudios/skbee/api/util/Util.java @@ -33,6 +33,7 @@ public class Util { // Shortcut for finding stuff to remove later public static final boolean IS_RUNNING_SKRIPT_2_9 = Skript.getVersion().isLargerThan(new Version(2, 8, 999)); + public static final boolean IS_RUNNING_SKRIPT_2_10 = Skript.getVersion().isLargerThan(new Version(2, 9, 999)); public static final boolean IS_RUNNING_MC_1_21 = Skript.isRunningMinecraft(1, 21); @SuppressWarnings("deprecation") // Paper deprecation diff --git a/src/main/java/com/shanebeestudios/skbee/elements/fishing/conditions/CondFishHookInOpenWater.java b/src/main/java/com/shanebeestudios/skbee/elements/fishing/conditions/CondFishHookInOpenWater.java index b92701da7..5b1bf7026 100644 --- a/src/main/java/com/shanebeestudios/skbee/elements/fishing/conditions/CondFishHookInOpenWater.java +++ b/src/main/java/com/shanebeestudios/skbee/elements/fishing/conditions/CondFishHookInOpenWater.java @@ -5,20 +5,24 @@ import ch.njol.skript.doc.Examples; import ch.njol.skript.doc.Name; import ch.njol.skript.doc.Since; +import com.shanebeestudios.skbee.api.util.Util; import org.bukkit.entity.Entity; import org.bukkit.entity.FishHook; import org.jetbrains.annotations.NotNull; @Name("Fish Hook - In Open Water") @Description({"Check if the fish hook is in open water.", - "Open water is defined by a 5x4x5 area of water, air and lily pads.", - "If in open water, treasure items may be caught."}) + "Open water is defined by a 5x4x5 area of water, air and lily pads.", + "If in open water, treasure items may be caught.", + "Removed if running Skript 2.10+ (now included in Skript)."}) @Examples("if fish hook is in open water:") @Since("2.8.0") public class CondFishHookInOpenWater extends PropertyCondition { static { - register(CondFishHookInOpenWater.class, "in open water", "entities"); + if (!Util.IS_RUNNING_SKRIPT_2_10) { + register(CondFishHookInOpenWater.class, "in open water", "entities"); + } } @Override diff --git a/src/main/java/com/shanebeestudios/skbee/elements/other/conditions/CondEntityTicking.java b/src/main/java/com/shanebeestudios/skbee/elements/other/conditions/CondEntityTicking.java index 9d5fd88fc..5f6a97201 100644 --- a/src/main/java/com/shanebeestudios/skbee/elements/other/conditions/CondEntityTicking.java +++ b/src/main/java/com/shanebeestudios/skbee/elements/other/conditions/CondEntityTicking.java @@ -9,11 +9,14 @@ import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.SkriptParser.ParseResult; import ch.njol.util.Kleenean; +import com.shanebeestudios.skbee.api.util.Util; import org.bukkit.entity.Entity; import org.jetbrains.annotations.NotNull; @Name("Entity - Is Ticking") -@Description("Check if an entity is currently ticking. If they're in a chunk that is not ticking, this will be false.") +@Description({"Check if an entity is currently ticking.", + "If they're in a chunk that is not ticking, this will be false.", + "Removed if running Skript 2.10+ (now included in Skript)."}) @Examples("loop all entities where [input is ticking]:") @Since("2.6.0") public class CondEntityTicking extends PropertyCondition { @@ -21,7 +24,9 @@ public class CondEntityTicking extends PropertyCondition { private static final boolean TICKING_METHOD_EXISTS = Skript.methodExists(Entity.class, "isTicking"); static { - register(CondEntityTicking.class, "ticking", "entities"); + if (!Util.IS_RUNNING_SKRIPT_2_10) { + register(CondEntityTicking.class, "ticking", "entities"); + } } @SuppressWarnings("NullableProblems") diff --git a/src/main/java/com/shanebeestudios/skbee/elements/other/events/OtherEvents.java b/src/main/java/com/shanebeestudios/skbee/elements/other/events/OtherEvents.java index 5c12617a3..c10a7a426 100644 --- a/src/main/java/com/shanebeestudios/skbee/elements/other/events/OtherEvents.java +++ b/src/main/java/com/shanebeestudios/skbee/elements/other/events/OtherEvents.java @@ -146,41 +146,43 @@ public Player get(PrepareAnvilEvent event) { .since("1.8.0"); // Entity Breed Event - Skript.registerEvent("Entity Breed", OtherEvents.class, EntityBreedEvent.class, - "entity breed") - .description("Called when one Entity breeds with another Entity.") - .examples("on entity breed:", "\nif breeding mother is a sheep:", - "\n\nkill breeding player") - .since("1.17.0"); - - EventValues.registerEventValue(EntityBreedEvent.class, Player.class, new Getter<>() { - @Override - public @Nullable Player get(EntityBreedEvent breedEvent) { - LivingEntity breeder = breedEvent.getBreeder(); - if (breeder instanceof Player player) { - return player; + if (!Util.IS_RUNNING_SKRIPT_2_10) { + Skript.registerEvent("Entity Breed", OtherEvents.class, EntityBreedEvent.class, + "entity breed") + .description("Called when one Entity breeds with another Entity.") + .examples("on entity breed:", "\nif breeding mother is a sheep:", + "\n\nkill breeding player") + .since("1.17.0"); + + EventValues.registerEventValue(EntityBreedEvent.class, Player.class, new Getter<>() { + @Override + public @Nullable Player get(EntityBreedEvent breedEvent) { + LivingEntity breeder = breedEvent.getBreeder(); + if (breeder instanceof Player player) { + return player; + } + return null; } - return null; - } - }, EventValues.TIME_NOW); + }, EventValues.TIME_NOW); - EventValues.registerEventValue(EntityBreedEvent.class, Entity.class, new Getter<>() { - @Override - public Entity get(EntityBreedEvent breedEvent) { - return breedEvent.getEntity(); - } - }, EventValues.TIME_NOW); + EventValues.registerEventValue(EntityBreedEvent.class, Entity.class, new Getter<>() { + @Override + public Entity get(EntityBreedEvent breedEvent) { + return breedEvent.getEntity(); + } + }, EventValues.TIME_NOW); - EventValues.registerEventValue(EntityBreedEvent.class, ItemType.class, new Getter<>() { - @Override - public @Nullable ItemType get(EntityBreedEvent breedEvent) { - ItemStack bredWith = breedEvent.getBredWith(); - if (bredWith != null) { - return new ItemType(bredWith); + EventValues.registerEventValue(EntityBreedEvent.class, ItemType.class, new Getter<>() { + @Override + public @Nullable ItemType get(EntityBreedEvent breedEvent) { + ItemStack bredWith = breedEvent.getBredWith(); + if (bredWith != null) { + return new ItemType(bredWith); + } + return null; } - return null; - } - }, EventValues.TIME_NOW); + }, EventValues.TIME_NOW); + } // Entity Change Block Event Skript.registerEvent("Entity Change Block", OtherEvents.class, EntityChangeBlockEvent.class, @@ -204,49 +206,51 @@ public Entity get(EntityBreedEvent breedEvent) { }, EventValues.TIME_NOW); // Block Drop Item Event - Skript.registerEvent("Block Drop Item", OtherEvents.class, BlockDropItemEvent.class, - "block drop item") - .description("This event is called if a block broken by a player drops an item.", - "`event-player` = Player who broke the block.", - "`event-entities` = Item entities which were dropped (may include drops of attached blocks, like a torch).", - "`past event-block` = The block that was broken (This event is called after the block actually breaks).", - "`event-block` = Current state of block after broken (Probably will just be air).") - .examples("on block drop item:", - "\tif past event-block is any ore:", - "\t\tteleport event-entities to player", - "\t\tset {_data} to blockdata of past event-block", - "\t\tset event-block to bedrock", - "\t\twait 2 seconds", - "\t\tset event-block to {_data}") - .since("2.6.0"); - - EventValues.registerEventValue(BlockDropItemEvent.class, Player.class, new Getter<>() { - @Override - public Player get(BlockDropItemEvent event) { - return event.getPlayer(); - } - }, EventValues.TIME_NOW); + if (!Util.IS_RUNNING_SKRIPT_2_10) { + Skript.registerEvent("Block Drop Item", OtherEvents.class, BlockDropItemEvent.class, + "block drop item") + .description("This event is called if a block broken by a player drops an item.", + "`event-player` = Player who broke the block.", + "`event-entities` = Item entities which were dropped (may include drops of attached blocks, like a torch).", + "`past event-block` = The block that was broken (This event is called after the block actually breaks).", + "`event-block` = Current state of block after broken (Probably will just be air).") + .examples("on block drop item:", + "\tif past event-block is any ore:", + "\t\tteleport event-entities to player", + "\t\tset {_data} to blockdata of past event-block", + "\t\tset event-block to bedrock", + "\t\twait 2 seconds", + "\t\tset event-block to {_data}") + .since("2.6.0"); + + EventValues.registerEventValue(BlockDropItemEvent.class, Player.class, new Getter<>() { + @Override + public Player get(BlockDropItemEvent event) { + return event.getPlayer(); + } + }, EventValues.TIME_NOW); - EventValues.registerEventValue(BlockDropItemEvent.class, Block.class, new Getter<>() { - @Override - public Block get(BlockDropItemEvent event) { - return event.getBlock(); - } - }, EventValues.TIME_NOW); + EventValues.registerEventValue(BlockDropItemEvent.class, Block.class, new Getter<>() { + @Override + public Block get(BlockDropItemEvent event) { + return event.getBlock(); + } + }, EventValues.TIME_NOW); - EventValues.registerEventValue(BlockDropItemEvent.class, Block.class, new Getter<>() { - @Override - public Block get(BlockDropItemEvent event) { - return new BlockStateBlock(event.getBlockState()); - } - }, EventValues.TIME_PAST); + EventValues.registerEventValue(BlockDropItemEvent.class, Block.class, new Getter<>() { + @Override + public Block get(BlockDropItemEvent event) { + return new BlockStateBlock(event.getBlockState()); + } + }, EventValues.TIME_PAST); - EventValues.registerEventValue(BlockDropItemEvent.class, Item[].class, new Getter<>() { - @Override - public Item @Nullable [] get(BlockDropItemEvent event) { - return event.getItems().toArray(new Item[0]); - } - }, EventValues.TIME_NOW); + EventValues.registerEventValue(BlockDropItemEvent.class, Item[].class, new Getter<>() { + @Override + public Item @Nullable [] get(BlockDropItemEvent event) { + return event.getItems().toArray(new Item[0]); + } + }, EventValues.TIME_NOW); + } // Block Damage Abort Event if (Skript.classExists("org.bukkit.event.block.BlockDamageAbortEvent")) { diff --git a/src/main/java/com/shanebeestudios/skbee/elements/other/events/PaperEvents.java b/src/main/java/com/shanebeestudios/skbee/elements/other/events/PaperEvents.java index 01f6e08d2..1787410fc 100644 --- a/src/main/java/com/shanebeestudios/skbee/elements/other/events/PaperEvents.java +++ b/src/main/java/com/shanebeestudios/skbee/elements/other/events/PaperEvents.java @@ -17,6 +17,7 @@ import com.destroystokyo.paper.event.player.PlayerElytraBoostEvent; import com.destroystokyo.paper.event.player.PlayerPickupExperienceEvent; import com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent; +import com.shanebeestudios.skbee.api.util.Util; import io.papermc.paper.event.block.BeaconActivatedEvent; import io.papermc.paper.event.block.BeaconDeactivatedEvent; import io.papermc.paper.event.entity.EntityInsideBlockEvent; @@ -46,11 +47,11 @@ public class PaperEvents extends SimpleEvent { // Player Recipe Book Click Event if (Skript.classExists("com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent")) { Skript.registerEvent("Recipe Book Click Event", PaperEvents.class, PlayerRecipeBookClickEvent.class, "[player] recipe book click") - .description("Called when the player clicks on a recipe in their recipe book. Requires Paper 1.15+") - .examples("on recipe book click:", - "\tif event-string = \"minecraft:diamond_sword\":", - "\t\tcancel event") - .since("1.5.0"); + .description("Called when the player clicks on a recipe in their recipe book. Requires Paper 1.15+") + .examples("on recipe book click:", + "\tif event-string = \"minecraft:diamond_sword\":", + "\t\tcancel event") + .since("1.5.0"); EventValues.registerEventValue(PlayerRecipeBookClickEvent.class, String.class, new Getter<>() { @Override @@ -63,14 +64,14 @@ public class PaperEvents extends SimpleEvent { // Player Pickup XP Event if (Skript.classExists("com.destroystokyo.paper.event.player.PlayerPickupExperienceEvent")) { Skript.registerEvent("Player Pickup Experience Orb", PaperEvents.class, PlayerPickupExperienceEvent.class, - "player pickup (experience|xp) [orb]") - .description("Fired when a player is attempting to pick up an experience orb. Requires Paper 1.12.2+", - "\n`event-experience` represents the experience picked up (This is Skript's version of XP).", - "\n`event-number` represents the experience picked up as a number.", - "\n`event-entity` represents the experience orb entity.") - .examples("on player pickup xp:", - "\tadd 10 to level of player") - .since("1.8.0"); + "player pickup (experience|xp) [orb]") + .description("Fired when a player is attempting to pick up an experience orb. Requires Paper 1.12.2+", + "\n`event-experience` represents the experience picked up (This is Skript's version of XP).", + "\n`event-number` represents the experience picked up as a number.", + "\n`event-entity` represents the experience orb entity.") + .examples("on player pickup xp:", + "\tadd 10 to level of player") + .since("1.8.0"); EventValues.registerEventValue(PlayerPickupExperienceEvent.class, Experience.class, new Getter<>() { @Override @@ -97,10 +98,10 @@ public Entity get(PlayerPickupExperienceEvent event) { // Player Elytra Boost Event if (Skript.classExists("com.destroystokyo.paper.event.player.PlayerElytraBoostEvent")) { Skript.registerEvent("Player Elytra Boost", PaperEvents.class, PlayerElytraBoostEvent.class, "[player] elytra boost") - .description("Fired when a player boosts elytra flight with a firework. Requires Paper 1.13.2+") - .examples("on elytra boost:", - "\tpush player forward at speed 50") - .since("1.8.0"); + .description("Fired when a player boosts elytra flight with a firework. Requires Paper 1.13.2+") + .examples("on elytra boost:", + "\tpush player forward at speed 50") + .since("1.8.0"); EventValues.registerEventValue(PlayerElytraBoostEvent.class, ItemType.class, new Getter<>() { @Override public ItemType get(PlayerElytraBoostEvent e) { @@ -112,13 +113,13 @@ public ItemType get(PlayerElytraBoostEvent e) { // Player Stop Using Item Event if (Skript.classExists("io.papermc.paper.event.player.PlayerStopUsingItemEvent")) { Skript.registerEvent("Player Stop Using Item", PaperEvents.class, PlayerStopUsingItemEvent.class, "[player] stop using item") - .description("Called when the server detects a player stopping using an item.", - "Examples of this are letting go of the interact button when holding a bow, an edible item, or a spyglass.", - "event-number is the number of ticks the item was held for. Requires Paper 1.18+.") - .examples("on player stop using item:", - "\tif event-item is a spyglass:", - "\t\tkill player") - .since("1.17.0"); + .description("Called when the server detects a player stopping using an item.", + "Examples of this are letting go of the interact button when holding a bow, an edible item, or a spyglass.", + "event-number is the number of ticks the item was held for. Requires Paper 1.18+.") + .examples("on player stop using item:", + "\tif event-item is a spyglass:", + "\t\tkill player") + .since("1.17.0"); EventValues.registerEventValue(PlayerStopUsingItemEvent.class, ItemType.class, new Getter<>() { @Override public ItemType get(PlayerStopUsingItemEvent event) { @@ -135,12 +136,14 @@ public Number get(PlayerStopUsingItemEvent event) { // Player Change Beacon Effect Event if (Skript.classExists("io.papermc.paper.event.player.PlayerChangeBeaconEffectEvent")) { - Skript.registerEvent("Beacon - Player Change Effect", PaperEvents.class, PlayerChangeBeaconEffectEvent.class, "[player] change beacon [potion] effect[s]", "beacon [potion] effect change") - .description("Called when a player changes the current potion effects of a beacon.") - .examples("on beacon potion effect change:", - "\tprimary beacon effect of event-block is jump boost", - "\tset primary beacon effect of event-block to levitation") - .since("2.16.0"); + Skript.registerEvent("Beacon - Player Change Effect", PaperEvents.class, PlayerChangeBeaconEffectEvent.class, + "[player] change beacon [potion] effect[s]", + "beacon [potion] effect change") + .description("Called when a player changes the current potion effects of a beacon.") + .examples("on beacon potion effect change:", + "\tprimary beacon effect of event-block is jump boost", + "\tset primary beacon effect of event-block to levitation") + .since("2.16.0"); EventValues.registerEventValue(PlayerChangeBeaconEffectEvent.class, Block.class, new Getter<>() { @Override @@ -154,16 +157,16 @@ public Block get(PlayerChangeBeaconEffectEvent event) { // Player Chunk Load Event if (Skript.classExists("io.papermc.paper.event.packet.PlayerChunkLoadEvent")) { Skript.registerEvent("Player Chunk Load", PaperEvents.class, PlayerChunkLoadEvent.class, - "player chunk (send|load)") - .description("Is called when a Player receives a Chunk.", - "Can for example be used for spawning a fake entity when the player receives a chunk. ", - "Should only be used for packet/clientside related stuff. Not intended for modifying server side state.", - "\nRequires a PaperMC server.") - .examples("on player chunk send:", - "\tloop all blocks in event-chunk:", - "\t\tif loop-block is diamond ore:", - "\t\t\tmake player see loop-block as stone") - .since("2.6.1"); + "player chunk (send|load)") + .description("Is called when a Player receives a Chunk.", + "Can for example be used for spawning a fake entity when the player receives a chunk. ", + "Should only be used for packet/clientside related stuff. Not intended for modifying server side state.", + "\nRequires a PaperMC server.") + .examples("on player chunk send:", + "\tloop all blocks in event-chunk:", + "\t\tif loop-block is diamond ore:", + "\t\t\tmake player see loop-block as stone") + .since("2.6.1"); EventValues.registerEventValue(PlayerChunkLoadEvent.class, Player.class, new Getter<>() { @Override @@ -176,13 +179,13 @@ public Block get(PlayerChangeBeaconEffectEvent event) { // Player Chunk Unload Event if (Skript.classExists("io.papermc.paper.event.packet.PlayerChunkUnloadEvent")) { Skript.registerEvent("Player Chunk Unload", PaperEvents.class, PlayerChunkUnloadEvent.class, - "player chunk unload") - .description("Is called when a Player receives a chunk unload packet.", - "Should only be used for packet/clientside related stuff. Not intended for modifying server side.", - "\nRequires a PaperMC server.") - .examples("on player chunk unload:", - "\tsend \"looks like you lost your chunk cowboy!\" to player") - .since("2.6.1"); + "player chunk unload") + .description("Is called when a Player receives a chunk unload packet.", + "Should only be used for packet/clientside related stuff. Not intended for modifying server side.", + "\nRequires a PaperMC server.") + .examples("on player chunk unload:", + "\tsend \"looks like you lost your chunk cowboy!\" to player") + .since("2.6.1"); EventValues.registerEventValue(PlayerChunkUnloadEvent.class, Player.class, new Getter<>() { @Override @@ -197,12 +200,12 @@ public Block get(PlayerChangeBeaconEffectEvent event) { // Entity Pathfind Event if (Skript.classExists("com.destroystokyo.paper.event.entity.EntityPathfindEvent")) { Skript.registerEvent("Entity Pathfind Event", PaperEvents.class, new Class[]{EntityPathfindEvent.class, SlimePathfindEvent.class}, "entity start[s] pathfinding") - .description("Called when an Entity decides to start moving towards a location. This event does not fire for the entities " + - "actual movement. Only when it is choosing to start moving to a location. Requires Paper.") - .examples("on entity starts pathfinding:", - "\tif event-entity is a sheep:", - "\t\tcancel event") - .since("1.5.0"); + .description("Called when an Entity decides to start moving towards a location. This event does not fire for the entities " + + "actual movement. Only when it is choosing to start moving to a location. Requires Paper.") + .examples("on entity starts pathfinding:", + "\tif event-entity is a sheep:", + "\t\tcancel event") + .since("1.5.0"); EventValues.registerEventValue(EntityPathfindEvent.class, Location.class, new Getter<>() { @Override @@ -215,22 +218,22 @@ public Block get(PlayerChangeBeaconEffectEvent event) { // Skeleton Horse Trap Event if (Skript.classExists("com.destroystokyo.paper.event.entity.SkeletonHorseTrapEvent")) { Skript.registerEvent("Skeleton Horse Trap Event", PaperEvents.class, SkeletonHorseTrapEvent.class, "skeleton horse trap") - .description("Called when a player gets close to a skeleton horse and triggers the lightning trap. Requires Paper 1.13+") - .examples("on skeleton horse trap:", - "\tloop all players in radius 10 around event-entity:", - "\t\tif loop-player is an op:", - "\t\t\tcancel event") - .since("1.5.0"); + .description("Called when a player gets close to a skeleton horse and triggers the lightning trap. Requires Paper 1.13+") + .examples("on skeleton horse trap:", + "\tloop all players in radius 10 around event-entity:", + "\t\tif loop-player is an op:", + "\t\t\tcancel event") + .since("1.5.0"); } // Entity Zap Event if (Skript.classExists("com.destroystokyo.paper.event.entity.EntityZapEvent")) { Skript.registerEvent("Entity Zap", PaperEvents.class, EntityZapEvent.class, "entity (zap|struck by lightning)") - .description("Fired when lightning strikes an entity. Requires Paper 1.10.2+") - .examples("on entity zap:", - "\tif event-entity is a pig:", - "\t\tspawn 3 zombie pigmen at event-location") - .since("1.8.0"); + .description("Fired when lightning strikes an entity. Requires Paper 1.10.2+") + .examples("on entity zap:", + "\tif event-entity is a pig:", + "\t\tspawn 3 zombie pigmen at event-location") + .since("1.8.0"); EventValues.registerEventValue(EntityZapEvent.class, Location.class, new Getter<>() { @Override public Location get(EntityZapEvent e) { @@ -242,93 +245,100 @@ public Location get(EntityZapEvent e) { // Entity Knockback Event if (Skript.classExists("com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent")) { Skript.registerEvent("Entity Knockback", PaperEvents.class, EntityKnockbackByEntityEvent.class, "entity knockback") - .description("Fired when an Entity is knocked back by the hit of another Entity. " + - "If this event is cancelled, the entity is not knocked back. Requires Paper 1.12.2+") - .examples("on entity knockback:", "\tif event-entity is a cow:", "\t\tcancel event") - .since("1.8.0"); + .description("Fired when an Entity is knocked back by the hit of another Entity. " + + "If this event is cancelled, the entity is not knocked back. Requires Paper 1.12.2+") + .examples("on entity knockback:", "\tif event-entity is a cow:", "\t\tcancel event") + .since("1.8.0"); } // Experience Orb Merge Event if (Skript.classExists("com.destroystokyo.paper.event.entity.ExperienceOrbMergeEvent")) { Skript.registerEvent("Experience Orb Merge", PaperEvents.class, ExperienceOrbMergeEvent.class, "(experience|[e]xp) orb merge") - .description("Fired anytime the server is about to merge 2 experience orbs into one. Requires Paper 1.12.2+") - .examples("on xp merge:", - "\tcancel event") - .since("1.8.0"); + .description("Fired anytime the server is about to merge 2 experience orbs into one. Requires Paper 1.12.2+") + .examples("on xp merge:", + "\tcancel event") + .since("1.8.0"); } // Entity Add To World Event if (Skript.classExists("com.destroystokyo.paper.event.entity.EntityAddToWorldEvent")) { Skript.registerEvent("Entity Add to World", PaperEvents.class, EntityAddToWorldEvent.class, - "entity add[ed] to world") - .description("Fired any time an entity is being added to the world for any reason.", - "Not to be confused with entity spawn event. This will fire anytime a chunk is reloaded too. Requires a PaperMC server.") - .examples("on entity added to world:", - "\tdelete event-entity") - .since("2.7.2"); + "entity add[ed] to world") + .description("Fired any time an entity is being added to the world for any reason.", + "Not to be confused with entity spawn event. This will fire anytime a chunk is reloaded too. Requires a PaperMC server.") + .examples("on entity added to world:", + "\tdelete event-entity") + .since("2.7.2"); } // == BLOCK EVENTS == // // Beacon Effect Event - if (Skript.classExists("com.destroystokyo.paper.event.block.BeaconEffectEvent")) { - Skript.registerEvent("Beacon Effect", PaperEvents.class, BeaconEffectEvent.class, "beacon effect") - .description("Called when a beacon effect is being applied to a player. Requires Paper 1.9+") + if (!Util.IS_RUNNING_SKRIPT_2_10) { + if (Skript.classExists("com.destroystokyo.paper.event.block.BeaconEffectEvent")) { + Skript.registerEvent("Beacon Effect", PaperEvents.class, BeaconEffectEvent.class, "beacon effect") + .description("Called when a beacon effect is being applied to a player.", + "Removed if running Skript 2.10+ (now included in Skript).", + "Requires Paper 1.9+") .examples("on beacon effect:", - "\tif event-player does not have permission \"my.server.beacons\":", - "\t\tcancel event") + "\tif event-player does not have permission \"my.server.beacons\":", + "\t\tcancel event") .since("1.8.4"); - EventValues.registerEventValue(BeaconEffectEvent.class, Player.class, new Getter<>() { - @Override - public Player get(BeaconEffectEvent e) { - return e.getPlayer(); - } - }, EventValues.TIME_NOW); - - EventValues.registerEventValue(BeaconEffectEvent.class, PotionEffectType.class, new Getter<>() { - @Override - public PotionEffectType get(BeaconEffectEvent e) { - return e.getEffect().getType(); - } - }, EventValues.TIME_NOW); - EventValues.registerEventValue(BeaconEffectEvent.class, PotionEffect.class, new Getter<>() { - @Override - public @NotNull PotionEffect get(BeaconEffectEvent e) { - return e.getEffect(); - } - }, EventValues.TIME_NOW); - } - - // Beacon Deactivated Event - if (Skript.classExists("io.papermc.paper.event.block.BeaconDeactivatedEvent")) { - Skript.registerEvent("Beacon Deactivation", PaperEvents.class, BeaconDeactivatedEvent.class, "beacon (deactivate|deactivation)") - .description("Called when a beacon is deactivated from breaking or losing required amount blocks.") + EventValues.registerEventValue(BeaconEffectEvent.class, Player.class, new Getter<>() { + @Override + public Player get(BeaconEffectEvent e) { + return e.getPlayer(); + } + }, EventValues.TIME_NOW); + + EventValues.registerEventValue(BeaconEffectEvent.class, PotionEffectType.class, new Getter<>() { + @Override + public PotionEffectType get(BeaconEffectEvent e) { + return e.getEffect().getType(); + } + }, EventValues.TIME_NOW); + EventValues.registerEventValue(BeaconEffectEvent.class, PotionEffect.class, new Getter<>() { + @Override + public @NotNull PotionEffect get(BeaconEffectEvent e) { + return e.getEffect(); + } + }, EventValues.TIME_NOW); + } + + + // Beacon Deactivated Event + if (Skript.classExists("io.papermc.paper.event.block.BeaconDeactivatedEvent")) { + Skript.registerEvent("Beacon Deactivation", PaperEvents.class, BeaconDeactivatedEvent.class, "beacon (deactivate|deactivation)") + .description("Called when a beacon is deactivated from breaking or losing required amount blocks.", + "Removed if running Skript 2.10+ (now included in Skript).") .examples("on beacon deactivation:", - "\tbroadcast \"%event-block% is no longer activated, :cry:\""); + "\tbroadcast \"%event-block% is no longer activated, :cry:\""); - } + } - // Beacon Activated Event - if (Skript.classExists("io.papermc.paper.event.block.BeaconActivatedEvent")) { - Skript.registerEvent("Beacon Activation", PaperEvents.class, BeaconActivatedEvent.class, "beacon (activate|activation)") - .description("Called when a beacon is successfully activated by having correct amount of blocks.") + // Beacon Activated Event + if (Skript.classExists("io.papermc.paper.event.block.BeaconActivatedEvent")) { + Skript.registerEvent("Beacon Activation", PaperEvents.class, BeaconActivatedEvent.class, "beacon (activate|activation)") + .description("Called when a beacon is successfully activated by having correct amount of blocks.", + "Removed if running Skript 2.10+ (now included in Skript).") .examples("on beacon activation", - "\tset primary effect of event-block to strength") + "\tset primary effect of event-block to strength") .since("2.16.0"); + } } if (Skript.classExists("io.papermc.paper.event.entity.EntityInsideBlockEvent")) { Skript.registerEvent("Entity Inside Block", PaperEvents.class, EntityInsideBlockEvent.class, "entity inside block") - .description("Called when an entity enters the hitbox of a block.", - "Only called for blocks that react when an entity is inside.", - "If cancelled, any action that would have resulted from that entity being in the block will not happen (such as extinguishing an entity in a cauldron).", - "Currently called for: Big dripleaf, Bubble column, Buttons, Cactus, Campfire, Cauldron, Crops, Ender Portal, Fires, Frogspawn, Honey, Hopper, Detector rails,", - "Nether portals, Pitcher crop, Powdered snow, Pressure plates, Sweet berry bush, Tripwire, Waterlily, Web, Wither rose") - .examples("on entity inside block:", - "\tif event-block is a cactus:", - "\t\tcancel event", - "\t\tbroadcast \"OUCHIE\"") - .since("3.4.0"); + .description("Called when an entity enters the hitbox of a block.", + "Only called for blocks that react when an entity is inside.", + "If cancelled, any action that would have resulted from that entity being in the block will not happen (such as extinguishing an entity in a cauldron).", + "Currently called for: Big dripleaf, Bubble column, Buttons, Cactus, Campfire, Cauldron, Crops, Ender Portal, Fires, Frogspawn, Honey, Hopper, Detector rails,", + "Nether portals, Pitcher crop, Powdered snow, Pressure plates, Sweet berry bush, Tripwire, Waterlily, Web, Wither rose") + .examples("on entity inside block:", + "\tif event-block is a cactus:", + "\t\tcancel event", + "\t\tbroadcast \"OUCHIE\"") + .since("3.4.0"); EventValues.registerEventValue(EntityInsideBlockEvent.class, Block.class, new Getter<>() { @Override @@ -341,16 +351,16 @@ public Block get(EntityInsideBlockEvent event) { // PlayerAttemptPickupItemEvent if (Skript.classExists("org.bukkit.event.player.PlayerAttemptPickupItemEvent")) { Skript.registerEvent("Player Attempt Item Pickup", PaperEvents.class, PlayerAttemptPickupItemEvent.class, "player attempt item pickup") - .description("Called when a player attempts to pick an item up from the ground. Requires PaperMC.", - "`event-number` = Represents the amount that will remain on the ground, if any.", - "`past event-number` = Represents the item amount of the dropped item before pickup.", - "`event-dropped item` = Represents the dropped item entity that is attempting to pickup.") - .examples("on player attempt item pickup:", - "\tif event-number > 0:", - "\t\twait 1 tick", - "\t\tadd (item of event-dropped item) to enderchest of player", - "\t\tkill event-dropped item") - .since("3.5.0"); + .description("Called when a player attempts to pick an item up from the ground. Requires PaperMC.", + "`event-number` = Represents the amount that will remain on the ground, if any.", + "`past event-number` = Represents the item amount of the dropped item before pickup.", + "`event-dropped item` = Represents the dropped item entity that is attempting to pickup.") + .examples("on player attempt item pickup:", + "\tif event-number > 0:", + "\t\twait 1 tick", + "\t\tadd (item of event-dropped item) to enderchest of player", + "\t\tkill event-dropped item") + .since("3.5.0"); EventValues.registerEventValue(PlayerAttemptPickupItemEvent.class, Number.class, new Getter<>() { @Override diff --git a/src/main/java/com/shanebeestudios/skbee/elements/other/expressions/ExprBreedEntities.java b/src/main/java/com/shanebeestudios/skbee/elements/other/expressions/ExprBreedEntities.java index c7efb604d..317d8ef78 100644 --- a/src/main/java/com/shanebeestudios/skbee/elements/other/expressions/ExprBreedEntities.java +++ b/src/main/java/com/shanebeestudios/skbee/elements/other/expressions/ExprBreedEntities.java @@ -12,6 +12,7 @@ import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; +import com.shanebeestudios.skbee.api.util.Util; import org.bukkit.entity.Entity; import org.bukkit.event.Event; import org.bukkit.event.entity.EntityBreedEvent; @@ -19,17 +20,20 @@ import org.jetbrains.annotations.Nullable; @Name("Breed Event Entities") -@Description("Get the entities involved in a breed event.") +@Description({"Get the entities involved in a breed event.", + "Removed if running Skript 2.10+ (now included in Skript).",}) @Examples({"on entity breed:", - "\tif breeding mother is a sheep:", - "\t\tkill breeding player"}) + "\tif breeding mother is a sheep:", + "\t\tkill breeding player"}) @Since("1.17.0") public class ExprBreedEntities extends SimpleExpression { static { - Skript.registerExpression(ExprBreedEntities.class, Entity.class, ExpressionType.SIMPLE, + if (!Util.IS_RUNNING_SKRIPT_2_10) { + Skript.registerExpression(ExprBreedEntities.class, Entity.class, ExpressionType.SIMPLE, "[the] breed[ing] parents", "[the] breed[ing] (mother|1:father|2:baby|3:player)"); + } } private int pattern; diff --git a/src/main/java/com/shanebeestudios/skbee/elements/other/expressions/ExprItemFlags.java b/src/main/java/com/shanebeestudios/skbee/elements/other/expressions/ExprItemFlags.java index cd1d8e7e0..af5772df5 100644 --- a/src/main/java/com/shanebeestudios/skbee/elements/other/expressions/ExprItemFlags.java +++ b/src/main/java/com/shanebeestudios/skbee/elements/other/expressions/ExprItemFlags.java @@ -11,6 +11,7 @@ import ch.njol.skript.lang.SkriptParser; import ch.njol.util.Kleenean; import ch.njol.util.coll.CollectionUtils; +import com.shanebeestudios.skbee.api.util.Util; import org.bukkit.event.Event; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.meta.ItemMeta; @@ -22,20 +23,23 @@ import java.util.Set; @Name("ItemFlag - ItemFlags of Items") -@Description("Get/Set the ItemFlags of an item.") +@Description({"Get/Set the ItemFlags of an item.", + "Removed if running Skript 2.10+ (now included in Skript)."}) @Examples({"set {_flags::*} to item flags of player's tool", - "add hide enchants to item flags of player's tool", - "add hide attributes to item flags of player's tool", - "add hide enchants and hide attributes to item flags of player's tool", - "remove hide enchants from item flags of player's tool", - "remove hide attributes from item flags of player's tool", - "delete item flags of player's tool", - "reset item flags of player's tool"}) + "add hide enchants to item flags of player's tool", + "add hide attributes to item flags of player's tool", + "add hide enchants and hide attributes to item flags of player's tool", + "remove hide enchants from item flags of player's tool", + "remove hide attributes from item flags of player's tool", + "delete item flags of player's tool", + "reset item flags of player's tool"}) @Since("3.4.0") public class ExprItemFlags extends PropertyExpression { static { - register(ExprItemFlags.class, ItemFlag.class, "item[ ]flags", "itemtypes"); + if (!Util.IS_RUNNING_SKRIPT_2_10) { + register(ExprItemFlags.class, ItemFlag.class, "item[ ]flags", "itemtypes"); + } } @SuppressWarnings({"NullableProblems", "unchecked"}) diff --git a/src/main/java/com/shanebeestudios/skbee/elements/other/expressions/ExprItemFlagsItem.java b/src/main/java/com/shanebeestudios/skbee/elements/other/expressions/ExprItemFlagsItem.java index abcf5ddb0..a08e9ebf3 100644 --- a/src/main/java/com/shanebeestudios/skbee/elements/other/expressions/ExprItemFlagsItem.java +++ b/src/main/java/com/shanebeestudios/skbee/elements/other/expressions/ExprItemFlagsItem.java @@ -11,6 +11,7 @@ import ch.njol.skript.lang.SkriptParser.ParseResult; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.util.Kleenean; +import com.shanebeestudios.skbee.api.util.Util; import org.bukkit.event.Event; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.meta.ItemMeta; @@ -18,21 +19,24 @@ import org.jetbrains.annotations.Nullable; @Name("ItemFlag - Item with ItemFlags") -@Description("Get an item with ItemFlags.") +@Description({"Get an item with ItemFlags.", + "Removed if running Skript 2.10+ (now included in Skript)."}) @Examples({"set {_sword} to diamond sword with all item flags", - "set {_sword} to diamond sword of sharpness 3 with hide enchants item flag", - "set {_sword} to diamond sword of sharpness 3 with item flag hide enchants", - "give player fishing rod of lure 10 with item flag hide enchants", - "give player potion of extended regeneration with hide enchants itemflag", - "give player netherite leggings with itemflag hide attributes"}) + "set {_sword} to diamond sword of sharpness 3 with hide enchants item flag", + "set {_sword} to diamond sword of sharpness 3 with item flag hide enchants", + "give player fishing rod of lure 10 with item flag hide enchants", + "give player potion of extended regeneration with hide enchants itemflag", + "give player netherite leggings with itemflag hide attributes"}) @Since("3.4.0") public class ExprItemFlagsItem extends SimpleExpression { static { - Skript.registerExpression(ExprItemFlagsItem.class, ItemType.class, ExpressionType.COMBINED, + if (!Util.IS_RUNNING_SKRIPT_2_10) { + Skript.registerExpression(ExprItemFlagsItem.class, ItemType.class, ExpressionType.COMBINED, "%itemtype% with all item[ ]flags", "%itemtype% with item[ ]flag[s] %itemflags%", "%itemtype% with %itemflags% item[ ]flag[s]"); + } } private int pattern; diff --git a/src/main/java/com/shanebeestudios/skbee/elements/other/expressions/ExprLastDeathLocation.java b/src/main/java/com/shanebeestudios/skbee/elements/other/expressions/ExprLastDeathLocation.java index dec867c46..8f67f7f9f 100644 --- a/src/main/java/com/shanebeestudios/skbee/elements/other/expressions/ExprLastDeathLocation.java +++ b/src/main/java/com/shanebeestudios/skbee/elements/other/expressions/ExprLastDeathLocation.java @@ -7,6 +7,7 @@ import ch.njol.skript.doc.Since; import ch.njol.skript.expressions.base.SimplePropertyExpression; import ch.njol.util.coll.CollectionUtils; +import com.shanebeestudios.skbee.api.util.Util; import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; @@ -15,15 +16,19 @@ import org.jetbrains.annotations.Nullable; @Name("Death Location of Player") -@Description("Represents the last death location of player. Set/Delete will only work for online players not offline players.") +@Description({"Represents the last death location of player.", + "Set/Delete will only work for online players not offline players.", + "Removed if running Skript 2.10+ (now included in Skript)."}) @Examples({"command /death:", - "\ttrigger:", - "\t\tteleport player to last death location of player"}) + "\ttrigger:", + "\t\tteleport player to last death location of player"}) @Since("2.8.5") public class ExprLastDeathLocation extends SimplePropertyExpression { static { - register(ExprLastDeathLocation.class, Location.class, "[last ]death location", "offlineplayers"); + if (!Util.IS_RUNNING_SKRIPT_2_10) { + register(ExprLastDeathLocation.class, Location.class, "[last ]death location", "offlineplayers"); + } } @Override diff --git a/src/main/java/com/shanebeestudios/skbee/elements/other/type/Types.java b/src/main/java/com/shanebeestudios/skbee/elements/other/type/Types.java index a0fdc2c40..2cad11676 100644 --- a/src/main/java/com/shanebeestudios/skbee/elements/other/type/Types.java +++ b/src/main/java/com/shanebeestudios/skbee/elements/other/type/Types.java @@ -58,18 +58,21 @@ public class Types { public static boolean HAS_CHUNK_LOAD_LEVEL = Skript.classExists("org.bukkit.Chunk$LoadLevel"); static { - if (Classes.getExactClassInfo(ItemFlag.class) == null) { - EnumWrapper ITEM_FLAGS = new EnumWrapper<>(ItemFlag.class); - Classes.registerClass(ITEM_FLAGS.getClassInfo("itemflag") - .user("item ?flags?") - .name("ItemFlag") - .description("Represents the different ItemFlags that can be applied to an item.", - "NOTE: Underscores aren't required, you CAN use spaces.", - "NOTE: These are auto-generated and may differ between server versions.") - .since("3.4.0")); - } else { - Util.logLoading("It looks like another addon registered 'itemflag' already."); - Util.logLoading("You may have to use their ItemFlags in SkBee's 'Item Flags' expressions."); + if (!Util.IS_RUNNING_SKRIPT_2_10) { + if (Classes.getExactClassInfo(ItemFlag.class) == null) { + EnumWrapper ITEM_FLAGS = new EnumWrapper<>(ItemFlag.class); + Classes.registerClass(ITEM_FLAGS.getClassInfo("itemflag") + .user("item ?flags?") + .name("ItemFlag") + .description("Represents the different ItemFlags that can be applied to an item.", + "Removed if running Skript 2.10+ (now included in Skript).", + "NOTE: Underscores aren't required, you CAN use spaces.", + "NOTE: These are auto-generated and may differ between server versions.") + .since("3.4.0")); + } else { + Util.logLoading("It looks like another addon registered 'itemflag' already."); + Util.logLoading("You may have to use their ItemFlags in SkBee's 'Item Flags' expressions."); + } } // Only register if no other addons have registered this class @@ -88,17 +91,20 @@ public class Types { // Only register if no other addons have registered this class // EntityPotionEffectEvent.Cause - if (Classes.getExactClassInfo(Cause.class) == null) { - EnumWrapper POTION_EFFECT_EVENT_CAUSE = new EnumWrapper<>(Cause.class, "", "effect"); - Classes.registerClass(POTION_EFFECT_EVENT_CAUSE.getClassInfo("potioneffectcause") - .user("potion ?effect ?causes?") - .name("Potion Effect Cause") - .description("Represents the different causes of an entity potion effect event.", - "NOTE: These are auto-generated and may differ between server versions.") - .since("1.17.0")); - } else { - Util.logLoading("It looks like another addon registered 'potioneffectcause' already."); - Util.logLoading("You may have to use their potion effect causes in SkBee's 'Entity Potion Effect' event."); + if (!Util.IS_RUNNING_SKRIPT_2_10) { + if (Classes.getExactClassInfo(Cause.class) == null) { + EnumWrapper POTION_EFFECT_EVENT_CAUSE = new EnumWrapper<>(Cause.class, "", "effect"); + Classes.registerClass(POTION_EFFECT_EVENT_CAUSE.getClassInfo("potioneffectcause") + .user("potion ?effect ?causes?") + .name("Potion Effect Cause") + .description("Represents the different causes of an entity potion effect event.", + "Removed if running Skript 2.10+ (now included in Skript).", + "NOTE: These are auto-generated and may differ between server versions.") + .since("1.17.0")); + } else { + Util.logLoading("It looks like another addon registered 'potioneffectcause' already."); + Util.logLoading("You may have to use their potion effect causes in SkBee's 'Entity Potion Effect' event."); + } } if (Classes.getExactClassInfo(NamespacedKey.class) == null) { diff --git a/src/main/java/com/shanebeestudios/skbee/elements/villager/expressions/ExprVillagerLevel.java b/src/main/java/com/shanebeestudios/skbee/elements/villager/expressions/ExprVillagerLevel.java index b1a509967..86b41855a 100644 --- a/src/main/java/com/shanebeestudios/skbee/elements/villager/expressions/ExprVillagerLevel.java +++ b/src/main/java/com/shanebeestudios/skbee/elements/villager/expressions/ExprVillagerLevel.java @@ -10,6 +10,7 @@ import ch.njol.skript.lang.SkriptParser.ParseResult; import ch.njol.util.Kleenean; import ch.njol.util.coll.CollectionUtils; +import com.shanebeestudios.skbee.api.util.Util; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Villager; import org.bukkit.event.Event; @@ -18,17 +19,20 @@ @Name("Villager - Level/Experience") @Description({"Represents the level/experience of a villager.", - "Level is between 1 and 5.","" + - "Experience is a number greater than or equal to 0."}) + "Removed if running Skript 2.10+ (now included in Skript).", + "Level is between 1 and 5.", + "Experience is a number greater than or equal to 0."}) @Examples({"set villager level of target entity to 5", - "set villager experience of last spawned villager to 10", - "if villager level of target entity > 2:", - "if villager experience of target entity > 10:"}) + "set villager experience of last spawned villager to 10", + "if villager level of target entity > 2:", + "if villager experience of target entity > 10:"}) @Since("1.17.0") public class ExprVillagerLevel extends SimplePropertyExpression { static { - register(ExprVillagerLevel.class, Number.class, "villager (level|1:experience)", "livingentities"); + if (!Util.IS_RUNNING_SKRIPT_2_10) { + register(ExprVillagerLevel.class, Number.class, "villager (level|1:experience)", "livingentities"); + } } private int pattern; diff --git a/src/main/java/com/shanebeestudios/skbee/elements/villager/expressions/ExprVillagerProfession.java b/src/main/java/com/shanebeestudios/skbee/elements/villager/expressions/ExprVillagerProfession.java index b9b4075c9..0ace0e7ec 100644 --- a/src/main/java/com/shanebeestudios/skbee/elements/villager/expressions/ExprVillagerProfession.java +++ b/src/main/java/com/shanebeestudios/skbee/elements/villager/expressions/ExprVillagerProfession.java @@ -8,21 +8,25 @@ import ch.njol.skript.expressions.base.SimplePropertyExpression; import ch.njol.skript.lang.Expression; import ch.njol.util.coll.CollectionUtils; +import com.shanebeestudios.skbee.api.util.Util; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Villager; import org.bukkit.entity.Villager.Profession; import org.bukkit.event.Event; -import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; @Name("Villager - Profession") -@Description("Represents the profession of a villager.") +@Description({"Represents the profession of a villager.", + "Removed if running Skript 2.10+ (now included in Skript)."}) @Examples("set profession of target entity to nitwit profession") @Since("1.17.0") public class ExprVillagerProfession extends SimplePropertyExpression { static { - register(ExprVillagerProfession.class, Profession.class, "profession", "livingentities"); + if (!Util.IS_RUNNING_SKRIPT_2_10) { + register(ExprVillagerProfession.class, Profession.class, "profession", "livingentities"); + } } @Override diff --git a/src/main/java/com/shanebeestudios/skbee/elements/villager/expressions/ExprVillagerType.java b/src/main/java/com/shanebeestudios/skbee/elements/villager/expressions/ExprVillagerType.java index 8f212b371..a7fc9987b 100644 --- a/src/main/java/com/shanebeestudios/skbee/elements/villager/expressions/ExprVillagerType.java +++ b/src/main/java/com/shanebeestudios/skbee/elements/villager/expressions/ExprVillagerType.java @@ -7,22 +7,26 @@ import ch.njol.skript.doc.Since; import ch.njol.skript.expressions.base.SimplePropertyExpression; import ch.njol.util.coll.CollectionUtils; +import com.shanebeestudios.skbee.api.util.Util; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Villager; import org.bukkit.entity.Villager.Type; import org.bukkit.event.Event; -import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; @Name("Villager - Type") -@Description("Represents the type of villager. Resetting will set a villager to a plains villager.") +@Description({"Represents the type of villager. Resetting will set a villager to a plains villager.", + "Removed if running Skript 2.10+ (now included in Skript)."}) @Examples({"set {_t} to villager type of last spawned villager", - "set villager type of target entity to desert villager"}) + "set villager type of target entity to desert villager"}) @Since("1.17.0") public class ExprVillagerType extends SimplePropertyExpression { static { - register(ExprVillagerType.class, Type.class, "villager type", "livingentities"); + if (!Util.IS_RUNNING_SKRIPT_2_10) { + register(ExprVillagerType.class, Type.class, "villager type", "livingentities"); + } } @Override diff --git a/src/main/java/com/shanebeestudios/skbee/elements/villager/type/Types.java b/src/main/java/com/shanebeestudios/skbee/elements/villager/type/Types.java index 1e85e46af..bb9a59efe 100644 --- a/src/main/java/com/shanebeestudios/skbee/elements/villager/type/Types.java +++ b/src/main/java/com/shanebeestudios/skbee/elements/villager/type/Types.java @@ -25,34 +25,38 @@ public class Types { static { - // VILLAGER PROFESSION - // Only register if no other addons have registered this class - if (Classes.getExactClassInfo(Profession.class) == null) { - Classes.registerClass(RegistryClassInfo.create(Registry.VILLAGER_PROFESSION, - Profession.class, "profession", "", "profession") - .user("professions?") - .name("Villager Profession") - .description("Represent the types of professions for villagers.", - "Due to not parsing correctly, the professions are suffixed with 'profession'.") - .since("1.17.0")); - } else { - Util.logLoading("It looks like another addon registered 'profession' already."); - Util.logLoading("You may have to use their profession in SkBee's 'Villager Profession' expression."); - } + if (!Util.IS_RUNNING_SKRIPT_2_10) { + // VILLAGER PROFESSION + // Only register if no other addons have registered this class + if (Classes.getExactClassInfo(Profession.class) == null) { + Classes.registerClass(RegistryClassInfo.create(Registry.VILLAGER_PROFESSION, + Profession.class, "profession", "", "profession") + .user("professions?") + .name("Villager Profession") + .description("Represent the types of professions for villagers.", + "Removed if running Skript 2.10+ (now included in Skript).", + "Due to not parsing correctly, the professions are suffixed with 'profession'.") + .since("1.17.0")); + } else { + Util.logLoading("It looks like another addon registered 'profession' already."); + Util.logLoading("You may have to use their profession in SkBee's 'Villager Profession' expression."); + } - // VILLAGER TYPE - // Only register if no other addons have registered this class - if (Classes.getExactClassInfo(Type.class) == null) { - Classes.registerClass(RegistryClassInfo.create(Registry.VILLAGER_TYPE, - Type.class, "villagertype", "", "villager") - .user("villager ?types?") - .name("Villager Type") - .description("Represents the types of villagers.", - "Due to possible overlaps with biomes, types are suffixed with 'villager'.") - .since("1.17.0")); - } else { - Util.logLoading("It looks like another addon registered 'villagertype' already."); - Util.logLoading("You may have to use their villagertype in SkBee's 'Villager Type' expression."); + // VILLAGER TYPE + // Only register if no other addons have registered this class + if (Classes.getExactClassInfo(Type.class) == null) { + Classes.registerClass(RegistryClassInfo.create(Registry.VILLAGER_TYPE, + Type.class, "villagertype", "", "villager") + .user("villager ?types?") + .name("Villager Type") + .description("Represents the types of villagers.", + "Removed if running Skript 2.10+ (now included in Skript).", + "Due to possible overlaps with biomes, types are suffixed with 'villager'.") + .since("1.17.0")); + } else { + Util.logLoading("It looks like another addon registered 'villagertype' already."); + Util.logLoading("You may have to use their villagertype in SkBee's 'Villager Type' expression."); + } } // MERCHANT