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:
parent
684432d7dc
commit
8d6eb13504
@ -363,6 +363,9 @@ public abstract class Game implements Listener
|
||||
|
||||
public boolean TeamPerSpawn = false;
|
||||
|
||||
// Used for "%player% is your teammate"
|
||||
public boolean ShowTeammateMessage = false;
|
||||
|
||||
public boolean ForceTeamSize = true;
|
||||
public int PlayersPerTeam = 2;
|
||||
public int TeamCount = 0;
|
||||
|
@ -40,6 +40,7 @@ public class TeamSkyfall extends Skyfall
|
||||
|
||||
DontAllowOverfill = true;
|
||||
TeamMode = true;
|
||||
ShowTeammateMessage = true;
|
||||
|
||||
HideTeamSheep = true;
|
||||
|
||||
|
@ -67,6 +67,7 @@ public class TeamSkywars extends Skywars
|
||||
|
||||
TeamMode = true;
|
||||
TeamPerSpawn = true;
|
||||
ShowTeammateMessage = true;
|
||||
|
||||
registerModule(new TeamModule());
|
||||
}
|
||||
|
@ -6,18 +6,15 @@ import java.util.List;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
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.modules.TeamModule;
|
||||
import nautilus.game.arcade.managers.chat.ChatStatData;
|
||||
@ -40,11 +37,11 @@ public class TeamSuperSmash extends SuperSmash
|
||||
SpawnNearAllies = true;
|
||||
DamageTeamSelf = false;
|
||||
|
||||
TeamArmorHotbar = true;
|
||||
|
||||
DontAllowOverfill = true;
|
||||
|
||||
TeamMode = true;
|
||||
TeamArmorHotbar = true;
|
||||
ShowTeammateMessage = true;
|
||||
|
||||
registerModule(new TeamModule());
|
||||
|
||||
@ -100,55 +97,6 @@ public class TeamSuperSmash extends SuperSmash
|
||||
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
|
||||
public void onCustomDamage(CustomDamageEvent event)
|
||||
{
|
||||
|
@ -48,6 +48,7 @@ public class TeamSurvivalGames extends SurvivalGames
|
||||
|
||||
DontAllowOverfill = true;
|
||||
TeamMode = true;
|
||||
ShowTeammateMessage = true;
|
||||
|
||||
registerModule(new TeamModule());
|
||||
|
||||
|
@ -6,6 +6,7 @@ import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTabTitle;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.party.PartyManager;
|
||||
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 nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.events.PlayerStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
@ -44,6 +46,9 @@ import java.util.ArrayList;
|
||||
public class GamePlayerManager implements Listener
|
||||
{
|
||||
ArcadeManager Manager;
|
||||
|
||||
private static final int TEAMMATE_MESSAGE_DELAY = 40;
|
||||
|
||||
private static final long PLAYER_VISIBILITY_REFRESH_RATE = 30000;
|
||||
private static final int VIEW_DISTANCE_BLOCK_VALUE = 8;
|
||||
private long _lastVisibilityRefresh = 0;
|
||||
@ -418,4 +423,54 @@ public class GamePlayerManager implements Listener
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user