Skip to content

Commit

Permalink
Prepare first official release (#26)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
BONNe committed Oct 11, 2019
1 parent fb9b464 commit 3449169
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 96 deletions.
34 changes: 0 additions & 34 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

25 changes: 0 additions & 25 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

6 changes: 0 additions & 6 deletions CONTRIBUTING.md

This file was deleted.

5 changes: 0 additions & 5 deletions PULL_REQUEST_TEMPLATE.md

This file was deleted.

8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
<java.version>1.8</java.version>
<powermock.version>1.7.4</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.13.2-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>1.5.0-SNAPSHOT</bentobox.version>
<level.version>1.4.0</level.version>
<spigot.version>1.14.4-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>1.7.0</bentobox.version>
<level.version>1.6.0</level.version>
<vault.version>68f14ec</vault.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>1.5.0.1</build.version>
<build.version>1.7.0.2</build.version>
<build.number>-LOCAL</build.number>
</properties>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package world.bentobox.magiccobblestonegenerator.listeners;


import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.EventHandler;
Expand All @@ -10,6 +14,8 @@
import org.bukkit.event.block.BlockFromToEvent;


import java.util.Random;

import world.bentobox.magiccobblestonegenerator.StoneGeneratorAddon;


Expand Down Expand Up @@ -37,7 +43,7 @@ public MainGeneratorListener(StoneGeneratorAddon addon)
* It cancels this event only if a custom generator manages to change material.
* @param event BlockFromToEvent which result will be overwritten.
*/
@EventHandler(priority = EventPriority.LOW)
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockFromToEvent(BlockFromToEvent event)
{
Block eventSourceBlock = event.getBlock();
Expand Down Expand Up @@ -89,7 +95,14 @@ public void onBlockFromToEvent(BlockFromToEvent event)
if (this.canGenerateStone(liquid, eventToBlock))
{
// Return from here at any case. Even if could not manage to replace stone.
event.setCancelled(this.addon.getGenerator().isReplacementGenerated(eventToBlock, true));

if (this.addon.getGenerator().isReplacementGenerated(eventToBlock, true))
{
// sound when lava transforms to cobble
this.playEffects(eventToBlock);
event.setCancelled(true);
}

return;
}

Expand All @@ -102,7 +115,12 @@ public void onBlockFromToEvent(BlockFromToEvent event)
if (liquid.equals(Material.LAVA) && this.canLavaGenerateCobblestone(eventToBlock, event.getFace()))
{
// Lava is generating cobblestone into eventToBlock place
event.setCancelled(this.addon.getGenerator().isReplacementGenerated(eventToBlock));
if (this.addon.getGenerator().isReplacementGenerated(eventToBlock, true))
{
// sound when lava transforms to cobble
this.playEffects(eventToBlock);
event.setCancelled(true);
}
}
else if (liquid.equals(Material.WATER))
{
Expand All @@ -112,14 +130,57 @@ else if (liquid.equals(Material.WATER))

if (replacedBlock != null)
{
event.setCancelled(this.addon.getGenerator().isReplacementGenerated(replacedBlock));
// Water flow should not be cancelled even if replacement is generated, as replacement block will
// never be in the flow block, as it will always be next block.

if (this.addon.getGenerator().isReplacementGenerated(replacedBlock, true))
{
// sound when lava transforms to cobble
this.playEffects(replacedBlock);
}
}
}

// End of process... no generation for you!!
}


/**
* This method plays sound effect and adds particles to new block.
* @param block block placement where particle must be generated.
*/
private void playEffects(Block block)
{
final double blockX = block.getX();
final double blockY = block.getY();
final double blockZ = block.getZ();

// Run everything in new task
Bukkit.getServer().getScheduler().runTask(this.addon.getPlugin(), () -> {
// Play sound for spawning block
block.getWorld().playSound(block.getLocation(),
Sound.BLOCK_FIRE_EXTINGUISH,
SoundCategory.BLOCKS,
0.5F,
2.6F + (this.random.nextFloat() - this.random.nextFloat()) * 0.8F);

// This spawns 8 large smoke particles.
for (int counter = 0; counter < 8; ++counter)
{
block.getWorld().spawnParticle(Particle.SMOKE_LARGE,
blockX + Math.random(),
blockY + 1 + Math.random(),
blockZ + Math.random(),
1,
0,
0,
0,
0);
}
});
}


// ---------------------------------------------------------------------
// Section: Private Methods
// ---------------------------------------------------------------------
Expand Down Expand Up @@ -372,4 +433,9 @@ private boolean isFlowingLavaBlock(Block block)
* Main addon class.
*/
private StoneGeneratorAddon addon;

/**
* A bit of randomness
*/
public final Random random = new Random();
}
17 changes: 17 additions & 0 deletions src/main/resources/locales/es.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
stonegenerator:
commands:
level:
description: Este método muestra el nivel del generador mágico de tu isla.
main:
description: Método principal para Magic Cobblestone Generator. Muestra ayuda.
alllevels:
description: Este método devuelve todos los niveles del generador de adoquines
mágicos para el mundo actual.
messages:
generator-tier: "&2 [name] &r &2 (desde [value] nivel de isla)."
material-chance: "&2 [name] - [value]%"
island-level: "&2Tu nivel de isla es: &6[level]&2!"
errors:
cannot-find-any-generators: "&cNo puedo encontrar ningún nivel de generador de
adoquines mágicos para el mundo actual."
18 changes: 0 additions & 18 deletions src/main/resources/locales/lv-LV.yml

This file was deleted.

0 comments on commit 3449169

Please sign in to comment.