Skip to content

Commit f0f9d62

Browse files
committed
Move raw vanish functions out of sandbox
1 parent bed97e6 commit f0f9d62

File tree

2 files changed

+113
-121
lines changed

2 files changed

+113
-121
lines changed

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

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7415,4 +7415,117 @@ public String docs() {
74157415
+ "by the night-skip sleep check.";
74167416
}
74177417
}
7418+
7419+
@api(environments = {CommandHelperEnvironment.class})
7420+
@seealso({raw_pcan_see.class})
7421+
public static class raw_set_pvanish extends AbstractFunction {
7422+
7423+
@Override
7424+
public String getName() {
7425+
return "raw_set_pvanish";
7426+
}
7427+
7428+
@Override
7429+
public Integer[] numArgs() {
7430+
return new Integer[]{2, 3};
7431+
}
7432+
7433+
@Override
7434+
public String docs() {
7435+
return "void {[player], isVanished, otherPlayer} Sets the visibility of this player to another player.";
7436+
}
7437+
7438+
@Override
7439+
public Class<? extends CREThrowable>[] thrown() {
7440+
return new Class[]{CREPlayerOfflineException.class, CRELengthException.class};
7441+
}
7442+
7443+
@Override
7444+
public boolean isRestricted() {
7445+
return true;
7446+
}
7447+
7448+
@Override
7449+
public Boolean runAsync() {
7450+
return false;
7451+
}
7452+
7453+
@Override
7454+
public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException {
7455+
MCPlayer thisPlayer;
7456+
boolean isVanished;
7457+
MCPlayer otherPlayer;
7458+
if(args.length == 2) {
7459+
thisPlayer = environment.getEnv(CommandHelperEnvironment.class).GetPlayer();
7460+
isVanished = ArgumentValidation.getBooleanObject(args[0], t);
7461+
otherPlayer = Static.GetPlayer(args[1], t);
7462+
} else {
7463+
thisPlayer = Static.GetPlayer(args[0], t);
7464+
isVanished = ArgumentValidation.getBooleanObject(args[1], t);
7465+
otherPlayer = Static.GetPlayer(args[2], t);
7466+
}
7467+
otherPlayer.setVanished(isVanished, thisPlayer);
7468+
return CVoid.VOID;
7469+
}
7470+
7471+
@Override
7472+
public MSVersion since() {
7473+
return MSVersion.V3_3_0;
7474+
}
7475+
}
7476+
7477+
@api(environments = {CommandHelperEnvironment.class})
7478+
@seealso({raw_set_pvanish.class})
7479+
public static class raw_pcan_see extends AbstractFunction {
7480+
7481+
@Override
7482+
public String getName() {
7483+
return "raw_pcan_see";
7484+
}
7485+
7486+
@Override
7487+
public Integer[] numArgs() {
7488+
return new Integer[]{1, 2};
7489+
}
7490+
7491+
@Override
7492+
public String docs() {
7493+
return "boolean {[player], otherPlayer} Returns whether this player can see another player or not."
7494+
+ " Hidden players are sometimes called vanished players.";
7495+
}
7496+
7497+
@Override
7498+
public Class<? extends CREThrowable>[] thrown() {
7499+
return new Class[]{CREPlayerOfflineException.class, CRELengthException.class};
7500+
}
7501+
7502+
@Override
7503+
public boolean isRestricted() {
7504+
return true;
7505+
}
7506+
7507+
@Override
7508+
public Boolean runAsync() {
7509+
return false;
7510+
}
7511+
7512+
@Override
7513+
public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException {
7514+
MCPlayer thisPlayer;
7515+
MCPlayer otherPlayer;
7516+
if(args.length == 1) {
7517+
thisPlayer = environment.getEnv(CommandHelperEnvironment.class).GetPlayer();
7518+
otherPlayer = Static.GetPlayer(args[0], t);
7519+
} else {
7520+
thisPlayer = Static.GetPlayer(args[0], t);
7521+
otherPlayer = Static.GetPlayer(args[1], t);
7522+
}
7523+
return CBoolean.get(thisPlayer.canSee(otherPlayer));
7524+
}
7525+
7526+
@Override
7527+
public MSVersion since() {
7528+
return MSVersion.V3_3_0;
7529+
}
7530+
}
74187531
}

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

Lines changed: 0 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import com.laytonsmith.PureUtilities.TermColors;
88
import com.laytonsmith.PureUtilities.Version;
99
import com.laytonsmith.PureUtilities.ZipReader;
10-
import com.laytonsmith.abstraction.MCPlayer;
1110
import com.laytonsmith.annotations.api;
1211
import com.laytonsmith.annotations.hide;
1312
import com.laytonsmith.annotations.noboilerplate;
@@ -18,7 +17,6 @@
1817
import com.laytonsmith.core.ParseTree;
1918
import com.laytonsmith.core.Security;
2019
import com.laytonsmith.core.Static;
21-
import com.laytonsmith.core.constructs.CBoolean;
2220
import com.laytonsmith.core.compiler.analysis.StaticAnalysis;
2321
import com.laytonsmith.core.constructs.CByteArray;
2422
import com.laytonsmith.core.constructs.CDouble;
@@ -36,7 +34,6 @@
3634
import com.laytonsmith.core.exceptions.CRE.CRECastException;
3735
import com.laytonsmith.core.exceptions.CRE.CREIOException;
3836
import com.laytonsmith.core.exceptions.CRE.CREIncludeException;
39-
import com.laytonsmith.core.exceptions.CRE.CREPlayerOfflineException;
4037
import com.laytonsmith.core.exceptions.CRE.CRESecurityException;
4138
import com.laytonsmith.core.exceptions.CRE.CREThrowable;
4239
import com.laytonsmith.core.exceptions.ConfigCompileException;
@@ -124,124 +121,6 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
124121
}
125122
}
126123

127-
@api(environments = {CommandHelperEnvironment.class})
128-
public static class raw_set_pvanish extends AbstractFunction {
129-
130-
@Override
131-
public String getName() {
132-
return "raw_set_pvanish";
133-
}
134-
135-
@Override
136-
public Integer[] numArgs() {
137-
return new Integer[]{2, 3};
138-
}
139-
140-
@Override
141-
public String docs() {
142-
return "void {[player], isVanished, otherPlayer} Sets the visibility"
143-
+ " of the current player (or the one specified) to visible or invisible"
144-
+ " (based on the value of isVanished) from the view of the otherPlayer."
145-
+ " This is the raw access function, you probably shouldn't use this, as"
146-
+ " the CommandHelper vanish api functions will probably be easier to use.";
147-
}
148-
149-
@Override
150-
public Class<? extends CREThrowable>[] thrown() {
151-
return new Class[]{CREPlayerOfflineException.class};
152-
}
153-
154-
@Override
155-
public boolean isRestricted() {
156-
return true; //lol, very
157-
}
158-
159-
@Override
160-
public Boolean runAsync() {
161-
return false;
162-
}
163-
164-
@Override
165-
public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException {
166-
MCPlayer me;
167-
boolean isVanished;
168-
MCPlayer other;
169-
if(args.length == 2) {
170-
me = environment.getEnv(CommandHelperEnvironment.class).GetPlayer();
171-
isVanished = ArgumentValidation.getBoolean(args[0], t);
172-
other = Static.GetPlayer(args[1], t);
173-
} else {
174-
me = Static.GetPlayer(args[0], t);
175-
isVanished = ArgumentValidation.getBoolean(args[1], t);
176-
other = Static.GetPlayer(args[2], t);
177-
}
178-
179-
other.setVanished(isVanished, me);
180-
181-
return CVoid.VOID;
182-
}
183-
184-
@Override
185-
public MSVersion since() {
186-
return MSVersion.V3_3_0;
187-
}
188-
}
189-
190-
@api(environments = {CommandHelperEnvironment.class})
191-
public static class raw_pcan_see extends AbstractFunction {
192-
193-
@Override
194-
public String getName() {
195-
return "raw_pcan_see";
196-
}
197-
198-
@Override
199-
public Integer[] numArgs() {
200-
return new Integer[]{1, 2};
201-
}
202-
203-
@Override
204-
public String docs() {
205-
return "boolean {[player], other} Returns a boolean stating if the other player can"
206-
+ " see this player or not. This is the raw access function, you probably shouldn't use this, as"
207-
+ " the CommandHelper vanish api functions will probably be easier to use.";
208-
}
209-
210-
@Override
211-
public Class<? extends CREThrowable>[] thrown() {
212-
return new Class[]{CREPlayerOfflineException.class};
213-
}
214-
215-
@Override
216-
public boolean isRestricted() {
217-
return true;
218-
}
219-
220-
@Override
221-
public Boolean runAsync() {
222-
return false;
223-
}
224-
225-
@Override
226-
public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException {
227-
MCPlayer me;
228-
MCPlayer other;
229-
if(args.length == 1) {
230-
me = environment.getEnv(CommandHelperEnvironment.class).GetPlayer();
231-
other = Static.GetPlayer(args[0], t);
232-
} else {
233-
me = Static.GetPlayer(args[0], t);
234-
other = Static.GetPlayer(args[1], t);
235-
}
236-
return CBoolean.get(me.canSee(other));
237-
}
238-
239-
@Override
240-
public MSVersion since() {
241-
return MSVersion.V3_3_0;
242-
}
243-
}
244-
245124
private static String GenerateMooSaying(String text) {
246125
String[] saying = text.split("\r\n|\n|\n\r");
247126
int longest = 0;

0 commit comments

Comments
 (0)