mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-13 19:51:27 +01:00
parent
865a1d0caa
commit
c86fb35aac
@ -4,6 +4,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -22,24 +23,30 @@ import world.bentobox.bentobox.lists.Flags;
|
||||
public class EntityInteractListener extends FlagListener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
|
||||
public void onPlayerInteract(final PlayerInteractAtEntityEvent e) {
|
||||
public void onPlayerInteractAtEntity(final PlayerInteractAtEntityEvent e) {
|
||||
if (e.getRightClicked() instanceof ArmorStand) {
|
||||
checkIsland(e, e.getRightClicked().getLocation(), Flags.ARMOR_STAND);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerHitEntity(PlayerInteractEntityEvent e) {
|
||||
// Animal riding
|
||||
if (e.getRightClicked() instanceof Vehicle && e.getRightClicked() instanceof Animals) {
|
||||
checkIsland(e, e.getRightClicked().getLocation(), Flags.RIDING);
|
||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent e) {
|
||||
if (e.getRightClicked() instanceof Vehicle) {
|
||||
// Animal riding
|
||||
if (e.getRightClicked() instanceof Animals) {
|
||||
checkIsland(e, e.getRightClicked().getLocation(), Flags.RIDING);
|
||||
}
|
||||
// Minecart riding
|
||||
else if (e.getRightClicked() instanceof Minecart) {
|
||||
checkIsland(e, e.getRightClicked().getLocation(), Flags.MINECART);
|
||||
}
|
||||
}
|
||||
// Villager trading
|
||||
if (e.getRightClicked().getType().equals(EntityType.VILLAGER)) {
|
||||
else if (e.getRightClicked().getType().equals(EntityType.VILLAGER)) {
|
||||
checkIsland(e, e.getRightClicked().getLocation(), Flags.TRADING);
|
||||
}
|
||||
// Name tags
|
||||
if (e.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.NAME_TAG)) {
|
||||
else if (e.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.NAME_TAG)) {
|
||||
checkIsland(e, e.getRightClicked().getLocation(), Flags.NAME_TAG);
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class PlaceBlocksListener extends FlagListener {
|
||||
case ACTIVATOR_RAIL:
|
||||
if (e.getMaterial() != null && (e.getMaterial() == Material.MINECART || e.getMaterial() == Material.CHEST_MINECART || e.getMaterial() == Material.HOPPER_MINECART
|
||||
|| e.getMaterial() == Material.TNT_MINECART || e.getMaterial() == Material.FURNACE_MINECART)) {
|
||||
checkIsland(e, e.getClickedBlock().getLocation(), Flags.PLACE_BLOCKS);
|
||||
checkIsland(e, e.getClickedBlock().getLocation(), Flags.MINECART);
|
||||
}
|
||||
return;
|
||||
default:
|
||||
|
@ -107,6 +107,13 @@ public final class Flags {
|
||||
// Entity interactions
|
||||
public static final Flag ARMOR_STAND = new Flag.Builder("ARMOR_STAND", Material.ARMOR_STAND).listener(new EntityInteractListener()).build();
|
||||
public static final Flag RIDING = new Flag.Builder("RIDING", Material.GOLDEN_HORSE_ARMOR).build();
|
||||
/**
|
||||
* Prevents players from issuing any kind of interactions with Minecarts (entering, placing and opening if chest).
|
||||
* @since 1.3.0
|
||||
* @see EntityInteractListener
|
||||
* @see PlaceBlocksListener
|
||||
*/
|
||||
public static final Flag MINECART = new Flag.Builder("MINECART", Material.MINECART).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();
|
||||
|
||||
|
@ -674,6 +674,10 @@ protection:
|
||||
description: "Toggle cow milking"
|
||||
name: "Milking"
|
||||
hint: "No milking allowed"
|
||||
MINECART:
|
||||
name: "Minecarts"
|
||||
description: "Toggle minecart interactions"
|
||||
hint: "No minecart interaction allowed"
|
||||
MONSTER_SPAWN:
|
||||
description: "Toggle spawning"
|
||||
name: "Monster spawning"
|
||||
|
Loading…
Reference in New Issue
Block a user