Compare commits
5 Commits
4a3ef2c7b3
...
8102c217bb
| Author | SHA1 | Date | |
|---|---|---|---|
|
8102c217bb
|
|||
|
f8046db1df
|
|||
|
ca7aed303f
|
|||
|
8a39e95ffa
|
|||
|
86372a3f6f
|
@@ -828,7 +828,7 @@ public class ArenaManager implements Listener {
|
||||
|
||||
if (arena != null){ // Did this player move into an arena's bounding box?
|
||||
if (this.playersInArenas.get(player) != arena){ // Is the arena they entered different than the one they were last in? (Including not in an arena)
|
||||
player.sendTitle(ChatColor.AQUA + "" + arena.getName(), ChatColor.GOLD + "" + arena.getSubtitle(), 10, 70, 20); // Display a title screen with the arena's name.
|
||||
player.sendTitle(ChatColor.AQUA + "" + arena.getName().replaceAll("_", " "), ChatColor.GOLD + "" + arena.getSubtitle(), 10, 70, 20); // Display a title screen with the arena's name.
|
||||
this.playersInArenas.put(player, arena); // Store which arena the player is in for future checks.
|
||||
}
|
||||
|
||||
|
||||
@@ -266,10 +266,10 @@ public class MatchManager implements Listener, Runnable {
|
||||
* @return The amount of ticks per second the queue wait time will decay, up to 10.
|
||||
*/
|
||||
public int getQueueDecayRate(){
|
||||
final float availablePlayers = this.snowbrawl.getServer().getOnlinePlayers().size() - this.getPlayersInMatches().size(); // The amount of players online but not in a match.
|
||||
final float queuedPlayers = this.getQueuedPlayers().size(); // The amount of queued players.
|
||||
final double availablePlayers = this.snowbrawl.getServer().getOnlinePlayers().size() - this.getPlayersInMatches().size(); // The amount of players online but not in a match.
|
||||
final double queuedPlayers = this.getQueuedPlayers().size(); // The amount of queued players.
|
||||
|
||||
final int decayRate = (int) (queuedPlayers / availablePlayers) * 10;
|
||||
final int decayRate = (int) ((queuedPlayers / availablePlayers) * 10);
|
||||
|
||||
// Clamp decay rate between 1 and 10 ticks per second.
|
||||
if (decayRate < 1){
|
||||
|
||||
@@ -24,10 +24,7 @@ import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Represents the state of a match taking place in an arena.
|
||||
@@ -35,6 +32,7 @@ import java.util.List;
|
||||
public class Match {
|
||||
private final Snowbrawl snowbrawl;
|
||||
|
||||
private final UUID uuid = UUID.randomUUID();
|
||||
private final Arena arena;
|
||||
private final List<MatchParticipant> participants;
|
||||
private int graceTimeTicksRemaining; // The amount of grace time remaining in ticks.
|
||||
@@ -58,6 +56,14 @@ public class Match {
|
||||
|
||||
this.graceTimeTicksRemaining = arena.getGraceTime();
|
||||
this.matchTimeTicksRemaining = arena.getMatchTime();
|
||||
|
||||
this.logInfo("Match initialized.");
|
||||
this.logInfo(" - Arena: " + this.arena.getName());
|
||||
this.logInfo(" - Participants: ");
|
||||
for (final MatchParticipant participant : this.getParticipants()){
|
||||
final Player player = participant.getPlayer();
|
||||
this.logInfo(" - " + player.getUniqueId() + " (" + player.getName() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,6 +134,7 @@ public class Match {
|
||||
final boolean success = this.participants.remove(participant);
|
||||
if (success){
|
||||
this.broadcastMessageToPlayers(ChatColor.RED + participant.getPlayer().getName() + " has been removed from the the match.");
|
||||
this.logInfo(participant.getPlayer().getUniqueId() + " (" + participant.getPlayer().getName() + ") has been removed from the match.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,6 +151,7 @@ public class Match {
|
||||
|
||||
// First tick of grace period.
|
||||
if (graceTimeTicksRemaining >= arena.getGraceTime()){
|
||||
this.logInfo("Grace period started.");
|
||||
final double bossBarProgress = (double) graceTimeTicksRemaining / (double) (arena.getGraceTime());
|
||||
for (MatchParticipant participant : this.getParticipants()){
|
||||
final Player player = participant.getPlayer();
|
||||
@@ -183,6 +191,7 @@ public class Match {
|
||||
|
||||
// No more grace time remaining, first tick of match.
|
||||
if (matchTimeTicksRemaining >= arena.getMatchTime()){
|
||||
this.logInfo("Grace period ended. Match starting.");
|
||||
for (MatchParticipant participant : this.getParticipants()){
|
||||
final Player player = participant.getPlayer();
|
||||
player.teleport(this.arena.getRandomSpawnPoint());
|
||||
@@ -242,6 +251,15 @@ public class Match {
|
||||
// Get final leaderboard.
|
||||
final List<MatchParticipant> leaderboard = this.getLeaderboard();
|
||||
|
||||
// Log leaderboard to console.
|
||||
this.logInfo("Match ended.");
|
||||
this.logInfo(" - Leaderboard:");
|
||||
for (int i = 0; i < leaderboard.size(); i++){
|
||||
final MatchParticipant participant = leaderboard.get(i);
|
||||
final Player player = participant.getPlayer();
|
||||
this.logInfo(" - " + (i + 1) + ": " + player.getUniqueId() + " (" + player.getName() + "): " + participant.getScore() + " (" + participant.getKills() + "K/" + participant.getDeaths() + "D)");
|
||||
}
|
||||
|
||||
// For each player still a member of the match
|
||||
for (MatchParticipant participant : this.getParticipants()){
|
||||
final Player player = participant.getPlayer();
|
||||
@@ -272,7 +290,7 @@ public class Match {
|
||||
break; // Stop printing the leaderboard if there is fewer players in the match than places on the leaderboard we are printing.
|
||||
}
|
||||
|
||||
final MatchParticipant leaderboardPlayer = leaderboard.get(place);
|
||||
final MatchParticipant leaderboardPlayer = leaderboard.get(leaderboardPlace);
|
||||
player.sendMessage(ChatColor.YELLOW + " - " + (leaderboardPlace + 1) + ": " + leaderboardPlayer.getPlayer().getName() + ": " + ChatColor.GOLD + ChatColor.BOLD + leaderboardPlayer.getScore() + ChatColor.YELLOW + " (" + ChatColor.GREEN + leaderboardPlayer.getKills() + ChatColor.YELLOW + "/" + ChatColor.RED + leaderboardPlayer.getDeaths() + ChatColor.YELLOW + ")"); // 1: Player: 2 (4/2)
|
||||
|
||||
}
|
||||
@@ -353,6 +371,11 @@ public class Match {
|
||||
|
||||
// Suppress global death message and only send to match participants.
|
||||
this.broadcastMessageToPlayers(ChatColor.GRAY + "" + ChatColor.ITALIC + event.getDeathMessage());
|
||||
|
||||
// Log death message to console.
|
||||
this.logInfo(event.getDeathMessage());
|
||||
|
||||
// Suppress vanilla death message.
|
||||
event.setDeathMessage(null);
|
||||
|
||||
// Force the player to respawn in one second.
|
||||
@@ -382,4 +405,8 @@ public class Match {
|
||||
public void onPlayerRespawn(final PlayerRespawnEvent event){
|
||||
event.setRespawnLocation(this.getArena().getRandomSpawnPoint());
|
||||
}
|
||||
|
||||
private void logInfo(final String message){
|
||||
this.snowbrawl.getLogger().info("[Match " + this.uuid + "] " + message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ command snowbrawl {
|
||||
alias sb;
|
||||
|
||||
[empty] {
|
||||
perm redstoner.snowbrawl;
|
||||
run join_queue;
|
||||
type player;
|
||||
perm redstoner.snowbrawl;
|
||||
}
|
||||
|
||||
arena list {
|
||||
@@ -15,7 +15,7 @@ command snowbrawl {
|
||||
}
|
||||
|
||||
arena create [string:name] {
|
||||
perm redstoner.snowbrawl.arena.create;
|
||||
perm redstoner.snowbrawl.arena.create;
|
||||
run create_arena name;
|
||||
type player;
|
||||
help Creates a new arena.;
|
||||
@@ -50,6 +50,7 @@ command snowbrawl {
|
||||
}
|
||||
|
||||
arena [string:name] config {
|
||||
perm redstoner.snowbrawl.arena.config;
|
||||
run get_arena_config name;
|
||||
type all;
|
||||
help Prints all configuration variable values for an arena.;
|
||||
@@ -126,53 +127,62 @@ command snowbrawl {
|
||||
|
||||
bounds pos1 {
|
||||
[block_x:x] [block_y:y] [block_z:z] {
|
||||
run set_arena_pos1 name x y z;
|
||||
type all;
|
||||
help Sets one corner of this arena's bounds to the given coordinates.;
|
||||
}
|
||||
perm redstoner.snowbrawl.arena.config.bounds;
|
||||
run set_arena_pos1 name x y z;
|
||||
type all;
|
||||
help Sets one corner of this arena's bounds to the given coordinates.;
|
||||
}
|
||||
|
||||
run set_arena_pos1_from_playerpos name;
|
||||
type player;
|
||||
help Sets one corner of this arena's bounds to your current position.;
|
||||
perm redstoner.snowbrawl.arena.config.bounds;
|
||||
run set_arena_pos1_from_playerpos name;
|
||||
type player;
|
||||
help Sets one corner of this arena's bounds to your current position.;
|
||||
}
|
||||
|
||||
bounds pos2 {
|
||||
[block_x:x] [block_y:y] [block_z:z] {
|
||||
perm redstoner.snowbrawl.arena.config.bounds;
|
||||
run set_arena_pos2 name x y z;
|
||||
type all;
|
||||
help Sets the other corner of this arena's bounds to the given coordinates.;
|
||||
}
|
||||
|
||||
perm redstoner.snowbrawl.arena.config.bounds;
|
||||
run set_arena_pos2_from_playerpos name;
|
||||
type player;
|
||||
help Sets the other corner of this arena's bounds to your current position.;
|
||||
}
|
||||
|
||||
bounds [block_x:x1] [block_y:y1] [block_z:z1] [block_x:x2] [block_y:y2] [block_z:z2] {
|
||||
perm redstoner.snowbrawl.arena.config.bounds;
|
||||
run set_arena_bounds name x1 y1 z1 x2 y2 z2;
|
||||
type all;
|
||||
help Sets this arena's bounds to the given pair of coordinates.;
|
||||
}
|
||||
|
||||
spawnpoints list {
|
||||
perm redstoner.snowbrawl.arena.config.spawnpoints;
|
||||
run get_arena_spawnpoints name;
|
||||
type all;
|
||||
help Gets all spawn points in this arena.;
|
||||
}
|
||||
|
||||
spawnpoints add {
|
||||
perm redstoner.snowbrawl.arena.config.spawnpoints;
|
||||
run add_arena_spawnpoint_from_playerpos name;
|
||||
type player;
|
||||
help Adds a new spawn point on your current position.;
|
||||
}
|
||||
|
||||
spawnpoints add [entity_x:x] [entity_y:y] [entity_z:z] [entity_yaw:yaw] [entity_pitch:pitch] {
|
||||
perm redstoner.snowbrawl.arena.config.spawnpoints;
|
||||
run add_arena_spawnpoint name x y z yaw pitch;
|
||||
type player;
|
||||
help Adds the given coordinates as a spawn point.;
|
||||
}
|
||||
|
||||
spawnpoints delete [int:id] {
|
||||
perm redstoner.snowbrawl.arena.config.spawnpoints;
|
||||
run delete_arena_spawnpoint name id;
|
||||
type player;
|
||||
help Deletes the spawn point of the given IDs.;
|
||||
@@ -180,6 +190,7 @@ command snowbrawl {
|
||||
}
|
||||
|
||||
arena [string:name] teleport {
|
||||
perm redstoner.snowbrawl.arena.teleport;
|
||||
run go_to_arena name;
|
||||
type player;
|
||||
help Teleports to a spawn point in this arena.;
|
||||
|
||||
Reference in New Issue
Block a user