Compare commits

..

7 Commits

Author SHA1 Message Date
3fb8859a29 Removed Gitlab CI pipeline.
All checks were successful
Build Plugin JAR File / Build (push) Successful in 11s
2024-05-18 21:23:21 -04:00
42de884b65 Added Gitea Actions workflow for building plugin JAR artifact.
All checks were successful
Build Plugin JAR File / Build (push) Successful in 11s
2024-05-18 21:10:40 -04:00
8102c217bb Added missing permissions for commands. 2022-06-25 12:39:02 -04:00
f8046db1df Fixed arena titles showing underscores. 2022-06-25 11:24:02 -04:00
ca7aed303f Added logging of match activity to console. 2022-06-25 11:07:31 -04:00
8a39e95ffa Fixed leaderboard showing incorrect players. 2022-06-18 18:07:43 -04:00
86372a3f6f Fixed additional casting issues in queue wait time decay rate calculation. 2022-06-18 12:29:51 -04:00
6 changed files with 80 additions and 59 deletions

View File

@@ -0,0 +1,24 @@
name: Build Plugin JAR File
on: [push]
jobs:
Build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Java environment
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Build artifact
run: chmod +x ./gradlew && ./gradlew build --no-daemon
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: Plugin JAR
path: build/libs/Snowbrawl-2.jar

View File

@@ -1,41 +0,0 @@
stages:
- build
- publish
variables:
JAR_PATH: "build/libs/Snowbrawl-2.jar"
build:
stage: build
tags:
- docker
image: openjdk:17-jdk
script:
- chmod +x gradlew
- ./gradlew build
artifacts:
name: Snowbrawl-$CI_COMMIT_REF_SLUG-$CI_JOB_NAME
paths:
- $JAR_PATH
expire_in: 1 day
publish:
stage: publish
tags:
- docker
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: $CI_COMMIT_TAG
before_script:
- apk add --no-cache curl
script:
- curl --header "JOB-TOKEN:$CI_JOB_TOKEN" --upload-file $JAR_PATH "$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/generic/release/$CI_COMMIT_TAG/Snowbrawl_$CI_COMMIT_TAG.jar"
release:
name: "Snowbrawl $CI_COMMIT_TAG"
description: "Automatic Snowbrawl release from tag $CI_COMMIT_TAG."
tag_name: "$CI_COMMIT_TAG"
ref: "$CI_COMMIT_TAG"
assets:
links:
- name: "Snowbrawl_$CI_COMMIT_TAG.jar"
url: "$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/generic/release/$CI_COMMIT_TAG/Snowbrawl_$CI_COMMIT_TAG.jar"

View File

@@ -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.
}

View File

@@ -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){

View File

@@ -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);
}
}

View File

@@ -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.;