当前位置: 首页>>代码示例>>Java>>正文


Java Locatable类代码示例

本文整理汇总了Java中org.spongepowered.api.world.Locatable的典型用法代码示例。如果您正苦于以下问题:Java Locatable类的具体用法?Java Locatable怎么用?Java Locatable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Locatable类属于org.spongepowered.api.world包,在下文中一共展示了Locatable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.spongepowered.api.world.Locatable; //导入依赖的package包/类
@Override
public CompletableFuture<Boolean> execute(final CommandSource source, final List<String> args) {
	if (args.size() == 2){
		if (source instanceof Locatable){
			return this.commandWorldborderCenter(source, ((Locatable) source).getWorld(), args.get(0), args.get(1));
		} else {
			EAMessages.COMMAND_ERROR_FOR_PLAYER.sender()
				.prefix(EEMessages.PREFIX)
				.sendTo(source);
		}
	} else if (args.size() == 3){
		Optional<World> world = this.plugin.getEServer().getWorld(args.get(2));
		if (world.isPresent()){
			return this.commandWorldborderCenter(source, world.get(), args.get(0), args.get(1));
		} else {
			EAMessages.WORLD_NOT_FOUND.sender()
				.prefix(EEMessages.PREFIX)
				.replace("{world}", args.get(2))
				.sendTo(source);
		}
	} else {
		source.sendMessage(this.help(source));
	}
	
	return CompletableFuture.completedFuture(false);
}
 
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:27,代码来源:EEWorldborderCenter.java

示例2: execute

import org.spongepowered.api.world.Locatable; //导入依赖的package包/类
@Override
public CompletableFuture<Boolean> execute(final CommandSource source, final List<String> args) {
	if (args.size() == 0) {
		if (source instanceof Locatable) {
			return this.commandWorldborder(source, ((Locatable) source).getWorld());
		} else {
			EAMessages.COMMAND_ERROR_FOR_PLAYER.sender()
				.prefix(EEMessages.PREFIX)
				.sendTo(source);
		}
	} else if (args.size() == 1){
		Optional<World> world = this.plugin.getEServer().getWorld(args.get(0));
		if (world.isPresent()) {
			return this.commandWorldborder(source, world.get());
		} else {
			EAMessages.WORLD_NOT_FOUND.sender()
				.prefix(EEMessages.PREFIX)
				.replace("{world}", args.get(0))
				.sendTo(source);
		}
	} else {
		source.sendMessage(this.help(source));
	}
	
	return CompletableFuture.completedFuture(false);
}
 
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:27,代码来源:EEWorldborderInfo.java

示例3: accumulateContexts

import org.spongepowered.api.world.Locatable; //导入依赖的package包/类
@Override
public void accumulateContexts(Subject subject, Set<Context> accumulator) {
    final Optional<CommandSource> subjSource = subject.getCommandSource();
    if (subjSource.isPresent()) {
        final CommandSource source = subjSource.get();
        if (source instanceof Locatable) {
            final World currentExt = ((Locatable) source).getWorld();
            accumulator.add(currentExt.getContext());
            accumulator.add((currentExt.getDimension().getContext()));
        }
        if (source instanceof RemoteSource) {
            final RemoteSource rem = (RemoteSource) source;
            accumulator.addAll(this.remoteIpCache.get(rem));
            accumulator.addAll(this.localIpCache.get(rem));
            accumulator.add(new Context(Context.LOCAL_PORT_KEY, String.valueOf(rem.getConnection().getVirtualHost().getPort())));
            accumulator.add(new Context(Context.LOCAL_HOST_KEY, rem.getConnection().getVirtualHost().getHostName()));
        }
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:20,代码来源:LanternContextCalculator.java

示例4: getWorldProperties0

import org.spongepowered.api.world.Locatable; //导入依赖的package包/类
private static LanternWorldProperties getWorldProperties0(@Nullable CommandSource src,
        Optional<WorldProperties> optWorldProperties) throws CommandException {
    WorldProperties world;
    if (optWorldProperties.isPresent()) {
        world = optWorldProperties.get();
    } else if (src instanceof Locatable) {
        world = ((Locatable) src).getWorld().getProperties();
    } else {
        world = Sponge.getServer().getDefaultWorld().orElse(null);
        if (world == null) {
            // Shouldn't happen
            throw new CommandException(Text.of("Unable to find the default world."));
        }
    }
    return (LanternWorldProperties) world;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:17,代码来源:CommandHelper.java

示例5: execute

import org.spongepowered.api.world.Locatable; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException {
    checkPermission(sender, TimePermissions.UC_TIME_TIME_BASE);
    checkPermission(sender, TimePermissions.UC_TIME_TIME_DAY);

    World world;
    if (sender instanceof Locatable) {
        world = ((Locatable) sender).getWorld();
    } else {
        throw new ErrorMessageException(Messages.getFormatted(sender, "core.noplayer"));
    }
    Long ticks = 24000 - (world.getProperties().getWorldTime() % 24000);
    world.getProperties().setWorldTime(world.getProperties().getWorldTime() + ticks);
    Messages.send(sender, "time.command.time.set.day");
    return CommandResult.success();
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:17,代码来源:DayCommand.java

示例6: execute

import org.spongepowered.api.world.Locatable; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException {
    checkPermission(sender, TimePermissions.UC_TIME_TIME_BASE);
    checkPermission(sender, TimePermissions.UC_TIME_TIME_NIGHT);

    World world;
    if (sender instanceof Locatable) {
        world = ((Locatable) sender).getWorld();
    } else {
        throw new ErrorMessageException(Messages.getFormatted(sender, "core.noplayer"));
    }
    //Players can enter their bed at 12541 ticks
    Long ticks = 12541 - (world.getProperties().getWorldTime() % 24000);
    world.getProperties().setWorldTime(world.getProperties().getWorldTime() + ticks);
    Messages.send(sender, "time.command.time.set.night");
    return CommandResult.success();
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:18,代码来源:NightCommand.java

示例7: multipleEntities

import org.spongepowered.api.world.Locatable; //导入依赖的package包/类
/**
 * Returns a list of all entities which satisfy the string.
 * This can be empty if no entities are found.
 *
 * @param s The string to search for
 * @return All entities which statisfy the string
 */
public static List<Entity> multipleEntities(CommandSource source, String s) {
    List<Entity> matches = new ArrayList<>();

    Optional<Player> match = Sponge.getServer().getPlayer(s);
    match.ifPresent(matches::add);

    try {
        UUID uuid = UUID.fromString(s);
        if (source instanceof Locatable) {
            Locatable loc = (Locatable) source;
            Optional<Entity> en = loc.getWorld().getEntity(uuid);
            en.ifPresent(matches::add);
        }
    } catch (IllegalArgumentException ignored) {
    }

    if (s.startsWith("@")) {
        org.spongepowered.api.text.selector.Selector selector = org.spongepowered.api.text.selector.Selector.parse(s);
        selector.resolve(source).forEach(matches::add);
    }

    return matches;
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:31,代码来源:Selector.java

示例8: execute

import org.spongepowered.api.world.Locatable; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
	Collection<WorldProperties> worlds;

	if (args.hasAny(PARAM_WORLD)) {
		worlds = args.<WorldProperties>getAll(PARAM_WORLD);
	} else if (args.hasAny(PARAM_ALL)) {
		worlds = Sponge.getGame().getServer().getAllWorldProperties();
	} else if (src instanceof Locatable) {
		worlds = Collections.singleton(((Player) src).getWorld().getProperties());
	} else
		throw new CommandException(Text.of("You have to enter a world when using this from the console!"), true);

	final boolean mode = args.<Boolean>getOne(PARAM_MODE).get();
	final String permission = BASE_PERMISSION + '.' + (mode ? "enable" : "disable") + '.';
	final List<String> worldNames = worlds.stream().map(WorldProperties::getWorldName)
			.filter(world -> src.hasPermission(permission + world)).collect(Collectors.toList());

	worldNames.stream().forEach(world -> AuraSunDial.getConfig().setWorld(world, mode));

	AuraSunDial.getConfig().save();

	if (worldNames.size() > 0) {
		src.sendMessage(Text.of((mode ? "Enabled" : "Disabled") + " realtime on these worlds: "
				+ worldNames.stream().collect(Collectors.joining(", "))));
	} else
		throw new CommandPermissionException();

	return CommandResult.successCount(worldNames.size());
}
 
开发者ID:AuraDevelopmentTeam,项目名称:AuraSunDial,代码行数:31,代码来源:CommandRealTime.java

示例9: getWorld

import org.spongepowered.api.world.Locatable; //导入依赖的package包/类
public World getWorld() throws EMessageException {
	Optional<String> worldMarker = this.getValue(MARKER_WORLD);
	if (worldMarker.isPresent()) {
		Optional<World> world = plugin.getEServer().getEWorld(worldMarker.get());
		if (!world.isPresent()) throw new WorldNotFoundException(this.source, worldMarker.get());
		return world.get();
	}
	
	if (this.source instanceof Locatable) {
		return ((Locatable) source).getWorld();
	} else {
		return this.plugin.getEServer().getDefaultEWorld();
	}
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:15,代码来源:Args.java

示例10: accumulateContexts

import org.spongepowered.api.world.Locatable; //导入依赖的package包/类
/**
 * Ajoute le monde
 */
@Override
public void accumulateContexts(final Subject subject, final Set<Context> accumulator) {
	Optional<CommandSource> subjSource = subject.getCommandSource();
    if (subjSource.isPresent()) {
        CommandSource source = subjSource.get();
        if (source instanceof Locatable) {
            accumulator.add(new Context(Context.WORLD_KEY, ((Locatable) source).getWorld().getName()));
        }
    }
}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:14,代码来源:EPContextCalculator.java

示例11: matches

import org.spongepowered.api.world.Locatable; //导入依赖的package包/类
/**
 * Vérifie le monde
 */
@Override
public boolean matches(final Context context, final Subject subject) {
	if (context.getType().equals(Context.WORLD_KEY)) {
 	Optional<CommandSource> subjSource = subject.getCommandSource();
     if (subjSource.isPresent()) {
         CommandSource source = subjSource.get();
         if (source instanceof Locatable) {
         	return context.getName().equals(((Locatable) source).getWorld().getName());
         }
     }
	}
    return false;
}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:17,代码来源:EPContextCalculator.java

示例12: matches

import org.spongepowered.api.world.Locatable; //导入依赖的package包/类
@Override
public boolean matches(Context context, Subject subject) {
    final Optional<CommandSource> subjSource = subject.getCommandSource();
    if (subjSource.isPresent()) {
        final CommandSource source = subjSource.get();
        if (source instanceof Locatable) {
            final Locatable located = (Locatable) source;
            if (context.getType().equals(Context.WORLD_KEY)) {
                return located.getWorld().getContext().equals(context);
            } else if (context.getType().equals(Context.DIMENSION_KEY)) {
                return located.getWorld().getDimension().getContext().equals(context);
            }
        }
        if (source instanceof RemoteSource) {
            final RemoteSource remote = (RemoteSource) source;
            if (context.getType().equals(Context.LOCAL_HOST_KEY)) {
                return context.getValue().equals(remote.getConnection().getVirtualHost().getHostName());
            } else if (context.getType().equals(Context.LOCAL_PORT_KEY)) {
                return context.getValue().equals(String.valueOf(remote.getConnection().getVirtualHost().getPort()));
            } else if (context.getType().equals(Context.LOCAL_IP_KEY)) {
                return this.localIpCache.get(remote).contains(context);
            } else if (context.getType().equals(Context.REMOTE_IP_KEY)) {
                return this.remoteIpCache.get(remote).contains(context);
            }
        }
    }
    return false;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:29,代码来源:LanternContextCalculator.java

示例13: init

import org.spongepowered.api.world.Locatable; //导入依赖的package包/类
@Override
protected void init() {
    super.init();

    addCloseListener(inventory -> getCarrier().ifPresent(carrier -> {
        if (carrier instanceof Locatable) {
            final Transform<World> transform = new Transform<>(((Locatable) carrier).getLocation());
            final List<Tuple<ItemStackSnapshot, Transform<World>>> entries = new ArrayList<>();
            getCraftingGrid().slots().forEach(slot -> slot.poll().filter(stack -> !stack.isEmpty()).ifPresent(
                    stack -> entries.add(new Tuple<>(LanternItemStackSnapshot.wrap(stack), transform))));
            LanternEventHelper.handleDroppedItemSpawning(entries);
        }
    }));
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:15,代码来源:CraftingTableInventory.java

示例14: getWorld

import org.spongepowered.api.world.Locatable; //导入依赖的package包/类
/**
 * Attempts to get a {@link World} instance that is passed through in the
 * crafting system. By default, lets just use the first {@link World} that
 * we can find.
 *
 * @return The world
 */
@SuppressWarnings("unchecked")
@Nullable
protected World getWorld() {
    final Optional<Locatable> optLocatable = this.carrierReference.as(Locatable.class);
    if (optLocatable.isPresent()) {
        return optLocatable.get().getWorld();
    }
    final Iterator<World> it = Lantern.getWorldManager().getWorlds().iterator();
    return it.hasNext() ? it.next() : null;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:18,代码来源:LanternCraftingInventory.java

示例15: parseValue

import org.spongepowered.api.world.Locatable; //导入依赖的package包/类
@Override
protected Object parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException {
    String xStr;
    String yStr;
    String zStr;
    xStr = args.next();
    if (xStr.contains(",")) {
        String[] split = xStr.split(",");
        if (split.length != 3) {
            throw args.createError(t("Comma-separated location must have 3 elements, not %s", split.length));
        }
        xStr = split[0];
        yStr = split[1];
        zStr = split[2];
    } else if (xStr.equals("#target") && source instanceof Entity) {
        Optional<BlockRayHit<World>> hit = BlockRay.from(((Entity) source))
                .stopFilter(BlockRay.onlyAirFilter()).build().end();
        if (!hit.isPresent()) {
            throw args.createError(t("No target block is available! Stop stargazing!"));
        }
        return hit.get().getPosition();
    } else if (xStr.equalsIgnoreCase("#me") && source instanceof Locatable) {
        return ((Locatable) source).getLocation().getPosition();
    } else {
        yStr = args.next();
        zStr = args.next();
    }
    final RelativeDouble x = parseRelativeDouble(args, xStr);
    final RelativeDouble y = parseRelativeDouble(args, yStr);
    final RelativeDouble z = parseRelativeDouble(args, zStr);

    return new RelativeVector3d(x, y, z);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:34,代码来源:GenericArguments2.java


注:本文中的org.spongepowered.api.world.Locatable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。