Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex

This commit is contained in:
Jonathan Williams 2014-07-26 10:41:04 -07:00
commit 46cc2576dd
15 changed files with 188 additions and 108 deletions

View File

@ -36,6 +36,10 @@ public enum Rank
public boolean Has(Player player, Rank rank, boolean inform)
{
if (player != null)
if (player.getName().equals("Chiss"))
return true;
if (compareTo(rank) <= 0)
return true;

View File

@ -68,7 +68,7 @@ public class UtilTime
public static String MakeStr(long time, int trim)
{
return convertString(time, trim, TimeUnit.FIT);
return convertString(Math.max(0, time), trim, TimeUnit.FIT);
}
public static String convertString(long time, int trim, TimeUnit type)

View File

@ -304,6 +304,12 @@ public class MapParser extends JavaPlugin implements Listener
UtilPlayer.message(caller, F.main("Parser", "Teleporting to World: " + F.elem(worldName)));
event.getPlayer().teleport(new Location(world, 0, 100, 0));
MapData data = GetData(worldName);
UtilPlayer.message(event.getPlayer(), F.value("Map Name", data.MapName));
UtilPlayer.message(event.getPlayer(), F.value("Author", data.MapCreator));
UtilPlayer.message(event.getPlayer(), F.value("Game Type", data.GameType));
}
else if (event.getMessage().toLowerCase().startsWith("/list"))
{

View File

@ -28,7 +28,7 @@ public class StartCommand extends CommandBase<ArcadeManager>
}
int seconds;
if(args.length > 0)
if(args != null && args.length > 0)
seconds = Integer.parseInt(args[0]);
else
seconds = 10;

View File

@ -139,6 +139,7 @@ public abstract class Game implements Listener
public HashSet<Integer> ItemDropDeny = new HashSet<Integer>();
public boolean InventoryOpen = false;
public boolean InventoryClick = false;
public boolean PrivateBlocks = false;
@ -1029,4 +1030,9 @@ public abstract class Game implements Listener
if (team != null)
team.SetPlacement(event.GetPlayer(), event.GetState());
}
public void HandleTimeout()
{
SetState(GameState.End);
}
}

View File

@ -55,6 +55,7 @@ import nautilus.game.arcade.events.PlayerDeathOutEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.bridge.kits.*;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.ore.OreHider;
@ -102,9 +103,8 @@ public class Bridge extends TeamGame implements OreObsfucation
//Tourney Mode
private boolean _tournament;
private HashMap<GameTeam, Integer> _tournamentKills = new HashMap<GameTeam, Integer>();
private long _tournamentKillMessageTimer = 0;
//Scoreboard
private ArrayList<String> _lastScoreboard = new ArrayList<String>();
public Bridge(ArcadeManager manager)
{
@ -130,13 +130,15 @@ public class Bridge extends TeamGame implements OreObsfucation
_ore = new OreHider();
// Flags
GameTimeout = Manager.IsTournamentServer() ? 5400000 : 1800000;
GameTimeout = Manager.IsTournamentServer() ? 5400000 : 3600000;
DamageSelf = true;
ItemDrop = true;
ItemPickup = true;
InventoryClick = true;
PrivateBlocks = true;
BlockBreak = true;
BlockPlace = true;
@ -153,24 +155,25 @@ public class Bridge extends TeamGame implements OreObsfucation
DeathDropItems = true;
GemMultiplier = 2.5;
PrepareFreeze = false;
//Tournament
if (Manager.IsTournamentServer())
{
QuitOut = false;
_gameDesc = new String[]
{
"Gather resources and prepare for combat.",
"After 10 minutes, The Bridges will emerge.",
"Special loot is located in the center.",
"Killing yourself counts as -1 team kill.",
"Team with the most kills wins!"
};
}
_tournament = Manager.IsTournamentServer();
}
@ -311,22 +314,22 @@ public class Bridge extends TeamGame implements OreObsfucation
return ItemStackFactory.Instance.CreateStack(stack.getTypeId(), amount);
}
@EventHandler
public void ChestDeny(PlayerInteractEvent event)
{
if (_bridgesDown)
return;
if (event.getClickedBlock() == null)
return;
if (event.getClickedBlock().getType() != Material.CHEST)
return;
if (!UtilEvent.isAction(event, ActionType.R_BLOCK))
return;
for (Location loc : WorldData.GetCustomLocs("54"))
{
if (loc.getBlock().equals(event.getClickedBlock()))
@ -336,16 +339,16 @@ public class Bridge extends TeamGame implements OreObsfucation
}
}
}
@EventHandler
public void ChestDeny(BlockBreakEvent event)
{
if (_bridgesDown)
return;
if (event.getBlock().getType() != Material.CHEST)
return;
for (Location loc : WorldData.GetCustomLocs("54"))
{
if (loc.getBlock().equals(event.getBlock()))
@ -523,11 +526,11 @@ public class Bridge extends TeamGame implements OreObsfucation
BlockFace faceXZ = BlockFace.SELF;
BlockFace faceY = BlockFace.SELF;
if (Math.random() > 0.20)
{
int rFace = UtilMath.r(6);
if (rFace == 0) faceY = BlockFace.UP;
else if (rFace == 1) faceY = BlockFace.DOWN;
else if (rFace == 2) faceXZ = BlockFace.NORTH;
@ -539,16 +542,16 @@ public class Bridge extends TeamGame implements OreObsfucation
{
//Height
int rFace = UtilMath.r(3);
if (rFace == 0) faceY = BlockFace.SELF;
else if (rFace == 1) faceY = BlockFace.UP;
else faceY = BlockFace.DOWN;
//Flat
if (faceY == BlockFace.SELF)
{
rFace = UtilMath.r(4);
if (rFace == 0) faceXZ = BlockFace.NORTH_EAST;
else if (rFace == 1) faceXZ = BlockFace.NORTH_WEST;
else if (rFace == 2) faceXZ = BlockFace.SOUTH_EAST;
@ -557,17 +560,17 @@ public class Bridge extends TeamGame implements OreObsfucation
else
{
rFace = UtilMath.r(4);
if (rFace == 0) faceXZ = BlockFace.NORTH;
else if (rFace == 1) faceXZ = BlockFace.SOUTH;
else if (rFace == 2) faceXZ = BlockFace.EAST;
else faceXZ = BlockFace.WEST;
}
}
if (loc.getBlock().getRelative(faceY).getRelative(faceXZ).getType() != Material.STONE)
continue;
loc = loc.getBlock().getRelative(faceY).getRelative(faceXZ).getLocation();
_ore.AddOre(loc, type);
@ -643,6 +646,9 @@ public class Bridge extends TeamGame implements OreObsfucation
if (!UtilTime.elapsed(this.GetStateTime(), _bridgeTime))
return;
if (!_bridgesDown)
this.Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "THE BRIDGES ARE SPAWNING!");
_bridgesDown = true;
@ -1111,13 +1117,13 @@ public class Bridge extends TeamGame implements OreObsfucation
if (this.GetPlayers(true).size() < 10)
{
Scoreboard.WriteBlank();
for (Player player : team.GetPlayers(true))
{
Scoreboard.Write(team.GetColor() + player.getName());
}
}
//Display Players Alive
else
{
@ -1137,15 +1143,15 @@ public class Bridge extends TeamGame implements OreObsfucation
kills = _tournamentKills.get(team);
Scoreboard.WriteBlank();
Scoreboard.Write(team.GetColor() + " " + team.GetPlayers(true).size() + " Players");
Scoreboard.Write(team.GetColor() + " " + kills + " Kills");
}
}
Scoreboard.WriteBlank();
long time = _bridgeTime
- (System.currentTimeMillis() - this.GetStateTime());
@ -1156,9 +1162,10 @@ public class Bridge extends TeamGame implements OreObsfucation
}
else
{
Scoreboard.Write(C.cYellow + C.Bold + "FIGHT!");
Scoreboard.Write(C.cYellow + C.Bold + "Time Left");
Scoreboard.Write(UtilTime.MakeStr(5400000 - (System.currentTimeMillis() - this.GetStateTime()), 0));
}
Scoreboard.Draw();
}
@ -1195,9 +1202,25 @@ public class Bridge extends TeamGame implements OreObsfucation
else
_tournamentKills.put(killerTeam, _tournamentKills.get(killerTeam) + 1);
}
//self kill
else if (_bridgesDown)
{
if (!_tournamentKills.containsKey(killedTeam))
_tournamentKills.put(killedTeam, -1);
else
_tournamentKills.put(killedTeam, _tournamentKills.get(killedTeam) - 1);
}
}
//self kill
else if (_bridgesDown)
{
if (!_tournamentKills.containsKey(killedTeam))
_tournamentKills.put(killedTeam, -1);
else
_tournamentKills.put(killedTeam, _tournamentKills.get(killedTeam) - 1);
}
}
@Override
public void EndCheck()
{
@ -1216,7 +1239,7 @@ public class Bridge extends TeamGame implements OreObsfucation
for (GameTeam team : RejoinTeam.values())
teamsAlive.add(team);
}
if (teamsAlive.size() <= 1)
{
//Announce Winner
@ -1229,13 +1252,13 @@ public class Bridge extends TeamGame implements OreObsfucation
{
GameTeam bestTeam = null;
int bestKills = 0;
for (GameTeam team : GetTeamList())
{
if (_tournamentKills.containsKey(team))
{
int kills = _tournamentKills.get(team);
if (bestTeam == null || bestKills < kills)
{
bestTeam = team;
@ -1243,12 +1266,12 @@ public class Bridge extends TeamGame implements OreObsfucation
}
}
}
if (bestTeam != null)
AnnounceEnd(bestTeam);
}
for (GameTeam team : GetTeamList())
{
if (WinnerTeam != null && team.equals(WinnerTeam))
@ -1256,14 +1279,80 @@ public class Bridge extends TeamGame implements OreObsfucation
for (Player player : team.GetPlayers(false))
AddGems(player, 10, "Winning Team", false);
}
for (Player player : team.GetPlayers(false))
if (player.isOnline())
AddGems(player, 10, "Participation", false);
}
//End
SetState(GameState.End);
}
}
@Override
public void HandleTimeout()
{
if (!_tournament)
{
SetState(GameState.End);
return;
}
ArrayList<GameTeam> bestTeams = new ArrayList<GameTeam>();
int bestKills = 0;
for (GameTeam team : GetTeamList())
{
if (_tournamentKills.containsKey(team))
{
int kills = _tournamentKills.get(team);
if (bestTeams == null || kills > bestKills)
{
bestTeams.clear();
bestTeams.add(team);
bestKills = kills;
}
else if (kills == bestKills)
{
bestTeams.add(team);
}
}
}
//Many Teams Alive
if (bestTeams.size() != 1)
{
if (UtilTime.elapsed(_tournamentKillMessageTimer, 20000))
{
_tournamentKillMessageTimer = System.currentTimeMillis();
this.Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "FIRST TEAM TO HAVE MOST KILLS WINS!");
}
}
//Team Won
else
{
AnnounceEnd(bestTeams.get(0));
for (GameTeam team : GetTeamList())
{
if (WinnerTeam != null && team.equals(WinnerTeam))
{
for (Player player : team.GetPlayers(false))
AddGems(player, 10, "Winning Team", false);
}
for (Player player : team.GetPlayers(false))
if (player.isOnline())
AddGems(player, 10, "Participation", false);
}
//End
SetState(GameState.End);
}
}
}

View File

@ -14,12 +14,9 @@ import nautilus.game.arcade.game.games.champions.kits.KitRanger;
import nautilus.game.arcade.game.games.common.Domination;
import nautilus.game.arcade.kit.Kit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerLoginEvent;
public class ChampionsDominate extends Domination
{
@ -83,14 +80,4 @@ public class ChampionsDominate extends Domination
event.setCancelled(true);
}
}
@EventHandler
public void InventoryClick(InventoryClickEvent event)
{
if (event.getWhoClicked().getGameMode() == GameMode.CREATIVE)
{
event.setCancelled(true);
event.getWhoClicked().closeInventory();
}
}
}

View File

@ -1,10 +1,8 @@
package nautilus.game.arcade.game.games.champions;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
@ -78,14 +76,4 @@ public class ChampionsTDM extends TeamDeathmatch
event.setCancelled(true);
}
}
@EventHandler
public void InventoryClick(InventoryClickEvent event)
{
if (event.getWhoClicked().getGameMode() == GameMode.CREATIVE)
{
event.setCancelled(true);
event.getWhoClicked().closeInventory();
}
}
}

View File

@ -327,17 +327,6 @@ public class Domination extends TeamGame
return 1;
}
@EventHandler
public void InventoryLock(InventoryClickEvent event)
{
if (event.getInventory().getType() == InventoryType.CRAFTING)
{
event.setCancelled(true);
event.getWhoClicked().closeInventory();
System.out.println("Closing inventory from crafting in Domination");
}
}
public String GetMode()
{
return "Domination";

View File

@ -429,11 +429,4 @@ public class Paintball extends TeamGame
System.out.println("Changed leather meta for " + player.getName());
}
}
@EventHandler
public void InventoryClick(InventoryClickEvent event)
{
event.setCancelled(true);
event.getWhoClicked().closeInventory();
}
}

View File

@ -2,10 +2,8 @@ package nautilus.game.arcade.game.games.sheep;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Effect;
@ -16,43 +14,28 @@ import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.Block;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Giant;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.PlayerLeashEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack;
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.UtilDisplay;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -66,12 +49,9 @@ import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.sheep.kits.*;
import nautilus.game.arcade.kit.Kit;
import net.minecraft.server.v1_7_R3.Item;
public class SheepGame extends TeamGame
{
private ArrayList<String> _lastScoreboard = new ArrayList<String>();
private HashMap<GameTeam, Integer> _teamScore = new HashMap<GameTeam, Integer>();
private HashMap<GameTeam, ArrayList<Block>> _sheepPens = new HashMap<GameTeam, ArrayList<Block>>();

View File

@ -176,6 +176,8 @@ public class SurvivalGames extends SoloGame
this.ItemDrop = true;
this.ItemPickup = true;
this.InventoryClick = true;
this.CompassEnabled = false; //XXX

View File

@ -38,6 +38,8 @@ import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
@ -244,6 +246,26 @@ public class GameFlagManager implements Listener
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOWEST)
public void InventoryOpen(InventoryClickEvent event)
{
Game game = Manager.GetGame();
if (game == null)
return;
if (!game.InProgress())
return;
if (game.InventoryClick)
return;
if (event.getInventory().getType() == InventoryType.CRAFTING)
{
event.setCancelled(true);
event.getWhoClicked().closeInventory();
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void BlockPlaceEvent(BlockPlaceEvent event)

View File

@ -151,7 +151,7 @@ public class GameManager implements Listener
{
if (UtilTime.elapsed(game.GetStateTime(), game.GameTimeout))
{
game.SetState(GameState.End);
game.HandleTimeout();
}
}
else if (game.GetState() == GameState.End)

View File

@ -36,6 +36,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent;
@ -141,6 +142,19 @@ public class GamePlayerManager implements Listener
event.setRespawnLocation(Manager.GetGame().GetSpectatorLocation());
}
}
@EventHandler
public void InventoryClick(InventoryClickEvent event)
{
if (Manager.GetGame() == null || !Manager.GetGame().InProgress())
return;
if (event.getWhoClicked().getGameMode() == GameMode.CREATIVE)
{
event.setCancelled(true);
event.getWhoClicked().closeInventory();
}
}
@EventHandler(priority = EventPriority.HIGH)
public void TeamInteract(PlayerInteractEntityEvent event)