Add "%player% is your teammate" in 2 player team games (#273)

* Add "%player% is your teammate" in 2 player team games

* Add to Team Skyfall
This commit is contained in:
Sam 2016-11-17 01:10:16 +00:00 committed by Shaun Bennett
parent 684432d7dc
commit 8d6eb13504
6 changed files with 65 additions and 56 deletions

View File

@ -362,6 +362,9 @@ public abstract class Game implements Listener
public boolean TeamMode = false; public boolean TeamMode = false;
public boolean TeamPerSpawn = false; public boolean TeamPerSpawn = false;
// Used for "%player% is your teammate"
public boolean ShowTeammateMessage = false;
public boolean ForceTeamSize = true; public boolean ForceTeamSize = true;
public int PlayersPerTeam = 2; public int PlayersPerTeam = 2;

View File

@ -40,6 +40,7 @@ public class TeamSkyfall extends Skyfall
DontAllowOverfill = true; DontAllowOverfill = true;
TeamMode = true; TeamMode = true;
ShowTeammateMessage = true;
HideTeamSheep = true; HideTeamSheep = true;

View File

@ -67,6 +67,7 @@ public class TeamSkywars extends Skywars
TeamMode = true; TeamMode = true;
TeamPerSpawn = true; TeamPerSpawn = true;
ShowTeammateMessage = true;
registerModule(new TeamModule()); registerModule(new TeamModule());
} }

View File

@ -6,18 +6,15 @@ import java.util.List;
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.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.common.Pair; import mineplex.core.common.Pair;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.modules.TeamModule; import nautilus.game.arcade.game.modules.TeamModule;
import nautilus.game.arcade.managers.chat.ChatStatData; import nautilus.game.arcade.managers.chat.ChatStatData;
@ -40,12 +37,12 @@ public class TeamSuperSmash extends SuperSmash
SpawnNearAllies = true; SpawnNearAllies = true;
DamageTeamSelf = false; DamageTeamSelf = false;
TeamArmorHotbar = true;
DontAllowOverfill = true; DontAllowOverfill = true;
TeamMode = true; TeamMode = true;
TeamArmorHotbar = true;
ShowTeammateMessage = true;
registerModule(new TeamModule()); registerModule(new TeamModule());
registerStatTrackers(new WinWithoutDyingStatTracker(this, "MLGPro"), new FreeKitWinStatTracker(this), new OneVThreeStatTracker(this), new KillFastStatTracker(this, 3, 10, "TripleKill"), registerStatTrackers(new WinWithoutDyingStatTracker(this, "MLGPro"), new FreeKitWinStatTracker(this), new OneVThreeStatTracker(this), new KillFastStatTracker(this, 3, 10, "TripleKill"),
@ -99,55 +96,6 @@ public class TeamSuperSmash extends SuperSmash
Scoreboard.draw(); Scoreboard.draw();
} }
@Override
@EventHandler
public void gameStart(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Prepare)
{
return;
}
super.gameStart(event);
new BukkitRunnable()
{
@Override
public void run()
{
for (Player player : GetPlayers(true))
{
GameTeam team = GetTeam(player);
Player bestTeamMember = null;
if (team == null)
{
continue;
}
for (Player teamMember : team.GetPlayers(true))
{
if (player.equals(teamMember))
{
continue;
}
bestTeamMember = teamMember;
}
if (bestTeamMember == null)
{
UtilTextMiddle.display(C.cRedB + "No one", "You don\'t have a teammate :(", 10, 50, 10, player);
return;
}
UtilTextMiddle.display(null, team.GetColor() + bestTeamMember.getName() + " is your teammate", 10, 50, 10, player);
}
}
}.runTaskLater(Manager.getPlugin(), 40);
}
@EventHandler @EventHandler
public void onCustomDamage(CustomDamageEvent event) public void onCustomDamage(CustomDamageEvent event)

View File

@ -48,6 +48,7 @@ public class TeamSurvivalGames extends SurvivalGames
DontAllowOverfill = true; DontAllowOverfill = true;
TeamMode = true; TeamMode = true;
ShowTeammateMessage = true;
registerModule(new TeamModule()); registerModule(new TeamModule());

View File

@ -6,6 +6,7 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTabTitle; import mineplex.core.common.util.UtilTabTitle;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.party.PartyManager; import mineplex.core.party.PartyManager;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
@ -16,6 +17,7 @@ import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.events.PlayerStateChangeEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.Game.GameState;
@ -44,10 +46,13 @@ import java.util.ArrayList;
public class GamePlayerManager implements Listener public class GamePlayerManager implements Listener
{ {
ArcadeManager Manager; ArcadeManager Manager;
private static final int TEAMMATE_MESSAGE_DELAY = 40;
private static final long PLAYER_VISIBILITY_REFRESH_RATE = 30000; private static final long PLAYER_VISIBILITY_REFRESH_RATE = 30000;
private static final int VIEW_DISTANCE_BLOCK_VALUE = 8; private static final int VIEW_DISTANCE_BLOCK_VALUE = 8;
private long _lastVisibilityRefresh = 0; private long _lastVisibilityRefresh = 0;
public GamePlayerManager(ArcadeManager manager) public GamePlayerManager(ArcadeManager manager)
{ {
Manager = manager; Manager = manager;
@ -418,4 +423,54 @@ public class GamePlayerManager implements Listener
player.teleport(target); player.teleport(target);
} }
} }
@EventHandler
public void sendTeammateDetails(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Prepare)
{
return;
}
Game game = Manager.GetGame();
if (!game.ShowTeammateMessage || game.GetTeamList().size() == 1)
{
return;
}
Manager.runSyncLater(() -> {
for (Player player : game.GetPlayers(true))
{
GameTeam team = game.GetTeam(player);
Player bestTeamMember = null;
if (team == null)
{
continue;
}
for (Player teamMember : team.GetPlayers(true))
{
if (player.equals(teamMember))
{
continue;
}
bestTeamMember = teamMember;
}
if (bestTeamMember == null)
{
UtilTextMiddle.display(C.cRedB + "No one", "You don\'t have a teammate :(", 10, 50, 10, player);
return;
}
UtilTextMiddle.display(null, team.GetColor() + bestTeamMember.getName() + " is your teammate", 10, 50, 10, player);
}
}, TEAMMATE_MESSAGE_DELAY);
}
} }