Fixed LUA property methods setting default values when passed nil
This commit is contained in:
parent
0f6c5da42d
commit
589064d03f
20 changed files with 46 additions and 46 deletions
|
@ -280,7 +280,7 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas
|
|||
|
||||
protected UUID computer_getUUID(final UUID uuidDefault, final Object[] arguments) {
|
||||
try {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
if (arguments[0] instanceof UUID) {
|
||||
return (UUID) arguments[0];
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ public class TileEntityChunkLoader extends TileEntityAbstractChunkLoading {
|
|||
|
||||
// Common OC/CC methods
|
||||
public Object[] enable(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
isEnabled = Commons.toBool(arguments[0]);
|
||||
}
|
||||
return new Object[] { isEnabled };
|
||||
|
@ -189,7 +189,7 @@ public class TileEntityChunkLoader extends TileEntityAbstractChunkLoading {
|
|||
}
|
||||
|
||||
public Object[] radius(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
final int radius = Commons.toInt(arguments[0]);
|
||||
setBounds(radius, radius, radius, radius);
|
||||
}
|
||||
|
|
|
@ -637,7 +637,7 @@ public class TileEntityLaser extends TileEntityAbstractLaser implements IBeamFre
|
|||
return new Integer[] { xCoord, yCoord, zCoord };
|
||||
|
||||
case "beamFrequency":
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
setBeamFrequency(Commons.toInt(arguments[0]));
|
||||
}
|
||||
return new Integer[] { beamFrequency };
|
||||
|
|
|
@ -158,7 +158,7 @@ public class TileEntityAcceleratorControlPoint extends TileEntityAbstractInterfa
|
|||
|
||||
// Common OC/CC methods
|
||||
public Object[] enable(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
boolean enable;
|
||||
try {
|
||||
enable = Commons.toBool(arguments[0]);
|
||||
|
@ -190,7 +190,7 @@ public class TileEntityAcceleratorControlPoint extends TileEntityAbstractInterfa
|
|||
return enable(arguments);
|
||||
|
||||
case "controlChannel":
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
setControlChannel(Commons.toInt(arguments[0]));
|
||||
}
|
||||
return new Integer[] { controlChannel };
|
||||
|
|
|
@ -132,7 +132,7 @@ public class TileEntityAirGenerator extends TileEntityAbstractEnergy {
|
|||
|
||||
// Common OC/CC methods
|
||||
public Object[] enable(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
isEnabled = Commons.toBool(arguments[0]);
|
||||
}
|
||||
return new Object[] { isEnabled };
|
||||
|
|
|
@ -153,7 +153,7 @@ public class TileEntityAirGeneratorTiered extends TileEntityAbstractEnergy {
|
|||
}
|
||||
|
||||
public Object[] enable(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
isEnabled = Commons.toBool(arguments[0]);
|
||||
}
|
||||
return new Object[] { isEnabled };
|
||||
|
|
|
@ -659,7 +659,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
|||
|
||||
private Object[] radius(Object[] arguments) {
|
||||
try {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
radiusX = Commons.clamp(1, WarpDriveConfig.TREE_FARM_totalMaxRadius, Commons.toInt(arguments[0]));
|
||||
radiusZ = radiusX;
|
||||
markDirty();
|
||||
|
@ -676,7 +676,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
|||
}
|
||||
|
||||
private Object[] breakLeaves(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
try {
|
||||
breakLeaves = Commons.toBool(arguments[0]);
|
||||
markDirty();
|
||||
|
@ -688,7 +688,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
|||
}
|
||||
|
||||
private Object[] silktouch(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
try {
|
||||
enableSilktouch = Commons.toBool(arguments[0]);
|
||||
markDirty();
|
||||
|
@ -700,7 +700,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
|||
}
|
||||
|
||||
private Object[] tapTrees(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
try {
|
||||
tapTrees = Commons.toBool(arguments[0]);
|
||||
markDirty();
|
||||
|
|
|
@ -447,7 +447,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractMiner {
|
|||
}
|
||||
|
||||
private Object[] onlyOres(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
try {
|
||||
mineAllBlocks = ! Commons.toBool(arguments[0]);
|
||||
markDirty();
|
||||
|
@ -462,7 +462,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractMiner {
|
|||
}
|
||||
|
||||
private Object[] offset(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
try {
|
||||
layerOffset = Math.min(256, Math.abs(Commons.toInt(arguments[0])));
|
||||
markDirty();
|
||||
|
@ -477,7 +477,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractMiner {
|
|||
}
|
||||
|
||||
private Object[] silktouch(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
try {
|
||||
enableSilktouch = Commons.toBool(arguments[0]);
|
||||
markDirty();
|
||||
|
|
|
@ -148,7 +148,7 @@ public class TileEntityCamera extends TileEntityAbstractInterfaced implements IV
|
|||
final String methodName = getMethodName(method);
|
||||
|
||||
if (methodName.equals("videoChannel")) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
setVideoChannel(Commons.toInt(arguments[0]));
|
||||
}
|
||||
return new Integer[] { videoChannel };
|
||||
|
|
|
@ -471,7 +471,7 @@ public class TileEntityCloakingCore extends TileEntityAbstractEnergy {
|
|||
|
||||
// Common OC/CC methods
|
||||
public Object[] tier(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
int tier_new;
|
||||
try {
|
||||
tier_new = Commons.toInt(arguments[0]);
|
||||
|
@ -493,7 +493,7 @@ public class TileEntityCloakingCore extends TileEntityAbstractEnergy {
|
|||
}
|
||||
|
||||
public Object[] enable(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
isEnabled = Commons.toBool(arguments[0]);
|
||||
markDirty();
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ public class TileEntityMonitor extends TileEntityAbstractInterfaced implements I
|
|||
final String methodName = getMethodName(method);
|
||||
|
||||
if (methodName.equals("videoChannel")) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
setVideoChannel(Commons.toInt(arguments[0]));
|
||||
}
|
||||
return new Integer[] { videoChannel };
|
||||
|
|
|
@ -132,7 +132,7 @@ public class TileEntityRadar extends TileEntityAbstractEnergy {
|
|||
|
||||
private Object[] getEnergyRequired(Object[] arguments) {
|
||||
try {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
return new Object[] { calculateEnergyRequired(Commons.toInt(arguments[0])) };
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
|
@ -143,7 +143,7 @@ public class TileEntityRadar extends TileEntityAbstractEnergy {
|
|||
|
||||
private Object[] getScanDuration(Object[] arguments) {
|
||||
try {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
return new Object[] { 0.050D * calculateScanDuration(Commons.toInt(arguments[0])) };
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
|
|
|
@ -380,7 +380,7 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen
|
|||
// Common OC/CC methods
|
||||
@Override
|
||||
public Object[] enable(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
boolean enableRequest;
|
||||
try {
|
||||
enableRequest = Commons.toBool(arguments[0]);
|
||||
|
@ -419,7 +419,7 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen
|
|||
|
||||
@Override
|
||||
public Object[] instabilityTarget(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
double instabilityTargetRequested;
|
||||
try {
|
||||
instabilityTargetRequested = Commons.toDouble(arguments[0]);
|
||||
|
@ -437,7 +437,7 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen
|
|||
|
||||
@Override
|
||||
public Object[] release(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
boolean releaseRequested;
|
||||
try {
|
||||
releaseRequested = Commons.toBool(arguments[0]);
|
||||
|
@ -457,7 +457,7 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen
|
|||
|
||||
@Override
|
||||
public Object[] releaseRate(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
int releaseRateRequested;
|
||||
try {
|
||||
releaseRateRequested = Commons.toInt(arguments[0]);
|
||||
|
@ -505,7 +505,7 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen
|
|||
|
||||
@Override
|
||||
public Object[] stabilizerEnergy(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
int stabilizerEnergyRequested;
|
||||
try {
|
||||
stabilizerEnergyRequested = Commons.toInt(arguments[0]);
|
||||
|
|
|
@ -155,7 +155,7 @@ public class TileEntityAbstractForceField extends TileEntityAbstractEnergy imple
|
|||
|
||||
// Common OC/CC methods
|
||||
public Object[] enable(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
boolean enable;
|
||||
try {
|
||||
enable = Commons.toBool(arguments[0]);
|
||||
|
@ -182,7 +182,7 @@ public class TileEntityAbstractForceField extends TileEntityAbstractEnergy imple
|
|||
return enable(arguments);
|
||||
|
||||
case "beamFrequency":
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
setBeamFrequency(Commons.toInt(arguments[0]));
|
||||
}
|
||||
return new Integer[] { beamFrequency };
|
||||
|
|
|
@ -1093,7 +1093,7 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
|
|||
|
||||
switch (methodName) {
|
||||
case "min":
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
setMin(Commons.toFloat(arguments[0]), Commons.toFloat(arguments[0]), Commons.toFloat(arguments[0]));
|
||||
} else if (arguments.length == 2) {
|
||||
setMin(Commons.toFloat(arguments[0]), Commons.toFloat(arguments[1]), Commons.toFloat(arguments[0]));
|
||||
|
@ -1103,7 +1103,7 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
|
|||
return new Double[] { v3Min.x, v3Min.y, v3Min.z };
|
||||
|
||||
case "max":
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
setMax(Commons.toFloat(arguments[0]), Commons.toFloat(arguments[0]), Commons.toFloat(arguments[0]));
|
||||
} else if (arguments.length == 2) {
|
||||
setMax(Commons.toFloat(arguments[0]), Commons.toFloat(arguments[1]), Commons.toFloat(arguments[0]));
|
||||
|
@ -1113,7 +1113,7 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
|
|||
return new Double[] { v3Max.x, v3Max.y, v3Max.z };
|
||||
|
||||
case "rotation":
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
setRotation(Commons.toFloat(arguments[0]), rotationPitch, rotationRoll);
|
||||
} else if (arguments.length == 2) {
|
||||
setRotation(Commons.toFloat(arguments[0]), Commons.toFloat(arguments[1]), rotationRoll);
|
||||
|
@ -1126,7 +1126,7 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
|
|||
return state();
|
||||
|
||||
case "translation":
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
setTranslation(Commons.toFloat(arguments[0]), Commons.toFloat(arguments[0]), Commons.toFloat(arguments[0]));
|
||||
} else if (arguments.length == 2) {
|
||||
setTranslation(Commons.toFloat(arguments[0]), Commons.toFloat(arguments[1]), Commons.toFloat(arguments[0]));
|
||||
|
|
|
@ -216,7 +216,7 @@ public class TileEntityLift extends TileEntityAbstractEnergy implements ILift {
|
|||
// Common OC/CC methods
|
||||
@Override
|
||||
public Object[] enable(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
isEnabled = Commons.toBool(arguments[0]);
|
||||
markDirty();
|
||||
}
|
||||
|
|
|
@ -450,7 +450,7 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced imple
|
|||
if (tileEntityShipCore == null) {
|
||||
return null;
|
||||
}
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
final String shipNamePrevious = tileEntityShipCore.shipName;
|
||||
tileEntityShipCore.shipName = Commons.sanitizeFileName((String) arguments[0]);
|
||||
if ( tileEntityShipCore.shipName == null
|
||||
|
@ -534,7 +534,7 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced imple
|
|||
@Override
|
||||
public Object[] command(Object[] arguments) {
|
||||
try {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
setCommand(arguments[0].toString());
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
|
@ -546,7 +546,7 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced imple
|
|||
|
||||
@Override
|
||||
public Object[] enable(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
isEnabled = Commons.toBool(arguments[0]);
|
||||
if (WarpDriveConfig.LOGGING_LUA) {
|
||||
WarpDrive.logger.info(this + " enable(" + isEnabled + ")");
|
||||
|
@ -595,7 +595,7 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced imple
|
|||
@Override
|
||||
public Object[] rotationSteps(Object[] arguments) {
|
||||
try {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
setRotationSteps((byte) Commons.toInt(arguments[0]));
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
|
@ -607,7 +607,7 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced imple
|
|||
|
||||
@Override
|
||||
public Object[] targetName(Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
this.nameTarget = (String) arguments[0];
|
||||
}
|
||||
return new Object[] { nameTarget };
|
||||
|
|
|
@ -126,7 +126,7 @@ public class TileEntityTransporterBeacon extends TileEntityAbstractEnergy implem
|
|||
// Common OC/CC methods
|
||||
@Override
|
||||
public Boolean[] enable(final Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
isEnabled = Commons.toBool(arguments[0]);
|
||||
markDirty();
|
||||
}
|
||||
|
|
|
@ -1470,7 +1470,7 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergy implemen
|
|||
// Common OC/CC methods
|
||||
@Override
|
||||
public String[] transporterName(final Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
final String transporterNameNew = arguments[0].toString();
|
||||
if (!transporterName.equals(transporterNameNew)) {
|
||||
transporterName = transporterNameNew;
|
||||
|
@ -1482,7 +1482,7 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergy implemen
|
|||
|
||||
@Override
|
||||
public Boolean[] enable(final Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
isEnabled = Commons.toBool(arguments[0]);
|
||||
markDirty();
|
||||
}
|
||||
|
@ -1514,7 +1514,7 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergy implemen
|
|||
tickUpdateParameters = 0;
|
||||
}
|
||||
}
|
||||
} else if (arguments.length == 1) {
|
||||
} else if (arguments.length == 1 && arguments[0] != null) {
|
||||
// is it a UUID?
|
||||
final UUID uuidNew = computer_getUUID(null, arguments);
|
||||
if (uuidNew != null) {
|
||||
|
@ -1547,7 +1547,7 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergy implemen
|
|||
|
||||
@Override
|
||||
public Boolean[] lock(final Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
isLockRequested = Commons.toBool(arguments[0]);
|
||||
markDirty();
|
||||
}
|
||||
|
@ -1579,7 +1579,7 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergy implemen
|
|||
|
||||
@Override
|
||||
public Boolean[] energize(final Object[] arguments) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
isEnergizeRequested = Commons.toBool(arguments[0]);
|
||||
markDirty();
|
||||
}
|
||||
|
@ -1658,7 +1658,7 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergy implemen
|
|||
|
||||
switch (methodName) {
|
||||
case "beamFrequency":
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
setBeamFrequency(Commons.toInt(arguments[0]));
|
||||
}
|
||||
return new Integer[] { beamFrequency };
|
||||
|
|
|
@ -138,7 +138,7 @@ public class TileEntityLaserCamera extends TileEntityLaser implements IVideoChan
|
|||
final String methodName = getMethodName(method);
|
||||
|
||||
if (methodName.equals("videoChannel")) {
|
||||
if (arguments.length == 1) {
|
||||
if (arguments.length == 1 && arguments[0] != null) {
|
||||
setVideoChannel(Commons.toInt(arguments[0]));
|
||||
}
|
||||
return new Integer[] { videoChannel };
|
||||
|
|
Loading…
Reference in a new issue