mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-29 11:57:59 +01:00
Refine lily pad placement check, add place against air for some reason.
This commit is contained in:
parent
def976df50
commit
4ee1880a4d
@ -104,6 +104,8 @@ permissions:
|
||||
children:
|
||||
nocheatplus.checks.blockplace.against.liquids:
|
||||
description: Allow the player to place blocks against liquids.
|
||||
nocheatplus.checks.blockplace.against.air:
|
||||
description: Allow the player to place blocks against air.
|
||||
nocheatplus.checks.blockplace.direction:
|
||||
description: Allow the player to bypass to Direction check.
|
||||
nocheatplus.checks.blockplace.fastplace:
|
||||
|
@ -3,6 +3,7 @@ package fr.neatmonster.nocheatplus.checks.blockplace;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -85,11 +86,16 @@ public class BlockPlaceListener implements Listener {
|
||||
final Player player = event.getPlayer();
|
||||
boolean cancelled = false;
|
||||
|
||||
if (BlockProperties.isLiquid(blockAgainst.getTypeId())
|
||||
&& mat != Material.WATER_LILY && !player.hasPermission(Permissions.BLOCKPLACE_AGAINST_LIQUIDS))
|
||||
// The block was placed against a liquid block, cancel its
|
||||
// placement.
|
||||
cancelled = true;
|
||||
// Check if the block may be placed against a certain material.
|
||||
// TODO: Maybe make it an extra check after all.
|
||||
final int againstId = blockAgainst.getTypeId();
|
||||
if (BlockProperties.isLiquid(againstId)){
|
||||
if ((mat != Material.WATER_LILY || !BlockProperties.isLiquid(block.getRelative(BlockFace.DOWN).getTypeId()))
|
||||
&& !player.hasPermission(Permissions.BLOCKPLACE_AGAINST_LIQUIDS)) cancelled = true;
|
||||
}
|
||||
else if (againstId == Material.AIR.getId()){
|
||||
if (!player.hasPermission(Permissions.BLOCKPLACE_AGAINST_AIR)) cancelled = true;
|
||||
}
|
||||
|
||||
// First, the fast place check.
|
||||
if (fastPlace.isEnabled(player)){
|
||||
|
@ -91,6 +91,7 @@ public class Permissions {
|
||||
*/
|
||||
private static final String BLOCKPLACE = CHECKS + ".blockplace";
|
||||
public static final String BLOCKPLACE_AGAINST = BLOCKPLACE + ".against";
|
||||
public static final String BLOCKPLACE_AGAINST_AIR = BLOCKPLACE_AGAINST + ".air";
|
||||
public static final String BLOCKPLACE_AGAINST_LIQUIDS = BLOCKPLACE_AGAINST + ".liquids";
|
||||
public static final String BLOCKPLACE_DIRECTION = BLOCKPLACE + ".direction";
|
||||
public static final String BLOCKPLACE_FASTPLACE = BLOCKPLACE + ".fastplace";
|
||||
|
Loading…
Reference in New Issue
Block a user