Skip to content

Commit 3449169

Browse files
authored
Prepare first official release (#26)
* Add ignoreCancelled to BlockFromToEvent to avoid issues when addon allows to place water where it should not be. * Fix issue when water stop flowing, if cobblestone generation is triggered by water flow (#24) * Add generation sound effect and particles (#23) * Add Spanish translation (#25) * Update config.yml to include info on decimals and total chance values per tier (#22) * Update config.yml to include info on decimals and max chance values Update config.yml to include info on decimals for chances and max chance values for tiers. * Translate es.yml via GitLocalize * Translate es.yml via GitLocalize * Remove unnecessary templates un translation files. Update dependencies in pom.
1 parent fb9b464 commit 3449169

File tree

8 files changed

+91
-96
lines changed

8 files changed

+91
-96
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

-34
This file was deleted.

.github/ISSUE_TEMPLATE/feature_request.md

-25
This file was deleted.

CONTRIBUTING.md

-6
This file was deleted.

PULL_REQUEST_TEMPLATE.md

-5
This file was deleted.

pom.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@
3535
<java.version>1.8</java.version>
3636
<powermock.version>1.7.4</powermock.version>
3737
<!-- More visible way how to change dependency versions -->
38-
<spigot.version>1.13.2-R0.1-SNAPSHOT</spigot.version>
39-
<bentobox.version>1.5.0-SNAPSHOT</bentobox.version>
40-
<level.version>1.4.0</level.version>
38+
<spigot.version>1.14.4-R0.1-SNAPSHOT</spigot.version>
39+
<bentobox.version>1.7.0</bentobox.version>
40+
<level.version>1.6.0</level.version>
4141
<vault.version>68f14ec</vault.version>
4242
<!-- Revision variable removes warning about dynamic version -->
4343
<revision>${build.version}-SNAPSHOT</revision>
4444
<!-- This allows to change between versions and snapshots. -->
45-
<build.version>1.5.0.1</build.version>
45+
<build.version>1.7.0.2</build.version>
4646
<build.number>-LOCAL</build.number>
4747
</properties>
4848

src/main/java/world/bentobox/magiccobblestonegenerator/listeners/MainGeneratorListener.java

+70-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package world.bentobox.magiccobblestonegenerator.listeners;
22

33

4+
import org.bukkit.Bukkit;
45
import org.bukkit.Material;
6+
import org.bukkit.Particle;
7+
import org.bukkit.Sound;
8+
import org.bukkit.SoundCategory;
59
import org.bukkit.block.Block;
610
import org.bukkit.block.BlockFace;
711
import org.bukkit.event.EventHandler;
@@ -10,6 +14,8 @@
1014
import org.bukkit.event.block.BlockFromToEvent;
1115

1216

17+
import java.util.Random;
18+
1319
import world.bentobox.magiccobblestonegenerator.StoneGeneratorAddon;
1420

1521

@@ -37,7 +43,7 @@ public MainGeneratorListener(StoneGeneratorAddon addon)
3743
* It cancels this event only if a custom generator manages to change material.
3844
* @param event BlockFromToEvent which result will be overwritten.
3945
*/
40-
@EventHandler(priority = EventPriority.LOW)
46+
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
4147
public void onBlockFromToEvent(BlockFromToEvent event)
4248
{
4349
Block eventSourceBlock = event.getBlock();
@@ -89,7 +95,14 @@ public void onBlockFromToEvent(BlockFromToEvent event)
8995
if (this.canGenerateStone(liquid, eventToBlock))
9096
{
9197
// Return from here at any case. Even if could not manage to replace stone.
92-
event.setCancelled(this.addon.getGenerator().isReplacementGenerated(eventToBlock, true));
98+
99+
if (this.addon.getGenerator().isReplacementGenerated(eventToBlock, true))
100+
{
101+
// sound when lava transforms to cobble
102+
this.playEffects(eventToBlock);
103+
event.setCancelled(true);
104+
}
105+
93106
return;
94107
}
95108

@@ -102,7 +115,12 @@ public void onBlockFromToEvent(BlockFromToEvent event)
102115
if (liquid.equals(Material.LAVA) && this.canLavaGenerateCobblestone(eventToBlock, event.getFace()))
103116
{
104117
// Lava is generating cobblestone into eventToBlock place
105-
event.setCancelled(this.addon.getGenerator().isReplacementGenerated(eventToBlock));
118+
if (this.addon.getGenerator().isReplacementGenerated(eventToBlock, true))
119+
{
120+
// sound when lava transforms to cobble
121+
this.playEffects(eventToBlock);
122+
event.setCancelled(true);
123+
}
106124
}
107125
else if (liquid.equals(Material.WATER))
108126
{
@@ -112,14 +130,57 @@ else if (liquid.equals(Material.WATER))
112130

113131
if (replacedBlock != null)
114132
{
115-
event.setCancelled(this.addon.getGenerator().isReplacementGenerated(replacedBlock));
133+
// Water flow should not be cancelled even if replacement is generated, as replacement block will
134+
// never be in the flow block, as it will always be next block.
135+
136+
if (this.addon.getGenerator().isReplacementGenerated(replacedBlock, true))
137+
{
138+
// sound when lava transforms to cobble
139+
this.playEffects(replacedBlock);
140+
}
116141
}
117142
}
118143

119144
// End of process... no generation for you!!
120145
}
121146

122147

148+
/**
149+
* This method plays sound effect and adds particles to new block.
150+
* @param block block placement where particle must be generated.
151+
*/
152+
private void playEffects(Block block)
153+
{
154+
final double blockX = block.getX();
155+
final double blockY = block.getY();
156+
final double blockZ = block.getZ();
157+
158+
// Run everything in new task
159+
Bukkit.getServer().getScheduler().runTask(this.addon.getPlugin(), () -> {
160+
// Play sound for spawning block
161+
block.getWorld().playSound(block.getLocation(),
162+
Sound.BLOCK_FIRE_EXTINGUISH,
163+
SoundCategory.BLOCKS,
164+
0.5F,
165+
2.6F + (this.random.nextFloat() - this.random.nextFloat()) * 0.8F);
166+
167+
// This spawns 8 large smoke particles.
168+
for (int counter = 0; counter < 8; ++counter)
169+
{
170+
block.getWorld().spawnParticle(Particle.SMOKE_LARGE,
171+
blockX + Math.random(),
172+
blockY + 1 + Math.random(),
173+
blockZ + Math.random(),
174+
1,
175+
0,
176+
0,
177+
0,
178+
0);
179+
}
180+
});
181+
}
182+
183+
123184
// ---------------------------------------------------------------------
124185
// Section: Private Methods
125186
// ---------------------------------------------------------------------
@@ -372,4 +433,9 @@ private boolean isFlowingLavaBlock(Block block)
372433
* Main addon class.
373434
*/
374435
private StoneGeneratorAddon addon;
436+
437+
/**
438+
* A bit of randomness
439+
*/
440+
public final Random random = new Random();
375441
}

src/main/resources/locales/es.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
stonegenerator:
3+
commands:
4+
level:
5+
description: Este método muestra el nivel del generador mágico de tu isla.
6+
main:
7+
description: Método principal para Magic Cobblestone Generator. Muestra ayuda.
8+
alllevels:
9+
description: Este método devuelve todos los niveles del generador de adoquines
10+
mágicos para el mundo actual.
11+
messages:
12+
generator-tier: "&2 [name] &r &2 (desde [value] nivel de isla)."
13+
material-chance: "&2 [name] - [value]%"
14+
island-level: "&2Tu nivel de isla es: &6[level]&2!"
15+
errors:
16+
cannot-find-any-generators: "&cNo puedo encontrar ningún nivel de generador de
17+
adoquines mágicos para el mundo actual."

src/main/resources/locales/lv-LV.yml

-18
This file was deleted.

0 commit comments

Comments
 (0)