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


Java Player.get方法代码示例

本文整理汇总了Java中org.spongepowered.api.entity.living.player.Player.get方法的典型用法代码示例。如果您正苦于以下问题:Java Player.get方法的具体用法?Java Player.get怎么用?Java Player.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.spongepowered.api.entity.living.player.Player的用法示例。


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

示例1: onMoveEntity

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
@Listener
public void onMoveEntity(MoveEntityEvent event, @Root @Has(ViewerData.class) Player player) {
    Optional<String> camId = player.get(VigilateKeys.CAMERA);
    if(camId.isPresent() && Vigilate.getInstance().getCameras().containsKey(camId.get())) {
        Camera camera = Vigilate.getInstance().getCameras().get(camId.get());

        if (!camera.getLocation().equals(event.getToTransform().getLocation())) {
            camera.endViewCamera(player);
        }

        return;
    }

    if(!event.getFromTransform().getLocation().equals(event.getToTransform().getLocation())) {
        Camera.resetPlayer(player);
        event.setCancelled(true);
    }
}
 
开发者ID:Lergin,项目名称:Vigilate,代码行数:19,代码来源:MoveListener.java

示例2: getOnlinePlayers

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
private List<ServerPlayer> getOnlinePlayers() {
    List<ServerPlayer> players = new ArrayList<>();
    for (Player player : Sponge.getServer().getOnlinePlayers()) {
        Optional<ExperienceHolderData> experienceData = player.get(ExperienceHolderData.class);
        Optional<Long> level;
        int exp;
        if (experienceData.isPresent()) {
            level = Optional.of((long) experienceData.get().level().get());
            exp = experienceData.get().totalExperience().get();
        } else {
            level = Optional.empty();
            exp = 0;
        }
        players.add(new ServerPlayer(
                0,
                player.getName(),
                player.getUniqueId().toString(),
                player.getConnection().getAddress().getAddress().getHostAddress(),
                player.getConnection().getLatency(),
                Optional.empty(),
                Optional.of(player.getWorld().getName()),
                Optional.of((long) player.getLocation().getBlockX()),
                Optional.of((long) player.getLocation().getBlockY()),
                Optional.of((long) player.getLocation().getBlockZ()),
                Optional.of(player.gameMode().get().getName()),
                Optional.of(round(player.health().get())),
                Optional.of(round(player.maxHealth().get())),
                level,
                Optional.of(round(exp)),
                Optional.of((long) player.foodLevel().get()),
                Optional.empty(),
                Optional.empty()
        ));
    }
    return players;
}
 
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:37,代码来源:SpongeStats.java

示例3: onDropItem

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
@Listener
public void onDropItem(DropItemEvent event, @Root @Has(ViewerData.class) Player player) {
    Optional<String> camId = player.get(VigilateKeys.CAMERA);

    if(camId.isPresent() && Vigilate.getInstance().getCameras().containsKey(camId.get())){
        Vigilate.getInstance().getCameras().get(camId.get()).endViewCamera(player);
    } else {
        Camera.resetPlayer(player);
    }

    event.setCancelled(true);
}
 
开发者ID:Lergin,项目名称:Vigilate,代码行数:13,代码来源:DropListener.java

示例4: onClickInventory

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
@Listener
public void onClickInventory(InteractInventoryEvent event, @Root @Has(ViewerData.class) Player player) {
    Optional<String> camId = player.get(VigilateKeys.CAMERA);

    if(camId.isPresent() && Vigilate.getInstance().getCameras().containsKey(camId.get())){
        Vigilate.getInstance().getCameras().get(camId.get()).endViewCamera(player);
    } else {
        Camera.resetPlayer(player);
    }

    event.setCancelled(true);
}
 
开发者ID:Lergin,项目名称:Vigilate,代码行数:13,代码来源:InteractInventoryListener.java

示例5: onSendCommand

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
@Listener
public void onSendCommand(SendCommandEvent event, @Root @Has(ViewerData.class) Player player) {
    Optional<String> camId = player.get(VigilateKeys.CAMERA);

    if(camId.isPresent() && Vigilate.getInstance().getCameras().containsKey(camId.get())){
        Vigilate.getInstance().getCameras().get(camId.get()).endViewCamera(player);
    } else {
        Camera.resetPlayer(player);
    }

    event.setCancelled(true);
}
 
开发者ID:Lergin,项目名称:Vigilate,代码行数:13,代码来源:CommandListener.java

示例6: onInteract

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
@Listener
public void onInteract(InteractEvent event, @Root @Has(ViewerData.class) Player player) {
    Optional<String> camId = player.get(VigilateKeys.CAMERA);

    if(camId.isPresent() && Vigilate.getInstance().getCameras().containsKey(camId.get())){
        Vigilate.getInstance().getCameras().get(camId.get()).endViewCamera(player);
    } else {
        Camera.resetPlayer(player);
    }

    event.setCancelled(true);
}
 
开发者ID:Lergin,项目名称:Vigilate,代码行数:13,代码来源:ClickListener.java

示例7: endViewCamera

import org.spongepowered.api.entity.living.player.Player; //导入方法依赖的package包/类
public void endViewCamera(Player player){
    Optional<String> cameraId = player.get(VigilateKeys.CAMERA);

    if (cameraId.isPresent() && !cameraId.get().equals("")) {
        Camera.resetPlayer(player);
        player.sendMessage(plugin.translations.CAMERA_ENDVIEW, this.templateVariables());
    }
}
 
开发者ID:Lergin,项目名称:Vigilate,代码行数:9,代码来源:Camera.java


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