# 13 - API

## API

```
double getPlayerPoints(Player p)
//Get a player's points

void setPlayerPoints(Player p,double value)
//Set a player's points

int getPlayerWin(Player p)
//Get a player's win times

int getPlayerLose(Player p)
//Get a player's lose times

int getPlayerDraw(Player p)
//Get a player's draw times

double getPlayerKD(Player p)
//get a player's KD

double getPlayerEnergy(Player p)
//get a player's current energy

double getMaxEnergy()
//get the max energy set in the server

int getPlayerWinRank(Player p)
//get the win ranking of a player

int getPlayerKDRank(Player p)
//get the KD ranking of a player

String getPlayerDanName(Player p)
//get a player's dan's name
```

## Events

#### 1.DanExpChangedEvent

```
Player getPlayer()
//Get the player

int getBefore()
//Get the value before being changed

int getNow()
//Get the value after being changed

void setCancelled(boolean cancel)
//Cancel this event

boolean isCancelled()
//Whether this event is cancelled
```

#### 2.EnergyChangedEvent

```
Player getPlayer()
//Get the player

int getBefore()
//Get the value before being changed

int getNow()
//Get the value after being changed

void setCancelled(boolean cancel)
//Cancel this event

boolean isCancelled()
//Whether this event is cancelled
```

#### 3.ShopEvent \\

```
Player getPlayer()
//Get the player

int getPage()
//Get the page which the good locate in

int getRow()
//Get the row which the good locate in

int getColumn()
//Get the column which the good locate in

int getNum()
//Get the number of the good,it equals "page*64+row*9+column-1"

ItemStack getItemStack()
//Get the itemstack of the good

void setCancelled(boolean cancel)
//Cancel this event

boolean isCancelled()
//Whether this event is cancelled
```

#### 4.ArenaStartEvent

```
String getPlayer1()
//Get the P1

String getPlayer2()
//Get the P2

Arena getArena()
//Get the arena
```

#### 5.ArenaFinishEvent

```
String getWinner()
//Get the name of winner

String getLoser()
//Get the name of loser

Arena getArena()
//Get the arena
```

#### 6.ArenaDrawFinishEvent

```
String getPlayer1()
//Get the P1

String getPlayer2()
//Get the P2

Arena getArena()
//Get the arena
```

#### \*.The main function of Arena

```
boolean isp1(String pn)
//Whether someone is P1

double getDamage(boolean isp1)
//Get total damage

double getMaxDamage(boolean isp1)
//Get max damage

double getExp(boolean isp1)
//Get the exp attained in the game

int getTime()
//Get the time consumed
```

```
For example:

@EventHandler
public void onFinishGame(ArenaFinishEvent event) {
    Arena arena = event.getArena();
    //Get the arena.
    int second = arena.getTime()
    //Get the time consumed.
    String winner = arena.getWinner();
    //Get the name of winner.
    double totalDamage = arena.getMaxDamage(arena.isp1(winner);
    //Get the total damage output by winner.
    winner.sendMessage("Amazing!You only took "+time+" to output "+totalDamege+" in this game!");
    //Inform winner of the totalDamage.
}
```


---

# 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://1392847363.gitbook.io/dantiao-plugin/13.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.
