> For the complete documentation index, see [llms.txt](https://sonic-rokas.gitbook.io/easybungee/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sonic-rokas.gitbook.io/easybungee/for-developers/example-player.md).

# Example - Player

#### 1.1 Get the server name in which the player is

```
new BungeePlayer(playername).getCurrentServer().getName();

OR

new SpigotPlayer(playername).getCurrentServer().getName();
```

#### 1.2 Get health of a player

```
new SpigotPlayer(playername).getHealth().send(result -> System.out.println(result));
```

#### 1.3 Set food level of player

```
new SpigotPlayer(playername).setFood(foodlevel).send();
```

#### 1.4 Get Location of player

```
new SpigotPlayer(playername).getLocation().send(location -> System.out.println(location.getX() + "." + location.getY() + "." + location.getZ()));
```

#### 1.5 Get playtime of player

```
new BungeePlayer(playername).getPlayTime();

Or if player is offline

new BOfflinePlayer(playername).getPlayTime();
```

#### 1.6 Play sound to a player

```
new SpigotPlayer(playername).playSound(new SpigotSound("EXPLODE",1.0F,1.0F)).send();
```

#### 1.7 Kick player

```
new SpigotPlayer(playername).kick().send();

Or

new SpigotPlayer(playername).kick().send(complete -> System.out.println("result: " + complete));

If the method doesn't return an object it returns a boolean if the command was successful

Or

new SpigotPlayer(playername).kick(reason).send(complete -> System.out.println("result: " + complete));

Or

new SpigotPlayer(playername).kick(reason).send();

You could also do this with the BungeePlayer class
```

#### 1.8 Get an inventory of a player

```
new SpigotPlayer(playername).getInventory().send(inventory -> System.out.println(inventory.getSlots().get(slot).getMaterial()));
```

#### 1.9 Set item in the player's hand

```
new SpigotPlayer(playername).setItemInHand(new SpigotItem("DIAMOND_BLOCK",1)).send();
```
