Few fixes to COARSE_DIRT_TILLING flag

#337
This commit is contained in:
Florian CUNY 2018-11-11 10:22:18 +01:00
parent 72738f42b9
commit 23af6e7012
2 changed files with 9 additions and 5 deletions

View File

@ -6,13 +6,15 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import world.bentobox.bentobox.api.flags.FlagListener; import world.bentobox.bentobox.api.flags.FlagListener;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.lists.Flags; import world.bentobox.bentobox.lists.Flags;
public class CoarseDirtTillingListener extends FlagListener { public class CoarseDirtTillingListener extends FlagListener {
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onTillingCoarseDirt(PlayerInteractEvent e) { public void onTillingCoarseDirt(PlayerInteractEvent e) {
if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK) || e.getItem() == null) {
return; return;
} }
@ -26,7 +28,9 @@ public class CoarseDirtTillingListener extends FlagListener {
if (e.getClickedBlock().getType().equals(Material.COARSE_DIRT) if (e.getClickedBlock().getType().equals(Material.COARSE_DIRT)
&& getIWM().inWorld(e.getClickedBlock().getWorld()) && getIWM().inWorld(e.getClickedBlock().getWorld())
&& !Flags.COARSE_DIRT_TILLING.isSetForWorld(e.getClickedBlock().getWorld())) { && !Flags.COARSE_DIRT_TILLING.isSetForWorld(e.getClickedBlock().getWorld())) {
noGo(e, Flags.COARSE_DIRT_TILLING); e.setCancelled(true);
User user = User.getInstance(e.getPlayer());
user.notify("protection.protected", TextVariables.DESCRIPTION, user.getTranslation(Flags.COARSE_DIRT_TILLING.getHintReference()));
} }
break; break;
default: default:

View File

@ -442,9 +442,9 @@ protection:
name: "Clean Super Flat" name: "Clean Super Flat"
COARSE_DIRT_TILLING: COARSE_DIRT_TILLING:
description: |- description: |-
&aPrevent the players from &aToggle tilling the
&atilling the coarse dirt &acoarse dirt to
&ato obtain dirt &aobtain dirt
name: "Coarse dirt tilling" name: "Coarse dirt tilling"
hint: "No coarse dirt tilling" hint: "No coarse dirt tilling"
COLLECT_LAVA: COLLECT_LAVA: