Merge remote-tracking branch 'origin/magicbot-reg-update' into magicbox1.5

# Conflicts:
#	src/engine/ai/MobileFSM.java
#	src/engine/ai/MobileFSMManager.java
#	src/engine/devcmd/cmds/SetAICmd.java
#	src/engine/gameManager/DevCmdManager.java
This commit is contained in:
2023-07-15 09:27:57 -04:00
748 changed files with 99752 additions and 101122 deletions
+11 -4
View File
@@ -1,17 +1,23 @@
![Logo](https://magicbane.com/images/MBLogo.jpg)
# Magicbane Open-Source MMO Project
### *The Community written Shadowbane emulator*
[Magicbane](http://www.magicbane.com)
</BR>
[Public Repository](http://repo.magicbane.com)
<BR>
<magicbot@magicbane.com>
> Magicbane is an emulator for the long dead but much beloved Ubisoft MMO, [Shadowbane](https://en.wikipedia.org/wiki/Shadowbane).
The project was founded in 2013 with the concept of free availability of gameplay; players unencumbered by any factor other than a desire to again play a game they once loved. A game where the developers do not play is guaranteed to be the fairest game.
> Magicbane is an emulator for the long dead but much beloved Ubisoft
> MMO, [Shadowbane](https://en.wikipedia.org/wiki/Shadowbane).
> The project was founded in 2013 with the concept of free availability of gameplay; players unencumbered by any factor
> other than a desire to again play a game they once loved. A game where the developers do not play is guaranteed to be
> the fairest game.
The Magicbane Team has wanted to open source Shadowbane for half a decade. We are excited to now finally have the opportunity, along with some new technology, to truly democratize Shadowbane.
The Magicbane Team has wanted to open source Shadowbane for half a decade. We are excited to now finally have the
opportunity, along with some new technology, to truly democratize Shadowbane.
- Written in some 80k lines of Java 8 and bash.
- Project with real infrastructure; Production and development servers supporting multiple containerized apps.
@@ -27,4 +33,5 @@ The Magicbane Team has wanted to open source Shadowbane for half a decade. We a
## Support
Documentation is available through the Magicbane [Wiki](http://repo.magicbane.com/MagicBane/Server/wiki) and [Discord server](www.magicbane.com).
Documentation is available through the Magicbane [Wiki](http://repo.magicbane.com/MagicBane/Server/wiki)
and [Discord server](www.magicbane.com).
+2
View File
@@ -7,6 +7,7 @@
// www.magicbane.com
package discord;
import engine.Enum;
import java.time.LocalDateTime;
@@ -18,6 +19,7 @@ public class DiscordAccount {
public LocalDateTime registrationDate;
public LocalDateTime lastUpdateRequest;
public byte isDiscordAdmin;
public DiscordAccount() {
}
+128 -127
View File
@@ -59,10 +59,10 @@ import static discord.ChatChannel.ADMINLOG;
*/
public class MagicBot extends ListenerAdapter {
public static JDA jda;
public static Database database;
public static final Pattern accountNameRegex = Pattern.compile("^[\\p{Alnum}]{6,20}$");
public static final Pattern passwordRegex = Pattern.compile("^[\\p{Alnum}]{6,20}$");
public static JDA jda;
public static Database database;
public static long discordServerID;
public static long discordRoleID;
@@ -132,6 +132,130 @@ public class MagicBot extends ListenerAdapter {
}
public static void sendResponse(MessageReceivedEvent event, String responseContent) {
// Send a formatted MagicBot response to a Discord user
String discordUserName;
MessageChannel channel;
// Exit if discord is offline
if (jda.getStatus().equals(JDA.Status.CONNECTED) == false)
return;
discordUserName = event.getAuthor().getName();
channel = event.getMessage().getChannel();
channel.sendMessage(
"```\n" + "Hello Player " + discordUserName + "\n\n" +
responseContent + "\n\n" +
RobotSpeak.getRobotSpeak() + "\n```").queue();
}
public static boolean isAdminEvent(MessageReceivedEvent event) {
String discordAccountID = event.getAuthor().getId();
List<DiscordAccount> discordAccounts;
DiscordAccount discordAccount;
// Note that database errors will cause this to return false.
// After the database is offline Avail status must be set
// to true before any subsequent admin commands will function.
if (Database.online == false)
return false;
discordAccounts = database.getDiscordAccounts(discordAccountID);
if (discordAccounts.isEmpty())
return false;
discordAccount = discordAccounts.get(0);
return (discordAccount.isDiscordAdmin == 1);
}
public static String generatePassword(int length) {
String ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
StringBuilder passwordBuilder = new StringBuilder(length);
Random random = new Random();
// Generate alphanumeric password of a given length.
// Could not find a good method of generating a password
// based upon a given regex.
for (int i = 0; i < length; i++)
passwordBuilder.append(ALPHABET.charAt(random.nextInt(ALPHABET.length())));
return new String(passwordBuilder);
}
public static String readLogFile(String filePath, int lineCount) {
ProcessBuilder builder = new ProcessBuilder("/bin/bash", "-c", "tail -n " + lineCount + " " + filePath);
builder.redirectErrorStream(true);
Process process = null;
String line = null;
String logOutput = "";
try {
process = builder.start();
InputStream is = process.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
while ((line = reader.readLine()) != null) {
logOutput += line + "\n";
}
} catch (IOException e) {
Logger.error(e.toString());
return "Error while reading logfile";
}
return logOutput;
}
private static void junkbot(String command, String[] inString) {
String outString;
Writer fileWriter;
if (inString == null)
return;
;
outString = command + String.join(" ", inString);
outString += "\n";
try {
fileWriter = new BufferedWriter(new FileWriter("junkbot.txt", true));
fileWriter.append(outString);
fileWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private static void SendAdminLogUpdates() {
HashMap<Integer, String> adminEvents = database.getAdminEvents();
for (int adminEvent : adminEvents.keySet()) {
// Set event as read
database.setAdminEventAsRead(adminEvent);
String outString =
"```\n" + "Hello Players \n\n" +
adminEvents.get(adminEvent) + "\n\n" +
RobotSpeak.getRobotSpeak() + "\n```";
if (ADMINLOG.textChannel.canTalk())
ADMINLOG.textChannel.sendMessage(outString).queue();
}
}
@Override
public void onMessageReceived(MessageReceivedEvent event) {
@@ -142,7 +266,8 @@ public class MagicBot extends ListenerAdapter {
// Early exit if message sent to us by another bot or ourselves.
if (event.getAuthor().isBot()) return;
if (event.getAuthor().isBot())
return;
// Extract message and origin channel from event
@@ -247,49 +372,6 @@ public class MagicBot extends ListenerAdapter {
}
}
public static void sendResponse(MessageReceivedEvent event, String responseContent) {
// Send a formatted MagicBot response to a Discord user
String discordUserName;
MessageChannel channel;
// Exit if discord is offline
if (jda.getStatus().equals(JDA.Status.CONNECTED) == false)
return;
discordUserName = event.getAuthor().getName();
channel = event.getMessage().getChannel();
channel.sendMessage(
"```\n" + "Hello Player " + discordUserName + "\n\n" +
responseContent + "\n\n" +
RobotSpeak.getRobotSpeak() + "\n```").queue();
}
public static boolean isAdminEvent(MessageReceivedEvent event) {
String discordAccountID = event.getAuthor().getId();
List<DiscordAccount> discordAccounts;
DiscordAccount discordAccount;
// Note that database errors will cause this to return false.
// After the database is offline Avail status must be set
// to true before any subsequent admin commands will function.
if (Database.online == false)
return false;
discordAccounts = database.getDiscordAccounts(discordAccountID);
if (discordAccounts.isEmpty())
return false;
discordAccount = discordAccounts.get(0);
return (discordAccount.isDiscordAdmin == 1);
}
public void handleHelpRequest(MessageReceivedEvent event) {
// Help is kept here in the main class instead of a handler as a
@@ -322,85 +404,4 @@ public class MagicBot extends ListenerAdapter {
"#trash <blank>/detail/flush";
sendResponse(event, helpString);
}
public static String generatePassword(int length) {
String ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
StringBuilder passwordBuilder = new StringBuilder(length);
Random random = new Random();
// Generate alphanumeric password of a given length.
// Could not find a good method of generating a password
// based upon a given regex.
for (int i = 0; i < length; i++)
passwordBuilder.append(ALPHABET.charAt(random.nextInt(ALPHABET.length())));
return new String(passwordBuilder);
}
public static String readLogFile(String filePath, int lineCount) {
ProcessBuilder builder = new ProcessBuilder("/bin/bash", "-c", "tail -n " + lineCount + " " + filePath);
builder.redirectErrorStream(true);
Process process = null;
String line = null;
String logOutput = "";
try {
process = builder.start();
InputStream is = process.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
while ((line = reader.readLine()) != null) {
logOutput += line + "\n";
}
} catch (IOException e) {
Logger.error(e.toString());
return "Error while reading logfile";
}
return logOutput;
}
private static void junkbot(String command, String[] inString) {
String outString;
Writer fileWriter;
if (inString == null)
return;
;
outString = command + String.join(" ", inString);
outString += "\n";
try {
fileWriter = new BufferedWriter(new FileWriter("junkbot.txt", true));
fileWriter.append(outString);
fileWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private static void SendAdminLogUpdates() {
HashMap<Integer, String> adminEvents = database.getAdminEvents();
for (int adminEvent : adminEvents.keySet()) {
// Set event as read
database.setAdminEventAsRead(adminEvent);
String outString =
"```\n" + "Hello Players \n\n" +
adminEvents.get(adminEvent) + "\n\n" +
RobotSpeak.getRobotSpeak() + "\n```";
if (ADMINLOG.textChannel.canTalk())
ADMINLOG.textChannel.sendMessage(outString).queue();
}
}
}
+2 -1
View File
@@ -42,7 +42,8 @@ public class ChatChannelHandler {
"```\n" + "Hello Players \n\n" +
chatText.substring(3) + "\n\n" +
RobotSpeak.getRobotSpeak() + "\n```";
else outString = chatText;
else
outString = chatText;
// Write string to changelog channel
@@ -89,6 +89,7 @@ public class DevRequestHandler {
"Use #dev lastout to view results");
}
private static String getLastOutput() {
String outString = null;
@@ -64,7 +64,7 @@ public class LookupRequestHandler {
User discordUser = MagicBot.jda.getUserById(userAccount.discordAccount);
if (discordUser != null)
outString += discordUser.getName() + discordUser.getDiscriminator() +
outString += discordUser.getName() +
"/" + userAccount.discordAccount + " ";
else
outString += userAccount.discordAccount + " *N/A* ";
@@ -45,16 +45,16 @@ public class RegisterAccountHandler {
return;
}
// if user supplied argument let's validate it.
// otherwise build an account name based on their discord account.
// User must supply an account name
if (args.length != 1) {
// Build account name using Discord name along with their discriminator.
accountName = discordUserName.replaceAll("\\s+", "");
accountName += "#" + event.getAuthor().getDiscriminator();
} else {
MagicBot.sendResponse(event,
"Your supplied account name does not compute.\n" +
"Account names must satisfy following regex:\n" +
"^[\\p{Alnum}]{6,20}$");
return;
}
// Validate account name with regex
@@ -69,13 +69,12 @@ public class RegisterAccountHandler {
return;
}
if (accountName.toLowerCase().equals("accountname")) {
if (accountName.equalsIgnoreCase("accountname")) {
MagicBot.sendResponse(event,
"accountname is not valid account name.\n" +
"Have brain player!");
return;
}
}
// Make sure account doesn't already exist.
+158 -158
View File
@@ -206,88 +206,6 @@ public class HeightMap {
}
public Vector2f getGridSquare(Vector2f zoneLoc) {
if (zoneLoc.x < 0)
zoneLoc.setX(0);
if (zoneLoc.x > this.fullExtentsX - 1)
zoneLoc.setX((this.fullExtentsX - 1) + .9999999f);
if (zoneLoc.y < 0)
zoneLoc.setY(0);
if (zoneLoc.y > this.fullExtentsY - 1)
zoneLoc.setY((this.fullExtentsY - 1) + .9999999f);
float xBucket = (zoneLoc.x / this.bucketWidthX);
float yBucket = (zoneLoc.y / this.bucketWidthY);
return new Vector2f(xBucket, yBucket);
}
public float getInterpolatedTerrainHeight(Vector2f zoneLoc) {
Vector2f gridSquare;
if (zoneLoc.x < 0 || zoneLoc.x > this.fullExtentsX)
return -1;
if (zoneLoc.y < 0 || zoneLoc.y > this.fullExtentsY)
return -1;
int maxX = (int) (this.fullExtentsX / this.bucketWidthX);
int maxY = (int) (this.fullExtentsY / this.bucketWidthY);
//flip the Y so it grabs from the bottom left instead of top left.
//zoneLoc.setY(maxZoneHeight - zoneLoc.y);
gridSquare = getGridSquare(zoneLoc);
int gridX = (int) gridSquare.x;
int gridY = (int) (gridSquare.y);
if (gridX > maxX)
gridX = maxX;
if (gridY > maxY)
gridY = maxY;
float offsetX = (gridSquare.x - gridX);
float offsetY = gridSquare.y - gridY;
//get height of the 4 vertices.
float topLeftHeight = 0;
float topRightHeight = 0;
float bottomLeftHeight = 0;
float bottomRightHeight = 0;
int nextY = gridY +1;
int nextX = gridX + 1;
if (nextY > maxY)
nextY = gridY;
if (nextX > maxX)
nextX = gridX;
topLeftHeight = pixelColorValues[gridX][gridY];
topRightHeight = pixelColorValues[nextX][gridY];
bottomLeftHeight = pixelColorValues[gridX][nextY];
bottomRightHeight = pixelColorValues[nextX][nextY];
float interpolatedHeight;
interpolatedHeight = topRightHeight * (1 - offsetY) * (offsetX);
interpolatedHeight += (bottomRightHeight * offsetY * offsetX);
interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY);
interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY));
interpolatedHeight *= (float) this.maxHeight / 256; // Scale height
return interpolatedHeight;
}
public static Zone getNextZoneWithTerrain(Zone zone) {
Zone nextZone = zone;
@@ -505,48 +423,6 @@ public class HeightMap {
return realWorldAltitude;
}
public float getInterpolatedTerrainHeight(Vector3fImmutable zoneLoc3f) {
Vector2f zoneLoc = new Vector2f(zoneLoc3f.x, zoneLoc3f.z);
Vector2f gridSquare;
if (zoneLoc.x < 0 || zoneLoc.x > this.fullExtentsX)
return -1;
if (zoneLoc.y < 0 || zoneLoc.y > this.fullExtentsY)
return -1;
//flip the Y so it grabs from the bottom left instead of top left.
//zoneLoc.setY(maxZoneHeight - zoneLoc.y);
gridSquare = getGridSquare(zoneLoc);
int gridX = (int) gridSquare.x;
int gridY = (int) (gridSquare.y);
float offsetX = (gridSquare.x - gridX);
float offsetY = gridSquare.y - gridY;
//get height of the 4 vertices.
float topLeftHeight = pixelColorValues[gridX][gridY];
float topRightHeight = pixelColorValues[gridX + 1][gridY];
float bottomLeftHeight = pixelColorValues[gridX][gridY + 1];
float bottomRightHeight = pixelColorValues[gridX + 1][gridY + 1];
float interpolatedHeight;
interpolatedHeight = topRightHeight * (1 - offsetY) * (offsetX);
interpolatedHeight += (bottomRightHeight * offsetY * offsetX);
interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY);
interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY));
interpolatedHeight *= (float) this.maxHeight / 256; // Scale height
return interpolatedHeight;
}
public static float getOutsetHeight(float interpolatedAltitude, Zone zone, Vector3fImmutable worldLocation) {
Vector2f parentLoc;
@@ -620,24 +496,6 @@ public class HeightMap {
return outsetALt;
}
private void generatePixelData() {
Color color;
// Generate altitude lookup table for this heightmap
this.pixelColorValues = new int[this.heightmapImage.getWidth()][this.heightmapImage.getHeight()];
for (int y = 0; y < this.heightmapImage.getHeight(); y++) {
for (int x = 0; x < this.heightmapImage.getWidth(); x++) {
color = new Color(this.heightmapImage.getRGB(x, y));
pixelColorValues[x][y] = color.getRed();
}
}
}
public static Vector2f getGridOffset(Vector2f gridSquare) {
int floorX = (int) gridSquare.x;
@@ -647,11 +505,6 @@ public class HeightMap {
}
public float getScaledHeightForColor(float color) {
return (color / 256) * this.maxHeight;
}
public static void loadAlHeightMaps() {
// Load the heightmaps into staging hashmap keyed by HashMapID
@@ -672,6 +525,164 @@ public class HeightMap {
Logger.info(HeightMap.heightmapByLoadNum.size() + " Heightmaps cached.");
}
public static boolean isLocUnderwater(Vector3fImmutable currentLoc) {
float localAltitude = HeightMap.getWorldHeight(currentLoc);
Zone zone = ZoneManager.findSmallestZone(currentLoc);
if (localAltitude < zone.getSeaLevel())
return true;
return false;
}
public Vector2f getGridSquare(Vector2f zoneLoc) {
if (zoneLoc.x < 0)
zoneLoc.setX(0);
if (zoneLoc.x > this.fullExtentsX - 1)
zoneLoc.setX((this.fullExtentsX - 1) + .9999999f);
if (zoneLoc.y < 0)
zoneLoc.setY(0);
if (zoneLoc.y > this.fullExtentsY - 1)
zoneLoc.setY((this.fullExtentsY - 1) + .9999999f);
float xBucket = (zoneLoc.x / this.bucketWidthX);
float yBucket = (zoneLoc.y / this.bucketWidthY);
return new Vector2f(xBucket, yBucket);
}
public float getInterpolatedTerrainHeight(Vector2f zoneLoc) {
Vector2f gridSquare;
if (zoneLoc.x < 0 || zoneLoc.x > this.fullExtentsX)
return -1;
if (zoneLoc.y < 0 || zoneLoc.y > this.fullExtentsY)
return -1;
int maxX = (int) (this.fullExtentsX / this.bucketWidthX);
int maxY = (int) (this.fullExtentsY / this.bucketWidthY);
//flip the Y so it grabs from the bottom left instead of top left.
//zoneLoc.setY(maxZoneHeight - zoneLoc.y);
gridSquare = getGridSquare(zoneLoc);
int gridX = (int) gridSquare.x;
int gridY = (int) (gridSquare.y);
if (gridX > maxX)
gridX = maxX;
if (gridY > maxY)
gridY = maxY;
float offsetX = (gridSquare.x - gridX);
float offsetY = gridSquare.y - gridY;
//get height of the 4 vertices.
float topLeftHeight = 0;
float topRightHeight = 0;
float bottomLeftHeight = 0;
float bottomRightHeight = 0;
int nextY = gridY + 1;
int nextX = gridX + 1;
if (nextY > maxY)
nextY = gridY;
if (nextX > maxX)
nextX = gridX;
topLeftHeight = pixelColorValues[gridX][gridY];
topRightHeight = pixelColorValues[nextX][gridY];
bottomLeftHeight = pixelColorValues[gridX][nextY];
bottomRightHeight = pixelColorValues[nextX][nextY];
float interpolatedHeight;
interpolatedHeight = topRightHeight * (1 - offsetY) * (offsetX);
interpolatedHeight += (bottomRightHeight * offsetY * offsetX);
interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY);
interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY));
interpolatedHeight *= (float) this.maxHeight / 256; // Scale height
return interpolatedHeight;
}
public float getInterpolatedTerrainHeight(Vector3fImmutable zoneLoc3f) {
Vector2f zoneLoc = new Vector2f(zoneLoc3f.x, zoneLoc3f.z);
Vector2f gridSquare;
if (zoneLoc.x < 0 || zoneLoc.x > this.fullExtentsX)
return -1;
if (zoneLoc.y < 0 || zoneLoc.y > this.fullExtentsY)
return -1;
//flip the Y so it grabs from the bottom left instead of top left.
//zoneLoc.setY(maxZoneHeight - zoneLoc.y);
gridSquare = getGridSquare(zoneLoc);
int gridX = (int) gridSquare.x;
int gridY = (int) (gridSquare.y);
float offsetX = (gridSquare.x - gridX);
float offsetY = gridSquare.y - gridY;
//get height of the 4 vertices.
float topLeftHeight = pixelColorValues[gridX][gridY];
float topRightHeight = pixelColorValues[gridX + 1][gridY];
float bottomLeftHeight = pixelColorValues[gridX][gridY + 1];
float bottomRightHeight = pixelColorValues[gridX + 1][gridY + 1];
float interpolatedHeight;
interpolatedHeight = topRightHeight * (1 - offsetY) * (offsetX);
interpolatedHeight += (bottomRightHeight * offsetY * offsetX);
interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY);
interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY));
interpolatedHeight *= (float) this.maxHeight / 256; // Scale height
return interpolatedHeight;
}
private void generatePixelData() {
Color color;
// Generate altitude lookup table for this heightmap
this.pixelColorValues = new int[this.heightmapImage.getWidth()][this.heightmapImage.getHeight()];
for (int y = 0; y < this.heightmapImage.getHeight(); y++) {
for (int x = 0; x < this.heightmapImage.getWidth(); x++) {
color = new Color(this.heightmapImage.getRGB(x, y));
pixelColorValues[x][y] = color.getRed();
}
}
}
public float getScaledHeightForColor(float color) {
return (color / 256) * this.maxHeight;
}
public float getBucketWidthX() {
return bucketWidthX;
}
@@ -692,15 +703,4 @@ public class HeightMap {
return seaLevel;
}
public static boolean isLocUnderwater(Vector3fImmutable currentLoc) {
float localAltitude = HeightMap.getWorldHeight(currentLoc);
Zone zone = ZoneManager.findSmallestZone(currentLoc);
if (localAltitude < zone.getSeaLevel())
return true;
return false;
}
}
+121 -121
View File
@@ -38,14 +38,128 @@ public enum InterestManager implements Runnable {
private static long lastTime;
private static boolean keepGoing = true;
public void shutdown() {
this.keepGoing = false;
}
InterestManager() {
Logger.info(" Interest Management thread is running.");
}
public static void forceLoad(AbstractWorldObject awo) {
AbstractNetMsg msg = null;
LoadStructureMsg lsm;
LoadCharacterMsg lcm;
NPC npc;
Corpse corpse;
HashSet<AbstractWorldObject> toUpdate;
switch (awo.getObjectType()) {
case Building:
lsm = new LoadStructureMsg();
lsm.addObject((Building) awo);
msg = lsm;
break;
case Corpse:
corpse = (Corpse) awo;
lcm = new LoadCharacterMsg(corpse, false);
msg = lcm;
break;
case NPC:
npc = (NPC) awo;
lcm = new LoadCharacterMsg(npc, false);
msg = lcm;
break;
default:
return;
}
toUpdate = WorldGrid.getObjectsInRangePartial(awo.getLoc(), MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_PLAYER);
boolean send;
for (AbstractWorldObject tar : toUpdate) {
PlayerCharacter player = (PlayerCharacter) tar;
HashSet<AbstractWorldObject> loadedStaticObjects = player.getLoadedStaticObjects();
send = false;
if (!loadedStaticObjects.contains(awo)) {
loadedStaticObjects.add(awo);
send = true;
}
if (send) {
Dispatch dispatch = Dispatch.borrow(player, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
}
}
}
public static void HandleSpecialUnload(Building building, ClientConnection origin) {
if (Regions.FurnitureRegionMap.get(building.getObjectUUID()) == null)
return;
Regions buildingRegion = Regions.FurnitureRegionMap.get(building.getObjectUUID());
if (!buildingRegion.isOutside())
return;
MoveToPointMsg moveMsg = new MoveToPointMsg(building);
if (origin != null)
origin.sendMsg(moveMsg);
}
public static void reloadCharacter(AbstractCharacter absChar) {
UnloadObjectsMsg uom = new UnloadObjectsMsg();
uom.addObject(absChar);
LoadCharacterMsg lcm = new LoadCharacterMsg(absChar, false);
HashSet<AbstractWorldObject> toSend = WorldGrid.getObjectsInRangePartial(absChar.getLoc(), MBServerStatics.CHARACTER_LOAD_RANGE,
MBServerStatics.MASK_PLAYER);
PlayerCharacter pc = null;
if (absChar.getObjectType().equals(GameObjectType.PlayerCharacter))
pc = (PlayerCharacter) absChar;
for (AbstractWorldObject awo : toSend) {
PlayerCharacter pcc = (PlayerCharacter) awo;
if (pcc == null)
continue;
ClientConnection cc = SessionManager.getClientConnection(pcc);
if (cc == null)
continue;
if (pcc.getObjectUUID() == absChar.getObjectUUID())
continue;
else {
if (pc != null)
if (pcc.getSeeInvis() < pc.getHidden())
continue;
if (!cc.sendMsg(uom)) {
String classType = uom.getClass().getSimpleName();
Logger.error("Failed to send message ");
}
if (!cc.sendMsg(lcm)) {
String classType = lcm.getClass().getSimpleName();
Logger.error("Failed to send message");
}
}
}
}
public void shutdown() {
this.keepGoing = false;
}
@Override
public void run() {
beginLoadJob();
@@ -84,6 +198,9 @@ public enum InterestManager implements Runnable {
return dur;
}
// Forces the loading of static objects (corpses and buildings).
// Needed to override threshold limits on loading statics
private void updateAllPlayers() {
// get all players
@@ -385,76 +502,6 @@ public enum InterestManager implements Runnable {
//JobScheduler.getInstance().scheduleJob(new LoadEffectsJob(players, origin), MBServerStatics.LOAD_OBJECT_DELAY);
}
// Forces the loading of static objects (corpses and buildings).
// Needed to override threshold limits on loading statics
public static void forceLoad(AbstractWorldObject awo) {
AbstractNetMsg msg = null;
LoadStructureMsg lsm;
LoadCharacterMsg lcm;
NPC npc;
Corpse corpse;
HashSet<AbstractWorldObject> toUpdate;
switch (awo.getObjectType()) {
case Building:
lsm = new LoadStructureMsg();
lsm.addObject((Building) awo);
msg = lsm;
break;
case Corpse:
corpse = (Corpse) awo;
lcm = new LoadCharacterMsg(corpse, false);
msg = lcm;
break;
case NPC:
npc = (NPC) awo;
lcm = new LoadCharacterMsg(npc, false);
msg = lcm;
break;
default:
return;
}
toUpdate = WorldGrid.getObjectsInRangePartial(awo.getLoc(), MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_PLAYER);
boolean send;
for (AbstractWorldObject tar : toUpdate) {
PlayerCharacter player = (PlayerCharacter) tar;
HashSet<AbstractWorldObject> loadedStaticObjects = player.getLoadedStaticObjects();
send = false;
if (!loadedStaticObjects.contains(awo)) {
loadedStaticObjects.add(awo);
send = true;
}
if (send) {
Dispatch dispatch = Dispatch.borrow(player, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
}
}
}
public static void HandleSpecialUnload(Building building, ClientConnection origin) {
if (Regions.FurnitureRegionMap.get(building.getObjectUUID()) == null)
return;
Regions buildingRegion = Regions.FurnitureRegionMap.get(building.getObjectUUID());
if (!buildingRegion.isOutside())
return;
MoveToPointMsg moveMsg = new MoveToPointMsg(building);
if (origin != null)
origin.sendMsg(moveMsg);
}
public synchronized void HandleLoadForEnterWorld(PlayerCharacter player) {
if (player == null)
@@ -504,51 +551,4 @@ public enum InterestManager implements Runnable {
Logger.error("InterestManager.updateAllMobilePlayers: " + player.getObjectUUID(), e);
}
}
public static void reloadCharacter(AbstractCharacter absChar) {
UnloadObjectsMsg uom = new UnloadObjectsMsg();
uom.addObject(absChar);
LoadCharacterMsg lcm = new LoadCharacterMsg(absChar, false);
HashSet<AbstractWorldObject> toSend = WorldGrid.getObjectsInRangePartial(absChar.getLoc(), MBServerStatics.CHARACTER_LOAD_RANGE,
MBServerStatics.MASK_PLAYER);
PlayerCharacter pc = null;
if (absChar.getObjectType().equals(GameObjectType.PlayerCharacter))
pc = (PlayerCharacter) absChar;
for (AbstractWorldObject awo : toSend) {
PlayerCharacter pcc = (PlayerCharacter) awo;
if (pcc == null)
continue;
ClientConnection cc = SessionManager.getClientConnection(pcc);
if (cc == null)
continue;
if (pcc.getObjectUUID() == absChar.getObjectUUID())
continue;
else {
if (pc != null)
if (pcc.getSeeInvis() < pc.getHidden())
continue;
if (!cc.sendMsg(uom)) {
String classType = uom.getClass().getSimpleName();
Logger.error("Failed to send message ");
}
if (!cc.sendMsg(lcm)) {
String classType = lcm.getClass().getSimpleName();
Logger.error("Failed to send message");
}
}
}
}
}
+1 -1
View File
@@ -36,8 +36,8 @@ public enum RealmMap {
// Spatial hashmap. Used for determining which Realm
// a player is currently located within.
public static int[][] _realmImageMap;
private static final HashMap<Color, Integer> _rgbToIDMap = new HashMap<>();
public static int[][] _realmImageMap;
public static int getRealmIDByColor(Color color) {
+1 -1
View File
@@ -30,6 +30,7 @@ public class WorldGrid {
public static ConcurrentHashMap<Integer, AbstractWorldObject>[][] StaticGridMap;
private static float dynamicBucketScale = 0.00390625f; // 256 bucket size, 1/256
private static float staticBucketScale = 0.00390625f;
public static void startLoadJob() {
Thread loadJobThread;
@@ -66,7 +67,6 @@ public class WorldGrid {
int startingZ = gridZ + bucketSize;
int limitX = Math.abs((int) (MBServerStatics.MAX_WORLD_WIDTH * scale));
int limitZ = Math.abs((int) (MBServerStatics.MAX_WORLD_HEIGHT * scale)); //LimitZ is negative, remember to flip sign.
+32 -10
View File
@@ -6,6 +6,7 @@
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.ai;
import engine.Enum;
import engine.Enum.DispatchChannel;
import engine.InterestManagement.WorldGrid;
@@ -22,12 +23,15 @@ import engine.objects.*;
import engine.powers.ActionsBase;
import engine.powers.PowersBase;
import engine.server.MBServerStatics;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom;
import static engine.math.FastMath.sqr;
public class MobileFSM {
private static void AttackTarget(Mob mob, AbstractWorldObject target) {
if (mob == null)
@@ -58,6 +62,7 @@ public class MobileFSM {
break;
}
}
public static void AttackPlayer(Mob mob, PlayerCharacter target) {
if (!mob.canSee(target)) {
mob.setCombatTarget(null);
@@ -100,6 +105,7 @@ public class MobileFSM {
}
}
}
public static void AttackBuilding(Mob mob, Building target) {
if (target.getRank() == -1 || !target.isVulnerable() || BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) {
mob.setCombatTarget(null);
@@ -140,6 +146,7 @@ public class MobileFSM {
DispatchMessage.dispatchMsgToInterestArea(mob, ppm, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
}
}
public static void AttackMob(Mob mob, Mob target) {
if (mob.getRange() >= 30 && mob.isMoving())
return;
@@ -166,6 +173,7 @@ public class MobileFSM {
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
}
}
private static void Patrol(Mob mob) {
//make sure mob is out of combat stance
if (mob.isCombat() && mob.getCombatTarget() == null) {
@@ -214,6 +222,7 @@ public class MobileFSM {
}
}
}
public static boolean canCast(Mob mob) {
// Performs validation to determine if a
// mobile in the proper state to cast.
@@ -225,14 +234,11 @@ public class MobileFSM {
mob.setCombatTarget(null);
return false;
}
int castRoll = ThreadLocalRandom.current().nextInt(101);
if(castRoll <= MobileFSMManager.AI_POWER_DIVISOR){
return false;
}
if (mob.nextCastTime == 0)
mob.nextCastTime = System.currentTimeMillis();
return mob.nextCastTime <= System.currentTimeMillis();
}
public static boolean MobCast(Mob mob) {
// Method picks a random spell from a mobile's list of powers
// and casts it on the current target (or itself). Validation
@@ -290,12 +296,12 @@ public class MobileFSM {
msg.setUnknown04(2);
PowersManager.finishUseMobPower(msg, mob, 0, 0);
// Default minimum seconds between cast = 10
float randomCooldown = (ThreadLocalRandom.current().nextInt(150) + 100) * 0.01f;
mob.nextCastTime = System.currentTimeMillis() + (long)((mobPower.getCooldown() + (MobileFSMManager.AI_POWER_DIVISOR * 1000)) * randomCooldown);
mob.nextCastTime = System.currentTimeMillis() + mobPower.getCooldown() + (MobileFSMManager.AI_POWER_DIVISOR * 1000);
return true;
}
return false;
}
public static void MobCallForHelp(Mob mob) {
boolean callGotResponse = false;
if (mob.nextCallForHelp == 0) {
@@ -316,6 +322,7 @@ public class MobileFSM {
//wait 60 seconds to call for help again
mob.nextCallForHelp = System.currentTimeMillis() + 60000;
}
public static void DetermineAction(Mob mob) {
if (mob == null)
return;
@@ -380,6 +387,7 @@ public class MobileFSM {
break;
}
}
private static void CheckForAggro(Mob aiAgent) {
//looks for and sets mobs combatTarget
if (!aiAgent.isAlive())
@@ -410,6 +418,7 @@ public class MobileFSM {
}
}
}
private static void CheckMobMovement(Mob mob) {
if (!MovementUtilities.canMove(mob))
return;
@@ -451,6 +460,7 @@ public class MobileFSM {
break;
}
}
private static void CheckForRespawn(Mob aiAgent) {
if (aiAgent.deathTime == 0) {
aiAgent.setDeathTime(System.currentTimeMillis());
@@ -484,6 +494,7 @@ public class MobileFSM {
aiAgent.respawn();
}
}
public static void CheckForAttack(Mob mob) {
//checks if mob can attack based on attack timer and range
if (mob.isAlive() == false)
@@ -510,10 +521,10 @@ public class MobileFSM {
if (System.currentTimeMillis() > mob.getLastAttackTime())
AttackTarget(mob, mob.getCombatTarget());
}
private static void CheckToSendMobHome(Mob mob) {
if (mob.BehaviourType.isAgressive) {
if(mob.isPlayerGuard())
{
if (mob.isPlayerGuard()) {
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) {
CheckForPlayerGuardAggro(mob);
}
@@ -538,8 +549,7 @@ public class MobileFSM {
}
}
}
}
else if(MovementUtilities.inRangeOfBindLocation(mob) == false) {
} else if (MovementUtilities.inRangeOfBindLocation(mob) == false) {
PowersBase recall = PowersManager.getPowerByToken(-1994153779);
PowersManager.useMobPower(mob, mob, recall, 40);
@@ -549,6 +559,7 @@ public class MobileFSM {
}
}
}
private static void chaseTarget(Mob mob) {
mob.updateMovementState();
if (mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false) {
@@ -565,6 +576,7 @@ public class MobileFSM {
}
}
}
private static void SafeGuardAggro(Mob mob) {
HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(mob, 100, MBServerStatics.MASK_MOB);
for (AbstractWorldObject awoMob : awoList) {
@@ -580,12 +592,14 @@ public class MobileFSM {
mob.setCombatTarget(aggroMob);
}
}
public static void GuardCaptainLogic(Mob mob) {
if (mob.getCombatTarget() == null)
CheckForPlayerGuardAggro(mob);
CheckMobMovement(mob);
CheckForAttack(mob);
}
public static void GuardMinionLogic(Mob mob) {
if (!mob.npcOwner.isAlive() && mob.getCombatTarget() == null) {
CheckForPlayerGuardAggro(mob);
@@ -597,12 +611,14 @@ public class MobileFSM {
CheckMobMovement(mob);
CheckForAttack(mob);
}
public static void GuardWallArcherLogic(Mob mob) {
if (mob.getCombatTarget() == null)
CheckForPlayerGuardAggro(mob);
else
CheckForAttack(mob);
}
private static void PetLogic(Mob mob) {
if (mob.getCombatTarget() != null && !mob.getCombatTarget().isAlive())
mob.setCombatTarget(null);
@@ -610,6 +626,7 @@ public class MobileFSM {
CheckMobMovement(mob);
CheckForAttack(mob);
}
private static void HamletGuardLogic(Mob mob) {
if (mob.getCombatTarget() == null) {
//safehold guard
@@ -621,6 +638,7 @@ public class MobileFSM {
}
CheckForAttack(mob);
}
private static void DefaultLogic(Mob mob) {
if (mob.getObjectUUID() == 40548) {
int thing = 0;
@@ -648,6 +666,7 @@ public class MobileFSM {
if (!mob.BehaviourType.isWimpy && !mob.isMoving() && mob.combatTarget != null)
CheckForAttack(mob);
}
public static void CheckForPlayerGuardAggro(Mob mob) {
//looks for and sets mobs combatTarget
if (!mob.isAlive())
@@ -678,6 +697,7 @@ public class MobileFSM {
}
}
}
public static Boolean GuardCanAggro(Mob mob, PlayerCharacter target) {
if (mob.getGuild().getNation().equals(target.getGuild().getNation()))
return false;
@@ -718,6 +738,7 @@ public class MobileFSM {
}
return false;
}
public static void randomGuardPatrolPoint(Mob mob) {
if (mob.isMoving() == true) {
//early exit for a mob who is already moving to a patrol point
@@ -755,6 +776,7 @@ public class MobileFSM {
}
}
}
public static AbstractWorldObject ChangeTargetFromHateValue(Mob mob) {
float CurrentHateValue = 0;
if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
+4 -3
View File
@@ -25,16 +25,17 @@ public class MobileFSMManager {
private static final MobileFSMManager INSTANCE = new MobileFSMManager();
public static Duration executionTime = Duration.ofNanos(1);
public static Duration executionMax = Duration.ofNanos(1);
private volatile boolean alive;
private long timeOfKill = -1;
//AI variables moved form mb_server_statics
public static int AI_BASE_AGGRO_RANGE = 60;
public static int AI_DROP_AGGRO_RANGE = 60;
public static int AI_RECALL_RANGE = 400;
public static int AI_PULSE_MOB_THRESHOLD = 200;
public static int AI_THREAD_SLEEP = 1000;
public static int AI_PATROL_DIVISOR = 15;
public static int AI_POWER_DIVISOR = 20;
public static float AI_MAX_ANGLE = 10f;
private volatile boolean alive;
private long timeOfKill = -1;
private MobileFSMManager() {
+23 -24
View File
@@ -17,10 +17,16 @@ import java.util.ArrayList;
*
*/
public abstract class ControlledRunnable implements Runnable {
// Runnable tracking
private static final ArrayList<ControlledRunnable> runnables = new ArrayList<>();
private final String threadName;
protected boolean runCmd = false;
protected boolean runStatus = false;
private Thread thisThread;
private final String threadName;
/*
* Main loop
*/
public ControlledRunnable(String threadName) {
super();
@@ -28,9 +34,14 @@ public abstract class ControlledRunnable implements Runnable {
ControlledRunnable.runnables.add(this);
}
/*
* Main loop
*/
public static void shutdownAllRunnables() {
for (ControlledRunnable cr : ControlledRunnable.runnables) {
//Use Direct logging since JobManager is a runnable.
Logger.info("ControlledRunnable",
"Sending Shutdown cmd to: " + cr.threadName);
cr.shutdown();
}
}
/**
* This is the method called when ControlledRunnable.thisThread.start() is
@@ -62,6 +73,10 @@ public abstract class ControlledRunnable implements Runnable {
*/
protected abstract boolean _preRun();
/*
* Control
*/
/**
* _Run() is called after _startup() and contains should contain the main
* loop.
@@ -78,10 +93,6 @@ public abstract class ControlledRunnable implements Runnable {
*/
protected abstract boolean _postRun();
/*
* Control
*/
/**
* startup() initializes the internal thread, sets the runCMD to true, and
* calls _startup() prior to starting of the internal Thread.
@@ -141,6 +152,10 @@ public abstract class ControlledRunnable implements Runnable {
}
}
/*
* Instance monitoring and tools
*/
/**
* @return the thisThread
*/
@@ -155,20 +170,4 @@ public abstract class ControlledRunnable implements Runnable {
return threadName;
}
/*
* Instance monitoring and tools
*/
// Runnable tracking
private static final ArrayList<ControlledRunnable> runnables = new ArrayList<>();
public static void shutdownAllRunnables() {
for (ControlledRunnable cr : ControlledRunnable.runnables) {
//Use Direct logging since JobManager is a runnable.
Logger.info("ControlledRunnable",
"Sending Shutdown cmd to: " + cr.threadName);
cr.shutdown();
}
}
}
+2 -4
View File
@@ -50,8 +50,7 @@ public class BaneRecord extends DataRecord {
if (baneRecord == null) {
baneRecord = new BaneRecord(bane);
baneRecord.eventType = eventType;
}
else {
} else {
baneRecord.recordType = Enum.DataRecordType.BANE;
baneRecord.eventType = eventType;
@@ -67,8 +66,7 @@ public class BaneRecord extends DataRecord {
baneRecord.baneDropperHash = "ERRANT";
baneRecord.baneGuildHash = "ERRANT";
baneRecord.baneNationHash = "ERRANT";
}
else {
} else {
baneRecord.baneDropperHash = DataWarehouse.hasher.encrypt(bane.getOwner().getObjectUUID()); // getPlayerCharacter didn't check hash first? OMFG
+1 -2
View File
@@ -44,8 +44,7 @@ public class CharacterRecord extends DataRecord {
if (characterRecord == null) {
characterRecord = new CharacterRecord(player);
}
else {
} else {
characterRecord.recordType = Enum.DataRecordType.CHARACTER;
characterRecord.player = player;
+1 -2
View File
@@ -46,8 +46,7 @@ public class CityRecord extends DataRecord {
if (cityRecord == null) {
cityRecord = new CityRecord(city);
cityRecord.eventType = eventType;
}
else {
} else {
cityRecord.recordType = Enum.DataRecordType.CITY;
cityRecord.eventType = eventType;
cityRecord.city = city;
-1
View File
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.db.archive;
import engine.Enum;
+18 -18
View File
@@ -188,6 +188,24 @@ public class DataWarehouse implements Runnable {
return false;
}
private static void configureRemoteConnectionPool() {
HikariConfig config = new HikariConfig();
config.setMaximumPoolSize(1); // Only the server talks to remote, so yeah.
config.setJdbcUrl(ConfigManager.MB_WAREHOUSE_ADDR.getValue());
config.setUsername(ConfigManager.MB_WAREHOUSE_USER.getValue());
config.setPassword(ConfigManager.MB_WAREHOUSE_PASS.getValue());
config.addDataSourceProperty("characterEncoding", "utf8");
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
remoteConnectionPool = new HikariDataSource(config); // setup the connection pool
Logger.info("remote warehouse connection configured");
}
public void run() {
// Working variable set
@@ -269,22 +287,4 @@ public class DataWarehouse implements Runnable {
}
}
private static void configureRemoteConnectionPool() {
HikariConfig config = new HikariConfig();
config.setMaximumPoolSize(1); // Only the server talks to remote, so yeah.
config.setJdbcUrl(ConfigManager.MB_WAREHOUSE_ADDR.getValue());
config.setUsername(ConfigManager.MB_WAREHOUSE_USER.getValue());
config.setPassword(ConfigManager.MB_WAREHOUSE_PASS.getValue());
config.addDataSourceProperty("characterEncoding", "utf8");
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
remoteConnectionPool = new HikariDataSource(config); // setup the connection pool
Logger.info("remote warehouse connection configured");
}
}
+4 -9
View File
@@ -27,9 +27,11 @@ import java.util.concurrent.LinkedBlockingQueue;
public class GuildRecord extends DataRecord {
private static final LinkedBlockingQueue<GuildRecord> recordPool = new LinkedBlockingQueue<>();
public static HashMap<Integer, GuildRecord> GuildRecordCache = null;
public String guildHash;
public int guildID;
private Enum.RecordEventType eventType;
private Guild guild;
public String guildHash;
private String guildName;
private String charterName;
private String GLHash;
@@ -39,12 +41,8 @@ public class GuildRecord extends DataRecord {
private int bgColour2;
private int fgIcon;
private int fgColour;
public int guildID;
private java.time.LocalDateTime eventDatetime;
public static HashMap<Integer, GuildRecord> GuildRecordCache = null;
private GuildRecord(Guild guild) {
this.recordType = Enum.DataRecordType.GUILD;
this.guild = guild;
@@ -52,7 +50,6 @@ public class GuildRecord extends DataRecord {
}
public GuildRecord(ResultSet rs) throws SQLException {
super();
this.eventType = RecordEventType.valueOf(rs.getString("eventType"));
@@ -74,7 +71,6 @@ public class GuildRecord extends DataRecord {
}
public static GuildRecord borrow(Guild guild, Enum.RecordEventType eventType) {
GuildRecord guildRecord;
//add
@@ -83,8 +79,7 @@ public class GuildRecord extends DataRecord {
if (guildRecord == null) {
guildRecord = new GuildRecord(guild);
guildRecord.eventType = eventType;
}
else {
} else {
guildRecord.guild = guild;
guildRecord.recordType = Enum.DataRecordType.GUILD;
guildRecord.eventType = eventType;
+2 -4
View File
@@ -47,8 +47,7 @@ public class MineRecord extends DataRecord {
if (mineRecord == null) {
mineRecord = new MineRecord();
mineRecord.eventType = eventType;
}
else {
} else {
mineRecord.recordType = Enum.DataRecordType.MINE;
mineRecord.eventType = eventType;
}
@@ -58,8 +57,7 @@ public class MineRecord extends DataRecord {
if (character.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
player = (PlayerCharacter) character;
mineRecord.charHash = player.getHash();
}
else
} else
mineRecord.charHash = character.getName();
DataWarehouse.hasher.encrypt(0);
+1 -2
View File
@@ -51,8 +51,7 @@ public class PvpRecord extends DataRecord {
if (pvpRecord == null) {
pvpRecord = new PvpRecord(player, victim, location, pvpExp);
}
else {
} else {
pvpRecord.recordType = DataRecordType.PVP;
pvpRecord.player = player;
pvpRecord.victim = victim;
+1 -2
View File
@@ -44,8 +44,7 @@ public class RealmRecord extends DataRecord {
if (realmRecord == null) {
realmRecord = new RealmRecord(realm);
realmRecord.eventType = eventType;
}
else {
} else {
realmRecord.recordType = Enum.DataRecordType.REALM;
realmRecord.eventType = eventType;
realmRecord.realm = realm;
+60 -60
View File
@@ -29,6 +29,60 @@ public abstract class AbstractDevCmd {
this.rsult = "";
}
/*
* Misc tools/helpers
*/
protected static Building getTargetAsBuilding(PlayerCharacter pc) {
int targetType = pc.getLastTargetType().ordinal();
int targetID = pc.getLastTargetID();
if (targetType == GameObjectType.Building.ordinal()) {
Building b = (Building) DbManager
.getFromCache(GameObjectType.Building, targetID);
if (b == null) {
ChatManager.chatSystemError(
pc,
"Command Failed. Could not find building of ID "
+ targetID);
return null;
}
return b;
} else {
return null;
}
}
protected static Mob getTargetAsMob(PlayerCharacter pc) {
int targetType = pc.getLastTargetType().ordinal();
int targetID = pc.getLastTargetID();
if (targetType == GameObjectType.Mob.ordinal()) {
Mob b = Mob.getMob(targetID);
if (b == null) {
ChatManager.chatSystemError(pc,
"Command Failed. Could not find Mob of ID " + targetID);
return null;
}
return b;
} else {
return null;
}
}
protected static NPC getTargetAsNPC(PlayerCharacter pc) {
int targetType = pc.getLastTargetType().ordinal();
int targetID = pc.getLastTargetID();
if (targetType == GameObjectType.NPC.ordinal()) {
NPC b = NPC.getFromCache(targetID);
if (b == null) {
ChatManager.chatSystemError(pc,
"Command Failed. Could not find NPC of ID " + targetID);
return null;
}
return b;
} else {
return null;
}
}
/**
* This function is called by the DevCmdManager. Method splits argString
* into a String array and then calls the subclass specific _doCmd method.
@@ -89,22 +143,22 @@ public abstract class AbstractDevCmd {
this.cmdStrings.add(lowercase);
}
public void setTarget(AbstractGameObject ago) {
this.tr = ago;
}
public AbstractGameObject getTarget() {
return this.tr;
}
public void setResult(String result) {
this.rsult = result;
public void setTarget(AbstractGameObject ago) {
this.tr = ago;
}
public String getResult() {
return this.rsult;
}
public void setResult(String result) {
this.rsult = result;
}
/*
* Helper functions
*/
@@ -124,58 +178,4 @@ public abstract class AbstractDevCmd {
ChatManager.chatSystemInfo(pc, msgText);
}
/*
* Misc tools/helpers
*/
protected static Building getTargetAsBuilding(PlayerCharacter pc) {
int targetType = pc.getLastTargetType().ordinal();
int targetID = pc.getLastTargetID();
if (targetType == GameObjectType.Building.ordinal()) {
Building b = (Building) DbManager
.getFromCache(GameObjectType.Building, targetID);
if (b == null) {
ChatManager.chatSystemError(
pc,
"Command Failed. Could not find building of ID "
+ targetID);
return null;
}
return b;
} else {
return null;
}
}
protected static Mob getTargetAsMob(PlayerCharacter pc) {
int targetType = pc.getLastTargetType().ordinal();
int targetID = pc.getLastTargetID();
if (targetType == GameObjectType.Mob.ordinal()) {
Mob b = Mob.getMob(targetID);
if (b == null) {
ChatManager.chatSystemError(pc,
"Command Failed. Could not find Mob of ID " + targetID);
return null;
}
return b;
} else {
return null;
}
}
protected static NPC getTargetAsNPC(PlayerCharacter pc) {
int targetType = pc.getLastTargetType().ordinal();
int targetID = pc.getLastTargetID();
if (targetType == GameObjectType.NPC.ordinal()) {
NPC b = NPC.getFromCache(targetID);
if (b == null) {
ChatManager.chatSystemError(pc,
"Command Failed. Could not find NPC of ID " + targetID);
return null;
}
return b;
} else {
return null;
}
}
}
-1
View File
@@ -17,7 +17,6 @@ import engine.objects.PlayerCharacter;
/**
* @author Eighty
*
*/
public class AddGoldCmd extends AbstractDevCmd {
-1
View File
@@ -20,7 +20,6 @@ import org.pmw.tinylog.Logger;
/**
* @author Eighty
*
*/
public class AddMobCmd extends AbstractDevCmd {
-1
View File
@@ -18,7 +18,6 @@ import org.pmw.tinylog.Logger;
/**
* @author Eighty
*
*/
public class AddNPCCmd extends AbstractDevCmd {
@@ -124,8 +124,6 @@ public class ApplyBonusCmd extends AbstractDevCmd {
break;
}
}
+2 -7
View File
@@ -21,18 +21,16 @@ import engine.powers.PowersBase;
import java.util.ArrayList;
/**
*
* @author Eighty
*
*/
public class ApplyStatModCmd extends AbstractDevCmd {
private static int cnt = 0;
public ApplyStatModCmd() {
super("applystatmod");
}
private static int cnt = 0;
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] args,
AbstractGameObject target) {
@@ -72,9 +70,6 @@ public class ApplyStatModCmd extends AbstractDevCmd {
pbList.add(PowersManager.getPowerByToken(431081336));
for (PowersBase pb : pbList) {
if (amount <= 0) {
if (pb.getToken() == 428677994)
@@ -29,7 +29,6 @@ public class AuditFailedItemsCmd extends AbstractDevCmd {
AbstractGameObject target) {
if (ItemProductionManager.FailedItems.isEmpty())
return;
@@ -103,8 +102,6 @@ public class AuditFailedItemsCmd extends AbstractDevCmd {
}
auditFailedItem += newLine;
auditFailedItem += itemName + " | " + prefix + " | " + suffix + " | " + failedItem.getNpcUID() + ":" + npcName + " | " + contractName + " | " + failedItem.getPlayerID() + ":" + playerName;
@@ -36,7 +36,6 @@ public class AuditHeightMapCmd extends AbstractDevCmd {
Zone currentZone = ZoneManager.findSmallestZone(pcSender.getLoc());
Vector3fImmutable currentLoc = Vector3fImmutable.getRandomPointInCircle(currentZone.getLoc(), currentZone.getBounds().getHalfExtents().x < currentZone.getBounds().getHalfExtents().y ? currentZone.getBounds().getHalfExtents().x : currentZone.getBounds().getHalfExtents().y);
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(currentLoc, currentZone);
+2 -3
View File
@@ -24,7 +24,8 @@ public class AuditMobsCmd extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) {
if (pcSender == null) return;
if (pcSender == null)
return;
//get Zone to check mobs against
@@ -83,12 +84,10 @@ public class AuditMobsCmd extends AbstractDevCmd {
throwbackInfo(pcSender, "UUID, dbID, inRespawnMap, isAlive, activeAI, Loc");
//mob not found in spawn map, check respawn
boolean inRespawn = false;
}
@@ -7,9 +7,6 @@
// www.magicbane.com
// ·. · · · · .
// · ·
// · ·
@@ -27,9 +24,7 @@ import engine.objects.AbstractGameObject;
import engine.objects.PlayerCharacter;
/**
*
* @author Eighty
*
*/
public class CombatMessageCmd extends AbstractDevCmd {
@@ -17,7 +17,6 @@ import engine.objects.PlayerCharacter;
/**
* @author Eighty
*
*/
public class CreateItemCmd extends AbstractDevCmd {
+8 -9
View File
@@ -17,12 +17,19 @@ import engine.objects.PlayerCharacter;
public class DebugCmd extends AbstractDevCmd {
public DebugCmd() {
super("debug");
// super("debug", MBServerStatics.ACCESS_GROUP_ALL_TEAM, 0, false, false);
}
private static void toggleDebugTimer(PlayerCharacter pc, String name, int num, int duration, boolean toggle) {
if (toggle) {
DebugTimerJob dtj = new DebugTimerJob(pc, name, num, duration);
pc.renewTimer(name, dtj, duration);
} else
pc.cancelTimer(name);
}
@Override
protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) {
@@ -112,12 +119,4 @@ public class DebugCmd extends AbstractDevCmd {
protected String _getUsageString() {
return "'./Debug command on/off'";
}
private static void toggleDebugTimer(PlayerCharacter pc, String name, int num, int duration, boolean toggle) {
if (toggle) {
DebugTimerJob dtj = new DebugTimerJob(pc, name, num, duration);
pc.renewTimer(name, dtj, duration);
} else
pc.cancelTimer(name);
}
}
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd;
-7
View File
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
@@ -27,17 +26,11 @@ public class DespawnCmd extends AbstractDevCmd {
AbstractGameObject target) {
if (pc == null) {
return;
}
Mob mob = null;
if (target != null && target.getObjectType().equals(GameObjectType.Mob))
-3
View File
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd;
@@ -27,8 +26,6 @@ public class DistanceCmd extends AbstractDevCmd {
AbstractGameObject target) {
// Arg Count Check
if (words.length != 1) {
this.sendUsage(pc);
-2
View File
@@ -17,9 +17,7 @@ import engine.objects.PlayerCharacter;
import engine.powers.EffectsBase;
/**
*
* @author Eighty
*
*/
public class EffectCmd extends AbstractDevCmd {
-1
View File
@@ -35,7 +35,6 @@ public class EnchantCmd extends AbstractDevCmd {
}
Item item;
if (target == null || target instanceof Item)
item = (Item) target;
-3
View File
@@ -15,9 +15,7 @@ import engine.objects.AbstractGameObject;
import engine.objects.PlayerCharacter;
/**
*
* @author Eighty
*
*/
public class FlashMsgCmd extends AbstractDevCmd {
@@ -39,7 +37,6 @@ public class FlashMsgCmd extends AbstractDevCmd {
* This function is called by the DevCmdManager. Override to avoid splitting
* argString into String array, since flash displays full String as message,
* then calls the subclass specific _doCmd method.
*
*/
@Override
-1
View File
@@ -81,5 +81,4 @@ public class GateInfoCmd extends AbstractDevCmd {
}
}
+4 -4
View File
@@ -17,9 +17,7 @@ import engine.objects.AbstractGameObject;
import engine.objects.PlayerCharacter;
/**
*
* @author Eighty
*
*/
public class GetBankCmd extends AbstractDevCmd {
@@ -30,10 +28,12 @@ public class GetBankCmd extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] args,
AbstractGameObject target) {
if (pcSender == null) return;
if (pcSender == null)
return;
ClientConnection cc = SessionManager.getClientConnection(pcSender);
if (cc == null) return;
if (cc == null)
return;
VendorDialogMsg.getBank(pcSender, null, cc);
this.setTarget(pcSender); //for logging
+2 -9
View File
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.InterestManagement.HeightMap;
@@ -88,8 +87,6 @@ public class GetHeightCmd extends AbstractDevCmd {
this.throwbackInfo(pc, "SeaFloor Local : " + seaFloorLocalLoc.x + " , " + seaFloorLocalLoc.y);
this.throwbackInfo(pc, "Local Zone Location : " + zoneLoc.x + " , " + zoneLoc.y);
Vector3fImmutable localLocFromCenter = ZoneManager.worldToLocal(pc.getLoc(), currentZone);
Vector3fImmutable parentLocFromCenter = ZoneManager.worldToLocal(pc.getLoc(), currentZone.getParent());
@@ -102,7 +99,8 @@ public class GetHeightCmd extends AbstractDevCmd {
if ((parentZone != null) && (parentZone.getHeightMap() != null)) {
parentLoc = ZoneManager.worldToZoneSpace(pc.getLoc(), parentZone);
parentGrid = parentZone.getHeightMap().getGridSquare(parentLoc);
} else parentGrid = new Vector2f(-1,-1);
} else
parentGrid = new Vector2f(-1, -1);
gridSquare = heightMap.getGridSquare(zoneLoc);
gridOffset = HeightMap.getGridOffset(gridSquare);
@@ -184,8 +182,6 @@ public class GetHeightCmd extends AbstractDevCmd {
realWorldAltitude = outsetALt;
}
}
@@ -210,14 +206,11 @@ public class GetHeightCmd extends AbstractDevCmd {
strMod -= .5f;
realWorldAltitude += strMod;
this.throwbackInfo(pc, "interpolated height with World: " + realWorldAltitude);
}
@Override
+14 -13
View File
@@ -19,19 +19,6 @@ public class GetMemoryCmd extends AbstractDevCmd {
super("getmemory");
}
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) {
if (pcSender == null) return;
String hSize = getMemoryOutput(Runtime.getRuntime().totalMemory());
String mhSize = getMemoryOutput(Runtime.getRuntime().maxMemory());
String fhSize = getMemoryOutput(Runtime.getRuntime().freeMemory());
String out = "Heap Size: " + hSize + ", Max Heap Size: " + mhSize + ", Free Heap Size: " + fhSize;
throwbackInfo(pcSender, out);
}
public static String getMemoryOutput(long memory) {
String out = "";
if (memory > 1073741824)
@@ -44,6 +31,20 @@ public class GetMemoryCmd extends AbstractDevCmd {
return memory + "B";
}
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) {
if (pcSender == null)
return;
String hSize = getMemoryOutput(Runtime.getRuntime().totalMemory());
String mhSize = getMemoryOutput(Runtime.getRuntime().maxMemory());
String fhSize = getMemoryOutput(Runtime.getRuntime().freeMemory());
String out = "Heap Size: " + hSize + ", Max Heap Size: " + mhSize + ", Free Heap Size: " + fhSize;
throwbackInfo(pcSender, out);
}
@Override
protected String _getUsageString() {
return "' /getmemory'";
@@ -18,7 +18,6 @@ import engine.objects.PlayerCharacter;
/**
* @author Eighty
*
*/
public class GetMobBaseLoot extends AbstractDevCmd {
+2 -1
View File
@@ -24,7 +24,8 @@ public class GetOffsetCmd extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) {
if (pcSender == null) return;
if (pcSender == null)
return;
Zone zone = null;
try {
@@ -23,7 +23,8 @@ public class GetRuneDropRateCmd extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) {
if (pcSender == null) return;
if (pcSender == null)
return;
String out = "Depracated";
throwbackInfo(pcSender, out);
+4 -2
View File
@@ -25,10 +25,12 @@ public class GetVaultCmd extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] args,
AbstractGameObject target) {
if (pcSender == null) return;
if (pcSender == null)
return;
ClientConnection cc = SessionManager.getClientConnection(pcSender);
if (cc == null) return;
if (cc == null)
return;
VendorDialogMsg.getVault(pcSender, null, cc);
this.setTarget(pcSender); //for logging
+2 -1
View File
@@ -26,7 +26,8 @@ public class GetZoneCmd extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) {
if (pcSender == null) return;
if (pcSender == null)
return;
if (words.length != 1) {
this.sendUsage(pcSender);
+4 -2
View File
@@ -25,13 +25,15 @@ public class GetZoneMobsCmd extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) {
if (pcSender == null) return;
if (pcSender == null)
return;
int loadID = 0;
if (words.length == 1) {
try {
loadID = Integer.parseInt(words[0]);
} catch (Exception e) {}
} catch (Exception e) {
}
}
//find the zone
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
-1
View File
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
-1
View File
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum;
-1
View File
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.ai.MobileFSMManager;
+1 -1
View File
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd;
@@ -63,6 +62,7 @@ public class HotzoneCmd extends AbstractDevCmd {
return;
}
@Override
protected String _getHelpString() {
return "Use no arguments to see the current hotzone or \"random\" to change it randomly.";
+3 -4
View File
@@ -26,7 +26,6 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* @author
*
*/
public class InfoCmd extends AbstractDevCmd {
@@ -426,8 +425,7 @@ public class InfoCmd extends AbstractDevCmd {
output += newline;
output += "enemy: " + targetMob.enemy.toString();
output += newline;
}
catch(Exception ex){
} catch (Exception ex) {
//who cares its info
}
output += "Spawn: (" + targetMob.getBindLoc().getX();
@@ -439,7 +437,8 @@ public class InfoCmd extends AbstractDevCmd {
output += newline;
if (targetMob.isSummonedPet())
output += "isSummonedPet: true";
else output += "isSummonedPet: false";
else
output += "isSummonedPet: false";
PlayerCharacter owner = targetMob.getOwner();
if (owner != null)
output += " owner: " + owner.getObjectUUID();
-2
View File
@@ -16,9 +16,7 @@ import engine.objects.LootTable;
import engine.objects.PlayerCharacter;
/**
*
* @author Eighty
*
*/
public class MBDropCmd extends AbstractDevCmd {
-3
View File
@@ -23,7 +23,6 @@ import org.pmw.tinylog.Logger;
/**
* @author Eighty
*
*/
public class MakeBaneCmd extends AbstractDevCmd {
@@ -78,8 +77,6 @@ public class MakeBaneCmd extends AbstractDevCmd {
PlayerCharacter player = PlayerCharacter.getPlayerCharacter(attackerID);
if (player.getGuild().isEmptyGuild()) {
throwbackError(pc, "Errant's can not place banes");
return;
-2
View File
@@ -21,7 +21,6 @@ import java.util.ArrayList;
/**
* @author Eighty
*
*/
public class MakeItemCmd extends AbstractDevCmd {
@@ -70,7 +69,6 @@ public class MakeItemCmd extends AbstractDevCmd {
}
//add item to inventory
pc.getCharItemManager().addItemToInventory(item);
}
+20 -22
View File
@@ -6,9 +6,7 @@ import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics;
/**
* @author
* Summary: Devcmd to toggle logging of application protocol messages
*
* @author Summary: Devcmd to toggle logging of application protocol messages
*/
public class NetDebugCmd extends AbstractDevCmd {
@@ -23,6 +21,23 @@ public class NetDebugCmd extends AbstractDevCmd {
// AbstractDevCmd Overridden methods
private static boolean validateUserInput(String[] userInput) {
int stringIndex;
String commandSet = "onoff";
// incorrect number of arguments test
if (userInput.length != 1)
return false;
// Validate arguments
stringIndex = commandSet.indexOf(userInput[0].toLowerCase());
return stringIndex != -1;
}
@Override
protected void _doCmd(PlayerCharacter pc, String[] args,
AbstractGameObject target) {
@@ -58,29 +73,12 @@ public class NetDebugCmd extends AbstractDevCmd {
return "Toggles sending network messages to log";
}
// Class methods
@Override
protected String _getUsageString() {
return "/netdebug on|off";
}
// Class methods
private static boolean validateUserInput(String[] userInput) {
int stringIndex;
String commandSet = "onoff";
// incorrect number of arguments test
if (userInput.length != 1)
return false;
// Validate arguments
stringIndex = commandSet.indexOf(userInput[0].toLowerCase());
return stringIndex != -1;
}
}
+1 -2
View File
@@ -73,8 +73,7 @@ public class PrintBonusesCmd extends AbstractDevCmd {
}
} else if (((AbstractCharacter) tar).getBonuses() != null) {
((AbstractCharacter) tar).getBonuses().printBonusesToClient(pc);
}
else
} else
throwbackInfo(pc, "Bonuses for " + type + ' ' + name + " not found");
}
@@ -83,7 +83,8 @@ public class PrintInventoryCmd extends AbstractDevCmd {
chargeInfo = " charges: " + charges + '/' + chargeMax;
}
throwbackInfo(pc, " " + item.getItemBase().getName() + ", count: " + item.getNumOfItems() + chargeInfo);
} else goldCount += item.getNumOfItems();
} else
goldCount += item.getNumOfItems();
}
if (gold != null) {
goldCount += gold.getNumOfItems();
@@ -16,7 +16,6 @@ import engine.objects.Regions;
/**
* @author Eighty
*
*/
public class PrintLocationCmd extends AbstractDevCmd {
+10 -12
View File
@@ -25,6 +25,16 @@ public class PrintStatsCmd extends AbstractDevCmd {
// super("printstats", MBServerStatics.ACCESS_LEVEL_ADMIN);
}
public static ItemBase getWeaponBase(int slot, HashMap<Integer, MobEquipment> equip) {
if (equip.containsKey(slot)) {
MobEquipment item = equip.get(slot);
if (item != null && item.getItemBase() != null) {
return item.getItemBase();
}
}
return null;
}
@Override
protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) {
@@ -71,7 +81,6 @@ public class PrintStatsCmd extends AbstractDevCmd {
return;
String newline = "\r\n ";
String out = "Server stats for Mob " + mb.getFirstName() + newline;
out += "Stats Base (Modified)" + newline;
@@ -130,17 +139,6 @@ public class PrintStatsCmd extends AbstractDevCmd {
throwbackInfo(pc, out);
}
public static ItemBase getWeaponBase(int slot, HashMap<Integer, MobEquipment> equip) {
if (equip.containsKey(slot)) {
MobEquipment item = equip.get(slot);
if (item != null && item.getItemBase() != null) {
return item.getItemBase();
}
}
return null;
}
@Override
protected String _getHelpString() {
return "Returns the player's current stats";
+37 -39
View File
@@ -8,9 +8,7 @@ import engine.math.Vector3fImmutable;
import engine.objects.*;
/**
*
* @author
* Dev command to move mobile and it's spawn location
* @author Dev command to move mobile and it's spawn location
* to the player's current location
*/
public class PullCmd extends AbstractDevCmd {
@@ -19,6 +17,42 @@ public class PullCmd extends AbstractDevCmd {
super("pull");
}
private static void MoveMobile(Mob targetMobile, PlayerCharacter pcSender, Vector3fImmutable newLoc, Zone serverZone) {
Vector3fImmutable localCoords;
localCoords = ZoneManager.worldToLocal(newLoc, serverZone);
DbManager.MobQueries.MOVE_MOB(targetMobile.getObjectUUID(), serverZone.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
targetMobile.setBindLoc(newLoc);
targetMobile.setLoc(newLoc);
targetMobile.refresh();
}
private static void MoveBuilding(Building targetBuilding, PlayerCharacter pcSender, Vector3fImmutable newLoc, Zone serverZone) {
Vector3fImmutable localCoords;
localCoords = ZoneManager.worldToLocal(newLoc, serverZone);
DbManager.BuildingQueries.MOVE_BUILDING(targetBuilding.getObjectUUID(), serverZone.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
targetBuilding.setLoc(newLoc);
targetBuilding.getBounds().setBounds(targetBuilding);
targetBuilding.refresh(true);
}
private static void MoveNPC(NPC targetNPC, PlayerCharacter pcSender, Vector3fImmutable newLoc, Zone serverZone) {
Vector3fImmutable localCoords;
localCoords = ZoneManager.worldToLocal(newLoc, serverZone);
DbManager.NPCQueries.MOVE_NPC(targetNPC.getObjectUUID(), serverZone.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
targetNPC.setBindLoc(newLoc);
targetNPC.setLoc(newLoc);
WorldGrid.updateObject(targetNPC, pcSender);
}
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] args,
AbstractGameObject target) {
@@ -65,40 +99,4 @@ public class PullCmd extends AbstractDevCmd {
}
return true;
}
private static void MoveMobile(Mob targetMobile, PlayerCharacter pcSender, Vector3fImmutable newLoc, Zone serverZone) {
Vector3fImmutable localCoords;
localCoords = ZoneManager.worldToLocal(newLoc, serverZone);
DbManager.MobQueries.MOVE_MOB(targetMobile.getObjectUUID(), serverZone.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
targetMobile.setBindLoc(newLoc);
targetMobile.setLoc(newLoc);
targetMobile.refresh();
}
private static void MoveBuilding(Building targetBuilding, PlayerCharacter pcSender, Vector3fImmutable newLoc, Zone serverZone) {
Vector3fImmutable localCoords;
localCoords = ZoneManager.worldToLocal(newLoc, serverZone);
DbManager.BuildingQueries.MOVE_BUILDING(targetBuilding.getObjectUUID(), serverZone.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
targetBuilding.setLoc(newLoc);
targetBuilding.getBounds().setBounds(targetBuilding);
targetBuilding.refresh(true);
}
private static void MoveNPC(NPC targetNPC, PlayerCharacter pcSender, Vector3fImmutable newLoc, Zone serverZone) {
Vector3fImmutable localCoords;
localCoords = ZoneManager.worldToLocal(newLoc, serverZone);
DbManager.NPCQueries.MOVE_NPC(targetNPC.getObjectUUID(), serverZone.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
targetNPC.setBindLoc(newLoc);
targetNPC.setLoc(newLoc);
WorldGrid.updateObject(targetNPC, pcSender);
}
}
+109 -112
View File
@@ -18,9 +18,8 @@ import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* @author
* Summary: Game designer utility command to purge all
objects of a given type within a supplied range
* @author Summary: Game designer utility command to purge all
* objects of a given type within a supplied range
*/
public class PurgeObjectsCmd extends AbstractDevCmd {
@@ -59,7 +58,6 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
mobA = (Mob) ac;
if (npc != null) {
for (Mob mob : npc.getSiegeMinionMap().keySet()) {
WorldGrid.RemoveWorldObject(mob);
@@ -100,6 +98,113 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
// AbstractDevCmd Overridden methods
private static boolean validateUserInput(String[] userInput) {
int stringIndex;
String commandSet = "npcmobmeshall";
// incorrect number of arguments test
if (userInput.length != 2)
return false;
// Test of game object type argument
stringIndex = commandSet.indexOf(userInput[0].toLowerCase());
if (stringIndex == -1)
return false;
// Test if range argument can convert to a float
try {
Float.parseFloat(userInput[1]);
} catch (NumberFormatException | NullPointerException e) {
return false;
}
// User input passes validation
return true;
}
private static void removeBuilding(PlayerCharacter pc, Building building) {
if ((building.getBlueprintUUID() != 0) &&
(building.getBlueprint().getBuildingGroup() == BuildingGroup.TOL))
return;
if ((building.getBlueprintUUID() != 0) &&
(building.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE))
Shrine.RemoveShrineFromCacheByBuilding(building);
if ((building.getBlueprint() != null) && (building.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE))
building.disableSpire(false);
for (AbstractCharacter ac : building.getHirelings().keySet()) {
NPC npc = null;
Mob mobA = null;
if (ac.getObjectType() == GameObjectType.NPC)
npc = (NPC) ac;
else if (ac.getObjectType() == GameObjectType.Mob)
mobA = (Mob) ac;
if (npc != null) {
for (Mob mob : npc.getSiegeMinionMap().keySet()) {
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob);
if (mob.getParentZone() != null)
mob.getParentZone().zoneMobSet.remove(mob);
}
DbManager.NPCQueries.DELETE_NPC(npc);
DbManager.removeFromCache(Enum.GameObjectType.NPC,
npc.getObjectUUID());
WorldGrid.RemoveWorldObject(npc);
} else if (mobA != null) {
for (Mob mob : mobA.getSiegeMinionMap().keySet()) {
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob);
if (mob.getParentZone() != null)
mob.getParentZone().zoneMobSet.remove(mob);
}
DbManager.MobQueries.DELETE_MOB(mobA);
DbManager.removeFromCache(Enum.GameObjectType.Mob,
mobA.getObjectUUID());
WorldGrid.RemoveWorldObject(mobA);
}
}
DbManager.BuildingQueries.DELETE_FROM_DATABASE(building);
DbManager.removeFromCache(building);
WorldGrid.RemoveWorldObject(building);
WorldGrid.removeObject(building, pc);
}
private static void removeNPC(PlayerCharacter pc, NPC npc) {
DbManager.NPCQueries.DELETE_NPC(npc);
DbManager.removeFromCache(npc);
WorldGrid.RemoveWorldObject(npc);
WorldGrid.removeObject(npc, pc);
}
// Class methods
private static void removeMob(PlayerCharacter pc, Mob mob) {
mob.setLoc(Vector3fImmutable.ZERO); //Move it off the plane..
mob.setBindLoc(Vector3fImmutable.ZERO); //Reset the bind loc..
//mob.setHealth(-1, pc); //Kill it!
DbManager.MobQueries.DELETE_MOB(mob);
DbManager.removeFromCache(mob);
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
}
@Override
protected void _doCmd(PlayerCharacter pc, String[] args,
AbstractGameObject target) {
@@ -174,38 +279,6 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
return "/purge [npc|mob|mesh|all] [range <= 200]";
}
// Class methods
private static boolean validateUserInput(String[] userInput) {
int stringIndex;
String commandSet = "npcmobmeshall";
// incorrect number of arguments test
if (userInput.length != 2)
return false;
// Test of game object type argument
stringIndex = commandSet.indexOf(userInput[0].toLowerCase());
if (stringIndex == -1)
return false;
// Test if range argument can convert to a float
try {
Float.parseFloat(userInput[1]); }
catch (NumberFormatException | NullPointerException e) {
return false;
}
// User input passes validation
return true;
}
private void parseUserInput(String[] userInput) {
_targetMask = 0;
@@ -236,80 +309,4 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
_targetRange = Math.min(_targetRange, 200f);
}
private static void removeBuilding(PlayerCharacter pc, Building building) {
if ((building.getBlueprintUUID() != 0) &&
(building.getBlueprint().getBuildingGroup() == BuildingGroup.TOL))
return;
if ((building.getBlueprintUUID() != 0) &&
(building.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE))
Shrine.RemoveShrineFromCacheByBuilding(building);
if ((building.getBlueprint() != null) && (building.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE))
building.disableSpire(false);
for (AbstractCharacter ac: building.getHirelings().keySet()){
NPC npc = null;
Mob mobA = null;
if (ac.getObjectType() == GameObjectType.NPC)
npc = (NPC)ac;
else if (ac.getObjectType() == GameObjectType.Mob)
mobA = (Mob)ac;
if (npc != null){
for (Mob mob: npc.getSiegeMinionMap().keySet()){
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob);
if (mob.getParentZone() != null)
mob.getParentZone().zoneMobSet.remove(mob);
}
DbManager.NPCQueries.DELETE_NPC(npc);
DbManager.removeFromCache(Enum.GameObjectType.NPC,
npc.getObjectUUID());
WorldGrid.RemoveWorldObject(npc);
}else if (mobA != null){
for (Mob mob: mobA.getSiegeMinionMap().keySet()){
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob);
if (mob.getParentZone() != null)
mob.getParentZone().zoneMobSet.remove(mob);
}
DbManager.MobQueries.DELETE_MOB(mobA);
DbManager.removeFromCache(Enum.GameObjectType.Mob,
mobA.getObjectUUID());
WorldGrid.RemoveWorldObject(mobA);
}
}
DbManager.BuildingQueries.DELETE_FROM_DATABASE(building);
DbManager.removeFromCache(building);
WorldGrid.RemoveWorldObject(building);
WorldGrid.removeObject(building, pc);
}
private static void removeNPC(PlayerCharacter pc, NPC npc) {
DbManager.NPCQueries.DELETE_NPC(npc);
DbManager.removeFromCache(npc);
WorldGrid.RemoveWorldObject(npc);
WorldGrid.removeObject(npc, pc);
}
private static void removeMob(PlayerCharacter pc, Mob mob) {
mob.setLoc(Vector3fImmutable.ZERO); //Move it off the plane..
mob.setBindLoc(Vector3fImmutable.ZERO); //Reset the bind loc..
//mob.setHealth(-1, pc); //Kill it!
DbManager.MobQueries.DELETE_MOB(mob);
DbManager.removeFromCache(mob);
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
}
}
-1
View File
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
+1 -3
View File
@@ -6,9 +6,7 @@ import engine.objects.PlayerCharacter;
import org.pmw.tinylog.Logger;
/**
* @author
* Summary: Devcmd to reboot server
*
* @author Summary: Devcmd to reboot server
*/
public class RebootCmd extends AbstractDevCmd {
-1
View File
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd;
@@ -16,7 +16,6 @@ import engine.objects.*;
/**
* @author Eighty
*
*/
public class RemoveBaneCmd extends AbstractDevCmd {
-2
View File
@@ -18,9 +18,7 @@ import engine.objects.NPC;
import engine.objects.PlayerCharacter;
/**
*
* @author Eighty
*
*/
public class RenameCmd extends AbstractDevCmd {
@@ -32,5 +32,4 @@ public class ResetLevelCmd extends AbstractDevCmd {
}
}
+127
View File
@@ -0,0 +1,127 @@
// ·. · · · · .
// · ·
// · ·
//
// · · ·
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.devcmd.cmds;
import engine.ai.MobileFSMManager;
import engine.devcmd.AbstractDevCmd;
import engine.gameManager.DbManager;
import engine.objects.AbstractGameObject;
import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics;
/**
* @author Steve
*/
public class SetAICmd extends AbstractDevCmd {
public SetAICmd() {
super("setAI");
this.addCmdString("ai");
}
@Override
protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) {
if (words.length < 2) {
this.sendUsage(pc);
return;
}
int amount;
try {
amount = Integer.valueOf(words[1]);
} catch (NumberFormatException e) {
this.throwbackError(pc, "Failed to parse amount");
return;
}
switch (words[0]) {
case "angle":
float angle = Float.parseFloat(words[1]);
MobileFSMManager.AI_MAX_ANGLE = angle;
break;
case "aggrorange":
MobileFSMManager.AI_BASE_AGGRO_RANGE = amount;
DbManager.MobBaseQueries.UPDATE_AI_DEFAULTS();
this.throwbackInfo(pc, "Aggro Range is now set to " + amount);
break;
case "dropaggrorange":
MobileFSMManager.AI_DROP_AGGRO_RANGE = amount;
DbManager.MobBaseQueries.UPDATE_AI_DEFAULTS();
this.throwbackInfo(pc, "Drop Aggro Range is now set to " + amount);
break;
case "patroldivisor":
MobileFSMManager.AI_PATROL_DIVISOR = amount;
DbManager.MobBaseQueries.UPDATE_AI_DEFAULTS();
this.throwbackInfo(pc, "Patrol Chance is now set to " + amount);
break;
case "pulse":
if (amount < 500) {
this.throwbackError(pc, "pulse amount must be greather than 500 to execute.");
return;
}
MobileFSMManager.AI_PULSE_MOB_THRESHOLD = amount;
this.throwbackInfo(pc, "Pulse is now set to " + amount);
break;
case "sleepthread":
if (amount < 500) {
this.throwbackError(pc, "sleep amount must be greather than 500 to execute.");
return;
}
MobileFSMManager.AI_THREAD_SLEEP = amount;
this.throwbackInfo(pc, "Thread Sleep is now set to " + amount);
break;
case "recallrange":
MobileFSMManager.AI_RECALL_RANGE = amount;
DbManager.MobBaseQueries.UPDATE_AI_DEFAULTS();
this.throwbackInfo(pc, "Recall Range is now set to " + amount);
break;
case "powerdivisor":
MobileFSMManager.AI_POWER_DIVISOR = amount;
DbManager.MobBaseQueries.UPDATE_AI_DEFAULTS();
this.throwbackInfo(pc, "Power Divisor is now set to " + amount);
break;
case "losehate":
MBServerStatics.PLAYER_HATE_DELIMITER = amount;
break;
case "hatemodcombat":
MBServerStatics.PLAYER_COMBAT_HATE_MODIFIER = amount;
default:
this.throwbackError(pc, words[0] + " is not a valid AI Command.");
break;
}
}
@Override
protected String _getHelpString() {
String help = "Modifies Mob AI Statics. Commands:";
help += "\n AGGRORANGE: Sets the range when a mob will aggro it's target. Aggro range is currently " + MobileFSMManager.AI_BASE_AGGRO_RANGE;
help += "\n DROPAGGRORANGE: Sets the range when a mob will drop aggro from it's target. Drop aggro range is currently " + MobileFSMManager.AI_DROP_AGGRO_RANGE;
help += "\n PATROLDIVISOR: Sets the Patrol Divisor for Mob AI. Setting this will give a 1/[amount] chance to parol the area. Patrol Chance is currently 1/" + MobileFSMManager.AI_PATROL_DIVISOR;
help += "\n PULSE: sets how often to run mob's AI. Measured in MS. Pulse is currently " + MobileFSMManager.AI_PULSE_MOB_THRESHOLD + "ms.";
help += "\n SLEEPTHREAD: Sets how long to sleep the AI for ALL mobs.Thread sleep is currently " + MobileFSMManager.AI_THREAD_SLEEP + "ms.";
help += "\n RECALLRANGE: Sets the range of a mob to recall back to it's bind location. Recall range is currently " + MobileFSMManager.AI_RECALL_RANGE;
help += "\n POWERDIVISOR: Sets the Power Divisor for Mob AI.Setting this will give a 1/[amount] chance to use power on a player. Power Divisor is currently " + MobileFSMManager.AI_POWER_DIVISOR;
help += "\n LOSEHATE: Sets the amount per second to reduce hate amount for player while they are idle. Hate Delimiter is currently " + MBServerStatics.PLAYER_HATE_DELIMITER;
help += "\n HATEMODCOMBAT: sets the modifier for Hate value for Combat. Hate Value is `Damage *[HATEMODCOMBAT]`.Hate Mod Combat is currently " + MBServerStatics.PLAYER_COMBAT_HATE_MODIFIER;
return help;
}
@Override
protected String _getUsageString() {
String usage = "' /setai `command` `amount` `";
usage += '\n' + _getHelpString();
return usage;
}
}
@@ -17,9 +17,7 @@ import engine.objects.CharacterRune;
import engine.objects.PlayerCharacter;
/**
*
* @author Eighty
*
*/
public class SetAdminRuneCmd extends AbstractDevCmd {
@@ -15,7 +15,6 @@ import engine.objects.*;
/**
* @author Eighty
*
*/
public class SetBaneActiveCmd extends AbstractDevCmd {
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd;
+3 -5
View File
@@ -10,9 +10,7 @@ import engine.objects.NPC;
import engine.objects.PlayerCharacter;
/**
*
* @author
* Dev command to set the guild of targeted npc.
* @author Dev command to set the guild of targeted npc.
* Argument is a valid guild UID
*/
public class SetGuildCmd extends AbstractDevCmd {
@@ -84,8 +82,8 @@ public class SetGuildCmd extends AbstractDevCmd {
// Argument must parse as a int.
try {
Integer.parseInt(userInput[0]); }
catch (NumberFormatException | NullPointerException e) {
Integer.parseInt(userInput[0]);
} catch (NumberFormatException | NullPointerException e) {
return false;
}
-1
View File
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.DispatchChannel;
+2 -1
View File
@@ -27,7 +27,8 @@ public class SetInvulCmd extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) {
if (pcSender == null) return;
if (pcSender == null)
return;
if (words.length != 1) {
this.sendUsage(pcSender);
-1
View File
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum;
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
@@ -21,6 +20,7 @@ import engine.objects.PlayerCharacter;
public class SetNpcEquipSetCmd extends AbstractDevCmd {
public static int lastEquipSetID = 0;
public SetNpcEquipSetCmd() {
super("setEquipSet");
this.addCmdString("equipset");
@@ -68,7 +68,6 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd {
}
return;
}
@@ -99,7 +98,6 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd {
}
return;
}
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
+1 -1
View File
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
@@ -20,6 +19,7 @@ import engine.objects.PlayerCharacter;
public class SetNpcNameCmd extends AbstractDevCmd {
public static int lastEquipSetID = 0;
public SetNpcNameCmd() {
super("setNPCName");
this.addCmdString("npcname");
+5 -6
View File
@@ -8,9 +8,7 @@ import engine.objects.*;
/**
*
* @author
* Dev command to set the owner of targeted building.
* @author Dev command to set the owner of targeted building.
* Argument is a valid guild UID
*/
public class SetOwnerCmd extends AbstractDevCmd {
@@ -45,7 +43,8 @@ public class SetOwnerCmd extends AbstractDevCmd {
if (city != null) {
city.claim(outOwner);
return; }
return;
}
}
_targetBuilding.setOwner(outOwner);
@@ -89,8 +88,8 @@ public class SetOwnerCmd extends AbstractDevCmd {
// Argument must parse to a long.
try {
Long.parseLong(userInput[0]); }
catch (NumberFormatException | NullPointerException e) {
Long.parseLong(userInput[0]);
} catch (NumberFormatException | NullPointerException e) {
return false;
}
-2
View File
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.InterestManagement.WorldGrid;
@@ -126,7 +125,6 @@ public class SetRankCmd extends AbstractDevCmd {
}
}
@Override
-2
View File
@@ -17,9 +17,7 @@ import engine.objects.CharacterRune;
import engine.objects.PlayerCharacter;
/**
*
* @author Eighty
*
*/
public class SetRuneCmd extends AbstractDevCmd {
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.DispatchChannel;
-13
View File
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
@@ -79,7 +78,6 @@ public class SetSubRaceCmd extends AbstractDevCmd {
//pc.getCharItemManager().updateInventory();
// Mob mob = (Mob)target;
//
// if (mob == null)
@@ -90,8 +88,6 @@ public class SetSubRaceCmd extends AbstractDevCmd {
// mob.getCharItemManager().addItemToInventory(mobLoot);
// if (target.getObjectType() != GameObjectType.Building)
// return;
//
@@ -155,13 +151,6 @@ public class SetSubRaceCmd extends AbstractDevCmd {
// }
// for (EffectsBase eb : EffectsBase.getAllEffectsBase()){
// if (eb.getToken() == 0)
// continue;
@@ -192,8 +181,6 @@ public class SetSubRaceCmd extends AbstractDevCmd {
// }
}
@Override
@@ -53,5 +53,4 @@ public class ShowOffsetCmd extends AbstractDevCmd {
}
}
-1
View File
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
+38 -39
View File
@@ -12,8 +12,7 @@ import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* @author
* Summary: Game designer utility command to create multiple
* @author Summary: Game designer utility command to create multiple
* mobiles of a given UUID within a supplied range
*/
@@ -39,6 +38,41 @@ public class SplatMobCmd extends AbstractDevCmd {
// AbstractDevCmd Overridden methods
private static boolean validateUserInput(String[] userInput) {
// incorrect number of arguments test
if (userInput.length != 3)
return false;
// Test for UUID conversion to int
try {
Integer.parseInt(userInput[0]);
} catch (NumberFormatException | NullPointerException e) {
return false;
}
// Test for Number of Mobs conversion to int
try {
Integer.parseInt(userInput[1]);
} catch (NumberFormatException | NullPointerException e) {
return false;
}
// Test if range argument can convert to a float
try {
Float.parseFloat(userInput[2]);
} catch (NumberFormatException | NullPointerException e) {
return false;
}
return true;
}
@Override
protected void _doCmd(PlayerCharacter pc, String[] args,
AbstractGameObject target) {
@@ -97,48 +131,13 @@ public class SplatMobCmd extends AbstractDevCmd {
return "Spawns multiple mobiles with a given range";
}
// Class methods
@Override
protected String _getUsageString() {
return "/splatmob UUID [Count <= 100] [range <= 1200]";
}
// Class methods
private static boolean validateUserInput(String[] userInput) {
// incorrect number of arguments test
if (userInput.length != 3)
return false;
// Test for UUID conversion to int
try {
Integer.parseInt(userInput[0]); }
catch (NumberFormatException | NullPointerException e) {
return false;
}
// Test for Number of Mobs conversion to int
try {
Integer.parseInt(userInput[1]); }
catch (NumberFormatException | NullPointerException e) {
return false;
}
// 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
+20 -22
View File
@@ -6,9 +6,7 @@ import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics;
/**
* @author
* Summary: Devcmd to toggle logging of mysql statements
*
* @author Summary: Devcmd to toggle logging of mysql statements
*/
public class SqlDebugCmd extends AbstractDevCmd {
@@ -23,6 +21,23 @@ public class SqlDebugCmd extends AbstractDevCmd {
// AbstractDevCmd Overridden methods
private static boolean validateUserInput(String[] userInput) {
int stringIndex;
String commandSet = "onoff";
// incorrect number of arguments test
if (userInput.length != 1)
return false;
// Validate arguments
stringIndex = commandSet.indexOf(userInput[0].toLowerCase());
return stringIndex != -1;
}
@Override
protected void _doCmd(PlayerCharacter pc, String[] args,
AbstractGameObject target) {
@@ -58,29 +73,12 @@ public class SqlDebugCmd extends AbstractDevCmd {
return "Toggles sending SQL statements to log";
}
// Class methods
@Override
protected String _getUsageString() {
return "/sqldebug on|off";
}
// Class methods
private static boolean validateUserInput(String[] userInput) {
int stringIndex;
String commandSet = "onoff";
// incorrect number of arguments test
if (userInput.length != 1)
return false;
// Validate arguments
stringIndex = commandSet.indexOf(userInput[0].toLowerCase());
return stringIndex != -1;
}
}
-1
View File
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd;
@@ -21,7 +21,6 @@ import engine.objects.PlayerCharacter;
/**
* @author
*
*/
public class UnloadFurnitureCmd extends AbstractDevCmd {
-1
View File
@@ -22,7 +22,6 @@ import java.util.ArrayList;
/**
* @author
*
*/
public class ZoneInfoCmd extends AbstractDevCmd {
+4 -10
View File
@@ -9,25 +9,19 @@
package engine.devcmd.cmds;
import engine.Enum.BuildingGroup;
import engine.Enum.GameObjectType;
import engine.Enum.TargetColor;
import engine.devcmd.AbstractDevCmd;
import engine.gameManager.BuildingManager;
import engine.gameManager.SessionManager;
import engine.math.Vector3fImmutable;
import engine.objects.*;
import engine.util.StringUtils;
import engine.objects.AbstractGameObject;
import engine.objects.Building;
import engine.objects.Mob;
import engine.objects.PlayerCharacter;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author
*
*/
public class aiInfoCmd extends AbstractDevCmd {
-3
View File
@@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
@@ -44,8 +43,6 @@ public class convertLoc extends AbstractDevCmd {
ChatManager.chatSystemInfo(pc, Vector3fImmutable.toString(convertedLoc));
}
@Override
+3 -1
View File
@@ -2,8 +2,10 @@ package engine.devcmd.cmds;
import engine.Enum;
import engine.devcmd.AbstractDevCmd;
import engine.gameManager.*;
import engine.gameManager.BuildingManager;
import engine.gameManager.NPCManager;
import engine.objects.*;
import java.util.ArrayList;
public class simulateBootyCmd extends AbstractDevCmd {

Some files were not shown because too many files have changed in this diff Show More