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

This commit is contained in:
CoderTim 2014-07-29 20:24:04 -04:00
commit 0382afecd8
23 changed files with 223 additions and 458 deletions

View File

@ -36,7 +36,7 @@ public class LobbyBalancer implements Listener, Runnable
loadLobbyServers(); loadLobbyServers();
_plugin.getProxy().getPluginManager().registerListener(_plugin, this); _plugin.getProxy().getPluginManager().registerListener(_plugin, this);
_plugin.getProxy().getScheduler().schedule(_plugin, this, 2L, 2L, TimeUnit.SECONDS); _plugin.getProxy().getScheduler().schedule(_plugin, this, 200L, 200L, TimeUnit.MILLISECONDS);
} }
@EventHandler @EventHandler
@ -45,8 +45,6 @@ public class LobbyBalancer implements Listener, Runnable
if (!event.getTarget().getName().equalsIgnoreCase("Lobby")) if (!event.getTarget().getName().equalsIgnoreCase("Lobby"))
return; return;
boolean sort = false;
synchronized (_serverLock) synchronized (_serverLock)
{ {
if (_playersSentToBestServer >= _maxPlayersToSendToBestServer) if (_playersSentToBestServer >= _maxPlayersToSendToBestServer)
@ -56,7 +54,7 @@ public class LobbyBalancer implements Listener, Runnable
while (_bestServerIndex < _sortedLobbies.size()) while (_bestServerIndex < _sortedLobbies.size())
{ {
_bestServerIndex++; _bestServerIndex++;
_maxPlayersToSendToBestServer = (_sortedLobbies.get(_bestServerIndex).MaxPlayers - _sortedLobbies.get(_bestServerIndex).Players) / 10; _maxPlayersToSendToBestServer = _sortedLobbies.get(_bestServerIndex).MaxPlayers - _sortedLobbies.get(_bestServerIndex).Players;
if (_maxPlayersToSendToBestServer > 0) if (_maxPlayersToSendToBestServer > 0)
break; break;
@ -66,11 +64,6 @@ public class LobbyBalancer implements Listener, Runnable
{ {
_bestServerIndex = 0; _bestServerIndex = 0;
_maxPlayersToSendToBestServer = 1; _maxPlayersToSendToBestServer = 1;
// Since we had to enter our dangerzone, update local data so if we have to enter it again we don't pick the same server over and over
_sortedLobbies.get(_bestServerIndex).Players += 5;
sort = true;
} }
} }
@ -78,10 +71,6 @@ public class LobbyBalancer implements Listener, Runnable
event.setTarget(_plugin.getProxy().getServerInfo(_sortedLobbies.get(_bestServerIndex).Name)); event.setTarget(_plugin.getProxy().getServerInfo(_sortedLobbies.get(_bestServerIndex).Name));
_playersSentToBestServer++; _playersSentToBestServer++;
// Only if we had to pick default regardless of the buffer safezone
if (sort)
Collections.sort(_sortedLobbies, new LobbySorter());
} }
} }
@ -96,6 +85,7 @@ public class LobbyBalancer implements Listener, Runnable
synchronized (_serverLock) synchronized (_serverLock)
{ {
long startTime = System.currentTimeMillis();
_sortedLobbies.clear(); _sortedLobbies.clear();
for (ServerStatusData serverStatusData : serverStatusDataList) for (ServerStatusData serverStatusData : serverStatusDataList)
@ -120,8 +110,12 @@ public class LobbyBalancer implements Listener, Runnable
_playersSentToBestServer = 0; _playersSentToBestServer = 0;
_bestServerIndex = 0; _bestServerIndex = 0;
if (_sortedLobbies.size() > 0) _maxPlayersToSendToBestServer = _sortedLobbies.get(_bestServerIndex).MaxPlayers - _sortedLobbies.get(_bestServerIndex).Players;
_maxPlayersToSendToBestServer = (_sortedLobbies.get(_bestServerIndex).MaxPlayers - _sortedLobbies.get(_bestServerIndex).Players) / 10;
long timeSpentInLock = System.currentTimeMillis() - startTime;
if (timeSpentInLock > 50)
System.out.println("[==] TIMING [==] Locked loading servers for " + timeSpentInLock + "ms");
} }
} }
} }

View File

@ -1,25 +0,0 @@
package mineplex.bungee.playerTracker;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.api.plugin.Plugin;
public class FindCommand extends Command
{
private Plugin _plugin;
public FindCommand(Plugin plugin)
{
super("mineplex.bungee.playertracker.find", "", "");
_plugin = plugin;
}
@Override
public void execute(CommandSender arg0, String[] arg1)
{
// TODO Auto-generated method stub
}
}

View File

@ -1,19 +0,0 @@
package mineplex.bungee.playerTracker;
import net.md_5.bungee.api.plugin.Plugin;
public class PlayerTracker
{
private Plugin _plugin;
private PlayerTrackerRepository _repository;
public PlayerTracker(Plugin plugin)
{
_plugin = plugin;
_plugin.getProxy().getPluginManager().registerCommand(_plugin, new FindCommand(_plugin));
_repository = new PlayerTrackerRepository();
_repository.initialize();
}
}

View File

@ -1,253 +0,0 @@
package mineplex.bungee.playerTracker;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class PlayerTrackerRepository
{
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/PlayerTracker?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
private String _userName = "root";
private String _password = "tAbechAk3wR7tuTh";
private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS PlayerTracker (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(16), server VARCHAR(255), PRIMARY KEY (id));";
private static String INSERT_PLAYER_SERVER = "INSERT INTO PlayerTracker values(default, ?, ?);";
private static String UPDATE_PLAYER_SERVER = "UPDATE PlayerTracker SET server = ? WHERE name = ?;";
private static String DELETE_PLAYER = "DELETE FROM PlayerTracker WHERE name = ?;";
private static String RETRIEVE_PLAYER_SERVER = "SELECT server FROM PlayerTracker WHERE name = ?;";
public void initialize()
{
Connection connection = null;
PreparedStatement preparedStatement = null;
try
{
connection = DriverManager.getConnection(_connectionString, _userName, _password);
// Create table
preparedStatement = connection.prepareStatement(CREATE_TABLE);
preparedStatement.execute();
}
catch (Exception exception)
{
exception.printStackTrace();
}
finally
{
if (preparedStatement != null)
{
try
{
preparedStatement.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
if (connection != null)
{
try
{
connection.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
System.out.println("Initialized PlayerTracker.");
}
public boolean updatePlayerServer(String name, String server)
{
Connection connection = null;
PreparedStatement preparedStatement = null;
try
{
connection = DriverManager.getConnection(_connectionString, _userName, _password);
preparedStatement = connection.prepareStatement(UPDATE_PLAYER_SERVER);
preparedStatement.setString(1, server);
preparedStatement.setString(2, name);
int affectedRows = preparedStatement.executeUpdate();
if (affectedRows == 0)
{
preparedStatement = connection.prepareStatement(INSERT_PLAYER_SERVER);
preparedStatement.setString(1, name);
preparedStatement.setString(2, server);
affectedRows = preparedStatement.executeUpdate();
if (affectedRows == 0)
{
throw new SQLException("Updating player server failed, no rows affected.");
}
}
return true;
}
catch (Exception exception)
{
exception.printStackTrace();
return false;
}
finally
{
if (preparedStatement != null)
{
try
{
preparedStatement.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
if (connection != null)
{
try
{
connection.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
}
public String retrievePlayerServer(String name)
{
Connection connection = null;
ResultSet resultSet = null;
PreparedStatement preparedStatement = null;
try
{
connection = DriverManager.getConnection(_connectionString, _userName, _password);
preparedStatement = connection.prepareStatement(RETRIEVE_PLAYER_SERVER);
preparedStatement.setString(1, name);
resultSet = preparedStatement.executeQuery();
while (resultSet.next())
{
return resultSet.getString(1);
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
finally
{
if (preparedStatement != null)
{
try
{
preparedStatement.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
if (resultSet != null)
{
try
{
resultSet.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
if (connection != null)
{
try
{
connection.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
return "Lobby";
}
public boolean removePlayer(String name)
{
Connection connection = null;
PreparedStatement preparedStatement = null;
try
{
connection = DriverManager.getConnection(_connectionString, _userName, _password);
preparedStatement = connection.prepareStatement(DELETE_PLAYER);
preparedStatement.setString(1, name);
int affectedRows = preparedStatement.executeUpdate();
if (affectedRows == 0)
{
throw new SQLException("Updating player server failed, no rows affected.");
}
return true;
}
catch (Exception exception)
{
exception.printStackTrace();
return false;
}
finally
{
if (preparedStatement != null)
{
try
{
preparedStatement.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
if (connection != null)
{
try
{
connection.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
}
}

View File

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

View File

@ -68,7 +68,7 @@ public class UtilTime
public static String MakeStr(long time, int trim) 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) 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))); UtilPlayer.message(caller, F.main("Parser", "Teleporting to World: " + F.elem(worldName)));
event.getPlayer().teleport(new Location(world, 0, 100, 0)); 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")) else if (event.getMessage().toLowerCase().startsWith("/list"))
{ {

View File

@ -132,6 +132,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
if (serverConfig.Tournament) if (serverConfig.Tournament)
{ {
AntiHack.Instance.SetEnabled(false); AntiHack.Instance.SetEnabled(false);
Bukkit.getServer().setWhitelist(true);
} }
//Modules //Modules
@ -420,12 +421,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
@EventHandler @EventHandler
public void MessageMOTD(ServerListPingEvent event) public void MessageMOTD(ServerListPingEvent event)
{ {
if (this.IsTournamentServer())
{
event.setMotd(ChatColor.RED + "Twitch.tv "+ ChatColor.YELLOW + "Charity Event");
return;
}
String extrainformation = "|" + _serverConfig.ServerType + "|" + (_game == null ? "Unknown" : _game.GetName()) + "|" + ((_game == null || _game.WorldData == null) ? "Unknown" : _game.WorldData.MapName); String extrainformation = "|" + _serverConfig.ServerType + "|" + (_game == null ? "Unknown" : _game.GetName()) + "|" + ((_game == null || _game.WorldData == null) ? "Unknown" : _game.WorldData.MapName);
if (_game == null || _game.GetState() == GameState.Recruit) if (_game == null || _game.GetState() == GameState.Recruit)
@ -496,6 +491,26 @@ public class ArcadeManager extends MiniPlugin implements IRelation
@EventHandler @EventHandler
public void Login(PlayerLoginEvent event) public void Login(PlayerLoginEvent event)
{ {
if (Bukkit.getServer().hasWhitelist())
{
if (_clientManager.Get(event.getPlayer().getName()).GetRank().Has(event.getPlayer(), Rank.MODERATOR, false))
{
event.allow();
event.setResult(PlayerLoginEvent.Result.ALLOWED);
if (_serverConfig.Tournament)
{
event.getPlayer().setOp(true);
}
}
else
{
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server Whitelisted!");
}
return;
}
// Reserved Slot Check // Reserved Slot Check
if (Bukkit.getOnlinePlayers().length >= Bukkit.getServer().getMaxPlayers()) if (Bukkit.getOnlinePlayers().length >= Bukkit.getServer().getMaxPlayers())
{ {
@ -512,6 +527,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{ {
event.allow(); event.allow();
event.setResult(PlayerLoginEvent.Result.ALLOWED); event.setResult(PlayerLoginEvent.Result.ALLOWED);
return; return;
} }

View File

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

View File

@ -139,6 +139,7 @@ public abstract class Game implements Listener
public HashSet<Integer> ItemDropDeny = new HashSet<Integer>(); public HashSet<Integer> ItemDropDeny = new HashSet<Integer>();
public boolean InventoryOpen = false; public boolean InventoryOpen = false;
public boolean InventoryClick = false;
public boolean PrivateBlocks = false; public boolean PrivateBlocks = false;
@ -1029,4 +1030,9 @@ public abstract class Game implements Listener
if (team != null) if (team != null)
team.SetPlacement(event.GetPlayer(), event.GetState()); 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.Game;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame; 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.game.games.bridge.kits.*;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.ore.OreHider; import nautilus.game.arcade.ore.OreHider;
@ -102,9 +103,8 @@ public class Bridge extends TeamGame implements OreObsfucation
//Tourney Mode //Tourney Mode
private boolean _tournament; private boolean _tournament;
private HashMap<GameTeam, Integer> _tournamentKills = new HashMap<GameTeam, Integer>(); 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) public Bridge(ArcadeManager manager)
{ {
@ -130,13 +130,15 @@ public class Bridge extends TeamGame implements OreObsfucation
_ore = new OreHider(); _ore = new OreHider();
// Flags // Flags
GameTimeout = 96000000; GameTimeout = Manager.IsTournamentServer() ? 5400000 : 3600000;
DamageSelf = true; DamageSelf = true;
ItemDrop = true; ItemDrop = true;
ItemPickup = true; ItemPickup = true;
InventoryClick = true;
PrivateBlocks = true; PrivateBlocks = true;
BlockBreak = true; BlockBreak = true;
BlockPlace = true; BlockPlace = true;
@ -166,6 +168,7 @@ public class Bridge extends TeamGame implements OreObsfucation
"Gather resources and prepare for combat.", "Gather resources and prepare for combat.",
"After 10 minutes, The Bridges will emerge.", "After 10 minutes, The Bridges will emerge.",
"Special loot is located in the center.", "Special loot is located in the center.",
"Killing yourself counts as -1 team kill.",
"Team with the most kills wins!" "Team with the most kills wins!"
}; };
} }
@ -644,6 +647,9 @@ public class Bridge extends TeamGame implements OreObsfucation
if (!UtilTime.elapsed(this.GetStateTime(), _bridgeTime)) if (!UtilTime.elapsed(this.GetStateTime(), _bridgeTime))
return; return;
if (!_bridgesDown)
this.Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "THE BRIDGES ARE SPAWNING!");
_bridgesDown = true; _bridgesDown = true;
BuildWood(); BuildWood();
@ -1156,7 +1162,8 @@ public class Bridge extends TeamGame implements OreObsfucation
} }
else 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(); Scoreboard.Draw();
@ -1195,6 +1202,22 @@ public class Bridge extends TeamGame implements OreObsfucation
else else
_tournamentKills.put(killerTeam, _tournamentKills.get(killerTeam) + 1); _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);
} }
} }
@ -1249,6 +1272,72 @@ public class Bridge extends TeamGame implements OreObsfucation
} }
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);
}
}
@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()) for (GameTeam team : GetTeamList())
{ {
if (WinnerTeam != null && team.equals(WinnerTeam)) if (WinnerTeam != null && team.equals(WinnerTeam))

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.game.games.common.Domination;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerLoginEvent;
public class ChampionsDominate extends Domination public class ChampionsDominate extends Domination
{ {
@ -83,14 +80,4 @@ public class ChampionsDominate extends Domination
event.setCancelled(true); 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; package nautilus.game.arcade.game.games.champions;
import org.bukkit.GameMode;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
@ -78,14 +76,4 @@ public class ChampionsTDM extends TeamDeathmatch
event.setCancelled(true); 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; 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() public String GetMode()
{ {
return "Domination"; return "Domination";

View File

@ -429,11 +429,4 @@ public class Paintball extends TeamGame
System.out.println("Changed leather meta for " + player.getName()); 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.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.Effect; import org.bukkit.Effect;
@ -16,43 +14,28 @@ import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type; import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Giant;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep; import org.bukkit.entity.Sheep;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.PlayerLeashEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; 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.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent; 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.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilDisplay; import mineplex.core.common.util.UtilDisplay;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; 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.TeamGame;
import nautilus.game.arcade.game.games.sheep.kits.*; import nautilus.game.arcade.game.games.sheep.kits.*;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import net.minecraft.server.v1_7_R3.Item;
public class SheepGame extends TeamGame public class SheepGame extends TeamGame
{ {
private ArrayList<String> _lastScoreboard = new ArrayList<String>();
private HashMap<GameTeam, Integer> _teamScore = new HashMap<GameTeam, Integer>(); private HashMap<GameTeam, Integer> _teamScore = new HashMap<GameTeam, Integer>();
private HashMap<GameTeam, ArrayList<Block>> _sheepPens = new HashMap<GameTeam, ArrayList<Block>>(); private HashMap<GameTeam, ArrayList<Block>> _sheepPens = new HashMap<GameTeam, ArrayList<Block>>();

View File

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

View File

@ -50,12 +50,6 @@ public abstract class Kit implements Listener
_kitAvailability = kitAvailability; _kitAvailability = kitAvailability;
//Change to Free
if (Manager.IsTournamentServer() && (kitAvailability == KitAvailability.Green || kitAvailability == KitAvailability.Blue))
{
_kitAvailability = KitAvailability.Free;
}
_entityType = entityType; _entityType = entityType;
_itemInHand = itemInHand; _itemInHand = itemInHand;

View File

@ -104,7 +104,7 @@ public class GameChatManager implements Listener
{ {
Player receiver = recipientIterator.next(); Player receiver = recipientIterator.next();
if (Manager.GetClients().Get(receiver).GetRank().Has(Rank.MODERATOR)) if (!Manager.GetServerConfig().Tournament && Manager.GetClients().Get(receiver).GetRank().Has(Rank.MODERATOR))
continue; continue;
GameTeam recTeam = Manager.GetGame().GetTeam(receiver); GameTeam recTeam = Manager.GetGame().GetTeam(receiver);

View File

@ -38,6 +38,8 @@ import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; 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.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
@ -245,6 +247,26 @@ public class GameFlagManager implements Listener
event.setCancelled(true); 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) @EventHandler(priority = EventPriority.LOWEST)
public void BlockPlaceEvent(BlockPlaceEvent event) public void BlockPlaceEvent(BlockPlaceEvent event)
{ {

View File

@ -708,28 +708,6 @@ public class GameLobbyManager implements IPacketRunnable, Listener
return; return;
} }
if (Manager.IsTournamentServer())
{
if (_advertiseStage == 0)
{
WriteAdvertiseLine("TWITCH.TV", 0, 159, (byte)4);
WriteAdvertiseLine("CHARITY EVENT", 1, 159, (byte)15);
WriteAdvertiseLine(" ", 2, 159, (byte)15);
WriteAdvertiseLine("PROUDLY SPONSORED BY", 3, 159, (byte)15);
WriteAdvertiseLine("www.mineplex.com", 4, 159, (byte)4);
}
else if (_advertiseStage == 1)
{
WriteAdvertiseLine("Supporting", 0, 159, (byte)15);
WriteAdvertiseLine("ChildsPlay", 1, 159, (byte)4);
WriteAdvertiseLine("AbleGamers", 2, 159, (byte)4);
WriteAdvertiseLine("Extra Life", 3, 159, (byte)4);
WriteAdvertiseLine("Stand for the Silent", 4, 159, (byte)4);
}
return;
}
if (_advertiseStage == 0) if (_advertiseStage == 0)
{ {
WriteAdvertiseLine("MINEPLEX ULTRA RANK", 0, 159, (byte)4); WriteAdvertiseLine("MINEPLEX ULTRA RANK", 0, 159, (byte)4);

View File

@ -147,11 +147,11 @@ public class GameManager implements Listener
} }
} }
} }
else if (game.GetState() == GameState.Live && !Manager.IsTournamentServer()) else if (game.GetState() == GameState.Live)
{ {
if (UtilTime.elapsed(game.GetStateTime(), game.GameTimeout)) if (UtilTime.elapsed(game.GetStateTime(), game.GameTimeout))
{ {
game.SetState(GameState.End); game.HandleTimeout();
} }
} }
else if (game.GetState() == GameState.End) else if (game.GetState() == GameState.End)
@ -399,7 +399,7 @@ public class GameManager implements Listener
{ {
} }
else if (!game.IsPlaying(player)) else if (!game.IsPlaying(player) && !Manager.IsTournamentServer())
{ {
PlayerAdd(game, player, null); PlayerAdd(game, player, null);
} }

View File

@ -36,6 +36,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
@ -142,6 +143,19 @@ public class GamePlayerManager implements Listener
} }
} }
@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) @EventHandler(priority = EventPriority.HIGH)
public void TeamInteract(PlayerInteractEntityEvent event) public void TeamInteract(PlayerInteractEntityEvent event)
{ {