mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-27 14:13:11 +02:00
Allow placing boats on ground for MC 1.12 with protocol support plugins.
Allowing it with protocol support plugins is added, assuming that they'll allow 1.12 too. Missing: * The vehicle.envelope check must be made (more) precise, as moving on ground is possible with a boat since 1.12, specifically on ice they can reach high speeds. Without more close modeling, they'll be able to use this for speeding.
This commit is contained in:
parent
049a925fb3
commit
b441c1ea88
@ -27,6 +27,8 @@ import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.checks.access.ACheckConfig;
|
||||
import fr.neatmonster.nocheatplus.checks.access.CheckConfigFactory;
|
||||
import fr.neatmonster.nocheatplus.checks.access.ICheckConfig;
|
||||
import fr.neatmonster.nocheatplus.compat.activation.ActivationUtil;
|
||||
import fr.neatmonster.nocheatplus.components.registry.activation.Activation;
|
||||
import fr.neatmonster.nocheatplus.config.ConfPaths;
|
||||
import fr.neatmonster.nocheatplus.config.ConfigFile;
|
||||
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
||||
@ -102,7 +104,9 @@ public class BlockPlaceConfig extends ACheckConfig {
|
||||
public final long speedInterval;
|
||||
public final ActionList speedActions;
|
||||
|
||||
/** General activation flag. */
|
||||
public final boolean preventBoatsAnywhere;
|
||||
public final boolean preventBoatsGround;
|
||||
|
||||
/**
|
||||
* Instantiates a new block place configuration.
|
||||
@ -142,6 +146,9 @@ public class BlockPlaceConfig extends ACheckConfig {
|
||||
speedActions = config.getOptimizedActionList(ConfPaths.BLOCKPLACE_SPEED_ACTIONS, Permissions.BLOCKPLACE_SPEED);
|
||||
|
||||
preventBoatsAnywhere = config.getBoolean(ConfPaths.BLOCKPLACE_PREVENTMISC_BOATSANYWHERE);
|
||||
Activation activation = ActivationUtil.addMultiProtocolSupportPlugins(
|
||||
new Activation().setConditionsOR().minecraftVersionGT("1.12", true));
|
||||
preventBoatsGround = !activation.isAvailable();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -17,6 +17,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.block.BlockState;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -334,7 +335,9 @@ public class BlockPlaceListener extends CheckListener {
|
||||
final Material type = stack.getType();
|
||||
if (InventoryUtil.isBoat(type)) {
|
||||
if (cc.preventBoatsAnywhere) {
|
||||
checkBoatsAnywhere(player, event);
|
||||
// TODO: Alter config (activation, allow on top of ground).
|
||||
// TODO: Version/plugin specific alteration for 'default'.
|
||||
checkBoatsAnywhere(player, event, cc);
|
||||
}
|
||||
}
|
||||
else if (type == Material.MONSTER_EGG) {
|
||||
@ -346,9 +349,10 @@ public class BlockPlaceListener extends CheckListener {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkBoatsAnywhere(final Player player, final PlayerInteractEvent event) {
|
||||
private void checkBoatsAnywhere(final Player player, final PlayerInteractEvent event,
|
||||
final BlockPlaceConfig cc) {
|
||||
// Check boats-anywhere.
|
||||
final org.bukkit.block.Block block = event.getClickedBlock();
|
||||
final Block block = event.getClickedBlock();
|
||||
final Material mat = block.getType();
|
||||
|
||||
// TODO: allow lava ?
|
||||
@ -356,7 +360,9 @@ public class BlockPlaceListener extends CheckListener {
|
||||
return;
|
||||
}
|
||||
|
||||
final org.bukkit.block.Block relBlock = block.getRelative(event.getBlockFace());
|
||||
// TODO: Shouldn't this be the opposite face?
|
||||
final BlockFace blockFace = event.getBlockFace();
|
||||
final Block relBlock = block.getRelative(blockFace);
|
||||
final Material relMat = relBlock.getType();
|
||||
|
||||
// TODO: Placing inside of water, but not "against" ?
|
||||
@ -364,6 +370,16 @@ public class BlockPlaceListener extends CheckListener {
|
||||
return;
|
||||
}
|
||||
|
||||
// Allow placing boats on ground since 1.12.
|
||||
/*
|
||||
* TODO: Prevent, if the placed boat would collide with any blocks or
|
||||
* entities - alternatively perform post-mortem entity destruction.
|
||||
*/
|
||||
if (!cc.preventBoatsGround && blockFace == BlockFace.UP && BlockProperties.isGround(mat)
|
||||
&& BlockProperties.isPassable(block.getRelative(BlockFace.UP).getType())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Add a check type for exemption?
|
||||
if (!player.hasPermission(Permissions.BLOCKPLACE_BOATSANYWHERE)) {
|
||||
final Result previousUseBlock = event.useInteractedBlock();
|
||||
|
Loading…
Reference in New Issue
Block a user