Merge branch 'MortensRawBugFixes' into thanos-mineware

Conflicts:
	Plugins/Nautilus.Game.Arcade/.settings/org.eclipse.jdt.core.prefs
	Plugins/Nautilus.Game.Arcade/.settings/org.eclipse.jdt.ui.prefs
	Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/holeinwall/Wall.java
	Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/MineWare.java
	Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeAnvilDance.java
	Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeBlockLobbers.java
	Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeBuildRace.java
	Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeFallingBlocks.java
	Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeFastFood.java
	Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeWaveCrush.java
This commit is contained in:
Thanos paravantis 2015-11-25 23:14:22 +02:00
commit e0bb8f60d4
23 changed files with 2190 additions and 865 deletions

View File

@ -33,6 +33,7 @@ public class JumpManager extends MiniPlugin
Manager = manager;
}
@SuppressWarnings("deprecation")
@EventHandler
public void FlightHop(PlayerToggleFlightEvent event)
{

View File

@ -23,12 +23,43 @@ import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import sun.security.krb5.internal.HostAddress;
//<<<<<<< HEAD
//import nautilus.game.arcade.world.WorldData;
//import net.minecraft.server.v1_7_R4.DataWatcher;
//import net.minecraft.server.v1_7_R4.Packet;
//import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity;
//import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
//import net.minecraft.server.v1_7_R4.PacketPlayOutRelEntityMove;
//import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity;
//import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
//=======
//import net.minecraft.server.v1_8_R3.DataWatcher;
//import net.minecraft.server.v1_8_R3.Packet;
//import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity;
//import net.minecraft.server.v1_8_R3.PacketPlayOutEntity;
//import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMove;
//import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
//import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity;
//import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
//>>>>>>> 6983af944fff04c5910f789266ae46b9eca4cc8d
//
//import org.bukkit.Bukkit;
//import org.bukkit.Location;
//import org.bukkit.Material;
//<<<<<<< HEAD
//import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
//import org.bukkit.entity.Entity;
//=======
//import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
//>>>>>>> 6983af944fff04c5910f789266ae46b9eca4cc8d
//import org.bukkit.entity.EntityType;
//import org.bukkit.entity.Player;
//import org.bukkit.util.Vector;
//
//import sun.security.krb5.internal.HostAddress;
public class Wall
{

View File

@ -5,21 +5,28 @@ import java.util.HashSet;
import java.util.List;
import mineplex.core.common.util.C;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.Hologram.HologramTarget;
import mineplex.core.projectile.ProjectileUser;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import nautilus.game.arcade.game.games.mineware.events.challengeEndEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.scheduler.BukkitRunnable;
@ -29,22 +36,23 @@ public abstract class Challenge implements Listener
{
LastStanding, FirstComplete
}
public MineWare Host;
private String _challengeName;
private String[] _challengeDesc;
protected int Places;
protected long StartTime;
protected long Duration;
private Location _center;
protected HashSet<Player> Completed = new HashSet<Player>();
protected HashSet<Player> Lost = new HashSet<Player>();
protected HashSet<Player> currentPlaying;
private boolean _teamBased;
private boolean _crumble;
private ChallengeType _challengeType;
private String _challengeName;
private String[] _challengeDesc;
private Location _center;
private HashSet<Player> _invisPlayers = new HashSet<Player>();
private HashSet<Block> _modifiedBlocks = new HashSet<Block>();
protected int Places;
private ChallengeType _challengeType;
public Challenge(MineWare host, ChallengeType challengeType, String challengeName, String... challengeDes)
{
@ -53,6 +61,21 @@ public abstract class Challenge implements Listener
this._center = new Location(host.WorldData.World, 0, 0, 0);
this._challengeType = challengeType;
this._challengeName = challengeName;
this._teamBased = false;
this._crumble = false;
setBorder(-100, 100, 0, 256, -100, 100);
}
public Challenge(MineWare host, ChallengeType challengeType, String challengeName, boolean teamBased, boolean crumble, String... challengeDes)
{
this.Host = host;
this._challengeDesc = challengeDes;
this._center = new Location(host.WorldData.World, 0, 0, 0);
this._challengeType = challengeType;
this._challengeName = challengeName;
this._teamBased = teamBased;
this._crumble = crumble;
setBorder(-100, 100, 0, 256, -100, 100);
}
@ -74,7 +97,7 @@ public abstract class Challenge implements Listener
{
testing.add(strings);
}
testing.add("Have fun!");
testing.add("");
return testing.toArray(new String[testing.size()]);
}
@ -96,6 +119,7 @@ public abstract class Challenge implements Listener
public void StartOrder()
{
currentPlaying = new HashSet<Player>(getChallengers());
setupPlayers();
Completed.clear();
@ -164,7 +188,7 @@ public abstract class Challenge implements Listener
boolean maxTimeReached = UtilTime.elapsed(StartTime, Duration);
ArrayList<Player> players = getChallengers();
if (players.size() <= Completed.size())
if (players.size() <= Completed.size()) // 50% done
return true;
if (_challengeType == ChallengeType.LastStanding)
@ -192,6 +216,65 @@ public abstract class Challenge implements Listener
return maxTimeReached;
}
@Deprecated
@EventHandler
/**
* Do not use this method!
* @param event
*/
public void mapCrumble(UpdateEvent event)
{
if(event.getType() != UpdateType.FASTEST)
{
return;
}
if(!Host.IsLive())
{
return;
}
if(!_crumble)
{
return;
}
if(!Host._currentCrumble)
{
return;
}
Block qualifiedBlock = null;
double furthestDistance = 0;
if(_modifiedBlocks.isEmpty())
{
Host._currentCrumble = false;
return;
}
for(Block currentBlock: _modifiedBlocks)
{
double theBlocksdistance = UtilMath.offset2d(Host.GetSpectatorLocation(), currentBlock.getLocation().add(0.5, 0.5, 0.5));
if(qualifiedBlock == null || furthestDistance < theBlocksdistance)
{
qualifiedBlock = currentBlock;
furthestDistance = theBlocksdistance;
}
}
//if blocks are layered:
while(qualifiedBlock.getRelative(BlockFace.DOWN).getType() != Material.AIR)
{
qualifiedBlock = qualifiedBlock.getRelative(BlockFace.DOWN);
}
_modifiedBlocks.remove(qualifiedBlock);
if(UtilMath.r(4) == 0)
{
qualifiedBlock.getWorld().spawnFallingBlock(qualifiedBlock.getLocation().add(0.5, 0.5, 0.5), qualifiedBlock.getType(), qualifiedBlock.getData());
}
MapUtil.QuickChangeBlockAt(qualifiedBlock.getLocation(), Material.AIR);
}
/**This method is only called <br>
* if the challenge ends due to <br>
* exceeding the max time for the challenge <br>
*/
public void onChallengeTimeEnd() // Override-able
{
@ -216,7 +299,6 @@ public abstract class Challenge implements Listener
Completed.add(player);
UtilPlayer.message(player, C.cGreen + C.Bold + "You completed the task!");
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1f);
UtilInv.Clear(player);
}
public void SetCompleted(Player player)
@ -235,12 +317,16 @@ public abstract class Challenge implements Listener
{
return;
}
if(Host._currentCrumble == false)
{
Lost.add(player);
}
if(invis)
{
_invisPlayers.add(player);
Host.Manager.GetCondition().Factory().Cloak("Completed", player, player, 7777, true, false);
_invisPlayers.add(player);
Host.Manager.GetCondition().Factory().Cloak("Completed", player, player, 7777, true, false);
}
Lost.add(player);
Host.LoseLife(player, false);
UtilInv.Clear(player);
}
@ -257,6 +343,27 @@ public abstract class Challenge implements Listener
{
return Host.getChallengers();
}
public ArrayList<Player> getCurrentyAlive(boolean ignoreAlreadyWon)
{
ArrayList<Player> currentlyAlive = new ArrayList<Player>();
for(Player player: currentPlaying)
{
if(isLost(player))
{
continue;
}
if(ignoreAlreadyWon)
{
if(IsCompleted(player))
{
continue;
}
}
currentlyAlive.add(player);
}
return currentlyAlive;
}
public boolean IsCompleted(Player player)
{
@ -275,6 +382,15 @@ public abstract class Challenge implements Listener
}
}
public boolean isLost(Player player)
{
if(Lost.contains(player))
{
return true;
}
return false;
}
public String getChallengeName()
{
return _challengeName;
@ -332,11 +448,30 @@ public abstract class Challenge implements Listener
int size = (int) (minBlocks + Math.ceil(Host.GetPlayers(true).size()/2));
return size > 40 ? 40 : size;
}
public boolean getTeamBased()
{
return _teamBased;
}
public boolean getCrumble()
{
return _crumble;
}
public Location getCenter()
{
return _center.clone();
}
/**
* Only set this to true if you put <br>
* The "Crumble" in the challenge constructor to <b>True!<b>
* @param condition
*/
public void setMapCrumble(boolean condition)
{
Host._currentCrumble = condition;
}
public boolean hasWinner()
{

View File

@ -1,14 +1,19 @@
package nautilus.game.arcade.game.games.mineware;
import java.lang.reflect.InvocationTargetException;
import java.sql.Time;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
@ -17,11 +22,13 @@ import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTextTop;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeFormat;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
@ -29,11 +36,36 @@ 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.ChallengeBuildRace;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeArrowRampage;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeBlockLobbers;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeBlockRunner;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeBouncingBlock;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeChestLoot;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeCloudFall;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeDogvsCat;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeDragonEgg;
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.ChallengeFishingDay;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeTreasureDigger;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeInfestation;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeKOTL;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeKangarooJump;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeLavaRun;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeMilkACow;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeMineADiamond;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeMinecartDance;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeMiniOITQ;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeNavigateMaze;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengePickASide;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengePunchThePig;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeRedLightGreenLight;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeReverseTag;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeRushPush;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeShootChickens;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeSmashOff;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeStandOnColor;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeTntLauncher;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeVolleyPig;
import nautilus.game.arcade.game.games.mineware.challenges.ChallengeWaveCrush;
import nautilus.game.arcade.game.games.mineware.events.challengeEndEvent;
import nautilus.game.arcade.kit.Kit;
@ -41,6 +73,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Banner;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -48,13 +81,18 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import com.sun.xml.internal.ws.resources.UtilMessages;
public class MineWare extends SoloGame implements IThrown
{
private HashMap<Player, Integer> _lives = new HashMap<Player, Integer>();
@ -62,6 +100,7 @@ public class MineWare extends SoloGame implements IThrown
private Challenge _challenge;
private ArrayList<Block> _lastOrderBlocks;
private long _challengeTime;
public boolean _currentCrumble = false;
private boolean _waitingChallenge = true;
private boolean _allMessageSent = false;
private boolean _sendingMessages = false;
@ -92,7 +131,6 @@ public class MineWare extends SoloGame implements IThrown
AutomaticRespawn = false;
DeathMessages = false;
GiveClock = false;
// Welcome Thanos
Manager.GetCreature().SetDisableCustomDrops(true);
@ -146,18 +184,13 @@ public class MineWare extends SoloGame implements IThrown
public void PopulateOrders()
{
_challenges.add(ChallengeFishingDay.class);
// _challenges.add(ChallengeTreasureDigger.class);
// _challenges.add(ChallengeFastFood.class);
// _challenges.add(ChallengeBuildRace.class);
// _challenges.add(ChallengeAnvilDance.class);
// _challenges.add(ChallengeFallingBlocks.class);
// _challenges.add(ChallengeWaveCrush.class);
// _challenges.add(ChallengePickASide.class);
// _challenges.add(ChallengePickASide.class);//
// _challenges.add(ChallengeKOTL.class);
// _challenges.add(ChallengePunchThePig.class);
// _challenges.add(ChallengeDogvsCat.class); // TODO
// _challenges.add(ChallengeDogvsCat.class);
// _challenges.add(ChallengeShootChickens.class);
// _challenges.add(ChallengeReverseTag.class);
// _challenges.add(ChallengeKangarooJump.class);
@ -178,9 +211,14 @@ public class MineWare extends SoloGame implements IThrown
// _challenges.add(ChallengeCloudFall.class);
// _challenges.add(ChallengeInfestation.class);
// _challenges.add(ChallengeBouncingBlock.class);
// _challenges.add(ChallengeEvolutionOfCombat.class);
// _challenges.add(ChallengeBlockRunner.class);
// _challenges.add(ChallengeFastFood.class);
// _challenges.add(ChallengeMinecartDance.class);
_challenges.add(ChallengeRedLightGreenLight.class);
// ============== trashed ==============
//_challenges.add(ChallengeSimonSays.class);
// _challenges.add(ChallengeSimonSays.class);
// _challenges.add(ChallengeHitTargets.class);
// _challenges.add(ChallengeTameTheWolf.class);
// _challenges.add(ChallengeBlockShot.class);
@ -207,6 +245,16 @@ public class MineWare extends SoloGame implements IThrown
if(getChallengers().size() >= challenge.getMaxPlayers())
{
System.out.print("Cannot use challenge " + challenge.getClass().getSimpleName() + ", too many players");
continue;
}
if(challenge.getTeamBased() == true)
{
if(!(getChallengers().size() % 2 == 0))
{
System.out.print("Cannot use Challege: " + challenge.getClass().getSimpleName()
+ ". The game is a teamgame with unequal amount of living players");
continue;
}
}
System.out.print("Using challenge " + challenge.getClass().getSimpleName());
return challenge;
@ -214,7 +262,6 @@ public class MineWare extends SoloGame implements IThrown
else
{
System.out.print("Cannot use challenge " + challenge.getClass().getSimpleName() + ", not enough players");
}
}
catch(InvocationTargetException ex)
@ -234,38 +281,56 @@ public class MineWare extends SoloGame implements IThrown
{
_sendingMessages = true;
_allMessageSent = false;
int looped = 0;
new BukkitRunnable()
List<String> messages = Arrays.asList(challenge.getGameMessages());
for(Player player : UtilServer.getPlayers())
{
int looped = 0;
List<String> messages = Arrays.asList(challenge.getGameMessages());
player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 2f, 1f);
UtilPlayer.message(player, F.count(ArcadeFormat.Line));
@Override
public void run()
for(String currentMessage : messages)
{
if(!IsLive())
if(messages.get(messages.size()-1) != currentMessage)
{
this.cancel();
return;
UtilPlayer.message(player, C.cGreen + "ChallengeRule - " + C.cYellow + C.Bold + currentMessage);
}
for(Player player : UtilServer.getPlayers())
{
String message = C.cYellow + C.Bold + messages.get(looped);
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 1f);
UtilPlayer.message(player, message);
UtilTextMiddle.display(challenge.getChallengeName(), message);
}
if(looped == messages.size() - 1)
{
gamePrepareMessages();
this.cancel();
}
looped++;
}
}.runTaskTimer(Manager.getPlugin(), 0, 20 * 2);
UtilPlayer.message(player, F.count(ArcadeFormat.Line));
}
while(true)
{
if(!IsLive())
{
break;
}
for(Player player : UtilServer.getPlayers())
{
String message = C.cYellow + C.Bold + messages.get(looped);
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 1f);
UtilTextMiddle.display(challenge.getChallengeName(), message, 0, 60, 20);
}
if(looped == messages.size() - 1)
{
gamePrepareMessages();
break;
}
try
{
Thread.sleep(1000 + (55 * messages.get(looped).length()));
}
catch(InterruptedException e)
{
e.printStackTrace();
}
looped++;
}
}
public void gamePrepareMessages()
@ -287,7 +352,7 @@ public class MineWare extends SoloGame implements IThrown
UtilTextMiddle.display(message, null);
}
if(looped == messages.size() - 1) // TODO
if(looped == messages.size() - 1)
{
_allMessageSent = true;
_sendingMessages = false;
@ -295,7 +360,7 @@ public class MineWare extends SoloGame implements IThrown
}
looped++;
}
}.runTaskTimer(Manager.getPlugin(), 0, 20);
}.runTaskTimer(Manager.getPlugin(), 0, 15);
}
@EventHandler(priority = EventPriority.HIGH)
@ -382,6 +447,31 @@ public class MineWare extends SoloGame implements IThrown
event.setCancelled(true);
}
@EventHandler
public void onMortenSkip(AsyncPlayerChatEvent event) // Remember to remove on release
{
if(!IsLive())
{
return;
}
if(!event.getMessage().equalsIgnoreCase("skip current challenge"))
{
return;
}
if(!getArcadeManager().GetClients().Get(event.getPlayer()).GetRank().has(Rank.JNR_DEV))
{
event.getPlayer().sendMessage(F.main("Skip Challenge", "Only Morten can skip challenges you nub <3"));
return;
}
endCurrentChallenge();
if(_currentCrumble)
{
_currentCrumble = false;
}
Bukkit.broadcastMessage(F.main("Skip Challenge", event.getPlayer().getName() + " has decided to skip the current challenge!"));
}
@EventHandler
public void PlayerMoveCancel(PlayerMoveEvent event)
{
@ -447,7 +537,10 @@ public class MineWare extends SoloGame implements IThrown
block.setTypeIdAndData(Material.AIR.getId(), (byte) 0, false);
}
if(_currentCrumble == true)
{
_currentCrumble = false;
}
_challenge.generateRoom();
ArrayList<Location> spawns = _challenge.getSpawns();
@ -516,18 +609,41 @@ public class MineWare extends SoloGame implements IThrown
* "§lMineWare " + C.cGreen + "§l" + "Round " + _orderCount);
*/
}
else if(_waitingChallenge) //TODO
else if(_waitingChallenge)
{
if(!UtilTime.elapsed(_challengeTime, 1000))
return;
if(_sendingMessages == false && _allMessageSent == false)
{
sayChallenge(_challenge);
for(Player player : GetPlayers(true))
{
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Integer.MAX_VALUE, 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 1));
}
Thread newThread = new Thread(new Runnable() // TODO
{
@Override
public void run()
{
sayChallenge(_challenge);
}
});
newThread.start();
return;
}
if(_allMessageSent == true)
{
for(Player player : GetPlayers(true))
{
if(player.hasPotionEffect(PotionEffectType.BLINDNESS))
{
player.removePotionEffect(PotionEffectType.BLINDNESS);
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
}
}
_waitingChallenge = false;
_isChallengeStarted = true;
@ -538,47 +654,38 @@ public class MineWare extends SoloGame implements IThrown
_allMessageSent = false;
}
}
// Update Order
// Update Order TODO
else
{
if(_challenge.Finish())
{
_challengeTime = System.currentTimeMillis();
for(Player player : getChallengers())
if(_challenge.getCrumble() && !_challenge.getModifiedBlocks().isEmpty())
{
getArcadeManager().GetDisguise().undisguise(player);
UtilInv.Clear(player);
if(_challenge.hasWinner() && !_challenge.IsCompleted(player))
if(_currentCrumble == false && _challenge.Lost.size() >= _challenge.currentPlaying.size() / 2)
{
LoseLife(player, true);
_currentCrumble = true;
for(Player player : UtilServer.getPlayers())
{
UtilPlayer.message(player, F.main("Map Crumble", "The challenge has ended! The map will crumble away!"));
if(IsAlive(player))
{
UtilPlayer.message(player, F.main("Map Crumble", "The challenge will end when there's 1 player left."));
}
}
}
else
{
if((_challenge.currentPlaying.size() - _challenge.Lost.size()) <= 1 && _currentCrumble)
{
endCurrentChallenge();
_currentCrumble = false;
}
}
}
// Deregister
Bukkit.getServer().getPluginManager().callEvent(new challengeEndEvent(_challenge));
HandlerList.unregisterAll(_challenge);
_challenge.EndOrder();
_isChallengeStarted = false;
_lastOrderBlocks = new ArrayList<Block>(_challenge.getModifiedBlocks());
// Remove blocks from top to bottom, prevents blocks popping
// off.
Collections.sort(_lastOrderBlocks, new Comparator<Block>()
else
{
@Override
public int compare(Block o1, Block o2)
{
return new Integer(o2.getY()).compareTo(o1.getY());
}
});
_challenge = null;
EndCheck();
endCurrentChallenge();
}
}
else
{
@ -593,7 +700,7 @@ public class MineWare extends SoloGame implements IThrown
}
else
{
UtilTextTop.display(C.cYellow + C.Bold + _challenge.getChallengeName(), player);
UtilTextTop.displayTextBar(player, _challenge.GetTimeLeftPercent(), C.cYellow + C.Bold + _challenge.getChallengeName());
player.setLevel(_challenge.GetRemainingPlaces());
player.setExp(_challenge.GetTimeLeftPercent());
}
@ -636,6 +743,7 @@ public class MineWare extends SoloGame implements IThrown
UtilPlayer.message(player, C.cRed + C.Bold + "You failed the task!");
UtilPlayer.message(player, C.cRed + C.Bold + "You have " + lives + " lives left!");
player.playSound(player.getLocation(), Sound.NOTE_BASS_GUITAR, 2f, 0.5f);
}
else
{
@ -653,6 +761,122 @@ public class MineWare extends SoloGame implements IThrown
}
}
public void endCurrentChallenge() // TODO
{
_challengeTime = System.currentTimeMillis();
for(Player player : getChallengers())
{
getArcadeManager().GetDisguise().undisguise(player);
UtilInv.Clear(player);
if(_challenge.hasWinner() && !_challenge.IsCompleted(player))
{
LoseLife(player, true);
}
}
// Deregister
Bukkit.getServer().getPluginManager().callEvent(new challengeEndEvent(_challenge));
HandlerList.unregisterAll(_challenge);
_challenge.EndOrder();
_isChallengeStarted = false;
_lastOrderBlocks = new ArrayList<Block>(_challenge.getModifiedBlocks());
// Remove blocks from top to bottom, prevents blocks popping
// off.
Collections.sort(_lastOrderBlocks, new Comparator<Block>()
{
@Override
public int compare(Block o1, Block o2)
{
return new Integer(o2.getY()).compareTo(o1.getY());
}
});
_challenge = null;
EndCheck();
}
@Override
@EventHandler
public void ScoreboardUpdate(UpdateEvent event)
{
if(event.getType() != UpdateType.FAST)
{
return;
}
Scoreboard.Reset();
if(GetPlayers(false).size() > 14)
{
int alive = 0;
for(Player cAlive: _lives.keySet())
{
if(GetLives(cAlive) != 0)
{
alive++;
}
}
Scoreboard.WriteBlank();
Scoreboard.Write(C.cGreen + "Players Alive");
Scoreboard.Write(alive + " ");
Scoreboard.WriteBlank();
Scoreboard.Write(C.cRed + "Players out: ");
Scoreboard.Write((GetPlayers(false).size() - alive) + " ");
}
else
{
Scoreboard.WriteBlank();
for(Player player: GetPlayers(false))
{
int currentLives = GetLives(player);
String status;
String currentlyOut = "";
if(_challenge != null)
{
if(_challenge.isLost(player))
{
currentlyOut = C.cRed + "X ";
}
else if(_challenge.IsCompleted(player))
{
currentlyOut = C.cGreen + "";
}
}
switch(currentLives)
{
case 5:
status = currentlyOut + C.cGreen + player.getName();
break;
case 4:
status = currentlyOut + C.cYellow + player.getName();
break;
case 3:
status = currentlyOut + C.cGold + player.getName();
break;
case 2:
status = currentlyOut + C.cRed + player.getName();
break;
case 1:
status = currentlyOut + C.cRed + player.getName();
break;
default:
status = C.cGray + C.Strike + player.getName();
break;
}
Scoreboard.WriteOrdered("Lives Left", status, currentLives, true);
}
}
Scoreboard.Draw();
}
@Override
public int GetScoreboardScore(Player player)
{
@ -686,4 +910,4 @@ public class MineWare extends SoloGame implements IThrown
{
}
}
}

View File

@ -16,6 +16,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.MineWare;
import nautilus.game.arcade.game.games.mineware.events.challengeEndEvent;
import org.bukkit.Location;
import org.bukkit.Material;
@ -23,6 +24,9 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.FallingSand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityShootBowEvent;
@ -39,7 +43,7 @@ public class ChallengeArrowRampage extends Challenge
public ChallengeArrowRampage(MineWare host)
{
super(host, ChallengeType.LastStanding, "Arrow Rampage", "Equipped with explosive arrows", "Force your enemy into the void");
super(host, ChallengeType.LastStanding, "Arrow Rampage", false, true, "Equipped with explosive arrows", "Force your enemy into the void");
}
@Override
@ -47,9 +51,9 @@ public class ChallengeArrowRampage extends Challenge
{
ArrayList<Location> spawns = new ArrayList<Location>();
for(int x = -(getArenaSize(12) - 1); x < getArenaSize(12) - 1; x++)
for(int x = -(getArenaSize(9) - 1); x < getArenaSize(9) - 1; x++)
{
for(int z = -(getArenaSize(12) - 1); z < getArenaSize(12) - 1; z++)
for(int z = -(getArenaSize(9) - 1); z < getArenaSize(9) - 1; z++)
{
if(x % 2 == 0 && z % 2 == 0)
{
@ -87,9 +91,9 @@ public class ChallengeArrowRampage extends Challenge
@Override
public void generateRoom()
{
for(int x = -getArenaSize(12); x <= getArenaSize(12); x++)
for(int x = -getArenaSize(9); x <= getArenaSize(9); x++)
{
for(int z = -getArenaSize(12); z <= getArenaSize(12); z++)
for(int z = -getArenaSize(9); z <= getArenaSize(9); z++)
{
for(int y = 0; y <= 3; y++)
{
@ -117,7 +121,7 @@ public class ChallengeArrowRampage extends Challenge
b.setType(Material.WOOL);
b.setData((byte) UtilMath.r(16));
}
else if(b.getType() != Material.AIR)
if(b.getType() != Material.AIR)
{
addBlock(b);
}
@ -125,6 +129,18 @@ public class ChallengeArrowRampage extends Challenge
}
}
}
@EventHandler
public void onChallengeEnd(challengeEndEvent event)
{
for(Entity fBlocks: Host.WorldData.World.getEntities())
{
if(fBlocks instanceof FallingBlock || fBlocks instanceof FallingSand)
{
fBlocks.remove();
}
}
}
@EventHandler
public void arrowEffect(UpdateEvent event)

View File

@ -149,7 +149,7 @@ public class ChallengeBlockLobbers extends Challenge
UtilInv.remove(event.getPlayer(), event.getPlayer().getItemInHand().getType(), (byte) 0, 1);
UtilAction.velocity(fBlock, event.getPlayer().getLocation().getDirection(), 1.5, false, 0.0, 0.3, 10.0, true);
Host.Manager.GetProjectile().AddThrow(fBlock, event.getPlayer(), Host, -1, true, false, true, false, 0.2f);
Host.Manager.GetProjectile().AddThrow(fBlock, event.getPlayer(), Host, -1, true, false, true, true, 0.2f);
}
@EventHandler

View File

@ -0,0 +1,221 @@
package nautilus.game.arcade.game.games.mineware.challenges;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
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.UtilShapes;
import mineplex.core.common.util.UtilTextMiddle;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.MineWare;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
public class ChallengeBlockRunner extends Challenge
{
// The amount of blocks for every hotbar slot.
private static final int InventoryBlockAmount = 5;
private static Material[] _materials =
{ Material.DIRT, Material.STONE, Material.COBBLESTONE, Material.LOG, Material.WOOD, Material.WOOL, Material.BRICK, Material.SMOOTH_BRICK,
Material.GLASS };
public ChallengeBlockRunner(MineWare host)
{
super(host, ChallengeType.FirstComplete, "Block Runner", "Your inventory is filled with blocks.",
"Be the first to place them all in the ground!");
}
@Override
public ArrayList<Location> getSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
Location center = new Location(Host.WorldData.World, 0, 0, 0);
for(Location location : UtilShapes.getCircle(center, true, getArenaSize() - 3))
{
double x = location.getX() + 0.5;
double y = 1.1;
double z = location.getZ() + 0.5;
spawns.add(getCenter().add(x, y, z));
}
return spawns;
}
@Override
public void generateRoom()
{
Location center = new Location(Host.WorldData.World, 0, 0, 0);
for(Location location : UtilShapes.getCircle(center, false, getArenaSize()))
{
Block block = location.getBlock();
block.setType(Material.GRASS);
addBlock(location.getBlock());
}
}
@SuppressWarnings("deprecation")
@Override
public void setupPlayers()
{
for(Material allowed : _materials)
{
Host.BlockPlaceAllow.add(allowed.getId());
}
for(Player player : Host.GetPlayers(true))
{
setupInventoryContents(player);
}
}
private void setupInventoryContents(Player player)
{
ArrayList<Material> shuffledMaterials = new ArrayList<Material>(Arrays.asList(_materials));
Collections.shuffle(shuffledMaterials);
for(Material material : shuffledMaterials)
{
ItemStack itemStack = new ItemStack(material, InventoryBlockAmount);
player.getInventory().addItem(itemStack);
}
}
@SuppressWarnings("deprecation")
@Override
public void cleanupRoom()
{
for(Material allowed : _materials)
{
Host.BlockPlaceAllow.remove(allowed.getId());
}
}
@SuppressWarnings("deprecation")
@EventHandler
public void onBlockPlace(BlockPlaceEvent event)
{
if(!Host.IsLive() || !Host.isChallengeStarted())
return;
Player player = event.getPlayer();
if(IsCompleted(player))
{
event.setCancelled(true);
return;
}
Block block = event.getBlock();
addBlock(block);
// First Check
// Checking if the player is trying to get off the map.
Block bottomVoid1 = block.getRelative(BlockFace.DOWN);
Block bottomVoid2 = bottomVoid1.getRelative(BlockFace.DOWN);
Block bottomVoid3 = bottomVoid2.getRelative(BlockFace.DOWN);
if(bottomVoid1.isEmpty() && bottomVoid2.isEmpty() && bottomVoid3.isEmpty())
{
UtilTextMiddle.display("", C.cRed + "You can't place blocks that far from the ground.", 5, 40, 5, player);
blockBreakEffect(block);
event.setCancelled(true);
return;
}
// Second Check
// Checking if the player is trying to trap another player.
for(Player others : Host.GetPlayers(true))
{
if(others.equals(player))
continue;
if(block.getLocation().add(0.5, 0.5, 0.5).distanceSquared(others.getLocation()) <= 1.5)
{
UtilTextMiddle.display("", C.cRed + "You can't place blocks near other players.", 5, 40, 5, player);
blockBreakEffect(block);
event.setCancelled(true);
return;
}
}
// 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())
{
// 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);
return;
}
// Last Check
// Checking if the player has successfully placed all blocks.
ArrayList<ItemStack> items = UtilInv.getItems(player);
if((items.size() - 1) == 0)
{
if(items.get(0).getAmount() == 1)
{
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());
block.setType(Material.AIR);
}
}

View File

@ -47,11 +47,15 @@ public class ChallengeChestLoot extends Challenge
@Override
public void cleanupRoom()
{
Host.InventoryOpenChest = false;
Host.InventoryOpenBlock = false;
}
@Override
public void setupPlayers()
{
Host.InventoryOpenChest = true;
Host.InventoryOpenBlock = true;
}
@EventHandler

View File

@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.mineware.challenges;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -22,8 +23,7 @@ public class ChallengeCloudFall extends Challenge
public ChallengeCloudFall(MineWare host)
{
super(host, ChallengeType.FirstComplete, "Cloud Fall", "Jump down", "Land on the lime wool", "First to the buttom wins!");
// TODO Auto-generated constructor stub
super(host, ChallengeType.FirstComplete, "Cloud Fall", "First to the buttom wins!", "Avoid the clouds!", "Land on the lime wool");
}
@Override
@ -86,7 +86,7 @@ public class ChallengeCloudFall extends Challenge
if(y == 0)
{
b.setType(Material.GRASS);
b.setType(Material.WOOL);
}
if(y == 1 && Math.abs(x) < getArenaSize()-2 && Math.abs(z) < getArenaSize()-2)
{
@ -94,11 +94,15 @@ public class ChallengeCloudFall extends Challenge
{
b.setType(Material.WOOL);
b.setData((byte) 5);
b.getRelative(BlockFace.UP).setType(Material.WOOL);
b.getRelative(BlockFace.UP).setData((byte)5);
addBlock(b.getRelative(BlockFace.UP));
}
}
if(y > 10 && y < 70)
{
if(UtilMath.r(150) == 1)
if(UtilMath.r(200) == 1)
{
// RIP DRY rule ;-;. plz don't hurt me :(
b.getRelative(BlockFace.NORTH).setType(Material.STAINED_CLAY);
@ -153,15 +157,16 @@ public class ChallengeCloudFall extends Challenge
{
return;
}
if(Math.round(event.GetDamageePlayer().getLocation().getY()) == 2)
Bukkit.broadcastMessage("Player " + event.GetDamageePlayer().getName() + " feel and had a Y on " + event.GetDamageePlayer().getLocation().getY());
Bukkit.broadcastMessage("and when that's rounded it ends at: " + Math.round(event.GetDamageePlayer().getLocation().getY()));
if(Math.round(event.GetDamageePlayer().getLocation().getY()) == 3)
{
event.SetCancelled("fell on wool");
SetCompleted(event.GetDamageePlayer());
}
else
{
event.AddMod("Ensure Death", "Missed jump", 9999, false);
}
// else
// {
// event.AddMod("Increased Damage", "Missed jump", 2, false);
// }
}
}

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
@ -11,6 +12,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.disguise.disguises.DisguiseCat;
import mineplex.core.disguise.disguises.DisguiseWolf;
import mineplex.core.itemstack.ItemStackFactory;
@ -36,13 +38,13 @@ public class ChallengeDogvsCat extends Challenge
private int _catScore = 0;
private int _dogScore = 0;
private static final int _scorePerPlayer = 50;
private static final int _scorePerPlayer = 100;
private HashMap<String, String> _team = new HashMap<String, String>(); // <Player, team>
public ChallengeDogvsCat(MineWare host)
{
super(host, ChallengeType.FirstComplete, "Dogs VS Cats", "Look up and Bark/Meow!", "Keep an eye on your Action bar!");
super(host, ChallengeType.FirstComplete, "Dogs VS Cats", "Look up and Bark/Meow!", "First team to the end number wins!");
}
@Override
@ -184,8 +186,9 @@ public class ChallengeDogvsCat extends Challenge
int catScore = calculateScore("cat");
int dogScore = calculateScore("dog");
UtilTextBottom.display(C.cBlue + C.Bold + "Dog's Score: " + C.cGreen + _dogScore + "/" + dogScore + " " + C.cRed + C.Bold
+ "Cat's score: " + C.cGreen + _catScore + "/" + catScore, UtilServer.getPlayers());
UtilTextMiddle.display(C.cBlue + C.Bold + "Dog's: " + C.cGreen + _dogScore + "/" + dogScore + " - " + C.cRed + C.Bold
+ "Cat's: " + C.cGreen + _catScore + "/" + catScore, "");
if(_catScore >= catScore)
{

View File

@ -31,7 +31,10 @@ import org.bukkit.potion.PotionEffectType;
public class ChallengeInfestation extends Challenge
{
private float _zombieSpeed = 1.0f;
private boolean _zombieFrozen = false;
private float _zombieSpeed = 1.5f;
private long _gameStart;
private long _zombieFreezeEnd;
private Zombie _infectedZombie;
private HashSet<String> _infectedPlayers = new HashSet<String>();
@ -72,6 +75,7 @@ public class ChallengeInfestation extends Challenge
@Override
public void setupPlayers()
{
_gameStart = System.currentTimeMillis();
for(Player player : Host.GetPlayers(true))
{
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1));
@ -135,7 +139,6 @@ public class ChallengeInfestation extends Challenge
{
playerInfect(event.GetDamageePlayer());
event.SetCancelled("Infected");
Bukkit.broadcastMessage("Here 6");
return;
}
}
@ -151,6 +154,18 @@ public class ChallengeInfestation extends Challenge
{
return;
}
if(_zombieFrozen)
{
if(System.currentTimeMillis() > _zombieFreezeEnd)
{
_zombieFrozen = false;
}
return;
}
if(UtilMath.r(15) == 0)
{
freezeZombie((UtilMath.r(3)+3)*1000);
}
if(_infectedZombie.getLocation().getY() < -1)
{
_infectedZombie.teleport(new Location(Host.WorldData.World, 0, 1, 0));
@ -169,10 +184,41 @@ public class ChallengeInfestation extends Challenge
{
if(!_infectedPlayers.contains(closestPlayer.getName()))
{
if(_gameStart+5000 > System.currentTimeMillis())
{
return;
}
playerInfect(closestPlayer);
}
}
}
@EventHandler
public void winCheck(UpdateEvent event)
{
if(!Host.IsLive())
{
return;
}
if(event.getType() != UpdateType.FASTER)
{
return;
}
if(_infectedPlayers.size() >= Math.floor(Host.GetPlayers(true).size()/2))
{
for(Player player: Host.GetPlayers(true))
{
if(_infectedPlayers.contains(player.getName()))
{
setLost(player);
}
else
{
SetCompleted(player);
}
}
}
}
@EventHandler
public void blockMobFire(EntityCombustEvent event)
@ -187,6 +233,12 @@ public class ChallengeInfestation extends Challenge
event.setCancelled(true);
}
}
private void freezeZombie(int millisec)
{
_zombieFreezeEnd = System.currentTimeMillis() + millisec;
_zombieFrozen = true;
}
public void playerInfect(Player player)
{
@ -200,8 +252,7 @@ public class ChallengeInfestation extends Challenge
Host.WorldData.World.strikeLightningEffect(player.getLocation());
Host.getArcadeManager().GetDisguise().disguise(new DisguiseZombie(player));
setLost(player);
player.sendMessage(F.main("Infection", "You have been infected! Infected the rest!"));
player.sendMessage(F.main("Infection", "You have been infected! It's over so infect the rest!"));
}
}

View File

@ -27,195 +27,196 @@ import org.bukkit.scheduler.BukkitRunnable;
public class ChallengeKOTL extends Challenge
{
private Location _winCornerA = new Location(Host.WorldData.World, -2, 20, -2);
private Location _winCornerB = new Location(Host.WorldData.World, 2, 23, 2);
private Location _winCornerA = new Location(Host.WorldData.World, -2, 20, -2);
private Location _winCornerB = new Location(Host.WorldData.World, 2, 23, 2);
public ChallengeKOTL(MineWare host)
{
super(host, ChallengeType.FirstComplete, "King of the ladder", "Reach the top of the ladder");
}
@Override
public ArrayList<Location> getSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
for(int x = -(getArenaSize() - 1); x <= getArenaSize()-1; x++)
public ChallengeKOTL(MineWare host)
{
for(int z = -(getArenaSize() - 1); z <= getArenaSize()-1; z++)
{
if(x % 2 == 0 && z % 2 == 0)
super(host, ChallengeType.FirstComplete, "King of the ladder", "Reach the top of the ladder");
}
@Override
public ArrayList<Location> getSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
for(int x = -(getArenaSize() - 1); x <= getArenaSize() - 1; x++)
{
spawns.add(getCenter().clone().add(x + 0.5, 1.1, z + 0.5));
}
}
}
return spawns;
}
@Override
public int getMaxPlayers()
{
return 50;
};
@Override
public void cleanupRoom()
{
Host.DamagePvP = false;
for(int h = 0; h < 30; h++)
{
getCenter().getBlock().getRelative(0, h, 0).setType(Material.AIR);
}
new BukkitRunnable()
{
@Override
public void run()
{
List<Entity> drops = Host.WorldData.World.getEntities();
for(Entity ent: drops)
{
if(ent instanceof Item)
{
ent.remove();
}
}
}
}.runTaskLater(Host.getArcadeManager().getPlugin(), 20);
List<Entity> drops = Host.WorldData.World.getEntities();
for(Entity ent: drops)
{
if(ent instanceof Item)
{
ent.remove();
}
}
}
@Override
public void setupPlayers()
{
for(Player player : getChallengers())
{
player.getInventory().setItem(0,
new ItemBuilder(Material.STICK).addEnchantment(Enchantment.KNOCKBACK, 2).addLore(C.cPurple + "One strong stick!").build());
}
Host.DamagePvP = true;
}
@SuppressWarnings("deprecation")
@Override
public void generateRoom()
{
for(int x = -getArenaSize(); x <= getArenaSize(); x++)
{
for(int z = -getArenaSize(); z <= getArenaSize(); z++)
{
for(int y = 0; y <= 1; y++)
{
Block b = getCenter().getBlock().getRelative(x, y, z);
if(y == 0)
{
b.setType(Material.GRASS);
}
if(x == 0 && z == 0 && y == 0)
{
for(int h = 1; h <= 20; h++)
for(int z = -(getArenaSize() - 1); z <= getArenaSize() - 1; z++)
{
Block ladder = getCenter().getBlock().getRelative(x, h, z);
ladder.setType(Material.STONE);
ladder.getRelative(BlockFace.NORTH).setTypeIdAndData(65, (byte)2, false);
ladder.getRelative(BlockFace.SOUTH).setTypeIdAndData(65, (byte)3, false);
ladder.getRelative(BlockFace.WEST).setTypeIdAndData(65, (byte)4, false);
ladder.getRelative(BlockFace.EAST).setTypeIdAndData(65, (byte)5, false);
if(x % 2 == 0 && z % 2 == 0)
{
spawns.add(getCenter().clone().add(x + 0.5, 1.1, z + 0.5));
}
}
}
else
{
if(Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize())
{
b.setType(Material.FENCE);
}
}
if(b.getType() != Material.AIR)
{
addBlock(b);
}
}
}
}
}
@EventHandler
public void checkWinners(UpdateEvent event)
{
if(event.getType() != UpdateType.TICK)
{
return;
return spawns;
}
if(!Host.IsLive())
@Override
public int getMaxPlayers()
{
return;
return 10;
}
for(Player player : Host.GetPlayers(true))
@Override
public void cleanupRoom()
{
if(IsCompleted(player))
{
continue;
}
if(UtilAlg.inBoundingBox(player.getLocation(), _winCornerA, _winCornerB))
{
SetCompleted(player);
}
}
}
Host.DamagePvP = false;
@EventHandler
public void onPvp(CustomDamageEvent event)
{
if(!Host.IsLive())
{
return;
for(int h = 0; h < 30; h++)
{
getCenter().getBlock().getRelative(0, h, 0).setType(Material.AIR);
}
new BukkitRunnable()
{
@Override
public void run()
{
List<Entity> drops = Host.WorldData.World.getEntities();
for(Entity ent : drops)
{
if(ent instanceof Item)
{
ent.remove();
}
}
}
}.runTaskLater(Host.getArcadeManager().getPlugin(), 20);
List<Entity> drops = Host.WorldData.World.getEntities();
for(Entity ent : drops)
{
if(ent instanceof Item)
{
ent.remove();
}
}
}
if(event.GetDamageePlayer() == null)
@Override
public void setupPlayers()
{
return;
for(Player player : getChallengers())
{
player.getInventory().setItem(0,
new ItemBuilder(Material.STICK).addEnchantment(Enchantment.KNOCKBACK, 5).addLore(C.cPurple + "One strong stick!").build());
}
Host.DamagePvP = true;
}
if(IsCompleted(event.GetDamagerPlayer(false)))
@SuppressWarnings("deprecation")
@Override
public void generateRoom()
{
event.SetCancelled("Player already completed");
return;
for(int x = -getArenaSize(); x <= getArenaSize(); x++)
{
for(int z = -getArenaSize(); z <= getArenaSize(); z++)
{
for(int y = 0; y <= 1; y++)
{
Block b = getCenter().getBlock().getRelative(x, y, z);
if(y == 0)
{
b.setType(Material.GRASS);
}
if(x == 0 && z == 0 && y == 0)
{
for(int h = 1; h <= 20; h++)
{
Block ladder = getCenter().getBlock().getRelative(x, h, z);
ladder.setType(Material.STONE);
ladder.getRelative(BlockFace.NORTH).setTypeIdAndData(65, (byte) 2, false);
ladder.getRelative(BlockFace.SOUTH).setTypeIdAndData(65, (byte) 3, false);
ladder.getRelative(BlockFace.WEST).setTypeIdAndData(65, (byte) 4, false);
ladder.getRelative(BlockFace.EAST).setTypeIdAndData(65, (byte) 5, false);
}
}
else
{
if(Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize())
{
b.setType(Material.FENCE);
}
}
if(b.getType() != Material.AIR)
{
addBlock(b);
}
}
}
}
}
@EventHandler
public void checkWinners(UpdateEvent event)
{
if(event.getType() != UpdateType.TICK)
{
return;
}
if(!Host.IsLive())
{
return;
}
for(Player player : Host.GetPlayers(true))
{
if(IsCompleted(player))
{
continue;
}
if(UtilAlg.inBoundingBox(player.getLocation(), _winCornerA, _winCornerB))
{
SetCompleted(player);
}
}
}
@EventHandler
public void onPvp(CustomDamageEvent event)
{
if(!Host.IsLive())
{
return;
}
if(event.GetDamageePlayer() == null)
{
return;
}
if(IsCompleted(event.GetDamagerPlayer(false)))
{
event.SetCancelled("Player already completed");
return;
}
if(event.GetCause() == DamageCause.FALL)
{
event.SetCancelled("Fall damage");
}
}
if(event.GetCause() == DamageCause.FALL)
@EventHandler
public void resetPlayerHealth(UpdateEvent event)
{
event.SetCancelled("Fall damage");
if(event.getType() != UpdateType.SEC)
{
for(Player player : Host.GetPlayers(true))
{
player.setHealth(20);
}
}
}
}
@EventHandler
public void resetPlayerHealth(UpdateEvent event)
{
if(event.getType() != UpdateType.SEC)
{
for(Player player: Host.GetPlayers(true))
{
player.setHealth(20);
}
}
}
}

View File

@ -26,168 +26,172 @@ import com.sun.org.apache.bcel.internal.generic.RETURN;
public class ChallengeKangarooJump extends Challenge
{
private long _gameTime = System.currentTimeMillis() + ((UtilMath.r(5) + 20) * 1000);
private long _gameTime = System.currentTimeMillis() + ((UtilMath.r(5) + 20) * 1000);
private HashMap<String, Boolean> _players = new HashMap<String, Boolean>();
private HashMap<String, Boolean> _players = new HashMap<String, Boolean>();
public ChallengeKangarooJump(MineWare host)
{
super(host, ChallengeType.FirstComplete, "Kangaroo Jump", "Block from block to block", "Highest player win!");
}
@Override
public ArrayList<Location> getSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
for(int x = -(getArenaSize() - 1); x <= getArenaSize()-1; x++)
public ChallengeKangarooJump(MineWare host)
{
for(int z = -(getArenaSize() - 1); z <= getArenaSize()-1; z++)
{
if(x % 2 == 0 && z % 2 == 0)
{
spawns.add(getCenter().clone().add(x + 0.5, 1.1, z + 0.5));
}
}
super(host, ChallengeType.FirstComplete, "Kangaroo Jump", "Block from block to block", "Highest player win!");
}
return spawns;
}
@Override
public void cleanupRoom()
{
Host.StrictAntiHack = true;
}
@Override
public void setupPlayers()
{
for(Player player : Host.GetPlayers(true))
@Override
public ArrayList<Location> getSpawns()
{
_players.put(player.getName(), true);
}
Host.StrictAntiHack = false;
}
ArrayList<Location> spawns = new ArrayList<Location>();
@Override
public void generateRoom()
{
for(int x = -getArenaSize(); x <= getArenaSize(); x++)
{
for(int z = -getArenaSize(); z <= getArenaSize(); z++)
{
for(int y = 0; y <= 150; y++)
for(int x = -(getArenaSize() - 1); x <= getArenaSize() - 1; x++)
{
Block b = getCenter().getBlock().getRelative(x, y, z);
if(y == 0)
{
b.setType(Material.DIRT);
b.setData((byte) 2);
}
else if(y > 2)
{
if(UtilMath.r(33) == 15)
for(int z = -(getArenaSize() - 1); z <= getArenaSize() - 1; z++)
{
b.setType(Material.WOOL);
b.setData((byte) UtilMath.r(16));
if(x % 2 == 0 && z % 2 == 0)
{
spawns.add(getCenter().clone().add(x + 0.5, 1.1, z + 0.5));
}
}
}
else
{
if(Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize())
}
return spawns;
}
@Override
public void cleanupRoom()
{
Host.StrictAntiHack = true;
}
@Override
public void setupPlayers()
{
for(Player player : Host.GetPlayers(true))
{
_players.put(player.getName(), true);
}
Host.StrictAntiHack = false;
}
@Override
public void generateRoom()
{
for(int x = -getArenaSize(); x <= getArenaSize(); x++)
{
for(int z = -getArenaSize(); z <= getArenaSize(); z++)
{
b.setType(Material.FENCE);
for(int y = 0; y <= 150; y++)
{
Block b = getCenter().getBlock().getRelative(x, y, z);
if(y == 0)
{
b.setType(Material.DIRT);
b.setData((byte) 2);
}
else if(y > 2)
{
if(UtilMath.r(33) == 15)
{
b.setType(Material.WOOL);
b.setData((byte) UtilMath.r(16));
}
}
else
{
if(Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize())
{
b.setType(Material.FENCE);
}
}
if(b.getType() != Material.AIR)
{
addBlock(b);
}
}
}
}
if(b.getType() != Material.AIR)
{
addBlock(b);
}
}
}
}
}
@EventHandler
public void onPlayerJump(PlayerMoveEvent event)
{
if(!Host.IsLive())
@EventHandler
public void onPlayerJump(PlayerMoveEvent event)
{
return;
}
if(!Host.isChallengeStarted())
{
return;
}
if(event.getFrom().getY() >= event.getTo().getY())
{
return;
}
Player player = event.getPlayer();
if(_players.get(player.getName()) == false)
{
if(player.isOnGround())
{
_players.put(player.getName(), true);
}
return;
}
UtilAction.velocity(player, 2, 0.4, 4, true);
_players.put(player.getName(), false);
}
@EventHandler
public void gameEndChecker(UpdateEvent event)
{
if(event.getType() != UpdateType.FASTER)
{
return;
}
if(System.currentTimeMillis() > _gameTime)
{
HashMap<String, Integer> playerHeights = new HashMap<String, Integer>();
for(Player player : Host.GetPlayers(true))
{
if(!Host.IsAlive(player))
if(!Host.IsLive())
{
return;
return;
}
playerHeights.put(player.getName(), player.getLocation().getBlockY());
}
ArrayList<String> sortedList = sortHash(playerHeights);
for(int i = 0; i <= (Host.GetPlayers(true).size()); i++)
{
if(!isDone(Bukkit.getPlayer(sortedList.get(i))))
if(!Host.isChallengeStarted())
{
if(i <= (Host.GetPlayers(true).size() / 2))
{
SetCompleted(Bukkit.getPlayer(sortedList.get(i)));
}
else
{
setLost(Bukkit.getPlayer(sortedList.get(i)));
}
return;
}
}
}
}
if(event.getFrom().getY() >= event.getTo().getY())
{
return;
}
Player player = event.getPlayer();
private ArrayList<String> sortHash(final HashMap<String, Integer> unsortedMap)
{
ArrayList<String> players = new ArrayList<String>(unsortedMap.keySet());
Collections.sort(players, new Comparator<String>()
if(_players.get(player.getName()) == false)
{
if(player.isOnGround())
{
_players.put(player.getName(), true);
}
return;
}
UtilAction.velocity(player, 2, 0.4, 4, true);
_players.put(player.getName(), false);
}
@EventHandler
public void gameEndChecker(UpdateEvent event)
{
@Override
public int compare(String o1, String o2)
{
Integer height1 = unsortedMap.get(o1);
Integer height2 = unsortedMap.get(o2);
return height2.compareTo(height1);
}
});
return players;
}
if(event.getType() != UpdateType.FASTER)
{
return;
}
if(System.currentTimeMillis() > _gameTime)
{
HashMap<String, Integer> playerHeights = new HashMap<String, Integer>();
for(Player player : Host.GetPlayers(true))
{
if(!Host.IsAlive(player))
{
return;
}
if(!playerHeights.containsKey(player.getName()))
{
playerHeights.put(player.getName(), player.getLocation().getBlockY());
}
}
ArrayList<String> sortedList = sortHash(playerHeights);
for(int i = 0; i < (Host.GetPlayers(true).size()); i++)
{
System.out.println(sortedList.get(i));
if(!isDone(Bukkit.getPlayer(sortedList.get(i))))
{
if(i <= (Host.GetPlayers(true).size() / 2))
{
SetCompleted(Bukkit.getPlayer(sortedList.get(i)));
}
else
{
setLost(Bukkit.getPlayer(sortedList.get(i)));
}
}
}
}
}
private ArrayList<String> sortHash(final HashMap<String, Integer> unsortedMap)
{
ArrayList<String> players = new ArrayList<String>(unsortedMap.keySet());
Collections.sort(players, new Comparator<String>()
{
@Override
public int compare(String o1, String o2)
{
Integer height1 = unsortedMap.get(o1);
Integer height2 = unsortedMap.get(o2);
return height2.compareTo(height1);
}
});
return players;
}
}

View File

@ -0,0 +1,325 @@
package nautilus.game.arcade.game.games.mineware.challenges;
import java.util.ArrayList;
import java.util.HashSet;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.MineWare;
import net.md_5.bungee.api.ChatColor;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldEvent;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.vehicle.VehicleDamageEvent;
import org.bukkit.event.vehicle.VehicleEnterEvent;
import org.bukkit.scheduler.BukkitRunnable;
public class ChallengeMinecartDance extends Challenge
{
/*
* _state if 1 = waiting if 2 = stateSwitch if 3 = cartsSpawned and player
* battle
*/
private boolean _isPlayingMusic = false;
private int _availableMinecarts;
private volatile int _state = 1;
private long _timeSinceLastState;
private HashSet<Minecart> _minecarts = new HashSet<Minecart>();
public ChallengeMinecartDance(MineWare host)
{
super(host, ChallengeType.LastStanding, "Minecart Dance", "Whenever the firework turns green", "Get inside a minecart");
}
@Override
public ArrayList<Location> getSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
for(int x = -(getArenaSize(7) - 1); x <= getArenaSize(7); x++)
{
for(int z = -(getArenaSize(7) - 1); z <= getArenaSize(7); z++)
{
if(x % 2 == 0 && z % 2 == 0)
{
spawns.add(getCenter().clone().add(x + 0.5, 1.1, z + 0.5));
}
}
}
return spawns;
}
@Override
public void cleanupRoom()
{
if(_isPlayingMusic)
{
_isPlayingMusic = false;
for(Player player: UtilServer.getPlayers())
{
((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldEvent(1005, new BlockPosition(getCenter().getBlockX(), getCenter().getBlockY()+5, getCenter().getBlockZ()), 0, false));
}
}
for(Minecart minecarts : _minecarts)
{
minecarts.remove();
}
_minecarts.clear();
}
@Override
public void setupPlayers()
{
_timeSinceLastState = System.currentTimeMillis();
}
@Override
public void generateRoom()
{
for(int x = -getArenaSize(); x <= getArenaSize(); x++)
{
for(int z = -getArenaSize(); z <= getArenaSize(); z++)
{
for(int y = 0; y <= 1; y++)
{
Block b = getCenter().getBlock().getRelative(x, y, z);
if(y == 0)
{
b.setType(Material.WOOL);
b.setData((byte) UtilMath.r(16));
}
else
{
if(Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize())
{
b.setType(Material.FENCE);
}
}
if(b.getType() != Material.AIR)
{
addBlock(b);
}
}
}
}
}
@EventHandler
public void gameChecker(UpdateEvent event)
{
if(event.getType() != UpdateType.FASTEST)
{
return;
}
if(!Host.IsLive())
{
return;
}
if(_state == 3)
{
_availableMinecarts = 0;
for(Minecart mc : _minecarts)
{
if(!mc.isEmpty())
{
continue;
}
else
{
_availableMinecarts++;
}
}
if(_availableMinecarts == 0)
{
for(Player player : getCurrentyAlive(true))
{
if(!player.isInsideVehicle())
{
Host.WorldData.World.strikeLightningEffect(player.getLocation());
setLost(player);
UtilPlayer.message(player, F.main("Minecart Dance", "You didn't get inside a Minecart!"));
}
}
_timeSinceLastState = System.currentTimeMillis();
_state = 1;
for(Minecart minecarts : _minecarts)
{
if(!minecarts.isEmpty())
{
minecarts.eject();
}
minecarts.remove();
}
_minecarts.clear();
}
}
}
@EventHandler
public void onSecTick(UpdateEvent event)
{
// Main event that's fired each sec
if(event.getType() != UpdateType.SEC)
{
return;
}
if(!Host.IsLive())
{
return;
}
if(_state == 1) // waiting
{
if(!_isPlayingMusic)
{
_isPlayingMusic = true;
for(Player player: UtilServer.getPlayers())
{
((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldEvent(1005, new BlockPosition(getCenter().getBlockX(), getCenter().getBlockY()+5, getCenter().getBlockZ()), 2259, false));
}
}
if(_timeSinceLastState + 5500 < System.currentTimeMillis())
{
if(UtilMath.r(4) == 0)
{
_state = 2;
}
else
{
spawnFireworkAtCorners(Color.RED);
}
}
else
{
spawnFireworkAtCorners(Color.RED);
}
}
if(_state == 2) // stateChange
{
new BukkitRunnable()
{
@Override
public void run()
{
for(int i = 0; i < 3; i++)
{
spawnFireworkAtCorners(Color.GREEN);
//Thread.sleep((500)); // 10th tick, causing lag
}
}
}.runTaskLater(Host.Manager.getPlugin(), 0);
if(_isPlayingMusic)
{
_isPlayingMusic = false;
for(Player player: UtilServer.getPlayers())
{
((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldEvent(1005, new BlockPosition(getCenter().getBlockX(), getCenter().getBlockY()+5, getCenter().getBlockZ()), 0, false));
}
}
for(int i = 0; i < getCurrentyAlive(true).size() - 1; i++)
{
Minecart minecart = Host.WorldData.World.spawn(new Location(Host.WorldData.World,
UtilMath.r(getArenaSize(7) * 2) - (getArenaSize(7)), 2, UtilMath.r(getArenaSize(7) * 2) - (getArenaSize(7))), Minecart.class);
UtilEnt.ghost(minecart, true, false);
_minecarts.add(minecart);
}
_state = 3;
}
else if(_state == 3)
{
new BukkitRunnable()
{
@Override
public void run()
{
if(_state != 3 || !Host.IsLive())
{
this.cancel();
}
int minecarts = 0;
for(Minecart minecart : _minecarts)
{
if(!minecart.isEmpty())
{
minecarts++;
}
}
UtilTextMiddle.display("" + (_minecarts.size() - minecarts), "Minecarts left!", 0, 60, 20);
}
}.runTaskLater(Host.Manager.getPlugin(), 0); // Multi threading
}
}
@EventHandler
public void onVehicleDamage(VehicleDamageEvent event)
{
if(!Host.IsLive())
{
return;
}
if(event.getVehicle() instanceof Minecart)
{
event.setCancelled(true);
}
}
@EventHandler
public void onVehicleInteract(VehicleEnterEvent event)
{
if(!Host.IsLive())
{
return;
}
if(!(event.getEntered() instanceof Player))
{
return;
}
Player player = (Player) event.getEntered();
if(isLost(player) || !Host.IsPlaying(player))
{
event.setCancelled(true);
}
}
public void spawnFireworkAtCorners(Color color)
{
UtilFirework.playFirework(new Location(Host.WorldData.World, getArenaSize() + 5, 10, getArenaSize() + 5), Type.BALL_LARGE, color, false,
false);
UtilFirework.playFirework(new Location(Host.WorldData.World, -getArenaSize() - 5, 10, getArenaSize() + 5), Type.BALL_LARGE, color, false,
false);
UtilFirework.playFirework(new Location(Host.WorldData.World, getArenaSize() + 5, 10, -getArenaSize() - 5), Type.BALL_LARGE, color, false,
false);
UtilFirework.playFirework(new Location(Host.WorldData.World, -getArenaSize() - 5, 10, -getArenaSize() - 5), Type.BALL_LARGE, color, false,
false);
}
}

View File

@ -3,8 +3,11 @@ package nautilus.game.arcade.game.games.mineware.challenges;
import java.util.ArrayList;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilInput;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -14,6 +17,7 @@ import nautilus.game.arcade.game.games.mineware.MineWare;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Arrow;
@ -28,166 +32,165 @@ import org.bukkit.scheduler.BukkitRunnable;
public class ChallengeMiniOITQ extends Challenge
{
private long _gameTime;
public ChallengeMiniOITQ(MineWare host)
{
super(host, ChallengeType.FirstComplete, "Mini OITQ", "One Arrow! One Kill!", "Don't miss!");
}
@Override
public ArrayList<Location> getSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
for(int x = -(getArenaSize() - 1); x <= getArenaSize() - 1; x++)
public ChallengeMiniOITQ(MineWare host)
{
for(int z = -(getArenaSize() - 1); z <= getArenaSize() - 1; z++)
{
if(x % 2 == 0 && z % 2 == 0)
super(host, ChallengeType.LastStanding, "Mini OITQ", false, true, "Do not get hit!", "Get new arrow every 4 second", "Last man standing wins!");
}
@Override
public ArrayList<Location> getSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
for(int x = -(getArenaSize() - 1); x <= getArenaSize() - 1; x++)
{
spawns.add(getCenter().clone().add(x + 0.5, 1.1, z + 0.5));
}
}
}
return spawns;
}
@Override
public void cleanupRoom()
{
Host.DamagePvE = false;
for(Entity entities : Host.WorldData.World.getEntities())
{
if(entities instanceof Arrow)
{
entities.remove();
}
}
}
@Override
public void setupPlayers()
{
_gameTime = System.currentTimeMillis() + ((UtilMath.r(5) + 10) * 1000);
for(Player player : Host.GetPlayers(true))
{
player.getInventory().addItem(new ItemBuilder(Material.BOW).setTitle(C.cGreen + "1Shot1Kill").build());
player.getInventory().addItem(new ItemStack(Material.ARROW));
}
Host.DamagePvE = true;
}
@Override
public void generateRoom()
{
for(int x = -getArenaSize(); x <= getArenaSize(); x++)
{
for(int z = -getArenaSize(); z <= getArenaSize(); z++)
{
for(int y = 0; y <= 1; y++)
{
Block b = getCenter().getBlock().getRelative(x, y, z);
if(y == 0)
{
b.setType(Material.GRASS);
}
else
{
if(Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize())
for(int z = -(getArenaSize() - 1); z <= getArenaSize() - 1; z++)
{
b.setType(Material.FENCE);
if(x % 2 == 0 && z % 2 == 0)
{
spawns.add(getCenter().clone().add(x + 0.5, 1.1, z + 0.5));
}
}
else if(UtilMath.r(4) == 0 && y == 1)
{
if(UtilMath.r(8) == 0)
{
b.setType(Material.STAINED_CLAY);
b.getRelative(BlockFace.UP).setType(Material.STAINED_CLAY);
}
}
}
if(b.getType() != Material.AIR)
{
addBlock(b.getRelative(BlockFace.UP));
addBlock(b);
}
}
}
return spawns;
}
}
@EventHandler
public void gameTime(UpdateEvent event)
{
if(!Host.IsLive())
@Override
public void cleanupRoom()
{
return;
}
if(event.getType() != UpdateType.FASTER)
{
return;
}
if((System.currentTimeMillis() >= _gameTime))
{
for(Player player : Host.GetPlayers(true))
{
if(isDone(player))
Host.DamagePvP = false;
Host.DamagePvE = false;
for(Entity entities : Host.WorldData.World.getEntities())
{
continue;
if(entities instanceof Arrow)
{
entities.remove();
}
}
setLost(player);
}
}
}
@EventHandler
public void onArrowHitPlayer(EntityDamageByEntityEvent event)
{
if(!Host.IsLive())
{
return;
}
if(!(event.getDamager() instanceof Arrow)) // Damager = Arrow (player)
{
return;
}
if(!(event.getEntity() instanceof Player)) // Damaged = player
{
return;
}
Arrow arrow = (Arrow) event.getDamager();
Player shooter = (Player) arrow.getShooter();
Player damaged = (Player) event.getEntity();
if(isDone(shooter) || isDone(damaged))
{
event.setCancelled(true);
return;
}
SetCompleted(shooter, true);
setLost(damaged, true);
}
@Override
public void setupPlayers()
{
for(Player player : Host.GetPlayers(true))
{
player.getInventory().addItem(new ItemBuilder(Material.BOW).setTitle(C.cGreen + "1Shot1Kill").build());
player.getInventory().addItem(new ItemStack(Material.ARROW));
}
Host.DamagePvP = true;
Host.DamagePvE = true;
}
@EventHandler
public void onSuffication(EntityDamageEvent event)
{
if(!Host.IsLive())
@Override
public void generateRoom()
{
return;
for(int x = -getArenaSize(); x <= getArenaSize(); x++)
{
for(int z = -getArenaSize(); z <= getArenaSize(); z++)
{
forloopY:
for(int y = 0; y <= 1; y++)
{
Block b = getCenter().getBlock().getRelative(x, y, z);
if(y == 0)
{
b.setType(Material.GRASS);
}
else
{
if(Math.abs(x) == getArenaSize() || Math.abs(z) == getArenaSize())
{
b.setType(Material.FENCE);
}
if(Math.abs(x) == getArenaSize() - 2 || Math.abs(z) == getArenaSize() - 2)
{
if(y == 1)
{
if(UtilMath.r(8) == 0)
{
for(Location spawns: getSpawns())
{
if(spawns.getBlockX() == b.getLocation().getBlockX() && spawns.getBlockZ() == b.getLocation().getBlockZ())
{
continue forloopY;
}
}
b.setType(Material.STAINED_CLAY);
b.getRelative(BlockFace.UP).setType(Material.STAINED_CLAY);
b.setData((byte)14);
b.getRelative(BlockFace.UP).setData((byte)14);
}
}
}
}
if(b.getType() != Material.AIR)
{
addBlock(b.getRelative(BlockFace.UP));
addBlock(b);
}
}
}
}
Host.DamageSelf = false;
}
if(!(event.getEntity() instanceof Player))
@EventHandler
public void giveArrowHandler(UpdateEvent event)
{
return;
if(!Host.IsLive())
{
return;
}
if(event.getType() != UpdateType.SLOW)
{
return;
}
for(Player player: Host.GetPlayers(true))
{
if(isLost(player))
{
continue;
}
if(UtilInv.contains(player, Material.ARROW, (byte)0, 1))
{
continue;
}
player.getInventory().setItem(1, new ItemStack(Material.ARROW));
player.playSound(player.getLocation(), Sound.ITEM_PICKUP, 0.2f, 0.2f);
}
}
if(event.getCause() != DamageCause.SUFFOCATION)
@EventHandler
public void onArrowHitPlayer(EntityDamageByEntityEvent event)
{
return;
if(!Host.IsLive())
{
return;
}
if(!(event.getDamager() instanceof Arrow)) // Damager = Arrow (player)
{
return;
}
if(!(event.getEntity() instanceof Player)) // Damaged = player
{
return;
}
Arrow arrow = (Arrow) event.getDamager();
Player shooter = (Player) arrow.getShooter();
Player damaged = (Player) event.getEntity();
if(isLost(shooter) || !Host.IsPlaying(shooter))
{
event.setCancelled(true);
return;
}
damaged.setHealth(1);
event.setDamage(event.getDamage());
}
event.setCancelled(true);
}
}

View File

@ -30,7 +30,7 @@ public class ChallengePunchThePig extends Challenge
public ChallengePunchThePig(MineWare host)
{
super(host, ChallengeType.FirstComplete, "Punch the Pig", "KILL ALL THE PIGS!");
super(host, ChallengeType.FirstComplete, "Punch the Pig", "Kill 5 pigs!!");
}
@Override

View File

@ -0,0 +1,250 @@
package nautilus.game.arcade.game.games.mineware.challenges;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
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.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.MineWare;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
public class ChallengeRedLightGreenLight extends Challenge
{
private boolean _canMove;
private int _minTimeBeforeGreen = 2500;
private int _minTimeBeforeRed = 1500;
private long _timeBeforeAction;
private long _timeSinceLastGreen;
private long _timeSinceLastRed;
private ArrayList<String> _cooldownedPlayers = new ArrayList<String>();
private ArrayList<Integer> _colorList = new ArrayList<Integer>(Arrays.asList(14, 11, 9, 3, 1, 4, 13, 5));
private Villager _host;
public ChallengeRedLightGreenLight(MineWare host)
{
super(host, ChallengeType.FirstComplete, "Red Light, Green Light", false, false, "Reach the end as the first", "Don't move after RED firework");
}
@Override
public ArrayList<Location> getSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
for(int x = -31; x <= -30; x++)
{
for(int z = -(getArenaSize() - 1); z <= getArenaSize() - 1; z++)
{
if(x % 2 == 0 && z % 2 == 0)
{
spawns.add(getCenter().clone().add(x + 0.5, 2.1, z + 0.5));
}
}
}
return spawns;
}
@Override
public void cleanupRoom()
{
_host.remove();
for(Player player: Host.GetPlayers(true))
{
if(player.hasPotionEffect(PotionEffectType.SLOW))
{
player.removePotionEffect(PotionEffectType.SLOW);
}
}
}
@Override
public void setupPlayers()
{
changeMoveState(true);
for(Player player: Host.GetPlayers(true))
{
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 2));
}
}
@Override
public void generateRoom()
{
int var = 1;
int colorPicker = 0;
Collections.reverse(_colorList);
for(int x = -32; x <= 32; x++) //length people need to run
{
for(int z = -getArenaSize(); z <= getArenaSize(); z++)
{
for(int y = 0; y <= 1; y++)
{
Block b = getCenter().getBlock().getRelative(x, y, z);
if(y == 0)
{
b.setType(Material.BEDROCK);
}
else if(y > 0)
{
b.setType(Material.WOOL);
b.setData(_colorList.get(colorPicker).byteValue());
}
if(b.getType() != Material.AIR)
{
addBlock(b);
}
}
}
if(var % 8 == 0 && (colorPicker != _colorList.size() - 1))
{
colorPicker++;
}
var++;
}
Host.CreatureAllowOverride = true;
_host = (Villager)getCenter().getWorld().spawnEntity(new Location(getCenter().getWorld(), 30, 1, 0), EntityType.VILLAGER);
UtilEnt.Vegetate(_host);
UtilEnt.ghost(_host, true, false);
Host.CreatureAllowOverride = false;
}
@EventHandler
public void playerMoveHandler(final PlayerMoveEvent event)
{
if(!Host.IsLive())
{
return;
}
if(isDone(event.getPlayer()) || !Host.IsPlaying(event.getPlayer()))
{
return;
}
if(event.getPlayer().getLocation().getX() > 30) // Wins the challenge
{
SetCompleted(event.getPlayer());
}
if(!_canMove && !_cooldownedPlayers.contains(event.getPlayer().getName()) && _timeBeforeAction < System.currentTimeMillis())
{
UtilAction.velocity(event.getPlayer(), UtilAlg.getTrajectory2d(event.getPlayer().getLocation(), new Location(getCenter().getWorld(), -32, 5, 0)), 1.5, true, 0.4, 0, 10, true);
_cooldownedPlayers.add(event.getPlayer().getName());
new BukkitRunnable()
{
@Override
public void run()
{
_cooldownedPlayers.remove(event.getPlayer().getName());
}
}.runTaskLater(Host.Manager.getPlugin(), 40);
}
}
@EventHandler
public void stateChangeHandler(UpdateEvent event)
{
if(event.getType() != UpdateType.FAST)
{
return;
}
if(!Host.IsLive())
{
return;
}
if(_canMove)
{
if(_timeSinceLastRed+_minTimeBeforeRed < System.currentTimeMillis())
{
if(UtilMath.r(2) == 0)
{
changeMoveState(false);
}
}
}
else
{
if(_timeSinceLastGreen+_minTimeBeforeGreen < System.currentTimeMillis())
{
if(UtilMath.r(3) == 0)
{
changeMoveState(true);
}
}
}
}
private void changeMoveState(boolean condition)
{
if(condition != _canMove)
{
if(condition)
{
_timeSinceLastRed = System.currentTimeMillis();
_canMove = true;
spawnFireWork(Color.GREEN);
for(Player player: UtilServer.getPlayers())
{
player.sendMessage(F.main("Green Light", "You can now move!"));
player.getWorld().playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 2f, 1f);
player.getWorld().playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 2f, 1f);
}
}
else
{
_timeSinceLastGreen = System.currentTimeMillis();
_timeBeforeAction = System.currentTimeMillis() + 1500; //1.5 seconds before the player HAS to stand still
_canMove = false;
spawnFireWork(Color.RED);
for(Player player: UtilServer.getPlayers())
{
player.sendMessage(F.main("Red Light", "Freeze!"));
UtilTextMiddle.display(ChatColor.RED + "Freeze!", "", 0, 20*3, 20);
player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f);
player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f);
}
}
}
}
private void spawnFireWork(Color color)
{
for(int i = -getArenaSize(); i < getArenaSize()*2; i += 4)
{
UtilFirework.playFirework(new Location(Host.WorldData.World, 30, 10, i), Type.BALL_LARGE, color, false, false);
}
}
}

View File

@ -10,6 +10,7 @@ import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -32,12 +33,13 @@ import org.bukkit.inventory.ItemStack;
public class ChallengeReverseTag extends Challenge
{
private long _gameTime;
private double _endTime;
private double _startTime;
private HashSet<String> _tagged = new HashSet<String>();
public ChallengeReverseTag(MineWare Host)
{
super(Host, ChallengeType.FirstComplete, "Reverse Tag", "Be it!", "Punch the sparking people!");
super(Host, ChallengeType.FirstComplete, "Reverse Tag", "Be a sparkling person", "Punch the sparking people to become sparking!");
}
@Override
@ -67,7 +69,8 @@ public class ChallengeReverseTag extends Challenge
@Override
public void setupPlayers()
{
_gameTime = System.currentTimeMillis() + ((UtilMath.r(5) + 20) * 1000);
_endTime = System.currentTimeMillis() + ((UtilMath.r(5) + 20) * 1000);
_startTime = System.currentTimeMillis();
int looped = 0;
ArrayList<Player> players = new ArrayList<Player>(Host.GetPlayers(true));
@ -166,6 +169,20 @@ public class ChallengeReverseTag extends Challenge
removeTagged(event.GetDamageePlayer());
addTagged(event.GetDamagerPlayer(false));
}
@EventHandler
public void displayGameProgress(UpdateEvent event)
{
if(event.getType() != UpdateType.FASTEST)
{
return;
}
if(!Host.IsLive())
{
return;
}
UtilTextBottom.displayProgress(Double.valueOf((_endTime - System.currentTimeMillis()) / (_endTime - _startTime)), UtilServer.getPlayers());
}
@EventHandler
public void onTaggedDeath(PlayerDeathEvent event)
@ -188,9 +205,9 @@ public class ChallengeReverseTag extends Challenge
player.getInventory().setHelmet(new ItemStack(Material.AIR));
_tagged.remove(player.getName());
for(int i = 0; i >= 8; i++)
for(int i = 0; i <= 8; i++)
{
player.getInventory().remove(i);
player.getInventory().clear(i);
}
}
}
@ -203,7 +220,7 @@ public class ChallengeReverseTag extends Challenge
player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(35, (byte) 5));
_tagged.add(player.getName());
for(int i = 0; i >= 8; i++)
for(int i = 0; i <= 8; i++)
{
player.getInventory().setItem(i, ItemStackFactory.Instance.CreateStack(35, (byte) 5));
}
@ -212,7 +229,7 @@ public class ChallengeReverseTag extends Challenge
public void checkGameEnd()
{
if(System.currentTimeMillis() > _gameTime)
if(System.currentTimeMillis() > _endTime)
{
for(Player player : Host.GetPlayers(true))
{

View File

@ -21,108 +21,108 @@ import org.bukkit.inventory.meta.LeatherArmorMeta;
public class ChallengeRushPush extends Challenge
{
private HashMap<String, String> _teams = new HashMap<String, String>();
public ChallengeRushPush(MineWare host)
{
super(host, ChallengeType.LastStanding, "Rush push", "Rush your enemy", "And push them off the platform");
}
private HashMap<String, String> _teams = new HashMap<String, String>();
@Override
public ArrayList<Location> getSpawns()
{
ArrayList<Location> locations = new ArrayList<Location>();
for (int x = -(getArenaSize()-1); x <= getArenaSize()-1; x++)
public ChallengeRushPush(MineWare host)
{
for (int z = -6; z <= 6; z+=6)
{
if (z == 0)
continue;
super(host, ChallengeType.LastStanding, "Rush push", true, true, "Rush your enemy", "And push them off the platform", "Remember you have no teammates!");
}
locations.add(getCenter().add(x + 0.5, 1.1, z + 0.5));
@Override
public ArrayList<Location> getSpawns()
{
ArrayList<Location> locations = new ArrayList<Location>();
for(int x = -(getArenaSize() - 1); x <= getArenaSize() - 1; x++)
{
for(int z = -6; z <= 6; z += 6)
{
if(z == 0)
continue;
locations.add(getCenter().add(x + 0.5, 1.1, z + 0.5));
}
}
return locations;
}
@Override
public void cleanupRoom()
{
Host.DamagePvP = false;
}
@Override
public void setupPlayers()
{
for(Player player : Host.GetPlayers(true))
{
if(player.getLocation().add(0, -1, 0).getBlock().getData() == (byte) 11)
{
_teams.put(player.getName(), "blue");
}
else
{
_teams.put(player.getName(), "red");
}
player.getInventory().addItem(new ItemStack(Material.DIAMOND_SWORD));
}
for(String playerNames : _teams.keySet())
{
Player thePlayer = Bukkit.getPlayer(playerNames);
ItemStack helm = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta metaHelm = (LeatherArmorMeta) helm.getItemMeta();
metaHelm.setColor(_teams.get(playerNames) == "blue" ? Color.BLUE : Color.RED);
helm.setItemMeta(metaHelm);
thePlayer.getInventory().setHelmet(helm);
}
Host.DamagePvP = true;
}
// z < 1 = blue z > 1 = red; z ~ 0 = misc;
@Override
public void generateRoom()
{
for(int x = -getArenaSize(); x <= getArenaSize(); x++)
{
for(int z = -6; z <= 6; z++)
{
for(int y = 0; y <= 0; y++)
{
Block b = getCenter().getBlock().getRelative(x, y, z);
b.setType(Material.STAINED_CLAY);
if(z != 0)
{
b.setData((byte) (z < 0 ? 11 : z > 0 ? 14 : 0));
}
addBlock(b);
}
}
}
}
return locations;
}
@Override
public void cleanupRoom()
{
Host.DamagePvP = false;
}
@Override
public void setupPlayers()
{
for(Player player: Host.GetPlayers(true))
@EventHandler
public void onPlayerDamage(CustomDamageEvent event)
{
if(player.getLocation().add(0, -1, 0).getBlock().getData() == (byte)11)
{
_teams.put(player.getName(), "blue");
}
else
{
_teams.put(player.getName(), "red");
}
player.getInventory().addItem(new ItemStack(Material.DIAMOND_SWORD));
}
for(String playerNames: _teams.keySet())
{
Player thePlayer = Bukkit.getPlayer(playerNames);
ItemStack helm = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta metaHelm = (LeatherArmorMeta)helm.getItemMeta();
metaHelm.setColor(_teams.get(playerNames) == "blue" ? Color.BLUE : Color.RED);
helm.setItemMeta(metaHelm);
thePlayer.getInventory().setHelmet(helm);
}
Host.DamagePvP = true;
}
// z < 1 = blue z > 1 = red; z ~ 0 = misc;
@Override
public void generateRoom()
{
for(int x = -getArenaSize(); x <= getArenaSize(); x++)
{
for(int z = -6; z <= 6; z++)
{
for(int y = 0; y <= 0; y++)
if(!Host.IsLive())
{
Block b = getCenter().getBlock().getRelative(x, y, z);
b.setType(Material.STAINED_CLAY);
if(z != 0)
{
b.setData((byte) (z < 0 ? 11 : z > 0 ? 14 : 0));
}
addBlock(b);
return;
}
}
if(!(event.GetDamagerPlayer(true) instanceof Player) || !(event.GetDamageeEntity() instanceof Player))
{
return;
}
if(isLost(event.GetDamagerPlayer(false)))
{
event.SetCancelled("Player out of the game");
return;
}
event.AddMult("Ignore damage", null, 0.001, false);
event.AddKnockback("Power Punch", 5.5);
}
}
@EventHandler
public void onPlayerDamage(CustomDamageEvent event)
{
if(!Host.IsLive())
{
return;
}
if(!(event.GetDamagerPlayer(true) instanceof Player) || !(event.GetDamageeEntity() instanceof Player))
{
return;
}
if(isDone(event.GetDamagerPlayer(false)) || isDone(event.GetDamageePlayer()))
{
event.SetCancelled("Player out of the game");
return;
}
event.AddMult("Ignore damage", null, 0.001, false);
event.AddKnockback("Power Punch", 5.5);
}
}

View File

@ -17,7 +17,7 @@ public class ChallengeSmashOff extends Challenge
public ChallengeSmashOff(MineWare host)
{
super(host, ChallengeType.LastStanding, "Smash off", "Knock the other players off!");
super(host, ChallengeType.LastStanding, "Smash off", false, true, "Knock the other players off!");
}
@Override

View File

@ -34,7 +34,7 @@ public class ChallengeTntLauncher extends Challenge
public ChallengeTntLauncher(MineWare host)
{
super(host, ChallengeType.LastStanding, "Deadly TNT", "Throw TNT, don't get knocked off!");
super(host, ChallengeType.LastStanding, "Deadly TNT", false, true, "Throw TNT, don't get knocked off!");
}
@Override
@ -100,8 +100,7 @@ public class ChallengeTntLauncher extends Challenge
return;
}
TNTPrimed tnt = player.getWorld()
.spawn(player.getEyeLocation().add(player.getLocation().getDirection()), TNTPrimed.class);
TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), TNTPrimed.class);
UtilAction.velocity(tnt, player.getLocation().getDirection(), 0.6, false, 0, 0.2, 1, false);
tnt.setFuseTicks((int) (60 * (1 - ((System.currentTimeMillis() - StartTime) / 70000))));

View File

@ -2,7 +2,9 @@ package nautilus.game.arcade.game.games.mineware.challenges;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -15,11 +17,14 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
@ -39,6 +44,10 @@ public class ChallengeVolleyPig extends Challenge
private long _redSide;
private long _blueSide;
private Entity _pig;
private HashMap<String, String> _playerTeams = new HashMap<String, String>();
private Location _redCenter = new Location(Host.WorldData.World, 0, 3, -5);
private Location _blueCenter = new Location(Host.WorldData.World, 0, 3, 5);
public ChallengeVolleyPig(MineWare host)
{
@ -77,6 +86,24 @@ public class ChallengeVolleyPig extends Challenge
for (Player player : getChallengers())
{
player.getInventory().setItem(0, new ItemBuilder(Material.STICK).addEnchantment(Enchantment.KNOCKBACK, 1).build());
if(player.getWorld().getBlockAt(player.getLocation().clone().add(0, -1, 0)).getType() == Material.STAINED_CLAY)
{
Block clay = player.getWorld().getBlockAt(player.getLocation().clone().add(0, -1, 0));
if(clay.getData() == (byte)11)
{
_playerTeams.put(player.getName(), "blue");
}
else if (clay.getData() == (byte)14)
{
_playerTeams.put(player.getName(), "red");
}
ItemStack helm = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta metaHelm = (LeatherArmorMeta) helm.getItemMeta();
metaHelm.setColor(_playerTeams.get(player.getName()) == "blue" ? Color.BLUE : Color.RED);
helm.setItemMeta(metaHelm);
player.getInventory().setHelmet(helm);
}
}
Host.DamagePvE = true;
@ -108,11 +135,15 @@ public class ChallengeVolleyPig extends Challenge
Block bTo = to.getBlock();
if (bTo.getType() == Material.AIR || bTo.getData() != bFrom.getData())
{
Vector bump = UtilAlg.getAverageBump(event.getPlayer().getLocation(), new ArrayList<Location>(Arrays.asList(bTo.getLocation())));
{ // (z < 0 ? 11 : z > 0 ? 14 : 0)
String pName = event.getPlayer().getName();
Vector bump = UtilAlg.getAverageBump(event.getPlayer().getLocation(), new ArrayList<Location>(Arrays.asList(_playerTeams.get(pName) == "blue" ? _blueCenter : _redCenter)));
UtilAction.velocity(event.getPlayer(), bump, 0.8, false, 0, 0.4, 10, true);
event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20*3, 1));
// setLost(event.getPlayer());
UtilPlayer.message(event.getPlayer(), F.main("Side Checker", "You crossed over to the enemy!"));
}
}

View File

@ -2,13 +2,18 @@ package nautilus.game.arcade.game.games.mineware.challenges;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.ListIterator;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.projectile.ProjectileUser;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.mineware.Challenge;
import nautilus.game.arcade.game.games.mineware.MineWare;
import nautilus.game.arcade.game.games.mineware.events.challengeEndEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -23,225 +28,224 @@ import org.bukkit.util.Vector;
public class ChallengeWaveCrush extends Challenge
{
private boolean _inProgress = false;
private int _waveAmount = 0;
private int _waveSpeed = 30; // in ticks
private ArrayList<Integer> _colorList = new ArrayList<Integer>(Arrays.asList(14, 11, 9, 3, 1, 4, 13, 5));
private boolean _inProgress = false;
private int _waveAmount = 0;
private int _waveSpeed = 30; // in ticks
private ArrayList<Integer> _colorList = new ArrayList<Integer>(Arrays.asList(14, 11, 9, 3, 1, 4, 13, 5));
public ChallengeWaveCrush(MineWare host)
{
super(host, ChallengeType.LastStanding, "Wave Crush", "Avoid the crushing waves!");
}
@Override
public ArrayList<Location> getSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
for(int x = -15; x <= -13; x++)
public ChallengeWaveCrush(MineWare host)
{
for(int z = -(getArenaSize() - 1); z <= getArenaSize() - 1; z++)
{
if(x % 2 == 0 && z % 2 == 0)
{
spawns.add(getCenter().clone().add(x + 0.5, 2.1, z + 0.5));
}
}
super(host, ChallengeType.LastStanding, "Wave Crush", "Avoid the crushing waves!");
}
return spawns;
}
@Override
public void cleanupRoom()
{
_inProgress = false;
for(int x = -16; x <= 15; x++)
@Override
public ArrayList<Location> getSpawns()
{
for(int z = -getArenaSize(); z <= getArenaSize(); z++)
{
for(int y = 0; y <= 10; y++)
ArrayList<Location> spawns = new ArrayList<Location>();
for(int x = -15; x <= -13; x++)
{
Block b = Host.WorldData.World.getBlockAt(x, y, z);
{
if(b.getType() != Material.AIR)
for(int z = -(getArenaSize() - 1); z <= getArenaSize() - 1; z++)
{
if(!getModifiedBlocks().contains(b))
{
b.setType(Material.AIR);
}
if(x % 2 == 0 && z % 2 == 0)
{
spawns.add(getCenter().clone().add(x + 0.5, 2.1, z + 0.5));
}
}
}
}
}
return spawns;
}
}
@Override
public void setupPlayers()
{
_inProgress = true;
new BukkitRunnable()
@Override
public void cleanupRoom()
{
_inProgress = false;
@Override
public void run()
{
_waveAmount++;
Block choosenBlock;
if(!_inProgress || !Host.IsLive())
for(int x = -16; x <= 15; x++)
{
this.cancel();
for(int z = -getArenaSize(); z <= getArenaSize(); z++)
{
for(int y = 0; y <= 10; y++)
{
Block b = Host.WorldData.World.getBlockAt(x, y, z);
{
if(b.getType() != Material.AIR)
{
if(!getModifiedBlocks().contains(b))
{
b.setType(Material.AIR);
}
}
}
}
}
}
choosenBlock = Host.WorldData.World.getBlockAt(15, 1, UtilMath.r(getArenaSize() * 2) - getArenaSize());
while(choosenBlock.getType() == Material.AIR)
}
@Override
public void setupPlayers()
{
_inProgress = true;
new BukkitRunnable()
{
choosenBlock = Host.WorldData.World.getBlockAt(15, 1, UtilMath.r(getArenaSize() * 2) - getArenaSize());
}
waveStartingPoint(choosenBlock, 2);
@Override
public void run()
{
_waveAmount++;
Block choosenBlock;
if(_waveAmount % 3 == 0)
if(!_inProgress || !Host.IsLive())
{
this.cancel();
}
choosenBlock = Host.WorldData.World.getBlockAt(15, 1, UtilMath.r(getArenaSize() * 2) - getArenaSize());
while(choosenBlock.getType() == Material.AIR)
{
choosenBlock = Host.WorldData.World.getBlockAt(15, 1, UtilMath.r(getArenaSize() * 2) - getArenaSize());
}
waveStartingPoint(choosenBlock, 2);
if(_waveAmount % 3 == 0)
{
_waveSpeed--;
}
}
}.runTaskTimer(Host.Manager.getPlugin(), 20 * 3, _waveSpeed);
}
@Override
public void generateRoom()
{
int var = 0;
int colorPicker = 0;
for(int x = -16; x <= 15; x++)
{
_waveSpeed--;
for(int z = -getArenaSize(); z <= getArenaSize(); z++)
{
for(int y = 0; y <= 1; y++)
{
Block b = getCenter().getBlock().getRelative(x, y, z);
if(y == 0)
{
b.setType(Material.BEDROCK);
}
else if(y > 0)
{
b.setType(Material.WOOL);
b.setData(_colorList.get(colorPicker).byteValue());
}
if(b.getType() != Material.AIR)
{
addBlock(b);
}
}
}
if(var % 4 == 0 && (colorPicker != _colorList.size() - 1))
{
colorPicker++;
}
var++;
}
}
}.runTaskTimer(Host.Manager.getPlugin(), 20 * 3, _waveSpeed);
}
}
@Override
public void generateRoom()
{
int var = 0;
int colorPicker = 0;
for(int x = -16; x <= 15; x++)
@Override
public void onCollide(LivingEntity target, Block block, ProjectileUser data)
{
for(int z = -getArenaSize(); z <= getArenaSize(); z++)
{
for(int y = 0; y <= 1; y++)
if(!Host.IsLive())
{
Block b = getCenter().getBlock().getRelative(x, y, z);
if(y == 0)
{
b.setType(Material.BEDROCK);
}
else if(y > 0)
{
b.setType(Material.WOOL);
b.setData(_colorList.get(colorPicker).byteValue());
}
if(b.getType() != Material.AIR)
{
addBlock(b);
}
return;
}
}
if(var % 4 == 0 && (colorPicker != _colorList.size() - 1))
{
colorPicker++;
}
var++;
}
}
@Override
public void onCollide(LivingEntity target, Block block, ProjectileUser data)
{
if(!Host.IsLive())
{
return;
}
if(!(data.GetThrown() instanceof FallingBlock))
{
return;
}
if(!(target instanceof Player))
{
return;
}
Player thePlayer = (Player) target;
if(isDone(thePlayer))
{
return;
}
Host.Manager.GetDamage().NewDamageEvent(target, null, null, DamageCause.PROJECTILE, 9999.0, false, false, false, "Falling Block",
"Wave crush");
}
public void waveStartingPoint(Block block, int radius)
{
Block pickedBlock = Host.WorldData.World.getBlockAt(block.getX(), block.getY(), block.getZ() - radius);
if(radius != 1)
{
for(int i = 0; i <= (radius * 2) + 1; i++)
{
waveCreation(Host.WorldData.World.getBlockAt(pickedBlock.getX(), pickedBlock.getY(), pickedBlock.getZ() + i));
}
}
else
{
waveCreation(pickedBlock);
}
}
@EventHandler
public void OnChallengeEnd(challengeEndEvent event)
{
for(Player player : Host.GetPlayers(true))
{
if(!isDone(player))
{
SetCompleted(player);
}
}
new BukkitRunnable()
{
@Override
public void run()
{
for(Entity fBlocks : Host.WorldData.World.getEntities())
if(!(data.GetThrown() instanceof FallingBlock))
{
if(fBlocks instanceof FallingBlock)
{
fBlocks.remove();
}
return;
}
}
}.runTaskLater(Host.Manager.getPlugin(), 30);
}
if(!(target instanceof Player))
{
return;
}
Player thePlayer = (Player) target;
if(isDone(thePlayer))
{
return;
}
Host.Manager.GetDamage().NewDamageEvent(target, null, null, DamageCause.PROJECTILE, 9999.0, false, false, false, "Falling Block",
"Wave crush");
}
public void waveCreation(final Block block)
{
new BukkitRunnable()
public void waveStartingPoint(Block block, int radius)
{
Block theBlock = block;
@SuppressWarnings("deprecation")
@Override
public void run()
{
if(!_inProgress)
Block pickedBlock = Host.WorldData.World.getBlockAt(block.getX(), block.getY(), block.getZ() - radius);
if(radius != 1)
{
this.cancel();
for(int i = 0; i <= (radius * 2) + 1; i++)
{
waveCreation(Host.WorldData.World.getBlockAt(pickedBlock.getX(), pickedBlock.getY(), pickedBlock.getZ() + i));
}
}
if(theBlock.getType() == Material.AIR)
else
{
this.cancel();
waveCreation(pickedBlock);
}
FallingBlock fBlock = Host.WorldData.World.spawnFallingBlock(theBlock.getLocation().clone().add(0, 1, 0), theBlock.getType(),
theBlock.getData());
Host.Manager.GetProjectile().AddThrow(fBlock, null, Host, 1, true, false, true, false, 0.2f);
}
fBlock.setVelocity(new Vector(0, 10, 0).normalize());
theBlock.setType(Material.AIR);
theBlock = Host.WorldData.World.getBlockAt(theBlock.getX() - 1, theBlock.getY(), theBlock.getZ());
}
}.runTaskTimer(Host.Manager.getPlugin(), 0, 2);
}
@EventHandler
public void OnChallengeEnd(challengeEndEvent event)
{
for(Player player : Host.GetPlayers(true))
{
if(!isDone(player))
{
SetCompleted(player);
}
}
new BukkitRunnable()
{
@Override
public void run()
{
for(Entity fBlocks : Host.WorldData.World.getEntities())
{
if(fBlocks instanceof FallingBlock)
{
fBlocks.remove();
}
}
}
}.runTaskLater(Host.Manager.getPlugin(), 30);
}
public void waveCreation(final Block block)
{
new BukkitRunnable()
{
Block theBlock = block;
@SuppressWarnings("deprecation")
@Override
public void run()
{
if(!_inProgress)
{
this.cancel();
}
if(theBlock.getType() == Material.AIR)
{
this.cancel();
}
FallingBlock fBlock = Host.WorldData.World.spawnFallingBlock(theBlock.getLocation().clone().add(0, 1, 0), theBlock.getType(),
theBlock.getData());
Host.Manager.GetProjectile().AddThrow(fBlock, null, Host, -1, true, false, true, true, 0.4f);
fBlock.setVelocity(new Vector(0, 10, 0).normalize());
theBlock.setType(Material.AIR);
theBlock = Host.WorldData.World.getBlockAt(theBlock.getX() - 1, theBlock.getY(), theBlock.getZ());
}
}.runTaskTimer(Host.Manager.getPlugin(), 0, 2);
}
}