Ajout du koth set capture

This commit is contained in:
Maxlego08 2021-01-07 11:55:03 +01:00
parent 36efa82f51
commit 7c8671e2e8
7 changed files with 76 additions and 6 deletions

View File

@ -499,4 +499,9 @@ public class ZKoth extends ZUtils implements Koth {
}
@Override
public void setCapture(int second) {
this.captureSeconds = second;
}
}

View File

@ -52,6 +52,7 @@ import fr.maxlego08.zkoth.zcore.logger.Logger.LogType;
import fr.maxlego08.zkoth.zcore.utils.Cuboid;
import fr.maxlego08.zkoth.zcore.utils.ZSelection;
import fr.maxlego08.zkoth.zcore.utils.builder.ItemBuilder;
import fr.maxlego08.zkoth.zcore.utils.builder.TimerBuilder;
import fr.maxlego08.zkoth.zcore.utils.storage.Persist;
import net.md_5.bungee.api.chat.ClickEvent.Action;
import net.md_5.bungee.api.chat.TextComponent;
@ -423,7 +424,8 @@ public class ZKothManager extends ListenerAdapter implements KothManager {
for (int a = 0; a != koth.getCommands().size(); a++) {
TextComponent textComponent = buildTextComponent(" §b#" + (a + 1) + " §f" + koth.getCommands().get(0));
setClickAction(textComponent, Action.SUGGEST_COMMAND, "/koth removec " + koth.getName() + " " + (a + 1));
setClickAction(textComponent, Action.SUGGEST_COMMAND,
"/koth removec " + koth.getName() + " " + (a + 1));
setHoverMessage(textComponent, "§7Click for remove command");
player.spigot().sendMessage(textComponent);
@ -542,4 +544,19 @@ public class ZKothManager extends ListenerAdapter implements KothManager {
}
@Override
public void setCaptureSeconds(CommandSender sender, String name, int second) {
Optional<Koth> optional = getKoth(name);
if (!optional.isPresent()) {
message(sender, Message.ZKOTH_DOESNT_EXIST.replace("%name%", name));
return;
}
Koth koth = optional.get();
koth.setCapture(second);
message(sender, "§aYou have just modified the capture time of the koth §n%s§a to §f%s§a.", koth.getName(),
TimerBuilder.getStringTime(second));
}
}

View File

@ -108,7 +108,7 @@ public interface Koth {
* @param factionListener
*/
public void playerMove(Player player, FactionListener factionListener);
/**
*
* @return
@ -132,10 +132,16 @@ public interface Koth {
* @param itemStacks
*/
public void setItemStacks(List<ItemStack> itemStacks);
/**
*
* @param sender
*/
public void stop(CommandSender sender);
/**
*
* @param second
*/
public void setCapture(int second);
}

View File

@ -76,7 +76,7 @@ public interface KothManager extends Saveable {
* @return
*/
public List<Koth> getActiveKoths();
/**
*
* @return true if have active koth
@ -91,6 +91,7 @@ public interface KothManager extends Saveable {
/**
* Show informations
*
* @param sender
* @param name
*/
@ -106,14 +107,16 @@ public interface KothManager extends Saveable {
/**
* Remove commands
*
* @param sender
* @param name
* @param id
*/
public void removeCommand(CommandSender sender, String name, int id);
/**
* Stop koth
*
* @param sender
* @param name
*/
@ -134,4 +137,12 @@ public interface KothManager extends Saveable {
*/
public void updateLoots(Player player, String name);
/**
*
* @param sender
* @param name
* @param second
*/
public void setCaptureSeconds(CommandSender sender, String name, int second);
}

View File

@ -24,6 +24,7 @@ public class CommandKoth extends VCommand {
this.addSubCommand(new CommandKothRemove());
this.addSubCommand(new CommandKothSetType());
this.addSubCommand(new CommandKothLoot());
this.addSubCommand(new CommandKothSetCapture());
this.addSubCommand(new CommandKothAxe());
}

View File

@ -0,0 +1,29 @@
package fr.maxlego08.zkoth.command.commands;
import fr.maxlego08.zkoth.ZKothPlugin;
import fr.maxlego08.zkoth.command.VCommand;
import fr.maxlego08.zkoth.zcore.enums.Permission;
import fr.maxlego08.zkoth.zcore.utils.commands.CommandType;
public class CommandKothSetCapture extends VCommand {
public CommandKothSetCapture() {
this.setPermission(Permission.ZKOTH_SETCAPTURE);
this.addSubCommand("setcapture", "setcap");
this.setDescription("Set capture time");
this.addRequireArg("name");
this.addRequireArg("capture");
}
@Override
protected CommandType perform(ZKothPlugin plugin) {
String name = argAsString(0);
int second = argAsInteger(1);
manager.setCaptureSeconds(sender, name, second);
return CommandType.SUCCESS;
}
}

View File

@ -16,7 +16,8 @@ public enum Permission {
ZKOTH_COMMAND_ADD,
ZKOTH_COMMAND_REMOVE,
ZKOTH_LOOT,
ZKOTH_TYPE,
ZKOTH_TYPE,
ZKOTH_SETCAPTURE,
;