Implementing UHC team system to ssm, sg and skywars.
This commit is contained in:
parent
5389193cab
commit
b7ad0035bc
@ -261,6 +261,8 @@ public abstract class Game implements Listener
|
||||
public boolean CanAddStats = true;
|
||||
public boolean CanGiveLoot = true;
|
||||
|
||||
public boolean HideTeamSheep = false;
|
||||
|
||||
public boolean VersionRequire1_8 = false;
|
||||
|
||||
public ArrayList<String> GemBoosters = new ArrayList<String>();
|
||||
|
@ -143,6 +143,8 @@ public abstract class Skywars extends Game
|
||||
}, description);
|
||||
|
||||
PrepareFreeze = true;
|
||||
|
||||
HideTeamSheep = true;
|
||||
|
||||
CompassEnabled = true;
|
||||
|
||||
|
@ -1,18 +1,24 @@
|
||||
package nautilus.game.arcade.game.games.skywars;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -20,9 +26,16 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class TeamSkywars extends Skywars
|
||||
{
|
||||
|
||||
private NautHashMap<Player, Player> _teamReqs = new NautHashMap<Player, Player>();
|
||||
|
||||
public TeamSkywars(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.SkywarsTeams,
|
||||
@ -32,6 +45,7 @@ public class TeamSkywars extends Skywars
|
||||
"Craft or loot gear for combat",
|
||||
"Last team alive wins!"
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -99,17 +113,6 @@ public class TeamSkywars extends Skywars
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private BlockFace getBlockface(BlockFace face)
|
||||
{
|
||||
for(BlockFace faces : BlockFace.values()) {
|
||||
if(faces.ordinal() == face.ordinal() + 1)
|
||||
{
|
||||
return face;
|
||||
}
|
||||
}
|
||||
return BlockFace.NORTH;
|
||||
}
|
||||
|
||||
private enum TeamColors
|
||||
{
|
||||
@ -269,4 +272,178 @@ public class TeamSkywars extends Skywars
|
||||
return players;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanJoinTeam(GameTeam team)
|
||||
{
|
||||
return team.GetSize() < 2;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void TeamRename(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Live)
|
||||
return;
|
||||
|
||||
for (GameTeam team : GetTeamList())
|
||||
{
|
||||
// Big Team
|
||||
if (team.GetSize() > 2)
|
||||
{
|
||||
team.SetName("Team " + team.GetName());
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = "";
|
||||
|
||||
for (int i = 0; i < team.GetPlayers(false).size(); i++)
|
||||
{
|
||||
Player player = team.GetPlayers(false).get(i);
|
||||
|
||||
name += player.getName();
|
||||
|
||||
if (i < team.GetPlayers(false).size() - 1)
|
||||
name += " & ";
|
||||
}
|
||||
|
||||
team.SetName(name);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void teamSelectInteract(PlayerInteractEntityEvent event)
|
||||
{
|
||||
if (GetState() != GameState.Recruit)
|
||||
return;
|
||||
|
||||
if (event.getRightClicked() == null)
|
||||
return;
|
||||
|
||||
if (!(event.getRightClicked() instanceof Player))
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
//Observer
|
||||
if (Manager.IsObserver(player))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games."));
|
||||
return;
|
||||
}
|
||||
|
||||
selectTeamMate(player, (Player)event.getRightClicked());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void teamSelectCommand(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (GetState() != GameState.Recruit)
|
||||
return;
|
||||
|
||||
if (!event.getMessage().toLowerCase().startsWith("/team "))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
Player target = UtilPlayer.searchOnline(event.getPlayer(), event.getMessage().split(" ")[1], true);
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
//Observer
|
||||
if (Manager.IsObserver(event.getPlayer()))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Game", "Spectators cannot partake in games."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getPlayer().equals(target))
|
||||
return;
|
||||
|
||||
selectTeamMate(event.getPlayer(), target);
|
||||
}
|
||||
|
||||
public void selectTeamMate(Player player, Player ally)
|
||||
{
|
||||
//Accept Invite
|
||||
if (_teamReqs.containsKey(ally) && _teamReqs.get(ally).equals(player))
|
||||
{
|
||||
//Remove Prefs
|
||||
_teamReqs.remove(player);
|
||||
_teamReqs.remove(ally);
|
||||
|
||||
//Inform
|
||||
UtilPlayer.message(player, F.main("Game", "You accepted " + ally.getName() + "'s Team Request!"));
|
||||
UtilPlayer.message(ally, F.main("Game", player.getName() + " accepted your Team Request!"));
|
||||
|
||||
//Leave Old Teams
|
||||
if (GetTeam(player) != null)
|
||||
GetTeam(player).DisbandTeam();
|
||||
|
||||
if (GetTeam(ally) != null)
|
||||
GetTeam(ally).DisbandTeam();
|
||||
|
||||
//Get Team
|
||||
GameTeam team = getEmptyTeam();
|
||||
if (team == null)
|
||||
return;
|
||||
|
||||
team.setDisplayName(player.getName() + " & " + ally.getName());
|
||||
|
||||
//Join Team
|
||||
SetPlayerTeam(player, team, true);
|
||||
SetPlayerTeam(ally, team, true);
|
||||
}
|
||||
//Send Invite
|
||||
else
|
||||
{
|
||||
//Already on Team with Target
|
||||
if (GetTeam(player) != null)
|
||||
if (GetTeam(player).HasPlayer(ally))
|
||||
return;
|
||||
|
||||
//Inform Player
|
||||
UtilPlayer.message(player, F.main("Game", "You sent a Team Request to " + ally.getName() + "!"));
|
||||
|
||||
//Inform Target
|
||||
if (Recharge.Instance.use(player, "Team Req " + ally.getName(), 2000, false, false))
|
||||
{
|
||||
UtilPlayer.message(ally, F.main("Game", player.getName() + " sent you a Team Request!"));
|
||||
UtilPlayer.message(ally, F.main("Game", "Type " + F.elem("/team " + player.getName()) + " to accept!"));
|
||||
}
|
||||
|
||||
//Add Pref
|
||||
_teamReqs.put(player, ally);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void teamQuit(PlayerQuitEvent event)
|
||||
{
|
||||
if (GetState() != GameState.Recruit)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (GetTeam(player) != null)
|
||||
GetTeam(player).DisbandTeam();
|
||||
|
||||
Iterator<Player> teamIter = _teamReqs.keySet().iterator();
|
||||
while (teamIter.hasNext())
|
||||
{
|
||||
Player sender = teamIter.next();
|
||||
if (sender.equals(player) || _teamReqs.get(sender).equals(player))
|
||||
teamIter.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public GameTeam getEmptyTeam()
|
||||
{
|
||||
for (GameTeam team : GetTeamList())
|
||||
{
|
||||
if (team.GetPlayers(false).isEmpty())
|
||||
return team;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -120,10 +120,12 @@ public abstract class SuperSmash extends Game
|
||||
|
||||
this.DeathSpectateSecs = 4;
|
||||
|
||||
SpawnNearAllies = true;
|
||||
this.SpawnNearAllies = true;
|
||||
|
||||
this.WorldWaterDamage = 1000;
|
||||
|
||||
this.HideTeamSheep = true;
|
||||
|
||||
// Add stat table here
|
||||
// Example
|
||||
// Manager.GetStatsManager().addTable("SuperSmashMobStats", "Kills", "Deaths", "Wins", "Losses");
|
||||
|
@ -1,19 +1,29 @@
|
||||
package nautilus.game.arcade.game.games.smash;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class TeamSuperSmash extends SuperSmash
|
||||
{
|
||||
@ -22,6 +32,8 @@ public class TeamSuperSmash extends SuperSmash
|
||||
public int PlayersPerTeam = 2;
|
||||
public int TeamCount = 0;
|
||||
|
||||
private NautHashMap<Player, Player> _teamReqs = new NautHashMap<Player, Player>();
|
||||
|
||||
public TeamSuperSmash(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.SmashTeams,
|
||||
@ -214,4 +226,178 @@ public class TeamSuperSmash extends SuperSmash
|
||||
|
||||
return players;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanJoinTeam(GameTeam team)
|
||||
{
|
||||
return team.GetSize() < PlayersPerTeam;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void TeamRename(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Live)
|
||||
return;
|
||||
|
||||
for (GameTeam team : GetTeamList())
|
||||
{
|
||||
// Big Team
|
||||
if (team.GetSize() > PlayersPerTeam)
|
||||
{
|
||||
team.SetName("Team " + team.GetName());
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = "";
|
||||
|
||||
for (int i = 0; i < team.GetPlayers(false).size(); i++)
|
||||
{
|
||||
Player player = team.GetPlayers(false).get(i);
|
||||
|
||||
name += player.getName();
|
||||
|
||||
if (i < team.GetPlayers(false).size() - 1)
|
||||
name += " & ";
|
||||
}
|
||||
|
||||
team.SetName(name);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void teamSelectInteract(PlayerInteractEntityEvent event)
|
||||
{
|
||||
if (GetState() != GameState.Recruit)
|
||||
return;
|
||||
|
||||
if (event.getRightClicked() == null)
|
||||
return;
|
||||
|
||||
if (!(event.getRightClicked() instanceof Player))
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
//Observer
|
||||
if (Manager.IsObserver(player))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games."));
|
||||
return;
|
||||
}
|
||||
|
||||
selectTeamMate(player, (Player)event.getRightClicked());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void teamSelectCommand(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (GetState() != GameState.Recruit)
|
||||
return;
|
||||
|
||||
if (!event.getMessage().toLowerCase().startsWith("/team "))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
Player target = UtilPlayer.searchOnline(event.getPlayer(), event.getMessage().split(" ")[1], true);
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
//Observer
|
||||
if (Manager.IsObserver(event.getPlayer()))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Game", "Spectators cannot partake in games."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getPlayer().equals(target))
|
||||
return;
|
||||
|
||||
selectTeamMate(event.getPlayer(), target);
|
||||
}
|
||||
|
||||
public void selectTeamMate(Player player, Player ally)
|
||||
{
|
||||
//Accept Invite
|
||||
if (_teamReqs.containsKey(ally) && _teamReqs.get(ally).equals(player))
|
||||
{
|
||||
//Remove Prefs
|
||||
_teamReqs.remove(player);
|
||||
_teamReqs.remove(ally);
|
||||
|
||||
//Inform
|
||||
UtilPlayer.message(player, F.main("Game", "You accepted " + ally.getName() + "'s Team Request!"));
|
||||
UtilPlayer.message(ally, F.main("Game", player.getName() + " accepted your Team Request!"));
|
||||
|
||||
//Leave Old Teams
|
||||
if (GetTeam(player) != null)
|
||||
GetTeam(player).DisbandTeam();
|
||||
|
||||
if (GetTeam(ally) != null)
|
||||
GetTeam(ally).DisbandTeam();
|
||||
|
||||
//Get Team
|
||||
GameTeam team = getEmptyTeam();
|
||||
if (team == null)
|
||||
return;
|
||||
|
||||
team.setDisplayName(player.getName() + " & " + ally.getName());
|
||||
|
||||
//Join Team
|
||||
SetPlayerTeam(player, team, true);
|
||||
SetPlayerTeam(ally, team, true);
|
||||
}
|
||||
//Send Invite
|
||||
else
|
||||
{
|
||||
//Already on Team with Target
|
||||
if (GetTeam(player) != null)
|
||||
if (GetTeam(player).HasPlayer(ally))
|
||||
return;
|
||||
|
||||
//Inform Player
|
||||
UtilPlayer.message(player, F.main("Game", "You sent a Team Request to " + ally.getName() + "!"));
|
||||
|
||||
//Inform Target
|
||||
if (Recharge.Instance.use(player, "Team Req " + ally.getName(), 2000, false, false))
|
||||
{
|
||||
UtilPlayer.message(ally, F.main("Game", player.getName() + " sent you a Team Request!"));
|
||||
UtilPlayer.message(ally, F.main("Game", "Type " + F.elem("/team " + player.getName()) + " to accept!"));
|
||||
}
|
||||
|
||||
//Add Pref
|
||||
_teamReqs.put(player, ally);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void teamQuit(PlayerQuitEvent event)
|
||||
{
|
||||
if (GetState() != GameState.Recruit)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (GetTeam(player) != null)
|
||||
GetTeam(player).DisbandTeam();
|
||||
|
||||
Iterator<Player> teamIter = _teamReqs.keySet().iterator();
|
||||
while (teamIter.hasNext())
|
||||
{
|
||||
Player sender = teamIter.next();
|
||||
if (sender.equals(player) || _teamReqs.get(sender).equals(player))
|
||||
teamIter.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public GameTeam getEmptyTeam()
|
||||
{
|
||||
for (GameTeam team : GetTeamList())
|
||||
{
|
||||
if (team.GetPlayers(false).isEmpty())
|
||||
return team;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -209,6 +209,8 @@ public abstract class SurvivalGames extends Game
|
||||
// Manager.GetAntiStack().SetEnabled(false);
|
||||
|
||||
StrictAntiHack = true;
|
||||
|
||||
HideTeamSheep = true;
|
||||
|
||||
GameTimeout = 1500000;
|
||||
|
||||
|
@ -1,22 +1,32 @@
|
||||
package nautilus.game.arcade.game.games.survivalgames;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class TeamSurvivalGames extends SurvivalGames
|
||||
{
|
||||
@ -24,6 +34,8 @@ public class TeamSurvivalGames extends SurvivalGames
|
||||
public boolean ForceTeamSize = true;
|
||||
public int PlayersPerTeam = 2;
|
||||
public int TeamCount = 0;
|
||||
|
||||
private NautHashMap<Player, Player> _teamReqs = new NautHashMap<Player, Player>();
|
||||
|
||||
public TeamSurvivalGames(ArcadeManager manager)
|
||||
{
|
||||
@ -231,4 +243,179 @@ public class TeamSurvivalGames extends SurvivalGames
|
||||
|
||||
return players;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanJoinTeam(GameTeam team)
|
||||
{
|
||||
return team.GetSize() < PlayersPerTeam;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void TeamRename(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Live)
|
||||
return;
|
||||
|
||||
for (GameTeam team : GetTeamList())
|
||||
{
|
||||
// Big Team
|
||||
if (team.GetSize() > PlayersPerTeam)
|
||||
{
|
||||
team.SetName("Team " + team.GetName());
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = "";
|
||||
|
||||
for (int i = 0; i < team.GetPlayers(false).size(); i++)
|
||||
{
|
||||
Player player = team.GetPlayers(false).get(i);
|
||||
|
||||
name += player.getName();
|
||||
|
||||
if (i < team.GetPlayers(false).size() - 1)
|
||||
name += " & ";
|
||||
}
|
||||
|
||||
team.SetName(name);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void teamSelectInteract(PlayerInteractEntityEvent event)
|
||||
{
|
||||
if (GetState() != GameState.Recruit)
|
||||
return;
|
||||
|
||||
if (event.getRightClicked() == null)
|
||||
return;
|
||||
|
||||
if (!(event.getRightClicked() instanceof Player))
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
//Observer
|
||||
if (Manager.IsObserver(player))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games."));
|
||||
return;
|
||||
}
|
||||
|
||||
selectTeamMate(player, (Player)event.getRightClicked());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void teamSelectCommand(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (GetState() != GameState.Recruit)
|
||||
return;
|
||||
|
||||
if (!event.getMessage().toLowerCase().startsWith("/team "))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
Player target = UtilPlayer.searchOnline(event.getPlayer(), event.getMessage().split(" ")[1], true);
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
//Observer
|
||||
if (Manager.IsObserver(event.getPlayer()))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Game", "Spectators cannot partake in games."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getPlayer().equals(target))
|
||||
return;
|
||||
|
||||
selectTeamMate(event.getPlayer(), target);
|
||||
}
|
||||
|
||||
public void selectTeamMate(Player player, Player ally)
|
||||
{
|
||||
//Accept Invite
|
||||
if (_teamReqs.containsKey(ally) && _teamReqs.get(ally).equals(player))
|
||||
{
|
||||
//Remove Prefs
|
||||
_teamReqs.remove(player);
|
||||
_teamReqs.remove(ally);
|
||||
|
||||
//Inform
|
||||
UtilPlayer.message(player, F.main("Game", "You accepted " + ally.getName() + "'s Team Request!"));
|
||||
UtilPlayer.message(ally, F.main("Game", player.getName() + " accepted your Team Request!"));
|
||||
|
||||
//Leave Old Teams
|
||||
if (GetTeam(player) != null)
|
||||
GetTeam(player).DisbandTeam();
|
||||
|
||||
if (GetTeam(ally) != null)
|
||||
GetTeam(ally).DisbandTeam();
|
||||
|
||||
//Get Team
|
||||
GameTeam team = getEmptyTeam();
|
||||
if (team == null)
|
||||
return;
|
||||
|
||||
team.setDisplayName(player.getName() + " & " + ally.getName());
|
||||
|
||||
//Join Team
|
||||
SetPlayerTeam(player, team, true);
|
||||
SetPlayerTeam(ally, team, true);
|
||||
}
|
||||
//Send Invite
|
||||
else
|
||||
{
|
||||
//Already on Team with Target
|
||||
if (GetTeam(player) != null)
|
||||
if (GetTeam(player).HasPlayer(ally))
|
||||
return;
|
||||
|
||||
//Inform Player
|
||||
UtilPlayer.message(player, F.main("Game", "You sent a Team Request to " + ally.getName() + "!"));
|
||||
|
||||
//Inform Target
|
||||
if (Recharge.Instance.use(player, "Team Req " + ally.getName(), 2000, false, false))
|
||||
{
|
||||
UtilPlayer.message(ally, F.main("Game", player.getName() + " sent you a Team Request!"));
|
||||
UtilPlayer.message(ally, F.main("Game", "Type " + F.elem("/team " + player.getName()) + " to accept!"));
|
||||
}
|
||||
|
||||
//Add Pref
|
||||
_teamReqs.put(player, ally);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void teamQuit(PlayerQuitEvent event)
|
||||
{
|
||||
if (GetState() != GameState.Recruit)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (GetTeam(player) != null)
|
||||
GetTeam(player).DisbandTeam();
|
||||
|
||||
Iterator<Player> teamIter = _teamReqs.keySet().iterator();
|
||||
while (teamIter.hasNext())
|
||||
{
|
||||
Player sender = teamIter.next();
|
||||
if (sender.equals(player) || _teamReqs.get(sender).equals(player))
|
||||
teamIter.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public GameTeam getEmptyTeam()
|
||||
{
|
||||
for (GameTeam team : GetTeamList())
|
||||
{
|
||||
if (team.GetPlayers(false).isEmpty())
|
||||
return team;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ public class GameCreationManager implements Listener
|
||||
private String _lastMap = "";
|
||||
private ArrayList<GameType> _lastGames = new ArrayList<GameType>();
|
||||
|
||||
public String MapSource = null;
|
||||
public String MapPref = null;
|
||||
public String MapSource = null;
|
||||
|
||||
|
@ -323,7 +323,7 @@ public class GameLobbyManager implements Listener, IPacketHandler
|
||||
_teamBlocks.clear();
|
||||
|
||||
//Smash
|
||||
if (game.GetType() == GameType.Smash || game.GetType() == GameType.SurvivalGames)
|
||||
if (game.HideTeamSheep)
|
||||
{
|
||||
//Text
|
||||
WriteTeamLine("Select", 0, 159, (byte)15);
|
||||
@ -332,57 +332,6 @@ public class GameLobbyManager implements Listener, IPacketHandler
|
||||
CreateScoreboards();
|
||||
return;
|
||||
}
|
||||
|
||||
//UHC
|
||||
if (game.GetType() == GameType.UHC)
|
||||
{
|
||||
// if (game.GetTeamList().size() > 1)
|
||||
// {
|
||||
// //Text
|
||||
// WriteTeamLine("", 0, 159, (byte)15);
|
||||
// WriteTeamLine("", 1, 159, (byte)4);
|
||||
//
|
||||
// for (int i=0 ; i<game.GetTeamList().size() ; i++)
|
||||
// {
|
||||
// GameTeam team = game.GetTeamList().get(i);
|
||||
//
|
||||
// //Circle Math
|
||||
// double lead = i * ((2d * Math.PI)/game.GetTeamList().size());
|
||||
// double sizeMod = 32;
|
||||
// double oX = -Math.sin(lead) * sizeMod;
|
||||
// double oZ = Math.cos(lead) * sizeMod;
|
||||
//
|
||||
// //Location
|
||||
// Location entLoc = spawn.clone().add(oX, 0, oZ);
|
||||
// entLoc.setY(_teamDisplay.getY());
|
||||
//
|
||||
// //Blocks
|
||||
// SetKitTeamBlocks(entLoc.clone(), 35, team.GetColorData(), _teamBlocks);
|
||||
//
|
||||
// entLoc.add(0, 1.5, 0);
|
||||
//
|
||||
// entLoc.getChunk().load();
|
||||
//
|
||||
// //NPC
|
||||
// Sheep ent = (Sheep)Manager.GetCreature().SpawnEntity(entLoc, EntityType.SHEEP);
|
||||
// ent.setRemoveWhenFarAway(false);
|
||||
// ent.setCustomNameVisible(false);
|
||||
//
|
||||
// ent.setColor(DyeColor.getByWoolData(team.GetColorData()));
|
||||
//
|
||||
// UtilEnt.Vegetate(ent);
|
||||
//
|
||||
// team.SetTeamEntity(ent);
|
||||
//
|
||||
// _teams.put(ent, new LobbyEnt(ent, entLoc, team));
|
||||
// }
|
||||
//
|
||||
// return;
|
||||
//
|
||||
// }
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//Standard
|
||||
if (game.GetKits().length > 1 || game.GetTeamList().size() < 6)
|
||||
|
Loading…
Reference in New Issue
Block a user