Project cleanup pre merge.

This commit is contained in:
2023-07-15 09:23:48 -04:00
parent 134b651df8
commit 9bbdef224d
747 changed files with 99704 additions and 101200 deletions
+104 -105
View File
@@ -12,155 +12,154 @@ import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* @author
* Summary: Game designer utility command to create multiple
* mobiles of a given UUID within a supplied range
* @author Summary: Game designer utility command to create multiple
* mobiles of a given UUID within a supplied range
*/
public class SplatMobCmd extends AbstractDevCmd {
// Instance variables
// Instance variables
private int _mobileUUID;
private int _mobileCount;
private float _targetRange;
private Vector3fImmutable _currentLocation;
private int _mobileUUID;
private int _mobileCount;
private float _targetRange;
private Vector3fImmutable _currentLocation;
// Concurrency support
// Concurrency support
private ReadWriteLock lock = new ReentrantReadWriteLock();
private ReadWriteLock lock = new ReentrantReadWriteLock();
// Constructor
// Constructor
public SplatMobCmd() {
public SplatMobCmd() {
super("splatmob");
}
// AbstractDevCmd Overridden methods
// AbstractDevCmd Overridden methods
@Override
protected void _doCmd(PlayerCharacter pc, String[] args,
AbstractGameObject target) {
private static boolean validateUserInput(String[] userInput) {
// Member variables
// incorrect number of arguments test
Vector3fImmutable mobileLocation;
Mob mobile;
Zone serverZone;
if (userInput.length != 3)
return false;
// Concurrency write lock due to instance variable usage
// Test for UUID conversion to int
lock.writeLock().lock();
try {
Integer.parseInt(userInput[0]);
} catch (NumberFormatException | NullPointerException e) {
return false;
}
try {
// Validate user input
// Test for Number of Mobs conversion to int
if(validateUserInput(args) == false) {
this.sendUsage(pc);
return;
}
try {
Integer.parseInt(userInput[1]);
} catch (NumberFormatException | NullPointerException e) {
return false;
}
// Parse user input
// Test if range argument can convert to a float
parseUserInput(args);
try {
Float.parseFloat(userInput[2]);
} catch (NumberFormatException | NullPointerException e) {
return false;
}
// Arguments have been validated and parsed at this point
// Begin creating mobiles
return true;
}
_currentLocation = pc.getLoc();
serverZone = ZoneManager.findSmallestZone(_currentLocation);
@Override
protected void _doCmd(PlayerCharacter pc, String[] args,
AbstractGameObject target) {
for(int i=0;i<_mobileCount;i++) {
// Member variables
mobile = Mob.createMob(_mobileUUID,
Vector3fImmutable.getRandomPointInCircle(_currentLocation, _targetRange),
null, true, serverZone,null,0, "", 1);
Vector3fImmutable mobileLocation;
Mob mobile;
Zone serverZone;
if (mobile != null) {
mobile.updateDatabase();
}
}
// Concurrency write lock due to instance variable usage
} // End Try Block
lock.writeLock().lock();
// Release Reentrant lock
try {
finally {
lock.writeLock().unlock();
}
}
// Validate user input
@Override
protected String _getHelpString() {
if (validateUserInput(args) == false) {
this.sendUsage(pc);
return;
}
// Parse user input
parseUserInput(args);
// Arguments have been validated and parsed at this point
// Begin creating mobiles
_currentLocation = pc.getLoc();
serverZone = ZoneManager.findSmallestZone(_currentLocation);
for (int i = 0; i < _mobileCount; i++) {
mobile = Mob.createMob(_mobileUUID,
Vector3fImmutable.getRandomPointInCircle(_currentLocation, _targetRange),
null, true, serverZone, null, 0, "", 1);
if (mobile != null) {
mobile.updateDatabase();
}
}
} // End Try Block
// Release Reentrant lock
finally {
lock.writeLock().unlock();
}
}
@Override
protected String _getHelpString() {
return "Spawns multiple mobiles with a given range";
}
}
@Override
protected String _getUsageString() {
// Class methods
@Override
protected String _getUsageString() {
return "/splatmob UUID [Count <= 100] [range <= 1200]";
}
}
// Class methods
private void parseUserInput(String[] userInput) {
private static boolean validateUserInput(String[] userInput) {
// Clear previous values
// incorrect number of arguments test
_mobileUUID = 0;
_mobileCount = 0;
_targetRange = 0f;
if (userInput.length != 3)
return false;
// Parse first argument into mobile UID.
// Test for UUID conversion to int
_mobileUUID = Integer.parseInt(userInput[0]);
try {
Integer.parseInt(userInput[0]); }
catch (NumberFormatException | NullPointerException e) {
return false;
}
// Parse second argument into mobile count. Cap at 100 mobs.
_mobileCount = Integer.parseInt(userInput[1]);
_mobileCount = Math.min(_mobileCount, 100);
// Test for Number of Mobs conversion to int
// Parse third argument into range. Cap at 200 units.
try {
Integer.parseInt(userInput[1]); }
catch (NumberFormatException | NullPointerException e) {
return false;
}
_targetRange = Float.parseFloat(userInput[2]);
_targetRange = Math.min(_targetRange, 1200f);
// Test if range argument can convert to a float
try {
Float.parseFloat(userInput[2]); }
catch (NumberFormatException | NullPointerException e) {
return false;
}
return true;
}
private void parseUserInput(String[] userInput) {
// Clear previous values
_mobileUUID = 0;
_mobileCount = 0;
_targetRange = 0f;
// Parse first argument into mobile UID.
_mobileUUID = Integer.parseInt(userInput[0]);
// Parse second argument into mobile count. Cap at 100 mobs.
_mobileCount = Integer.parseInt(userInput[1]);
_mobileCount = Math.min(_mobileCount, 100);
// Parse third argument into range. Cap at 200 units.
_targetRange = Float.parseFloat(userInput[2]);
_targetRange = Math.min(_targetRange, 1200f);
}
}
}