🚧 Add start now command

This commit is contained in:
Maxlego08 2024-02-22 14:38:52 +01:00
parent 252de85ee7
commit a9d5d395ce
8 changed files with 133 additions and 17 deletions

View File

@ -85,6 +85,14 @@
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>krypton</id>
<url>https://repo.kryptonmc.org/releases</url>
</repository>
<repository>
<id>william278.net</id>
<url>https://repo.william278.net/releases</url>
</repository>
</repositories>
<dependencies>
<dependency>
@ -111,6 +119,57 @@
<version>3.11.50</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.booksaw</groupId>
<artifactId>BetterTeams</artifactId>
<version>4.8.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.MrUniverse44</groupId>
<artifactId>ScaredClansAPI</artifactId>
<version>0.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.neznamy</groupId>
<artifactId>tab-api</artifactId>
<version>4.0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.william278</groupId>
<artifactId>husktowns</artifactId>
<version>2.6.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.angeschossen</groupId>
<artifactId>LandsAPI</artifactId>
<version>6.44.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.ShieldCommunity</groupId>
<artifactId>SternalBoard</artifactId>
<version>2.2.0</version>
<scope>system</scope>
<systemPath>${basedir}/libs/SternalBoard-2.2.8-all.jar</systemPath>
</dependency>
<dependency>
<groupId>be.maximvdw.featherboard</groupId>
<artifactId>FeatherBoard</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${basedir}/libs/FeatherBoard.jar</systemPath>
</dependency>
<dependency>
<groupId>io.puharesource.mc.titlemanager</groupId>
<artifactId>TitleManager</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${basedir}/libs/TitleManager-2.3.6.jar</systemPath>
</dependency>
</dependencies>
<properties>
<maven.compiler.target>8</maven.compiler.target>

View File

@ -17,6 +17,7 @@ import fr.maxlego08.koth.zcore.utils.storage.Persist;
import fr.maxlego08.koth.zcore.utils.storage.Savable;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -111,7 +112,8 @@ public class KothManager extends ZUtils implements Savable {
public void createKoth(Player player, String name, Location minLocation, Location maxLocation, int capture, KothType kothType) {
Optional<Koth> optional = getKoth(name);
String fileName = name.replace(" ", "_");
Optional<Koth> optional = getKoth(fileName);
if (optional.isPresent()) {
message(player, Message.ALREADY_EXIST, "%name%", name);
return;
@ -123,7 +125,6 @@ public class KothManager extends ZUtils implements Savable {
return;
}
String fileName = name.replace(" ", "_");
Koth koth = new ZKoth(this.plugin, fileName, kothType, name, capture, minLocation, maxLocation);
KothCreateEvent event = new KothCreateEvent(koth);
@ -141,7 +142,7 @@ public class KothManager extends ZUtils implements Savable {
}
private Optional<Koth> getKoth(String name) {
return this.koths.stream().filter(koth -> name != null && koth.getName().equalsIgnoreCase(name)).findFirst();
return this.koths.stream().filter(koth -> name != null && koth.getFileName().equalsIgnoreCase(name)).findFirst();
}
public KothTeam getKothTeam() {
@ -155,4 +156,28 @@ public class KothManager extends ZUtils implements Savable {
public List<Koth> getEnableKoths() {
return koths.stream().filter(koth -> koth.getStatus() == KothStatus.COOLDOWN).collect(Collectors.toList());
}
public List<String> getNameKoths() {
return this.koths.stream().map(Koth::getFileName).collect(Collectors.toList());
}
public void spawnKoth(CommandSender sender, String name, boolean now) {
Optional<Koth> optional = getKoth(name);
if (!optional.isPresent()) {
message(sender, Message.DOESNT_EXIST, "%name%", name);
return;
}
Koth koth = optional.get();
koth.spawn(sender, now);
/*if (Config.enableScoreboard) {
this.manager.setLinesAndSchedule(koth.onScoreboard());
for (Player player : Bukkit.getOnlinePlayers()) {
this.manager.createBoard(player, Config.scoreboardTitle);
}
}*/
}
}

View File

@ -7,18 +7,19 @@ import fr.maxlego08.koth.zcore.utils.commands.CommandType;
public class CommandKoth extends VCommand {
public CommandKoth(KothPlugin plugin) {
super(plugin);
this.setPermission(Permission.ZKOTH_USE);
this.addSubCommand(new CommandKothReload(plugin));
this.addSubCommand(new CommandKothAxe(plugin));
this.addSubCommand(new CommandKothCreate(plugin));
}
public CommandKoth(KothPlugin plugin) {
super(plugin);
this.setPermission(Permission.ZKOTH_USE);
this.addSubCommand(new CommandKothReload(plugin));
this.addSubCommand(new CommandKothAxe(plugin));
this.addSubCommand(new CommandKothCreate(plugin));
this.addSubCommand(new CommandKothNow(plugin));
}
@Override
protected CommandType perform(KothPlugin plugin) {
syntaxMessage();
return CommandType.SUCCESS;
}
@Override
protected CommandType perform(KothPlugin plugin) {
syntaxMessage();
return CommandType.SUCCESS;
}
}

View File

@ -23,7 +23,7 @@ public class CommandKothCreate extends VCommand {
this.setConsoleCanUse(false);
this.addRequireArg("name");
this.addOptionalArg("type", (a, b) -> Arrays.stream(KothType.values()).map(e -> e.name().toLowerCase()).collect(Collectors.toList()));
this.addOptionalArg("capture/score");
this.addOptionalArg("capture/score", (a, b) -> Arrays.asList("10", "20", "30", "40", "50", "60"));
}
@Override

View File

@ -0,0 +1,29 @@
package fr.maxlego08.koth.command.commands;
import fr.maxlego08.koth.KothPlugin;
import fr.maxlego08.koth.command.VCommand;
import fr.maxlego08.koth.save.Config;
import fr.maxlego08.koth.zcore.enums.Message;
import fr.maxlego08.koth.zcore.enums.Permission;
import fr.maxlego08.koth.zcore.utils.commands.CommandType;
public class CommandKothNow extends VCommand {
public CommandKothNow(KothPlugin plugin) {
super(plugin);
this.setPermission(Permission.ZKOTH_NOW);
this.addSubCommand("now");
this.setDescription(Message.DESCRIPTION_NOW);
this.addRequireArg("name", (a,b) -> plugin.getKothManager().getNameKoths());
}
@Override
protected CommandType perform(KothPlugin plugin) {
String name = argAsString(0);
this.manager.spawnKoth(sender, name, true);
return CommandType.SUCCESS;
}
}

View File

@ -44,6 +44,7 @@ public enum Message {
RELOAD("§aYou have just reloaded the configuration files."),
DESCRIPTION_RELOAD("Reload configuration files"),
DESCRIPTION_NOW("Spawn a koth without cooldown"),
DESCRIPTION_AXE("Getting the selection axe"),
DESCRIPTION_CREATE("Create new koth"),

View File

@ -4,8 +4,8 @@ public enum Permission {
ZKOTH_USE,
ZKOTH_RELOAD,
ZKOTH_NOW,
ZKOTH_AXE,
ZKOTH_CREATE;
private String permission;

View File

@ -12,6 +12,7 @@
# /zkoth reload - zkoth.reload - Reload configuration files
# /zkoth axe - zkoth.axe - Getting the selection axe
# /zkoth create <koth name> [<koth type>] [<capture/score] - zkoth.create - Create koth
# /zkoth now <koth name> - zkoth.now - Spawn a koth without cooldown
#
# Placeholders:
#