Merge branch 'release/3.1.0'

This commit is contained in:
Maxlego08 2024-11-12 15:40:15 +01:00
commit 46ed49fb84
11 changed files with 118 additions and 89 deletions

View File

@ -1,10 +1,16 @@
# Unreleased
# 3.1.0
- Add ``enableEverySecondsCooldownMessage``, Periodically displays a message when the koth is launched
- Fixed the koth default type when creating, the type will now be CAPTURE
- Add ``%captureProgress%`` and `%capturePercent%` placeholder
# 3.0.9
- Update HuskTown API
- Fix scoreboard title with PlaceholderApi
- Minor fixs
- Minor fixes
# 3.0.8

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fr.maxlego08.koth</groupId>
<artifactId>zKoth</artifactId>
<version>3.0.9</version>
<version>3.1.0</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fr.maxlego08.koth</groupId>
<artifactId>zKoth</artifactId>
<version>3.0.9</version>
<version>3.1.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>

View File

@ -23,7 +23,6 @@ import fr.maxlego08.koth.save.Config;
import fr.maxlego08.koth.scoreboard.ScoreBoardManager;
import fr.maxlego08.koth.zcore.enums.Message;
import fr.maxlego08.koth.zcore.logger.Logger;
import fr.maxlego08.koth.zcore.utils.ColorTransformer;
import fr.maxlego08.koth.zcore.utils.Cuboid;
import fr.maxlego08.koth.zcore.utils.ProgressBar;
import fr.maxlego08.koth.zcore.utils.ZUtils;
@ -70,6 +69,7 @@ public class ZKoth extends ZUtils implements Koth {
private final boolean enableStartCapMessage;
private final boolean enableLooseCapMessage;
private final boolean enableEverySecondsCapMessage;
private final boolean enableEverySecondsCooldownMessage;
private final HologramConfig hologramConfig;
private final KothLootType kothLootType;
private final List<String> blacklistTeamId;
@ -92,7 +92,7 @@ public class ZKoth extends ZUtils implements Koth {
private TimerTask timerTaskStop;
private List<PlayerResult> playerResults = new ArrayList<>();
public ZKoth(KothPlugin plugin, String fileName, KothType kothType, String name, int captureSeconds, Location minLocation, Location maxLocation, List<String> startCommands, List<String> endCommands, ScoreboardConfiguration cooldownScoreboard, ScoreboardConfiguration startScoreboard, int cooldownStart, int stopAfterSeconds, boolean enableStartCapMessage, boolean enableLooseCapMessage, boolean enableEverySecondsCapMessage, HologramConfig hologramConfig, List<ItemStack> itemStacks, KothLootType kothLootType, DiscordWebhookConfig discordWebhookConfig, int randomItemStacks, List<String> blacklistTeamId, ProgressBar progressBar, List<RandomCommand> randomCommands, int maxRandomCommands) {
public ZKoth(KothPlugin plugin, String fileName, KothType kothType, String name, int captureSeconds, Location minLocation, Location maxLocation, List<String> startCommands, List<String> endCommands, ScoreboardConfiguration cooldownScoreboard, ScoreboardConfiguration startScoreboard, int cooldownStart, int stopAfterSeconds, boolean enableStartCapMessage, boolean enableLooseCapMessage, boolean enableEverySecondsCapMessage, boolean enableEverySecondsCooldownMessage, HologramConfig hologramConfig, List<ItemStack> itemStacks, KothLootType kothLootType, DiscordWebhookConfig discordWebhookConfig, int randomItemStacks, List<String> blacklistTeamId, ProgressBar progressBar, List<RandomCommand> randomCommands, int maxRandomCommands) {
this.plugin = plugin;
this.fileName = fileName;
this.kothType = kothType;
@ -109,6 +109,7 @@ public class ZKoth extends ZUtils implements Koth {
this.enableStartCapMessage = enableStartCapMessage;
this.enableLooseCapMessage = enableLooseCapMessage;
this.enableEverySecondsCapMessage = enableEverySecondsCapMessage;
this.enableEverySecondsCooldownMessage = enableEverySecondsCooldownMessage;
this.hologramConfig = hologramConfig;
this.itemStacks = itemStacks;
this.kothLootType = kothLootType;
@ -135,6 +136,7 @@ public class ZKoth extends ZUtils implements Koth {
this.enableStartCapMessage = true;
this.enableLooseCapMessage = true;
this.enableEverySecondsCapMessage = false;
this.enableEverySecondsCooldownMessage = false;
this.hologramConfig = new HologramConfig(false, new ArrayList<>(), getCenter());
this.discordWebhookConfig = null;
this.itemStacks = new ArrayList<>();
@ -349,6 +351,9 @@ public class ZKoth extends ZUtils implements Koth {
if (Config.displayMessageCooldown.contains(currentRemainingSeconds)) {
broadcast(Message.EVENT_COOLDOWN);
}
if (this.enableEverySecondsCapMessage) {
broadcast(Message.EVENT_COOLDOWN_EVERYSECONDS);
}
if (currentRemainingSeconds <= 0) {
this.timerTask.cancel();
@ -560,24 +565,25 @@ public class ZKoth extends ZUtils implements Koth {
KothCapEvent capEvent = new KothCapEvent(this, player, this.remainingSeconds.get(), this.kothTeam.getTeamName(player));
capEvent.call();
if (this.enableEverySecondsCapMessage) {
broadcast(Message.EVENT_EVERYSECONDS);
}
if (Config.displayMessageKothCap.contains(currentRemainingSeconds)) {
broadcast(Message.EVENT_TIMER);
} else if (enableEverySecondsCapMessage) {
broadcast(Message.EVENT_EVERYSECONDS);
}
updateDisplay();
switch (this.kothType) {
case CAPTURE:
default:
this.remainingSeconds.decrementAndGet();
break;
case SCORE:
// case TIMER:
this.playersValues.put(this.currentPlayer.getUniqueId(), this.getValue(this.currentPlayer) + 1);
this.playerResults.clear(); // Clear cache
break;
case CAPTURE:
default:
break;
}
}
});
@ -612,7 +618,7 @@ public class ZKoth extends ZUtils implements Koth {
this.plugin.getScoreBoardManager().clearBoard();
this.endCommands.forEach(command -> dispatchCommand(command, player));
if (this.maxRandomCommands != 0 && this.randomCommands.size() != 0) {
if (this.maxRandomCommands != 0 && !this.randomCommands.isEmpty()) {
int executedCommands = 0;
while (executedCommands < maxRandomCommands) {
RandomCommand randomCommand = randomElement(this.randomCommands);
@ -630,7 +636,7 @@ public class ZKoth extends ZUtils implements Koth {
}
Location location = center.clone();
if (this.itemStacks.size() != 0) {
if (!this.itemStacks.isEmpty()) {
switch (this.kothLootType) {
case CHEST:
location.getBlock().setType(Material.CHEST);
@ -699,7 +705,7 @@ public class ZKoth extends ZUtils implements Koth {
break;
}
case CENTER: {
if (message.getMessages().size() == 0) {
if (message.getMessages().isEmpty()) {
String realMessage = replaceMessage(message.getMessage());
broadcastCenterMessage(Collections.singletonList(realMessage));
} else {
@ -708,7 +714,7 @@ public class ZKoth extends ZUtils implements Koth {
break;
}
case TCHAT: {
if (message.getMessages().size() == 0) this.broadcast(replaceMessage(message.getMessage()));
if (message.getMessages().isEmpty()) this.broadcast(replaceMessage(message.getMessage()));
else message.getMessages().forEach(m -> this.broadcast(replaceMessage(m)));
break;
}
@ -742,6 +748,8 @@ public class ZKoth extends ZUtils implements Koth {
int seconds = this.remainingSeconds == null ? this.captureSeconds : this.remainingSeconds.get();
string = string.replace("%captureFormat%", TimerBuilder.getStringTime(seconds));
string = string.replace("%captureSeconds%", String.valueOf(seconds));
string = string.replace("%captureProgress%", getProgressBar(this.captureSeconds - seconds, this.captureSeconds, this.progressBar));
string = string.replace("%capturePercent%", this.captureSeconds == 0 ? "0" : format(percent(this.captureSeconds - seconds, this.captureSeconds)));
return replaceKothInformations(string);
}
@ -882,4 +890,9 @@ public class ZKoth extends ZUtils implements Koth {
public int getMaxRandomCommands() {
return this.maxRandomCommands;
}
@Override
public boolean isEnableEverySecondsCooldownMessage() {
return enableEverySecondsCooldownMessage;
}
}

View File

@ -210,6 +210,14 @@ public interface Koth {
*/
boolean isEnableEverySecondsCapMessage();
/**
* Checks if a message should be displayed every second during the game.
*
* @return {@code true} if the every-second game message is enabled, {@code false} otherwise.
*/
boolean isEnableEverySecondsCooldownMessage();
/**
* Defines a consumer to be called for scoreboards updates. This allows for dynamic scoreboard content based on the game state.
*

View File

@ -166,7 +166,7 @@ public class CommandManager extends ZUtils implements CommandExecutor, TabComple
super.runAsync(this.plugin, () -> {
CommandType returnType = command.prePerform(this.plugin, sender, strings);
if (returnType == CommandType.SYNTAX_ERROR) {
message(sender, Message.COMMAND_SYNTAXE_ERROR, "%syntax%", command.getSyntax());
message(sender, Message.COMMAND_SYNTAX_ERROR, "%syntax%", command.getSyntax());
}
});
return CommandType.DEFAULT;
@ -174,7 +174,7 @@ public class CommandManager extends ZUtils implements CommandExecutor, TabComple
CommandType returnType = command.prePerform(this.plugin, sender, strings);
if (returnType == CommandType.SYNTAX_ERROR) {
message(sender, Message.COMMAND_SYNTAXE_ERROR, "%syntax%", command.getSyntax());
message(sender, Message.COMMAND_SYNTAX_ERROR, "%syntax%", command.getSyntax());
}
return returnType;
}

View File

@ -589,7 +589,7 @@ public abstract class VCommand extends Arguments {
public void syntaxMessage() {
this.subVCommands.forEach(command -> {
if (command.getPermission() == null || hasPermission(sender, command.getPermission())) {
message(this.sender, Message.COMMAND_SYNTAXE_HELP, "%syntax%", command.getSyntax(), "%description%",
message(this.sender, Message.COMMAND_SYNTAX_HELP, "%syntax%", command.getSyntax(), "%description%",
command.getDescription());
}
});

View File

@ -31,7 +31,7 @@ public class CommandKothCreate extends VCommand {
protected CommandType perform(KothPlugin plugin) {
String name = argAsString(0);
KothType kothType = KothType.valueOf(argAsString(1, KothType.SCORE.name()).toUpperCase());
KothType kothType = KothType.valueOf(argAsString(1, KothType.CAPTURE.name()).toUpperCase());
int capture = argAsInteger(2, 30);
Optional<Selection> optional = this.manager.getSelection(this.player.getUniqueId());

View File

@ -54,6 +54,7 @@ public class KothLoader extends ZUtils implements Loader<Koth> {
boolean enableStartCapMessage = configuration.getBoolean("enableStartCapMessage", true);
boolean enableLooseCapMessage = configuration.getBoolean("enableLooseCapMessage", true);
boolean enableEverySecondsCapMessage = configuration.getBoolean("enableEverySecondsCapMessage", false);
boolean enableEverySecondsCooldownMessage = configuration.getBoolean("enableEverySecondsCooldownMessage", false);
List<String> startCommands = configuration.getStringList("startCommands");
List<String> endCommands = configuration.getStringList("endCommands");
Location minLocation = locationLoader.load(configuration, "minLocation.", file);
@ -90,7 +91,7 @@ public class KothLoader extends ZUtils implements Loader<Koth> {
});
}
return new ZKoth(this.plugin, fileName, kothType, name, captureSeconds, minLocation, maxLocation, startCommands, endCommands, cooldownScoreboard, startScoreboard, cooldownStart, stopAfterSeconds, enableStartCapMessage, enableLooseCapMessage, enableEverySecondsCapMessage, hologramConfig, itemStacks, kothLootType, discordWebhookConfig, randomItemStacks, blacklistTeamId, progressBar, randomCommands, maxRandomCommands);
return new ZKoth(this.plugin, fileName, kothType, name, captureSeconds, minLocation, maxLocation, startCommands, endCommands, cooldownScoreboard, startScoreboard, cooldownStart, stopAfterSeconds, enableStartCapMessage, enableLooseCapMessage, enableEverySecondsCapMessage, enableEverySecondsCooldownMessage, hologramConfig, itemStacks, kothLootType, discordWebhookConfig, randomItemStacks, blacklistTeamId, progressBar, randomCommands, maxRandomCommands);
}
@Override
@ -117,6 +118,7 @@ public class KothLoader extends ZUtils implements Loader<Koth> {
configuration.set("enableStartCapMessage", koth.isEnableStartCapMessage());
configuration.set("enableLooseCapMessage", koth.isEnableLooseCapMessage());
configuration.set("enableEverySecondsCapMessage", koth.isEnableEverySecondsCapMessage());
configuration.set("enableEverySecondsCooldownMessage", koth.isEnableEverySecondsCooldownMessage());
locationLoader.save(koth.getMinLocation(), configuration, "minLocation.");
locationLoader.save(koth.getMaxLocation(), configuration, "maxLocation.");
scoreboardLoaderLoader.save(koth.getCooldownScoreboard(), configuration, "scoreboard.cooldown.");

View File

@ -34,11 +34,11 @@ public enum Message {
FORMAT_DAY("d"),
FORMAT_DAYS("days"),
COMMAND_SYNTAXE_ERROR("§cYou must execute the command like this§7: §a%syntax%"),
COMMAND_SYNTAX_ERROR("§cYou must execute the command like this§7: §a%syntax%"),
COMMAND_NO_PERMISSION("§cYou do not have permission to run this command."),
COMMAND_NO_CONSOLE("§cOnly one player can execute this command."),
COMMAND_NO_ARG("§cImpossible to find the command with its arguments."),
COMMAND_SYNTAXE_HELP("§f%syntax% §7» §7%description%"),
COMMAND_SYNTAX_HELP("§f%syntax% §7» §7%description%"),
RELOAD("§aYou have just reloaded the configuration files."),
@ -104,6 +104,7 @@ public enum Message {
"",
"§8§m-+------------------------------+-"
),
EVENT_COOLDOWN_EVERYSECONDS(MessageType.ACTION, "§fThe koth §n%name%§f will appear in §d%spawnFormat% §8(§7%centerX%, %centerY%, %centerZ%§8)"),
EVENT_STOP(MessageType.CENTER,
"§8§m-+------------------------------+-",
@ -123,7 +124,7 @@ public enum Message {
EVENT_CATCH(MessageType.ACTION, "§d%playerName% §fjust started capturing the koth §n%name%§f. §8(§7%centerX%, %centerY%, %centerZ%§8)"),
EVENT_LOOSE(MessageType.ACTION, "§d%playerName% §fjust loose koth §n%name%§f. §8(§7%centerX%, %centerY%, %centerZ%§8)"),
EVENT_TIMER(MessageType.ACTION, "§fAnother §b%captureFormat% §fbefore §d%playerName% §fwins the koth §n%name%§e. §8(§7%centerX%, %centerY%, %centerZ%§8)"),
EVENT_EVERYSECONDS(MessageType.ACTION, "§d%playerName% §7- §8[§f%classicProgress%§8] §7- §b%classicPercent%§f%"),
EVENT_EVERYSECONDS(MessageType.ACTION, "§d%playerName% §7- §8[§f%captureProgress%§8] §7- §b%capturePercent%§f%"),
MOVE_SUCCESS("§7You have just moved the koth §f%name%§7."),

View File

@ -1,85 +1,86 @@
# Available placeholders:
# - %online-player% - Allows to run the order to all online players of the team
# - %name% - Koth name
# - %world% - World name
# - %minX% - Min location X
# - %minY% - Min location Y
# - %minZ% - Min location Z
# - %maxX% - Max location X
# - %maxY% - Max location Y
# - %maxZ% - Max location Z
# - %centerX% - Center location X
# - %centerY% - Center location Y
# - %centerZ% - Center location Z
# - %spawnSeconds% - Second before koth spawn
# - %spawnFormat% - Time format before koth spawn
# - %playerName% - Current player name
# - %teamName% - Current player team name
# - %teamId% - Current player team id
# - %teamLeader% - Current player team leader name
# - %captureSeconds% - Capture seconds (only for CAPTURE type)
# - %captureFormat% - Capture time format (only for CAPTURE type)
# Available placeholders for command execution:
# - %online-player%: Targets all online players in the team
# - %name%: Name of the Koth event
# - %world%: Name of the world where Koth is located
# - %minX%, %minY%, %minZ%: Minimum X, Y, Z coordinates of Koth area
# - %maxX%, %maxY%, %maxZ%: Maximum X, Y, Z coordinates of Koth area
# - %centerX%, %centerY%, %centerZ%: Center X, Y, Z coordinates of Koth area
# - %spawnSeconds%: Seconds before Koth spawns
# - %spawnFormat%: Formatted time before Koth spawns
# - %playerName%: Name of the player capturing Koth
# - %teamName%: Name of the player's team
# - %teamId%: ID of the player's team
# - %teamLeader%: Name of the team leader
# - %captureSeconds%: Seconds taken to capture (only for CAPTURE type)
# - %captureFormat%: Formatted capture time (only for CAPTURE type)
# Koth display name
# Display name for the Koth event
name: test
# Koth type
# Type of Koth event (e.g., CAPTURE)
type: CAPTURE
# Capture time or score to achieve
# Target capture time or score for winning Koth
capture: 30
# Time in seconds to spawn koth with /koth spawn command
# Cooldown duration in seconds before Koth can be spawned again
cooldownStart: 300
# Time in seconds to automatically stop koth
# Time in seconds after which the Koth event stops automatically
stopAfterSeconds: 3600
# Activate the message when a player starts capturing the koth
# Toggle message display when a player starts capturing Koth
enableStartCapMessage: true
# Activate the message when a player loses the koth capture
# Toggle message display when a player loses the Koth capture
enableLooseCapMessage: true
# Commands that will be executed when the koth is launched
# Enable/disable periodic messages during capture
enableEverySecondsCapMessage: false
# Enable/disable periodic message during spawn cooldown
enableEverySecondsCooldownMessage: false
# List of commands executed when Koth starts
startCommands: []
# Commands that will be executed when the koth is won by a player
# List of commands executed when a player wins the Koth
endCommands: []
# Allows to run random commands at the end of the koth
# Configuration for random commands executed at the end of Koth
randomEndCommands:
# Number of commands to execute
# Number of random commands to execute
commandAmount: 2
# List of possible commands
# List of potential commands with execution probability
commands:
- percent: 20 # Command percent
commands: # Commands list
- percent: 20 # Probability for this command
commands: # List of commands
- "bc random command #1"
- percent: 20 # Command percent
commands: # Commands list
- percent: 20
commands:
- "bc random command #2"
- percent: 10 # Command percent
commands: # Commands list
- percent: 10
commands:
- "bc random command #3"
- percent: 40 # Command percent
commands: # Commands list
- percent: 40
commands:
- "bc random command #4"
# First location
# Coordinates for the first location of Koth area
minLocation:
world: world
x: 0
y: 0
z: 0
# Second location
# Coordinates for the second location of Koth area
manLocation:
world: world
x: 0
y: 0
z: 0
# Scoreboard settings for Koth event
scoreboard:
cooldown:
enable: true
@ -107,6 +108,7 @@ scoreboard:
- " #636363◊ #ffffff%captureFormat%"
- "&r"
# Hologram display configuration for Koth
hologram:
enable: false
lines:
@ -118,16 +120,17 @@ hologram:
y: 0
z: 0
# Webhook settings for sending Koth events to external services
webhook:
enable: true
url: "https://discord.com/api/webhooks/1187068418923438190/eHBOLr52d7S28rcMqtNAdHbCi-9Gpk1tG0IU1ulbf3p6z9IbM2UqoSl9MxRT1TdX5k-W"
# Available event:
# - SPAWN
# - START
# - STOP
# - START_CAP
# - WIN
# - LOOSE
url: "https://discord.com/api/webhooks/1187068418923438190/<your webhook>"
# List of Koth events that trigger the webhook
# - SPAWN: When Koth spawns
# - START: When Koth starts
# - STOP: When Koth stops
# - START_CAP: When capture starts
# - WIN: When Koth is won
# - LOOSE: When Koth capture is lost
events:
START:
event: START
@ -142,7 +145,7 @@ webhook:
text: zKoth
iconUrl: https://groupez.dev/storage/images/9.png
# thumbnail: "<your thumbnail>"
# image: "<your image>
# image: "<your image>"
# author:
# name: "Maxlego08"
# url: ""
@ -152,25 +155,21 @@ webhook:
# value: "A new koth"
# inline: false
# Loot configuration for the Koth event
loot:
# Takes 10 items from the list of items, to put all the items you must put -1
# Number of random items to select from the item list; use -1 for all items
random: 3
# Available type :
# DROP
# CHEST
# INVENTORY
# NONE
# Type of loot distribution: DROP, CHEST, INVENTORY, NONE
type: NONE
# Use /koth loot <koth name>
# Item list for loot; configure using /koth loot <koth name>
items: []
# Allows blacklist of team IDs so that it does not participate in koth, in this example, teams with ID 0 and -1 are blacklist
# Blacklist configuration for team IDs that cannot participate in Koth
blacklistTeamId:
- "0"
- "-1"
# Configuration for the Progress Bar. Use by placeholders
# Configuration for the Koth Progress Bar, used in placeholders
progressBar:
length: 20
symbol: "|"