diff --git a/Plugins/Nautilus.Game.Arcade/.settings/org.eclipse.jdt.core.prefs b/Plugins/Nautilus.Game.Arcade/.settings/org.eclipse.jdt.core.prefs index 0b9935d5f..d9b647a86 100644 --- a/Plugins/Nautilus.Game.Arcade/.settings/org.eclipse.jdt.core.prefs +++ b/Plugins/Nautilus.Game.Arcade/.settings/org.eclipse.jdt.core.prefs @@ -276,7 +276,7 @@ org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_ org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_lines_in_comments=false org.eclipse.jdt.core.formatter.join_wrapped_lines=false org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java index 0648847e4..e034b7d93 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/BawkBawkBattles.java @@ -48,7 +48,6 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; @@ -158,11 +157,17 @@ public class BawkBawkBattles extends TeamGame implements IThrown /** * TODO: Bugs * - * - Rotating chicken head does not appear. - Small delay on spectator reset? - Do not trigger chicken attack on game end (eg. 3 players killed at - * once). - Make players spawn with equal distance from a target. - Do not spawn grass on spawn locations. - Team Challenges: Define team - * properly. - When timer runs out, challenge does not end. - Win placement is not accurate. - Chicken attack does not trigger sometimes. - - * Reverse Tag: Tagging does not work sometimes, remove any damage dealt. - Infestation: Zombie takes two lifes instead of one. - Pick a Side: - * Does not work with 3 players. - Dragon Egg: Eggs do not disappear sometimes. - Fix rest of the challenges. + * - Rotating chicken head does not appear. + * - Small delay on spectator reset? + * - Do not trigger chicken attack on game end (eg. 3 players killed at once). + * - Make players spawn with equal distance from a target. + * - Do not spawn grass on spawn locations. + * - Team Challenges: Define team properly. + * - When timer runs out, challenge does not end. + * - Win placement is not accurate. + * - Chicken attack does not trigger sometimes. + * - Pick a Side: Does not work with 3 players. + * - Fix rest of the challenges. */ @SuppressWarnings("unchecked") @@ -606,8 +611,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown { for (Player player : getChallengers()) { - Manager.GetDisguise().undisguise(player); - UtilInv.Clear(player); + Manager.Clear(player); for (PotionEffect effect : player.getActivePotionEffects()) { @@ -774,7 +778,8 @@ public class BawkBawkBattles extends TeamGame implements IThrown public void showChallengeDescription(final Challenge challenge) { - Manager.GetChat().Silence(5000, false); + if (Manager.GetChat().Silenced() < 0) + Manager.GetChat().Silence(5000, false); _settings.markMessagesAsSending(true); _settings.markMessagesAsSent(false); @@ -863,7 +868,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown if (index == _countdown.size() - 1) { - Manager.GetChat().Silence(0, true); _settings.markMessagesAsSent(true); _settings.markMessagesAsSending(false); cancel(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeInfestation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeInfestation.java index f1fde5901..40190f568 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeInfestation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeInfestation.java @@ -11,16 +11,17 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.potion.PotionEffectType; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; 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.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilShapes; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseZombie; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -33,7 +34,7 @@ import nautilus.game.arcade.game.games.mineware.challenge.other.InfestationZombi public class ChallengeInfestation extends Challenge { private InfestationZombie _zombie = new InfestationZombie(this); - private HashSet _infected = new HashSet(); + private HashSet _infected = new HashSet(); public ChallengeInfestation(BawkBawkBattles host) { @@ -77,24 +78,25 @@ public class ChallengeInfestation extends Challenge @Override public void onStart() { - Host.CreatureAllowOverride = true; + Host.DamageEvP = true; + Host.DamagePvP = true; + + Host.CreatureAllow = true; _zombie.spawn(); - Host.CreatureAllowOverride = false; + Host.CreatureAllow = false; + _zombie.getEntity().setFireTicks(0); addEffect(PotionEffectType.SPEED, 1); - - Host.DamageEvP = true; - Host.DamagePvP = true; } @Override public void onEnd() { - _zombie.remove(); - Host.DamageEvP = false; Host.DamagePvP = false; + + _zombie.remove(); } @EventHandler @@ -129,13 +131,15 @@ public class ChallengeInfestation extends Challenge _zombie.move(target); if (_zombie.getLocation().distance(target.getLocation()) <= 2) - if (!_infected.contains(target.getName())) + { + if (!_infected.contains(target)) { if (Settings.getStartTime() + 5000 > System.currentTimeMillis()) return; infect(target); } + } } @EventHandler @@ -162,29 +166,35 @@ public class ChallengeInfestation extends Challenge if ((!(event.GetDamagerEntity(false) instanceof Player))) return; - if (Data.isCompleted(event.GetDamageePlayer())) + Player damager = event.GetDamagerPlayer(false); + Player damagee = event.GetDamageePlayer(); + + if (!isPlayerValid(damager)) { - event.SetCancelled("Player already finished"); + event.SetCancelled("Invalid Damager"); return; } - if (!_infected.contains(event.GetDamagerPlayer(false).getName())) + if (!isPlayerValid(damagee)) { - event.SetCancelled("Not infected"); + event.SetCancelled("Invalid Damagee"); return; } - if (_infected.contains(event.GetDamageePlayer().getName())) + if (!_infected.contains(damager)) { - event.SetCancelled("Already infected"); + event.SetCancelled("Not Infected"); return; } - else + + if (_infected.contains(damagee)) { - infect(event.GetDamageePlayer()); - event.SetCancelled("Infected"); + event.SetCancelled("Already Infected"); return; } + + infect(damager); + event.SetCancelled("Infected"); } @EventHandler @@ -197,11 +207,15 @@ public class ChallengeInfestation extends Challenge return; if (_infected.size() >= Math.floor(getChallengers().size() / 2)) + { for (Player player : getChallengers()) - if (_infected.contains(player.getName())) - setLost(player); - else + { + if (!_infected.contains(player)) + { setCompleted(player); + } + } + } } @EventHandler @@ -216,25 +230,38 @@ public class ChallengeInfestation extends Challenge event.setCancelled(true); } } - - private void freeze(int millisec) + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) { - _zombie.setFreezeTime(System.currentTimeMillis() + millisec); + if (!isChallengeValid()) + return; + + Player player = event.getPlayer(); + + if (_infected.contains(player)) + { + _infected.remove(player); + } + } + + private void freeze(long duration) + { + _zombie.setFreezeTime(System.currentTimeMillis() + duration); _zombie.freeze(); } private void infect(Player player) { - if (_infected.contains(player.getName())) + if (_infected.contains(player)) return; - _infected.add(player.getName()); + _infected.add(player); _zombie.setSpeed(1.0F); Host.WorldData.World.strikeLightningEffect(player.getLocation()); Host.getArcadeManager().GetDisguise().disguise(new DisguiseZombie(player)); UtilPlayer.message(player, F.main("Game", "You have been infected, you now have to infect the rest.")); - // player.sendMessage(F.main("Game", "You have been infected. It's over so infect the rest!")); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeReverseTag.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeReverseTag.java index febc44a73..a0286de55 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeReverseTag.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeReverseTag.java @@ -99,16 +99,19 @@ public class ChallengeReverseTag extends Challenge Host.DamagePvP = true; int i = 0; - ArrayList players = new ArrayList(Host.GetPlayers(true)); + ArrayList players = getChallengers(); Collections.shuffle(players); for (Player player : players) { - _nonTagged.add(player); - - if (i % 2 == 0) + if (i < (int) players.size() / 2) { - addTagged(player); + _tagged.add(player); + tagEffect(player); + } + else + { + _nonTagged.add(player); } i++; @@ -129,10 +132,10 @@ public class ChallengeReverseTag extends Challenge setCompleted(tagged); } - for (Player nonTagged : _nonTagged.getPlayers()) - { - setLost(nonTagged); - } +// for (Player nonTagged : _nonTagged.getPlayers()) +// { +// setLost(nonTagged); +// } } @EventHandler @@ -165,24 +168,25 @@ public class ChallengeReverseTag extends Challenge if (!isPlayerValid(damager)) { - event.SetCancelled("Damager is invalid"); + event.SetCancelled("Invalid Damager"); return; } if (!isPlayerValid(damagee)) { - event.SetCancelled("Damagee is invalid"); + event.SetCancelled("Invalid Damagee"); return; } - if (_tagged.isMember(damagee) && _nonTagged.isMember(damager) && !_cooldowns.contains(damager)) + if (_tagged.isMember(damagee) && _nonTagged.isMember(damager) && !_cooldowns.contains(damagee)) { - removeTagged(damagee); - addTagged(damager); + clear(damagee); + tag(damager, true); + event.SetCancelled("Successful Tag"); } else { - event.SetCancelled("Cancelling tag attempt"); + event.SetCancelled("Invalid Tag Attempt"); } } @@ -214,48 +218,67 @@ public class ChallengeReverseTag extends Challenge _nonTagged.remove(player); } - private void removeTagged(Player player) + private void clear(Player player) { if (_tagged.isMember(player)) { - UtilTextMiddle.display(null, C.cRed + "You are no longer tagged.", 5, 40, 5, player); - player.getInventory().setHelmet(new ItemStack(Material.AIR)); - + clearEffect(player); _tagged.remove(player); - _nonTagged.remove(player); + _nonTagged.add(player); + } + } - for (int i = 0; i <= 8; i++) + private void clearEffect(Player player) + { + UtilTextMiddle.display(null, C.cRed + "You are no longer tagged.", 5, 40, 5, player); + player.getInventory().setHelmet(new ItemStack(Material.AIR)); + + for (int i = 0; i <= 8; i++) + { + player.getInventory().clear(i); + } + } + + private void tag(Player player, boolean cooldown) + { + if (_nonTagged.isMember(player)) + { + tagEffect(player); + + _nonTagged.remove(player); + _tagged.add(player); + _cooldowns.add(player); + + if (cooldown) { - player.getInventory().clear(i); + removeCooldown(player); } } } - private void addTagged(final Player player) + private void tagEffect(Player player) { - if (_nonTagged.isMember(player)) + UtilTextMiddle.display(null, C.cGreen + "You are now tagged, keep it up.", 5, 40, 5, player); + player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(35, (byte) 5)); + + for (int i = 0; i <= 8; i++) { - UtilTextMiddle.display(null, C.cGreen + "You are now tagged, keep it up.", 5, 40, 5, player); - player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(35, (byte) 5)); - _tagged.add(player); - _cooldowns.add(player); - - new BukkitRunnable() - { - @Override - public void run() - { - _cooldowns.remove(player); - } - }.runTaskLater(Host.Manager.getPlugin(), 20 * _cooldown); - - for (int i = 0; i <= 8; i++) - { - player.getInventory().setItem(i, ItemStackFactory.Instance.CreateStack(35, (byte) 5)); - } + player.getInventory().setItem(i, ItemStackFactory.Instance.CreateStack(35, (byte) 5)); } } + private void removeCooldown(Player player) + { + new BukkitRunnable() + { + @Override + public void run() + { + _cooldowns.remove(player); + } + }.runTaskLater(Host.Manager.getPlugin(), 20 * _cooldown); + } + public ChallengeTeam getTagged() { return _tagged; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeVolleyPig.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeVolleyPig.java index bac7cf4cb..8d583b858 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeVolleyPig.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenge/type/ChallengeVolleyPig.java @@ -1,14 +1,15 @@ package nautilus.game.arcade.game.games.mineware.challenge.type; import java.util.ArrayList; +import java.util.Arrays; import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Damageable; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Pig; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -20,6 +21,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAction; @@ -28,10 +31,7 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.challenge.Challenge; @@ -57,6 +57,7 @@ public class ChallengeVolleyPig extends Challenge Settings.setMaxPlayers(25); Settings.setTeamBased(); Settings.setLockInventory(4); + Settings.setDuration(30000); _blueTeam = new ChallengeTeam("Blue"); _redTeam = new ChallengeTeam("Red"); @@ -116,6 +117,8 @@ public class ChallengeVolleyPig extends Challenge spawnPig(); addPlayersOnTeam(); equipTeamHelmets(); + + startMainTask(); } @Override @@ -141,19 +144,20 @@ public class ChallengeVolleyPig extends Challenge Location from = event.getFrom(); Location to = event.getTo(); - if (from.getBlock().getType() != Material.STAINED_CLAY) - return; + Block fromBlock = from.getBlock().getRelative(BlockFace.DOWN); + Block toBlock = to.getBlock().getRelative(BlockFace.DOWN); - from.setY(0); - to.setY(0); - - if (to.getBlock().isEmpty() || to.getBlock().getData() != from.getBlock().getData()) + if (!fromBlock.isEmpty() && !toBlock.isEmpty()) { - // ArrayList center = new ArrayList(Arrays.asList(getTeamCenter(player))); - // Vector bump = UtilAlg.getAverageBump(player.getLocation(), center); - UtilAction.velocity(event.getPlayer(), UtilAlg.getTrajectory(player.getLocation(), getTeamCenter(player)), 0.8, false, 0, 0.4, 10, true); - player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 60, 1)); - UtilTextMiddle.display(null, C.cRed + "You cannot cross to the enemy side.", 5, 40, 5, event.getPlayer()); + boolean crossedBlue = _redTeam.isMember(player) && (fromBlock.getData() == 11 || toBlock.getData() == 11); + boolean crossedRed = _blueTeam.isMember(player) && (fromBlock.getData() == 14 || toBlock.getData() == 14); + boolean fromStainedGlass = fromBlock.getType() == Material.STAINED_GLASS; + boolean toStainedGlass = toBlock.getType() == Material.STAINED_GLASS; + + if (crossedBlue || crossedRed || fromStainedGlass || toStainedGlass) + { + knockback(player); + } } } @@ -175,20 +179,6 @@ public class ChallengeVolleyPig extends Challenge pig.setHealth(pig.getMaxHealth()); } - @EventHandler - public void onUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - if (!isChallengeValid()) - return; - - increaseTeamScore(); - displayProgress(); - selectWinners(); - } - @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { @@ -201,11 +191,31 @@ public class ChallengeVolleyPig extends Challenge _redTeam.remove(player); } + private void startMainTask() + { + new BukkitRunnable() + { + @Override + public void run() + { + if (!isChallengeValid()) + { + cancel(); + return; + } + + increaseTeamScore(); + displayProgress(); + selectWinners(); + } + }.runTaskTimer(Host.getArcadeManager().getPlugin(), 0L, 1L); + } + private void spawnPig() { Host.CreatureAllow = true; - _pig = (Pig) getCenter().getWorld().spawnEntity(getCenter().add(0, 1, 0), EntityType.PIG); + _pig = (Pig) getCenter().getWorld().spawn(getCenter().add(0, 1, 0), Pig.class); UtilEnt.Vegetate(_pig); Host.CreatureAllow = false; @@ -259,6 +269,16 @@ public class ChallengeVolleyPig extends Challenge } } + private void knockback(Player player) + { + ArrayList center = new ArrayList(Arrays.asList(getTeamCenter(player))); + Vector bump = UtilAlg.getAverageBump(player.getLocation(), center); + UtilAction.velocity(player, bump, 0.8, false, 0, 0.4, 10, true); + + player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 60, 1)); + UtilTextMiddle.display(null, C.cRed + "You cannot cross to the enemy side.", 5, 40, 5, player); + } + private Location getTeamCenter(Player player) { if (_blueTeam.isMember(player)) @@ -267,55 +287,50 @@ public class ChallengeVolleyPig extends Challenge return _redCenter; } + @SuppressWarnings("deprecation") private void increaseTeamScore() { if (_pig.isValid()) { Location loc = _pig.getLocation(); + Block block = loc.getBlock().getRelative(BlockFace.DOWN); - if (Math.abs(loc.getZ()) > 0.05) + if (block.getType() == Material.STAINED_CLAY) { - loc.setY(0); - Block block = loc.getBlock(); + byte data = block.getData(); - if (block.getType() != Material.AIR) + if (data == 11) // Blue { - if (loc.getZ() < 0) - { - _blueSide += 50; - } - else - { - _redSide += 50; - } + _blueSide += 50; } else { - _pig.remove(); + _redSide += 50; } } + else if (block.isEmpty()) + { + _pig.remove(); + } } } - @SuppressWarnings("deprecation") private void selectWinners() { - if (!_pig.isValid() || UtilTime.elapsed(Settings.getStartTime(), 30000) || _redSide > 10000 || _blueSide > 10000) + if (_pig.isValid()) { - Settings.setDuration(0); - - for (Player player : getChallengers()) + if (_redSide > 10000) { - Location loc = player.getLocation(); - loc.setY(0); - Block block = loc.getBlock(); - - if (block.getType() == Material.STAINED_CLAY) + for (Player bluePlayer : _blueTeam.getPlayers()) { - if (block.getData() == (_redSide > _blueSide ? 11 : 14)) - { - setCompleted(player); - } + setCompleted(bluePlayer); + } + } + else if (_blueSide > 10000) + { + for (Player redPlayer : _redTeam.getPlayers()) + { + setCompleted(redPlayer); } } }