Skip to content

Commit e17b850

Browse files
committed
Add plast_known_name()
1 parent a63cd4b commit e17b850

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

src/main/java/com/laytonsmith/core/functions/PlayerManagement.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4866,6 +4866,60 @@ public ExampleScript[] examples() throws ConfigCompileException {
48664866
}
48674867
}
48684868

4869+
@api
4870+
public static class plast_known_name extends AbstractFunction {
4871+
4872+
@Override
4873+
public Class<? extends CREThrowable>[] thrown() {
4874+
return new Class[]{CRELengthException.class};
4875+
}
4876+
4877+
@Override
4878+
public boolean isRestricted() {
4879+
return true;
4880+
}
4881+
4882+
@Override
4883+
public Boolean runAsync() {
4884+
return false;
4885+
}
4886+
4887+
@Override
4888+
public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
4889+
MCOfflinePlayer p = Static.GetUser(args[0].val(), t);
4890+
if(p == null) {
4891+
return CNull.NULL;
4892+
}
4893+
String name = p.getName();
4894+
if(name == null) {
4895+
return CNull.NULL;
4896+
}
4897+
return new CString(name, t);
4898+
}
4899+
4900+
@Override
4901+
public String getName() {
4902+
return "plast_known_name";
4903+
}
4904+
4905+
@Override
4906+
public Integer[] numArgs() {
4907+
return new Integer[]{1};
4908+
}
4909+
4910+
@Override
4911+
public String docs() {
4912+
return "string {uuid} Returns the name for this player the last time they were on the server."
4913+
+ " Return null if the player has never been on the server. This is not guaranteed to be their"
4914+
+ " current player name. This is read directly from the player data file for offline players.";
4915+
}
4916+
4917+
@Override
4918+
public CHVersion since() {
4919+
return CHVersion.V3_3_2;
4920+
}
4921+
}
4922+
48694923
@api
48704924
@hide("Deprecated.")
48714925
public static class get_player_from_entity_id extends AbstractFunction implements Optimizable {

0 commit comments

Comments
 (0)