Skip to content

Commit e18e7b9

Browse files
authored
Merge pull request #379 from BentoBoxWorld/particle_adjustment
Particle adjustment
2 parents 281d777 + 377474f commit e18e7b9

File tree

5 files changed

+101
-30
lines changed

5 files changed

+101
-30
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<!-- Do not change unless you want different name for local builds. -->
6868
<build.number>-LOCAL</build.number>
6969
<!-- This allows to change between versions. -->
70-
<build.version>1.15.1</build.version>
70+
<build.version>1.16.0</build.version>
7171
<!-- SonarCloud -->
7272
<sonar.projectKey>BentoBoxWorld_AOneBlock</sonar.projectKey>
7373
<sonar.organization>bentobox-world</sonar.organization>

src/main/java/world/bentobox/aoneblock/Settings.java

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,23 @@ public class Settings implements WorldSettings {
112112
@ConfigEntry(path = "world.hologram-duration")
113113
private int hologramDuration = 10;
114114

115-
@ConfigComment("Duration in seonds that players cannot move when they start a new one block.")
115+
@ConfigComment("Duration in seconds that players cannot move when they start a new one block.")
116116
@ConfigComment("Used only if the Starting Safety world setting is active.")
117117
@ConfigEntry(path = "world.starting-safety-duration")
118118
private int startingSafetyDuration = 10;
119119

120120
@ConfigComment("Block identification appearance.")
121-
@ConfigComment("Size of particles. Default is 0.7. Must be greater than 0.")
121+
@ConfigComment("Click type that will make particles appear. Options are:")
122+
@ConfigComment("LEFT (default), RIGHT, or NONE")
123+
@ConfigEntry(path = "world.block-id.click-type")
124+
private String clickType = "LEFT";
125+
126+
@ConfigComment("Size of particles. Default is 0.5. Must be greater than 0.")
122127
@ConfigEntry(path = "world.block-id.particle-size")
123-
private Double particleSize = 0.7;
124-
@ConfigComment("Density of particles - Value from 0.1 to 1. Default is 0.5. Smaller values are more dense, higher are less.")
128+
private Double particleSize = 0.5;
129+
@ConfigComment("Density of particles - Value from 0.1 to 1. Default is 0.65. Smaller values are more dense, higher are less.")
125130
@ConfigEntry(path = "world.block-id.particle-density")
126-
private Double particleDensity = 0.5D;
131+
private Double particleDensity = 0.65D;
127132
@ConfigComment("Color of particles")
128133
@ConfigEntry(path = "world.block-id.particle-color")
129134
private Color particleColor = Color.GREEN;
@@ -2154,4 +2159,21 @@ public Double getParticleDensity() {
21542159
public void setParticleDensity(Double particleDensity) {
21552160
this.particleDensity = particleDensity;
21562161
}
2162+
2163+
/**
2164+
* @return the clickType
2165+
*/
2166+
public String getClickType() {
2167+
if (clickType == null || (!clickType.equalsIgnoreCase("LEFT") && !clickType.equalsIgnoreCase("RIGHT")
2168+
&& !clickType.equalsIgnoreCase("NONE"))) {
2169+
clickType = "LEFT";
2170+
}
2171+
return clickType;
2172+
}
2173+
/**
2174+
* @param clickType the clickType to set
2175+
*/
2176+
public void setClickType(String clickType) {
2177+
this.clickType = clickType;
2178+
}
21572179
}

src/main/java/world/bentobox/aoneblock/listeners/BlockProtect.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
import org.bukkit.event.EventHandler;
1515
import org.bukkit.event.EventPriority;
1616
import org.bukkit.event.Listener;
17-
import org.bukkit.event.block.BlockDamageEvent;
17+
import org.bukkit.event.block.Action;
1818
import org.bukkit.event.block.BlockPistonExtendEvent;
1919
import org.bukkit.event.block.BlockPistonRetractEvent;
2020
import org.bukkit.event.entity.EntityChangeBlockEvent;
2121
import org.bukkit.event.entity.EntityExplodeEvent;
2222
import org.bukkit.event.entity.EntitySpawnEvent;
23+
import org.bukkit.event.player.PlayerInteractEvent;
2324
import org.bukkit.util.Vector;
2425

2526
import world.bentobox.aoneblock.AOneBlock;
@@ -45,13 +46,22 @@ public BlockProtect(AOneBlock addon) {
4546
* @param e - event
4647
*/
4748
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
48-
public void onBlockDamage(BlockDamageEvent e) {
49-
if (!addon.inWorld(e.getBlock().getWorld())) {
49+
public void onBlockDamage(PlayerInteractEvent e) {
50+
Action action = e.getAction();
51+
String clickType = addon.getSettings().getClickType();
52+
53+
if (clickType.equalsIgnoreCase("NONE") || !addon.inWorld(e.getPlayer().getWorld())
54+
|| e.getClickedBlock() == null) {
5055
return;
5156
}
52-
Block block = e.getBlock();
53-
Location l = block.getLocation();
54-
addon.getIslands().getIslandAt(l).map(Island::getCenter).filter(l::equals).ifPresent(this::showSparkles);
57+
58+
if ((action == Action.LEFT_CLICK_BLOCK && clickType.equalsIgnoreCase("LEFT"))
59+
|| (action == Action.RIGHT_CLICK_BLOCK && clickType.equalsIgnoreCase("RIGHT"))) {
60+
61+
Location l = e.getClickedBlock().getLocation();
62+
addon.getIslands().getIslandAt(l).map(Island::getCenter).filter(center -> center.equals(l))
63+
.ifPresent(this::showSparkles);
64+
}
5565
}
5666

5767
public void showSparkles(Location location) {

src/main/resources/config.yml

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ aoneblock:
3333
set-count-command: setCount
3434
# How long a player must wait until they can use the setCount command again. In minutes.
3535
# This is the command that is run from the phases panel.
36-
# Added since 1.13.0
36+
# Added since 1.13.0.
3737
set-count-cooldown: 5
3838
# The command label that allows to check if magic block is present and respawns it if not.
3939
# By default it is 'respawnBlock check'.
@@ -58,11 +58,29 @@ world:
5858
# Duration in seconds that phase holograms will exist after being displayed, if used.
5959
# If set to 0, then holograms will persist until cleared some other way.
6060
hologram-duration: 10
61+
# Duration in seconds that players cannot move when they start a new one block.
62+
# Used only if the Starting Safety world setting is active.
63+
starting-safety-duration: 10
64+
block-id:
65+
# Block identification appearance.
66+
# Click type that will make particles appear. Options are:
67+
# LEFT (default), RIGHT, or NONE
68+
click-type: RIGHT
69+
# Size of particles. Default is 0.7. Must be greater than 0.
70+
particle-size: 0.5
71+
# Density of particles - Value from 0.1 to 1. Default is 0.5. Smaller values are more dense, higher are less.
72+
particle-density: 0.65
73+
# Color of particles
74+
particle-color:
75+
==: Color
76+
ALPHA: 255
77+
RED: 0
78+
BLUE: 0
79+
GREEN: 128
6180
# Clear blocks when spawning mobs.
6281
# Mobs break blocks when they spawn is to prevent players from building a box around the magic block,
6382
# having the mob spawn, and then die by suffocation, i.e., it's a cheat prevention.
64-
clear-blocks: true
65-
83+
mobs-clear-blocks: true
6684
spawn-limits:
6785
# Spawn limits. These override the limits set in bukkit.yml
6886
# If set to a negative number, the server defaults will be used
@@ -174,34 +192,37 @@ world:
174192
# Mob white list - these mobs will NOT be removed when logging in or doing /island
175193
remove-mobs-whitelist:
176194
- ENDERMAN
177-
- WITHER
178195
- ZOMBIE_VILLAGER
196+
- WITHER
179197
# World flags. These are boolean settings for various flags for this world
180198
flags:
181199
CREEPER_DAMAGE: true
182200
OBSIDIAN_SCOOPING: true
183-
PISTON_PUSH: false
184201
ISLAND_RESPAWN: true
185202
CREEPER_GRIEFING: false
186203
VISITOR_KEEP_INVENTORY: false
204+
PETS_STAY_AT_HOME: true
205+
NATURAL_SPAWNING_OUTSIDE_RANGE: true
206+
LIQUIDS_FLOWING_OUT: false
207+
REMOVE_MOBS: true
208+
ENDER_CHEST: false
209+
TREES_GROWING_OUTSIDE_RANGE: false
210+
WITHER_DAMAGE: false
211+
PISTON_PUSH: false
187212
COARSE_DIRT_TILLING: true
188213
ENDERMAN_GRIEFING: true
189214
CLEAN_SUPER_FLAT: false
190215
CHEST_DAMAGE: false
191216
PREVENT_TELEPORT_WHEN_FALLING: false
192-
NATURAL_SPAWNING_OUTSIDE_RANGE: true
217+
START_SAFETY: false
193218
ENTER_EXIT_MESSAGES: true
219+
ALLOW_MOVE_BOX: true
194220
ENDERMAN_DEATH_DROP: true
195-
LIQUIDS_FLOWING_OUT: false
196221
OFFLINE_REDSTONE: true
197222
REMOVE_END_EXIT_ISLAND: true
198223
OFFLINE_GROWTH: true
199-
REMOVE_MOBS: true
200-
ENDER_CHEST: false
201224
ITEM_FRAME_DAMAGE: false
202-
TREES_GROWING_OUTSIDE_RANGE: false
203225
SPAWNER_SPAWN_EGGS: true
204-
WITHER_DAMAGE: false
205226
# These are the default protection settings for new islands.
206227
# The value is the minimum island rank required allowed to do the action
207228
# Ranks are the following:
@@ -213,6 +234,7 @@ world:
213234
# OWNER = 1000
214235
default-island-flags:
215236
HURT_ANIMALS: 500
237+
LOOM: 500
216238
DRAGON_EGG: 500
217239
REDSTONE: 500
218240
BUCKET: 500
@@ -228,6 +250,8 @@ world:
228250
END_PORTAL: 500
229251
BREEDING: 500
230252
HURT_VILLAGERS: 500
253+
BOOKSHELF: 500
254+
HARVEST: 500
231255
FROST_WALKER: 500
232256
TURTLE_EGGS: 500
233257
COLLECT_LAVA: 500
@@ -240,6 +264,7 @@ world:
240264
NAME_TAG: 500
241265
ARMOR_STAND: 500
242266
CHANGE_SETTINGS: 1000
267+
SIGN_EDITING: 500
243268
TRADING: 0
244269
EGGS: 500
245270
ITEM_DROP: 0
@@ -250,15 +275,19 @@ world:
250275
SCULK_SENSOR: 500
251276
LECTERN: 500
252277
SHULKER_BOX: 500
278+
GRINDSTONE: 500
253279
ITEM_PICKUP: 0
254280
CROP_TRAMPLE: 500
255281
DROPPER: 500
256282
BREWING: 500
283+
MOVE_BOX: 1000
257284
TNT_PRIMING: 500
285+
PARKOUR_CREATIVE: 500
258286
COLLECT_WATER: 500
259287
AXOLOTL_SCOOPING: 500
260288
BUTTON: 500
261289
COMPOSTER: 500
290+
STONECUTTING: 500
262291
FIRE_EXTINGUISH: 500
263292
COMMAND_RANKS: 500
264293
BEACON: 500
@@ -270,6 +299,7 @@ world:
270299
HIVE: 500
271300
ITEM_FRAME: 500
272301
PLACE_BLOCKS: 500
302+
CROP_PLANTING: 500
273303
CRAFTING: 0
274304
SHEARING: 500
275305
ENCHANTING: 0
@@ -281,6 +311,7 @@ world:
281311
DISPENSER: 500
282312
SCULK_SHRIEKER: 500
283313
GATE: 0
314+
SMITHING: 500
284315
EXPERIENCE_PICKUP: 500
285316
HOPPER: 500
286317
LEASH: 500
@@ -292,13 +323,16 @@ world:
292323
POTION_THROWING: 500
293324
BARREL: 500
294325
COLLECT_POWDERED_SNOW: 500
326+
CARTOGRAPHY: 500
295327
# These are the default settings for new islands
296328
default-island-settings:
297329
PVP_END: false
298330
PVP_NETHER: false
299331
LEAF_DECAY: true
332+
ENDERMAN_TELEPORT: true
300333
ANIMAL_NATURAL_SPAWN: true
301334
MONSTER_NATURAL_SPAWN: true
335+
SHULKER_TELEPORT: true
302336
FIRE_SPREAD: true
303337
FIRE_BURNING: true
304338
PVP_OVERWORLD: false
@@ -548,4 +582,3 @@ protection:
548582
do-not-edit-these-settings:
549583
# These settings should not be edited
550584
reset-epoch: 0
551-

src/test/java/world/bentobox/aoneblock/listeners/BlockProtectTest.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@
2727
import org.bukkit.entity.Entity;
2828
import org.bukkit.entity.EntityType;
2929
import org.bukkit.entity.Player;
30-
import org.bukkit.event.block.BlockDamageEvent;
30+
import org.bukkit.event.block.Action;
3131
import org.bukkit.event.block.BlockPistonExtendEvent;
3232
import org.bukkit.event.block.BlockPistonRetractEvent;
3333
import org.bukkit.event.entity.EntityChangeBlockEvent;
3434
import org.bukkit.event.entity.EntityExplodeEvent;
3535
import org.bukkit.event.entity.EntitySpawnEvent;
36+
import org.bukkit.event.player.PlayerInteractEvent;
3637
import org.bukkit.inventory.ItemStack;
3738
import org.junit.After;
3839
import org.junit.Before;
@@ -74,6 +75,8 @@ public class BlockProtectTest {
7475
*/
7576
@Before
7677
public void setUp() throws Exception {
78+
79+
when(p.getWorld()).thenReturn(world);
7780
// In World
7881
when(addon.inWorld(world)).thenReturn(true);
7982

@@ -118,11 +121,12 @@ public void testBlockProtect() {
118121
@Test
119122
public void testOnBlockDamage() {
120123
ItemStack item = new ItemStack(Material.DIAMOND_PICKAXE);
121-
BlockDamageEvent blockDamageEvent = new BlockDamageEvent(p, block, item, false);
124+
PlayerInteractEvent blockDamageEvent = new PlayerInteractEvent(p, Action.LEFT_CLICK_BLOCK, item, block,
125+
BlockFace.UP);
122126
bp.onBlockDamage(blockDamageEvent);
123127
verify(addon).inWorld(world);
124128
verify(im).getIslandAt(location);
125-
verify(world, times(80)).spawnParticle(eq(Particle.REDSTONE), eq(null), eq(5),
129+
verify(world, times(48)).spawnParticle(eq(Particle.REDSTONE), eq(null), eq(5),
126130
eq(0.1D), eq(0D), eq(0.1D), eq(1D), any(Particle.DustOptions.class));
127131
}
128132

@@ -131,9 +135,10 @@ public void testOnBlockDamage() {
131135
*/
132136
@Test
133137
public void testOnBlockDamageWrongWorld() {
134-
when(block.getWorld()).thenReturn(mock(World.class));
138+
when(p.getWorld()).thenReturn(mock(World.class));
135139
ItemStack item = new ItemStack(Material.DIAMOND_PICKAXE);
136-
BlockDamageEvent blockDamageEvent = new BlockDamageEvent(p, block, item, false);
140+
PlayerInteractEvent blockDamageEvent = new PlayerInteractEvent(p, Action.LEFT_CLICK_BLOCK, item, block,
141+
BlockFace.UP);
137142
bp.onBlockDamage(blockDamageEvent);
138143
verify(im, never()).getIslandAt(location);
139144
verify(world, never()).spawnParticle(any(Particle.class), any(Location.class),anyInt(),
@@ -147,7 +152,8 @@ public void testOnBlockDamageWrongWorld() {
147152
public void testOnBlockDamageNotCenterMagicBlock() {
148153
when(block.getLocation()).thenReturn(mock(Location.class));
149154
ItemStack item = new ItemStack(Material.DIAMOND_PICKAXE);
150-
BlockDamageEvent blockDamageEvent = new BlockDamageEvent(p, block, item, false);
155+
PlayerInteractEvent blockDamageEvent = new PlayerInteractEvent(p, Action.LEFT_CLICK_BLOCK, item, block,
156+
BlockFace.UP);
151157
bp.onBlockDamage(blockDamageEvent);
152158
verify(addon).inWorld(world);
153159
verify(im).getIslandAt(any(Location.class));

0 commit comments

Comments
 (0)