Skip to content

Commit

Permalink
Add IScriptServer.getEntity(String)
Browse files Browse the repository at this point in the history
  • Loading branch information
mchorse committed Nov 18, 2021
1 parent d51fbb6 commit 605454f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public class ScriptServer implements IScriptServer
{
Expand Down Expand Up @@ -57,6 +58,12 @@ public List<IScriptEntity> getEntities(String targetSelector)
return entities;
}

@Override
public IScriptEntity getEntity(String uuid)
{
return ScriptEntity.create(this.server.getEntityFromUuid(UUID.fromString(uuid)));
}

@Override
public List<IScriptPlayer> getAllPlayers()
{
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/mchorse/mappet/api/scripts/user/IScriptServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ public interface IScriptServer
*/
public List<IScriptEntity> getEntities(String targetSelector);

/**
* Get an entity by its UUID.
*
* <pre>{@code
* var uuid = "29a91933-86f2-4683-8a87-218084d8c927";
* var entity = c.getServer().getEntity(uuid);
*
* print(entity.getUniqueId() === uuid);
* }</pre>
*/
public IScriptEntity getEntity(String uuid);

/**
* Get all players on the server.
*
Expand Down

0 comments on commit 605454f

Please sign in to comment.