Made DYE flag more permissive with signs

It now only applies when the player has dyes in his hand.
#669
This commit is contained in:
Florian CUNY 2019-05-07 23:43:40 +02:00
parent fc160d8c5f
commit bf08475a4f

View File

@ -6,13 +6,13 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import world.bentobox.bentobox.api.flags.FlagListener;
import world.bentobox.bentobox.lists.Flags;
/**
* Protects against dying
* Protects against dying things.
* @author tastybento
* @since 1.5.0
*/
public class DyeListener extends FlagListener {
@ -22,22 +22,20 @@ public class DyeListener extends FlagListener {
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerInteract(final PlayerInteractEvent e) {
if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK) && e.getClickedBlock().getType().name().contains("SIGN")) {
checkIsland(e, e.getPlayer(), e.getClickedBlock().getLocation(), Flags.DYE);
if (e.getClickedBlock() == null || e.getItem() == null) {
return;
}
if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK) && e.getClickedBlock().getType().name().contains("SIGN")
&& e.getItem().getType().name().contains("DYE")) {
checkIsland(e, e.getPlayer(), e.getClickedBlock().getLocation(), Flags.DYE);
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerInteract(final PlayerInteractEntityEvent e) {
if (e.getRightClicked().getType().equals(EntityType.SHEEP)) {
checkIsland(e, e.getPlayer(), e.getRightClicked().getLocation(), Flags.DYE);
return;
}
}
}