use of com.skelril.skree.service.internal.world.WorldEffectWrapper in project Skree by Skelril.
the class WorldListCommand method execute.
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
WorldService service = Sponge.getServiceManager().provideUnchecked(WorldService.class);
List<WorldEffectWrapper> worldEffectWrapperList = service.getEffectWrappers().stream().sorted((a, b) -> a.getName().compareToIgnoreCase(b.getName())).collect(Collectors.toList());
for (WorldEffectWrapper wrapper : worldEffectWrapperList) {
String worldType = wrapper.getName();
if (!src.hasPermission("skree.world." + worldType.toLowerCase() + ".teleport")) {
continue;
}
src.sendMessage(Text.of(TextColors.GOLD, "Available ", worldType, " worlds (click to teleport):"));
for (World world : wrapper.getWorlds()) {
String worldName = world.getName();
String prettyName = worldName.replaceAll("_", " ");
src.sendMessage(Text.of(TextColors.YELLOW, TextActions.runCommand("/world " + worldName), TextActions.showText(Text.of("Teleport to " + prettyName)), " - ", prettyName));
}
}
return CommandResult.success();
}
use of com.skelril.skree.service.internal.world.WorldEffectWrapper in project Skree by Skelril.
the class ZoneTransitionalOrb method isInInstanceWorld.
private boolean isInInstanceWorld(Player player) {
Optional<WorldService> optWorldService = Sponge.getServiceManager().provide(WorldService.class);
if (!optWorldService.isPresent()) {
return false;
}
WorldService worldService = optWorldService.get();
WorldEffectWrapper wrapper = worldService.getEffectWrapper(InstanceWorldWrapper.class).get();
return wrapper.getWorlds().contains(player.getLocation().getExtent());
}
use of com.skelril.skree.service.internal.world.WorldEffectWrapper in project Skree by Skelril.
the class ZoneMasterOrb method isInInstanceWorld.
private boolean isInInstanceWorld(Player player) {
Optional<WorldService> optWorldService = Sponge.getServiceManager().provide(WorldService.class);
if (optWorldService.isPresent()) {
WorldService worldService = optWorldService.get();
WorldEffectWrapper wrapper = worldService.getEffectWrapper(InstanceWorldWrapper.class).get();
if (wrapper.getWorlds().contains(player.getLocation().getExtent())) {
return true;
}
}
return false;
}
use of com.skelril.skree.service.internal.world.WorldEffectWrapper in project Skree by Skelril.
the class WorldEntryPermissionCheck method checkDestination.
public static boolean checkDestination(Player player, World world) {
WorldService service = Sponge.getServiceManager().provideUnchecked(WorldService.class);
Optional<WorldEffectWrapper> optEffectWrapper = service.getEffectWrapperFor(world);
String worldType = "misc";
if (optEffectWrapper.isPresent()) {
worldType = optEffectWrapper.get().getName();
}
return player.hasPermission("skree.world." + worldType.toLowerCase() + ".teleport");
}
use of com.skelril.skree.service.internal.world.WorldEffectWrapper in project Skree by Skelril.
the class SummonWandererCommand 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!"));
return CommandResult.empty();
}
WorldService service = Sponge.getServiceManager().provideUnchecked(WorldService.class);
World world = ((Player) src).getWorld();
Optional<WorldEffectWrapper> optWrapper = service.getEffectWrapperFor(world);
if (!optWrapper.isPresent()) {
src.sendMessage(Text.of("This command can only be used in the Wilderness."));
return CommandResult.empty();
}
WorldEffectWrapper wrapper = optWrapper.get();
if (!(wrapper instanceof WildernessWorldWrapper)) {
src.sendMessage(Text.of("This command can only be used in the Wilderness."));
return CommandResult.empty();
}
Location<World> targetLocation = ((Player) src).getLocation();
int playerWildernessLevel = ((WildernessWorldWrapper) wrapper).getLevel(targetLocation).get();
int targetLevel = args.<Integer>getOne("target level").orElse(playerWildernessLevel);
if (targetLevel < 1) {
src.sendMessage(Text.of("The target level must be at least 1."));
return CommandResult.empty();
}
String wanderer = args.<String>getOne("wanderer").get();
((WildernessWorldWrapper) wrapper).getWanderingMobManager().summon(wanderer, targetLevel, targetLocation);
return CommandResult.success();
}
Aggregations