📝 Bug fixs

This commit is contained in:
Maxlego08 2024-02-24 12:11:49 +01:00
parent c467a8596a
commit 2d19e8cd7a
6 changed files with 91 additions and 16 deletions

View File

@ -1,5 +1,16 @@
# Unreleased
- Add SaberFaction and FactionUUID support
- Add command ``/koth addcommand <koth name> <start/win> <command>``
- Add comment in file koth-example.yml
- Add placeholders:
1. ``%zkoth_team_id%`` - Current koth capture player team id
2. ``%zkoth_team_leader%`` - Current koth capture player team leader name
3. ``%zkoth_active_<koth name>%`` - Lets you know if a koth is active
4. ``%zkoth_cooldown_<koth name>%`` - Lets you know if a koth is in cooldown
5. ``%zkoth_start_<koth name>%`` - Lets you know if a koth is start
- Fix scoreboard and hologram update
# 3.0.0
New version completely recoded

View File

@ -421,8 +421,7 @@ public class ZKoth extends ZUtils implements Koth {
this.currentPlayer = player;
this.startCap(player);
this.plugin.getKothHologram().update(this);
this.plugin.getScoreBoardManager().update();
updateDisplay();
} else if (this.currentPlayer != null && !cuboid.contains(this.currentPlayer.getLocation())) {
@ -433,8 +432,6 @@ public class ZKoth extends ZUtils implements Koth {
if (event.isCancelled()) return;
this.plugin.getKothHologram().update(this);
this.plugin.getScoreBoardManager().update();
broadcast(Message.EVENT_LOOSE);
if (this.timerTask != null) {
@ -445,6 +442,8 @@ public class ZKoth extends ZUtils implements Koth {
this.remainingSeconds = new AtomicInteger(this.captureSeconds);
this.timerTask = null;
this.currentPlayer = null;
updateDisplay();
}
}
@ -477,8 +476,7 @@ public class ZKoth extends ZUtils implements Koth {
Cuboid cuboid = getCuboid();
// this.changeBlocks(Config.onePersonneCapturingMaterial, false);
this.plugin.getKothHologram().update(this);
this.plugin.getScoreBoardManager().update();
updateDisplay();
scheduleFix(this.plugin, 0, 1000, (task, isCancelled) -> {
@ -499,8 +497,7 @@ public class ZKoth extends ZUtils implements Koth {
if (this.currentPlayer != null) {
if (!this.currentPlayer.isValid() || !this.currentPlayer.isOnline() || !cuboid.contains(this.currentPlayer.getLocation())) {
this.currentPlayer = null;
this.plugin.getKothHologram().update(this);
this.plugin.getScoreBoardManager().update();
updateDisplay();
}
}
@ -526,8 +523,7 @@ public class ZKoth extends ZUtils implements Koth {
broadcast(Message.EVENT_LOOSE);
}
this.plugin.getKothHologram().update(this);
this.plugin.getScoreBoardManager().update();
updateDisplay();
return;
}
@ -547,8 +543,7 @@ public class ZKoth extends ZUtils implements Koth {
broadcast(Message.EVENT_EVERYSECONDS);
}
this.plugin.getKothHologram().update(this);
this.plugin.getScoreBoardManager().update();
updateDisplay();
switch (this.kothType) {
case CAPTURE:
@ -573,10 +568,10 @@ public class ZKoth extends ZUtils implements Koth {
this.discordWebhookConfig.send(this.plugin, this, KothEvent.WIN);
this.plugin.getKothHologram().end(this);
task.cancel();
broadcast(Message.EVENT_WIN);
this.plugin.getKothHologram().end(this);
this.plugin.getScoreBoardManager().clearBoard();
this.endCommands.forEach(command -> {
@ -795,4 +790,10 @@ public class ZKoth extends ZUtils implements Koth {
public Player getCurrentPlayer() {
return this.currentPlayer;
}
@Override
public void updateDisplay() {
this.plugin.getKothHologram().update(this);
this.plugin.getScoreBoardManager().update();
}
}

View File

@ -88,4 +88,6 @@ public interface Koth {
AtomicInteger getRemainingSeconds();
Player getCurrentPlayer();
void updateDisplay();
}

View File

@ -5,10 +5,37 @@ import org.bukkit.entity.Player;
import java.util.function.Consumer;
/**
* The KothScoreboard interface defines methods for managing the visibility of the scoreboard for players in a King of the Hill (KOTH) game mode.
* It acts as an intermediary between the KOTH plugin and other scoreboard plugins, enabling the dynamic display of game-related information
* on the player's scoreboard.
*
* Implementing this interface allows scoreboard plugins to easily integrate with KOTH game modes, providing a seamless experience for
* players by showing or hiding scoreboards as necessary. This interface is crucial for plugins that wish to offer customizable scoreboard
* features within the context of KOTH matches.
*
* <p>Note: Implementations of this interface should ensure thread-safety if scoreboards are toggled or hidden asynchronously.</p>
*/
public interface KothScoreboard {
/**
* Toggles the visibility of the scoreboard for the given player. If the scoreboard is currently visible, it will be hidden, and vice versa.
* The {@code after} consumer is called after the toggle operation is completed, allowing for further actions to be taken.
*
* @param player The player for whom the scoreboard visibility will be toggled. This parameter cannot be null.
* @param after A {@code Consumer<Player>} that is executed after the scoreboard's visibility has been toggled, receiving the player as its parameter.
* This allows for additional operations to be performed after the toggle action. Can be {@code null} if no action is required afterwards.
*/
void toggle(Player player, Consumer<Player> after);
/**
* Hides the scoreboard for the given player, ensuring that it is not visible. The {@code after} consumer is called after the hide operation is completed,
* allowing for further actions to be taken.
*
* @param player The player for whom the scoreboard will be hidden. This parameter cannot be null.
* @param after A {@code Consumer<Player>} that is executed after the scoreboard has been hidden, receiving the player as its parameter.
* This allows for additional operations to be performed after hiding the scoreboard. Can be {@code null} if no action is required afterwards.
*/
void hide(Player player, Consumer<Player> after);
}

View File

@ -5,14 +5,48 @@ import org.bukkit.event.Listener;
import java.util.List;
/**
* The KothTeam interface provides methods for interacting with team-related data within a King of the Hill (KOTH) game mode.
* This interface serves as a bridge between the KOTH plugin and other team plugins, facilitating the retrieval of team information,
* online players within a team, the team leader's name, and the unique team identifier.
*
* Implementing this interface allows for seamless integration and manipulation of team data, enhancing the KOTH gaming experience by
* providing essential team-related functionalities. It's designed to be implemented by classes that manage team data in the context
* of KOTH game modes.
*
* <p>Note: This interface requires the implementation class to be a listener to game events, as indicated by the extension of the {@code Listener} interface.</p>
*/
public interface KothTeam extends Listener {
/**
* Retrieves the name of the team to which a given player belongs.
*
* @param player The player for whom the team name is to be retrieved. This parameter cannot be null.
* @return A {@code String} representing the name of the team. Returns {@code null} if the player is not part of any team.
*/
String getTeamName(Player player);
/**
* Retrieves a list of players who are currently online and belong to the same team as the given player.
*
* @param player The player used as a reference for the team query. This parameter cannot be null.
* @return A list of {@code Player} objects representing the online team members. Returns an empty list if no online players are found in the team.
*/
List<Player> getOnlinePlayer(Player player);
/**
* Retrieves the name of the leader of the team to which a given player belongs.
*
* @param player The player for whom the team leader's name is to be retrieved. This parameter cannot be null.
* @return A {@code String} representing the name of the team leader. Returns {@code null} if the player is not part of any team or the team does not have a designated leader.
*/
String getLeaderName(Player player);
/**
* Retrieves the unique identifier (ID) of the team to which a given player belongs.
*
* @param player The player for whom the team ID is to be retrieved. This parameter cannot be null.
* @return A {@code String} representing the unique ID of the team. Returns {@code null} if the player is not part of any team.
*/
String getTeamId(Player player);
}

View File

@ -91,7 +91,7 @@ public enum Message {
EVENT_WIN(MessageType.CENTER,
"§8§m-+------------------------------+-",
"",
"§d%playerName% §fof faction §7%playerName% §fhas just captured",
"§d%playerName% §fof faction §7%teamName% §fhas just captured",
"§fthe koth, and §nwins§f the event!",
"",
"§8§m-+------------------------------+-"