當前位置: 首頁>>代碼示例>>Java>>正文


Java Player.offer方法代碼示例

本文整理匯總了Java中org.spongepowered.api.entity.living.player.Player.offer方法的典型用法代碼示例。如果您正苦於以下問題:Java Player.offer方法的具體用法?Java Player.offer怎麽用?Java Player.offer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.spongepowered.api.entity.living.player.Player的用法示例。


在下文中一共展示了Player.offer方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setPlayer

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的package包/類
void setPlayer(Player player, Trail trail) {
    boolean existed = false;
    for (final Map.Entry<PlayerWrapper, Trail> next : this.playerTrails.entrySet()) {
        if (next.getKey().playerId.equals(player.getUniqueId())) {
            next.setValue(trail);
            existed = true;
            break;
        }
    }
    if (!existed) {
        this.playerTrails.put(new PlayerWrapper(player), trail);
    }
    final TrailData trailData = player.get(TrailData.class).orElseGet(() -> new TrailData(trail));
    trailData.setTrail(trail);
    player.offer(trailData);
}
 
開發者ID:gabizou,項目名稱:HappyTrails,代碼行數:17,代碼來源:HappyTrails.java

示例2: setDisplayName

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的package包/類
@Override
public void setDisplayName(String name) {
    if(!Sponge.isServerAvailable()) return;
    Optional<Player> optionalP = Sponge.getServer().getPlayer(this.getUniqueId());
    if(!optionalP.isPresent()) return;
    Player p = optionalP.get();
    p.offer(Keys.DISPLAY_NAME, Text.of(name)); //TODO: Formatting issues may occur
}
 
開發者ID:Proximyst,項目名稱:Bukkit2Sponge,代碼行數:9,代碼來源:LinkedPlayer.java

示例3: viewCamera

import org.spongepowered.api.entity.living.player.Player; //導入方法依賴的package包/類
public void viewCamera(Player player){
    if(!this.canUseCamera(player)){
        return; // shouldn't have the ability to even execute the command
    }

    if (player.supports(VigilateKeys.OLD_GAME_MODE)) {
        player.get(VigilateKeys.CAMERA).orElse("");

        if(Vigilate.getInstance().getCameras().containsKey(id)){
            Vigilate.getInstance().getCameras().get(id).endViewCamera(player);
        }
    }

    player.offer(new ViewerDataManipulatorBuilder().create());

    player.getValue(Keys.GAME_MODE).ifPresent(
            (value -> player.offer(VigilateKeys.OLD_GAME_MODE, value.get()))
    );
    player.getValue(Keys.IS_FLYING).ifPresent(
            (value -> player.offer(VigilateKeys.OLD_IS_FLYING, value.get()))
    );
    player.getValue(Keys.AFFECTS_SPAWNING).ifPresent(
            (value -> player.offer(VigilateKeys.OLD_AFFECTS_SPAWNING, value.get()))
    );
    player.getValue(Keys.VANISH).ifPresent(
            (value -> player.offer(VigilateKeys.OLD_VANISH, value.get()))
    );
    player.getValue(Keys.VANISH_PREVENTS_TARGETING).ifPresent(
            (value -> player.offer(VigilateKeys.OLD_VANISH_PREVENTS_TARGETING, value.get()))
    );
    player.getValue(Keys.VANISH_IGNORES_COLLISION).ifPresent(
            (value -> player.offer(VigilateKeys.OLD_VANISH_IGNORES_COLLISION, value.get()))
    );
    player.getValue(Keys.FLYING_SPEED).ifPresent(
            (value -> player.offer(VigilateKeys.OLD_FLYING_SPEED, value.get()))
    );

    player.offer(VigilateKeys.OLD_LOCATION_WORLD, player.getLocation().getExtent().getName());
    player.offer(VigilateKeys.OLD_LOCATION_X, player.getLocation().getX());
    player.offer(VigilateKeys.OLD_LOCATION_Y, player.getLocation().getY());
    player.offer(VigilateKeys.OLD_LOCATION_Z, player.getLocation().getZ());

    player.offer(Keys.GAME_MODE, GameModes.CREATIVE);
    player.offer(Keys.AFFECTS_SPAWNING, false);
    player.offer(Keys.VANISH, true);
    player.offer(Keys.VANISH_PREVENTS_TARGETING, true);
    player.offer(Keys.VANISH_IGNORES_COLLISION, true);
    player.offer(Keys.FLYING_SPEED, 0.0);
    player.offer(Keys.IS_FLYING, true);

    player.offer(VigilateKeys.CAMERA, this.getId());

    player.setLocation(this.getLocation());

    Title title = Title.builder()
            .fadeIn(20)
            .fadeOut(20)
            .title(Text.EMPTY)
            .subtitle(plugin.translations.CAMERA_VIEW_TITLE.apply(this.templateVariables()).toText())
            .stay(100000)
            .build();
    player.sendTitle(title);

    player.sendMessage(plugin.translations.CAMERA_VIEW, this.templateVariables());
}
 
開發者ID:Lergin,項目名稱:Vigilate,代碼行數:66,代碼來源:Camera.java


注:本文中的org.spongepowered.api.entity.living.player.Player.offer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。