default Optional<Home> getHome(User user, String name) { return getHome(user.getUniqueId(), name); }
/** * Modifies a home's location, if it exists, otherwise creates a home. This is subject to Nucleus' standard checks. * * @param cause The {@link Cause} of the change. The {@link PluginContainer} must be the root cause. * @param user The {@link UUID} of the user to modify the home for. * @param name The name of the home to modify or create. * @param location The location of the home. * @param rotation The rotation of the player when they return to this home. * @throws NucleusException if the home could not be created, due to home limits, or a plugin cancelled the event. */ default void modifyOrCreateHome(Cause cause, User user, String name, Location<World> location, Vector3d rotation) throws NucleusException { if (getHome(user, name).isPresent()) { modifyHome(cause, user, name, location, rotation); } else { createHome(cause, user, name, location, rotation); } }
/** * Removes a home. * * @param cause The {@link Cause} of the change. The {@link PluginContainer} must be the root cause. * @param user The {@link UUID} of the user to remove the home of. * @param name The name of the home to remove. * @throws NucleusException if the home could not be found, or a plugin cancelled the event. */ default void removeHome(Cause cause, UUID user, String name) throws NucleusException { removeHome(cause, getHome(user, name).orElseThrow(() -> new NucleusException(Text.of("Home does not exist"), NucleusException.ExceptionType.DOES_NOT_EXIST))); }
/** * Modifies a home's location. * * @param cause The {@link Cause} of the change. The {@link PluginContainer} must be the root cause. * @param user The {@link UUID} of the user to modify the home for. * @param name The name of the home to modify. * @param location The location of the home. * @param rotation The rotation of the player when they return to this home. * @throws NucleusException if the home could not be found, or a plugin cancelled the event. */ default void modifyHome(Cause cause, UUID user, String name, Location<World> location, Vector3d rotation) throws NucleusException { modifyHome(cause, getHome(user, name).orElseThrow(() -> new NucleusException(Text.of("Home does not exist"), NucleusException.ExceptionType.DOES_NOT_EXIST)), location, rotation); }