Skip to content

Commit

Permalink
Merge branch 'EngineHub:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
7man7LMYT authored Jun 27, 2021
2 parents 08d1a5a + 32d16a7 commit b960599
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 30 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog

## 7.0.5

* Add a use-anvil flag and exclude it from the use flag (since they can break on use.)
* Expand crop-related options (crop-growth, etc) to sweet berry bushes, nether wart, and bamboo.
* Add a config option (`mobs.block-vehicle-entry`) to prevent non-players from entering vehicles.
* Add a UUID flag (for developers/API usage).
* Add map query methods with fallback flag (for developers/API usage).
* Add `on` and `off` optional arguments for `/rg toggle-bypass` command.
* Add additional timings info for session handlers.
* Fix sponge-simulation clearing NBT from blocks. Note that if you are using sponge simulation you should switch to something like CraftBook as the feature will be removed from WorldGuard in a future (major) version.
* Fix the `/rg` command showing up as unknown client-side to players without bypass perms.
* Fix error propagation from third-party flag loading causing WG to error.
* Fix a (harmless) exception that occurred when swapping armor slots to the offhand slot.
* Fix empty lines being sent on enderpearl/chorus-fruit teleport if the deny messages were empty.
* Fix an issue with falling blocks when using max-priority-association.
* Fix performance issues with third-party plugins querying protection for offline players.
* Fix dispensing shulkers over region boundaries.
* Fix iron door interaction being denied as if it were a regular door.
* Fix being able to enter/exit regions with the flag denied by using entity mounting functions in other plugins.

## 7.0.4 (including beta1)

* Add support for MC 1.16. Dropped support for previous versions.
Expand Down
1 change: 1 addition & 0 deletions config/checkstyle/import-control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<allow pkg="io.papermc.lib"/>
<allow pkg="com.destroystokyo.paper"/>
<allow pkg="co.aikar.timings.lib" />
<allow pkg="org.spigotmc" />
</subpackage>

</subpackage>
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
group=com.sk89q.worldguard
version=7.0.5-SNAPSHOT
version=7.0.6-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,12 @@ public void onBlockDispense(BlockDispenseEvent event) {
Block placed = dispenserBlock.getRelative(dispenser.getFacing());
Block clicked = placed.getRelative(dispenser.getFacing());
handleBlockRightClick(event, cause, item, clicked, placed);

// handle special dispenser behavior
if (item != null && Materials.isShulkerBox(item.getType())) {
Events.fireToCancel(event, new PlaceBlockEvent(event, cause, placed.getLocation(), item.getType()));
return;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.session.MoveType;
import com.sk89q.worldguard.session.Session;
import io.papermc.lib.PaperLib;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
Expand All @@ -40,6 +41,7 @@
import org.bukkit.event.vehicle.VehicleEnterEvent;
import org.bukkit.plugin.PluginManager;
import org.bukkit.util.Vector;
import org.spigotmc.event.entity.EntityMountEvent;

public class PlayerMoveListener implements Listener {

Expand All @@ -53,6 +55,9 @@ public void registerEvents() {
if (WorldGuard.getInstance().getPlatform().getGlobalStateManager().usePlayerMove) {
PluginManager pm = plugin.getServer().getPluginManager();
pm.registerEvents(this, plugin);
if (PaperLib.isSpigot()) {
pm.registerEvents(new EntityMountListener(), plugin);
}
}
}

Expand Down Expand Up @@ -145,4 +150,18 @@ public void onPlayerQuit(PlayerQuitEvent event) {
player.teleport(BukkitAdapter.adapt(loc));
}
}

private class EntityMountListener implements Listener {
@EventHandler
public void onEntityMount(EntityMountEvent event) {
Entity entity = event.getEntity();
if (entity instanceof Player) {
LocalPlayer player = plugin.wrapPlayer((Player) entity);
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().get(player);
if (null != session.testMoveTo(player, BukkitAdapter.adapt(event.getMount().getLocation()), MoveType.EMBARK, true)) {
event.setCancelled(true);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,7 @@ public final class Materials {
private static final Map<Material, Integer> MATERIAL_FLAGS = new EnumMap<>(Material.class);
private static final Set<PotionEffectType> DAMAGE_EFFECTS = new HashSet<>();

private static Set<Material> shulkerBoxes = new HashSet<>();

static {
shulkerBoxes.add(Material.SHULKER_BOX);
shulkerBoxes.add(Material.WHITE_SHULKER_BOX);
shulkerBoxes.add(Material.ORANGE_SHULKER_BOX);
shulkerBoxes.add(Material.MAGENTA_SHULKER_BOX);
shulkerBoxes.add(Material.LIGHT_BLUE_SHULKER_BOX);
shulkerBoxes.add(Material.YELLOW_SHULKER_BOX);
shulkerBoxes.add(Material.LIME_SHULKER_BOX);
shulkerBoxes.add(Material.PINK_SHULKER_BOX);
shulkerBoxes.add(Material.GRAY_SHULKER_BOX);
shulkerBoxes.add(Material.LIGHT_GRAY_SHULKER_BOX);
shulkerBoxes.add(Material.CYAN_SHULKER_BOX);
shulkerBoxes.add(Material.PURPLE_SHULKER_BOX);
shulkerBoxes.add(Material.BLUE_SHULKER_BOX);
shulkerBoxes.add(Material.BROWN_SHULKER_BOX);
shulkerBoxes.add(Material.GREEN_SHULKER_BOX);
shulkerBoxes.add(Material.RED_SHULKER_BOX);
shulkerBoxes.add(Material.BLACK_SHULKER_BOX);

ENTITY_ITEMS.put(EntityType.PAINTING, Material.PAINTING);
ENTITY_ITEMS.put(EntityType.ARROW, Material.ARROW);
ENTITY_ITEMS.put(EntityType.SNOWBALL, Material.SNOWBALL);
Expand Down Expand Up @@ -747,14 +727,15 @@ public final class Materials {
MATERIAL_FLAGS.put(Material.WEEPING_VINES_PLANT, 0);


// Fake tags
for (Material m : shulkerBoxes) {
MATERIAL_FLAGS.put(m, MODIFIED_ON_RIGHT);
}

// Generated via tag
for (Material door : Tag.DOORS.getValues()) {
MATERIAL_FLAGS.put(door, MODIFIED_ON_RIGHT);
for (Material woodenDoor : Tag.WOODEN_DOORS.getValues()) {
MATERIAL_FLAGS.put(woodenDoor, MODIFIED_ON_RIGHT);
}
for (Material woodenTrapdoor : Tag.WOODEN_TRAPDOORS.getValues()) {
MATERIAL_FLAGS.put(woodenTrapdoor, MODIFIED_ON_RIGHT);
}
for (Material shulkerBox : Tag.SHULKER_BOXES.getValues()) {
MATERIAL_FLAGS.put(shulkerBox, MODIFIED_ON_RIGHT);
}
for (Material boat : Tag.ITEMS_BOATS.getValues()) {
MATERIAL_FLAGS.put(boat, 0);
Expand Down Expand Up @@ -1034,6 +1015,16 @@ public static boolean isBoat(Material material) {
return Tag.ITEMS_BOATS.isTagged(material);
}

/**
* Test whether the given material is a Shulker Box.
*
* @param material the material
* @return true if a Shulker Box block
*/
public static boolean isShulkerBox(Material material) {
return Tag.SHULKER_BOXES.isTagged(material);
}

/**
* Test whether the given material is an inventory block.
*
Expand All @@ -1052,7 +1043,7 @@ public static boolean isInventoryBlock(Material material) {
|| material == Material.BARREL
|| material == Material.BLAST_FURNACE
|| material == Material.SMOKER
|| shulkerBoxes.contains(material);
|| Tag.SHULKER_BOXES.isTagged(material);
}

public static boolean isSpawnEgg(Material material) {
Expand Down Expand Up @@ -1321,7 +1312,7 @@ public static boolean isVine(Material newType) {
*/
public static boolean isUseFlagApplicable(Material material) {
if (Tag.BUTTONS.isTagged(material)
|| Tag.DOORS.isTagged(material)
|| Tag.WOODEN_DOORS.isTagged(material)
|| Tag.WOODEN_TRAPDOORS.isTagged(material)
|| Tag.FENCE_GATES.isTagged(material)
|| Tag.PRESSURE_PLATES.isTagged(material)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@
import static com.google.common.base.Preconditions.checkNotNull;

import com.sk89q.worldguard.domains.Association;
import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;

import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

Expand All @@ -34,6 +38,7 @@ public abstract class AbstractRegionOverlapAssociation implements RegionAssociab
protected Set<ProtectedRegion> source;
private boolean useMaxPriorityAssociation;
private int maxPriority;
private Set<ProtectedRegion> maxPriorityRegions;

protected AbstractRegionOverlapAssociation(@Nullable Set<ProtectedRegion> source, boolean useMaxPriorityAssociation) {
this.source = source;
Expand All @@ -43,13 +48,39 @@ protected AbstractRegionOverlapAssociation(@Nullable Set<ProtectedRegion> source
protected void calcMaxPriority() {
checkNotNull(source);
int best = 0;
Set<ProtectedRegion> bestRegions = new HashSet<>();
for (ProtectedRegion region : source) {
int priority = region.getPriority();
if (priority > best) {
best = priority;
bestRegions.clear();
bestRegions.add(region);
} else if (priority == best) {
bestRegions.add(region);
}
}
this.maxPriority = best;
this.maxPriorityRegions = bestRegions;
}

private boolean checkNonplayerProtectionDomains(Iterable<? extends ProtectedRegion> source, Collection<?> domains) {
if (source == null || domains == null || domains.isEmpty()) {
return false;
}

for (ProtectedRegion region : source) {
Set<String> regionDomains = region.getFlag(Flags.NONPLAYER_PROTECTION_DOMAINS);

if (regionDomains == null || regionDomains.isEmpty()) {
continue;
}

if (!Collections.disjoint(regionDomains, domains)) {
return true;
}
}

return false;
}

@Override
Expand All @@ -70,6 +101,18 @@ public Association getAssociation(List<ProtectedRegion> regions) {
return Association.OWNER;
}
}

Set<ProtectedRegion> source;

if (useMaxPriorityAssociation) {
source = maxPriorityRegions;
} else {
source = this.source;
}

if (checkNonplayerProtectionDomains(source, region.getFlag(Flags.NONPLAYER_PROTECTION_DOMAINS))) {
return Association.OWNER;
}
}

return Association.NON_MEMBER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public final class Flags {

// Overrides membership check
public static final StateFlag PASSTHROUGH = register(new StateFlag("passthrough", false));
public static final SetFlag<String> NONPLAYER_PROTECTION_DOMAINS = register(new SetFlag<>("nonplayer-protection-domains", new StringFlag(null)));

// This flag is unlike the others. It forces the checking of region membership
public static final StateFlag BUILD = register(new BuildFlag("build", true));
Expand Down

0 comments on commit b960599

Please sign in to comment.