Skip to content

Commit

Permalink
Merge branch 'master' into packetJumper
Browse files Browse the repository at this point in the history
  • Loading branch information
LadyCailin committed Mar 5, 2024
2 parents b26bb43 + fd53398 commit 9e93d44
Show file tree
Hide file tree
Showing 6 changed files with 213 additions and 9 deletions.
8 changes: 4 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ pool:
steps:
- task: JavaToolInstaller@0
inputs:
versionSpec: '16'
versionSpec: '17'
jdkArchitectureOption: x64
jdkSourceOption: 'AzureStorage'
azureResourceManagerEndpoint: Azure Resource Manager
azureStorageAccountName: methodscriptjdkbuilds
azureContainerName: jdks
azureCommonVirtualFile: 'OpenJDK16U-jdk_x86-32_windows_hotspot_16.0.1_9.zip'
jdkDestinationDirectory: '$(agent.toolsDirectory)/jdk16'
azureCommonVirtualFile: 'OpenJDK-jdk_x64_linux_hotspot_2021-05-06-23-30.tar.gz'
jdkDestinationDirectory: '$(agent.toolsDirectory)/jdk17'
cleanDestinationDirectory: true
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.16'
jdkVersionOption: '1.17'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/TEST-*.xml'
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/laytonsmith/abstraction/MCPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ public interface MCPlayer extends MCCommandSender, MCHumanEntity, MCOfflinePlaye

void setVanished(boolean set, MCPlayer to);

void hideEntity(MCEntity entity);

void showEntity(MCEntity entity);

boolean canSeeEntity(MCEntity entity);

boolean isNewPlayer();

String getHost();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,34 @@ public void setVanished(boolean set, MCPlayer to) {
}
}

@Override
public void hideEntity(MCEntity entity) {
try {
p.hideEntity(CommandHelperPlugin.self, (Entity) entity.getHandle());
} catch(NoSuchMethodError ex) {
// probably before 1.18
}
}

@Override
public void showEntity(MCEntity entity) {
try {
p.showEntity(CommandHelperPlugin.self, (Entity) entity.getHandle());
} catch(NoSuchMethodError ex) {
// probably before 1.18
}
}

@Override
public boolean canSeeEntity(MCEntity entity) {
try {
return p.canSee((Entity) entity.getHandle());
} catch(NoSuchMethodError ex) {
// probably before 1.18
return true;
}
}

@Override
public void setWhitelisted(boolean value) {
p.setWhitelisted(value);
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/com/laytonsmith/core/MethodScriptCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3087,10 +3087,13 @@ public static Mixed execute(ParseTree root, Environment env, MethodScriptComplet
Mixed retc = script.eval(gg, env);
if(root.numberOfChildren() == 1) {
returnable = retc;
if(done == null) {
// string builder is not needed, so return immediately
return returnable;
}
}
@SuppressWarnings("null")
String ret = retc instanceof CNull ? "null" : retc.val();
if(ret != null && !ret.trim().isEmpty()) {
String ret = retc.val();
if(!ret.trim().isEmpty()) {
b.append(ret).append(" ");
}
}
Expand Down
167 changes: 167 additions & 0 deletions src/main/java/com/laytonsmith/core/functions/PlayerManagement.java
Original file line number Diff line number Diff line change
Expand Up @@ -6888,4 +6888,171 @@ public Boolean runAsync() {
return false;
}
}

@api
public static class phide_entity extends AbstractFunction {

@Override
public String getName() {
return "phide_entity";
}

@Override
public String docs() {
return "void {[player], entityUUID} Sets an entity to no longer be seen or tracked by the player's client."
+ " Resets to default on player rejoin."
+ " (MC 1.18+)";
}

@Override
public Integer[] numArgs() {
return new Integer[]{1, 2};
}

@Override
public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException {
MCPlayer p;
MCEntity e;
if(args.length == 1) {
p = env.getEnv(CommandHelperEnvironment.class).GetPlayer();
Static.AssertPlayerNonNull(p, t);
e = Static.getEntity(args[0], t);
} else {
p = Static.GetPlayer(args[0], t);
e = Static.getEntity(args[1], t);
}
p.hideEntity(e);
return CVoid.VOID;
}

@Override
public Class<? extends CREThrowable>[] thrown() {
return new Class[]{CREPlayerOfflineException.class, CRELengthException.class, CREBadEntityException.class};
}

@Override
public Version since() {
return MSVersion.V3_3_5;
}

@Override
public boolean isRestricted() {
return true;
}

@Override
public Boolean runAsync() {
return false;
}
}

@api
public static class pshow_entity extends AbstractFunction {

@Override
public String getName() {
return "pshow_entity";
}

@Override
public String docs() {
return "void {[player], entityUUID} Sets an entity to be sent to the player's client again. (MC 1.18+)";
}

@Override
public Integer[] numArgs() {
return new Integer[]{1, 2};
}

@Override
public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException {
MCPlayer p;
MCEntity e;
if(args.length == 1) {
p = env.getEnv(CommandHelperEnvironment.class).GetPlayer();
Static.AssertPlayerNonNull(p, t);
e = Static.getEntity(args[0], t);
} else {
p = Static.GetPlayer(args[0], t);
e = Static.getEntity(args[1], t);
}
p.showEntity(e);
return CVoid.VOID;
}

@Override
public Class<? extends CREThrowable>[] thrown() {
return new Class[]{CREPlayerOfflineException.class, CRELengthException.class, CREBadEntityException.class};
}

@Override
public Version since() {
return MSVersion.V3_3_5;
}

@Override
public boolean isRestricted() {
return true;
}

@Override
public Boolean runAsync() {
return false;
}
}

@api
public static class pcan_see_entity extends AbstractFunction {

@Override
public String getName() {
return "pcan_see_entity";
}

@Override
public String docs() {
return "boolean {[player], entityUUID} Gets whether the entity is known by the player's client or"
+ " hidden by a plugin. (MC 1.18+)";
}

@Override
public Integer[] numArgs() {
return new Integer[]{1, 2};
}

@Override
public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException {
MCPlayer p;
MCEntity e;
if(args.length == 1) {
p = env.getEnv(CommandHelperEnvironment.class).GetPlayer();
Static.AssertPlayerNonNull(p, t);
e = Static.getEntity(args[0], t);
} else {
p = Static.GetPlayer(args[0], t);
e = Static.getEntity(args[1], t);
}
return CBoolean.get(p.canSeeEntity(e));
}

@Override
public Class<? extends CREThrowable>[] thrown() {
return new Class[]{CREPlayerOfflineException.class, CRELengthException.class, CREBadEntityException.class};
}

@Override
public Version since() {
return MSVersion.V3_3_5;
}

@Override
public boolean isRestricted() {
return true;
}

@Override
public Boolean runAsync() {
return false;
}
}
}
4 changes: 2 additions & 2 deletions src/main/resources/functionDocs/get_itemmeta
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ The entity's custom name is derived from the item '''"display"''' string. All ot
|-
| Books
|
* '''title''' : (string) The title of the book.
* '''title''' : (string) The title of the book. (32 character limit)
* '''author''' : (string) The author of the book.
* '''pages''' : (array) An array of pages as strings. New lines supported. 256 character limit per page. 50 page limit.
* '''pages''' : (array) An array of pages as strings. New lines supported. (100 page limit)
* '''generation''' : (string) The generation of the book. Can be ORIGINAL, COPY_OF_ORIGINAL, COPY_OF_COPY, or TATTERED (the last two cannot be copied).
As pages are plain text, they do not yet support some advanced text components.
|-
Expand Down

0 comments on commit 9e93d44

Please sign in to comment.