-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDeleteZoneCommand.java
More file actions
33 lines (29 loc) · 1.41 KB
/
DeleteZoneCommand.java
File metadata and controls
33 lines (29 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package net.onelitefeather.labyrinth.commands;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.onelitefeather.labyrinth.Labyrinth;
import net.onelitefeather.labyrinth.utils.Constants;
import org.bukkit.entity.Player;
import org.incendo.cloud.annotations.Argument;
import org.incendo.cloud.annotations.Command;
import org.incendo.cloud.annotations.Permission;
@Command("labyrinth")
public record DeleteZoneCommand(Labyrinth labyrinth) {
@Command("delete <zone>")
@Permission("labyrinth.setup.deletezone")
public void deleteZone(Player player, @Argument(value = "zone", suggestions = "zones") String zone) {
var zoneString = Constants.CONFIG_ZONE_PATH.formatted(zone);
if(labyrinth.getConfig().contains(zoneString)) {
labyrinth.getConfig().set(zoneString, null);
labyrinth.saveConfig();
var message = MiniMessage.miniMessage().deserialize(Constants.DELETE_ZONE_MESSAGE_SUCCESS,
Placeholder.unparsed("zone", zone),
Placeholder.component("prefix", Constants.PREFIX));
player.sendMessage(message);
} else {
var message = MiniMessage.miniMessage().deserialize(Constants.ZONE_INVALID_MESSAGE,
Placeholder.component("prefix", Constants.PREFIX));
player.sendMessage(message);
}
}
}