Fix volley pig challenge, apply minor changes and bug fixes on Infestation, Reverse Tag.

This commit is contained in:
Thanos paravantis 2016-03-27 17:45:58 +03:00
parent 72994656dd
commit cd08e5581a
5 changed files with 208 additions and 139 deletions

View File

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

View File

@ -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,6 +778,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
public void showChallengeDescription(final Challenge challenge)
{
if (Manager.GetChat().Silenced() < 0)
Manager.GetChat().Silence(5000, false);
_settings.markMessagesAsSending(true);
@ -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();

View File

@ -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<String> _infected = new HashSet<String>();
private HashSet<Player> _infected = new HashSet<Player>();
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,7 +131,8 @@ 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;
@ -137,6 +140,7 @@ public class ChallengeInfestation extends Challenge
infect(target);
}
}
}
@EventHandler
public void onParticleUpdate(UpdateEvent event)
@ -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("Already Infected");
return;
}
infect(damager);
event.SetCancelled("Infected");
return;
}
}
@EventHandler
@ -197,12 +207,16 @@ 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
public void onEntityCombust(EntityCombustEvent event)
@ -217,24 +231,37 @@ public class ChallengeInfestation extends Challenge
}
}
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!"));
}
}

View File

@ -99,16 +99,19 @@ public class ChallengeReverseTag extends Challenge
Host.DamagePvP = true;
int i = 0;
ArrayList<Player> players = new ArrayList<Player>(Host.GetPlayers(true));
ArrayList<Player> 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,32 +218,57 @@ public class ChallengeReverseTag extends Challenge
_nonTagged.remove(player);
}
private void removeTagged(Player player)
private void clear(Player player)
{
if (_tagged.isMember(player))
{
clearEffect(player);
_tagged.remove(player);
_nonTagged.add(player);
}
}
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));
_tagged.remove(player);
_nonTagged.remove(player);
for (int i = 0; i <= 8; i++)
{
player.getInventory().clear(i);
}
}
}
private void addTagged(final Player player)
private void tag(Player player, boolean cooldown)
{
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));
tagEffect(player);
_nonTagged.remove(player);
_tagged.add(player);
_cooldowns.add(player);
if (cooldown)
{
removeCooldown(player);
}
}
}
private void tagEffect(Player 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++)
{
player.getInventory().setItem(i, ItemStackFactory.Instance.CreateStack(35, (byte) 5));
}
}
private void removeCooldown(Player player)
{
new BukkitRunnable()
{
@Override
@ -248,12 +277,6 @@ public class ChallengeReverseTag extends Challenge
_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));
}
}
}
public ChallengeTeam getTagged()

View File

@ -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<Location> center = new ArrayList<Location>(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<Location> center = new ArrayList<Location>(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,20 +287,19 @@ 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 (loc.getZ() < 0)
if (data == 11) // Blue
{
_blueSide += 50;
}
@ -289,34 +308,30 @@ public class ChallengeVolleyPig extends Challenge
_redSide += 50;
}
}
else
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);
}
}
}
}