Added Flags#BOAT

#387
This commit is contained in:
Florian CUNY 2019-02-10 23:11:11 +01:00
parent a2607c913f
commit 4873d11ec3
4 changed files with 27 additions and 9 deletions

View File

@ -3,6 +3,7 @@ package world.bentobox.bentobox.listeners.flags.protection;
import org.bukkit.Material;
import org.bukkit.entity.Animals;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Boat;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Vehicle;
@ -40,6 +41,10 @@ public class EntityInteractListener extends FlagListener {
else if (e.getRightClicked() instanceof Minecart) {
checkIsland(e, e.getRightClicked().getLocation(), Flags.MINECART);
}
// Boat riding
else if (e.getRightClicked() instanceof Boat) {
checkIsland(e, e.getRightClicked().getLocation(), Flags.BOAT);
}
}
// Villager trading
else if (e.getRightClicked().getType().equals(EntityType.VILLAGER)) {

View File

@ -70,15 +70,17 @@ public class PlaceBlocksListener extends FlagListener {
return;
default:
// Check in-hand items
if (e.getMaterial() != null
&& (e.getMaterial().equals(Material.FIREWORK_ROCKET)
|| e.getMaterial().equals(Material.ARMOR_STAND)
|| e.getMaterial().equals(Material.END_CRYSTAL)
//|| Tag.DOORS.isTagged(e.getMaterial())
|| e.getMaterial().equals(Material.CHEST) || e.getMaterial().equals(Material.TRAPPED_CHEST)
|| (e.getMaterial().name().contains("BOAT")
&& !e.getClickedBlock().isLiquid()))) {
checkIsland(e, e.getPlayer().getLocation(), Flags.PLACE_BLOCKS);
if (e.getMaterial() != null) {
if (e.getMaterial().equals(Material.FIREWORK_ROCKET)
|| e.getMaterial().equals(Material.ARMOR_STAND)
|| e.getMaterial().equals(Material.END_CRYSTAL)
//|| Tag.DOORS.isTagged(e.getMaterial())
|| e.getMaterial().equals(Material.CHEST) || e.getMaterial().equals(Material.TRAPPED_CHEST)) {
checkIsland(e, e.getPlayer().getLocation(), Flags.PLACE_BLOCKS);
}
else if (e.getMaterial().name().contains("BOAT")) {
checkIsland(e, e.getPlayer().getLocation(), Flags.BOAT);
}
}
}
}

View File

@ -114,6 +114,13 @@ public final class Flags {
* @see PlaceBlocksListener
*/
public static final Flag MINECART = new Flag.Builder("MINECART", Material.MINECART).build();
/**
* Prevents players from issuing any kind of interactions with Boats (entering, placing).
* @since 1.3.0
* @see EntityInteractListener
* @see PlaceBlocksListener
*/
public static final Flag BOAT = new Flag.Builder("BOAT", Material.OAK_BOAT).build();
public static final Flag TRADING = new Flag.Builder("TRADING", Material.EMERALD).defaultSetting(true).build();
public static final Flag NAME_TAG = new Flag.Builder("NAME_TAG", Material.NAME_TAG).build();

View File

@ -439,6 +439,10 @@ protection:
description: "Toggle interaction"
name: "Beds"
hint: "Bed use disabled"
BOAT:
name: "Boats"
description: "Toggle boats interactions"
hint: "No boat interaction allowed"
BREAK_BLOCKS:
description: "Toggle breaking"
name: "Break blocks"