當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。