Check build permissions on frostwalking. Resolves #708.

This commit is contained in:
Trent Hensler 2016-06-10 16:43:48 -07:00
parent c30aa34fb7
commit a7aeb26fd0

View File

@ -7,6 +7,7 @@ import com.massivecraft.factions.struct.Relation;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.EntityType;
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;
@ -129,6 +130,21 @@ public class FactionsBlockListener implements Listener {
} }
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onFrostWalker(EntityBlockFormEvent event) {
if (event.getEntity() == null || event.getEntity().getType() != EntityType.PLAYER || event.getBlock() == null) {
return;
}
Player player = (Player) event.getEntity();
Location location = event.getBlock().getLocation();
// Check if they have build permissions here. If not, block this from happening.
if (!playerCanBuildDestroyBlock(player, location, "frost walk", false)) {
event.setCancelled(true);
}
}
private boolean canPistonMoveBlock(Faction pistonFaction, Location target) { private boolean canPistonMoveBlock(Faction pistonFaction, Location target) {
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(target)); Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(target));