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