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