mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-09-29 23:27:28 +02:00
Fix fireworks, protect by default (this is a behavioral change).
Add regions.use-paper-entity-origin setting, false by default because it can have some weird implications.
This commit is contained in:
parent
14fe2d0e79
commit
48922118b1
@ -70,6 +70,7 @@ public class BukkitWorldConfiguration extends YamlWorldConfiguration {
|
|||||||
public Set<PotionEffectType> blockPotions;
|
public Set<PotionEffectType> blockPotions;
|
||||||
public TargetMatcherSet allowAllInteract;
|
public TargetMatcherSet allowAllInteract;
|
||||||
public TargetMatcherSet blockUseAtFeet;
|
public TargetMatcherSet blockUseAtFeet;
|
||||||
|
public boolean usePaperEntityOrigin;
|
||||||
/* Configuration data end */
|
/* Configuration data end */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -144,6 +145,8 @@ public void loadConfiguration() {
|
|||||||
blockUseAtFeet = getTargetMatchers("event-handling.emit-block-use-at-feet");
|
blockUseAtFeet = getTargetMatchers("event-handling.emit-block-use-at-feet");
|
||||||
ignoreHopperMoveEvents = getBoolean("event-handling.ignore-hopper-item-move-events", false);
|
ignoreHopperMoveEvents = getBoolean("event-handling.ignore-hopper-item-move-events", false);
|
||||||
|
|
||||||
|
usePaperEntityOrigin = getBoolean("regions.use-paper-entity-origin", false);
|
||||||
|
|
||||||
itemDurability = getBoolean("protection.item-durability", true);
|
itemDurability = getBoolean("protection.item-durability", true);
|
||||||
removeInfiniteStacks = getBoolean("protection.remove-infinite-stacks", false);
|
removeInfiniteStacks = getBoolean("protection.remove-infinite-stacks", false);
|
||||||
disableExpDrops = getBoolean("protection.disable-xp-orb-drops", false);
|
disableExpDrops = getBoolean("protection.disable-xp-orb-drops", false);
|
||||||
|
@ -242,12 +242,12 @@ public void addPlatformReports(ReportList report) {
|
|||||||
public ProfileService createProfileService(ProfileCache profileCache) {
|
public ProfileService createProfileService(ProfileCache profileCache) {
|
||||||
List<ProfileService> services = new ArrayList<>();
|
List<ProfileService> services = new ArrayList<>();
|
||||||
if (PaperLib.isPaper()) {
|
if (PaperLib.isPaper()) {
|
||||||
// Paper has a shared cache, and will do lookups for us if needed
|
// Paper has a shared cache
|
||||||
services.add(PaperProfileService.getInstance());
|
services.add(PaperProfileService.getInstance());
|
||||||
} else {
|
} else {
|
||||||
services.add(BukkitPlayerService.getInstance());
|
services.add(BukkitPlayerService.getInstance());
|
||||||
services.add(HttpRepositoryService.forMinecraft());
|
|
||||||
}
|
}
|
||||||
|
services.add(HttpRepositoryService.forMinecraft());
|
||||||
return new CacheForwardingService(new CombinedProfileService(services),
|
return new CacheForwardingService(new CombinedProfileService(services),
|
||||||
profileCache);
|
profileCache);
|
||||||
}
|
}
|
||||||
|
@ -35,9 +35,6 @@
|
|||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldguard.LocalPlayer;
|
import com.sk89q.worldguard.LocalPlayer;
|
||||||
import com.sk89q.worldguard.WorldGuard;
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
import com.sk89q.worldguard.commands.GeneralCommands;
|
|
||||||
import com.sk89q.worldguard.commands.ProtectionCommands;
|
|
||||||
import com.sk89q.worldguard.commands.ToggleCommands;
|
|
||||||
import com.sk89q.worldguard.bukkit.event.player.ProcessPlayerEvent;
|
import com.sk89q.worldguard.bukkit.event.player.ProcessPlayerEvent;
|
||||||
import com.sk89q.worldguard.bukkit.listener.BlacklistListener;
|
import com.sk89q.worldguard.bukkit.listener.BlacklistListener;
|
||||||
import com.sk89q.worldguard.bukkit.listener.BlockedPotionsListener;
|
import com.sk89q.worldguard.bukkit.listener.BlockedPotionsListener;
|
||||||
@ -63,6 +60,9 @@
|
|||||||
import com.sk89q.worldguard.bukkit.session.BukkitSessionManager;
|
import com.sk89q.worldguard.bukkit.session.BukkitSessionManager;
|
||||||
import com.sk89q.worldguard.bukkit.util.Events;
|
import com.sk89q.worldguard.bukkit.util.Events;
|
||||||
import com.sk89q.worldguard.bukkit.util.logging.ClassSourceValidator;
|
import com.sk89q.worldguard.bukkit.util.logging.ClassSourceValidator;
|
||||||
|
import com.sk89q.worldguard.commands.GeneralCommands;
|
||||||
|
import com.sk89q.worldguard.commands.ProtectionCommands;
|
||||||
|
import com.sk89q.worldguard.commands.ToggleCommands;
|
||||||
import com.sk89q.worldguard.protection.flags.Flag;
|
import com.sk89q.worldguard.protection.flags.Flag;
|
||||||
import com.sk89q.worldguard.protection.flags.registry.SimpleFlagRegistry;
|
import com.sk89q.worldguard.protection.flags.registry.SimpleFlagRegistry;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
|
@ -21,12 +21,26 @@
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldguard.LocalPlayer;
|
import com.sk89q.worldguard.LocalPlayer;
|
||||||
import com.sk89q.worldguard.WorldGuard;
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
|
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
import com.sk89q.worldguard.bukkit.cause.Cause;
|
||||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||||
import com.sk89q.worldguard.config.WorldConfiguration;
|
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||||
|
import com.sk89q.worldguard.domains.Association;
|
||||||
|
import com.sk89q.worldguard.protection.DelayedRegionOverlapAssociation;
|
||||||
|
import com.sk89q.worldguard.protection.association.Associables;
|
||||||
|
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||||
|
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,4 +115,34 @@ protected static boolean isRegionSupportEnabled(World world) {
|
|||||||
return getWorldConfig(world).useRegions;
|
return getWorldConfig(world).useRegions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected RegionAssociable createRegionAssociable(Cause cause) {
|
||||||
|
Object rootCause = cause.getRootCause();
|
||||||
|
|
||||||
|
if (!cause.isKnown()) {
|
||||||
|
return Associables.constant(Association.NON_MEMBER);
|
||||||
|
} else if (rootCause instanceof Player) {
|
||||||
|
return getPlugin().wrapPlayer((Player) rootCause);
|
||||||
|
} else if (rootCause instanceof OfflinePlayer) {
|
||||||
|
return getPlugin().wrapOfflinePlayer((OfflinePlayer) rootCause);
|
||||||
|
} else if (rootCause instanceof Entity) {
|
||||||
|
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||||
|
final Entity entity = (Entity) rootCause;
|
||||||
|
Location loc;
|
||||||
|
if (PaperLib.isPaper()
|
||||||
|
&& ((BukkitWorldConfiguration) getWorldConfig(BukkitAdapter.adapt(entity.getWorld()))).usePaperEntityOrigin) {
|
||||||
|
loc = entity.getOrigin();
|
||||||
|
if (loc == null) {
|
||||||
|
loc = entity.getLocation();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
loc = entity.getLocation();
|
||||||
|
}
|
||||||
|
return new DelayedRegionOverlapAssociation(query, BukkitAdapter.adapt(loc));
|
||||||
|
} else if (rootCause instanceof Block) {
|
||||||
|
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||||
|
return new DelayedRegionOverlapAssociation(query, BukkitAdapter.adapt(((Block) rootCause).getLocation()));
|
||||||
|
} else {
|
||||||
|
return Associables.constant(Association.NON_MEMBER);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,7 @@
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.FallingBlock;
|
import org.bukkit.entity.FallingBlock;
|
||||||
|
import org.bukkit.entity.Firework;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.ItemFrame;
|
import org.bukkit.entity.ItemFrame;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
@ -138,12 +139,11 @@
|
|||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class EventAbstractionListener extends AbstractListener {
|
public class EventAbstractionListener extends AbstractListener {
|
||||||
|
|
||||||
private final BlockEntityEventDebounce interactDebounce = new BlockEntityEventDebounce(10000);
|
private final BlockEntityEventDebounce interactDebounce = new BlockEntityEventDebounce(10000);
|
||||||
@ -767,7 +767,11 @@ public void onEntityDamage(EntityDamageEvent event) {
|
|||||||
} else if (event instanceof EntityDamageByEntityEvent) {
|
} else if (event instanceof EntityDamageByEntityEvent) {
|
||||||
EntityDamageByEntityEvent entityEvent = (EntityDamageByEntityEvent) event;
|
EntityDamageByEntityEvent entityEvent = (EntityDamageByEntityEvent) event;
|
||||||
Entity damager = entityEvent.getDamager();
|
Entity damager = entityEvent.getDamager();
|
||||||
Events.fireToCancel(event, new DamageEntityEvent(event, create(damager), event.getEntity()));
|
final DamageEntityEvent eventToFire = new DamageEntityEvent(event, create(damager), event.getEntity());
|
||||||
|
if (damager instanceof Firework) {
|
||||||
|
eventToFire.getRelevantFlags().add(Flags.FIREWORK_DAMAGE);
|
||||||
|
}
|
||||||
|
Events.fireToCancel(event, eventToFire);
|
||||||
|
|
||||||
// Item use event with the item in hand
|
// Item use event with the item in hand
|
||||||
// Older blacklist handler code used this, although it suffers from
|
// Older blacklist handler code used this, although it suffers from
|
||||||
|
@ -31,22 +31,17 @@
|
|||||||
import com.sk89q.worldguard.protection.flags.Flags;
|
import com.sk89q.worldguard.protection.flags.Flags;
|
||||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||||
import io.papermc.lib.PaperLib;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Firework;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class RegionFlagsListener extends AbstractListener {
|
public class RegionFlagsListener extends AbstractListener {
|
||||||
@ -143,25 +138,6 @@ public void onEntityDamage(EntityDamageEvent event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event instanceof EntityDamageByEntityEvent) {
|
|
||||||
Entity damager = (((EntityDamageByEntityEvent) event)).getDamager();
|
|
||||||
if (damager.getType() == EntityType.FIREWORK) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,10 +41,7 @@
|
|||||||
import com.sk89q.worldguard.bukkit.util.Materials;
|
import com.sk89q.worldguard.bukkit.util.Materials;
|
||||||
import com.sk89q.worldguard.commands.CommandUtils;
|
import com.sk89q.worldguard.commands.CommandUtils;
|
||||||
import com.sk89q.worldguard.config.WorldConfiguration;
|
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||||
import com.sk89q.worldguard.domains.Association;
|
|
||||||
import com.sk89q.worldguard.internal.permission.RegionPermissionModel;
|
import com.sk89q.worldguard.internal.permission.RegionPermissionModel;
|
||||||
import com.sk89q.worldguard.protection.DelayedRegionOverlapAssociation;
|
|
||||||
import com.sk89q.worldguard.protection.association.Associables;
|
|
||||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||||
import com.sk89q.worldguard.protection.flags.Flags;
|
import com.sk89q.worldguard.protection.flags.Flags;
|
||||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||||
@ -53,7 +50,6 @@
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -152,26 +148,6 @@ private boolean isWhitelisted(Cause cause, World world, boolean pvp) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private RegionAssociable createRegionAssociable(Cause cause) {
|
|
||||||
Object rootCause = cause.getRootCause();
|
|
||||||
|
|
||||||
if (!cause.isKnown()) {
|
|
||||||
return Associables.constant(Association.NON_MEMBER);
|
|
||||||
} else if (rootCause instanceof Player) {
|
|
||||||
return getPlugin().wrapPlayer((Player) rootCause);
|
|
||||||
} else if (rootCause instanceof OfflinePlayer) {
|
|
||||||
return getPlugin().wrapOfflinePlayer((OfflinePlayer) rootCause);
|
|
||||||
} else if (rootCause instanceof Entity) {
|
|
||||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
|
||||||
return new DelayedRegionOverlapAssociation(query, BukkitAdapter.adapt(((Entity) rootCause).getLocation()));
|
|
||||||
} else if (rootCause instanceof Block) {
|
|
||||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
|
||||||
return new DelayedRegionOverlapAssociation(query, BukkitAdapter.adapt(((Block) rootCause).getLocation()));
|
|
||||||
} else {
|
|
||||||
return Associables.constant(Association.NON_MEMBER);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPlaceBlock(final PlaceBlockEvent event) {
|
public void onPlaceBlock(final PlaceBlockEvent event) {
|
||||||
if (event.getResult() == Result.ALLOW) return; // Don't care about events that have been pre-allowed
|
if (event.getResult() == Result.ALLOW) return; // Don't care about events that have been pre-allowed
|
||||||
|
@ -44,7 +44,7 @@ public int getIdealRequestLimit() {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public Profile findByName(String name) {
|
public Profile findByName(String name) {
|
||||||
PlayerProfile profile = Bukkit.createProfile(name);
|
PlayerProfile profile = Bukkit.createProfile(name);
|
||||||
if (profile.complete(false)) {
|
if (profile.completeFromCache()) {
|
||||||
//noinspection ConstantConditions - completeFromCache guarantees non-null on success
|
//noinspection ConstantConditions - completeFromCache guarantees non-null on success
|
||||||
return new Profile(profile.getId(), profile.getName());
|
return new Profile(profile.getId(), profile.getName());
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,7 @@ public final class Flags {
|
|||||||
public static final StateFlag POTION_SPLASH = register(new StateFlag("potion-splash", false));
|
public static final StateFlag POTION_SPLASH = register(new StateFlag("potion-splash", false));
|
||||||
public static final StateFlag ITEM_FRAME_ROTATE = register(new StateFlag("item-frame-rotation", false));
|
public static final StateFlag ITEM_FRAME_ROTATE = register(new StateFlag("item-frame-rotation", false));
|
||||||
public static final StateFlag TRAMPLE_BLOCKS = register(new StateFlag("block-trampling", false));
|
public static final StateFlag TRAMPLE_BLOCKS = register(new StateFlag("block-trampling", false));
|
||||||
|
public static final StateFlag FIREWORK_DAMAGE = register(new StateFlag("firework-damage", false));
|
||||||
|
|
||||||
// These flags are similar to the ones above (used in tandem with BUILD),
|
// These flags are similar to the ones above (used in tandem with BUILD),
|
||||||
// but their defaults are set to TRUE because it is more user friendly.
|
// but their defaults are set to TRUE because it is more user friendly.
|
||||||
@ -86,7 +87,6 @@ public final class Flags {
|
|||||||
public static final StateFlag CREEPER_EXPLOSION = register(new StateFlag("creeper-explosion", true));
|
public static final StateFlag CREEPER_EXPLOSION = register(new StateFlag("creeper-explosion", true));
|
||||||
public static final StateFlag ENDERDRAGON_BLOCK_DAMAGE = register(new StateFlag("enderdragon-block-damage", true));
|
public static final StateFlag ENDERDRAGON_BLOCK_DAMAGE = register(new StateFlag("enderdragon-block-damage", true));
|
||||||
public static final StateFlag GHAST_FIREBALL = register(new StateFlag("ghast-fireball", true));
|
public static final StateFlag GHAST_FIREBALL = register(new StateFlag("ghast-fireball", true));
|
||||||
public static final StateFlag FIREWORK_DAMAGE = register(new StateFlag("firework-damage", true));
|
|
||||||
public static final StateFlag OTHER_EXPLOSION = register(new StateFlag("other-explosion", true));
|
public static final StateFlag OTHER_EXPLOSION = register(new StateFlag("other-explosion", true));
|
||||||
public static final StateFlag WITHER_DAMAGE = register(new StateFlag("wither-damage", true));
|
public static final StateFlag WITHER_DAMAGE = register(new StateFlag("wither-damage", true));
|
||||||
public static final StateFlag ENDER_BUILD = register(new StateFlag("enderman-grief", true));
|
public static final StateFlag ENDER_BUILD = register(new StateFlag("enderman-grief", true));
|
||||||
|
Loading…
Reference in New Issue
Block a user