Skip to content

Commit da2b820

Browse files
committed
Continue fixing deprecations
1 parent d4f8b9f commit da2b820

29 files changed

+927
-852
lines changed

deprecation.txt

-1.41 MB
Binary file not shown.

src/main/java/com/laytonsmith/core/ObjectGenerator.java

Lines changed: 494 additions & 419 deletions
Large diffs are not rendered by default.

src/main/java/com/laytonsmith/core/events/drivers/BlockEvents.java

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws Even
8787
CArray affected = new CArray(t);
8888
for(MCBlock block : event.getAffectedBlocks()) {
8989
MCMaterial mat = block.getType();
90-
CArray blk = CArray.GetAssociativeArray(t);
91-
blk.set("name", mat.getName(), t);
92-
blk.set("x", new CInt(block.getX(), t), t);
93-
blk.set("y", new CInt(block.getY(), t), t);
94-
blk.set("z", new CInt(block.getZ(), t), t);
95-
blk.set("world", new CString(block.getWorld().getName(), t), t);
96-
affected.push(blk, t);
90+
CArray blk = CArray.GetAssociativeArray(t, null, env);
91+
blk.set("name", mat.getName(), t, env);
92+
blk.set("x", new CInt(block.getX(), t), t, env);
93+
blk.set("y", new CInt(block.getY(), t), t, env);
94+
blk.set("z", new CInt(block.getZ(), t), t, env);
95+
blk.set("world", new CString(block.getWorld().getName(), t), t, env);
96+
affected.push(blk, t, env);
9797
}
9898
map.put("affectedBlocks", affected);
9999

@@ -261,7 +261,7 @@ public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws Even
261261

262262
CArray drops = new CArray(t);
263263
for(MCItemStack stack : event.getDrops()) {
264-
drops.push(ObjectGenerator.GetGenerator().item(stack, t), t);
264+
drops.push(ObjectGenerator.GetGenerator().item(stack, t, env), t, env);
265265
}
266266
map.put("drops", drops);
267267

@@ -279,9 +279,9 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent e, Environment
279279
List<MCItemStack> drops = new ArrayList<>();
280280
if(value.isInstanceOf(CArray.TYPE, null, env)) {
281281
CArray arr = (CArray) value;
282-
for(int i = 0; i < arr.size(); i++) {
283-
CArray item = ArgumentValidation.getArray(arr.get(i, value.getTarget()), value.getTarget());
284-
MCItemStack stack = ObjectGenerator.GetGenerator().item(item, value.getTarget());
282+
for(int i = 0; i < arr.size(env); i++) {
283+
CArray item = ArgumentValidation.getArray(arr.get(i, value.getTarget(), env), value.getTarget(), env);
284+
MCItemStack stack = ObjectGenerator.GetGenerator().item(item, value.getTarget(), env);
285285
if(!stack.isEmpty()) {
286286
drops.add(stack);
287287
}
@@ -400,7 +400,7 @@ public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws Even
400400
map.put("player", new CString(event.getPlayer().getName(), t));
401401
map.put("block", new CString(mat.getName(), t));
402402
map.put("location", ObjectGenerator.GetGenerator().location(block.getLocation(), false));
403-
map.put("item", ObjectGenerator.GetGenerator().item(event.getItemInHand(), Target.UNKNOWN));
403+
map.put("item", ObjectGenerator.GetGenerator().item(event.getItemInHand(), Target.UNKNOWN, env));
404404
if(event.getHand() == MCEquipmentSlot.WEAPON) {
405405
map.put("hand", new CString("main_hand", Target.UNKNOWN));
406406
} else {
@@ -409,11 +409,11 @@ public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws Even
409409

410410
MCBlock agstblock = event.getBlockAgainst();
411411
MCMaterial agstmat = agstblock.getType();
412-
CArray agst = CArray.GetAssociativeArray(t);
413-
agst.set("name", agstmat.getName(), t);
414-
agst.set("x", new CInt(agstblock.getX(), t), t);
415-
agst.set("y", new CInt(agstblock.getY(), t), t);
416-
agst.set("z", new CInt(agstblock.getZ(), t), t);
412+
CArray agst = CArray.GetAssociativeArray(t, null, env);
413+
agst.set("name", agstmat.getName(), t, env);
414+
agst.set("x", new CInt(agstblock.getX(), t), t, env);
415+
agst.set("y", new CInt(agstblock.getY(), t), t, env);
416+
agst.set("z", new CInt(agstblock.getZ(), t), t, env);
417417
map.put("against", agst);
418418

419419
map.put("oldblock", new CString(event.getBlockReplacedState().getType().getName(), t));
@@ -786,11 +786,11 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environ
786786
if(value.isInstanceOf(CArray.TYPE, null, env)) {
787787
CArray blockArray = (CArray) value;
788788
if(blockArray.containsKey("name")) {
789-
Mixed name = blockArray.get("name", value.getTarget());
789+
Mixed name = blockArray.get("name", value.getTarget(), env);
790790
int data = 0;
791791
if(blockArray.containsKey("data")) {
792792
try {
793-
data = Integer.parseInt(blockArray.get("data", value.getTarget()).val());
793+
data = Integer.parseInt(blockArray.get("data", value.getTarget(), env).val());
794794
} catch (Exception ex) {
795795
throw new CREFormatException("blockArray is invalid", value.getTarget());
796796
}
@@ -808,13 +808,13 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environ
808808
int type;
809809
int data = 0;
810810
try {
811-
type = Integer.parseInt(blockArray.get("type", value.getTarget()).val());
811+
type = Integer.parseInt(blockArray.get("type", value.getTarget(), env).val());
812812
} catch (Exception ex) {
813813
throw new CREFormatException("blockArray is invalid", value.getTarget());
814814
}
815815
if(blockArray.containsKey("data")) {
816816
try {
817-
data = Integer.parseInt(blockArray.get("data", value.getTarget()).val());
817+
data = Integer.parseInt(blockArray.get("data", value.getTarget(), env).val());
818818
} catch (Exception ex) {
819819
throw new CREFormatException("blockArray is invalid", value.getTarget());
820820
}
@@ -842,11 +842,11 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environ
842842
if(value.isInstanceOf(CArray.TYPE, null, env)) {
843843
CArray blockArray = (CArray) value;
844844
if(blockArray.containsKey("name")) {
845-
Mixed name = blockArray.get("name", value.getTarget());
845+
Mixed name = blockArray.get("name", value.getTarget(), env);
846846
int data = 0;
847847
if(blockArray.containsKey("data")) {
848848
try {
849-
data = Integer.parseInt(blockArray.get("data", value.getTarget()).val());
849+
data = Integer.parseInt(blockArray.get("data", value.getTarget(), env).val());
850850
} catch (Exception ex) {
851851
throw new CREFormatException("blockArray is invalid", value.getTarget());
852852
}
@@ -864,13 +864,13 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environ
864864
int type;
865865
int data = 0;
866866
try {
867-
type = Integer.parseInt(blockArray.get("type", value.getTarget()).val());
867+
type = Integer.parseInt(blockArray.get("type", value.getTarget(), env).val());
868868
} catch (Exception ex) {
869869
throw new CREFormatException("blockArray is invalid", value.getTarget());
870870
}
871871
if(blockArray.containsKey("data")) {
872872
try {
873-
data = Integer.parseInt(blockArray.get("data", value.getTarget()).val());
873+
data = Integer.parseInt(blockArray.get("data", value.getTarget(), env).val());
874874
} catch (Exception ex) {
875875
throw new CREFormatException("blockArray is invalid", value.getTarget());
876876
}
@@ -977,14 +977,14 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environ
977977
}
978978

979979
CArray val = (CArray) value;
980-
if(val.size() != 4) {
980+
if(val.size(env) != 4) {
981981
return false;
982982
}
983983

984984
String[] lines = {"", "", "", ""};
985985

986986
for(int i = 0; i < 4; i++) {
987-
lines[i] = val.get(i, value.getTarget()).toString();
987+
lines[i] = val.get(i, value.getTarget(), env).toString();
988988
}
989989

990990
sce.setLines(lines);
@@ -1019,9 +1019,9 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environ
10191019
public BindableEvent convert(CArray manual, Target t, Environment env) {
10201020
MCSignChangeEvent e = EventBuilder.instantiate(
10211021
MCSignChangeEvent.class,
1022-
Static.GetPlayer(manual.get("player", Target.UNKNOWN).val(), Target.UNKNOWN),
1023-
manual.get("1", Target.UNKNOWN).val(), manual.get("2", Target.UNKNOWN).val(),
1024-
manual.get("3", Target.UNKNOWN).val(), manual.get("4", Target.UNKNOWN).val());
1022+
Static.GetPlayer(manual.get("player", Target.UNKNOWN, env).val(), Target.UNKNOWN, env),
1023+
manual.get("1", Target.UNKNOWN, env).val(), manual.get("2", Target.UNKNOWN, env).val(),
1024+
manual.get("3", Target.UNKNOWN, env).val(), manual.get("4", Target.UNKNOWN, env).val());
10251025
return e;
10261026
}
10271027
}
@@ -1089,11 +1089,11 @@ public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws Even
10891089
MCBlock block = event.getBlock();
10901090

10911091
map.put("type", new CString(block.getType().getName(), t));
1092-
map.put("item", ObjectGenerator.GetGenerator().item(event.getItem(), t));
1092+
map.put("item", ObjectGenerator.GetGenerator().item(event.getItem(), t, env));
10931093
map.put("location", ObjectGenerator.GetGenerator().location(block.getLocation(), false));
10941094

10951095
CArray velocity = ObjectGenerator.GetGenerator().vector(event.getVelocity(), t);
1096-
velocity.set("magnitude", new CDouble(event.getVelocity().length(), t), t);
1096+
velocity.set("magnitude", new CDouble(event.getVelocity().length(), t), t, env);
10971097
map.put("velocity", velocity);
10981098

10991099
return map;
@@ -1103,7 +1103,7 @@ public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws Even
11031103
public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) {
11041104
if(event instanceof MCBlockDispenseEvent) {
11051105
if("item".equals(key)) {
1106-
((MCBlockDispenseEvent) event).setItem(ObjectGenerator.GetGenerator().item(value, value.getTarget()));
1106+
((MCBlockDispenseEvent) event).setItem(ObjectGenerator.GetGenerator().item(value, value.getTarget(), env));
11071107
return true;
11081108
}
11091109
if("velocity".equals(key)) {
@@ -1444,7 +1444,7 @@ public Map<String, Mixed> evaluate(BindableEvent e, Environment env) throws Even
14441444
ret.put("location", ObjectGenerator.GetGenerator().location(blk.getLocation(), false));
14451445
CArray blocks = new CArray(t);
14461446
for(MCBlock b : event.getBlocks()) {
1447-
blocks.push(ObjectGenerator.GetGenerator().location(b.getLocation(), false), t);
1447+
blocks.push(ObjectGenerator.GetGenerator().location(b.getLocation(), false), t, env);
14481448
}
14491449
ret.put("blocks", blocks);
14501450
ret.put("yield", new CDouble(event.getYield(), t));
@@ -1456,15 +1456,15 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environ
14561456
if(event instanceof MCBlockExplodeEvent) {
14571457
MCBlockExplodeEvent e = (MCBlockExplodeEvent) event;
14581458
if(key.equals("yield")) {
1459-
e.setYield((float) ArgumentValidation.getDouble(value, value.getTarget()));
1459+
e.setYield((float) ArgumentValidation.getDouble(value, value.getTarget(), env));
14601460
return true;
14611461
}
14621462
if(key.equals("blocks")) {
14631463
if(value.isInstanceOf(CArray.TYPE, null, env)) {
14641464
CArray ba = (CArray) value;
14651465
List<MCBlock> blocks = new ArrayList<>();
14661466
for(Mixed m : ba.asList()) {
1467-
MCLocation loc = ObjectGenerator.GetGenerator().location(m, null, value.getTarget());
1467+
MCLocation loc = ObjectGenerator.GetGenerator().location(m, null, value.getTarget(), env);
14681468
blocks.add(loc.getBlock());
14691469
}
14701470
e.setBlocks(blocks);

0 commit comments

Comments
 (0)