Skip to content
Permalink
Browse files

User paper firework tracking.

Hacky gradle tricks to make deps work.
  • Loading branch information...
wizjany committed Jul 28, 2019
1 parent 2e828e6 commit 57b87baaa2774fad078ed1d8219bfceb65727878
@@ -8,12 +8,12 @@ repositories {

dependencies {
compile project(path: ':worldguard-core', configuration: 'shadow')
api 'org.bukkit:bukkit:1.14.2-R0.1-SNAPSHOT'
api ('com.sk89q.worldedit:worldedit-bukkit:7.0.1-SNAPSHOT') {
exclude group: 'io.papermc', module: 'paperlib'
exclude group: 'org.bukkit', module: 'bukkit'
}
api 'com.destroystokyo.paper:paper-api:1.14.4-R0.1-SNAPSHOT'
implementation 'io.papermc:paperlib:1.0.2'
compileOnly 'com.destroystokyo.paper:paper-api:1.13.2-R0.1-SNAPSHOT'
implementation ('com.sk89q:commandbook:2.3') {
exclude group: 'com.sk89q', module: 'worldedit'
exclude group: 'com.zachsthings.libcomponents'
@@ -23,6 +23,15 @@ dependencies {
implementation 'org.bstats:bstats-bukkit:1.5'
}

def installer = install.repositories.mavenInstaller
def deployer = uploadArchives.repositories.mavenDeployer {}

[installer, deployer]*.pom*.whenConfigured {pom ->
def paper = pom.dependencies.find {dep -> dep.groupId == 'com.destroystokyo.paper' && dep.artifactId == 'paper-api' }
paper.groupId = 'org.bukkit'
paper.artifactId = 'bukkit'
}

processResources {
from (sourceSets.main.resources.srcDirs) {
expand project.properties
@@ -22,15 +22,27 @@
import com.google.common.base.Joiner;
import com.google.common.collect.Sets;
import com.sk89q.worldguard.bukkit.internal.WGMetadata;
import io.papermc.lib.PaperLib;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.entity.*;
import org.bukkit.entity.AreaEffectCloud;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.Vehicle;
import org.bukkit.metadata.Metadatable;

import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.UUID;

import static com.google.common.base.Preconditions.checkNotNull;

@@ -249,6 +261,14 @@ private void addAll(@Nullable Object... element) {
addAll(((TNTPrimed) o).getSource());
} else if (o instanceof Projectile) {
addAll(((Projectile) o).getShooter());
} else if (o instanceof Firework && PaperLib.isPaper()) {
UUID spawningUUID = ((Firework) o).getSpawningEntity();
if (spawningUUID != null) {
Entity spawningEntity = Bukkit.getEntity(spawningUUID);
if (spawningEntity != null) {
addAll(spawningEntity);
}
}
} else if (o instanceof Vehicle) {
addAll(((Vehicle) o).getPassengers());
} else if (o instanceof AreaEffectCloud) {
@@ -31,18 +31,22 @@
import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.regions.RegionQuery;
import io.papermc.lib.PaperLib;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;

import java.util.UUID;
import java.util.function.Predicate;

public class RegionFlagsListener extends AbstractListener {
@@ -142,7 +146,17 @@ public void onEntityDamage(EntityDamageEvent event) {
if (event instanceof EntityDamageByEntityEvent) {
Entity damager = (((EntityDamageByEntityEvent) event)).getDamager();
if (damager.getType() == EntityType.FIREWORK) {
if (!query.testState(BukkitAdapter.adapt(entity.getLocation()), (RegionAssociable) null, Flags.FIREWORK_DAMAGE)) {
RegionAssociable associable = null;
if (PaperLib.isPaper()) {
UUID spawning = ((Firework) damager).getSpawningEntity();
if (spawning != null) {
Player player = Bukkit.getPlayer(spawning);
if (player != null) {
associable = WorldGuardPlugin.inst().wrapPlayer(player);
}
}
}
if (!query.testState(BukkitAdapter.adapt(entity.getLocation()), associable, Flags.FIREWORK_DAMAGE)) {
event.setCancelled(true);
return;
}

0 comments on commit 57b87ba

Please sign in to comment.
You can’t perform that action at this time.