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!");
}
Aggregations