mirror of
https://github.com/Maxlego08/zKoth.git
synced 2024-11-22 11:55:12 +01:00
Merge branch 'release/3.0.1'
This commit is contained in:
commit
c3124b07ef
13
changelog.md
13
changelog.md
@ -1,5 +1,18 @@
|
||||
# Unreleased
|
||||
|
||||
# 3.0.1
|
||||
|
||||
- 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
|
@ -3,9 +3,18 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>fr.maxlego08.koth</groupId>
|
||||
<artifactId>zKoth</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.0.1</version>
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<filtering>true</filtering>
|
||||
<directory>src/main/resources/</directory>
|
||||
<includes>
|
||||
<include>*.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
@ -193,6 +202,13 @@
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/libs/DecentHolograms-2.8.6.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.SaberLLC</groupId>
|
||||
<artifactId>Saber-Factions</artifactId>
|
||||
<version>4.1.4-STABLE</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/libs/SaberFactions.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
|
BIN
libs/SaberFactions.jar
Normal file
BIN
libs/SaberFactions.jar
Normal file
Binary file not shown.
18
pom.xml
18
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>fr.maxlego08.koth</groupId>
|
||||
<artifactId>zKoth</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.0.1</version>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
@ -11,6 +11,15 @@
|
||||
</properties>
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources/</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>*.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
@ -209,5 +218,12 @@
|
||||
<version>2022.9</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.SaberLLC</groupId>
|
||||
<artifactId>Saber-Factions</artifactId>
|
||||
<version>4.1.4-STABLE</version>
|
||||
<systemPath>${basedir}/libs/SaberFactions.jar</systemPath>
|
||||
<scope>system</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -300,4 +300,21 @@ public class KothManager extends ZUtils implements Savable {
|
||||
KothHolder kothHolder = new KothHolder(koth, page);
|
||||
kothHolder.open(player);
|
||||
}
|
||||
|
||||
public void addCommand(CommandSender sender, String name, String type, StringBuilder command) {
|
||||
|
||||
Optional<Koth> optional = getKoth(name);
|
||||
if (!optional.isPresent()) {
|
||||
message(sender, Message.DOESNT_EXIST, "%name%", name);
|
||||
return;
|
||||
}
|
||||
|
||||
Koth koth = optional.get();
|
||||
|
||||
if (type.equalsIgnoreCase("start")) koth.getStartCommands().add(command.toString());
|
||||
else koth.getEndCommands().add(command.toString());
|
||||
|
||||
message(sender, Message.COMMAND_CREATE, "%command%", command);
|
||||
this.saveKoth(koth);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package fr.maxlego08.koth;
|
||||
|
||||
import fr.maxlego08.koth.api.Koth;
|
||||
import fr.maxlego08.koth.api.KothStatus;
|
||||
import fr.maxlego08.koth.placeholder.LocalPlaceholder;
|
||||
import fr.maxlego08.koth.save.Config;
|
||||
import fr.maxlego08.koth.zcore.utils.ReturnConsumer;
|
||||
@ -36,7 +37,23 @@ public class KothPlaceholder {
|
||||
this.register("capture_seconds", koth -> TimerBuilder.getStringTime(koth.getRemainingSeconds() == null ? koth.getCaptureSeconds() : koth.getRemainingSeconds().get()));
|
||||
|
||||
this.register("player_name", koth -> koth.getCurrentPlayer() != null ? koth.getCurrentPlayer().getName() : Config.noPlayer);
|
||||
this.register("team_name", koth -> koth.getCurrentPlayer() != null ? kothManager.getKothTeam().getFactionTag(koth.getCurrentPlayer()) : Config.noFaction);
|
||||
this.register("team_name", koth -> koth.getCurrentPlayer() != null ? this.kothManager.getKothTeam().getTeamName(koth.getCurrentPlayer()) : Config.noFaction);
|
||||
this.register("team_leader", koth -> koth.getCurrentPlayer() != null ? this.kothManager.getKothTeam().getLeaderName(koth.getCurrentPlayer()) : Config.noFaction);
|
||||
this.register("team_id", koth -> koth.getCurrentPlayer() != null ? this.kothManager.getKothTeam().getTeamId(koth.getCurrentPlayer()) : Config.noFaction);
|
||||
|
||||
LocalPlaceholder placeholder = LocalPlaceholder.getInstance();
|
||||
placeholder.register("active_", (player, args) -> {
|
||||
Optional<Koth> optional = this.kothManager.getKoth(args);
|
||||
return String.valueOf(optional.filter(koth -> koth.getStatus() != KothStatus.STOP).isPresent());
|
||||
});
|
||||
placeholder.register("cooldown_", (player, args) -> {
|
||||
Optional<Koth> optional = this.kothManager.getKoth(args);
|
||||
return String.valueOf(optional.filter(koth -> koth.getStatus() == KothStatus.COOLDOWN).isPresent());
|
||||
});
|
||||
placeholder.register("start_", (player, args) -> {
|
||||
Optional<Koth> optional = this.kothManager.getKoth(args);
|
||||
return String.valueOf(optional.filter(koth -> koth.getStatus() == KothStatus.START).isPresent());
|
||||
});
|
||||
}
|
||||
|
||||
private void register(String key, ReturnConsumer<Koth> consumer) {
|
||||
|
@ -4,6 +4,7 @@ import fr.maxlego08.koth.api.KothHologram;
|
||||
import fr.maxlego08.koth.api.KothScoreboard;
|
||||
import fr.maxlego08.koth.command.commands.CommandKoth;
|
||||
import fr.maxlego08.koth.hologram.DecentHologram;
|
||||
import fr.maxlego08.koth.hologram.EmptyHologram;
|
||||
import fr.maxlego08.koth.hook.ScoreboardPlugin;
|
||||
import fr.maxlego08.koth.hook.scoreboard.DefaultHook;
|
||||
import fr.maxlego08.koth.placeholder.LocalPlaceholder;
|
||||
@ -28,7 +29,7 @@ public class KothPlugin extends ZPlugin {
|
||||
private KothManager kothManager;
|
||||
private StorageManager storageManager;
|
||||
private KothScoreboard kothScoreboard = new DefaultHook();
|
||||
private KothHologram kothHologram;
|
||||
private KothHologram kothHologram = new EmptyHologram();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
@ -538,8 +534,8 @@ public class ZKoth extends ZUtils implements Koth {
|
||||
|
||||
} else {
|
||||
|
||||
KothCapEvent capEvent = new KothCapEvent(this, player, this.remainingSeconds.get(), this.kothTeam.getFactionTag(player));
|
||||
capEvent.callEvent();
|
||||
KothCapEvent capEvent = new KothCapEvent(this, player, this.remainingSeconds.get(), this.kothTeam.getTeamName(player));
|
||||
capEvent.call();
|
||||
|
||||
if (Config.displayMessageKothCap.contains(currentRemainingSeconds)) {
|
||||
broadcast(Message.EVENT_TIMER);
|
||||
@ -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 -> {
|
||||
@ -704,7 +699,9 @@ public class ZKoth extends ZUtils implements Koth {
|
||||
if (string == null) return null;
|
||||
|
||||
string = string.replace("%playerName%", this.currentPlayer != null ? this.currentPlayer.getName() : Config.noPlayer);
|
||||
string = string.replace("%teamName%", this.currentPlayer != null ? this.kothTeam.getFactionTag(this.currentPlayer) : Config.noFaction);
|
||||
string = string.replace("%teamName%", this.currentPlayer != null ? this.kothTeam.getTeamName(this.currentPlayer) : Config.noFaction);
|
||||
string = string.replace("%teamId%", this.currentPlayer != null ? this.kothTeam.getTeamId(this.currentPlayer) : Config.noFaction);
|
||||
string = string.replace("%teamLeader%", this.currentPlayer != null ? this.kothTeam.getTeamName(this.currentPlayer) : Config.noFaction);
|
||||
|
||||
int seconds = this.remainingSeconds == null ? this.captureSeconds : this.remainingSeconds.get();
|
||||
string = string.replace("%captureFormat%", TimerBuilder.getStringTime(seconds));
|
||||
@ -793,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();
|
||||
}
|
||||
}
|
||||
|
@ -13,79 +13,282 @@ import org.bukkit.inventory.ItemStack;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* The Koth interface represents all the essential information and functionalities of a King of the Hill (KOTH) game.
|
||||
* It includes methods for managing game settings, locations, statuses, and interactions. This interface is central to
|
||||
* the KOTH plugin, providing a comprehensive set of operations for configuring and controlling KOTH games.
|
||||
*
|
||||
* Implementing this interface allows for detailed customization and control over the KOTH games, including game dynamics,
|
||||
* area definitions, scoreboard configurations, and more. It's designed to facilitate seamless integration with other game
|
||||
* management components, such as teams, scoreboards, and holograms, enhancing the overall gameplay experience.
|
||||
*/
|
||||
public interface Koth {
|
||||
|
||||
/**
|
||||
* Gets the file name associated with this KOTH game's configuration.
|
||||
*
|
||||
* @return A {@code String} representing the configuration file name.
|
||||
*/
|
||||
String getFileName();
|
||||
|
||||
/**
|
||||
* Retrieves the type of the KOTH game. The {@code KothType} enum may define various game types, such as CLASSIC, TIMED, etc.
|
||||
*
|
||||
* @return The {@code KothType} representing the type of the KOTH game.
|
||||
*/
|
||||
KothType getKothType();
|
||||
|
||||
/**
|
||||
* Gets the name of this KOTH game.
|
||||
*
|
||||
* @return A {@code String} representing the name of the KOTH game.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Sets the name of this KOTH game.
|
||||
*
|
||||
* @param name The new name for the KOTH game.
|
||||
*/
|
||||
void setName(String name);
|
||||
|
||||
/**
|
||||
* Gets the minimum corner location of the KOTH game area.
|
||||
*
|
||||
* @return A {@code Location} representing the minimum corner of the KOTH area.
|
||||
*/
|
||||
Location getMinLocation();
|
||||
|
||||
/**
|
||||
* Gets the maximum corner location of the KOTH game area.
|
||||
*
|
||||
* @return A {@code Location} representing the maximum corner of the KOTH area.
|
||||
*/
|
||||
Location getMaxLocation();
|
||||
|
||||
/**
|
||||
* Retrieves the cuboid defining the KOTH game area.
|
||||
*
|
||||
* @return A {@code Cuboid} representing the KOTH game area.
|
||||
*/
|
||||
Cuboid getCuboid();
|
||||
|
||||
/**
|
||||
* Gets the center location of the KOTH game area.
|
||||
*
|
||||
* @return A {@code Location} representing the center of the KOTH area.
|
||||
*/
|
||||
Location getCenter();
|
||||
|
||||
/**
|
||||
* Retrieves a list of commands to be executed at the start of the KOTH game.
|
||||
*
|
||||
* @return A list of {@code String} commands to execute at the start.
|
||||
*/
|
||||
List<String> getStartCommands();
|
||||
|
||||
/**
|
||||
* Retrieves a list of commands to be executed at the end of the KOTH game.
|
||||
*
|
||||
* @return A list of {@code String} commands to execute at the end.
|
||||
*/
|
||||
List<String> getEndCommands();
|
||||
|
||||
/**
|
||||
* Moves the KOTH game area to a new location defined by minimum and maximum corner locations.
|
||||
*
|
||||
* @param minLocation The new minimum corner location.
|
||||
* @param maxLocation The new maximum corner location.
|
||||
*/
|
||||
void move(Location minLocation, Location maxLocation);
|
||||
|
||||
/**
|
||||
* Gets the number of seconds required for capturing the KOTH.
|
||||
*
|
||||
* @return An {@code int} representing the capture seconds.
|
||||
*/
|
||||
int getCaptureSeconds();
|
||||
|
||||
/**
|
||||
* Sets the number of seconds required for capturing the KOTH.
|
||||
*
|
||||
* @param captureSeconds The new capture time in seconds.
|
||||
*/
|
||||
void setCaptureSeconds(int captureSeconds);
|
||||
|
||||
/**
|
||||
* Retrieves the scoreboard configuration used during the cooldown period of the KOTH game.
|
||||
*
|
||||
* @return A {@code ScoreboardConfiguration} for the cooldown period.
|
||||
*/
|
||||
ScoreboardConfiguration getCooldownScoreboard();
|
||||
|
||||
/**
|
||||
* Retrieves the scoreboard configuration used at the start of the KOTH game.
|
||||
*
|
||||
* @return A {@code ScoreboardConfiguration} for the start of the game.
|
||||
*/
|
||||
ScoreboardConfiguration getStartScoreboard();
|
||||
|
||||
/**
|
||||
* Gets the current status of the KOTH game.
|
||||
*
|
||||
* @return A {@code KothStatus} representing the current game status.
|
||||
*/
|
||||
KothStatus getStatus();
|
||||
|
||||
/**
|
||||
* Spawns the KOTH game immediately or schedules it for later, based on the {@code now} parameter. Optionally,
|
||||
* a {@code CommandSender} can be specified to receive feedback about the operation.
|
||||
*
|
||||
* @param sender The command sender to notify about the operation's outcome. Can be {@code null}.
|
||||
* @param now A boolean indicating whether to spawn the KOTH game immediately ({@code true}) or later ({@code false}).
|
||||
*/
|
||||
void spawn(CommandSender sender, boolean now);
|
||||
|
||||
/**
|
||||
* Spawns the KOTH game immediately or schedules it for later, based on the {@code now} parameter.
|
||||
*
|
||||
* @param now A boolean indicating whether to spawn the KOTH game immediately ({@code true}) or later ({@code false}).
|
||||
*/
|
||||
void spawn(boolean now);
|
||||
|
||||
/**
|
||||
* Stops the KOTH game. Optionally, a {@code CommandSender} can be specified to receive feedback about the operation.
|
||||
*
|
||||
* @param sender The command sender to notify about the operation's outcome. Can be {@code null}.
|
||||
*/
|
||||
void stop(CommandSender sender);
|
||||
|
||||
/**
|
||||
* Stops the KOTH game.
|
||||
*/
|
||||
void stop();
|
||||
|
||||
/**
|
||||
* Handles player movement within the KOTH game area, potentially affecting the game's state based on the player's actions and team.
|
||||
*
|
||||
* @param player The player who moved.
|
||||
* @param kothTeam The team to which the player belongs.
|
||||
*/
|
||||
void playerMove(Player player, KothTeam kothTeam);
|
||||
|
||||
/**
|
||||
* Gets the cooldown start time in seconds.
|
||||
*
|
||||
* @return An {@code int} representing the cooldown start time.
|
||||
*/
|
||||
int getCooldownStart();
|
||||
|
||||
/**
|
||||
* Gets the configured time in seconds after which the KOTH game should automatically stop.
|
||||
*
|
||||
* @return An {@code int} representing the auto-stop time.
|
||||
*/
|
||||
int getStopAfterSeconds();
|
||||
|
||||
/**
|
||||
* Checks if a start capture message is enabled.
|
||||
*
|
||||
* @return {@code true} if the start capture message is enabled, {@code false} otherwise.
|
||||
*/
|
||||
boolean isEnableStartCapMessage();
|
||||
|
||||
/**
|
||||
* Checks if a loose capture message is enabled.
|
||||
*
|
||||
* @return {@code true} if the loose capture message is enabled, {@code false} otherwise.
|
||||
*/
|
||||
boolean isEnableLooseCapMessage();
|
||||
|
||||
/**
|
||||
* Checks if a message should be displayed every second during capture.
|
||||
*
|
||||
* @return {@code true} if the every-second capture message is enabled, {@code false} otherwise.
|
||||
*/
|
||||
boolean isEnableEverySecondsCapMessage();
|
||||
|
||||
/**
|
||||
* Defines a consumer to be called for scoreboards updates. This allows for dynamic scoreboard content based on the game state.
|
||||
*
|
||||
* @return A {@code CollectionConsumer<Player>} for scoreboard updates.
|
||||
*/
|
||||
CollectionConsumer<Player> onScoreboard();
|
||||
|
||||
/**
|
||||
* Retrieves the hologram configuration for the KOTH game.
|
||||
*
|
||||
* @return A {@code HologramConfig} representing the hologram settings.
|
||||
*/
|
||||
HologramConfig getHologramConfig();
|
||||
|
||||
/**
|
||||
* Replaces placeholders in a message string with dynamic values related to the KOTH game.
|
||||
*
|
||||
* @param string The message string with placeholders.
|
||||
* @return A {@code String} with placeholders replaced by dynamic values.
|
||||
*/
|
||||
String replaceMessage(String string);
|
||||
|
||||
/**
|
||||
* Retrieves the Discord webhook configuration for the KOTH game.
|
||||
*
|
||||
* @return A {@code DiscordWebhookConfig} representing the Discord integration settings.
|
||||
*/
|
||||
DiscordWebhookConfig getDiscordWebhookConfig();
|
||||
|
||||
/**
|
||||
* Retrieves the list of ItemStacks associated with the KOTH game.
|
||||
*
|
||||
* @return A list of {@code ItemStack} objects.
|
||||
*/
|
||||
List<ItemStack> getItemStacks();
|
||||
|
||||
/**
|
||||
* Sets the list of ItemStacks associated with the KOTH game.
|
||||
*
|
||||
* @param itemStacks The new list of {@code ItemStack} objects.
|
||||
*/
|
||||
void setItemStacks(List<ItemStack> itemStacks);
|
||||
|
||||
/**
|
||||
* Gets the loot type for the KOTH game, indicating how loot is distributed or acquired.
|
||||
*
|
||||
* @return A {@code KothLootType} representing the loot distribution method.
|
||||
*/
|
||||
KothLootType getLootType();
|
||||
|
||||
/**
|
||||
* Retrieves a list of random ItemStacks based on the game's configuration.
|
||||
*
|
||||
* @return A list of randomly selected {@code ItemStack} objects.
|
||||
*/
|
||||
List<ItemStack> getRandomItemStacks();
|
||||
|
||||
/**
|
||||
* Gets a random item stack index based on the game's loot configuration.
|
||||
*
|
||||
* @return An {@code int} representing the index of a randomly selected item stack.
|
||||
*/
|
||||
int getRandomItemStack();
|
||||
|
||||
/**
|
||||
* Retrieves an {@code AtomicInteger} representing the remaining seconds until the KOTH game ends.
|
||||
*
|
||||
* @return An {@code AtomicInteger} with the remaining seconds.
|
||||
*/
|
||||
AtomicInteger getRemainingSeconds();
|
||||
|
||||
/**
|
||||
* Gets the current player who is capturing the KOTH.
|
||||
*
|
||||
* @return A {@code Player} who is currently capturing the KOTH, or {@code null} if no player is capturing.
|
||||
*/
|
||||
Player getCurrentPlayer();
|
||||
|
||||
/**
|
||||
* Updates the display elements associated with the KOTH game, such as scoreboards or holograms, based on the current game state.
|
||||
*/
|
||||
void updateDisplay();
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,48 @@
|
||||
package fr.maxlego08.koth.api;
|
||||
|
||||
/**
|
||||
* The KothHologram interface specifies methods for managing holograms within a King of the Hill (KOTH) game mode.
|
||||
* It serves as a conduit between the KOTH plugin and hologram plugins, facilitating the creation, update, and removal
|
||||
* of holograms that display game-related information or visuals in the KOTH context.
|
||||
*
|
||||
* Implementing this interface allows hologram plugins to seamlessly integrate with KOTH game modes, providing a dynamic
|
||||
* and engaging player experience by visually representing game status, scores, or other relevant information through holograms.
|
||||
* This interface is crucial for plugins that aim to enhance the KOTH gameplay experience with interactive and informative holographic displays.
|
||||
*
|
||||
* <p>Note: Implementations should handle hologram lifecycle events carefully to ensure holograms are created, updated, and removed appropriately, avoiding any potential memory leaks or performance issues.</p>
|
||||
*/
|
||||
public interface KothHologram {
|
||||
|
||||
/**
|
||||
* Initiates the display of a hologram for a specific KOTH game. This method is called when a KOTH game starts,
|
||||
* and it should handle the creation and initial display of the hologram associated with the given KOTH instance.
|
||||
*
|
||||
* @param koth The KOTH instance for which the hologram is to be displayed. This parameter cannot be null.
|
||||
*/
|
||||
void start(Koth koth);
|
||||
|
||||
/**
|
||||
* Ends the display of a hologram for a specific KOTH game. This method is called when a KOTH game ends,
|
||||
* and it should handle the removal or hiding of the hologram associated with the given KOTH instance.
|
||||
*
|
||||
* @param koth The KOTH instance for which the hologram display is to be ended. This parameter cannot be null.
|
||||
*/
|
||||
void end(Koth koth);
|
||||
|
||||
/**
|
||||
* Updates the hologram for a specific KOTH game. This method is called periodically or when there is a significant
|
||||
* event that requires the hologram display to be updated (e.g., score changes, time updates). Implementations should
|
||||
* refresh the hologram's content based on the current state of the given KOTH instance.
|
||||
*
|
||||
* @param koth The KOTH instance for which the hologram needs to be updated. This parameter cannot be null.
|
||||
*/
|
||||
void update(Koth koth);
|
||||
|
||||
/**
|
||||
* Handles the disabling of the hologram feature. This method is called when the plugin is disabled (e.g., server shutdown,
|
||||
* plugin reload) and should ensure that all active holograms are properly removed or cleaned up to prevent memory leaks
|
||||
* or lingering holograms in the game world.
|
||||
*/
|
||||
void onDisable();
|
||||
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
||||
String getFactionTag(Player player);
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ public class CommandKoth extends VCommand {
|
||||
this.addSubCommand(new CommandKothList(plugin));
|
||||
this.addSubCommand(new CommandKothDelete(plugin));
|
||||
this.addSubCommand(new CommandKothLoot(plugin));
|
||||
this.addSubCommand(new CommandKothAddCommand(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,46 @@
|
||||
package fr.maxlego08.koth.command.commands;
|
||||
|
||||
import fr.maxlego08.koth.KothPlugin;
|
||||
import fr.maxlego08.koth.command.VCommand;
|
||||
import fr.maxlego08.koth.zcore.enums.Message;
|
||||
import fr.maxlego08.koth.zcore.enums.Permission;
|
||||
import fr.maxlego08.koth.zcore.utils.commands.CommandType;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class CommandKothAddCommand extends VCommand {
|
||||
|
||||
public CommandKothAddCommand(KothPlugin plugin) {
|
||||
super(plugin);
|
||||
this.setPermission(Permission.ZKOTH_COMMAND_ADD);
|
||||
this.addSubCommand("addcommand", "ac");
|
||||
this.setDescription(Message.DESCRIPTION_SPAWN);
|
||||
this.addRequireArg("name", (a, b) -> plugin.getKothManager().getNameKoths());
|
||||
this.addRequireArg("type", (a, b) -> Arrays.asList("start", "win"));
|
||||
this.addRequireArg("command");
|
||||
this.setExtendedArgs(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandType perform(KothPlugin plugin) {
|
||||
|
||||
if (this.args.length < 3) return CommandType.SYNTAX_ERROR;
|
||||
|
||||
String name = argAsString(0);
|
||||
String type = argAsString(1);
|
||||
|
||||
if (!type.equalsIgnoreCase("start") && !type.equalsIgnoreCase("win")) {
|
||||
return CommandType.SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
StringBuilder command = new StringBuilder();
|
||||
for (int index = 3; index != this.args.length; index++) {
|
||||
command.append(this.args[index]).append(" ");
|
||||
}
|
||||
|
||||
this.manager.addCommand(sender, name, type, command);
|
||||
|
||||
return CommandType.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
@ -5,6 +5,7 @@ import fr.maxlego08.koth.api.KothTeam;
|
||||
import fr.maxlego08.koth.hook.teams.BetterTeamHook;
|
||||
import fr.maxlego08.koth.hook.teams.HuskTownHook;
|
||||
import fr.maxlego08.koth.hook.teams.LandHook;
|
||||
import fr.maxlego08.koth.hook.teams.SaberFactionHook;
|
||||
import fr.maxlego08.koth.hook.teams.SuperiorSkyblock2Hook;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -17,6 +18,7 @@ public enum TeamPlugin {
|
||||
HUSKTOWN("HuskTowns", HuskTownHook.class),
|
||||
SUPERIORSKYBLOCK("SuperiorSkyblock2", SuperiorSkyblock2Hook.class),
|
||||
BETTERTEAMS("BetterTeams", BetterTeamHook.class),
|
||||
FACTIONS("Factions", SaberFactionHook.class),
|
||||
|
||||
;
|
||||
|
||||
|
@ -20,7 +20,7 @@ public class BetterTeamHook implements KothTeam {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFactionTag(Player player) {
|
||||
public String getTeamName(Player player) {
|
||||
Team team = Team.getTeam(player);
|
||||
return team == null ? player.getName() : team.getName();
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class HuskTownHook implements KothTeam {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFactionTag(Player player) {
|
||||
public String getTeamName(Player player) {
|
||||
Optional<Town> optional = getTown(player);
|
||||
if (optional.isPresent()) return optional.get().getName();
|
||||
return player.getName();
|
||||
|
@ -24,7 +24,7 @@ public class LandHook implements KothTeam {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFactionTag(Player player) {
|
||||
public String getTeamName(Player player) {
|
||||
Optional<? extends Land> optional = getLandByPlayer(player);
|
||||
return optional.map(Land::getName).orElseGet(player::getName);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ public class NoneHook implements KothTeam {
|
||||
|
||||
|
||||
@Override
|
||||
public String getFactionTag(Player player) {
|
||||
public String getTeamName(Player player) {
|
||||
return player.getName();
|
||||
}
|
||||
|
||||
|
44
src/fr/maxlego08/koth/hook/teams/SaberFactionHook.java
Normal file
44
src/fr/maxlego08/koth/hook/teams/SaberFactionHook.java
Normal file
@ -0,0 +1,44 @@
|
||||
package fr.maxlego08.koth.hook.teams;
|
||||
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.event.FactionDisbandEvent;
|
||||
import fr.maxlego08.koth.KothPlugin;
|
||||
import fr.maxlego08.koth.api.KothTeam;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SaberFactionHook implements KothTeam {
|
||||
|
||||
private final KothPlugin plugin;
|
||||
|
||||
public SaberFactionHook(KothPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTeamName(Player player) {
|
||||
return FPlayers.getInstance().getByPlayer(player).getFaction().getTag();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Player> getOnlinePlayer(Player player) {
|
||||
return FPlayers.getInstance().getByPlayer(player).getFaction().getOnlinePlayers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLeaderName(Player player) {
|
||||
return FPlayers.getInstance().getByPlayer(player).getFaction().getFPlayerAdmin().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTeamId(Player player) {
|
||||
return FPlayers.getInstance().getByPlayer(player).getFactionId();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDisband(FactionDisbandEvent event) {
|
||||
this.plugin.getStorageManager().onTeamDisband(event.getFaction().getId());
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ public class SuperiorSkyblock2Hook implements KothTeam {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFactionTag(Player player) {
|
||||
public String getTeamName(Player player) {
|
||||
Island island = getIsland(player);
|
||||
return island == null ? player.getName() : getIsland(player).getName();
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ public enum Message {
|
||||
ALREADY_EXIST("§cThe koth §f%name% §calready exists."),
|
||||
KOTH_SIZE("§cYour koth is too small, you can't create one that small. Then you will come on discord for support when the problem comes from you."),
|
||||
DOESNT_EXIST("§cThe koth §f%name% §cdoesnt exists."),
|
||||
COMMAND_CREATE("§7You have just added the command §8\"§f%command%§8\""),
|
||||
|
||||
EVENT_START(MessageType.CENTER,
|
||||
"§8§m-+------------------------------+-",
|
||||
@ -90,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-+------------------------------+-"
|
||||
|
@ -7,7 +7,7 @@ public enum Permission {
|
||||
ZKOTH_NOW,
|
||||
ZKOTH_AXE,
|
||||
ZKOTH_LIST,
|
||||
ZKOTH_CREATE, ZKOTH_SPAWN, ZKOTH_STOP, ZKOTH_MOVE, ZKOTH_DELETE, ZKOTH_LOOT;
|
||||
ZKOTH_CREATE, ZKOTH_SPAWN, ZKOTH_STOP, ZKOTH_MOVE, ZKOTH_DELETE, ZKOTH_LOOT, ZKOTH_COMMAND_ADD;
|
||||
|
||||
private String permission;
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
# /zkoth version - no permission - Show plugin version
|
||||
# /zkoth list - zkoth.list - Get koth list
|
||||
# /zkoth loot <koth name> [<page>] - zkoth.loot - Change loot for a koth
|
||||
# /zkoth addcommand <koth name> <start/win> <command> - zkoth.command.add - Add new command
|
||||
#
|
||||
# Placeholders:
|
||||
# %zkoth_world% - Current koth world
|
||||
@ -39,6 +40,11 @@
|
||||
# %zkoth_capture_format% - Current koth capture seconds formatted
|
||||
# %zkoth_player_name% - Current koth capture player name
|
||||
# %zkoth_team_name% - Current koth capture player team name
|
||||
# %zkoth_team_id% - Current koth capture player team id
|
||||
# %zkoth_team_leader% - Current koth capture player team leader name
|
||||
# %zkoth_active_<koth name>% - Lets you know if a koth is active
|
||||
# %zkoth_cooldown_<koth name>% - Lets you know if a koth is in cooldown
|
||||
# %zkoth_start_<koth name>% - Lets you know if a koth is start
|
||||
#
|
||||
# Supported Scoreboard Plugin:
|
||||
# - FeatherBoard
|
||||
@ -51,6 +57,10 @@
|
||||
# - HuskTown
|
||||
# - SuperiorSkyblock2
|
||||
# - BetterTeams
|
||||
# - SaberFaction
|
||||
# - FactionUUID
|
||||
#
|
||||
# Need scheduler ? Use zScheduler: https://www.spigotmc.org/resources/zschedulers.112705/
|
||||
#
|
||||
#########################################################################################################
|
||||
|
||||
|
@ -1,34 +1,4 @@
|
||||
|
||||
name: test
|
||||
|
||||
type: CAPTURE
|
||||
capture: 30
|
||||
|
||||
cooldownStart: 300
|
||||
|
||||
stopAfterSeconds: 3600
|
||||
|
||||
enableStartCapMessage: true
|
||||
enableLooseCapMessage: true
|
||||
|
||||
# Available placeholders:
|
||||
# - %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
|
||||
startCommands: []
|
||||
|
||||
# Available placeholders:
|
||||
# You can use these placeholders for scoreboards and messages.
|
||||
# - %online-player% - Allows to run the order to all online players of the team
|
||||
# - %name% - Koth name
|
||||
# - %world% - World name
|
||||
@ -45,16 +15,46 @@ startCommands: []
|
||||
# - %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)
|
||||
|
||||
# Koth display name
|
||||
name: test
|
||||
|
||||
# Koth type
|
||||
type: CAPTURE
|
||||
|
||||
# Capture time or score to achieve
|
||||
capture: 30
|
||||
|
||||
# Time in seconds to spawn koth with /koth spawn command
|
||||
cooldownStart: 300
|
||||
|
||||
# Time in seconds to automatically stop koth
|
||||
stopAfterSeconds: 3600
|
||||
|
||||
# Activate the message when a player starts capturing the koth
|
||||
enableStartCapMessage: true
|
||||
|
||||
# Activate the message when a player loses the koth capture
|
||||
enableLooseCapMessage: true
|
||||
|
||||
# Commands that will be executed when the koth is launched
|
||||
startCommands: []
|
||||
|
||||
# Commands that will be executed when the koth is won by a player
|
||||
endCommands: []
|
||||
|
||||
# First location
|
||||
minLocation:
|
||||
world: world
|
||||
x: 0
|
||||
y: 0
|
||||
z: 0
|
||||
|
||||
# Second location
|
||||
manLocation:
|
||||
world: world
|
||||
x: 0
|
||||
|
@ -3,7 +3,7 @@ author: Maxlego08
|
||||
main: fr.maxlego08.koth.KothPlugin
|
||||
website: https://www.spigotmc.org/resources/76749/
|
||||
description: Default plugin developed by GroupeZ
|
||||
version: 3.0.0
|
||||
version: ${project.version}
|
||||
api-version: 1.13
|
||||
softdepend:
|
||||
- PlaceholderAPI
|
||||
|
Loading…
Reference in New Issue
Block a user