Update blockBreakEffect and replace old methods

This commit is contained in:
Thanos Paravantis 2016-06-16 12:48:28 +03:00
parent 49fa3377fc
commit ce7bb82d67
4 changed files with 68 additions and 84 deletions

View File

@ -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)

View File

@ -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)
{

View File

@ -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());
}
}

View File

@ -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<Block, Double> distance = new HashMap<Block, Double>();
@ -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);
}
}
}