-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
ProjectKorra Bridge #425
Open
xicxen
wants to merge
3
commits into
DenizenScript:master
Choose a base branch
from
xicxen:ProjectKorra
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
ProjectKorra Bridge #425
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/com/denizenscript/depenizen/bukkit/bridges/ProjectKorraBridge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.denizenscript.depenizen.bukkit.bridges; | ||
|
||
import com.denizenscript.denizencore.events.ScriptEvent; | ||
import com.denizenscript.denizencore.utilities.debugging.Debug; | ||
import com.denizenscript.depenizen.bukkit.Bridge; | ||
import com.denizenscript.depenizen.bukkit.events.projectkorra.*; | ||
|
||
public class ProjectKorraBridge extends Bridge { | ||
|
||
@Override | ||
public void init() { | ||
if (!plugin.isEnabled()) { | ||
Debug.log("ProjectKorra plugin is not enabled or not present. ProjectKorra events will not be available."); | ||
return; | ||
} | ||
ScriptEvent.registerScriptEvent(EntityBendingDeathScriptEvent.class); | ||
ScriptEvent.registerScriptEvent(PlayerAbilityDamageEntityScriptEvent.class); | ||
ScriptEvent.registerScriptEvent(PlayerAbilityEndScriptEvent.class); | ||
ScriptEvent.registerScriptEvent(PlayerAbilityProgressScriptEvent.class); | ||
ScriptEvent.registerScriptEvent(PlayerAbilityStartScriptEvent.class); | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
...com/denizenscript/depenizen/bukkit/events/projectkorra/EntityBendingDeathScriptEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package com.denizenscript.depenizen.bukkit.events.projectkorra; | ||
|
||
import com.denizenscript.denizen.events.BukkitScriptEvent; | ||
import com.denizenscript.denizen.objects.EntityTag; | ||
import com.denizenscript.denizen.objects.PlayerTag; | ||
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import com.denizenscript.denizencore.objects.core.ElementTag; | ||
import com.denizenscript.denizencore.scripts.ScriptEntryData; | ||
import com.projectkorra.projectkorra.event.EntityBendingDeathEvent; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
public class EntityBendingDeathScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
||
// <--[event] | ||
// @Events | ||
// projectkorra entity dies|death|killed | ||
// | ||
// @Switch by:<ability> to only process the event if the ability matches the specified ability. | ||
// | ||
// @Triggers when an entity dies from bending. | ||
// | ||
// @Context | ||
// <context.ability> returns the ability's name. | ||
// <context.source> returns the player who triggered the ability. | ||
// <context.target> returns the target damaged by the ability. | ||
// <context.damage> returns the damage dealt to the entity as a decimal. | ||
// <context.element> returns the ability's element name. | ||
// <context.is_explosive> returns if the ability is explosive. | ||
// <context.is_ignite> returns if the ability can ignite. | ||
// <context.is_sneak> returns if the ability is triggered by sneak. | ||
// | ||
// @Plugin Depenizen, ProjectKorra | ||
// | ||
// @Player Always. | ||
// | ||
// --> | ||
|
||
public EntityBendingDeathScriptEvent() { | ||
registerCouldMatcher("projectkorra entity dies|death|killed"); | ||
registerSwitches("by"); | ||
} | ||
|
||
public EntityBendingDeathEvent event; | ||
public ElementTag ability; | ||
|
||
@Override | ||
public boolean matches(ScriptPath path) { | ||
if ((path.eventArgLowerAt(3).equals("by")) && (ability == null || !path.tryArgObject(4, ability))) { | ||
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. this shouldn't be here |
||
return false; | ||
} | ||
if (!path.tryObjectSwitch("by", ability)) { | ||
return false; | ||
} | ||
return super.matches(path); | ||
} | ||
|
||
@Override | ||
public ScriptEntryData getScriptEntryData() { | ||
return new BukkitScriptEntryData(PlayerTag.mirrorBukkitPlayer(event.getAbility().getPlayer()), null); | ||
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. Can use the single-entity constructor, I.e. just pass in the player |
||
} | ||
|
||
@Override | ||
public ObjectTag getContext(String name) { | ||
return switch (name) { | ||
case "ability" -> ability; | ||
case "source" -> new PlayerTag(event.getAttacker()); | ||
case "target" -> new EntityTag(event.getEntity()); | ||
case "damage" -> new ElementTag(event.getDamage()); | ||
case "element" -> new ElementTag(event.getAbility().getElement().getName()); | ||
case "is_explosive" -> new ElementTag(event.getAbility().isExplosiveAbility()); | ||
case "is_ignite" -> new ElementTag(event.getAbility().isIgniteAbility()); | ||
case "is_sneak" -> new ElementTag(event.getAbility().isSneakAbility()); | ||
default -> super.getContext(name); | ||
}; | ||
} | ||
|
||
@EventHandler | ||
public void onBendingDeath(EntityBendingDeathEvent event) { | ||
this.event = event; | ||
this.ability = new ElementTag(event.getAbility().getName()); | ||
fire(event); | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
...izenscript/depenizen/bukkit/events/projectkorra/PlayerAbilityDamageEntityScriptEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package com.denizenscript.depenizen.bukkit.events.projectkorra; | ||
|
||
import com.denizenscript.denizen.events.BukkitScriptEvent; | ||
import com.denizenscript.denizen.objects.EntityTag; | ||
import com.denizenscript.denizen.objects.PlayerTag; | ||
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import com.denizenscript.denizencore.objects.core.ElementTag; | ||
import com.denizenscript.denizencore.scripts.ScriptEntryData; | ||
import com.projectkorra.projectkorra.event.AbilityDamageEntityEvent; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
public class PlayerAbilityDamageEntityScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
||
// <--[event] | ||
// @Events | ||
// projectkorra player damages player|entity | ||
// | ||
// @Switch by:<ability> to only process the event if the ability matches the specified ability. | ||
// | ||
// @Triggers when a player damages an entity with a bending ability. | ||
// | ||
// @Context | ||
// <context.ability> returns the ability's name. | ||
// <context.source> returns the player who triggered the ability. | ||
// <context.target> returns the target damaged by the ability. | ||
// <context.damage> returns the damage dealt to the entity as a decimal. | ||
// <context.element> returns the ability's element name. | ||
// <context.cooldown> returns the ability's cooldown. | ||
// <context.is_explosive> returns if the ability is explosive. | ||
// <context.is_ignite> returns if the ability can ignite. | ||
// <context.is_sneak> returns if the ability is triggered by sneak. | ||
// <context.ignores_armor> returns if the event ignores armor. | ||
// | ||
// @Plugin Depenizen, ProjectKorra | ||
// | ||
// @Player Always. | ||
// | ||
// --> | ||
|
||
public PlayerAbilityDamageEntityScriptEvent() { | ||
registerCouldMatcher("projectkorra player damages player|entity"); | ||
registerSwitches("by"); | ||
} | ||
|
||
public AbilityDamageEntityEvent event; | ||
public ElementTag ability; | ||
|
||
@Override | ||
public boolean matches(ScriptPath path) { | ||
if ((path.eventArgLowerAt(4).equals("by")) && (ability == null || !path.tryArgObject(5, ability))) { | ||
return false; | ||
} | ||
if (!path.tryObjectSwitch("by", ability)) { | ||
return false; | ||
} | ||
return super.matches(path); | ||
} | ||
|
||
@Override | ||
public ScriptEntryData getScriptEntryData() { | ||
return new BukkitScriptEntryData(PlayerTag.mirrorBukkitPlayer(event.getAbility().getPlayer()), null); | ||
} | ||
|
||
@Override | ||
public ObjectTag getContext(String name) { | ||
return switch (name) { | ||
case "ability" -> ability; | ||
case "source" -> new PlayerTag(event.getSource()); | ||
case "target" -> new EntityTag(event.getEntity()); | ||
case "damage" -> new ElementTag(event.getDamage()); | ||
case "element" -> new ElementTag(event.getAbility().getElement().getName()); | ||
case "cooldown" -> new ElementTag(event.getAbility().getCooldown()); | ||
case "is_explosive" -> new ElementTag(event.getAbility().isExplosiveAbility()); | ||
case "is_ignite" -> new ElementTag(event.getAbility().isIgniteAbility()); | ||
case "is_sneak" -> new ElementTag(event.getAbility().isSneakAbility()); | ||
case "ignores_armor" -> new ElementTag(event.doesIgnoreArmor()); | ||
default -> super.getContext(name); | ||
}; | ||
} | ||
|
||
@EventHandler | ||
public void onAbilityDamage(AbilityDamageEntityEvent event) { | ||
this.event = event; | ||
this.ability = new ElementTag(event.getAbility().getName()); | ||
fire(event); | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
...a/com/denizenscript/depenizen/bukkit/events/projectkorra/PlayerAbilityEndScriptEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package com.denizenscript.depenizen.bukkit.events.projectkorra; | ||
|
||
import com.denizenscript.denizencore.objects.core.ElementTag; | ||
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData; | ||
import com.denizenscript.denizen.events.BukkitScriptEvent; | ||
import com.denizenscript.denizen.objects.PlayerTag; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import com.denizenscript.denizencore.scripts.ScriptEntryData; | ||
import com.projectkorra.projectkorra.event.AbilityEndEvent; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
public class PlayerAbilityEndScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
||
// <--[event] | ||
// @Events | ||
// projectkorra player ends|stops | ||
// | ||
// @Switch ability:<ability> to only process the event if the ability matches the specified ability. | ||
// | ||
// @Triggers when a player ends a bending ability. | ||
// | ||
// @Context | ||
// <context.ability> returns the ability's name. | ||
// <context.source> returns the player who triggered the ability. | ||
// <context.element> returns the ability's element name. | ||
// <context.cooldown> returns the ability's cooldown. | ||
// <context.is_explosive> returns if the ability is explosive. | ||
// <context.is_harmless> returns if the ability is harmless. | ||
// <context.is_hidden> returns if the ability is hidden. | ||
// <context.is_ignite> returns if the ability can ignite. | ||
// <context.is_sneak> returns if the ability is triggered by sneak. | ||
// | ||
// @Plugin Depenizen, ProjectKorra | ||
// | ||
// @Player Always. | ||
// | ||
// --> | ||
|
||
public PlayerAbilityEndScriptEvent() { | ||
registerCouldMatcher("projectkorra player ends|stops"); | ||
registerSwitches("ability"); | ||
} | ||
|
||
public AbilityEndEvent event; | ||
public ElementTag ability; | ||
|
||
@Override | ||
public boolean matches(ScriptPath path) { | ||
if ((path.eventArgLowerAt(3).equals("ability")) && (ability == null || !path.tryArgObject(4, ability))) { | ||
return false; | ||
} | ||
if (!path.tryObjectSwitch("ability", ability)) { | ||
return false; | ||
} | ||
return super.matches(path); | ||
} | ||
|
||
@Override | ||
public ScriptEntryData getScriptEntryData() { | ||
return new BukkitScriptEntryData(PlayerTag.mirrorBukkitPlayer(event.getAbility().getPlayer()), null); | ||
} | ||
|
||
@Override | ||
public ObjectTag getContext(String name) { | ||
return switch (name) { | ||
case "ability" -> ability; | ||
case "source" -> new PlayerTag(event.getAbility().getPlayer()); | ||
case "element" -> new ElementTag(event.getAbility().getElement().getName()); | ||
case "cooldown" -> new ElementTag(event.getAbility().getCooldown()); | ||
case "is_explosive" -> new ElementTag(event.getAbility().isExplosiveAbility()); | ||
case "is_harmless" -> new ElementTag(event.getAbility().isHarmlessAbility()); | ||
case "is_hidden" -> new ElementTag(event.getAbility().isHiddenAbility()); | ||
case "is_ignite" -> new ElementTag(event.getAbility().isIgniteAbility()); | ||
case "is_sneak" -> new ElementTag(event.getAbility().isSneakAbility()); | ||
default -> super.getContext(name); | ||
}; | ||
} | ||
|
||
@EventHandler | ||
public void onAbilityEnd(AbilityEndEvent event) { | ||
this.event = event; | ||
this.ability = new ElementTag(event.getAbility().getName()); | ||
fire(event); | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
.../denizenscript/depenizen/bukkit/events/projectkorra/PlayerAbilityProgressScriptEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package com.denizenscript.depenizen.bukkit.events.projectkorra; | ||
|
||
import com.denizenscript.denizen.events.BukkitScriptEvent; | ||
import com.denizenscript.denizen.objects.PlayerTag; | ||
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import com.denizenscript.denizencore.objects.core.ElementTag; | ||
import com.denizenscript.denizencore.scripts.ScriptEntryData; | ||
import com.projectkorra.projectkorra.event.AbilityProgressEvent; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
public class PlayerAbilityProgressScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
||
// <--[event] | ||
// @Events | ||
// projectkorra player progresses|continues | ||
// | ||
// @Switch ability:<ability> to only process the event if the ability matches the specified ability. | ||
// | ||
// @Triggers when a player progresses a bending ability. | ||
// | ||
// @Context | ||
// <context.ability> returns the ability's name. | ||
// <context.source> returns the player who triggered the ability. | ||
// <context.element> returns the ability's element name. | ||
// <context.cooldown> returns the ability's cooldown. | ||
// <context.is_explosive> returns if the ability is explosive. | ||
// <context.is_harmless> returns if the ability is harmless. | ||
// <context.is_hidden> returns if the ability is hidden. | ||
// <context.is_ignite> returns if the ability can ignite. | ||
// <context.is_sneak> returns if the ability is triggered by sneak. | ||
// | ||
// @Plugin Depenizen, ProjectKorra | ||
// | ||
// @Player Always. | ||
// | ||
// --> | ||
|
||
public PlayerAbilityProgressScriptEvent() { | ||
registerCouldMatcher("projectkorra player progresses|continues"); | ||
registerSwitches("ability"); | ||
} | ||
|
||
public AbilityProgressEvent event; | ||
public ElementTag ability; | ||
|
||
@Override | ||
public boolean matches(ScriptPath path) { | ||
if ((path.eventArgLowerAt(3).equals("ability")) && (ability == null || !path.tryArgObject(4, ability))) { | ||
return false; | ||
} | ||
if (!path.tryObjectSwitch("ability", ability)) { | ||
return false; | ||
} | ||
return super.matches(path); | ||
} | ||
|
||
@Override | ||
public ScriptEntryData getScriptEntryData() { | ||
return new BukkitScriptEntryData(PlayerTag.mirrorBukkitPlayer(event.getAbility().getPlayer()), null); | ||
} | ||
|
||
@Override | ||
public ObjectTag getContext(String name) { | ||
return switch (name) { | ||
case "ability" -> ability; | ||
case "source" -> new PlayerTag(event.getAbility().getPlayer()); | ||
case "element" -> new ElementTag(event.getAbility().getElement().getName()); | ||
case "cooldown" -> new ElementTag(event.getAbility().getCooldown()); | ||
case "is_explosive" -> new ElementTag(event.getAbility().isExplosiveAbility()); | ||
case "is_harmless" -> new ElementTag(event.getAbility().isHarmlessAbility()); | ||
case "is_hidden" -> new ElementTag(event.getAbility().isHiddenAbility()); | ||
case "is_ignite" -> new ElementTag(event.getAbility().isIgniteAbility()); | ||
case "is_sneak" -> new ElementTag(event.getAbility().isSneakAbility()); | ||
default -> super.getContext(name); | ||
}; | ||
} | ||
|
||
@EventHandler | ||
public void onAbilityProgress(AbilityProgressEvent event) { | ||
this.event = event; | ||
this.ability = new ElementTag(event.getAbility().getName()); | ||
fire(event); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be
<entity>
ie dynamic match the entityThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also the three dies/death/killed variants are silly, pick one