use of com.skelril.skree.service.WorldService 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.WorldService in project Skree by Skelril.
the class WorldCommand 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);
Optional<WorldProperties> optProperties = args.getOne("world");
if (!optProperties.isPresent()) {
src.sendMessage(Text.of(TextColors.YELLOW, "You are in: " + ((Player) src).getWorld().getName() + "."));
return CommandResult.empty();
}
Optional<World> optWorld = Sponge.getServer().getWorld(optProperties.get().getWorldName());
if (!optWorld.isPresent()) {
src.sendMessage(Text.of(TextColors.RED, "No loaded world by that name found."));
return CommandResult.empty();
}
World world = optWorld.get();
if (!WorldEntryPermissionCheck.checkDestination((Player) src, world)) {
src.sendMessage(Text.of(TextColors.RED, "You do not have permission to access worlds of this type."));
return CommandResult.empty();
}
Optional<Location<World>> optLoc = SafeTeleportHelper.teleport((Entity) src, optWorld.get().getSpawnLocation());
if (optLoc.isPresent()) {
src.sendMessage(Text.of(TextColors.YELLOW, "Entered world: " + world.getName() + " successfully!"));
} else if (args.hasAny("f")) {
((Player) src).setLocation(optWorld.get().getSpawnLocation());
src.sendMessage(Text.of(TextColors.YELLOW, "Force entered world: " + world.getName() + " successfully!"));
} else {
src.sendMessage(Text.of(TextColors.YELLOW, "Failed to enter " + world.getName() + " please report this!"));
}
return CommandResult.success();
}
use of com.skelril.skree.service.WorldService 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.WorldService 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();
}
use of com.skelril.skree.service.WorldService in project Skree by Skelril.
the class ZoneSystem method init.
@NModuleTrigger(trigger = "SERVER_STARTED", dependencies = { "World System" })
public void init() {
Optional<WorldService> optService = Sponge.getServiceManager().provide(WorldService.class);
World world = optService.get().getEffectWrapper(InstanceWorldWrapper.class).get().getWorlds().iterator().next();
Task.builder().execute(() -> {
WorldResolver instWorldResolver = new WorldResolver(world, WorldEdit.getInstance());
service = new ZoneServiceImpl(new CacheBasedAllocator(Decorators.ZONE_PRIMARY_DECORATOR, instWorldResolver));
service.registerManager(new CursedMineManager());
service.registerManager(new TempleOfFateManager());
service.registerManager(new TheForgeManager());
service.registerManager(new CatacombsManager());
service.registerManager(new FreakyFourManager());
service.registerManager(new GoldRushManager());
service.registerManager(new JungleRaidManager());
service.registerManager(new PatientXManager());
service.registerManager(new ShnugglesPrimeManager());
service.registerManager(new SkyWarsManager());
Sponge.getServiceManager().setProvider(SkreePlugin.inst(), ZoneService.class, service);
Sponge.getCommandManager().register(SkreePlugin.inst(), ZoneMeCommand.aquireSpec(), "zoneme");
}).delayTicks(1).submit(SkreePlugin.inst());
}
Aggregations