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