From ce7bb82d67f76924b940a805331a0b94bc9b7db6 Mon Sep 17 00:00:00 2001 From: Thanos Paravantis Date: Thu, 16 Jun 2016 12:48:28 +0300 Subject: [PATCH] Update blockBreakEffect and replace old methods --- .../games/mineware/challenge/Challenge.java | 13 ++- .../challenge/type/ChallengeBuildRace.java | 19 +-- .../challenge/type/ChallengeFastFood.java | 10 +- .../challenge/type/ChallengeLavaRun.java | 110 +++++++++--------- 4 files changed, 68 insertions(+), 84 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/Challenge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/Challenge.java index a2f3f9627..20ea87717 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/Challenge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/Challenge.java @@ -469,7 +469,7 @@ public abstract class Challenge implements Listener { setBlock(block, type, (byte) 0); } - + public void setData(Block block, byte data) { setBlock(block, block.getType(), data); @@ -479,7 +479,7 @@ public abstract class Challenge implements Listener { setBlock(block, Material.AIR, (byte) 0); } - + protected void addBlock(Block... blocks) { for (Block block : blocks) @@ -528,12 +528,17 @@ public abstract class Challenge implements Listener UtilInv.removeAll(player, type, data); } } - + @SuppressWarnings("deprecation") - protected void blockBreakParticles(Block block) + protected void blockBreakEffect(Block block, boolean resetBlock) { UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(block.getType(), block.getData()), block.getLocation(), 0, 0, 0, 0, 10, ViewDist.NORMAL, UtilServer.getPlayers()); block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId()); + + if (resetBlock) + { + resetBlock(block); + } } protected void addEffect(PotionEffectType type, int duration, int amplifier) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeBuildRace.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeBuildRace.java index d5b3a766c..72a1385ad 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeBuildRace.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeBuildRace.java @@ -5,7 +5,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -18,10 +17,6 @@ import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.challenge.Challenge; @@ -139,7 +134,7 @@ public class ChallengeBuildRace extends Challenge implements LogicTracker if (bottomVoid1.isEmpty() && bottomVoid2.isEmpty() && bottomVoid3.isEmpty()) { UtilTextMiddle.display(null, C.cRed + "You can't place blocks that far from the ground.", 5, 40, 5, player); - blockBreakEffect(block); + blockBreakEffect(block, true); event.setCancelled(true); return; } @@ -155,7 +150,7 @@ public class ChallengeBuildRace extends Challenge implements LogicTracker if (block.getLocation().add(0.5, 0.5, 0.5).distanceSquared(others.getLocation()) <= 1.5) { UtilTextMiddle.display(null, C.cRed + "You can't place blocks near other players.", 5, 40, 5, player); - blockBreakEffect(block); + blockBreakEffect(block, true); event.setCancelled(true); return; } @@ -167,7 +162,7 @@ public class ChallengeBuildRace extends Challenge implements LogicTracker if (block.getLocation().getY() >= getCenter().getY() + 3) { UtilTextMiddle.display("", C.cRed + "You can't build a tower that high.", 5, 40, 5, player); - blockBreakEffect(block); + blockBreakEffect(block, true); event.setCancelled(true); return; } @@ -219,14 +214,6 @@ public class ChallengeBuildRace extends Challenge implements LogicTracker } } - @SuppressWarnings("deprecation") - private void blockBreakEffect(Block block) - { - UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(block.getType(), block.getData()), block.getLocation(), 0.0F, 0.0F, 0.0F, 0, 10, ViewDist.NORMAL, UtilServer.getPlayers()); - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId()); - resetBlock(block); - } - @Override public boolean hasData(Player player) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeFastFood.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeFastFood.java index edacfe057..b8120362b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeFastFood.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeFastFood.java @@ -2,7 +2,6 @@ package nautilus.game.arcade.game.games.mineware.challenge.type; import java.util.ArrayList; -import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -275,7 +274,7 @@ public class ChallengeFastFood extends Challenge setData(block, (byte) UtilMath.r(8)); } - blockBreakEffect(block); + blockBreakEffect(block, false); addBlock(block); item.remove(); } @@ -294,11 +293,4 @@ public class ChallengeFastFood extends Challenge if (items.size() == 0) setCompleted(player); } - - @SuppressWarnings("deprecation") - private void blockBreakEffect(Block block) - { - UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(block.getType(), block.getData()), block.getLocation(), 0.0F, 0.0F, 0.0F, 0, 10, ViewDist.NORMAL, UtilServer.getPlayers()); - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId()); - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeLavaRun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeLavaRun.java index f31a064a2..9b6dc077f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeLavaRun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeLavaRun.java @@ -139,7 +139,7 @@ public class ChallengeLavaRun extends Challenge generatePlatform(); setBlock(_obsidian, Material.OBSIDIAN); - blockBreakParticles(_obsidian); + blockBreakEffect(_obsidian, false); playSound(); _delay = System.currentTimeMillis(); @@ -167,21 +167,6 @@ public class ChallengeLavaRun extends Challenge } } - private boolean isPlatformEmpty() - { - int emptyBlocks = 0; - - for (Block part : _platform) - { - if (part.isEmpty()) - { - emptyBlocks++; - } - } - - return emptyBlocks == _platform.size() - 1; - } - private void generatePlatform() { _platform = new ArrayList<>(); @@ -198,6 +183,45 @@ public class ChallengeLavaRun extends Challenge } } + private void createLava() + { + int size = getArenaSize() + 3; + + for (int x = -size; x <= size; x++) + { + for (int z = -size; z <= size; z++) + { + for (int y = 0; y < _mapY; y++) + { + Block block = getCenter().getBlock().getRelative(x, y, z); + setBlock(block, Material.STATIONARY_LAVA); + addBlock(block); + } + } + } + } + + private Block generateObsidianBlock() + { + Block block = getCenter().add( + UtilMath.r(21) - 9.5, + _mapY, + UtilMath.r(21) - 9.5).getBlock(); + + setBlock(block, Material.OBSIDIAN); + return block; + } + + private void disguisePlayers() + { + for (Player player : getPlayersAlive()) + { + DisguiseMagmaCube disguise = new DisguiseMagmaCube(player); + disguise.SetSize(1); + Host.getArcadeManager().GetDisguise().disguise(disguise); + } + } + private void playSound() { for (Player player : getPlayersAlive()) @@ -206,6 +230,21 @@ public class ChallengeLavaRun extends Challenge } } + private boolean isPlatformEmpty() + { + int emptyBlocks = 0; + + for (Block part : _platform) + { + if (part.isEmpty()) + { + emptyBlocks++; + } + } + + return emptyBlocks == _platform.size() - 1; + } + private void destroyPlatform() { HashMap distance = new HashMap(); @@ -235,43 +274,4 @@ public class ChallengeLavaRun extends Challenge } } } - - private Block generateObsidianBlock() - { - Block block = getCenter().add( - UtilMath.r(21) - 9.5, - _mapY, - UtilMath.r(21) - 9.5).getBlock(); - - setBlock(block, Material.OBSIDIAN); - return block; - } - - private void createLava() - { - int size = getArenaSize() + 3; - - for (int x = -size; x <= size; x++) - { - for (int z = -size; z <= size; z++) - { - for (int y = 0; y < _mapY; y++) - { - Block block = getCenter().getBlock().getRelative(x, y, z); - setBlock(block, Material.STATIONARY_LAVA); - addBlock(block); - } - } - } - } - - private void disguisePlayers() - { - for (Player player : getPlayersAlive()) - { - DisguiseMagmaCube disguise = new DisguiseMagmaCube(player); - disguise.SetSize(1); - Host.getArcadeManager().GetDisguise().disguise(disguise); - } - } }