Compare commits
7 Commits
4a3ef2c7b3
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
3fb8859a29
|
|||
|
42de884b65
|
|||
|
8102c217bb
|
|||
|
f8046db1df
|
|||
|
ca7aed303f
|
|||
|
8a39e95ffa
|
|||
|
86372a3f6f
|
24
.gitea/workflows/build.yml
Normal file
24
.gitea/workflows/build.yml
Normal 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
|
||||||
@@ -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"
|
|
||||||
@@ -828,7 +828,7 @@ public class ArenaManager implements Listener {
|
|||||||
|
|
||||||
if (arena != null){ // Did this player move into an arena's bounding box?
|
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)
|
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.
|
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.
|
* @return The amount of ticks per second the queue wait time will decay, up to 10.
|
||||||
*/
|
*/
|
||||||
public int getQueueDecayRate(){
|
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 double 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 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.
|
// Clamp decay rate between 1 and 10 ticks per second.
|
||||||
if (decayRate < 1){
|
if (decayRate < 1){
|
||||||
|
|||||||
@@ -24,10 +24,7 @@ import org.bukkit.event.player.PlayerRespawnEvent;
|
|||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the state of a match taking place in an arena.
|
* Represents the state of a match taking place in an arena.
|
||||||
@@ -35,6 +32,7 @@ import java.util.List;
|
|||||||
public class Match {
|
public class Match {
|
||||||
private final Snowbrawl snowbrawl;
|
private final Snowbrawl snowbrawl;
|
||||||
|
|
||||||
|
private final UUID uuid = UUID.randomUUID();
|
||||||
private final Arena arena;
|
private final Arena arena;
|
||||||
private final List<MatchParticipant> participants;
|
private final List<MatchParticipant> participants;
|
||||||
private int graceTimeTicksRemaining; // The amount of grace time remaining in ticks.
|
private int graceTimeTicksRemaining; // The amount of grace time remaining in ticks.
|
||||||
@@ -58,6 +56,14 @@ public class Match {
|
|||||||
|
|
||||||
this.graceTimeTicksRemaining = arena.getGraceTime();
|
this.graceTimeTicksRemaining = arena.getGraceTime();
|
||||||
this.matchTimeTicksRemaining = arena.getMatchTime();
|
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);
|
final boolean success = this.participants.remove(participant);
|
||||||
if (success){
|
if (success){
|
||||||
this.broadcastMessageToPlayers(ChatColor.RED + participant.getPlayer().getName() + " has been removed from the the match.");
|
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.
|
// First tick of grace period.
|
||||||
if (graceTimeTicksRemaining >= arena.getGraceTime()){
|
if (graceTimeTicksRemaining >= arena.getGraceTime()){
|
||||||
|
this.logInfo("Grace period started.");
|
||||||
final double bossBarProgress = (double) graceTimeTicksRemaining / (double) (arena.getGraceTime());
|
final double bossBarProgress = (double) graceTimeTicksRemaining / (double) (arena.getGraceTime());
|
||||||
for (MatchParticipant participant : this.getParticipants()){
|
for (MatchParticipant participant : this.getParticipants()){
|
||||||
final Player player = participant.getPlayer();
|
final Player player = participant.getPlayer();
|
||||||
@@ -183,6 +191,7 @@ public class Match {
|
|||||||
|
|
||||||
// No more grace time remaining, first tick of match.
|
// No more grace time remaining, first tick of match.
|
||||||
if (matchTimeTicksRemaining >= arena.getMatchTime()){
|
if (matchTimeTicksRemaining >= arena.getMatchTime()){
|
||||||
|
this.logInfo("Grace period ended. Match starting.");
|
||||||
for (MatchParticipant participant : this.getParticipants()){
|
for (MatchParticipant participant : this.getParticipants()){
|
||||||
final Player player = participant.getPlayer();
|
final Player player = participant.getPlayer();
|
||||||
player.teleport(this.arena.getRandomSpawnPoint());
|
player.teleport(this.arena.getRandomSpawnPoint());
|
||||||
@@ -242,6 +251,15 @@ public class Match {
|
|||||||
// Get final leaderboard.
|
// Get final leaderboard.
|
||||||
final List<MatchParticipant> leaderboard = this.getLeaderboard();
|
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 each player still a member of the match
|
||||||
for (MatchParticipant participant : this.getParticipants()){
|
for (MatchParticipant participant : this.getParticipants()){
|
||||||
final Player player = participant.getPlayer();
|
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.
|
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)
|
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.
|
// Suppress global death message and only send to match participants.
|
||||||
this.broadcastMessageToPlayers(ChatColor.GRAY + "" + ChatColor.ITALIC + event.getDeathMessage());
|
this.broadcastMessageToPlayers(ChatColor.GRAY + "" + ChatColor.ITALIC + event.getDeathMessage());
|
||||||
|
|
||||||
|
// Log death message to console.
|
||||||
|
this.logInfo(event.getDeathMessage());
|
||||||
|
|
||||||
|
// Suppress vanilla death message.
|
||||||
event.setDeathMessage(null);
|
event.setDeathMessage(null);
|
||||||
|
|
||||||
// Force the player to respawn in one second.
|
// Force the player to respawn in one second.
|
||||||
@@ -382,4 +405,8 @@ public class Match {
|
|||||||
public void onPlayerRespawn(final PlayerRespawnEvent event){
|
public void onPlayerRespawn(final PlayerRespawnEvent event){
|
||||||
event.setRespawnLocation(this.getArena().getRandomSpawnPoint());
|
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;
|
alias sb;
|
||||||
|
|
||||||
[empty] {
|
[empty] {
|
||||||
|
perm redstoner.snowbrawl;
|
||||||
run join_queue;
|
run join_queue;
|
||||||
type player;
|
type player;
|
||||||
perm redstoner.snowbrawl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
arena list {
|
arena list {
|
||||||
@@ -15,7 +15,7 @@ command snowbrawl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
arena create [string:name] {
|
arena create [string:name] {
|
||||||
perm redstoner.snowbrawl.arena.create;
|
perm redstoner.snowbrawl.arena.create;
|
||||||
run create_arena name;
|
run create_arena name;
|
||||||
type player;
|
type player;
|
||||||
help Creates a new arena.;
|
help Creates a new arena.;
|
||||||
@@ -50,6 +50,7 @@ command snowbrawl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
arena [string:name] config {
|
arena [string:name] config {
|
||||||
|
perm redstoner.snowbrawl.arena.config;
|
||||||
run get_arena_config name;
|
run get_arena_config name;
|
||||||
type all;
|
type all;
|
||||||
help Prints all configuration variable values for an arena.;
|
help Prints all configuration variable values for an arena.;
|
||||||
@@ -126,53 +127,62 @@ command snowbrawl {
|
|||||||
|
|
||||||
bounds pos1 {
|
bounds pos1 {
|
||||||
[block_x:x] [block_y:y] [block_z:z] {
|
[block_x:x] [block_y:y] [block_z:z] {
|
||||||
run set_arena_pos1 name x y z;
|
perm redstoner.snowbrawl.arena.config.bounds;
|
||||||
type all;
|
run set_arena_pos1 name x y z;
|
||||||
help Sets one corner of this arena's bounds to the given coordinates.;
|
type all;
|
||||||
}
|
help Sets one corner of this arena's bounds to the given coordinates.;
|
||||||
|
}
|
||||||
|
|
||||||
run set_arena_pos1_from_playerpos name;
|
perm redstoner.snowbrawl.arena.config.bounds;
|
||||||
type player;
|
run set_arena_pos1_from_playerpos name;
|
||||||
help Sets one corner of this arena's bounds to your current position.;
|
type player;
|
||||||
|
help Sets one corner of this arena's bounds to your current position.;
|
||||||
}
|
}
|
||||||
|
|
||||||
bounds pos2 {
|
bounds pos2 {
|
||||||
[block_x:x] [block_y:y] [block_z:z] {
|
[block_x:x] [block_y:y] [block_z:z] {
|
||||||
|
perm redstoner.snowbrawl.arena.config.bounds;
|
||||||
run set_arena_pos2 name x y z;
|
run set_arena_pos2 name x y z;
|
||||||
type all;
|
type all;
|
||||||
help Sets the other corner of this arena's bounds to the given coordinates.;
|
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;
|
run set_arena_pos2_from_playerpos name;
|
||||||
type player;
|
type player;
|
||||||
help Sets the other corner of this arena's bounds to your current position.;
|
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] {
|
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;
|
run set_arena_bounds name x1 y1 z1 x2 y2 z2;
|
||||||
type all;
|
type all;
|
||||||
help Sets this arena's bounds to the given pair of coordinates.;
|
help Sets this arena's bounds to the given pair of coordinates.;
|
||||||
}
|
}
|
||||||
|
|
||||||
spawnpoints list {
|
spawnpoints list {
|
||||||
|
perm redstoner.snowbrawl.arena.config.spawnpoints;
|
||||||
run get_arena_spawnpoints name;
|
run get_arena_spawnpoints name;
|
||||||
type all;
|
type all;
|
||||||
help Gets all spawn points in this arena.;
|
help Gets all spawn points in this arena.;
|
||||||
}
|
}
|
||||||
|
|
||||||
spawnpoints add {
|
spawnpoints add {
|
||||||
|
perm redstoner.snowbrawl.arena.config.spawnpoints;
|
||||||
run add_arena_spawnpoint_from_playerpos name;
|
run add_arena_spawnpoint_from_playerpos name;
|
||||||
type player;
|
type player;
|
||||||
help Adds a new spawn point on your current position.;
|
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] {
|
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;
|
run add_arena_spawnpoint name x y z yaw pitch;
|
||||||
type player;
|
type player;
|
||||||
help Adds the given coordinates as a spawn point.;
|
help Adds the given coordinates as a spawn point.;
|
||||||
}
|
}
|
||||||
|
|
||||||
spawnpoints delete [int:id] {
|
spawnpoints delete [int:id] {
|
||||||
|
perm redstoner.snowbrawl.arena.config.spawnpoints;
|
||||||
run delete_arena_spawnpoint name id;
|
run delete_arena_spawnpoint name id;
|
||||||
type player;
|
type player;
|
||||||
help Deletes the spawn point of the given IDs.;
|
help Deletes the spawn point of the given IDs.;
|
||||||
@@ -180,6 +190,7 @@ command snowbrawl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
arena [string:name] teleport {
|
arena [string:name] teleport {
|
||||||
|
perm redstoner.snowbrawl.arena.teleport;
|
||||||
run go_to_arena name;
|
run go_to_arena name;
|
||||||
type player;
|
type player;
|
||||||
help Teleports to a spawn point in this arena.;
|
help Teleports to a spawn point in this arena.;
|
||||||
|
|||||||
Reference in New Issue
Block a user