Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex
This commit is contained in:
commit
3014521e79
5
.gitignore
vendored
5
.gitignore
vendored
@ -29,3 +29,8 @@ Debug
|
||||
/MutualNDA (1)-signed.pdf
|
||||
/MutualNDA - signed-signed.pdf
|
||||
/MutualNDA - signed.pdf
|
||||
/Plugins/Cube/.classpath
|
||||
/Plugins/Cube/.project
|
||||
/Plugins/Cube/plugin.yml
|
||||
/Plugins/Cube/src/mastaG/Cube/Cube.java
|
||||
/Plugins/Libraries/spigot_server.jar
|
||||
|
@ -49,7 +49,7 @@ public class PlayerCount implements Listener, Runnable
|
||||
_secondRepository = new RedisDataRepository<BungeeServer>(new ConnectionData("10.81.1.156", 6379), new ConnectionData("10.81.1.156", 6377),
|
||||
Region.ALL, BungeeServer.class, "bungeeServers");
|
||||
else
|
||||
_secondRepository = new RedisDataRepository<BungeeServer>(new ConnectionData("10.33.53.16", 6379), new ConnectionData("10.33.53.16", 6377),
|
||||
_secondRepository = new RedisDataRepository<BungeeServer>(new ConnectionData("10.3.203.80", 6379), new ConnectionData("10.3.203.80", 6377),
|
||||
Region.ALL, BungeeServer.class, "bungeeServers");
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ public enum Rank
|
||||
OWNER("Owner", ChatColor.DARK_RED),
|
||||
DEVELOPER("Dev", ChatColor.RED),
|
||||
ADMIN("Admin", ChatColor.RED),
|
||||
JR_DEV("Jr. Dev", ChatColor.GOLD),
|
||||
SNR_MODERATOR("Sr.Mod", ChatColor.GOLD),
|
||||
MODERATOR("Mod", ChatColor.GOLD),
|
||||
HELPER("Trainee", ChatColor.DARK_AQUA),
|
||||
|
@ -15,9 +15,9 @@ public class UtilShapes
|
||||
BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST
|
||||
};
|
||||
|
||||
public static ArrayList<Location> getCircle(Location loc, double radius)
|
||||
public static ArrayList<Location> getCircle(Location loc, boolean hollow, double radius)
|
||||
{
|
||||
return getCircleBlocks(loc, radius, 0, true, false);
|
||||
return getCircleBlocks(loc, radius, 0, hollow, false);
|
||||
}
|
||||
|
||||
public static ArrayList<Location> getSphereBlocks(Location loc, double radius, double height, boolean hollow)
|
||||
|
@ -2,7 +2,7 @@ package mineplex.core.disguise.disguises;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class DisguiseVillager extends DisguiseCreature
|
||||
public class DisguiseVillager extends DisguiseAgeable
|
||||
{
|
||||
public DisguiseVillager(Entity entity)
|
||||
{
|
||||
|
@ -42,6 +42,7 @@ public class Portal extends MiniPlugin
|
||||
private HashSet<String> _connectingPlayers = new HashSet<String>();
|
||||
|
||||
private Region _region;
|
||||
private String _serverName;
|
||||
|
||||
public Portal(JavaPlugin plugin, CoreClientManager clientManager, String serverName)
|
||||
{
|
||||
@ -51,6 +52,7 @@ public class Portal extends MiniPlugin
|
||||
_clientManager = clientManager;
|
||||
|
||||
_region = plugin.getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU;
|
||||
_serverName = serverName;
|
||||
_repository = ServerManager.getServerRepository(_region);
|
||||
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(getPlugin(), "BungeeCord");
|
||||
@ -216,6 +218,6 @@ public class Portal extends MiniPlugin
|
||||
|
||||
UtilPlayer.message(
|
||||
player,
|
||||
F.main(getName(), "You have been sent to " + C.cGold + serverName));
|
||||
F.main(getName(), "You have been sent from " + C.cGold + _serverName + C.cGray + " to " + C.cGold + serverName));
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import mineplex.serverdata.servers.ConnectionData;
|
||||
public class RedisConfig
|
||||
{
|
||||
// Failsafe values in case configuration is not provided
|
||||
private static final String DEFAULT_IP = "10.33.53.16";
|
||||
private static final String DEFAULT_IP = "10.3.203.80";
|
||||
private static final int DEFAULT_PORT = 6379;
|
||||
private static Random random = new Random(); // Utility random
|
||||
|
||||
|
@ -168,6 +168,8 @@ public abstract class Game implements Listener
|
||||
public boolean DeathOut = true;
|
||||
public boolean DeathDropItems = false;
|
||||
public boolean DeathMessages = true;
|
||||
public boolean AutomaticRespawn = true;
|
||||
|
||||
public double DeathSpectateSecs = 0;
|
||||
|
||||
public boolean QuitOut = true;
|
||||
|
@ -9,7 +9,6 @@ import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.core.hologram.Hologram.HologramTarget;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -33,6 +32,7 @@ public abstract class Challenge implements Listener
|
||||
private Location _center;
|
||||
|
||||
protected HashSet<Player> Completed = new HashSet<Player>();
|
||||
protected HashSet<Player> Lost = new HashSet<Player>();
|
||||
private HashSet<Block> _modifiedBlocks = new HashSet<Block>();
|
||||
protected int Places;
|
||||
private ChallengeType _challengeType;
|
||||
@ -43,6 +43,13 @@ public abstract class Challenge implements Listener
|
||||
_order = challengeName;
|
||||
_center = new Location(host.WorldData.World, 0, 0, 0);
|
||||
_challengeType = challengeType;
|
||||
|
||||
setBorder(-100, 100, 0, 256, -100, 100);
|
||||
}
|
||||
|
||||
public long getMaxTime()
|
||||
{
|
||||
return 60000;
|
||||
}
|
||||
|
||||
public HashSet<Block> getModifiedBlocks()
|
||||
@ -66,16 +73,9 @@ public abstract class Challenge implements Listener
|
||||
}
|
||||
|
||||
protected void addBlock(Block block)
|
||||
{
|
||||
if (block.getType() == Material.AIR)
|
||||
{
|
||||
_modifiedBlocks.remove(block);
|
||||
}
|
||||
else
|
||||
{
|
||||
_modifiedBlocks.add(block);
|
||||
}
|
||||
}
|
||||
|
||||
public void StartOrder()
|
||||
{
|
||||
@ -85,7 +85,7 @@ public abstract class Challenge implements Listener
|
||||
|
||||
StartTime = System.currentTimeMillis();
|
||||
|
||||
Duration = 60000;
|
||||
Duration = getMaxTime();
|
||||
|
||||
Places = (int) Math.ceil(getChallengers().size() / 2D);
|
||||
}
|
||||
@ -141,11 +141,11 @@ public abstract class Challenge implements Listener
|
||||
return Host.isInsideMap(player.getLocation());
|
||||
}
|
||||
|
||||
public final boolean Finish()
|
||||
public boolean Finish()
|
||||
{
|
||||
ArrayList<Player> players = getChallengers();
|
||||
|
||||
if (players.isEmpty())
|
||||
if (players.size() <= Completed.size())
|
||||
return true;
|
||||
|
||||
if (_challengeType == ChallengeType.LastStanding)
|
||||
@ -186,10 +186,14 @@ public abstract class Challenge implements Listener
|
||||
UtilInv.Clear(player);
|
||||
}
|
||||
|
||||
public HashSet<Player> getLost()
|
||||
{
|
||||
return Lost;
|
||||
}
|
||||
|
||||
public void setLost(Player player)
|
||||
{
|
||||
Host.LoseLife(player, false);
|
||||
Host.Manager.addSpectator(player, true);
|
||||
UtilInv.Clear(player);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.mineware;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
import org.bukkit.Location;
|
||||
@ -11,7 +12,8 @@ import org.bukkit.entity.Player;
|
||||
public abstract class ChallengeSeperateRooms extends Challenge
|
||||
{
|
||||
private HashMap<String, Integer[]> _borders = new HashMap<String, Integer[]>();
|
||||
private HashMap<Location, Integer[]> _spawns = new HashMap<Location, Integer[]>();
|
||||
private HashMap<Location, Entry<Integer[], Location>> _spawns = new HashMap<Location, Entry<Integer[], Location>>();
|
||||
private HashMap<String, Location> _rooms = new HashMap<String, Location>();
|
||||
private double _borderX, _borderZ;
|
||||
|
||||
public ChallengeSeperateRooms(MineWare host, ChallengeType challengeType, String challengeName)
|
||||
@ -19,15 +21,23 @@ public abstract class ChallengeSeperateRooms extends Challenge
|
||||
super(host, challengeType, challengeName);
|
||||
}
|
||||
|
||||
public Location getRoom(Player player)
|
||||
{
|
||||
System.out.print("2. " + player.getName());
|
||||
return _rooms.get(player.getName()).clone();
|
||||
}
|
||||
|
||||
public void assignRooms()
|
||||
{
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
for (Entry<Location, Integer[]> entry : _spawns.entrySet())
|
||||
for (Entry<Location, Entry<Integer[], Location>> entry : _spawns.entrySet())
|
||||
{
|
||||
if (entry.getKey().distance(player.getLocation()) < 1)
|
||||
{
|
||||
_borders.put(player.getName(), entry.getValue());
|
||||
System.out.print("1. " + player.getName());
|
||||
_rooms.put(player.getName(), entry.getValue().getValue());
|
||||
_borders.put(player.getName(), entry.getValue().getKey());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -78,14 +88,14 @@ public abstract class ChallengeSeperateRooms extends Challenge
|
||||
|
||||
generateRoom(loc.clone());
|
||||
|
||||
_spawns.put(getSpawn(loc.clone()), new Integer[]
|
||||
_spawns.put(getSpawn(loc.clone()), new HashMap.SimpleEntry(new Integer[]
|
||||
{
|
||||
loc.getBlockX(), loc.getBlockX() + getBorderX(),
|
||||
|
||||
loc.getBlockY(), loc.getBlockY() + getBorderY(),
|
||||
|
||||
loc.getBlockZ(), loc.getBlockZ() + getBorderZ()
|
||||
});
|
||||
}, loc.clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -113,7 +123,7 @@ public abstract class ChallengeSeperateRooms extends Challenge
|
||||
|
||||
public Location getSpawn(Location roomLocation)
|
||||
{
|
||||
return roomLocation.clone().add(getBorderX() / 2D, 1, getBorderZ() / 2D);
|
||||
return roomLocation.clone().add((getBorderX() + 1) / 2D, 1.1, (getBorderZ() + 1) / 2D);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,12 +5,11 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -27,6 +26,8 @@ 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.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTextTop;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
@ -44,17 +45,16 @@ import nautilus.game.arcade.kit.Kit;
|
||||
public class MineWare extends SoloGame
|
||||
{
|
||||
private HashMap<Player, Integer> _lives = new HashMap<Player, Integer>();
|
||||
private HashSet<Player> _killed = new HashSet<Player>();
|
||||
|
||||
private Challenge _order;
|
||||
private ArrayList<Block> _lastOrderBlocks;
|
||||
private long _orderTime = 0;
|
||||
private boolean _orderWaiting;
|
||||
private long _orderTime;
|
||||
private boolean _orderWaiting = true;
|
||||
|
||||
private ArrayList<Class<? extends Challenge>> _orders = new ArrayList<Class<? extends Challenge>>();
|
||||
private ArrayList<Class<? extends Challenge>> _ordersCopy = new ArrayList<Class<? extends Challenge>>();
|
||||
|
||||
public MineWare(ArcadeManager manager, String justSoError)
|
||||
public MineWare(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.MineWare,
|
||||
|
||||
@ -69,13 +69,16 @@ public class MineWare extends SoloGame
|
||||
"Last player with lives wins!"
|
||||
});
|
||||
|
||||
this.DamagePvP = false;
|
||||
DamageTeamSelf = true;
|
||||
DamagePvP = false;
|
||||
DamagePvE = false;
|
||||
DamageEvP = false;
|
||||
DamageFall = false;
|
||||
InventoryClick = true;
|
||||
DamageSelf = false;
|
||||
DeathOut = false;
|
||||
AutomaticRespawn = false;
|
||||
DeathMessages = false;
|
||||
|
||||
Manager.GetCreature().SetDisableCustomDrops(true);
|
||||
|
||||
@ -92,9 +95,8 @@ public class MineWare extends SoloGame
|
||||
|
||||
for (Player player : GetPlayers(false))
|
||||
{
|
||||
if (_lives.containsKey(player) && _lives.get(player) > 0)
|
||||
if (GetLives(player) > 0)
|
||||
{
|
||||
System.out.print(player.getName() + " is living");
|
||||
living++;
|
||||
}
|
||||
}
|
||||
@ -102,7 +104,6 @@ public class MineWare extends SoloGame
|
||||
if (living <= 1)
|
||||
{
|
||||
SetState(GameState.End);
|
||||
System.out.print("End game");
|
||||
AnnounceEnd(getWinners());
|
||||
}
|
||||
}
|
||||
@ -110,7 +111,7 @@ public class MineWare extends SoloGame
|
||||
@Override
|
||||
public boolean isInsideMap(Player player)
|
||||
{
|
||||
if (_order != null)
|
||||
if (_order != null && !_orderWaiting)
|
||||
{
|
||||
return _order.isInsideMap(player);
|
||||
}
|
||||
@ -126,30 +127,27 @@ public class MineWare extends SoloGame
|
||||
return;
|
||||
}
|
||||
|
||||
UtilServer.getServer().getPluginManager().registerEvents(_order, Manager.getPlugin());
|
||||
|
||||
if (_order instanceof ChallengeSeperateRooms)
|
||||
{
|
||||
((ChallengeSeperateRooms) _order).assignRooms();
|
||||
}
|
||||
|
||||
_order.StartOrder();
|
||||
|
||||
sayChallenge(_order);
|
||||
_orderTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void PopulateOrders()
|
||||
{
|
||||
//_orders.add(ChallengeShootChickens.class);
|
||||
//_orders.add(ChallengeStandOnColor.class);
|
||||
_orders.add(ChallengePickASide.class);
|
||||
//_orders.add(ChallengeMilkACow.class);
|
||||
_orders.add(ChallengeHitTargets.class);
|
||||
_orders.add(ChallengeNavigateMaze.class);
|
||||
//_orders.add(ChallengeDragonEgg.class);
|
||||
_orders.add(ChallengeBlockShot.class);
|
||||
//_orders.add(ChallengeChestLoot.class);
|
||||
_orders.add(ChallengeShootChickens.class);
|
||||
_orders.add(ChallengeStandOnColor.class);
|
||||
_orders.add(ChallengeMilkACow.class);
|
||||
_orders.add(ChallengeDragonEgg.class);
|
||||
// _orders.add(ChallengeBlockShot.class);
|
||||
_orders.add(ChallengeChestLoot.class);
|
||||
_orders.add(ChallengeLavaRun.class);
|
||||
_orders.add(ChallengeNavigateMaze.class);
|
||||
// _orders.add(ChallengePickASide.class);
|
||||
_orders.add(ChallengeHitTargets.class);
|
||||
// _orders.add(ChallengeNameThatSound.class);
|
||||
_orders.add(ChallengeVolleyPig.class);
|
||||
// _orders.add(ChallengeSkyFall.class);
|
||||
_orders.add(ChallengeSmashOff.class);
|
||||
_orders.add(ChallengeTntLauncher.class);
|
||||
// _orders.add(ChallengeDiamondFall.class);
|
||||
}
|
||||
|
||||
public Challenge GetOrder()
|
||||
@ -197,7 +195,7 @@ public class MineWare extends SoloGame
|
||||
return;
|
||||
|
||||
for (Player player : GetPlayers(true))
|
||||
_lives.put(player, 5); // TODO
|
||||
_lives.put(player, 5);
|
||||
|
||||
_order = GetOrder();
|
||||
_order.generateRoom();
|
||||
@ -206,6 +204,24 @@ public class MineWare extends SoloGame
|
||||
SpectatorSpawn = UtilWorld.averageLocation(_order.getSpawns()).add(0, 7, 0);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void CancelOrder(GameStateChangeEvent event)
|
||||
{
|
||||
if (_order == null)
|
||||
return;
|
||||
|
||||
if (_orderWaiting)
|
||||
return;
|
||||
|
||||
if (event.GetState() == GameState.Live)
|
||||
return;
|
||||
|
||||
// Deregister
|
||||
HandlerList.unregisterAll(_order);
|
||||
|
||||
_order.EndOrder();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDamage(CustomDamageEvent event)
|
||||
{
|
||||
@ -215,24 +231,13 @@ public class MineWare extends SoloGame
|
||||
@EventHandler
|
||||
public void onDeath(PlayerDeathEvent event)
|
||||
{
|
||||
_killed.add(event.getEntity());
|
||||
|
||||
if (_order == null)
|
||||
return;
|
||||
|
||||
_order.getLost().add(event.getEntity());
|
||||
LoseLife(event.getEntity(), true);
|
||||
}
|
||||
|
||||
public boolean IsAlive(Entity entity)
|
||||
{
|
||||
if (_killed.contains(entity))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return super.IsAlive(entity);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event)
|
||||
{
|
||||
@ -243,7 +248,7 @@ public class MineWare extends SoloGame
|
||||
{
|
||||
ArrayList<Player> challengers = new ArrayList<Player>();
|
||||
|
||||
for (Player player : GetPlayers(false))
|
||||
for (Player player : GetPlayers(true))
|
||||
{
|
||||
if (!UtilPlayer.isSpectator(player))
|
||||
{
|
||||
@ -259,9 +264,10 @@ public class MineWare extends SoloGame
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 1f);
|
||||
String message = C.cYellow + C.Bold + (IsAlive(player) ? challenge.getMessage(player) : challenge.GetOrder());
|
||||
|
||||
UtilPlayer.message(player,
|
||||
C.cYellow + C.Bold + (IsAlive(player) ? challenge.getMessage(player) : challenge.GetOrder()));
|
||||
UtilPlayer.message(player, message);
|
||||
UtilTextMiddle.display(message, null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -285,6 +291,9 @@ public class MineWare extends SoloGame
|
||||
if (!_orderWaiting)
|
||||
return;
|
||||
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (!IsAlive(event.getPlayer()))
|
||||
return;
|
||||
|
||||
@ -314,14 +323,12 @@ public class MineWare extends SoloGame
|
||||
|
||||
for (Player player : GetPlayers(false))
|
||||
{
|
||||
if (_killed.contains(player) && _lives.get(player) > 0)
|
||||
if (_lives.containsKey(player) && _lives.get(player) > 0)
|
||||
{
|
||||
Manager.Clear(player);
|
||||
}
|
||||
}
|
||||
|
||||
_killed.clear();
|
||||
|
||||
_order = GetOrder();
|
||||
|
||||
if (_order == null)
|
||||
@ -343,12 +350,58 @@ public class MineWare extends SoloGame
|
||||
|
||||
_order.generateRoom();
|
||||
|
||||
ArrayList<Location> spawns = _order.getSpawns();
|
||||
|
||||
GetTeamList().get(0).SetSpawns(_order.getSpawns());
|
||||
SpectatorSpawn = UtilWorld.averageLocation(_order.getSpawns()).add(0, 7, 0);
|
||||
SpectatorSpawn = UtilWorld.averageLocation(spawns).add(0, 7, 0);
|
||||
|
||||
ArrayList<Location> toTeleport = new ArrayList<Location>();
|
||||
|
||||
for (int i = 0; i < spawns.size(); i++)
|
||||
{
|
||||
Location furthest = null;
|
||||
double furthestDist = 0;
|
||||
|
||||
for (Location spawn : spawns)
|
||||
{
|
||||
if (toTeleport.contains(spawn))
|
||||
continue;
|
||||
|
||||
double dist = 0;
|
||||
|
||||
for (Location loc : toTeleport)
|
||||
{
|
||||
dist += loc.distance(spawn);
|
||||
}
|
||||
|
||||
if (furthest == null || furthestDist < dist)
|
||||
{
|
||||
furthest = spawn;
|
||||
furthestDist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
toTeleport.add(furthest);
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
player.teleport(GetTeamList().get(0).GetSpawn());
|
||||
player.teleport(toTeleport.get(i++));
|
||||
|
||||
if (i >= toTeleport.size())
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (Player player : GetPlayers(false))
|
||||
{
|
||||
if (!IsAlive(player))
|
||||
{
|
||||
player.teleport(SpectatorSpawn);
|
||||
}
|
||||
}
|
||||
|
||||
if (_order instanceof ChallengeSeperateRooms)
|
||||
@ -387,11 +440,12 @@ public class MineWare extends SoloGame
|
||||
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
getArcadeManager().GetDisguise().undisguise(player);
|
||||
UtilInv.Clear(player);
|
||||
|
||||
if (_order.hasWinner() && !_order.IsCompleted(player))
|
||||
{
|
||||
LoseLife(player, false);
|
||||
LoseLife(player, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -421,6 +475,8 @@ public class MineWare extends SoloGame
|
||||
// Set Level
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
UtilTextTop.display(C.cYellow + C.Bold + (IsAlive(player) ? _order.getMessage(player) : _order.GetOrder()),
|
||||
player);
|
||||
player.setLevel(_order.GetRemainingPlaces());
|
||||
player.setExp(_order.GetTimeLeftPercent());
|
||||
}
|
||||
@ -438,18 +494,27 @@ public class MineWare extends SoloGame
|
||||
|
||||
public void LoseLife(Player player, boolean isDeath)
|
||||
{
|
||||
int lives = GetLives(player) - 1;
|
||||
if (!isDeath)
|
||||
{
|
||||
Manager.addSpectator(player, true);
|
||||
}
|
||||
|
||||
if (_order == null || _order.IsCompleted(player))
|
||||
return;
|
||||
|
||||
int lives = GetLives(player);
|
||||
|
||||
lives -= 1;
|
||||
_lives.put(player, lives);
|
||||
|
||||
if (lives > 0)
|
||||
{
|
||||
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);
|
||||
|
||||
_lives.put(player, lives);
|
||||
}
|
||||
else
|
||||
{System.out.print(player.getName() + " list");
|
||||
{
|
||||
UtilPlayer.message(player, C.cRed + C.Bold + "You are out of the game!");
|
||||
player.playSound(player.getLocation(), Sound.EXPLODE, 2f, 1f);
|
||||
|
||||
@ -457,7 +522,7 @@ public class MineWare extends SoloGame
|
||||
|
||||
SetPlayerState(player, PlayerState.OUT);
|
||||
|
||||
if (!isDeath)
|
||||
if (isDeath)
|
||||
{
|
||||
Manager.addSpectator(player, true);
|
||||
}
|
||||
|
@ -81,13 +81,19 @@ public class ChallengeChestLoot extends Challenge
|
||||
{
|
||||
for (int z = -7; z <= 7; z++)
|
||||
{
|
||||
Block b = getCenter().getBlock().getRelative(x, 1, z);
|
||||
Block b = getCenter().getBlock().getRelative(x, 0, z);
|
||||
b.setType(Material.STAINED_CLAY);
|
||||
b.setData((byte) UtilMath.r(16));
|
||||
|
||||
addBlock(b);
|
||||
|
||||
if (Math.abs(x) % 2 == 0 && Math.abs(z) % 2 == 0)
|
||||
{
|
||||
b.setType(Material.CHEST);
|
||||
Block block = b.getRelative(0, 1, 0);
|
||||
block.setType(Material.CHEST);
|
||||
addBlock(block);
|
||||
|
||||
Inventory inventory = ((Chest) b.getState()).getInventory();
|
||||
Inventory inventory = ((Chest) block.getState()).getInventory();
|
||||
invs.add(inventory);
|
||||
|
||||
for (int i = 0; i < inventory.getSize(); i++)
|
||||
@ -105,16 +111,11 @@ public class ChallengeChestLoot extends Challenge
|
||||
}
|
||||
else
|
||||
{
|
||||
b.setType(Material.STAINED_CLAY);
|
||||
b.setData((byte) UtilMath.r(16));
|
||||
|
||||
Block block = b.getRelative(BlockFace.UP);
|
||||
block.setType(Material.STAINED_CLAY);
|
||||
block.setData((byte) UtilMath.r(16));
|
||||
addBlock(block);
|
||||
}
|
||||
|
||||
addBlock(b);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,168 @@
|
||||
package nautilus.game.arcade.game.games.mineware.challenges;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import nautilus.game.arcade.game.games.mineware.Challenge;
|
||||
import nautilus.game.arcade.game.games.mineware.MineWare;
|
||||
|
||||
public class ChallengeDiamondFall extends Challenge
|
||||
{
|
||||
|
||||
public ChallengeDiamondFall(MineWare host)
|
||||
{
|
||||
super(host, ChallengeType.LastStanding, "Loot the most diamonds from chests!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean Finish()
|
||||
{
|
||||
if (super.Finish())
|
||||
{
|
||||
final HashMap<Player, Integer> diamonds = new HashMap<Player, Integer>();
|
||||
ArrayList<Player> players = getChallengers();
|
||||
|
||||
for (Player player : players)
|
||||
{
|
||||
int diamond = 0;
|
||||
|
||||
for (ItemStack item : UtilInv.getItems(player))
|
||||
{
|
||||
if (item != null && item.getType() == Material.DIAMOND)
|
||||
{
|
||||
diamond += item.getAmount();
|
||||
}
|
||||
}
|
||||
|
||||
diamonds.put(player, diamond);
|
||||
}
|
||||
|
||||
Collections.sort(players, new Comparator<Player>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public int compare(Player o1, Player o2)
|
||||
{
|
||||
return diamonds.get(o2).compareTo(diamonds.get(o1));
|
||||
}
|
||||
});
|
||||
|
||||
for (int places = 0; places < Math.min(players.size(), Places); places++)
|
||||
{
|
||||
SetCompleted(players.get(places));
|
||||
}
|
||||
}
|
||||
|
||||
return super.Finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxTime()
|
||||
{
|
||||
return 30000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Location> getSpawns()
|
||||
{
|
||||
ArrayList<Location> locations = new ArrayList<Location>();
|
||||
|
||||
for (int x = -3; x <= 3; x++)
|
||||
{
|
||||
for (int z = -3; z <= 3; z++)
|
||||
{
|
||||
locations.add(getCenter().add(x + 0.5, 201.5, z + 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
return locations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateRoom()
|
||||
{
|
||||
for (int x = -3; x <= 3; x++)
|
||||
{
|
||||
for (int z = -3; z <= 3; z++)
|
||||
{
|
||||
Block block = getCenter().getBlock().getRelative(x, 200, z);
|
||||
block.setType(Material.STAINED_GLASS);
|
||||
addBlock(block);
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = -5; x <= 5; x++)
|
||||
{
|
||||
for (int z = -5; z <= 5; z++)
|
||||
{
|
||||
Block block = getCenter().getBlock().getRelative(x, 0, z);
|
||||
block.setType(Material.STAINED_CLAY);
|
||||
block.setData((byte) UtilMath.r(16));
|
||||
addBlock(block);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 70; i++)
|
||||
{
|
||||
int y = UtilMath.r(160) + 10;
|
||||
|
||||
Block b = getCenter().getBlock().getRelative(UtilMath.r(16) - 8, y, UtilMath.r(16) - 8);
|
||||
boolean chestFound = false;
|
||||
|
||||
for (BlockFace face : new BlockFace[]
|
||||
{
|
||||
BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH
|
||||
})
|
||||
{
|
||||
Block block = b.getRelative(face);
|
||||
|
||||
if (block.getType() != Material.AIR)
|
||||
{
|
||||
chestFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (chestFound)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
b.setType(Material.CHEST);
|
||||
|
||||
addBlock(b);
|
||||
|
||||
Inventory inventory = ((Chest) b.getState()).getInventory();
|
||||
|
||||
for (int a = 0; a < UtilMath.r(5); a++)
|
||||
{
|
||||
inventory.setItem(UtilMath.r(inventory.getSize()), new ItemStack(Material.DIAMOND));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanupRoom()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupPlayers()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
@ -92,6 +92,11 @@ public class ChallengeDragonEgg extends Challenge
|
||||
(byte) 0);
|
||||
_dragonEggs.add(entity);
|
||||
|
||||
for (int y = 0; y <= 2; y++)
|
||||
{
|
||||
addBlock(b.getRelative(0, y, 0));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -117,16 +122,6 @@ public class ChallengeDragonEgg extends Challenge
|
||||
@Override
|
||||
public void cleanupRoom()
|
||||
{
|
||||
for (int x = -15; x <= 15; x++)
|
||||
{
|
||||
for (int z = -15; z <= 15; z++)
|
||||
{
|
||||
Block b = getCenter().getBlock().getRelative(x, 1, z);
|
||||
|
||||
addBlock(b);
|
||||
}
|
||||
}
|
||||
|
||||
for (Entity ent : _dragonEggs)
|
||||
{
|
||||
ent.remove();
|
||||
|
@ -31,18 +31,20 @@ public class ChallengeHitTargets extends Challenge
|
||||
@EventHandler
|
||||
public void onDamage(CustomDamageEvent event)
|
||||
{
|
||||
if (UtilPlayer.isSpectator(event.GetDamageePlayer()))
|
||||
Player p = event.GetDamagerPlayer(true);
|
||||
|
||||
if (p == null || UtilPlayer.isSpectator(p))
|
||||
return;
|
||||
|
||||
if (!(event.GetDamageeEntity() instanceof Player))
|
||||
if (event.GetDamageePlayer() == null)
|
||||
return;
|
||||
|
||||
Player p = event.GetDamageePlayer();
|
||||
|
||||
if (!_targets.containsKey(p.getName()))
|
||||
return;
|
||||
|
||||
String name = ((Player) event.GetDamageeEntity()).getName();
|
||||
event.SetCancelled("No damage");
|
||||
|
||||
String name = event.GetDamageePlayer().getName();
|
||||
|
||||
ArrayList<String> targets = _targets.get(p.getName());
|
||||
|
||||
@ -50,7 +52,7 @@ public class ChallengeHitTargets extends Challenge
|
||||
{
|
||||
p.playSound(p.getLocation(), Sound.NOTE_PLING, 1f, 1f);
|
||||
|
||||
UtilPlayer.message(p, "Hit the players " + StringUtils.join(targets, C.cWhite + C.Bold + ", " + C.cYellow + C.Bold));
|
||||
UtilPlayer.message(p, C.cYellow + "They are not your target! " + getMessage(p));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -66,8 +68,8 @@ public class ChallengeHitTargets extends Challenge
|
||||
@Override
|
||||
public String getMessage(Player player)
|
||||
{
|
||||
return "Hit the players "
|
||||
+ StringUtils.join(_targets.get(player.getName()), C.cWhite + C.Bold + ", " + C.cYellow + C.Bold);
|
||||
return C.cYellow + "Hit the players " + C.cWhite
|
||||
+ StringUtils.join(_targets.get(player.getName()), C.cYellow + ", " + C.cWhite);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -98,12 +100,14 @@ public class ChallengeHitTargets extends Challenge
|
||||
@Override
|
||||
public void cleanupRoom()
|
||||
{
|
||||
Host.DamagePvP = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupPlayers()
|
||||
{
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
Host.DamagePvP = true;
|
||||
ArrayList<Player> players = getChallengers();
|
||||
|
||||
for (Player player : players)
|
||||
{
|
||||
@ -131,15 +135,15 @@ public class ChallengeHitTargets extends Challenge
|
||||
@Override
|
||||
public void generateRoom()
|
||||
{
|
||||
for (int x = -10; x <= 10; x++)
|
||||
for (int x = -12; x <= 12; x++)
|
||||
{
|
||||
for (int z = -10; z <= 10; z++)
|
||||
for (int z = -12; z <= 12; z++)
|
||||
{
|
||||
Block b = getCenter().clone().add(x, 0, z).getBlock();
|
||||
b.setType(Material.SMOOTH_BRICK);
|
||||
addBlock(b);
|
||||
|
||||
if (Math.abs(x) > 1 && Math.abs(x) < 9 && Math.abs(z) > 1 && Math.abs(z) < 9)
|
||||
if (Math.abs(x) > 1 && Math.abs(x) < 8 && Math.abs(z) > 1 && Math.abs(z) < 8)
|
||||
{
|
||||
for (int y = 1; y < 3; y++)
|
||||
{
|
||||
|
@ -8,6 +8,8 @@ import java.util.HashMap;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.disguise.disguises.DisguiseMagmaCube;
|
||||
import mineplex.core.disguise.disguises.DisguiseVillager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
@ -25,6 +27,8 @@ import org.bukkit.event.EventHandler;
|
||||
public class ChallengeLavaRun extends Challenge
|
||||
{
|
||||
private long _delay;
|
||||
private long _minusDelay = 1000;
|
||||
private int _disappearingBlocks = 10;
|
||||
private Location _obsidian;
|
||||
|
||||
public ChallengeLavaRun(MineWare host)
|
||||
@ -67,7 +71,7 @@ public class ChallengeLavaRun extends Challenge
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UtilTime.elapsed(_delay, 2000))
|
||||
if (_delay > System.currentTimeMillis())
|
||||
return;
|
||||
|
||||
if (_obsidian == null)
|
||||
@ -89,6 +93,11 @@ public class ChallengeLavaRun extends Challenge
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
player.playSound(player.getLocation(), Sound.NOTE_PIANO, 2f, 0f);
|
||||
|
||||
_delay = System.currentTimeMillis() + _minusDelay;
|
||||
_minusDelay -= 100;
|
||||
|
||||
_disappearingBlocks++;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -109,7 +118,7 @@ public class ChallengeLavaRun extends Challenge
|
||||
|
||||
if (glassBlocks.isEmpty())
|
||||
{
|
||||
_delay = System.currentTimeMillis();
|
||||
_delay = System.currentTimeMillis() + 1500;
|
||||
_obsidian = null;
|
||||
}
|
||||
else
|
||||
@ -131,7 +140,7 @@ public class ChallengeLavaRun extends Challenge
|
||||
}
|
||||
});
|
||||
|
||||
for (int i = 0; i < Math.min(8, glassBlocks.size()); i++)
|
||||
for (int i = 0; i < Math.min(_disappearingBlocks, glassBlocks.size()); i++)
|
||||
{
|
||||
Block b = glassBlocks.remove(0);
|
||||
b.setTypeIdAndData(Material.AIR.getId(), (byte) 0, false);
|
||||
@ -149,6 +158,14 @@ public class ChallengeLavaRun extends Challenge
|
||||
@Override
|
||||
public void setupPlayers()
|
||||
{
|
||||
_delay = System.currentTimeMillis() + 2000;
|
||||
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
DisguiseMagmaCube disguise = new DisguiseMagmaCube(player);
|
||||
disguise.SetSize(2);
|
||||
Host.getArcadeManager().GetDisguise().disguise(disguise);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import java.util.HashMap;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.disguise.disguises.DisguiseVillager;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.game.games.mineware.Challenge;
|
||||
import nautilus.game.arcade.game.games.mineware.MineWare;
|
||||
@ -34,7 +35,7 @@ public class ChallengeMilkACow extends Challenge
|
||||
|
||||
public ChallengeMilkACow(MineWare host)
|
||||
{
|
||||
super(host, ChallengeType.FirstComplete, "Deliver 5 buckets of milk to the villager");
|
||||
super(host, ChallengeType.FirstComplete, "Milk 5 different cows and deliver to the villager!");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -74,6 +75,9 @@ public class ChallengeMilkACow extends Challenge
|
||||
|
||||
for (Player player : Host.GetPlayers(true))
|
||||
{
|
||||
DisguiseVillager disguise = new DisguiseVillager(player);
|
||||
disguise.setBaby();
|
||||
Host.getArcadeManager().GetDisguise().disguise(disguise);
|
||||
player.getInventory().setItem(0, new ItemStack(Material.BUCKET));
|
||||
_score.put(player.getName(), 0);
|
||||
}
|
||||
@ -125,6 +129,9 @@ public class ChallengeMilkACow extends Challenge
|
||||
Host.CreatureAllowOverride = true;
|
||||
_villager = (Villager) getCenter().getWorld().spawnEntity(getCenter().clone().add(0, 1, 0), EntityType.VILLAGER);
|
||||
_villager.setProfession(Profession.FARMER);
|
||||
_villager.setCustomName(C.Bold + "Farmer Joe");
|
||||
_villager.setCustomNameVisible(true);
|
||||
|
||||
String[] names = new String[]
|
||||
{
|
||||
"Tom", "Steve", "John", "Harry", "Andrew", "Daniel", "Jorge", "Jim"
|
||||
|
@ -0,0 +1,371 @@
|
||||
package nautilus.game.arcade.game.games.mineware.challenges;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.game.games.mineware.ChallengeSeperateRooms;
|
||||
import nautilus.game.arcade.game.games.mineware.MineWare;
|
||||
|
||||
public class ChallengeNameThatSound extends ChallengeSeperateRooms
|
||||
{
|
||||
private HashMap<EntityType, Sound[]> _sounds = new HashMap<EntityType, Sound[]>();
|
||||
private ArrayList<Entry<Entry<EntityType, Sound>, Float>> _toPlay = new ArrayList<Entry<Entry<EntityType, Sound>, Float>>();
|
||||
private HashMap<String, Integer> _currentState = new HashMap<String, Integer>();
|
||||
private HashMap<String, ArrayList<Entity>> _mobs = new HashMap<String, ArrayList<Entity>>();
|
||||
private HashMap<String, Long> _lastGuess = new HashMap<String, Long>();
|
||||
|
||||
public ChallengeNameThatSound(MineWare host)
|
||||
{
|
||||
super(host, ChallengeType.FirstComplete, "Hit the creature that makes the noises");
|
||||
|
||||
_sounds.put(EntityType.ZOMBIE, new Sound[]
|
||||
{
|
||||
Sound.ZOMBIE_DEATH, Sound.ZOMBIE_HURT, Sound.ZOMBIE_IDLE, Sound.ZOMBIE_INFECT, Sound.ZOMBIE_METAL,
|
||||
Sound.ZOMBIE_REMEDY, Sound.ZOMBIE_UNFECT
|
||||
});
|
||||
|
||||
_sounds.put(EntityType.PIG, new Sound[]
|
||||
{
|
||||
Sound.PIG_DEATH, Sound.PIG_IDLE
|
||||
});
|
||||
|
||||
_sounds.put(EntityType.CHICKEN, new Sound[]
|
||||
{
|
||||
Sound.CHICKEN_EGG_POP, Sound.CHICKEN_HURT, Sound.CHICKEN_IDLE
|
||||
});
|
||||
|
||||
/*_sounds.put(EntityType.SPIDER, new Sound[]
|
||||
{
|
||||
Sound.SPIDER_DEATH, Sound.SPIDER_IDLE
|
||||
});*/
|
||||
|
||||
_sounds.put(EntityType.IRON_GOLEM, new Sound[]
|
||||
{
|
||||
Sound.IRONGOLEM_DEATH, Sound.IRONGOLEM_HIT, Sound.IRONGOLEM_THROW
|
||||
});
|
||||
|
||||
_sounds.put(EntityType.ENDERMAN, new Sound[]
|
||||
{
|
||||
Sound.ENDERMAN_DEATH, Sound.ENDERMAN_HIT, Sound.ENDERMAN_IDLE, Sound.ENDERMAN_SCREAM, Sound.ENDERMAN_TELEPORT
|
||||
});
|
||||
|
||||
_sounds.put(EntityType.COW, new Sound[]
|
||||
{
|
||||
Sound.COW_HURT, Sound.COW_IDLE, Sound.COW_WALK
|
||||
});
|
||||
|
||||
_sounds.put(EntityType.HORSE, new Sound[]
|
||||
{
|
||||
Sound.HORSE_ANGRY, Sound.HORSE_BREATHE, Sound.HORSE_DEATH, Sound.HORSE_GALLOP, Sound.HORSE_ARMOR,
|
||||
Sound.HORSE_HIT, Sound.HORSE_IDLE
|
||||
});
|
||||
|
||||
_sounds.put(EntityType.OCELOT, new Sound[]
|
||||
{
|
||||
Sound.CAT_HISS, Sound.CAT_HIT, Sound.CAT_MEOW, Sound.CAT_PURR, Sound.CAT_PURREOW
|
||||
});
|
||||
|
||||
_sounds.put(EntityType.VILLAGER, new Sound[]
|
||||
{
|
||||
Sound.VILLAGER_DEATH, Sound.VILLAGER_HAGGLE, Sound.VILLAGER_HIT, Sound.VILLAGER_IDLE, Sound.VILLAGER_NO,
|
||||
Sound.VILLAGER_YES
|
||||
});
|
||||
|
||||
_sounds.put(EntityType.WOLF, new Sound[]
|
||||
{
|
||||
Sound.WOLF_BARK, Sound.WOLF_DEATH, Sound.WOLF_GROWL, Sound.WOLF_HURT, Sound.WOLF_PANT, Sound.WOLF_SHAKE,
|
||||
Sound.WOLF_WHINE
|
||||
});
|
||||
|
||||
_sounds.put(EntityType.PIG_ZOMBIE, new Sound[]
|
||||
{
|
||||
Sound.ZOMBIE_PIG_ANGRY, Sound.ZOMBIE_PIG_DEATH, Sound.ZOMBIE_PIG_HURT, Sound.ZOMBIE_PIG_IDLE
|
||||
});
|
||||
|
||||
_sounds.put(EntityType.SHEEP, new Sound[]
|
||||
{
|
||||
Sound.SHEEP_IDLE
|
||||
});
|
||||
|
||||
_sounds.put(EntityType.SKELETON, new Sound[]
|
||||
{
|
||||
Sound.SKELETON_DEATH, Sound.SKELETON_HURT, Sound.SKELETON_IDLE
|
||||
});
|
||||
|
||||
/*_sounds.put(EntityType.SLIME, new Sound[]
|
||||
{
|
||||
Sound.SLIME_ATTACK, Sound.SLIME_WALK, Sound.SLIME_WALK2, Sound.MAGMACUBE_JUMP, Sound.MAGMACUBE_WALK,
|
||||
Sound.MAGMACUBE_WALK2
|
||||
});*/
|
||||
|
||||
while (_toPlay.size() < 3)
|
||||
{
|
||||
EntityType entityType = EntityType.values()[UtilMath.r(EntityType.values().length)];
|
||||
|
||||
if (!_sounds.containsKey(entityType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean allClear = true;
|
||||
|
||||
for (Entry<Entry<EntityType, Sound>, Float> entry : _toPlay)
|
||||
{
|
||||
if (entry.getKey().getKey() == entityType)
|
||||
{
|
||||
allClear = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!allClear)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Sound sound = _sounds.get(entityType)[UtilMath.r(_sounds.get(entityType).length)];
|
||||
|
||||
_toPlay.add(new HashMap.SimpleEntry(new HashMap.SimpleEntry(entityType, sound), UtilMath.random.nextFloat() + 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnMobs(Player player, int stage)
|
||||
{
|
||||
if (!_mobs.containsKey(player.getName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Entity entity : _mobs.get(player.getName()))
|
||||
{
|
||||
entity.remove();
|
||||
}
|
||||
|
||||
if (stage > 2)
|
||||
return;
|
||||
|
||||
ArrayList<EntityType> entityType = new ArrayList<EntityType>();
|
||||
|
||||
for (EntityType type : _sounds.keySet())
|
||||
{
|
||||
entityType.add(type);
|
||||
}
|
||||
|
||||
entityType.remove(_toPlay.get(stage).getKey().getKey());
|
||||
|
||||
while (entityType.size() > 8)
|
||||
{
|
||||
entityType.remove(UtilMath.r(entityType.size()));
|
||||
}
|
||||
|
||||
entityType.add(_toPlay.get(stage).getKey().getKey());
|
||||
|
||||
Collections.shuffle(entityType);
|
||||
|
||||
Host.CreatureAllowOverride = true;
|
||||
|
||||
int i = 0;
|
||||
|
||||
for (int x = 1; x <= 9; x++)
|
||||
{
|
||||
for (int z = 1; z <= 9; z++)
|
||||
{
|
||||
if ((x == 3 && z == 3) || (x % 3 != 0 || z % 3 != 0))
|
||||
continue;
|
||||
|
||||
Location loc = getRoom(player).add(x, 1.1, z);
|
||||
|
||||
Entity entity = loc.getWorld().spawnEntity(loc, entityType.get(i++));
|
||||
|
||||
UtilEnt.Vegetate(entity, true);
|
||||
|
||||
_mobs.get(player.getName()).add(entity);
|
||||
}
|
||||
}
|
||||
|
||||
Host.CreatureAllowOverride = false;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEntityEvent event)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (UtilPlayer.isSpectator(player))
|
||||
return;
|
||||
|
||||
if (_lastGuess.containsKey(player.getName()) && !UtilTime.elapsed(_lastGuess.get(player.getName()), 3000))
|
||||
{
|
||||
player.sendMessage(F.main(
|
||||
"Guess",
|
||||
"Wait "
|
||||
+ UtilTime.convertString((_lastGuess.get(player.getName()) + 3000) - System.currentTimeMillis(), 1,
|
||||
TimeUnit.SECONDS) + " before next guess"));
|
||||
return;
|
||||
}
|
||||
|
||||
EntityType entityType = event.getRightClicked().getType();
|
||||
|
||||
int stage = _currentState.get(player.getName());
|
||||
|
||||
if (_toPlay.get(stage).getKey().getKey() == entityType)
|
||||
{
|
||||
stage++;
|
||||
displayCount(player, event.getRightClicked().getLocation(), stage == 1 ? C.cRed : stage == 2 ? C.cGreen : C.cDGreen);
|
||||
spawnMobs(player, stage);
|
||||
|
||||
if (stage < 3)
|
||||
{
|
||||
player.playSound(player.getLocation(), _toPlay.get(stage).getKey().getValue(), 5, _toPlay.get(stage).getValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
SetCompleted(player);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_lastGuess.put(player.getName(), System.currentTimeMillis());
|
||||
player.playSound(player.getLocation(), Sound.NOTE_BASS_DRUM, 2, 0);
|
||||
player.sendMessage(F.main("Name that sound", "Bad guess!"));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTwoSeconds(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TWOSEC)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
int stage = _currentState.get(player.getName());
|
||||
|
||||
if (stage < 3)
|
||||
{
|
||||
player.playSound(player.getLocation(), _toPlay.get(stage).getKey().getValue(), 5, _toPlay.get(stage).getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onAttack(CustomDamageEvent event)
|
||||
{
|
||||
if (event.GetDamagerPlayer(true) == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
onInteract(new PlayerInteractEntityEvent(event.GetDamagerPlayer(true), event.GetDamageeEntity()));
|
||||
|
||||
event.SetCancelled("No damage");
|
||||
event.GetDamageeEntity().setFireTicks(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateRoom(Location loc)
|
||||
{
|
||||
for (int x = 0; x <= 10; x++)
|
||||
{
|
||||
for (int z = 0; z <= 10; z++)
|
||||
{
|
||||
if (x == 0 || x == 10 || z == 0 || z == 10)
|
||||
{
|
||||
for (int y = 1; y <= 5; y++)
|
||||
{
|
||||
Block b = loc.getBlock().getRelative(x, y, z);
|
||||
b.setType(Material.COAL_BLOCK);
|
||||
addBlock(b);
|
||||
}
|
||||
}
|
||||
|
||||
Block b = loc.getBlock().getRelative(x, 0, z);
|
||||
b.setType(Material.WOOL);
|
||||
addBlock(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBorderX()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBorderY()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBorderZ()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDividersX()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDividersZ()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanupRoom()
|
||||
{
|
||||
for (ArrayList<Entity> entityList : _mobs.values())
|
||||
{
|
||||
for (Entity entity : entityList)
|
||||
{
|
||||
entity.remove();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupPlayers()
|
||||
{
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
_currentState.put(player.getName(), 0);
|
||||
_mobs.put(player.getName(), new ArrayList<Entity>());
|
||||
|
||||
spawnMobs(player, 0);
|
||||
player.playSound(player.getLocation(), _toPlay.get(0).getKey().getValue(), 5, _toPlay.get(0).getValue());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -18,7 +18,7 @@ public class ChallengeNavigateMaze extends Challenge
|
||||
|
||||
public ChallengeNavigateMaze(MineWare host)
|
||||
{
|
||||
super(host, ChallengeType.FirstComplete, "Make it to the other side of the maze");
|
||||
super(host, ChallengeType.FirstComplete, "Go to the other side of the maze");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -41,7 +41,7 @@ public class ChallengeNavigateMaze extends Challenge
|
||||
if (UtilPlayer.isSpectator(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (event.getTo().getY() >= 1 && event.getTo().getX() > 15)
|
||||
if (event.getTo().getY() >= 1 && event.getTo().getX() > 16)
|
||||
{
|
||||
SetCompleted(event.getPlayer());
|
||||
}
|
||||
@ -55,13 +55,13 @@ public class ChallengeNavigateMaze extends Challenge
|
||||
@Override
|
||||
public void setupPlayers()
|
||||
{
|
||||
setBorder(-20, 18, 0, 10, -20, 18);
|
||||
setBorder(-20, 22, 0, 10, -20, 22);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateRoom()
|
||||
{
|
||||
for (int x = -18; x <= 20; x++)
|
||||
for (int x = -18; x <= 21; x++)
|
||||
{
|
||||
for (int z = -12; z <= 15; z++)
|
||||
{
|
||||
@ -78,7 +78,7 @@ public class ChallengeNavigateMaze extends Challenge
|
||||
}
|
||||
}
|
||||
|
||||
if (x > 14 || x < -12)
|
||||
if (x > 15 || x < -12)
|
||||
{
|
||||
b.setType(Material.WOOL);
|
||||
b.setData((byte) (x < 0 ? 14 : 13));
|
||||
@ -174,14 +174,14 @@ public class ChallengeNavigateMaze extends Challenge
|
||||
private ArrayList<Block> generateMaze()
|
||||
{
|
||||
ArrayList<Block> blocks = new ArrayList<Block>();
|
||||
int[][] maze = new MazeGenerator(10, 10).getMaze();
|
||||
int[][] maze = new MazeGenerator(11, 10).getMaze();
|
||||
|
||||
// Divisable by 2's are up and down walls
|
||||
// Other's are left and right. All walls have a corner block.
|
||||
|
||||
// This means I need to loop over all of the blocks, figure out if its a corner if yes then set block
|
||||
// Else if its a wall, then figure out if I'm making the wall or not
|
||||
for (int x = 1; x < 10; x++)
|
||||
for (int x = 1; x < 11; x++)
|
||||
{
|
||||
for (int z = 1; z < 10; z++)
|
||||
{
|
||||
@ -200,7 +200,7 @@ public class ChallengeNavigateMaze extends Challenge
|
||||
}
|
||||
|
||||
// Set blocks for x
|
||||
if ((maze[x][z] & 8) == 0)
|
||||
if (x < 10 && (maze[x][z] & 8) == 0)
|
||||
{
|
||||
for (int i = 1; i <= 2; i++)
|
||||
{
|
||||
|
@ -61,6 +61,7 @@ public class ChallengePickASide extends Challenge
|
||||
public void setupPlayers()
|
||||
{
|
||||
setBorder(-10, 10, 0, 10, -10, 10);
|
||||
_stageExpires = System.currentTimeMillis() + 4000;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -99,19 +100,15 @@ public class ChallengePickASide extends Challenge
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
Location loc = player.getLocation();
|
||||
|
||||
while (loc.getBlockY() > 0 && loc.getBlock().getType() != Material.STAINED_CLAY)
|
||||
{
|
||||
loc.add(0, -1, 0);
|
||||
}
|
||||
loc.setY(0);
|
||||
|
||||
byte data = loc.getBlock().getType() == Material.STAINED_CLAY ? loc.getBlock().getData() : 0;
|
||||
|
||||
if (data == 11)
|
||||
if (data == 14)
|
||||
{
|
||||
red.add(player);
|
||||
}
|
||||
else if (data == 14)
|
||||
else if (data == 11)
|
||||
{
|
||||
blue.add(player);
|
||||
}
|
||||
@ -149,7 +146,7 @@ public class ChallengePickASide extends Challenge
|
||||
}
|
||||
else if (!_isFalling)
|
||||
{
|
||||
UtilTextBottom.displayProgress((_stageExpires - System.currentTimeMillis()) / 8D, players);
|
||||
UtilTextBottom.displayProgress(1 - ((_stageExpires - System.currentTimeMillis()) / 8000D), players);
|
||||
|
||||
if (_lastSound < System.currentTimeMillis())
|
||||
{
|
||||
|
@ -136,7 +136,7 @@ public class ChallengeShootChickens extends Challenge
|
||||
}
|
||||
}
|
||||
|
||||
if (_chickens.size() < 13)
|
||||
if (_chickens.size() < 11 + (getChallengers().size() * 2))
|
||||
{
|
||||
Location loc = getCenter().clone().add(UtilMath.r(20) - 10, 15, UtilMath.r(20) - 10);
|
||||
|
||||
|
@ -0,0 +1,138 @@
|
||||
package nautilus.game.arcade.game.games.mineware.challenges;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.game.games.mineware.Challenge;
|
||||
import nautilus.game.arcade.game.games.mineware.MineWare;
|
||||
|
||||
public class ChallengeSkyFall extends Challenge
|
||||
{
|
||||
public ChallengeSkyFall(MineWare host)
|
||||
{
|
||||
super(host, ChallengeType.FirstComplete, "Land on the bottom pad, knock players around with snowballs!");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Location> getSpawns()
|
||||
{
|
||||
ArrayList<Location> locations = new ArrayList<Location>();
|
||||
|
||||
for (int x = -3; x <= 3; x++)
|
||||
{
|
||||
for (int z = -3; z <= 3; z++)
|
||||
{
|
||||
locations.add(getCenter().add(x + 0.5, 201.5, z + 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
return locations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanupRoom()
|
||||
{
|
||||
Host.DamageEvP = false;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSnowballDamage(CustomDamageEvent event)
|
||||
{
|
||||
if (event.GetDamageePlayer() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsCompleted(event.GetDamageePlayer()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.SetCancelled("Has completed already");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupPlayers()
|
||||
{
|
||||
setBorder(-50, 50, 0, 254, -50, 50);
|
||||
|
||||
Host.DamageEvP = true;
|
||||
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
player.getInventory().setItem(0, new ItemStack(Material.SNOW_BALL, 64));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTick(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
if (IsCompleted(player))
|
||||
continue;
|
||||
|
||||
double y = player.getLocation().getY();
|
||||
|
||||
if (player.isOnGround() && y < 3)
|
||||
{
|
||||
SetCompleted(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateRoom()
|
||||
{
|
||||
for (int x = -3; x <= 3; x++)
|
||||
{
|
||||
for (int z = -3; z <= 3; z++)
|
||||
{
|
||||
Block block = getCenter().getBlock().getRelative(x, 200, z);
|
||||
block.setType(Material.STAINED_GLASS);
|
||||
addBlock(block);
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = -1; x <= 1; x++)
|
||||
{
|
||||
for (int z = -1; z <= 1; z++)
|
||||
{
|
||||
Block block = getCenter().getBlock().getRelative(x, 0, z);
|
||||
block.setType(Material.STAINED_CLAY);
|
||||
block.setData((byte) UtilMath.r(16));
|
||||
addBlock(block);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 70; i++)
|
||||
{
|
||||
int y = UtilMath.r(160) + 10;
|
||||
|
||||
if (UtilMath.r(y) > 50)
|
||||
continue;
|
||||
|
||||
Block b = getCenter().getBlock().getRelative(UtilMath.r(16) - 8, y, UtilMath.r(16) - 8);
|
||||
|
||||
b.setType(Material.CARPET);
|
||||
b.setData((byte) UtilMath.r(16));
|
||||
|
||||
addBlock(b);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package nautilus.game.arcade.game.games.mineware.challenges;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import nautilus.game.arcade.game.games.mineware.Challenge;
|
||||
import nautilus.game.arcade.game.games.mineware.MineWare;
|
||||
|
||||
public class ChallengeSmashOff extends Challenge
|
||||
{
|
||||
private ArrayList<Location> _spawns = new ArrayList<Location>();
|
||||
|
||||
public ChallengeSmashOff(MineWare host)
|
||||
{
|
||||
super(host, ChallengeType.LastStanding, "Knock the other players off!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Location> getSpawns()
|
||||
{
|
||||
return _spawns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanupRoom()
|
||||
{
|
||||
Host.DamagePvP = false;
|
||||
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
player.setHealth(player.getMaxHealth());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupPlayers()
|
||||
{
|
||||
Host.DamagePvP = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateRoom()
|
||||
{
|
||||
int amount = (int) Math.ceil(Math.sqrt(getChallengers().size()));
|
||||
int a = UtilMath.r(16);
|
||||
|
||||
for (int pX = 0; pX < amount; pX++)
|
||||
{
|
||||
for (int pZ = 0; pZ < amount; pZ++)
|
||||
{
|
||||
_spawns.add(getCenter().add((pX * 4) + 1.5, 1.1, (pZ * 4) + 1.5));
|
||||
|
||||
for (int x = pX * 4; x < (pX * 4) + 2; x++)
|
||||
{
|
||||
for (int z = pZ * 4; z < (pZ * 4) + 2; z++)
|
||||
{
|
||||
Block b = getCenter().getBlock().getRelative(x, 0, z);
|
||||
b.setType(Material.STAINED_CLAY);
|
||||
b.setData((byte) a);
|
||||
|
||||
addBlock(b);
|
||||
}
|
||||
}
|
||||
|
||||
if (++a > 15)
|
||||
{
|
||||
a = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -29,7 +29,7 @@ public class ChallengeStandOnColor extends Challenge
|
||||
private boolean _isFalling;
|
||||
private long _lastSound;
|
||||
private long _stageExpires;
|
||||
private long _timeDelay = 5000;
|
||||
private long _timeDelay = 3000;
|
||||
|
||||
public ChallengeStandOnColor(MineWare host)
|
||||
{
|
||||
@ -143,7 +143,7 @@ public class ChallengeStandOnColor extends Challenge
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
player.playSound(player.getLocation(), Sound.NOTE_PIANO, 2f, 0f);
|
||||
|
||||
_timeDelay -= 800;
|
||||
_timeDelay *= 0.8;
|
||||
_isFalling = false;
|
||||
_stageExpires = System.currentTimeMillis() + _timeDelay;
|
||||
_currentColor = _colors.get(UtilMath.r(_colors.size()));
|
||||
|
@ -0,0 +1,141 @@
|
||||
package nautilus.game.arcade.game.games.mineware.challenges;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilShapes;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.game.games.mineware.Challenge;
|
||||
import nautilus.game.arcade.game.games.mineware.MineWare;
|
||||
|
||||
public class ChallengeTntLauncher extends Challenge
|
||||
{
|
||||
private ArrayList<Location> _spawns = new ArrayList<Location>();
|
||||
private ArrayList<Entity> _tnt = new ArrayList<Entity>();
|
||||
|
||||
public ChallengeTntLauncher(MineWare host)
|
||||
{
|
||||
super(host, ChallengeType.LastStanding, "Throw TNT, don't get knocked off!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Location> getSpawns()
|
||||
{
|
||||
return _spawns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanupRoom()
|
||||
{
|
||||
Host.Damage = true;
|
||||
|
||||
for (Entity tnt : _tnt)
|
||||
{
|
||||
tnt.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void Update(EntityExplodeEvent event)
|
||||
{
|
||||
if (!(event.getEntity() instanceof TNTPrimed))
|
||||
return;
|
||||
|
||||
if (!_tnt.remove(event.getEntity()))
|
||||
return;
|
||||
|
||||
HashMap<Player, Double> players = UtilPlayer.getInRadius(event.getLocation(),
|
||||
4 + ((System.currentTimeMillis() - StartTime) / 10000D));
|
||||
|
||||
for (Player player : players.keySet())
|
||||
{
|
||||
double mult = players.get(player) / 2;
|
||||
mult += (System.currentTimeMillis() - StartTime) / 20000D;
|
||||
|
||||
// Knockback
|
||||
UtilAction.velocity(player, UtilAlg.getTrajectory(event.getLocation(), player.getLocation()), 3 * mult, false, 0,
|
||||
0.5 + 2 * mult, 10, true);
|
||||
}
|
||||
|
||||
event.blockList().clear();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDamage(CustomDamageEvent event)
|
||||
{
|
||||
if (event.GetCause() != DamageCause.ENTITY_EXPLOSION)
|
||||
return;
|
||||
|
||||
event.SetCancelled("TNT no damage");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
UtilInv.Update(player);
|
||||
|
||||
if (!Recharge.Instance.use(player, "TNT", 3000, true, false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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))));
|
||||
|
||||
_tnt.add(tnt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupPlayers()
|
||||
{
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
player.getInventory().setItem(0, new ItemStack(Material.TNT));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateRoom()
|
||||
{
|
||||
double radius = 6 + (getChallengers().size() / 2D);
|
||||
|
||||
for (Location loc : UtilShapes.getCircle(getCenter(), false, radius))
|
||||
{
|
||||
Block block = loc.getBlock();
|
||||
|
||||
block.setType(Material.STAINED_CLAY);
|
||||
block.setData((byte) UtilMath.r(16));
|
||||
|
||||
addBlock(block);
|
||||
|
||||
if (Math.abs(block.getLocation().add(0.5, 0, 0.5).distance(getCenter().add(0.5, 0, 0.5)) - (radius - 2)) < 1)
|
||||
{
|
||||
_spawns.add(block.getLocation().add(0.5, 1.1, 0.5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,232 @@
|
||||
package nautilus.game.arcade.game.games.mineware.challenges;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Damageable;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextBottom;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.game.games.mineware.Challenge;
|
||||
import nautilus.game.arcade.game.games.mineware.MineWare;
|
||||
|
||||
public class ChallengeVolleyPig extends Challenge
|
||||
{
|
||||
private long _redSide;
|
||||
private long _blueSide;
|
||||
private Entity _pig;
|
||||
|
||||
public ChallengeVolleyPig(MineWare host)
|
||||
{
|
||||
super(host, ChallengeType.LastStanding, "Keep the pig on the other side and stack up the time!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Location> getSpawns()
|
||||
{
|
||||
ArrayList<Location> locations = new ArrayList<Location>();
|
||||
|
||||
for (int x = -5; x <= 5; x++)
|
||||
{
|
||||
for (int z = -9; z <= 9; z++)
|
||||
{
|
||||
if (z == 0)
|
||||
continue;
|
||||
|
||||
locations.add(getCenter().add(x + 0.5, 1.1, z + 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
return locations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanupRoom()
|
||||
{
|
||||
_pig.remove();
|
||||
Host.DamagePvE = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupPlayers()
|
||||
{
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
player.getInventory().setItem(0, new ItemBuilder(Material.STICK).addEnchantment(Enchantment.KNOCKBACK, 1).build());
|
||||
}
|
||||
|
||||
Host.DamagePvE = true;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onMove(PlayerMoveEvent event)
|
||||
{
|
||||
if (UtilPlayer.isSpectator(event.getPlayer()))
|
||||
return;
|
||||
|
||||
Location from = event.getFrom().clone();
|
||||
from.setY(0);
|
||||
|
||||
Block bFrom = from.getBlock();
|
||||
|
||||
if (bFrom.getType() != Material.STAINED_CLAY)
|
||||
return;
|
||||
|
||||
Location to = event.getTo().clone();
|
||||
to.setY(0);
|
||||
|
||||
Block bTo = to.getBlock();
|
||||
|
||||
if (bTo.getType() == Material.AIR || bTo.getData() != bFrom.getData())
|
||||
{
|
||||
setLost(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDamage(CustomDamageEvent event)
|
||||
{
|
||||
if (event.GetDamageeEntity() != _pig || event.GetCause() == DamageCause.FALL)
|
||||
return;
|
||||
|
||||
event.AddMult("Reduce damage", null, 0.001, false);
|
||||
((Damageable) _pig).setHealth(((Damageable) _pig).getMaxHealth());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTick(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
if (_pig.isValid())
|
||||
{
|
||||
Location loc = _pig.getLocation();
|
||||
|
||||
if (Math.abs(loc.getZ()) > 0.05)
|
||||
{
|
||||
|
||||
loc.setY(0);
|
||||
Block block = loc.getBlock();
|
||||
|
||||
if (block.getType() != Material.AIR)
|
||||
{
|
||||
if (loc.getZ() < 0)
|
||||
{
|
||||
_blueSide += 50;
|
||||
}
|
||||
else
|
||||
{
|
||||
_redSide += 50;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_pig.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
displayProgress();
|
||||
|
||||
if (!_pig.isValid() || UtilTime.elapsed(StartTime, 30000) || _redSide > 10000 || _blueSide > 10000)
|
||||
{
|
||||
Duration = 0; // Instant game over
|
||||
|
||||
for (Player player : getChallengers())
|
||||
{
|
||||
Location loc = player.getLocation();
|
||||
loc.setY(0);
|
||||
Block block = loc.getBlock();
|
||||
|
||||
if (block.getType() == Material.STAINED_CLAY)
|
||||
{
|
||||
if (block.getData() == (_redSide > _blueSide ? 11 : 14))
|
||||
{
|
||||
SetCompleted(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void displayProgress()
|
||||
{
|
||||
double red = _redSide / 10000D;
|
||||
double blue = _blueSide / 10000D;
|
||||
// Generate Bar
|
||||
int bars = 24;
|
||||
boolean redFirst = red < blue;
|
||||
String progressBar = (redFirst ? C.cRed : C.cBlue) + "";
|
||||
int colorChange = 0;
|
||||
|
||||
for (int i = 0; i < bars; i++)
|
||||
{
|
||||
float d = (float) i / (float) bars;
|
||||
|
||||
if (colorChange == 0 && d >= (redFirst ? red : blue))
|
||||
{
|
||||
progressBar += (redFirst ? C.cBlue : C.cRed);
|
||||
colorChange = 1;
|
||||
}
|
||||
|
||||
if (colorChange != 2 && d >= Math.max(red, blue))
|
||||
{
|
||||
progressBar += C.cWhite;
|
||||
colorChange = 2;
|
||||
}
|
||||
|
||||
progressBar += "▌";
|
||||
}
|
||||
|
||||
UtilTextBottom.display(progressBar, UtilServer.getPlayers());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateRoom()
|
||||
{
|
||||
Host.CreatureAllowOverride = true;
|
||||
|
||||
_pig = getCenter().getWorld().spawnEntity(getCenter().add(0, 1, 0), EntityType.PIG);
|
||||
UtilEnt.Vegetate(_pig);
|
||||
|
||||
Host.CreatureAllowOverride = false;
|
||||
|
||||
for (int x = -6; x <= 6; x++)
|
||||
{
|
||||
for (int z = -10; z <= 10; z++)
|
||||
{
|
||||
for (int y = 0; y <= 3; y++)
|
||||
{
|
||||
Block b = getCenter().getBlock().getRelative(x, y, z);
|
||||
|
||||
if (y == 0 || Math.abs(x) == 6 || Math.abs(z) == 10)
|
||||
{
|
||||
b.setType(z == 0 ? Material.STAINED_GLASS : Material.STAINED_CLAY);
|
||||
b.setData((byte) (z < 0 ? 11 : z > 0 ? 14 : 0));
|
||||
addBlock(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -681,7 +681,7 @@ public class GameFlagManager implements Listener
|
||||
if (game.DeathSpectateSecs <= 0 && (game.GetTeam(player) == null || game.GetTeam(player).GetRespawnTime() <= 0))
|
||||
{
|
||||
//Teleport
|
||||
if (game.IsAlive(player))
|
||||
if (game.AutomaticRespawn && game.IsAlive(player))
|
||||
{
|
||||
game.RespawnPlayer(player);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user