-
-
Notifications
You must be signed in to change notification settings - Fork 112
Dragon tags & mechs #2620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dragon tags & mechs #2620
Changes from 8 commits
1de7488
cb733f3
3520fa5
5f1b351
a6691b6
09bf2b3
62a9c7b
1353da1
ac3169b
dac18a9
432fb02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,14 @@ | ||
| package com.denizenscript.denizen.paper.properties; | ||
|
|
||
| import com.denizenscript.denizen.nms.NMSHandler; | ||
| import com.denizenscript.denizen.nms.NMSVersion; | ||
| import com.denizenscript.denizen.objects.EntityTag; | ||
| import com.denizenscript.denizen.objects.LocationTag; | ||
| import com.denizenscript.denizen.objects.WorldTag; | ||
| import com.denizenscript.denizen.utilities.BukkitImplDeprecations; | ||
| import com.denizenscript.denizencore.objects.core.ElementTag; | ||
| import com.denizenscript.denizencore.objects.core.ListTag; | ||
| import org.bukkit.boss.DragonBattle; | ||
|
|
||
| public class PaperWorldExtensions { | ||
|
|
||
|
|
@@ -23,6 +29,81 @@ public static void register() { | |
| return new ElementTag(world.getWorld().getNoTickViewDistance()); | ||
| }); | ||
|
|
||
| if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_20)) { | ||
|
|
||
| // <--[tag] | ||
| // @attribute <WorldTag.gateway_count> | ||
| // @returns ElementTag(Number) | ||
| // @description | ||
| // Returns the number of end gateway portals. | ||
| // Only works in end worlds. | ||
|
||
| // --> | ||
| WorldTag.tagProcessor.registerTag(ElementTag.class, "gateway_count", (attribute, object) -> { | ||
| DragonBattle battle = object.getWorld().getEnderDragonBattle(); | ||
| if (battle == null) { | ||
| attribute.echoError("Provided world is not an end world!"); | ||
| return null; | ||
| } | ||
| return new ElementTag(battle.getGatewayCount()); | ||
| }); | ||
|
|
||
| // <--[tag] | ||
| // @attribute <WorldTag.healing_crystals> | ||
| // @returns ListTag(EntityTag) | ||
| // @description | ||
| // Returns a ListTag of the healing crystals located on top of the obsidian towers. | ||
|
||
| // Only works in end worlds. | ||
| // --> | ||
| WorldTag.tagProcessor.registerTag(ListTag.class, "healing_crystals", (attribute, object) -> { | ||
| DragonBattle battle = object.getWorld().getEnderDragonBattle(); | ||
| if (battle == null) { | ||
| attribute.echoError("Provided world is not an end world!"); | ||
| return null; | ||
| } | ||
| return new ListTag(battle.getHealingCrystals(), EntityTag::new); | ||
| }); | ||
|
|
||
| // <--[tag] | ||
| // @attribute <WorldTag.healing_crystals> | ||
|
||
| // @returns ListTag(EntityTag) | ||
| // @description | ||
| // Returns a ListTag of the respawn crystals located at the end exit portal. | ||
|
||
| // Only works in end worlds. | ||
| // --> | ||
| WorldTag.tagProcessor.registerTag(ListTag.class, "respawn_crystals", (attribute, object) -> { | ||
| DragonBattle battle = object.getWorld().getEnderDragonBattle(); | ||
| if (battle == null) { | ||
| attribute.echoError("Provided world is not an end world!"); | ||
| return null; | ||
| } | ||
| return new ListTag(battle.getRespawnCrystals(), EntityTag::new); | ||
| }); | ||
|
|
||
| // <--[mechanism] | ||
| // @object WorldTag | ||
| // @name spawn_gateway | ||
| // @input LocationTag | ||
| // @Plugin Paper | ||
| // @group paper | ||
| // @description | ||
| // If no location is specified, tries to spawn a new end gateway using default game mechanics. Otherwise, spawns a new end gateway portal at the specified location. | ||
|
||
| // Only works in end worlds. | ||
| // --> | ||
| WorldTag.tagProcessor.registerMechanism("spawn_gateway", false, (object, mechanism) -> { | ||
| DragonBattle battle = object.getWorld().getEnderDragonBattle(); | ||
| if (battle == null) { | ||
| mechanism.echoError("Cannot spawn gateway in non-end world!"); | ||
| return; | ||
mcmonkey4eva marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| if (!mechanism.hasValue()) { | ||
| battle.spawnNewGateway(); | ||
| } | ||
| else if (mechanism.requireObject(LocationTag.class)) { | ||
| battle.spawnNewGateway(mechanism.getValue().asType(LocationTag.class, mechanism.context)); | ||
|
||
| } | ||
| }); | ||
| } | ||
|
|
||
| // <--[mechanism] | ||
| // @object WorldTag | ||
| // @name view_distance | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
|
|
||
| import com.denizenscript.denizen.events.BukkitScriptEvent; | ||
| import com.denizenscript.denizen.nms.NMSHandler; | ||
| import com.denizenscript.denizen.nms.NMSVersion; | ||
| import com.denizenscript.denizen.nms.abstracts.BiomeNMS; | ||
| import com.denizenscript.denizen.utilities.flags.WorldFlagHandler; | ||
| import com.denizenscript.denizencore.flags.AbstractFlagTracker; | ||
|
|
@@ -837,6 +838,7 @@ else if (time >= 12500) { | |
| registerTag(LocationTag.class, "dragon_portal_location", (attribute, object) -> { | ||
| DragonBattle battle = object.getWorld().getEnderDragonBattle(); | ||
| if (battle == null) { | ||
| attribute.echoError("Provided world is not an end world!"); | ||
| return null; | ||
| } | ||
| if (battle.getEndPortalLocation() == null) { | ||
|
|
@@ -1006,6 +1008,92 @@ else if (time >= 12500) { | |
| registerTag(ElementTag.class, "is_night", (attribute, world) -> { | ||
| return new ElementTag(NMSHandler.worldHelper.isNight(world.getWorld())); | ||
| }); | ||
|
|
||
| // <--[tag] | ||
| // @attribute <WorldTag.first_dragon_killed> | ||
| // @returns ElementTag(Boolean) | ||
| // @description | ||
| // Returns whether the ender dragon has been killed in this world before. | ||
| // Only works in end worlds. | ||
| // --> | ||
| registerTag(ElementTag.class, "first_dragon_killed", (attribute, object) -> { | ||
| DragonBattle battle = object.getWorld().getEnderDragonBattle(); | ||
| if (battle == null) { | ||
| attribute.echoError("Provided world is not an end world!"); | ||
| return null; | ||
| } | ||
| return new ElementTag(battle.hasBeenPreviouslyKilled()); | ||
| }); | ||
|
|
||
| // <--[mechanism] | ||
| // @object WorldTag | ||
| // @name respawn_dragon | ||
| // @description | ||
| // Initiates the respawn sequence of the ender dragon as if a player placed 4 end crystals on the portal. | ||
| // Only works in end worlds. | ||
| // --> | ||
| tagProcessor.registerMechanism("respawn_dragon", false, (object, mechanism) -> { | ||
| DragonBattle battle = object.getWorld().getEnderDragonBattle(); | ||
| if (battle == null) { | ||
| mechanism.echoError("Provided world is not an end world!"); | ||
| return; | ||
| } | ||
| battle.initiateRespawn(); | ||
| }); | ||
|
|
||
| // <--[mechanism] | ||
| // @object WorldTag | ||
| // @name reset_crystals | ||
| // @description | ||
| // Resets the end crystals located on the obsidian pillars in this world. | ||
| // Only works in end worlds. | ||
| // --> | ||
| tagProcessor.registerMechanism("reset_crystals", false, (object, mechanism) -> { | ||
| DragonBattle battle = object.getWorld().getEnderDragonBattle(); | ||
| if (battle == null) { | ||
| mechanism.echoError("Provided world is not an end world!"); | ||
| return; | ||
mcmonkey4eva marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| battle.resetCrystals(); | ||
| }); | ||
|
|
||
| // <--[mechanism] | ||
| // @object WorldTag | ||
| // @name respawn_phase | ||
| // @input ElementTag | ||
| // @description | ||
| // Set the current respawn phase of the ender dragon. Valid phases can be found at <@link url https://jd.papermc.io/paper/1.20/org/bukkit/boss/DragonBattle.RespawnPhase.html> | ||
|
||
| // Only works in end worlds. | ||
| // --> | ||
| tagProcessor.registerMechanism("respawn_phase", false, ElementTag.class, (object, mechanism, input) -> { | ||
| DragonBattle battle = object.getWorld().getEnderDragonBattle(); | ||
| if (battle == null) { | ||
| mechanism.echoError("Provided world is not an end world!"); | ||
| return; | ||
| } | ||
| battle.setRespawnPhase(input.asEnum(DragonBattle.RespawnPhase.class)); | ||
| }); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs |
||
|
|
||
| if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_20)) { | ||
|
|
||
| // <--[mechanism] | ||
| // @object WorldTag | ||
| // @name respawn_phase | ||
|
||
| // @input ElementTag(Boolean) | ||
| // @description | ||
| // Set whether the first ender dragon was killed already. | ||
| // Only works in end worlds. | ||
|
||
| // --> | ||
| tagProcessor.registerMechanism("first_dragon_killed", false, ElementTag.class, (object, mechanism, input) -> { | ||
| DragonBattle battle = object.getWorld().getEnderDragonBattle(); | ||
| if (battle == null) { | ||
| mechanism.echoError("Provided world is not an end world!"); | ||
| return; | ||
| } | ||
| battle.setPreviouslyKilled(input.asBoolean()); | ||
| }); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs |
||
| } | ||
|
|
||
| } | ||
|
|
||
| public static ObjectTagProcessor<WorldTag> tagProcessor = new ObjectTagProcessor<>(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.