Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ autoService = "com.google.auto.service:auto-service:1.1.1"
jsr305 = "com.google.code.findbugs:jsr305:3.0.2"
jetbrains-annotations = "org.jetbrains:annotations:24.1.0"

paperApi = "io.papermc.paper:paper-api:26.1.2.build.+"
paperApi = "io.papermc.paper:paper-api:26.2.build.+"
paperLib = "io.papermc:paperlib:1.0.8"

dummypermscompat = "com.sk89q:dummypermscompat:1.10"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.bukkit.entity.LightningStrike;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.SulfurCube;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.Vehicle;
Expand Down Expand Up @@ -117,7 +118,7 @@ public boolean isKnown() {
return false;
}

if (object instanceof TNTPrimed || object instanceof Vehicle) {
if (object instanceof TNTPrimed || object instanceof Vehicle || object instanceof SulfurCube) {
if (!PaperLib.isPaper()) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
import org.bukkit.entity.Mob;
import org.bukkit.entity.Painting;
import org.bukkit.entity.Player;
import org.bukkit.entity.SulfurCube;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.entity.WindCharge;
Expand Down Expand Up @@ -895,7 +896,18 @@ public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
if (matchingItem != null && hasInteractBypass(world, matchingItem)) {
useEntityEvent.setAllowed(true);
}
Events.fireToCancel(event, useEntityEvent);
if (!Events.fireToCancel(event, useEntityEvent)) {
/* Sulfur cube doesn't have API for interaction/ignition source tracking */
if(Entities.isSulfurCube(entity)) {
/* Remove player in case of using shears */
if(item.getType() == Material.SHEARS) {
Cause.untrackParentCause(entity);
/* Save player overwise */
} else {
Cause.trackParentCause(entity, player);
}
}
}
}

@EventHandler(ignoreCancelled = true)
Expand All @@ -917,6 +929,8 @@ public void onEntityDamage(EntityDamageEvent event) {
eventToFire.getRelevantFlags().add(Flags.FIREWORK_DAMAGE);
} else if (damager instanceof Creeper) {
eventToFire.getRelevantFlags().add(Flags.CREEPER_EXPLOSION);
} else if (damager instanceof SulfurCube) {
eventToFire.getRelevantFlags().add(Flags.TNT);
}
if (Events.fireToCancel(event, eventToFire)) {
if (damager instanceof Tameable && damager instanceof Mob) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import org.bukkit.entity.Item;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Player;
import org.bukkit.entity.SulfurCube;
import org.bukkit.entity.Tameable;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Result;
Expand Down Expand Up @@ -222,7 +223,7 @@ public void onBreakBlock(final BreakBlockEvent event) {
String what;

/* TNT */
if (event.getCause().find(EntityType.TNT, EntityType.TNT_MINECART) != null) {
if (event.getCause().find(EntityType.TNT, EntityType.TNT_MINECART, EntityType.SULFUR_CUBE) != null) {
canBreak = query.testBuild(BukkitAdapter.adapt(target), associable, combine(event, Flags.BLOCK_BREAK, Flags.TNT));
what = "use dynamite";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.SulfurCube;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.WindCharge;
Expand Down Expand Up @@ -487,7 +488,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
event.blockList().clear();
return;
}
} else if (ent instanceof TNTPrimed || ent instanceof ExplosiveMinecart) {
} else if (ent instanceof TNTPrimed || ent instanceof ExplosiveMinecart || ent instanceof SulfurCube) {
if (wcfg.blockTNTExplosions) {
event.setCancelled(true);
return;
Expand Down Expand Up @@ -615,7 +616,8 @@ public void onExplosionPrime(ExplosionPrimeEvent event) {
return;
}
} else if (event.getEntityType() == EntityType.TNT
|| event.getEntityType() == EntityType.TNT_MINECART) {
|| event.getEntityType() == EntityType.TNT_MINECART
|| event.getEntityType() == EntityType.SULFUR_CUBE) {
if (wcfg.blockTNTExplosions) {
event.setCancelled(true);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.bukkit.entity.Projectile;
import org.bukkit.entity.SpectralArrow;
import org.bukkit.entity.Steerable;
import org.bukkit.entity.SulfurCube;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.Vehicle;
Expand Down Expand Up @@ -78,7 +79,9 @@ public static boolean isTamed(@Nullable Entity entity) {
* @return true if TNT based
*/
public static boolean isTNTBased(Entity entity) {
return entity instanceof TNTPrimed || entity instanceof ExplosiveMinecart;
return entity instanceof TNTPrimed
|| entity instanceof ExplosiveMinecart
|| (entity instanceof SulfurCube && ((SulfurCube) entity).canExplode());
}

/**
Expand Down Expand Up @@ -265,9 +268,20 @@ public static boolean isPluginSpawning(CreatureSpawnEvent.SpawnReason spawnReaso
case Wither wither -> Flags.WITHER_DAMAGE;
case Creeper creeper -> Flags.CREEPER_EXPLOSION;
case TNTPrimed tnt -> Flags.TNT;
case SulfurCube sulfurCube -> Flags.TNT;
case ExplosiveMinecart minecart -> Flags.TNT;
case EnderDragon dragon -> Flags.ENDERDRAGON_BLOCK_DAMAGE;
case null, default -> Flags.OTHER_EXPLOSION;
};
}

/**
* Test whether an entity is Sulfur Cube.
*
* @param entity the entity
* @return true if sulfur cube
*/
public static boolean isSulfurCube(Entity entity) {
return entity instanceof SulfurCube;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,7 @@ public static EntityType getEntitySpawnEgg(Material material) {
case SQUID_SPAWN_EGG -> EntityType.SQUID;
case STRAY_SPAWN_EGG -> EntityType.STRAY;
case STRIDER_SPAWN_EGG -> EntityType.STRIDER;
case SULFUR_CUBE_SPAWN_EGG -> EntityType.SULFUR_CUBE;
case TADPOLE_SPAWN_EGG -> EntityType.TADPOLE;
case TRADER_LLAMA_SPAWN_EGG -> EntityType.TRADER_LLAMA;
case TROPICAL_FISH_SPAWN_EGG -> EntityType.TROPICAL_FISH;
Expand Down