fixed some scoreboard stuff

This commit is contained in:
Cheese 2015-07-17 16:17:01 +10:00
parent b7ad0035bc
commit 6ed3f93df7
7 changed files with 117 additions and 45 deletions

View File

@ -1,6 +1,7 @@
package mineplex.core.common.util;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@ -39,12 +40,14 @@ public class UtilAction
//Velocity
ent.setFallDistance(0);
ent.setVelocity(vec);
//Debug
if (ent instanceof Player && UtilGear.isMat(((Player)ent).getItemInHand(), Material.SUGAR))
{
UtilPlayer.message(ent, F.main("Debug", "Velocity Sent: " + vec.length()));
Bukkit.broadcastMessage(F.main("Debug", "Velocity Sent: " + vec.length()));
}
ent.setVelocity(vec);
}
}

View File

@ -41,6 +41,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
@ -251,34 +252,34 @@ public class DamageManager extends MiniPlugin
{
if (stack == null)
continue;
Map<Enchantment, Integer> enchants = stack.getEnchantments();
for (Enchantment e : enchants.keySet())
{
if (e.equals(Enchantment.PROTECTION_ENVIRONMENTAL))
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
else if (e.equals(Enchantment.PROTECTION_FIRE) &&
event.GetCause() == DamageCause.FIRE &&
event.GetCause() == DamageCause.FIRE_TICK &&
event.GetCause() == DamageCause.LAVA)
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
else if (e.equals(Enchantment.PROTECTION_FALL) &&
event.GetCause() == DamageCause.FALL)
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
else if (e.equals(Enchantment.PROTECTION_EXPLOSIONS) &&
event.GetCause() == DamageCause.ENTITY_EXPLOSION)
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
else if (e.equals(Enchantment.PROTECTION_PROJECTILE) &&
event.GetCause() == DamageCause.PROJECTILE)
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
}
}
}
//Offensive
Player damager = event.GetDamagerPlayer(true);
if (damager != null)
@ -390,9 +391,19 @@ public class DamageManager extends MiniPlugin
trajectory.multiply(0.6 * knockback);
trajectory.setY(Math.abs(trajectory.getY()));
//Debug
if (event.GetDamageeEntity() instanceof Player && UtilGear.isMat(((Player)event.GetDamageeEntity()).getItemInHand(), Material.SUGAR))
{
Bukkit.broadcastMessage("--------- " +
UtilEnt.getName(event.GetDamageeEntity()) + " hurt by " + UtilEnt.getName(event.GetDamagerEntity(true)) + "-----------" );
Bukkit.broadcastMessage(F.main("Debug", "Damage: " + event.GetDamage()));
}
//Apply
double vel = 0.2 + trajectory.length() * 0.8;
UtilAction.velocity(event.GetDamageeEntity(), trajectory, vel,
false, 0, Math.abs(0.2 * knockback), 0.4 + (0.04 * knockback), true);
}
@ -411,6 +422,15 @@ public class DamageManager extends MiniPlugin
}
}
@EventHandler
public void debugVel2(PlayerVelocityEvent event)
{
if (UtilGear.isMat(((Player)event.getPlayer()).getItemInHand(), Material.SUGAR))
{
Bukkit.broadcastMessage(F.main("Debug", "Event: " + event.getVelocity().length()));
}
}
private void DisplayDamage(CustomDamageEvent event)
{
for (Player player : UtilServer.getPlayers())

View File

@ -209,7 +209,7 @@ public abstract class Game implements Listener
public int TickPerTeleport = 1;
public int EnforceTeamSize = -1;
public int FillTeamsInOrderToCount = -1;
public boolean SpawnNearAllies = false;
public boolean SpawnNearEnemies = false;
@ -618,11 +618,11 @@ public abstract class Game implements Listener
public GameTeam ChooseTeam(Player player)
{
if (EnforceTeamSize != -1)
if (FillTeamsInOrderToCount != -1)
{
for (int i = 0; i < _teamList.size(); i++)
{
if (_teamList.get(i).GetSize() < EnforceTeamSize)
if (_teamList.get(i).GetSize() < FillTeamsInOrderToCount)
{
return _teamList.get(i);
}

View File

@ -46,6 +46,7 @@ public class TeamSkywars extends Skywars
"Last team alive wins!"
});
this.FillTeamsInOrderToCount = 2;
}
@EventHandler
@ -169,16 +170,34 @@ public class TeamSkywars extends Skywars
Scoreboard.WriteBlank();
Scoreboard.Write(C.cYellow + C.Bold + "Teams");
if (GetTeamList().size() <= 4)
ArrayList<GameTeam> alive = new ArrayList<GameTeam>();
for (GameTeam team : GetTeamList())
{
for(GameTeam team : GetTeamList())
if (team.IsTeamAlive())
alive.add(team);
}
if (GetPlayers(true).size() <= 4)
{
for (GameTeam team : GetTeamList())
{
Scoreboard.Write(team.GetColor() + team.GetName() + " " + team.GetSize());
for (Player player : team.GetPlayers(true))
{
Scoreboard.Write(team.GetColor() + player.getName());
}
}
}
}
else if (alive.size() <= 4)
{
for (GameTeam team : alive)
{
Scoreboard.Write(C.cWhite + team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName());
}
}
else
{
Scoreboard.Write(C.cYellow + "Players " + GetPlayers(true).size());
Scoreboard.Write(C.cWhite + alive.size() + " Alive");
}
if (IsLive())

View File

@ -4,6 +4,7 @@ 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;
@ -45,7 +46,7 @@ public class TeamSuperSmash extends SuperSmash
});
this.PlayersPerTeam = 2;
this.EnforceTeamSize = 2;
this.FillTeamsInOrderToCount = 2;
}
@Override
@ -55,37 +56,48 @@ public class TeamSuperSmash extends SuperSmash
if (event.getType() != UpdateType.FAST)
return;
ArrayList<GameTeam> alive = new ArrayList<GameTeam>();
for (GameTeam team : GetTeamList())
{
if (team.IsTeamAlive())
alive.add(team);
}
//Wipe Last
Scoreboard.Reset();
if (GetPlayers(true).size() > 14)
Scoreboard.WriteBlank();
if (GetPlayers(true).size() < 16)
{
for (GameTeam team : this.GetTeamList())
for (GameTeam team : GetTeamList())
{
Scoreboard.WriteBlank();
Scoreboard.Write(team.GetFormattedName());
int lives = 0;
for (Player player : team.GetPlayers(true))
{
int lives = GetLives(player);
Scoreboard.Write(C.cWhite + lives + " " + team.GetColor() + player.getName());
}
}
}
else if (alive.size() < 16)
{
for (GameTeam team : alive)
{
int lives = 0;
for (Player player : team.GetPlayers(true))
{
lives += GetLives(player);
}
Scoreboard.Write(team.GetColor() + "" + lives + " Lives");
Scoreboard.Write(C.cWhite + lives + " " + team.GetColor() + team.GetName());
}
}
else
{
Scoreboard.WriteBlank();
//Write New
for (Player player : GetPlayers(true))
{
int lives = GetLives(player);
if (lives <= 0)
continue;
Scoreboard.WriteOrdered("Lives", GetTeam(player).GetColor() + player.getName(), lives, true);
}
Scoreboard.Write(C.cYellow + C.Bold + "Teams Alive");
Scoreboard.Write(C.cWhite + alive.size());
}
Scoreboard.Draw();

View File

@ -27,6 +27,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scoreboard.Team;
public class TeamSurvivalGames extends SurvivalGames
{
@ -49,7 +50,7 @@ public class TeamSurvivalGames extends SurvivalGames
});
this.PlayersPerTeam = 2;
this.EnforceTeamSize = 2;
this.FillTeamsInOrderToCount = 2;
}
@ -146,19 +147,36 @@ public class TeamSurvivalGames extends SurvivalGames
Scoreboard.Write(UtilTime.convertString(this.getSecondsSinceStart() * 1000, 0, TimeUnit.FIT));
Scoreboard.WriteBlank();
Scoreboard.Write(C.cYellow + C.Bold + "Teams");
if (GetTeamList().size() > 7)
ArrayList<GameTeam> alive = new ArrayList<GameTeam>();
for (GameTeam team : GetTeamList())
{
Scoreboard.Write("" + GetTeamList().size());
if (team.IsTeamAlive())
alive.add(team);
}
else
if (GetPlayers(true).size() <= 7)
{
for (GameTeam team : GetTeamList())
{
Scoreboard.Write(C.cWhite + team.GetColor() + team.GetName());
for (Player player : team.GetPlayers(true))
{
Scoreboard.Write(team.GetColor() + player.getName());
}
}
}
else if (alive.size() <= 7)
{
for (GameTeam team : alive)
{
Scoreboard.Write(C.cWhite + team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName());
}
}
else
{
Scoreboard.Write(C.cWhite + alive.size() + " Alive");
}
Scoreboard.WriteBlank();

View File

@ -334,7 +334,7 @@ public class GameLobbyManager implements Listener, IPacketHandler
}
//Standard
if (game.GetKits().length > 1 || game.GetTeamList().size() < 6)
if ((game.GetKits().length > 1 || game.GetTeamList().size() < 6) && game.GetType() != GameType.SurvivalGamesTeams)
{
//Display
ArrayList<GameTeam> teams = new ArrayList<GameTeam>();