mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-13 03:40:45 +01:00
Added Flags#FLINT_AND_STEEL, Flags#FIRE_BURNING, Flags#FIRE_IGNITE and removed Flags#FIRE + fixed Flags#FIRE_SCOOPING description in en-US locale
Closes #414 commit 0b551d174289ea1b75e55f0f4d268592a716f66f Author: Florian CUNY <poslovitch@bentobox.world> Date: Tue Feb 19 10:50:08 2019 +0100 Updated FireListenerTest commit 3f2cc83037e1994a686bacd4d8541eece8c9dc53 Author: Florian CUNY <poslovitch@bentobox.world> Date: Tue Feb 19 10:40:46 2019 +0100 Added descriptions in en-US for FIRE_BURNING, FIRE_IGNITE and FLINT_AND_STEEL commit 880df9e904a0121804a73c2fcb40b9faa2aa290b Author: Florian CUNY <poslovitch@bentobox.world> Date: Tue Feb 19 10:35:54 2019 +0100 Fixed description of FISH_SCOOPING commit 02259b0f8fdad31e7431d4d525b74bee6b499813 Author: Florian CUNY <poslovitch@bentobox.world> Date: Tue Feb 19 10:34:54 2019 +0100 Improved description of FIRE_SPREAD commit 92c5d137d8fb114dacdebc32626e04a5ee16982b Author: Florian CUNY <poslovitch@bentobox.world> Date: Tue Feb 19 10:30:17 2019 +0100 Added Flags#FIRE_BURNING and Flags#Fire_IGNITE These are SETTING flags commit 0be4a87c1986a55a15fa16e87e4073921a269e34 Author: Florian CUNY <poslovitch@bentobox.world> Date: Tue Feb 19 10:21:52 2019 +0100 Added Flags#FLINT_AND_STEEL #414
This commit is contained in:
parent
095237cd5d
commit
9b1e955d18
@ -48,7 +48,7 @@ public class FireListener extends FlagListener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public boolean onBlockBurn(BlockBurnEvent e) {
|
||||
return checkFire(e, e.getBlock().getLocation(), Flags.FIRE);
|
||||
return checkFire(e, e.getBlock().getLocation(), Flags.FIRE_BURNING);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,7 +67,7 @@ public class FireListener extends FlagListener {
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public boolean onBlockIgnite(BlockIgniteEvent e) {
|
||||
// Check if this is a portal lighting - that is allowed any time
|
||||
return !e.getBlock().getType().equals(Material.OBSIDIAN) && checkFire(e, e.getBlock().getLocation(), Flags.FIRE);
|
||||
return !e.getBlock().getType().equals(Material.OBSIDIAN) && checkFire(e, e.getBlock().getLocation(), Flags.FIRE_IGNITE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -76,8 +76,9 @@ public class FireListener extends FlagListener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerInteract(PlayerInteractEvent e) {
|
||||
if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK) && e.getMaterial() != null && e.getMaterial().equals(Material.FLINT_AND_STEEL)) {
|
||||
checkIsland(e, e.getPlayer(), e.getClickedBlock().getLocation(), Flags.FIRE);
|
||||
if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK) && e.getMaterial() != null
|
||||
&& (e.getMaterial() == Material.FLINT_AND_STEEL || e.getMaterial() == Material.FIRE_CHARGE)) {
|
||||
checkIsland(e, e.getPlayer(), e.getClickedBlock().getLocation(), Flags.FLINT_AND_STEEL);
|
||||
}
|
||||
// Look along player's sight line to see if any blocks are fire. Players can hit fire out quite a long way away.
|
||||
try {
|
||||
@ -92,5 +93,4 @@ public class FireListener extends FlagListener {
|
||||
// To catch at block iterator exceptions that can happen in the void or at the very top of blocks
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -166,9 +166,17 @@ public final class Flags {
|
||||
* I'll take you to burn
|
||||
* - The Crazy World of Arthur Brown
|
||||
*/
|
||||
public static final Flag FIRE = new Flag.Builder("FIRE", Material.FLINT_AND_STEEL).listener(new FireListener()).build();
|
||||
|
||||
|
||||
/**
|
||||
* Prevents players from starting fires using flint and steel or fire charges.
|
||||
* @since 1.3.0
|
||||
*
|
||||
* @see FireListener
|
||||
*/
|
||||
public static final Flag FLINT_AND_STEEL = new Flag.Builder("FLINT_AND_STEEL", Material.FLINT_AND_STEEL).listener(new FireListener()).build();
|
||||
/**
|
||||
* Prevents players from extinguishing fires.
|
||||
* @see FireListener
|
||||
*/
|
||||
public static final Flag FIRE_EXTINGUISH = new Flag.Builder("FIRE_EXTINGUISH", Material.POTION).build();
|
||||
|
||||
// Inventories
|
||||
@ -224,13 +232,30 @@ public final class Flags {
|
||||
public static final Flag PVP_END = new Flag.Builder("PVP_END", Material.END_CRYSTAL).type(Type.SETTING)
|
||||
.defaultRank(DISABLED).build();
|
||||
|
||||
// Fire
|
||||
/**
|
||||
* Prevents fire from burning blocks.
|
||||
* @since 1.3.0
|
||||
* @see FireListener
|
||||
*/
|
||||
public static final Flag FIRE_BURNING = new Flag.Builder("FIRE_BURNING", Material.CHARCOAL).defaultSetting(true).type(Type.SETTING).build();
|
||||
/**
|
||||
* Prevents fire from being ignited by non-players.
|
||||
* @since 1.3.0
|
||||
* @see FireListener
|
||||
*/
|
||||
public static final Flag FIRE_IGNITE = new Flag.Builder("FIRE_IGNITE", Material.FLINT_AND_STEEL).defaultSetting(true).type(Type.SETTING).build();
|
||||
/**
|
||||
* Prevents fire from spreading to other blocks.
|
||||
* @see FireListener
|
||||
*/
|
||||
public static final Flag FIRE_SPREAD = new Flag.Builder("FIRE_SPREAD", Material.FIREWORK_STAR).defaultSetting(true).type(Type.SETTING).build();
|
||||
|
||||
// Others
|
||||
public static final Flag ANIMAL_SPAWN = new Flag.Builder("ANIMAL_SPAWN", Material.APPLE).defaultSetting(true).type(Type.SETTING)
|
||||
.listener(new MobSpawnListener()).build();
|
||||
public static final Flag MONSTER_SPAWN = new Flag.Builder("MONSTER_SPAWN", Material.SPAWNER).defaultSetting(true).type(Type.SETTING).build();
|
||||
|
||||
public static final Flag FIRE_SPREAD = new Flag.Builder("FIRE_SPREAD", Material.FIREWORK_STAR).defaultSetting(true).type(Type.SETTING).build();
|
||||
|
||||
/*
|
||||
* World Settings - they apply to every island in the game worlds.
|
||||
*/
|
||||
|
@ -595,24 +595,35 @@ protection:
|
||||
name: "Enter/Exit messages"
|
||||
now-entering: "&bNow entering [name]"
|
||||
now-leaving: "&bNow leaving [name]"
|
||||
FIRE:
|
||||
description: "Allow fire to exist or not"
|
||||
name: "Fire"
|
||||
hint: "No fire allowed"
|
||||
FIRE_BURNING:
|
||||
name: "Fire burning"
|
||||
description: |-
|
||||
&aToggle whether fire can burn
|
||||
&ablocks or not.
|
||||
FIRE_EXTINGUISH:
|
||||
description: "Toggle extinguishing"
|
||||
description: "Toggle extinguishing fires"
|
||||
name: "Fire extinguish"
|
||||
hint: "No fire extinguishing allowed"
|
||||
FIRE_SPREAD:
|
||||
description: "Toggle spread"
|
||||
name: "Fire spread"
|
||||
hint: "No fire spread allowed"
|
||||
FISH_SCOOPING:
|
||||
FIRE_IGNITE:
|
||||
name: "Fire ignition"
|
||||
description: |-
|
||||
&aAllow scooping of
|
||||
&atropical fish
|
||||
&aToggle whether fire can be ignited
|
||||
&aby non-player means or not.
|
||||
FIRE_SPREAD:
|
||||
name: "Fire spread"
|
||||
description: |-
|
||||
&aToggle whether fire can spread
|
||||
&ato nearby blocks or not.
|
||||
FISH_SCOOPING:
|
||||
name: "Fish Scooping"
|
||||
hint: "No scooping of tropical fish"
|
||||
description: "Allow scooping of fishes using a bucket"
|
||||
hint: "No scooping of fishes"
|
||||
FLINT_AND_STEEL:
|
||||
name: "Flint and steel"
|
||||
description: |-
|
||||
&aAllow players to ignite fires using
|
||||
&aflint and steel or fire charges.
|
||||
hint: "No flint and steel or fire charges usage"
|
||||
FURNACE:
|
||||
description: "Toggle use"
|
||||
name: "Furnace"
|
||||
|
@ -162,27 +162,27 @@ public class FireListenerTest {
|
||||
// Disallow fire
|
||||
when(island.isAllowed(Mockito.any())).thenReturn(false);
|
||||
when(island.isAllowed(Mockito.any(), Mockito.any())).thenReturn(false);
|
||||
Flags.FIRE.setDefaultSetting(false);
|
||||
assertTrue(listener.checkFire(e, location, Flags.FIRE));
|
||||
Flags.FIRE.setDefaultSetting(true);
|
||||
assertTrue(listener.checkFire(e, location, Flags.FIRE));
|
||||
Flags.FLINT_AND_STEEL.setDefaultSetting(false);
|
||||
assertTrue(listener.checkFire(e, location, Flags.FLINT_AND_STEEL));
|
||||
Flags.FLINT_AND_STEEL.setDefaultSetting(true);
|
||||
assertTrue(listener.checkFire(e, location, Flags.FLINT_AND_STEEL));
|
||||
|
||||
// Allow fire
|
||||
when(island.isAllowed(Mockito.any())).thenReturn(true);
|
||||
when(island.isAllowed(Mockito.any(), Mockito.any())).thenReturn(true);
|
||||
Flags.FIRE.setDefaultSetting(false);
|
||||
assertFalse(listener.checkFire(e, location, Flags.FIRE));
|
||||
Flags.FIRE.setDefaultSetting(true);
|
||||
assertFalse(listener.checkFire(e, location, Flags.FIRE));
|
||||
Flags.FLINT_AND_STEEL.setDefaultSetting(false);
|
||||
assertFalse(listener.checkFire(e, location, Flags.FLINT_AND_STEEL));
|
||||
Flags.FLINT_AND_STEEL.setDefaultSetting(true);
|
||||
assertFalse(listener.checkFire(e, location, Flags.FLINT_AND_STEEL));
|
||||
|
||||
// Check with no island
|
||||
when(im.getIslandAt(Matchers.any())).thenReturn(Optional.empty());
|
||||
// Fire is not allowed, so should be cancelled
|
||||
Flags.FIRE.setDefaultSetting(false);
|
||||
assertTrue(listener.checkFire(e, location, Flags.FIRE));
|
||||
Flags.FLINT_AND_STEEL.setDefaultSetting(false);
|
||||
assertTrue(listener.checkFire(e, location, Flags.FLINT_AND_STEEL));
|
||||
// Fire allowed
|
||||
Flags.FIRE.setDefaultSetting(true);
|
||||
assertFalse(listener.checkFire(e, location, Flags.FIRE));
|
||||
Flags.FLINT_AND_STEEL.setDefaultSetting(true);
|
||||
assertFalse(listener.checkFire(e, location, Flags.FLINT_AND_STEEL));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -205,26 +205,26 @@ public class FireListenerTest {
|
||||
// Disallow fire
|
||||
when(island.isAllowed(Mockito.any())).thenReturn(false);
|
||||
when(island.isAllowed(Mockito.any(), Mockito.any())).thenReturn(false);
|
||||
Flags.FIRE.setDefaultSetting(false);
|
||||
Flags.FIRE_BURNING.setDefaultSetting(false);
|
||||
assertTrue(listener.onBlockBurn(e));
|
||||
Flags.FIRE.setDefaultSetting(true);
|
||||
Flags.FIRE_BURNING.setDefaultSetting(true);
|
||||
assertTrue(listener.onBlockBurn(e));
|
||||
|
||||
// Allow fire
|
||||
when(island.isAllowed(Mockito.any())).thenReturn(true);
|
||||
when(island.isAllowed(Mockito.any(), Mockito.any())).thenReturn(true);
|
||||
Flags.FIRE.setDefaultSetting(false);
|
||||
Flags.FIRE_BURNING.setDefaultSetting(false);
|
||||
assertFalse(listener.onBlockBurn(e));
|
||||
Flags.FIRE.setDefaultSetting(true);
|
||||
Flags.FIRE_BURNING.setDefaultSetting(true);
|
||||
assertFalse(listener.onBlockBurn(e));
|
||||
|
||||
// Check with no island
|
||||
when(im.getIslandAt(Matchers.any())).thenReturn(Optional.empty());
|
||||
// Fire is not allowed, so should be cancelled
|
||||
Flags.FIRE.setDefaultSetting(false);
|
||||
Flags.FIRE_BURNING.setDefaultSetting(false);
|
||||
assertTrue(listener.onBlockBurn(e));
|
||||
// Fire allowed
|
||||
Flags.FIRE.setDefaultSetting(true);
|
||||
Flags.FIRE_BURNING.setDefaultSetting(true);
|
||||
assertFalse(listener.onBlockBurn(e));
|
||||
}
|
||||
|
||||
@ -305,27 +305,26 @@ public class FireListenerTest {
|
||||
// Disallow fire
|
||||
when(island.isAllowed(Mockito.any())).thenReturn(false);
|
||||
when(island.isAllowed(Mockito.any(), Mockito.any())).thenReturn(false);
|
||||
Flags.FIRE.setDefaultSetting(false);
|
||||
Flags.FIRE_IGNITE.setDefaultSetting(false);
|
||||
assertTrue(listener.onBlockIgnite(e));
|
||||
Flags.FIRE.setDefaultSetting(true);
|
||||
Flags.FIRE_IGNITE.setDefaultSetting(true);
|
||||
assertTrue(listener.onBlockIgnite(e));
|
||||
|
||||
// Allow fire spread
|
||||
when(island.isAllowed(Mockito.any())).thenReturn(true);
|
||||
when(island.isAllowed(Mockito.any(), Mockito.any())).thenReturn(true);
|
||||
Flags.FIRE.setDefaultSetting(false);
|
||||
Flags.FIRE_IGNITE.setDefaultSetting(false);
|
||||
assertFalse(listener.onBlockIgnite(e));
|
||||
Flags.FIRE.setDefaultSetting(true);
|
||||
Flags.FIRE_IGNITE.setDefaultSetting(true);
|
||||
assertFalse(listener.onBlockIgnite(e));
|
||||
|
||||
// Check with no island
|
||||
when(im.getIslandAt(Matchers.any())).thenReturn(Optional.empty());
|
||||
// Fire spread is not allowed, so should be cancelled
|
||||
Flags.FIRE.setDefaultSetting(false);
|
||||
Flags.FIRE_IGNITE.setDefaultSetting(false);
|
||||
assertTrue(listener.onBlockIgnite(e));
|
||||
// Fire allowed
|
||||
Flags.FIRE.setDefaultSetting(true);
|
||||
Flags.FIRE_IGNITE.setDefaultSetting(true);
|
||||
assertFalse(listener.onBlockIgnite(e));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user