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


Java World类代码示例

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


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

示例1: tryCreateHologram

import org.spongepowered.api.world.World; //导入依赖的package包/类
public static Optional<HologramsService.Hologram> tryCreateHologram(Location<World> location, Optional<Text> optional_text) {
    if (!optional_text.isPresent()) {
        return Optional.empty();
    }
    Text text = optional_text.get();
    Optional<HologramsService> optional_hologram_service = GWMCrates.getInstance().getHologramsService();
    if (!optional_hologram_service.isPresent()) {
        GWMCrates.getInstance().getLogger().warn("Unable to create hologram, Holograms Service not found!");
        return Optional.empty();
    }
    HologramsService holograms_service = optional_hologram_service.get();
    location.getExtent().loadChunk(location.getChunkPosition(), true);
    Optional<HologramsService.Hologram> optional_hologram = holograms_service.
            createHologram(location.add(GWMCrates.getInstance().getHologramOffset()), text);
    if (!optional_hologram.isPresent()) {
        GWMCrates.getInstance().getLogger().warn("Holograms Service found, but hologram can not be created! :-(");
        return Optional.empty();
    }
    return optional_hologram;
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:21,代码来源:Utils.java

示例2: onBlockPrimaryInteract

import org.spongepowered.api.world.World; //导入依赖的package包/类
@Listener
public void onBlockPrimaryInteract(InteractBlockEvent.Primary.MainHand e, @First Player p) {
	if (!plugin.getInspectManager().isInspector(p))
		return;
	
	e.setCancelled(true);
	BlockSnapshot block = e.getTargetBlock();
	if (block == null || !block.getLocation().isPresent())
		return;
	
	Location<World> loc = block.getLocation().get();
	
	p.sendMessage(Text.of(TextColors.BLUE, "Querying database, please wait..."));
	Sponge.getScheduler().createAsyncExecutor(plugin).execute(() -> {
		plugin.getInspectManager().inspect(p, block.getWorldUniqueId(), loc.getBlockPosition()); });
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:17,代码来源:PlayerInspectListener.java

示例3: onLiquidFlow

import org.spongepowered.api.world.World; //导入依赖的package包/类
@Listener(order = Order.POST)
public void onLiquidFlow(ChangeBlockEvent.Pre e) {
	if (e.getLocations().isEmpty()) return;
			
	Location<World> loc = e.getLocations().get(0);
	BlockSnapshot snapshot = loc.getExtent().createSnapshot(loc.getBlockPosition());
	
	Optional<MatterProperty> matter = snapshot.getState().getProperty(MatterProperty.class);
	if (matter.isPresent() && matter.get().getValue() == Matter.LIQUID) {
		String name = "Water";
		BlockType type = snapshot.getState().getType();
		if (type == BlockTypes.LAVA || type == BlockTypes.FLOWING_LAVA)
			name = "Lava";
		db.addToQueue(new BlockQueueEntry(snapshot, ActionType.FLOW, name, new Date().getTime()));
	}
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:17,代码来源:LiquidFlowListener.java

示例4: performRemoval

import org.spongepowered.api.world.World; //导入依赖的package包/类
private void performRemoval(LookupLine line) {
	World w = Sponge.getServer().getWorld(line.getWorld()).orElse(null);
	if (w == null) return;
	
	if (line.getTarget() instanceof ItemType) {
		
		Optional<TileEntity> te = w.getTileEntity(line.getPos());
		if (te.isPresent() && te.get() instanceof TileEntityCarrier) {
			TileEntityCarrier c = (TileEntityCarrier) te.get();
			Inventory i = c.getInventory();
			
			Inventory slot = i.query(new SlotIndex(line.getSlot()));
			slot.set(ItemStack.of(ItemTypes.NONE, 0));
		}
		
	} else if (line.getTarget() instanceof BlockType) {
		
		BlockState block = BlockState.builder().blockType(BlockTypes.AIR).build();
		w.setBlock(line.getPos(), block, Cause.source(container).build());
		
	}
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:23,代码来源:RollbackManager.java

示例5: createTicket

import org.spongepowered.api.world.World; //导入依赖的package包/类
/***
 * Create a ticket, requested from the Ticket Manager which returns an Optional
 * @param world the world which the ticket should associate with
 * @return A LoadingTicket for force loading chunks
 */
private LoadingTicket createTicket(World world) {
	Optional<LoadingTicket> opTicket = ticketManager.createTicket(world);
	LoadingTicket newTicket = null;

	if (opTicket.isPresent()) {
		newTicket = opTicket.get();
		newTicket.getCompanionData().set(DataQuery.of("type"), getType().toString());
		this.isValid = true;
	} else {
		logger.error("Requested ticket was not provided; maximum tickets may have been reached.");
		this.isValid = false;
	}

	return newTicket;
}
 
开发者ID:DevOnTheRocks,项目名称:StickyChunk,代码行数:21,代码来源:LoadedRegion.java

示例6: onBlockSecondaryInteract

import org.spongepowered.api.world.World; //导入依赖的package包/类
@Listener
public void onBlockSecondaryInteract(InteractBlockEvent.Secondary.MainHand e, @First Player p) {		
	if (!plugin.getInspectManager().isInspector(p))
		return;
	
	//TODO: Figure out why shearing sheep causes weird shit to happen
	
	e.setCancelled(true);
	BlockSnapshot block = e.getTargetBlock();
	if (block == null || !block.getLocation().isPresent())
		return;
	
	Location<World> loc = block.getLocation().get();
	
	p.sendMessage(Text.of(TextColors.BLUE, "Querying database, please wait..."));
	if (loc.getTileEntity().isPresent() && loc.getTileEntity().get() instanceof TileEntityCarrier) {
		Sponge.getScheduler().createAsyncExecutor(plugin).execute(() -> {
			plugin.getInspectManager().inspectContainer(p, block.getWorldUniqueId(), loc.getBlockPosition()); });
	} else {
		Sponge.getScheduler().createAsyncExecutor(plugin).execute(() -> {
			plugin.getInspectManager().inspect(p, block.getWorldUniqueId(), loc.getBlockPosition().add(e.getTargetSide().asBlockOffset())); });
	}
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:24,代码来源:PlayerInspectListener.java

示例7: registerPlayer

import org.spongepowered.api.world.World; //导入依赖的package包/类
private void registerPlayer(Player player) {
    player.setSleepingIgnored(true); // Turn off vanilla sleeping to prevent a bug where the time advances (or doesn't, if /gamerule doDaylightCycle false, in which case it just kicks players out of bed without doing anything) but the plugin doesn't display the wakeup message.
    SVPlayerData svPlayerData = getSVPlayerData(player);

    svPlayerData.getSleepTask().ifPresent(Task::cancel);
    svPlayerData.setSleepTask(Task.builder().execute(() -> {
        if (isInBed(player) && !isIgnored(player)) {
            World world = player.getWorld();
            SVWorldData svWorldData = getSVWorldData(world);
            svWorldData.getSleepingPlayers().add(player.getUniqueId());

            Text text = messenger.parseMessage(enterBedMessage,
                    svWorldData.getSleepingPlayers().size(),
                    getRequiredPlayerCount(world),
                    player.getName(),
                    enablePrefix);
            messenger.sendWorldMessage(world, text);
            messenger.playWorldSound(world, SoundTypes.BLOCK_NOTE_HAT);

            if (messageLogging) {
                logger.info("[" + world.getName() + "] " + text.toPlain());
            }
        }
    }).async().delayTicks(80).submit(sleepVote));
}
 
开发者ID:Icohedron,项目名称:SleepVote,代码行数:26,代码来源:SleepVoteManager.java

示例8: generatePoints

import org.spongepowered.api.world.World; //导入依赖的package包/类
@Override
public void generatePoints(World world, Random random, Rectangled rectangle, List<Vector2d> points) {
    final int minX = ((int) rectangle.getMin().getX()) >> 4;
    final int minZ = ((int) rectangle.getMin().getY()) >> 4;
    final int maxX = ((int) rectangle.getMax().getX()) >> 4;
    final int maxZ = ((int) rectangle.getMax().getY()) >> 4;
    final long worldSeed = world.getProperties().getSeed();
    for (int x = minX; x <= maxX; x++) {
        for (int z = minZ; z <= maxZ; z++) {
            random.setSeed(((long) x * 341873128712L + (long) z * 132897987541L) ^ worldSeed);
            final int xPos = x << 4;
            final int zPos = z << 4;
            this.parent.generatePoints(world, random, new Rectangled(new Vector2d(xPos, zPos), new Vector2d(xPos & 0xf, zPos & 0xf)), points);
        }
    }
}
 
开发者ID:LanternPowered,项目名称:Porygen,代码行数:17,代码来源:ChunkBasedPointsGenerator.java

示例9: getRequiredPlayerCount

import org.spongepowered.api.world.World; //导入依赖的package包/类
private int getRequiredPlayerCount(World world) {
    // TODO: Automatically add exclusions for vanished players -- requires Nucleus to provide some sort of API for that
    Set<Player> players = new HashSet<>(world.getPlayers());
    players.removeIf(this::isIgnored);

    int requiredFromPercent = (int) (players.size() * requiredPercentSleeping);

    int required;
    if (requiredNumberSleeping <= 0) {
        required = requiredFromPercent;
    } else {
        required = Math.min(requiredFromPercent, requiredNumberSleeping);
    }

    return required < 1 ? 1 : required;
}
 
开发者ID:Icohedron,项目名称:SleepVote,代码行数:17,代码来源:SleepVoteManager.java

示例10: clanCoordsCommand

import org.spongepowered.api.world.World; //导入依赖的package包/类
@Command(name = "coords", description = "Посмотреть координаты ваших соклановцев", isPlayerOnly = true, isClanOnly = true, clanPermission = "coords", spongePermission = "mcclans.user.coords")
public void clanCoordsCommand(CommandSource commandSource, ClanPlayerImpl clanPlayer, @PageParameter int page) {
    ClanImpl clan = clanPlayer.getClan();
    List<Player> onlineMembers = new ArrayList<Player>();
    List<ClanPlayerImpl> members = clan.getMembersImpl();
    for (ClanPlayerImpl member : members) {
        Optional<Player> playerOpt = Sponge.getServer().getPlayer(member.getUUID());
        if (playerOpt.isPresent() && playerOpt.get().isOnline()) {
            onlineMembers.add(playerOpt.get());
        }
    }
    java.util.Collections.sort(members, new MemberComparator());

    HorizontalTable<Player> table = new HorizontalTable<Player>("Clan coordinates " + clan.getName(), 10, (row, player, index) -> {
        if (player.isOnline()) {
            Location<World> location = player.getLocation();
            row.setValue("Player", Text.of(player.getName()));
            row.setValue("Location", Utils.formatLocation(location));

        }
    });
    table.defineColumn("Player", 30);
    table.defineColumn("Location", 30);

    table.draw(onlineMembers, page, commandSource);
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:27,代码来源:ClanCommands.java

示例11: SignsConfig

import org.spongepowered.api.world.World; //导入依赖的package包/类
public SignsConfig(File baseDir) {
    super(baseDir, "signs");

    for (Object objKey : config.getChildrenMap().keySet()) {
        if (objKey instanceof String) {
            String key = (String) objKey;
            if (Utils.isInt(key)) {
                Set<DonorSign> signs = new HashSet<>();
                System.out.println("key " + key);
                try {
                    for (Location<World> loc : stringsToLocArray(config.getChildrenMap().get(objKey).getList(TypeToken.of(String.class)))) {
                        if (loc != null && loc.getTileEntity().isPresent() && loc.getTileEntity().get() instanceof Sign) {
                            System.out.println("2");
                            signs.add(new DonorSign(Utils.getInt(key), loc));
                        }
                    }
                } catch (ObjectMappingException e) {
                    e.printStackTrace();
                }
                donorSigns.put(Utils.getInt(key), signs);
            }
        }
    }
}
 
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:25,代码来源:SignsConfig.java

示例12: addDonorSign

import org.spongepowered.api.world.World; //导入依赖的package包/类
public boolean addDonorSign(Integer key, Location<World> location) {
    DonorSign donorSign = getDonorSignFor(location);
    if (donorSign == null) {
        Set<DonorSign> signs;
        if (donorSigns.containsKey(key)) {
            signs = donorSigns.get(key);
        } else {
            signs = new HashSet<>();
        }
        signs.add(new DonorSign(key, location));
        donorSigns.put(key, signs);
        List<String> locs = new ArrayList<>();
        for (DonorSign ds : signs) {
            locs.add(locToString(ds.getLocation()));
        }
        if (locs.size() > 0) {
            config.getNode(String.valueOf(key)).setValue(locs);
        } else {
            config.getNode(String.valueOf(key)).setValue(null);
        }
        saveConfig();
        return true;
    }
    return false;
}
 
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:26,代码来源:SignsConfig.java

示例13: removeDonorSign

import org.spongepowered.api.world.World; //导入依赖的package包/类
public boolean removeDonorSign(Location<World> location) {
    DonorSign donorSign = getDonorSignFor(location);
    if (donorSign != null) {
        Set<DonorSign> signs = donorSigns.get(donorSign.getKey());
        signs.remove(donorSign);
        List<String> locs = new ArrayList<>();
        for (DonorSign ds : signs) {
            locs.add(locToString(ds.getLocation()));
        }
        if (locs.size() > 0) {
            config.getNode(String.valueOf(donorSign.getKey())).setValue(locs);
        } else {
            config.getNode(String.valueOf(donorSign.getKey())).setValue(null);
        }
        saveConfig();
        return true;
    }
    return false;
}
 
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:20,代码来源:SignsConfig.java

示例14: stringToLoc

import org.spongepowered.api.world.World; //导入依赖的package包/类
private Location<World> stringToLoc(String str) {
    String[] a = str.split(",");
    if (a.length < 4) {
        return null;
    }

    Optional<World> w = Sponge.getServer().getWorld(a[0]);
    if (!w.isPresent()) {
        return null;
    }

    double x = Double.parseDouble(a[1]);
    double y = Double.parseDouble(a[2]);
    double z = Double.parseDouble(a[3]);

    return new Location<>(w.get(), x, y, z);
}
 
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:18,代码来源:SignsConfig.java

示例15: deserialize

import org.spongepowered.api.world.World; //导入依赖的package包/类
@Override
public Location deserialize(TypeToken<?> typeToken, ConfigurationNode value) throws ObjectMappingException {
    String name = value.getNode("world").getValue(TypeToken.of(String.class));
    Double x = value.getNode("x").getValue(TypeToken.of(Double.class));
    Double y = value.getNode("y").getValue(TypeToken.of(Double.class));
    Double z = value.getNode("z").getValue(TypeToken.of(Double.class));

    Optional<World> optional = Sponge.getServer().getWorld(name);

    if (!optional.isPresent()) {
        throw new ObjectMappingException("Unknown world");
    }

    World world = optional.get();
    return world.getLocation(x, y, z);
}
 
开发者ID:Lergin,项目名称:Vigilate,代码行数:17,代码来源:LocationSerializer.java


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