Search in sources :

Example 1 with BungeeCordHandler

use of com.gmail.stefvanschiedev.buildinggame.utils.bungeecord.BungeeCordHandler in project buildinggame by stefvanschie.

the class BuildingGameCommand method onSetMainSpawn.

@Subcommand("setmainspawn")
@Description("Set the main spawn")
@CommandPermission("bg.setmainspawn")
// ACF may not function correctly when Player is changed to Entity due to the reliance on reflection
@SuppressWarnings("TypeMayBeWeakened")
public void onSetMainSpawn(Player player) {
    ConfigurationSection config = SettingsManager.getInstance().getConfig();
    BungeeCordHandler instance = BungeeCordHandler.getInstance();
    var location = player.getLocation();
    instance.write(BungeeCordHandler.Receiver.MAIN, "arenas.yml", "main-spawn.server", config.getString("this-server.name"), null);
    instance.write(BungeeCordHandler.Receiver.MAIN, "arenas.yml", "main-spawn.world", player.getWorld().getName(), null);
    instance.write(BungeeCordHandler.Receiver.MAIN, "arenas.yml", "main-spawn.x", "(int)" + location.getBlockX(), null);
    instance.write(BungeeCordHandler.Receiver.MAIN, "arenas.yml", "main-spawn.y", "(int)" + location.getBlockY(), null);
    instance.write(BungeeCordHandler.Receiver.MAIN, "arenas.yml", "main-spawn.z", "(int)" + location.getBlockZ(), null);
    instance.save(BungeeCordHandler.Receiver.MAIN, null);
    player.sendMessage(ChatColor.GREEN + "Main spawn set!");
}
Also used : BungeeCordHandler(com.gmail.stefvanschiedev.buildinggame.utils.bungeecord.BungeeCordHandler) ConfigurationSection(org.bukkit.configuration.ConfigurationSection) Description(co.aikar.commands.annotation.Description) Subcommand(co.aikar.commands.annotation.Subcommand) CommandPermission(co.aikar.commands.annotation.CommandPermission)

Aggregations

CommandPermission (co.aikar.commands.annotation.CommandPermission)1 Description (co.aikar.commands.annotation.Description)1 Subcommand (co.aikar.commands.annotation.Subcommand)1 BungeeCordHandler (com.gmail.stefvanschiedev.buildinggame.utils.bungeecord.BungeeCordHandler)1 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)1