From 7009e466935c3cb6c80023b9b1dfdf4a8609c044 Mon Sep 17 00:00:00 2001 From: Thanos paravantis Date: Fri, 6 Nov 2015 20:25:38 +0200 Subject: [PATCH] Several updates and bug fixes. Evolution of Combat rework (See ChallengeNewEvolutionOfCombat). --- .../arcade/game/games/mineware/MineWare.java | 8 +- .../challenges/ChallengeBlockRunner.java | 33 +--- .../challenges/ChallengeFastFood.java | 2 +- .../ChallengeNewEvolutionOfCombat.java | 144 ++++++++++++++++++ 4 files changed, 155 insertions(+), 32 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeNewEvolutionOfCombat.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/MineWare.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/MineWare.java index ccfaea9d2..504e26178 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/MineWare.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/MineWare.java @@ -28,7 +28,12 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.games.holeinwall.KitNormal; +import nautilus.game.arcade.game.games.mineware.challenges.ChallengeAnvilDance; +import nautilus.game.arcade.game.games.mineware.challenges.ChallengeBlockRunner; +import nautilus.game.arcade.game.games.mineware.challenges.ChallengeEvolutionOfCombat; +import nautilus.game.arcade.game.games.mineware.challenges.ChallengeFallingBlocks; import nautilus.game.arcade.game.games.mineware.challenges.ChallengeFastFood; +import nautilus.game.arcade.game.games.mineware.challenges.ChallengeNewEvolutionOfCombat; import nautilus.game.arcade.game.games.mineware.events.challengeEndEvent; import nautilus.game.arcade.kit.Kit; @@ -143,7 +148,8 @@ public class MineWare extends SoloGame implements IThrown public void PopulateOrders() { - _challenges.add(ChallengeFastFood.class); + _challenges.add(ChallengeNewEvolutionOfCombat.class); +// _challenges.add(ChallengeFastFood.class); // _challenges.add(ChallengeEvolutionOfCombat.class); // _challenges.add(ChallengeBlockRunner.class); // _challenges.add(ChallengeAnvilDance.class); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeBlockRunner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeBlockRunner.java index 85f8fc01a..51f1c52d5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeBlockRunner.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeBlockRunner.java @@ -109,7 +109,6 @@ public class ChallengeBlockRunner extends Challenge } } - @SuppressWarnings("deprecation") @EventHandler public void onBlockPlace(BlockPlaceEvent event) { @@ -162,37 +161,11 @@ public class ChallengeBlockRunner extends Challenge // Third Check // Checking if the player is trying to make a tower up to the sky. - Block bottom1 = player.getLocation().getBlock().getRelative(BlockFace.DOWN); - Block bottom2 = bottom1.getRelative(BlockFace.DOWN); - Block bottom3 = bottom2.getRelative(BlockFace.DOWN); - - if(!bottom1.isEmpty() && !bottom2.isEmpty() && !bottom3.isEmpty() && block.getY() < player.getLocation().getY()) + if(block.getLocation().getY() >= 4) { - // Adding broken blocks back to inventory even if he didn't placed them. - // This is so we can prevent quick block farming. - - ItemStack handItem = player.getItemInHand(); - UtilInv.remove(player, handItem.getType(), handItem.getData().getData(), 1); - - if(bottom1.getType() != Material.GRASS) - { - UtilInv.insert(player, new ItemStack(bottom1.getType())); - blockBreakEffect(bottom1); - } - - if(bottom2.getType() != Material.GRASS) - { - UtilInv.insert(player, new ItemStack(bottom2.getType())); - blockBreakEffect(bottom2); - } - - if(bottom3.getType() != Material.GRASS && bottom3.getType() != Material.DIRT) - { - UtilInv.insert(player, new ItemStack(bottom3.getType())); - blockBreakEffect(bottom3); - } - UtilTextMiddle.display("", C.cRed + "You can't build a tower that high.", 5, 40, 5, player); + blockBreakEffect(block); + event.setCancelled(true); return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeFastFood.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeFastFood.java index 112615716..1d7e482af 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeFastFood.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeFastFood.java @@ -195,7 +195,7 @@ public class ChallengeFastFood extends Challenge { double random = Math.random() * 100; - if(random < 30) + if(random < 30.0) { Location drop = item.getLocation(); Block block = drop.getBlock(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeNewEvolutionOfCombat.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeNewEvolutionOfCombat.java new file mode 100644 index 000000000..05f01c114 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeNewEvolutionOfCombat.java @@ -0,0 +1,144 @@ +package nautilus.game.arcade.game.games.mineware.challenges; + +import java.util.ArrayList; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilShapes; +import nautilus.game.arcade.game.games.mineware.Challenge; +import nautilus.game.arcade.game.games.mineware.MineWare; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockBreakEvent; + +public class ChallengeNewEvolutionOfCombat extends Challenge +{ + public ChallengeNewEvolutionOfCombat(MineWare host) + { + super(host, ChallengeType.LastStanding, "Evolution of Combat", "Find supplies and attack others quickly.", + "Be the last person to stay alive."); + } + + @Override + public ArrayList getSpawns() + { + ArrayList spawns = new ArrayList(); + Location center = new Location(Host.WorldData.World, 0, 0, 0); + + for(Location location : UtilShapes.getCircle(center, true, getArenaSize() - 2)) + { + double x = location.getX() + 0.5; + double y = 3.1; + double z = location.getZ() + 0.5; + + Location spawn = getCenter().add(x, y, z); + spawns.add(spawn); + } + + return spawns; + } + + @Override + public void generateRoom() + { + Location center = new Location(Host.WorldData.World, 0, 0, 0); + + for(int i = 0; i < 6; i++) + { + if(i > 0) + { + center = center.clone(); + center.setY(0); + center.add(0, i, 0); + } + + for(Location location : UtilShapes.getCircle(center, false, getArenaSize())) + { + Block map = location.getBlock(); + double chance = Math.random() * 100; + + if(i == 0) + { + map.setType(Material.BEDROCK); + } + else if(i == 1) + { + map.setType(Material.SAND); + + if(chance < 3.0) + { + map.setType(Material.CHEST); + } + else if(chance < 20.0) + { + map.setType(Material.SANDSTONE); + } + } + else if(i == 2) + { + map.setType(Material.SAND); + } + else if(i == 3) + { + if(chance < 2.0 && !getSpawns().contains(map.getLocation())) + { + if(UtilMath.random.nextBoolean()) + map.setType(Material.DEAD_BUSH); + else + map.setType(Material.CACTUS); + } + } + else if(i == 4) + { + if(map.getRelative(BlockFace.DOWN).getType() == Material.CACTUS && UtilMath.random.nextBoolean()) + { + map.setType(Material.CACTUS); + } + } + + addBlock(map); + } + } + } + + @EventHandler + public void onBlockBreak(BlockBreakEvent event) + { + Block block = event.getBlock(); + + Block above = block.getRelative(BlockFace.UP); + + if(above.getType() == Material.CACTUS) + { + above.setType(Material.AIR); + } + + block.setType(Material.AIR); + } + + @Override + public void setupPlayers() + { + Host.InventoryOpenChest = true; + Host.BlockBreak = true; + Host.InventoryOpenBlock = true; + Host.InventoryClick = true; + Host.WorldBlockBurn = true; + Host.WorldFireSpread = true; + } + + @Override + public void cleanupRoom() + { + Host.InventoryOpenChest = false; + Host.BlockBreak = false; + Host.InventoryOpenBlock = false; + Host.InventoryClick = false; + Host.DamagePvP = false; + Host.WorldBlockBurn = false; + Host.WorldFireSpread = false; + } +}