use of rocks.gravili.notquests.paper.structs.objectives.ReachLocationObjective in project NotQuests by AlessioGr.
the class WorldEditManager method handleReachLocationObjectiveCreation.
public void handleReachLocationObjectiveCreation(final Player player, final String locationName, @NonNull final CommandContext<CommandSender> context) {
// WorldEdit's native Player class extends Actor
BukkitPlayer actor = BukkitAdapter.adapt(player);
SessionManager manager = main.getIntegrationsManager().getWorldEditManager().getWorldEdit().getWorldEdit().getSessionManager();
LocalSession localSession = manager.get(actor);
Region region;
com.sk89q.worldedit.world.World selectionWorld = localSession.getSelectionWorld();
try {
if (selectionWorld == null)
throw new IncompleteRegionException();
region = localSession.getSelection(selectionWorld);
final Location min = new Location(BukkitAdapter.adapt(selectionWorld), region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ());
final Location max = new Location(BukkitAdapter.adapt(selectionWorld), region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ());
// Create Objective
ReachLocationObjective reachLocationObjective = new ReachLocationObjective(main);
reachLocationObjective.setLocationName(locationName);
reachLocationObjective.setMinLocation(min);
reachLocationObjective.setMaxLocation(max);
main.getObjectiveManager().addObjective(reachLocationObjective, context);
} catch (IncompleteRegionException ex) {
player.sendMessage(main.parse("<error>Please make a region selection using WorldEdit first."));
}
}
Aggregations