-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCenterCommand.java
More file actions
39 lines (35 loc) · 1.73 KB
/
CenterCommand.java
File metadata and controls
39 lines (35 loc) · 1.73 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
34
35
36
37
38
39
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.service.api.ValidationService;
import net.onelitefeather.labyrinth.utils.Constants;
import org.bukkit.Location;
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 CenterCommand(Labyrinth labyrinth, ValidationService validationService) {
@Command("center <zone>")
@Permission("labyrinth.setup.center")
public void centerCommand(Player player, @Argument(value = "zone", suggestions = "zones") String zone) {
Location location = player.getLocation();
/**
* This location Y is important to be set to 0 for a cylindric region, see {@link SetRadiusCommand}
* */
location.setY(0);
if (validationService.validateZoneInput(player,zone)) {
this.labyrinth.getConfig().set(Constants.CONFIG_ZONE_CENTER_PATH.formatted(zone), location);
labyrinth.saveConfig();
var message = MiniMessage.miniMessage().deserialize(Constants.CENTER_COMMAND_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);
}
}
}