# For Developers

## Lobby & Game

Obtain LeaderBoard RBucket

```java
String leaderboardName = "bedwars_wins_daily";
RBucket<LeaderBoard> redisBoard = Basement.rclient().getBucket(leaderboardName);

if (redisBoard.isExists()) {
    LeaderBoard board = redisBoard.get();|
    ...   
}
```

Obtain Statistic Class

```java
UUID uniqueId = null;
Statistics stats = Basement.rclient().getLiveObjectService().get(Statistics.class, uniqueId.toString());
if (stats == null) {
    System.out.println("Statistics not found");
    return;
}

int wins = statistics.get(StatsScope.SOLO, StatsType.WIN);
...
```

Obtain UserData Class

```java
UUID uniqueId = null;
UserData userData = Basement.rclient().getLiveObjectService().get(UserData.class, uniqueId.toString());
if (userData == null) {
    System.out.println("UserData not found");
    return;
}

int level = userData.getLevel();
...
```

Obtain SharedBedwarsMatch Class

```java
SharedBedwarsMatch match = Basement.redis().redissonClient().getLiveObjectService().get(SharedBedwarsMatch.class, statistics.getMatch());
if (match == null) {
    System.out.println("Match not found");
    return;
}

boolean isPrivateGame = match.getHost() != null;
match.spectate("Username");
...
```

## Game Only

Obtain MatchPlayer Class

```java
Player player = null;
MatchPlayer matchPlayer = MatchPlayer.get(player.getUniqueId());

Statistics statistics = matchPlayer.getStatistics();
Arena arena = matchPlayer.getArena();

matchPlayer.resetStats(); // Reset stats for the current game
...
```

### Cosmetics API

Create custom cosmetics with easy API

Implements one of those Abstract Class\
![](/files/hbkIsWFIHF06cwK5DfwY)

Add your cosmetic class to the avaible one

```java
CosmeticsInstance.COSMETICS.put(, Type.YOUR_TYPE, "cosmetic_id", new YourCustomCosmeticsClass());
```

PlayerCosmetics class is an utility class to manage cosmetics for players:

```java
@Getter
@RequiredArgsConstructor
public class PlayerCosmetics {

    private final UUID uuid;

    private final Table<Type, String, Boolean> cosmetics = HashBasedTable.create();

    public void addCosmetic(Type type, String cosmetic, boolean equipped) {
        if (equipped) equipCosmetic(type, cosmetic);
        else this.cosmetics.put(type, cosmetic, false);
    }

    public void equipCosmetic(Type type, String cosmetic) {
        String key;
        if ((key = getEquippedCosmetic(type)) != null) {
            this.cosmetics.put(type, key, false);
        }
        this.cosmetics.put(type, cosmetic, true);
    }

    public void unequipCosmetic(Type type, String key) {
        this.cosmetics.put(type, key, false);
    }

    public boolean hasEquippedCosmetic(Type type, String key) {
        return this.cosmetics.get(type, key);
    }

    public boolean hasCosmetic(String cosmetic) {
        return this.cosmetics.containsColumn(cosmetic);
    }

    public boolean hasCosmetic(Type type) {
        return this.cosmetics.containsRow(type);
    }

    public @Nullable String getEquippedCosmetic(Type type) {
        return this.cosmetics.row(type).entrySet().stream()
                .filter(Map.Entry::getValue)
                .map(Map.Entry::getKey)
                .findFirst()
                .orElse(null);
    }
}
```

Cosmetic Example

```java
public class LightningBolt extends KillEffect {

    public LightningBolt() {
        super("lightning_bolt");
    }

    @Override
    public String getDisplayName() {
        return "Lightning Bolt";
    }

    @Override
    public void play(Location victimPosition, Location killerPosition) {
        victimPosition.getWorld().strikeLightningEffect(victimPosition);
    }

}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ohalee.com/products/ultimatebedwars/for-developers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
