Skip to content

Commit

Permalink
Re-add block sign physics flag from Jilm's fork
Browse files Browse the repository at this point in the history
- Add JUnit to allow for tests to run
  • Loading branch information
RhysB committed Jan 3, 2024
1 parent de2aa7a commit 7039a23
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 32 deletions.
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@
<artifactId>opencsv</artifactId>
<version>2.0</version>
</dependency>


<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,48 +18,32 @@
*/
package com.sk89q.worldguard.bukkit;

import static com.sk89q.worldguard.bukkit.BukkitUtil.dropSign;
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;

import java.util.logging.Logger;

import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.blocks.ItemType;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.blacklist.events.BlockBreakBlacklistEvent;
import com.sk89q.worldguard.blacklist.events.BlockPlaceBlacklistEvent;
import com.sk89q.worldguard.blacklist.events.DestroyWithBlacklistEvent;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.managers.RegionManager;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.block.*;
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.PluginManager;

import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.blocks.ItemType;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.blacklist.events.BlockBreakBlacklistEvent;
import com.sk89q.worldguard.blacklist.events.BlockPlaceBlacklistEvent;
import com.sk89q.worldguard.blacklist.events.DestroyWithBlacklistEvent;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.managers.RegionManager;
import java.util.logging.Logger;

import static com.sk89q.worldguard.bukkit.BukkitUtil.dropSign;
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;

/**
* The listener for block events.
Expand Down Expand Up @@ -482,6 +466,14 @@ public void onBlockPhysics(BlockPhysicsEvent event) {
return;
}

//Block Sign Physics
if(event.getBlock().getTypeId() == 63 || event.getBlock().getTypeId() == 68) {
if (wcfg.useRegions && !this.plugin.getGlobalRegionManager().allows(DefaultFlag.SIGN_UPDATE, event.getBlock().getLocation())) {
event.setCancelled(true);
return;
}
}

int id = event.getChangedTypeId();

if (id == 13 && wcfg.noPhysicsGravel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public final class DefaultFlag {
public static final StateFlag ICE_MELT = new StateFlag("ice-melt", true);
public static final StateFlag MUSHROOMS = new StateFlag("mushroom-growth", true);
public static final StateFlag LEAF_DECAY = new StateFlag("leaf-decay", true);
public static final StateFlag SIGN_UPDATE = new StateFlag("sign-update", true); //Re-added from Jilm's fork
public static final StateFlag ENDER_BUILD = new StateFlag("enderman-grief", true);
public static final StateFlag INVINCIBILITY = new StateFlag("invincible", false);
public static final StateFlag ENTRY = new StateFlag("entry", true);
Expand Down Expand Up @@ -91,7 +92,7 @@ public final class DefaultFlag {
SNOW_FALL, SNOW_MELT, ICE_FORM, ICE_MELT, MUSHROOMS, LEAF_DECAY,
FIRE_SPREAD, LAVA_FIRE, LAVA_FLOW, WATER_FLOW,
TELE_LOC, TELE_PERM, SPAWN_LOC, SPAWN_PERM,
BLOCKED_CMDS, ALLOWED_CMDS, PRICE, BUYABLE,
BLOCKED_CMDS, ALLOWED_CMDS, PRICE, BUYABLE, SIGN_UPDATE
};

static {
Expand Down

0 comments on commit 7039a23

Please sign in to comment.