Skip to content

Commit

Permalink
replace paper impl of PlayerShootsBow with spigot impl
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Nov 8, 2020
1 parent e5acbbb commit fc6cc0d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 50 deletions.
Expand Up @@ -18,7 +18,6 @@ public static void init() {
// Events
ScriptEvent.registerScriptEvent(new EntityKnocksbackEntityScriptEvent());
ScriptEvent.registerScriptEvent(new EntityPathfindScriptEvent());
ScriptEvent.registerScriptEvent(new EntityShootsBowPaperScriptEventImpl());
ScriptEvent.registerScriptEvent(new ExperienceOrbMergeScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerAbsorbsExperienceScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerBeaconEffectScriptEvent());
Expand Down

This file was deleted.

Expand Up @@ -11,6 +11,7 @@
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.core.ListTag;
import com.denizenscript.denizencore.scripts.ScriptEntryData;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -44,11 +45,11 @@ public class EntityShootsBowEvent extends BukkitScriptEvent implements Listener
// <context.projectile> returns a EntityTag of the projectile.
// <context.bow> returns the ItemTag of the bow used to shoot.
// <context.force> returns the force of the shot.
// <context.item> returns an ItemTag of the shot projectile, if any (on Paper servers only).
// <context.item> returns an ItemTag of the shot projectile, if any.
//
// @Determine
// ListTag(EntityTag) to change the projectile(s) being shot. (Note that in certain cases, determining an arrow may not be valid).
// "KEEP_ITEM" to keep the projectile item on shooting it (on Paper servers only).
// "KEEP_ITEM" to keep the projectile item on shooting it.
//
// @Player when the entity that shot the bow is a player.
//
Expand Down Expand Up @@ -107,9 +108,24 @@ public String getName() {
@Override
public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
String determination = determinationObj.toString();
if (Argument.valueOf(determination).matchesArgumentList(EntityTag.class)) {
if (determinationObj instanceof ElementTag && !isDefaultDetermination(determinationObj)) {
String lower = CoreUtilities.toLowerCase(determination);
if (lower.equals("keep_item")) {
event.setConsumeItem(false);
if (entity.isPlayer()) {
final Player p = entity.getPlayer();
Bukkit.getScheduler().scheduleSyncDelayedTask(DenizenAPI.getCurrentInstance(), new Runnable() {
@Override
public void run() {
p.updateInventory();
}
}, 1);
}
return true;
}
}
else if (Argument.valueOf(determination).matchesArgumentList(EntityTag.class)) {
cancelled = true;

// Get the list of entities
List<EntityTag> newProjectiles = ListTag.getListFor(determinationObj, getTagContext(path)).filter(EntityTag.class, path.container, true);
// Go through all the entities, spawning/teleporting them
Expand All @@ -121,7 +137,6 @@ public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
newProjectile.setShooter(entity);
}
}

// Mount the projectiles on top of each other
Position.mount(Conversion.convertEntities(newProjectiles));
// Get the last entity on the list, i.e. the one at the bottom
Expand Down Expand Up @@ -155,6 +170,9 @@ else if (name.equals("bow")) {
else if (name.equals("projectile")) {
return projectile;
}
if (name.equals("item")) {
return new ItemTag(event.getConsumable());
}
return super.getContext(name);
}

Expand Down
Expand Up @@ -19,12 +19,14 @@ public class PlayerLoginScriptEvent extends BukkitScriptEvent implements Listene
// player logs in (for the first time)
// player (first) login
//
// @Regex ^on player (logs in( for the first time)?|( first)? login)$
// @Regex ^on player( logs in( for the first time)?|( first)? login)$
//
// @Group Player
//
// @Triggers when a player logs in to the server. This is during the authentication process, and should NOT be confused with <@link event player joins>.
//
// @Warning Generally avoid this event. This is not a way to get a 'first join' event. This is an internal technical event, with specific uses (eg custom whitelisting).
//
// @Context
// <context.hostname> returns an ElementTag of the player's hostname.
//
Expand Down

0 comments on commit fc6cc0d

Please sign in to comment.