Added COARSE_DIRT_TILLING World Setting flag

This commit is contained in:
Florian CUNY 2018-11-10 14:31:36 +01:00
parent f8d1626ba5
commit 6df262a14b
4 changed files with 47 additions and 3 deletions

View File

@ -1,6 +1,3 @@
/**
*
*/
package world.bentobox.bentobox.listeners.flags; package world.bentobox.bentobox.listeners.flags;
import org.bukkit.Material; import org.bukkit.Material;

View File

@ -0,0 +1,37 @@
package world.bentobox.bentobox.listeners.flags;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import world.bentobox.bentobox.api.flags.FlagListener;
import world.bentobox.bentobox.lists.Flags;
public class CoarseDirtTillingListener extends FlagListener {
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onTillingCoarseDirt(PlayerInteractEvent e) {
if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
return;
}
if (e.getClickedBlock().getType().equals(Material.COARSE_DIRT)) {
switch (e.getItem().getType()) {
case WOODEN_HOE:
case STONE_HOE:
case IRON_HOE:
case GOLDEN_HOE:
case DIAMOND_HOE:
if (e.getClickedBlock().getType().equals(Material.COARSE_DIRT)
&& getIWM().inWorld(e.getClickedBlock().getWorld())
&& !Flags.COARSE_DIRT_TILLING.isSetForWorld(e.getClickedBlock().getWorld())) {
noGo(e, Flags.COARSE_DIRT_TILLING);
}
break;
default:
break;
}
}
}
}

View File

@ -16,6 +16,7 @@ import world.bentobox.bentobox.listeners.flags.BreedingListener;
import world.bentobox.bentobox.listeners.flags.BucketListener; import world.bentobox.bentobox.listeners.flags.BucketListener;
import world.bentobox.bentobox.listeners.flags.ChestDamageListener; import world.bentobox.bentobox.listeners.flags.ChestDamageListener;
import world.bentobox.bentobox.listeners.flags.CleanSuperFlatListener; import world.bentobox.bentobox.listeners.flags.CleanSuperFlatListener;
import world.bentobox.bentobox.listeners.flags.CoarseDirtTillingListener;
import world.bentobox.bentobox.listeners.flags.CreeperListener; import world.bentobox.bentobox.listeners.flags.CreeperListener;
import world.bentobox.bentobox.listeners.flags.EggListener; import world.bentobox.bentobox.listeners.flags.EggListener;
import world.bentobox.bentobox.listeners.flags.EnderChestListener; import world.bentobox.bentobox.listeners.flags.EnderChestListener;
@ -219,6 +220,8 @@ public class Flags {
public static final Flag COMMAND_RANKS = new FlagBuilder().id("COMMAND_RANKS").icon(Material.PLAYER_HEAD).type(Type.WORLD_SETTING) public static final Flag COMMAND_RANKS = new FlagBuilder().id("COMMAND_RANKS").icon(Material.PLAYER_HEAD).type(Type.WORLD_SETTING)
.onClick(new CommandRankClickListener()).subPanel(true).build(); .onClick(new CommandRankClickListener()).subPanel(true).build();
public static final Flag COARSE_DIRT_TILLING = new FlagBuilder().id("COARSE_DIRT_TILLING").icon(Material.COARSE_DIRT).type(Type.WORLD_SETTING).allowedByDefault(true).listener(new CoarseDirtTillingListener()).build();
/** /**
* @return List of all the flags in this class * @return List of all the flags in this class
*/ */

View File

@ -440,6 +440,13 @@ protection:
&asuper-flat chunks in &asuper-flat chunks in
&aisland worlds &aisland worlds
name: "Clean Super Flat" name: "Clean Super Flat"
COARSE_DIRT_TILLING:
description: |-
&aPrevent the players from
&atilling the coarse dirt
&ato obtain dirt
name: "Coarse dirt tilling"
hint: "No coarse dirt tilling"
COLLECT_LAVA: COLLECT_LAVA:
description: |- description: |-
&aToggle collecting lava &aToggle collecting lava