use of com.skelril.skree.service.RegionService in project Skree by Skelril.
the class RegionListMarkersCommand method execute.
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
if (!(src instanceof Player)) {
src.sendMessage(Text.of("You must be a player to use this command (for now ;) )!"));
return CommandResult.empty();
}
Optional<RegionService> optService = Sponge.getServiceManager().provide(RegionService.class);
if (!optService.isPresent()) {
src.sendMessage(Text.of(TextColors.DARK_RED, "The region service is not currently running."));
return CommandResult.empty();
}
RegionService service = optService.get();
Player player = (Player) src;
Optional<Region> optRef = service.getSelectedRegion(player);
if (!optRef.isPresent()) {
player.sendMessage(Text.of(TextColors.RED, "You do not currently have a region selected."));
return CommandResult.empty();
}
Region ref = optRef.get();
PaginationService pagination = Sponge.getServiceManager().provideUnchecked(PaginationService.class);
List<RegionPoint> points = ref.getPoints();
List<Text> result = ref.getFullPoints().stream().map(a -> Text.of((points.contains(a) ? TextColors.GREEN : TextColors.RED), a.getFloorX(), ", ", a.getFloorY(), ", ", a.getFloorZ())).collect(Collectors.toList());
pagination.builder().contents(result).title(Text.of(TextColors.GOLD, "Region Markers")).padding(Text.of(" ")).sendTo(src);
return CommandResult.success();
}
use of com.skelril.skree.service.RegionService in project Skree by Skelril.
the class RegionListMembersCommand method execute.
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
if (!(src instanceof Player)) {
src.sendMessage(Text.of("You must be a player to use this command (for now ;) )!"));
return CommandResult.empty();
}
Optional<RegionService> optService = Sponge.getServiceManager().provide(RegionService.class);
if (!optService.isPresent()) {
src.sendMessage(Text.of(TextColors.DARK_RED, "The region service is not currently running."));
return CommandResult.empty();
}
RegionService service = optService.get();
Player player = (Player) src;
Optional<Region> optRef = service.getSelectedRegion(player);
if (!optRef.isPresent()) {
player.sendMessage(Text.of(TextColors.RED, "You do not currently have a region selected."));
return CommandResult.empty();
}
Region ref = optRef.get();
UserStorageService userService = Sponge.getServiceManager().provideUnchecked(UserStorageService.class);
PaginationService pagination = Sponge.getServiceManager().provideUnchecked(PaginationService.class);
List<Text> result = ref.getMembers().stream().map(userService::get).filter(Optional::isPresent).map(Optional::get).sorted((a, b) -> a.getName().compareToIgnoreCase(b.getName())).map(a -> Text.of((a.isOnline() ? TextColors.GREEN : TextColors.RED), a.getName())).collect(Collectors.toList());
pagination.builder().contents(result).title(Text.of(TextColors.GOLD, "Region Members")).padding(Text.of(" ")).sendTo(src);
return CommandResult.success();
}
use of com.skelril.skree.service.RegionService in project Skree by Skelril.
the class RegionMaster method onBlockInteract.
@Listener
public void onBlockInteract(InteractBlockEvent.Primary event, @Root Player player) {
BlockSnapshot targetBlock = event.getTargetBlock();
if (targetBlock.getState().getType() != this) {
return;
}
Optional<Location<World>> optLoc = targetBlock.getLocation();
if (!optLoc.isPresent()) {
return;
}
Optional<RegionService> optService = Sponge.getServiceManager().provide(RegionService.class);
if (!optService.isPresent()) {
return;
}
RegionService service = optService.get();
Optional<Region> optRef = service.getMarkedRegion(optLoc.get());
if (optRef.isPresent()) {
Region ref = optRef.get();
service.setSelectedRegion(player, ref);
player.sendMessage(Text.of(TextColors.YELLOW, "Region selected!"));
}
}
Aggregations