Problem while taking data from config

Discussion in 'Plugin Development' started by MgMaor, Aug 5, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    MgMaor

    Config:
    Code:
    Explosion-Power: 5
    Bounce-Blocks: true
    Explode-Multiple-TNT-Manually: true
    randomX: -0.5 + (%random% * ((0.5 - -0.5) + 1))
    randomY: -0.5 + (%random% * ((0.5 - -0.5) + 1))
    randomZ: -0.5 + (%random% * ((0.5 - -0.5) + 1))
    Source:
    Code:java
    1. @EventHandler
    2. public void bounceBlocks(EntityExplodeEvent event) {
    3. if (bounceBlocks) {
    4. for (Block block : event.blockList()) {
    5. double randomX = Double.parseDouble(String.valueOf(config.getDouble("RandomX")).replaceAll("%random%", String.valueOf(Math.random())));
    6. double randomY = Double.parseDouble(String.valueOf(config.getDouble("RandomY")).replaceAll("%random%", String.valueOf(Math.random())));
    7. double randomZ = Double.parseDouble(String.valueOf(config.getDouble("RandomZ")).replaceAll("%random%", String.valueOf(Math.random())));
    8. if (explodeMultipleTNT && block.getType() == Material.TNT) {
    9. ((TNTPrimed) block.getWorld().spawnEntity(block.getLocation(), EntityType.PRIMED_TNT)).setFuseTicks(1);
    10. } else {
    11. FallingBlock falling = block.getWorld().spawnFallingBlock(block.getLocation(), block.getType(), block.getData());
    12. falling.setDropItem(false);
    13. falling.setVelocity(new Vector(randomX, randomY, randomZ));
    14. block.setType(Material.AIR);
    15. }
    16. }
    17. }
    18. }

    The TNT doesn't bounce blocks, the x,y,z = 0
     
  2. Offline

    Totom3

    MgMaor Are you sure you can store arithmetic operations in your .yml as numbers and just extract them like that ?
     
  3. MgMaor You can't store a double as an equation.
     
Thread Status:
Not open for further replies.

Share This Page