本文整理匯總了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);
}
示例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
}
示例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());
}