Browse Source

Project cleanup pre merge.

master
MagicBot 2 years ago
parent
commit
9bbdef224d
  1. 15
      README.md
  2. 2
      src/discord/DiscordAccount.java
  3. 297
      src/discord/MagicBot.java
  4. 3
      src/discord/handlers/ChatChannelHandler.java
  5. 7
      src/discord/handlers/DevRequestHandler.java
  6. 320
      src/engine/InterestManagement/HeightMap.java
  7. 246
      src/engine/InterestManagement/InterestManager.java
  8. 2
      src/engine/InterestManagement/RealmMap.java
  9. 68
      src/engine/InterestManagement/WorldGrid.java
  10. 121
      src/engine/ai/MobileFSM.java
  11. 5
      src/engine/ai/MobileFSMManager.java
  12. 2
      src/engine/ai/utilities/CombatUtilities.java
  13. 49
      src/engine/core/ControlledRunnable.java
  14. 12
      src/engine/db/archive/BaneRecord.java
  15. 3
      src/engine/db/archive/CharacterRecord.java
  16. 3
      src/engine/db/archive/CityRecord.java
  17. 1
      src/engine/db/archive/DataRecord.java
  18. 44
      src/engine/db/archive/DataWarehouse.java
  19. 15
      src/engine/db/archive/GuildRecord.java
  20. 6
      src/engine/db/archive/MineRecord.java
  21. 3
      src/engine/db/archive/PvpRecord.java
  22. 3
      src/engine/db/archive/RealmRecord.java
  23. 120
      src/engine/devcmd/AbstractDevCmd.java
  24. 1
      src/engine/devcmd/cmds/AddGoldCmd.java
  25. 17
      src/engine/devcmd/cmds/AddMobCmd.java
  26. 5
      src/engine/devcmd/cmds/AddNPCCmd.java
  27. 36
      src/engine/devcmd/cmds/ApplyBonusCmd.java
  28. 47
      src/engine/devcmd/cmds/ApplyStatModCmd.java
  29. 35
      src/engine/devcmd/cmds/AuditFailedItemsCmd.java
  30. 7
      src/engine/devcmd/cmds/AuditHeightMapCmd.java
  31. 15
      src/engine/devcmd/cmds/AuditMobsCmd.java
  32. 14
      src/engine/devcmd/cmds/BoundsCmd.java
  33. 2
      src/engine/devcmd/cmds/ChangeNameCmd.java
  34. 5
      src/engine/devcmd/cmds/CombatMessageCmd.java
  35. 5
      src/engine/devcmd/cmds/CreateItemCmd.java
  36. 17
      src/engine/devcmd/cmds/DebugCmd.java
  37. 1
      src/engine/devcmd/cmds/DebugMeleeSyncCmd.java
  38. 4
      src/engine/devcmd/cmds/DecachePlayerCmd.java
  39. 13
      src/engine/devcmd/cmds/DespawnCmd.java
  40. 5
      src/engine/devcmd/cmds/DistanceCmd.java
  41. 2
      src/engine/devcmd/cmds/EffectCmd.java
  42. 13
      src/engine/devcmd/cmds/EnchantCmd.java
  43. 3
      src/engine/devcmd/cmds/FlashMsgCmd.java
  44. 5
      src/engine/devcmd/cmds/GateInfoCmd.java
  45. 8
      src/engine/devcmd/cmds/GetBankCmd.java
  46. 41
      src/engine/devcmd/cmds/GetHeightCmd.java
  47. 27
      src/engine/devcmd/cmds/GetMemoryCmd.java
  48. 7
      src/engine/devcmd/cmds/GetMobBaseLoot.java
  49. 3
      src/engine/devcmd/cmds/GetOffsetCmd.java
  50. 3
      src/engine/devcmd/cmds/GetRuneDropRateCmd.java
  51. 6
      src/engine/devcmd/cmds/GetVaultCmd.java
  52. 3
      src/engine/devcmd/cmds/GetZoneCmd.java
  53. 6
      src/engine/devcmd/cmds/GetZoneMobsCmd.java
  54. 17
      src/engine/devcmd/cmds/GotoBoundsCmd.java
  55. 39
      src/engine/devcmd/cmds/GotoCmd.java
  56. 1
      src/engine/devcmd/cmds/GotoObj.java
  57. 1
      src/engine/devcmd/cmds/HeartbeatCmd.java
  58. 2
      src/engine/devcmd/cmds/HotzoneCmd.java
  59. 87
      src/engine/devcmd/cmds/InfoCmd.java
  60. 2
      src/engine/devcmd/cmds/JumpCmd.java
  61. 18
      src/engine/devcmd/cmds/MBDropCmd.java
  62. 7
      src/engine/devcmd/cmds/MakeBaneCmd.java
  63. 12
      src/engine/devcmd/cmds/MakeItemCmd.java
  64. 44
      src/engine/devcmd/cmds/NetDebugCmd.java
  65. 2
      src/engine/devcmd/cmds/PrintBankCmd.java
  66. 7
      src/engine/devcmd/cmds/PrintBonusesCmd.java
  67. 16
      src/engine/devcmd/cmds/PrintEquipCmd.java
  68. 5
      src/engine/devcmd/cmds/PrintInventoryCmd.java
  69. 1
      src/engine/devcmd/cmds/PrintLocationCmd.java
  70. 22
      src/engine/devcmd/cmds/PrintStatsCmd.java
  71. 2
      src/engine/devcmd/cmds/PrintVaultCmd.java
  72. 76
      src/engine/devcmd/cmds/PullCmd.java
  73. 247
      src/engine/devcmd/cmds/PurgeObjectsCmd.java
  74. 1
      src/engine/devcmd/cmds/RealmInfoCmd.java
  75. 6
      src/engine/devcmd/cmds/RebootCmd.java
  76. 19
      src/engine/devcmd/cmds/RegionCmd.java
  77. 1
      src/engine/devcmd/cmds/RemoveBaneCmd.java
  78. 16
      src/engine/devcmd/cmds/RemoveObjectCmd.java
  79. 6
      src/engine/devcmd/cmds/RenameCmd.java
  80. 1
      src/engine/devcmd/cmds/ResetLevelCmd.java
  81. 44
      src/engine/devcmd/cmds/RotateCmd.java
  82. 16
      src/engine/devcmd/cmds/SetAICmd.java
  83. 4
      src/engine/devcmd/cmds/SetAdminRuneCmd.java
  84. 1
      src/engine/devcmd/cmds/SetBaneActiveCmd.java
  85. 7
      src/engine/devcmd/cmds/SetBuildingAltitudeCmd.java
  86. 1
      src/engine/devcmd/cmds/SetForceRenameCityCmd.java
  87. 12
      src/engine/devcmd/cmds/SetGuildCmd.java
  88. 1
      src/engine/devcmd/cmds/SetHealthCmd.java
  89. 5
      src/engine/devcmd/cmds/SetInvulCmd.java
  90. 3
      src/engine/devcmd/cmds/SetMaintCmd.java
  91. 38
      src/engine/devcmd/cmds/SetNpcEquipSetCmd.java
  92. 7
      src/engine/devcmd/cmds/SetNpcMobbaseCmd.java
  93. 6
      src/engine/devcmd/cmds/SetNpcNameCmd.java
  94. 19
      src/engine/devcmd/cmds/SetOwnerCmd.java
  95. 16
      src/engine/devcmd/cmds/SetRankCmd.java
  96. 2
      src/engine/devcmd/cmds/SetRuneCmd.java
  97. 1
      src/engine/devcmd/cmds/SetStaminaCmd.java
  98. 31
      src/engine/devcmd/cmds/SetSubRaceCmd.java
  99. 3
      src/engine/devcmd/cmds/ShowOffsetCmd.java
  100. 3
      src/engine/devcmd/cmds/SlotTestCmd.java
  101. Some files were not shown because too many files have changed in this diff Show More

15
README.md

@ -1,17 +1,23 @@ @@ -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 @@ -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
src/discord/DiscordAccount.java

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
// www.magicbane.com
package discord;
import engine.Enum;
import java.time.LocalDateTime;
@ -18,6 +19,7 @@ public class DiscordAccount { @@ -18,6 +19,7 @@ public class DiscordAccount {
public LocalDateTime registrationDate;
public LocalDateTime lastUpdateRequest;
public byte isDiscordAdmin;
public DiscordAccount() {
}

297
src/discord/MagicBot.java

@ -37,32 +37,32 @@ import java.util.regex.Pattern; @@ -37,32 +37,32 @@ import java.util.regex.Pattern;
import static discord.ChatChannel.ADMINLOG;
/*
* MagicBot is many things to Magicbane...
*
* -Project Mascot
* -Customer service and administration bot
* -Benevolent dictator
* -Investment manager.
*
* MagicBot will never beg you for money. He is a very
* responsible robot. He was varnished but never garnished.
* MagicBot does not for to overclock himself. His chips
* will therefore never overcook.
* MagicBot will never be a pitiful robot trying for to use
* you as emotional support human.
*
* MagicBot is just not that sort of robot and Magicbane
* just isn't that sort of project.
*
* MagicBot runs a Shaodowbane emulator not a Second Life emulator.
*
*/
* MagicBot is many things to Magicbane...
*
* -Project Mascot
* -Customer service and administration bot
* -Benevolent dictator
* -Investment manager.
*
* MagicBot will never beg you for money. He is a very
* responsible robot. He was varnished but never garnished.
* MagicBot does not for to overclock himself. His chips
* will therefore never overcook.
* MagicBot will never be a pitiful robot trying for to use
* you as emotional support human.
*
* MagicBot is just not that sort of robot and Magicbane
* just isn't that sort of project.
*
* MagicBot runs a Shaodowbane emulator not a Second Life emulator.
*
*/
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;
@ -126,12 +126,136 @@ public class MagicBot extends ListenerAdapter { @@ -126,12 +126,136 @@ public class MagicBot extends ListenerAdapter {
Runnable adminLogRunnable = () -> SendAdminLogUpdates();
ScheduledExecutorService exec = Executors.newScheduledThreadPool(1);
exec.scheduleAtFixedRate(adminLogRunnable , 0, 1, TimeUnit.MINUTES);
exec.scheduleAtFixedRate(adminLogRunnable, 0, 1, TimeUnit.MINUTES);
Logger.info("***MAGICBOT IS RUNNING***");
}
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 { @@ -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 { @@ -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 { @@ -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();
}
}
}

3
src/discord/handlers/ChatChannelHandler.java

@ -42,7 +42,8 @@ public class ChatChannelHandler { @@ -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

7
src/discord/handlers/DevRequestHandler.java

@ -40,7 +40,7 @@ public class DevRequestHandler { @@ -40,7 +40,7 @@ public class DevRequestHandler {
switch (serverCommand) {
case "build" :
case "build":
commandString = "./mbdevbuild.sh";
break;
case "restart":
@ -62,7 +62,7 @@ public class DevRequestHandler { @@ -62,7 +62,7 @@ public class DevRequestHandler {
MagicBot.sendResponse(event,
"#dev build <target> (blank==master) \n" +
"#dev shutdown (Shutdown dev server)\n" +
"#dev restart (Restarts the server)\n"+
"#dev restart (Restarts the server)\n" +
"#dev debug (Restarts server in debug mode)\n" +
"#dev console # (Displays # lines from console)\n" +
"#dev lastout (Displays output from last command) \n");
@ -77,7 +77,7 @@ public class DevRequestHandler { @@ -77,7 +77,7 @@ public class DevRequestHandler {
}
processBuilder = new ProcessBuilder("/bin/sh", "-c", commandString + " " + commandArgument + " > devLastOut");
logString = String.join(" ",processBuilder.command().toArray(new String[0]));
logString = String.join(" ", processBuilder.command().toArray(new String[0]));
try {
processBuilder.start();
@ -89,6 +89,7 @@ public class DevRequestHandler { @@ -89,6 +89,7 @@ public class DevRequestHandler {
"Use #dev lastout to view results");
}
private static String getLastOutput() {
String outString = null;

320
src/engine/InterestManagement/HeightMap.java

@ -142,7 +142,7 @@ public class HeightMap { @@ -142,7 +142,7 @@ public class HeightMap {
this.bucketWidthX = 1;
this.bucketWidthY = 1;
this.pixelColorValues = new int[this.fullExtentsX + 1][this.fullExtentsY+1];
this.pixelColorValues = new int[this.fullExtentsX + 1][this.fullExtentsY + 1];
for (int y = 0; y <= this.fullExtentsY; y++) {
for (int x = 0; x <= this.fullExtentsX; x++) {
@ -180,7 +180,7 @@ public class HeightMap { @@ -180,7 +180,7 @@ public class HeightMap {
this.bucketWidthX = 1;
this.bucketWidthY = 1;
this.pixelColorValues = new int[this.fullExtentsX+1][this.fullExtentsY+1];
this.pixelColorValues = new int[this.fullExtentsX + 1][this.fullExtentsY + 1];
for (int y = 0; y <= this.fullExtentsY; y++) {
for (int x = 0; x <= this.fullExtentsX; x++) {
@ -206,88 +206,6 @@ public class HeightMap { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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;
}
}

246
src/engine/InterestManagement/InterestManager.java

@ -38,14 +38,128 @@ public enum InterestManager implements Runnable { @@ -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 { @@ -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
@ -341,7 +458,7 @@ public enum InterestManager implements Runnable { @@ -341,7 +458,7 @@ public enum InterestManager implements Runnable {
awonpc.playerAgroMap.put(player.getObjectUUID(), false);
//MobileFSM.setAwake(awonpc, false);
((Mob)awonpc).setCombatTarget(null);
((Mob) awonpc).setCombatTarget(null);
// IVarController.setVariable(awonpc, "IntelligenceDisableDelay", (double) (System.currentTimeMillis() + 5000));
// awonpc.enableIntelligence();
lcm = new LoadCharacterMsg(awonpc, PlayerCharacter.hideNonAscii());
@ -358,7 +475,7 @@ public enum InterestManager implements Runnable { @@ -358,7 +475,7 @@ public enum InterestManager implements Runnable {
if (awonpc.isMob())
//MobileFSM.setAwake(awonpc, false);
((Mob)awonpc).setCombatTarget(null);
((Mob) awonpc).setCombatTarget(null);
// IVarController.setVariable(awonpc, "IntelligenceDisableDelay", (double) (System.currentTimeMillis() + 5000));
// awonpc.enableIntelligence();
lcm = new LoadCharacterMsg(awonpc, PlayerCharacter.hideNonAscii());
@ -385,76 +502,6 @@ public enum InterestManager implements Runnable { @@ -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 { @@ -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");
}
}
}
}
}

2
src/engine/InterestManagement/RealmMap.java

@ -36,8 +36,8 @@ public enum RealmMap { @@ -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) {

68
src/engine/InterestManagement/WorldGrid.java

@ -26,10 +26,11 @@ import java.util.concurrent.ConcurrentHashMap; @@ -26,10 +26,11 @@ import java.util.concurrent.ConcurrentHashMap;
public class WorldGrid {
public static ConcurrentHashMap<Integer,AbstractWorldObject>[][] DynamicGridMap;
public static ConcurrentHashMap<Integer,AbstractWorldObject>[][] StaticGridMap;
public static ConcurrentHashMap<Integer, AbstractWorldObject>[][] DynamicGridMap;
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;
@ -59,16 +60,15 @@ public class WorldGrid { @@ -59,16 +60,15 @@ public class WorldGrid {
else
scale = WorldGrid.dynamicBucketScale;
int gridX = (int) Math.abs(loc.x * scale);
int gridZ = (int)Math.abs(loc.z * scale);
int bucketSize = (int) (r *scale) + 1;
int gridZ = (int) Math.abs(loc.z * scale);
int bucketSize = (int) (r * scale) + 1;
//start at top left most corner to scan.
int startingX = gridX - bucketSize;
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.
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.
if (startingX < 0)
startingX = 0;
@ -98,16 +98,16 @@ public class WorldGrid { @@ -98,16 +98,16 @@ public class WorldGrid {
endZ = limitZ;
int auditMob = 0;
for (int x = startingX;x<=endX;x++){
for (int z = startingZ;z >= endZ;z--){
for (int x = startingX; x <= endX; x++) {
for (int z = startingZ; z >= endZ; z--) {
ConcurrentHashMap<Integer,AbstractWorldObject> gridMap;
ConcurrentHashMap<Integer, AbstractWorldObject> gridMap;
if ((MBServerStatics.MASK_STATIC & mask) != 0)
gridMap = WorldGrid.StaticGridMap[x][z];
else
gridMap = WorldGrid.DynamicGridMap[x][z];
for (AbstractWorldObject gridObject: gridMap.values()){
for (AbstractWorldObject gridObject : gridMap.values()) {
if ((gridObject.getObjectTypeMask() & mask) == 0)
continue;
if (gridObject.getLoc().distanceSquared2D(loc) <= FastMath.sqr(r))
@ -124,7 +124,7 @@ public class WorldGrid { @@ -124,7 +124,7 @@ public class WorldGrid {
}
public static HashSet<AbstractWorldObject> getObjectsInRangeContains(Vector3fImmutable loc, double r, int mask) {
HashSet<AbstractWorldObject> outbound = getObjectsInRangePartial(loc,r,mask);
HashSet<AbstractWorldObject> outbound = getObjectsInRangePartial(loc, r, mask);
return outbound;
}
@ -133,36 +133,36 @@ public class WorldGrid { @@ -133,36 +133,36 @@ public class WorldGrid {
}
public static void InitializeGridObjects(){
public static void InitializeGridObjects() {
int dynamicWidth = (int) Math.abs(MBServerStatics.MAX_WORLD_WIDTH *WorldGrid.dynamicBucketScale);
int dynamicHeight = (int) Math.abs(MBServerStatics.MAX_WORLD_HEIGHT*WorldGrid.dynamicBucketScale);
int dynamicWidth = (int) Math.abs(MBServerStatics.MAX_WORLD_WIDTH * WorldGrid.dynamicBucketScale);
int dynamicHeight = (int) Math.abs(MBServerStatics.MAX_WORLD_HEIGHT * WorldGrid.dynamicBucketScale);
int staticWidth = (int) Math.abs(MBServerStatics.MAX_WORLD_WIDTH *WorldGrid.staticBucketScale);
int staticHeight = (int) Math.abs(MBServerStatics.MAX_WORLD_HEIGHT*WorldGrid.staticBucketScale);
WorldGrid.DynamicGridMap = new ConcurrentHashMap[dynamicWidth+ 1][dynamicHeight + 1];
int staticWidth = (int) Math.abs(MBServerStatics.MAX_WORLD_WIDTH * WorldGrid.staticBucketScale);
int staticHeight = (int) Math.abs(MBServerStatics.MAX_WORLD_HEIGHT * WorldGrid.staticBucketScale);
WorldGrid.DynamicGridMap = new ConcurrentHashMap[dynamicWidth + 1][dynamicHeight + 1];
WorldGrid.StaticGridMap = new ConcurrentHashMap[staticWidth + 1][staticHeight + 1];
//create new hash maps for each bucket
for (int x = 0; x<= staticWidth; x++)
for (int y = 0; y<= staticHeight; y++){
WorldGrid.StaticGridMap[x][y] = new ConcurrentHashMap<Integer,AbstractWorldObject>();
for (int x = 0; x <= staticWidth; x++)
for (int y = 0; y <= staticHeight; y++) {
WorldGrid.StaticGridMap[x][y] = new ConcurrentHashMap<Integer, AbstractWorldObject>();
}
for (int x = 0; x<= dynamicWidth; x++)
for (int y = 0; y<= dynamicHeight; y++){
WorldGrid.DynamicGridMap[x][y] = new ConcurrentHashMap<Integer,AbstractWorldObject>();
for (int x = 0; x <= dynamicWidth; x++)
for (int y = 0; y <= dynamicHeight; y++) {
WorldGrid.DynamicGridMap[x][y] = new ConcurrentHashMap<Integer, AbstractWorldObject>();
}
}
public static void RemoveWorldObject(AbstractWorldObject gridObject){
public static void RemoveWorldObject(AbstractWorldObject gridObject) {
if (gridObject == null)
return;
AbstractWorldObject.RemoveFromWorldGrid(gridObject);
}
public static boolean addObject(AbstractWorldObject gridObject, float x, float z){
public static boolean addObject(AbstractWorldObject gridObject, float x, float z) {
if (gridObject == null)
return false;
@ -181,12 +181,12 @@ public class WorldGrid { @@ -181,12 +181,12 @@ public class WorldGrid {
int gridX;
int gridZ;
if (gridObject.getGridObjectType().equals(GridObjectType.STATIC)){
gridX = Math.abs((int) (x *WorldGrid.staticBucketScale));
gridZ = Math.abs((int) (z*WorldGrid.staticBucketScale));
}else{
gridX = Math.abs((int) (x *WorldGrid.dynamicBucketScale));
gridZ = Math.abs((int) (z*WorldGrid.dynamicBucketScale));
if (gridObject.getGridObjectType().equals(GridObjectType.STATIC)) {
gridX = Math.abs((int) (x * WorldGrid.staticBucketScale));
gridZ = Math.abs((int) (z * WorldGrid.staticBucketScale));
} else {
gridX = Math.abs((int) (x * WorldGrid.dynamicBucketScale));
gridZ = Math.abs((int) (z * WorldGrid.dynamicBucketScale));
}
@ -212,7 +212,7 @@ public class WorldGrid { @@ -212,7 +212,7 @@ public class WorldGrid {
switch (awo.getObjectType()) {
case Building:
lsm = new LoadStructureMsg();
lsm.addObject((Building)awo);
lsm.addObject((Building) awo);
DispatchMessage.sendToAllInRange(awo, lsm);
break;
case NPC:
@ -238,7 +238,7 @@ public class WorldGrid { @@ -238,7 +238,7 @@ public class WorldGrid {
case Building:
lsm = new LoadStructureMsg();
lsm.addObject((Building)awo);
lsm.addObject((Building) awo);
DispatchMessage.sendToAllInRange(awo, lsm);
break;
case NPC:

121
src/engine/ai/MobileFSM.java

@ -6,6 +6,7 @@ @@ -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.*; @@ -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)
@ -36,8 +40,8 @@ public class MobileFSM { @@ -36,8 +40,8 @@ public class MobileFSM {
mob.setCombatTarget(null);
return;
}
if(target.getObjectType() == Enum.GameObjectType.PlayerCharacter && canCast(mob)){
if(MobCast(mob)){
if (target.getObjectType() == Enum.GameObjectType.PlayerCharacter && canCast(mob)) {
if (MobCast(mob)) {
return;
}
}
@ -58,8 +62,9 @@ public class MobileFSM { @@ -58,8 +62,9 @@ public class MobileFSM {
break;
}
}
public static void AttackPlayer(Mob mob, PlayerCharacter target) {
if(!mob.canSee(target)){
if (!mob.canSee(target)) {
mob.setCombatTarget(null);
return;
}
@ -100,6 +105,7 @@ public class MobileFSM { @@ -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 { @@ -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 { @@ -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) {
@ -174,7 +182,7 @@ public class MobileFSM { @@ -174,7 +182,7 @@ public class MobileFSM {
rwss.setPlayer(mob);
DispatchMessage.sendToAllInRange(mob, rwss);
}
int patrolDelay = ThreadLocalRandom.current().nextInt((int)(MobileFSMManager.AI_PATROL_DIVISOR * 0.5f), MobileFSMManager.AI_PATROL_DIVISOR) + MobileFSMManager.AI_PATROL_DIVISOR;
int patrolDelay = ThreadLocalRandom.current().nextInt((int) (MobileFSMManager.AI_PATROL_DIVISOR * 0.5f), MobileFSMManager.AI_PATROL_DIVISOR) + MobileFSMManager.AI_PATROL_DIVISOR;
if (mob.stopPatrolTime + (patrolDelay * 1000) > System.currentTimeMillis())
//early exit while waiting to patrol again
return;
@ -183,7 +191,7 @@ public class MobileFSM { @@ -183,7 +191,7 @@ public class MobileFSM {
Building barracks = mob.building;
if (barracks != null && barracks.patrolPoints != null && !barracks.getPatrolPoints().isEmpty()) {
mob.patrolPoints = barracks.patrolPoints;
} else{
} else {
randomGuardPatrolPoint(mob);
return;
}
@ -194,7 +202,7 @@ public class MobileFSM { @@ -194,7 +202,7 @@ public class MobileFSM {
mob.destination = mob.patrolPoints.get(mob.lastPatrolPointIndex);
mob.lastPatrolPointIndex += 1;
MovementUtilities.aiMove(mob, mob.destination, true);
if(mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()){
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) {
for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) {
//make sure mob is out of combat stance
if (minion.getKey().despawned == false) {
@ -214,6 +222,7 @@ public class MobileFSM { @@ -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.
@ -221,7 +230,7 @@ public class MobileFSM { @@ -221,7 +230,7 @@ public class MobileFSM {
return false;
if (mob.mobPowers.isEmpty())
return false;
if(!mob.canSee((PlayerCharacter) mob.getCombatTarget())){
if (!mob.canSee((PlayerCharacter) mob.getCombatTarget())) {
mob.setCombatTarget(null);
return false;
}
@ -229,6 +238,7 @@ public class MobileFSM { @@ -229,6 +238,7 @@ public class MobileFSM {
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
@ -261,7 +271,7 @@ public class MobileFSM { @@ -261,7 +271,7 @@ public class MobileFSM {
int powerRank = mob.mobPowers.get(powerToken);
PowersBase mobPower = PowersManager.getPowerByToken(powerToken);
//check for hit-roll
if(mobPower.requiresHitRoll) {
if (mobPower.requiresHitRoll) {
if (CombatUtilities.triggerDefense(mob, mob.getCombatTarget())) {
return false;
}
@ -291,6 +301,7 @@ public class MobileFSM { @@ -291,6 +301,7 @@ public class MobileFSM {
}
return false;
}
public static void MobCallForHelp(Mob mob) {
boolean callGotResponse = false;
if (mob.nextCallForHelp == 0) {
@ -311,6 +322,7 @@ public class MobileFSM { @@ -311,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;
@ -321,10 +333,10 @@ public class MobileFSM { @@ -321,10 +333,10 @@ public class MobileFSM {
}
if (mob.despawned && mob.isPlayerGuard) {
//override for guards
if(mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()){
if(mob.npcOwner.isAlive() == false || ((Mob)mob.npcOwner).despawned == true){
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) {
if (mob.npcOwner.isAlive() == false || ((Mob) mob.npcOwner).despawned == true) {
//minions don't respawn while guard captain is dead
if(mob.isAlive() == false) {
if (mob.isAlive() == false) {
mob.deathTime = System.currentTimeMillis();
return;
}
@ -351,7 +363,7 @@ public class MobileFSM { @@ -351,7 +363,7 @@ public class MobileFSM {
}
mob.updateLocation();
CheckToSendMobHome(mob);
if(mob.combatTarget != null && mob.combatTarget.isAlive() == false){
if (mob.combatTarget != null && mob.combatTarget.isAlive() == false) {
mob.setCombatTarget(null);
}
switch (mob.BehaviourType) {
@ -375,6 +387,7 @@ public class MobileFSM { @@ -375,6 +387,7 @@ public class MobileFSM {
break;
}
}
private static void CheckForAggro(Mob aiAgent) {
//looks for and sets mobs combatTarget
if (!aiAgent.isAlive())
@ -405,10 +418,11 @@ public class MobileFSM { @@ -405,10 +418,11 @@ public class MobileFSM {
}
}
}
private static void CheckMobMovement(Mob mob) {
if (!MovementUtilities.canMove(mob))
return;
switch(mob.BehaviourType){
switch (mob.BehaviourType) {
case Pet1:
if (!mob.playerAgroMap.containsKey(mob.getOwner().getObjectUUID())) {
//mob no longer has its owner loaded, translocate pet to owner
@ -425,27 +439,28 @@ public class MobileFSM { @@ -425,27 +439,28 @@ public class MobileFSM {
chaseTarget(mob);
break;
case GuardMinion:
if (!mob.npcOwner.isAlive() || ((Mob)mob.npcOwner).despawned)
if (!mob.npcOwner.isAlive() || ((Mob) mob.npcOwner).despawned)
randomGuardPatrolPoint(mob);
else{
if(mob.getCombatTarget() != null){
else {
if (mob.getCombatTarget() != null) {
chaseTarget(mob);
}
}
break;
default:
if (mob.getCombatTarget() == null) {
if(!mob.isMoving()) {
if (!mob.isMoving()) {
Patrol(mob);
} else{
} else {
mob.stopPatrolTime = System.currentTimeMillis();
}
}else {
} else {
chaseTarget(mob);
}
break;
}
}
private static void CheckForRespawn(Mob aiAgent) {
if (aiAgent.deathTime == 0) {
aiAgent.setDeathTime(System.currentTimeMillis());
@ -479,14 +494,15 @@ public class MobileFSM { @@ -479,14 +494,15 @@ 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)
return;
if(mob.getCombatTarget() == null){
if (mob.getCombatTarget() == null) {
return;
}
if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter)mob.getCombatTarget()) == false) {
if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) == false) {
mob.setCombatTarget(null);
if (mob.isCombat()) {
mob.setCombat(false);
@ -505,18 +521,18 @@ public class MobileFSM { @@ -505,18 +521,18 @@ 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.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()){
if (mob.BehaviourType.isAgressive) {
if (mob.isPlayerGuard()) {
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) {
CheckForPlayerGuardAggro(mob);
}
} else {
CheckForAggro(mob);
}
}
if(mob.getCombatTarget() != null && CombatUtilities.inRange2D(mob,mob.getCombatTarget(), MobileFSMManager.AI_BASE_AGGRO_RANGE * 0.5f)){
if (mob.getCombatTarget() != null && CombatUtilities.inRange2D(mob, mob.getCombatTarget(), MobileFSMManager.AI_BASE_AGGRO_RANGE * 0.5f)) {
return;
}
if (mob.isPlayerGuard() && !mob.despawned) {
@ -525,7 +541,7 @@ public class MobileFSM { @@ -525,7 +541,7 @@ public class MobileFSM {
PowersBase recall = PowersManager.getPowerByToken(-1994153779);
PowersManager.useMobPower(mob, mob, recall, 40);
mob.setCombatTarget(null);
if(mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal() && mob.isAlive()){
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal() && mob.isAlive()) {
//guard captain pulls his minions home with him
for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) {
PowersManager.useMobPower(minion.getKey(), minion.getKey(), recall, 40);
@ -533,20 +549,20 @@ public class MobileFSM { @@ -533,20 +549,20 @@ 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);
mob.setCombatTarget(null);
for (Entry playerEntry : mob.playerAgroMap.entrySet()) {
PlayerCharacter.getFromCache((int)playerEntry.getKey()).setHateValue(0);
PlayerCharacter.getFromCache((int) playerEntry.getKey()).setHateValue(0);
}
}
}
private static void chaseTarget(Mob mob) {
mob.updateMovementState();
if(mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false){
if (mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false) {
mob.setCombatTarget(null);
return;
}
@ -560,6 +576,7 @@ public class MobileFSM { @@ -560,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) {
@ -575,29 +592,33 @@ public class MobileFSM { @@ -575,29 +592,33 @@ 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);
}
if(mob.npcOwner.getCombatTarget() != null)
if (mob.npcOwner.getCombatTarget() != null)
mob.setCombatTarget(mob.npcOwner.getCombatTarget());
else
mob.setCombatTarget(null);
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);
@ -605,19 +626,21 @@ public class MobileFSM { @@ -605,19 +626,21 @@ public class MobileFSM {
CheckMobMovement(mob);
CheckForAttack(mob);
}
private static void HamletGuardLogic(Mob mob) {
if (mob.getCombatTarget() == null) {
//safehold guard
SafeGuardAggro(mob);
} else{
if(mob.combatTarget.isAlive() == false){
} else {
if (mob.combatTarget.isAlive() == false) {
SafeGuardAggro(mob);
}
}
CheckForAttack(mob);
}
private static void DefaultLogic(Mob mob) {
if(mob.getObjectUUID() == 40548){
if (mob.getObjectUUID() == 40548) {
int thing = 0;
}
//check for players that can be aggroed if mob is agressive and has no target
@ -643,6 +666,7 @@ public class MobileFSM { @@ -643,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())
@ -673,14 +697,15 @@ public class MobileFSM { @@ -673,14 +697,15 @@ public class MobileFSM {
}
}
}
public static Boolean GuardCanAggro(Mob mob, PlayerCharacter target) {
if (mob.getGuild().getNation().equals(target.getGuild().getNation()))
return false;
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) {
if(((Mob)mob.npcOwner).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true){
if (((Mob) mob.npcOwner).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
return true;
}
} else if(mob.building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true){
} else if (mob.building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
return true;
}
//first check condemn list for aggro allowed (allies button is checked)
@ -697,7 +722,7 @@ public class MobileFSM { @@ -697,7 +722,7 @@ public class MobileFSM {
return false;
}
return true;
} else{
} else {
//allies button is not checked
for (Entry<Integer, Condemned> entry : ZoneManager.getCityAtLocation(mob.getLoc()).getTOL().getCondemned().entrySet()) {
if (entry.getValue().getPlayerUID() == target.getObjectUUID() && entry.getValue().isActive())
@ -713,7 +738,8 @@ public class MobileFSM { @@ -713,7 +738,8 @@ public class MobileFSM {
}
return false;
}
public static void randomGuardPatrolPoint(Mob mob){
public static void randomGuardPatrolPoint(Mob mob) {
if (mob.isMoving() == true) {
//early exit for a mob who is already moving to a patrol point
//while mob moving, update lastPatrolTime so that when they stop moving the 10 second timer can begin
@ -728,9 +754,9 @@ public class MobileFSM { @@ -728,9 +754,9 @@ public class MobileFSM {
float xPoint = ThreadLocalRandom.current().nextInt(400) - 200;
float zPoint = ThreadLocalRandom.current().nextInt(400) - 200;
Vector3fImmutable TreePos = mob.getGuild().getOwnedCity().getLoc();
mob.destination = new Vector3fImmutable(TreePos.x + xPoint,TreePos.y,TreePos.z + zPoint);
mob.destination = new Vector3fImmutable(TreePos.x + xPoint, TreePos.y, TreePos.z + zPoint);
MovementUtilities.aiMove(mob, mob.destination, true);
if(mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()){
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) {
for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) {
//make sure mob is out of combat stance
if (minion.getKey().despawned == false) {
@ -750,18 +776,19 @@ public class MobileFSM { @@ -750,18 +776,19 @@ public class MobileFSM {
}
}
}
public static AbstractWorldObject ChangeTargetFromHateValue(Mob mob){
public static AbstractWorldObject ChangeTargetFromHateValue(Mob mob) {
float CurrentHateValue = 0;
if(mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){
CurrentHateValue = ((PlayerCharacter)mob.getCombatTarget()).getHateValue();
if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
CurrentHateValue = ((PlayerCharacter) mob.getCombatTarget()).getHateValue();
}
AbstractWorldObject mostHatedTarget = null;
for (Entry playerEntry : mob.playerAgroMap.entrySet()) {
PlayerCharacter potentialTarget = PlayerCharacter.getFromCache((int)playerEntry.getKey());
if(potentialTarget.equals(mob.getCombatTarget())){
PlayerCharacter potentialTarget = PlayerCharacter.getFromCache((int) playerEntry.getKey());
if (potentialTarget.equals(mob.getCombatTarget())) {
continue;
}
if(potentialTarget != null && potentialTarget.getHateValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)){
if (potentialTarget != null && potentialTarget.getHateValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) {
CurrentHateValue = potentialTarget.getHateValue();
mostHatedTarget = potentialTarget;
}

5
src/engine/ai/MobileFSMManager.java

@ -25,9 +25,6 @@ public class MobileFSMManager { @@ -25,9 +25,6 @@ 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;
@ -37,6 +34,8 @@ public class MobileFSMManager { @@ -37,6 +34,8 @@ public class MobileFSMManager {
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() {

2
src/engine/ai/utilities/CombatUtilities.java

@ -405,7 +405,7 @@ public class CombatUtilities { @@ -405,7 +405,7 @@ public class CombatUtilities {
float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None);
double min = agent.getMinDamageHandOne();
double max = agent.getMaxDamageHandOne();
if(agent.getEquip().get(1) != null) {
if (agent.getEquip().get(1) != null) {
if (agent.getEquip().get(1).getItemBase() != null) {
dt = agent.getEquip().get(1).getItemBase().getDamageType();
min = agent.getMinDamageHandOne();

49
src/engine/core/ControlledRunnable.java

@ -17,10 +17,16 @@ import java.util.ArrayList; @@ -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 { @@ -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 { @@ -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 { @@ -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.
@ -134,13 +145,17 @@ public abstract class ControlledRunnable implements Runnable { @@ -134,13 +145,17 @@ public abstract class ControlledRunnable implements Runnable {
System.out.println("BLOCKING");
Thread.sleep(25L);
} catch (InterruptedException e) {
Logger.debug( e.getMessage());
Logger.debug(e.getMessage());
break;
}
}
}
/*
* Instance monitoring and tools
*/
/**
* @return the thisThread
*/
@ -155,20 +170,4 @@ public abstract class ControlledRunnable implements Runnable { @@ -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();
}
}
}

12
src/engine/db/archive/BaneRecord.java

@ -50,8 +50,7 @@ public class BaneRecord extends DataRecord { @@ -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 { @@ -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
@ -153,7 +151,7 @@ public class BaneRecord extends DataRecord { @@ -153,7 +151,7 @@ public class BaneRecord extends DataRecord {
}
private static PreparedStatement buildDateTimeQueryStatement (Connection connection, City city) throws SQLException {
private static PreparedStatement buildDateTimeQueryStatement(Connection connection, City city) throws SQLException {
PreparedStatement outStatement;
String queryString = "SELECT `endDatetime` FROM `warehouse_banehistory` WHERE `city_id` = ? ORDER BY `endDatetime` DESC LIMIT 1";
outStatement = connection.prepareStatement(queryString);
@ -275,7 +273,7 @@ public class BaneRecord extends DataRecord { @@ -275,7 +273,7 @@ public class BaneRecord extends DataRecord {
}
} catch (SQLException e) {
Logger.error( e.toString());
Logger.error(e.toString());
}
}
@ -287,7 +285,7 @@ public class BaneRecord extends DataRecord { @@ -287,7 +285,7 @@ public class BaneRecord extends DataRecord {
statement.execute();
return true;
} catch (SQLException e) {
Logger.error( e.toString());
Logger.error(e.toString());
return false;
}
}

3
src/engine/db/archive/CharacterRecord.java

@ -44,8 +44,7 @@ public class CharacterRecord extends DataRecord { @@ -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;

3
src/engine/db/archive/CityRecord.java

@ -46,8 +46,7 @@ public class CityRecord extends DataRecord { @@ -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
src/engine/db/archive/DataRecord.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.db.archive;
import engine.Enum;

44
src/engine/db/archive/DataWarehouse.java

@ -35,12 +35,12 @@ public class DataWarehouse implements Runnable { @@ -35,12 +35,12 @@ public class DataWarehouse implements Runnable {
// If WarehousePush is disabled
// then early exit
if ( ConfigManager.MB_WORLD_WAREHOUSE_PUSH.getValue().equalsIgnoreCase("false")) {
if (ConfigManager.MB_WORLD_WAREHOUSE_PUSH.getValue().equalsIgnoreCase("false")) {
Logger.info("Warehouse Remote Connection disabled along with push");
return;
}
Logger.info( "Configuring remote Database Connection Pool...");
Logger.info("Configuring remote Database Connection Pool...");
configureRemoteConnectionPool();
}
@ -188,6 +188,24 @@ public class DataWarehouse implements Runnable { @@ -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
@ -201,7 +219,7 @@ public class DataWarehouse implements Runnable { @@ -201,7 +219,7 @@ public class DataWarehouse implements Runnable {
RealmRecord realmRecord;
MineRecord mineRecord;
Logger.info( "DataWarehouse is running.");
Logger.info("DataWarehouse is running.");
while (true) {
@ -261,7 +279,7 @@ public class DataWarehouse implements Runnable { @@ -261,7 +279,7 @@ public class DataWarehouse implements Runnable {
mineRecord.release();
break;
default:
Logger.error( "Unhandled record type");
Logger.error("Unhandled record type");
break;
} // end switch
@ -269,22 +287,4 @@ public class DataWarehouse implements Runnable { @@ -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");
}
}

15
src/engine/db/archive/GuildRecord.java

@ -27,9 +27,11 @@ import java.util.concurrent.LinkedBlockingQueue; @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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;
@ -197,7 +192,7 @@ public class GuildRecord extends DataRecord { @@ -197,7 +192,7 @@ public class GuildRecord extends DataRecord {
outStatement.setInt(9, this.fgIcon);
outStatement.setInt(10, this.fgColour);
outStatement.setString(11, this.eventType.name());
outStatement.setTimestamp(12, new java.sql.Timestamp( this.eventDatetime.atZone(ZoneId.systemDefault())
outStatement.setTimestamp(12, new java.sql.Timestamp(this.eventDatetime.atZone(ZoneId.systemDefault())
.toInstant().toEpochMilli()));
return outStatement;

6
src/engine/db/archive/MineRecord.java

@ -47,8 +47,7 @@ public class MineRecord extends DataRecord { @@ -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 { @@ -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);

3
src/engine/db/archive/PvpRecord.java

@ -51,8 +51,7 @@ public class PvpRecord extends DataRecord { @@ -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;

3
src/engine/db/archive/RealmRecord.java

@ -44,8 +44,7 @@ public class RealmRecord extends DataRecord { @@ -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;

120
src/engine/devcmd/AbstractDevCmd.java

@ -29,6 +29,60 @@ public abstract class AbstractDevCmd { @@ -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 { @@ -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 { @@ -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
src/engine/devcmd/cmds/AddGoldCmd.java

@ -17,7 +17,6 @@ import engine.objects.PlayerCharacter; @@ -17,7 +17,6 @@ import engine.objects.PlayerCharacter;
/**
* @author Eighty
*
*/
public class AddGoldCmd extends AbstractDevCmd {

17
src/engine/devcmd/cmds/AddMobCmd.java

@ -20,7 +20,6 @@ import org.pmw.tinylog.Logger; @@ -20,7 +20,6 @@ import org.pmw.tinylog.Logger;
/**
* @author Eighty
*
*/
public class AddMobCmd extends AbstractDevCmd {
@ -38,19 +37,19 @@ public class AddMobCmd extends AbstractDevCmd { @@ -38,19 +37,19 @@ public class AddMobCmd extends AbstractDevCmd {
Zone zone = ZoneManager.findSmallestZone(pc.getLoc());
if (words[0].equals("all")){
if (words[0].equals("all")) {
for (AbstractGameObject mobbaseAGO: DbManager.getList(GameObjectType.MobBase)){
MobBase mb = (MobBase)mobbaseAGO;
for (AbstractGameObject mobbaseAGO : DbManager.getList(GameObjectType.MobBase)) {
MobBase mb = (MobBase) mobbaseAGO;
int loadID = mb.getObjectUUID();
Mob mob = Mob.createMob( loadID, Vector3fImmutable.getRandomPointInCircle(pc.getLoc(), 100),
null, true, zone, null,0, "", 1);
Mob mob = Mob.createMob(loadID, Vector3fImmutable.getRandomPointInCircle(pc.getLoc(), 100),
null, true, zone, null, 0, "", 1);
if (mob != null) {
mob.updateDatabase();
this.setResult(String.valueOf(mob.getDBID()));
} else {
throwbackError(pc, "Failed to create mob of type " + loadID);
Logger.error( "Failed to create mob of type "
Logger.error("Failed to create mob of type "
+ loadID);
}
}
@ -84,8 +83,8 @@ public class AddMobCmd extends AbstractDevCmd { @@ -84,8 +83,8 @@ public class AddMobCmd extends AbstractDevCmd {
}
Mob mob = Mob.createMob( loadID, pc.getLoc(),
null, true, zone, null,0, "", 1);
Mob mob = Mob.createMob(loadID, pc.getLoc(),
null, true, zone, null, 0, "", 1);
if (mob != null) {
mob.updateDatabase();
ChatManager.chatSayInfo(pc,

5
src/engine/devcmd/cmds/AddNPCCmd.java

@ -18,7 +18,6 @@ import org.pmw.tinylog.Logger; @@ -18,7 +18,6 @@ import org.pmw.tinylog.Logger;
/**
* @author Eighty
*
*/
public class AddNPCCmd extends AbstractDevCmd {
@ -73,8 +72,8 @@ public class AddNPCCmd extends AbstractDevCmd { @@ -73,8 +72,8 @@ public class AddNPCCmd extends AbstractDevCmd {
}
if (target != null)
if (target.getObjectType() == GameObjectType.Building){
Building parentBuilding = (Building)target;
if (target.getObjectType() == GameObjectType.Building) {
Building parentBuilding = (Building) target;
BuildingManager.addHirelingForWorld(parentBuilding, pc, parentBuilding.getLoc(), parentBuilding.getParentZone(), contract, level);
return;
}

36
src/engine/devcmd/cmds/ApplyBonusCmd.java

@ -38,36 +38,36 @@ public class ApplyBonusCmd extends AbstractDevCmd { @@ -38,36 +38,36 @@ public class ApplyBonusCmd extends AbstractDevCmd {
PowerActionType actionType = null;
HashMap<String,HashSet<String>> appliedMods = new HashMap<>();
HashMap<String, HashSet<String>> appliedMods = new HashMap<>();
try{
try {
if (action.equals("all") == false)
for (PowerActionType powerActionType : PowerActionType.values()){
for (PowerActionType powerActionType : PowerActionType.values()) {
if (powerActionType.name().equalsIgnoreCase(action) == false)
continue;
actionType = powerActionType;
break;
}
}catch(Exception e){
} catch (Exception e) {
this.throwbackError(pcSender, "Invalid power Action type for " + action);
this.throwbackInfo(pcSender, "Valid Types : " + this.getActionTypes());
return;
}
if (action.equals("all") == false)
if (actionType == null){
if (actionType == null) {
this.throwbackError(pcSender, "Invalid power Action type for " + action);
this.throwbackInfo(pcSender, "Valid Types : " + this.getActionTypes());
return;
}
for (PowersBase pb : PowersManager.powersBaseByIDString.values()){
for (PowersBase pb : PowersManager.powersBaseByIDString.values()) {
if (pb.getActions() == null || pb.getActions().isEmpty())
continue;
for (ActionsBase ab: pb.getActions()){
for (ActionsBase ab : pb.getActions()) {
if (ab.getPowerAction() == null)
continue;
if (action.equals("all") == false)
@ -75,8 +75,8 @@ public class ApplyBonusCmd extends AbstractDevCmd { @@ -75,8 +75,8 @@ public class ApplyBonusCmd extends AbstractDevCmd {
continue;
String effect1 = "";
String effect2 = "";
ChatManager.chatSystemInfo(pcSender,"Applying Power " + pb.getName() + " : " +pb.getDescription());
if (ab.getPowerAction().getEffectsBase() == null){
ChatManager.chatSystemInfo(pcSender, "Applying Power " + pb.getName() + " : " + pb.getDescription());
if (ab.getPowerAction().getEffectsBase() == null) {
try {
PowersManager.runPowerAction(pcSender, pcSender, pcSender.getLoc(), ab, 1, pb);
@ -89,7 +89,7 @@ public class ApplyBonusCmd extends AbstractDevCmd { @@ -89,7 +89,7 @@ public class ApplyBonusCmd extends AbstractDevCmd {
}
if (ab.getPowerAction().getEffectsBase().getModifiers() == null || ab.getPowerAction().getEffectsBase().getModifiers().isEmpty()){
if (ab.getPowerAction().getEffectsBase().getModifiers() == null || ab.getPowerAction().getEffectsBase().getModifiers().isEmpty()) {
try {
PowersManager.runPowerAction(pcSender, pcSender, pcSender.getLoc(), ab, 1, pb);
} catch (Exception e) {
@ -100,8 +100,8 @@ public class ApplyBonusCmd extends AbstractDevCmd { @@ -100,8 +100,8 @@ public class ApplyBonusCmd extends AbstractDevCmd {
}
boolean run = true;
for (AbstractEffectModifier mod : ab.getPowerAction().getEffectsBase().getModifiers()){
if (appliedMods.containsKey(mod.modType.name()) == false){
for (AbstractEffectModifier mod : ab.getPowerAction().getEffectsBase().getModifiers()) {
if (appliedMods.containsKey(mod.modType.name()) == false) {
appliedMods.put(mod.modType.name(), new HashSet<>());
}
@ -110,7 +110,7 @@ public class ApplyBonusCmd extends AbstractDevCmd { @@ -110,7 +110,7 @@ public class ApplyBonusCmd extends AbstractDevCmd {
// }
appliedMods.get(mod.modType.name()).add(mod.sourceType.name());
try{
try {
try {
PowersManager.runPowerAction(pcSender, pcSender, pcSender.getLoc(), ab, 1, pb);
} catch (Exception e) {
@ -118,14 +118,12 @@ public class ApplyBonusCmd extends AbstractDevCmd { @@ -118,14 +118,12 @@ public class ApplyBonusCmd extends AbstractDevCmd {
e.printStackTrace();
}
}catch(Exception e){
} catch (Exception e) {
Logger.error(e);
}
break;
}
}
@ -144,15 +142,15 @@ public class ApplyBonusCmd extends AbstractDevCmd { @@ -144,15 +142,15 @@ public class ApplyBonusCmd extends AbstractDevCmd {
}
private String getActionTypes(){
private String getActionTypes() {
String output = "";
for (PowerActionType actionType : PowerActionType.values()){
for (PowerActionType actionType : PowerActionType.values()) {
output += actionType.name() + " | ";
}
return output.substring(0, output.length() -3);
return output.substring(0, output.length() - 3);
}
}

47
src/engine/devcmd/cmds/ApplyStatModCmd.java

@ -21,28 +21,26 @@ import engine.powers.PowersBase; @@ -21,28 +21,26 @@ 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) {
if(args.length < 1) {
if (args.length < 1) {
// if(args.length < 2) {
this.sendUsage(pcSender);
return;
}
if(!(target instanceof AbstractCharacter)) {
if (!(target instanceof AbstractCharacter)) {
this.sendHelp(pcSender);
return;
}
@ -51,7 +49,7 @@ public class ApplyStatModCmd extends AbstractDevCmd { @@ -51,7 +49,7 @@ public class ApplyStatModCmd extends AbstractDevCmd {
int spellID;
int powerAction = 0;
if (args[0].toLowerCase().contains("all")){
if (args[0].toLowerCase().contains("all")) {
int amount = 0;
if (args.length == 1) {
@ -59,7 +57,7 @@ public class ApplyStatModCmd extends AbstractDevCmd { @@ -59,7 +57,7 @@ public class ApplyStatModCmd extends AbstractDevCmd {
ApplyStatModCmd.cnt++;
} else {
amount = Integer.valueOf(args[1]);
ApplyStatModCmd.cnt = amount+1;
ApplyStatModCmd.cnt = amount + 1;
}
@ -72,43 +70,40 @@ public class ApplyStatModCmd extends AbstractDevCmd { @@ -72,43 +70,40 @@ public class ApplyStatModCmd extends AbstractDevCmd {
pbList.add(PowersManager.getPowerByToken(431081336));
for (PowersBase pb:pbList){
if(amount <= 0) {
if (pb.getToken() ==428677994)
for (PowersBase pb : pbList) {
if (amount <= 0) {
if (pb.getToken() == 428677994)
powerAction = 1;
PowersManager.removeEffect(pcSender, pb.getActions().get(powerAction), false, false);
continue;
} else if(amount > 9999 || amount < 21) {
} else if (amount > 9999 || amount < 21) {
ChatManager.chatSystemInfo(pcSender, "Amount must be between 21 and 9999 inclusive.");
return;
}
if (pb.getToken() ==428677994){
if (pb.getToken() == 428677994) {
PowersManager.removeEffect(pcSender, pb.getActions().get(powerAction), false, false);
PowersManager.runPowerAction(pcSender, pcSender, Vector3fImmutable.ZERO, pb.getActions().get(powerAction), amount - 20, pb);
}
if (pb.getToken() ==428677994)
if (pb.getToken() == 428677994)
powerAction = 1;
PowersManager.removeEffect(pcSender, pb.getActions().get(powerAction), false, false);
PowersManager.runPowerAction(pcSender, pcSender, Vector3fImmutable.ZERO, pb.getActions().get(powerAction), amount - 20, pb);
}
return;
}
if(args[0].toLowerCase().contains("con")) {
if (args[0].toLowerCase().contains("con")) {
spellID = 429047968; //Blessing of Health
} else if(args[0].toLowerCase().contains("str")) {
} else if (args[0].toLowerCase().contains("str")) {
spellID = 429768864; //Blessing of Might
} else if(args[0].toLowerCase().contains("dex")) {
} else if (args[0].toLowerCase().contains("dex")) {
spellID = 428458144; //Blessing of Dexterity
} else if(args[0].toLowerCase().contains("int")) {
} else if (args[0].toLowerCase().contains("int")) {
spellID = 428677994; //Bard Spi - TODO
powerAction = 1;
} else if(args[0].toLowerCase().contains("spi")) {
} else if (args[0].toLowerCase().contains("spi")) {
spellID = 428677994; //Bard Spi
} else{
} else {
ChatManager.chatSystemInfo(pcSender, "No valid stat found.");
return;
}
@ -121,13 +116,13 @@ public class ApplyStatModCmd extends AbstractDevCmd { @@ -121,13 +116,13 @@ public class ApplyStatModCmd extends AbstractDevCmd {
ApplyStatModCmd.cnt++;
} else {
amount = Integer.valueOf(args[1]);
ApplyStatModCmd.cnt = amount+1;
ApplyStatModCmd.cnt = amount + 1;
}
// int amount = Integer.valueOf(args[1]);
if(amount <= 0) {
if (amount <= 0) {
PowersManager.removeEffect(pcSender, pb.getActions().get(powerAction), false, false);
return;
} else if(amount > 9999 || amount < 21) {
} else if (amount > 9999 || amount < 21) {
ChatManager.chatSystemInfo(pcSender, "Amount must be between 21 and 9999 inclusive.");
return;
}

35
src/engine/devcmd/cmds/AuditFailedItemsCmd.java

@ -29,7 +29,6 @@ public class AuditFailedItemsCmd extends AbstractDevCmd { @@ -29,7 +29,6 @@ public class AuditFailedItemsCmd extends AbstractDevCmd {
AbstractGameObject target) {
if (ItemProductionManager.FailedItems.isEmpty())
return;
@ -38,10 +37,10 @@ public class AuditFailedItemsCmd extends AbstractDevCmd { @@ -38,10 +37,10 @@ public class AuditFailedItemsCmd extends AbstractDevCmd {
String newLine = "\r\n";
String auditFailedItem = "Failed Item Name | Prefix | Suffix | NPC | Contract | Player | ";
for (ProducedItem failedItem: ItemProductionManager.FailedItems){
for (ProducedItem failedItem : ItemProductionManager.FailedItems) {
String npcName = "";
String playerName ="";
String playerName = "";
String contractName = "";
String prefix = "";
@ -49,10 +48,10 @@ public class AuditFailedItemsCmd extends AbstractDevCmd { @@ -49,10 +48,10 @@ public class AuditFailedItemsCmd extends AbstractDevCmd {
String itemName = "";
NPC npc = NPC.getFromCache(failedItem.getNpcUID());
if (npc == null){
if (npc == null) {
npcName = "null";
contractName = "null";
}else{
} else {
npcName = npc.getName();
if (npc.getContract() != null)
contractName = npc.getContract().getName();
@ -67,16 +66,16 @@ public class AuditFailedItemsCmd extends AbstractDevCmd { @@ -67,16 +66,16 @@ public class AuditFailedItemsCmd extends AbstractDevCmd {
ItemBase ib = ItemBase.getItemBase(failedItem.getItemBaseID());
if (ib != null){
if (ib != null) {
itemName = ib.getName();
}
if (failedItem.isRandom() == false){
if (failedItem.getPrefix().isEmpty() == false){
if (failedItem.isRandom() == false) {
if (failedItem.getPrefix().isEmpty() == false) {
AbstractPowerAction pa = PowersManager.getPowerActionByIDString(failedItem.getPrefix());
if (pa != null){
for (AbstractEffectModifier aem : pa.getEffectsBase().getModifiers()){
if (aem.modType.equals(ModType.ItemName)){
if (pa != null) {
for (AbstractEffectModifier aem : pa.getEffectsBase().getModifiers()) {
if (aem.modType.equals(ModType.ItemName)) {
prefix = aem.getString1();
break;
}
@ -85,11 +84,11 @@ public class AuditFailedItemsCmd extends AbstractDevCmd { @@ -85,11 +84,11 @@ public class AuditFailedItemsCmd extends AbstractDevCmd {
}
if (failedItem.getSuffix().isEmpty() == false){
if (failedItem.getSuffix().isEmpty() == false) {
AbstractPowerAction pa = PowersManager.getPowerActionByIDString(failedItem.getSuffix());
if (pa != null){
for (AbstractEffectModifier aem : pa.getEffectsBase().getModifiers()){
if (aem.modType.equals(ModType.ItemName)){
if (pa != null) {
for (AbstractEffectModifier aem : pa.getEffectsBase().getModifiers()) {
if (aem.modType.equals(ModType.ItemName)) {
suffix = aem.getString1();
break;
}
@ -98,15 +97,13 @@ public class AuditFailedItemsCmd extends AbstractDevCmd { @@ -98,15 +97,13 @@ public class AuditFailedItemsCmd extends AbstractDevCmd {
}
}else{
} else {
prefix = "random";
}
auditFailedItem += newLine;
auditFailedItem += itemName + " | "+prefix + " | "+suffix + " | "+ failedItem.getNpcUID() + ":" +npcName + " | "+contractName + " | "+failedItem.getPlayerID() + ":" +playerName;
auditFailedItem += itemName + " | " + prefix + " | " + suffix + " | " + failedItem.getNpcUID() + ":" + npcName + " | " + contractName + " | " + failedItem.getPlayerID() + ":" + playerName;
}
Logger.info(auditFailedItem);

7
src/engine/devcmd/cmds/AuditHeightMapCmd.java

@ -30,18 +30,17 @@ public class AuditHeightMapCmd extends AbstractDevCmd { @@ -30,18 +30,17 @@ public class AuditHeightMapCmd extends AbstractDevCmd {
int count = Integer.parseInt(words[0]);
long start = System.currentTimeMillis();
for (int i = 0; i<count;i++){
for (int i = 0; i < count; i++) {
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 );
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);
if (currentZone != null && currentZone.getHeightMap() != null){
if (currentZone != null && currentZone.getHeightMap() != null) {
float altitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
float outsetAltitude = HeightMap.getOutsetHeight(altitude, currentZone, pcSender.getLoc());
}

15
src/engine/devcmd/cmds/AuditMobsCmd.java

@ -24,20 +24,21 @@ public class AuditMobsCmd extends AbstractDevCmd { @@ -24,20 +24,21 @@ 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
Zone zone;
if (words.length == 2){
if (words[0].equals("all")){
if (words.length == 2) {
if (words[0].equals("all")) {
int plusplus = 0;
int count = Integer.parseInt(words[1]);
for (Zone zoneMicro: ZoneManager.getAllZones()){
for (Zone zoneMicro : ZoneManager.getAllZones()) {
int size = zoneMicro.zoneMobSet.size();
if (size >= count){
if (size >= count) {
plusplus++;
throwbackInfo(pcSender, zoneMicro.getName() + " at location " + zoneMicro.getLoc().toString() + " has " + size + " mobs. ");
System.out.println(zoneMicro.getName() + " at location " + zoneMicro.getLoc().toString() + " has " + size + " mobs. ");
@ -45,7 +46,7 @@ public class AuditMobsCmd extends AbstractDevCmd { @@ -45,7 +46,7 @@ public class AuditMobsCmd extends AbstractDevCmd {
}
throwbackInfo(pcSender," there are " +plusplus + " zones with at least " + count + " mobs in each.");
throwbackInfo(pcSender, " there are " + plusplus + " zones with at least " + count + " mobs in each.");
}
return;
}
@ -83,12 +84,10 @@ public class AuditMobsCmd extends AbstractDevCmd { @@ -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;
}

14
src/engine/devcmd/cmds/BoundsCmd.java

@ -24,14 +24,14 @@ public class BoundsCmd extends AbstractDevCmd { @@ -24,14 +24,14 @@ public class BoundsCmd extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pcSender, String[] words,
AbstractGameObject target) {
if (target == null || !target.getObjectType().equals(GameObjectType.Building)){
if (target == null || !target.getObjectType().equals(GameObjectType.Building)) {
this.throwbackError(pcSender, "No Building Selected");
return;
}
Building building = (Building)target;
Building building = (Building) target;
if (building.getBounds() == null){
if (building.getBounds() == null) {
this.throwbackInfo(pcSender, "No valid Bounds for building UUID " + building.getObjectUUID());
return;
}
@ -52,10 +52,10 @@ public class BoundsCmd extends AbstractDevCmd { @@ -52,10 +52,10 @@ public class BoundsCmd extends AbstractDevCmd {
String output = "Bounds Information for Building UUID " + building.getObjectUUID();
output += newLine;
output+= "Top Left : " + topLeftX + " , " + topLeftY + newLine;
output+= "Top Right : " + topRightX + " , " + topRightY + newLine;
output+= "Bottom Left : " + bottomLeftX + " , " + bottomLeftY + newLine;
output+= "Bottom Right : " + bottomRightX + " , " + bottomRightY + newLine;
output += "Top Left : " + topLeftX + " , " + topLeftY + newLine;
output += "Top Right : " + topRightX + " , " + topRightY + newLine;
output += "Bottom Left : " + bottomLeftX + " , " + bottomLeftY + newLine;
output += "Bottom Right : " + bottomRightX + " , " + bottomRightY + newLine;
this.throwbackInfo(pcSender, output);

2
src/engine/devcmd/cmds/ChangeNameCmd.java

@ -39,7 +39,7 @@ public class ChangeNameCmd extends AbstractDevCmd { @@ -39,7 +39,7 @@ public class ChangeNameCmd extends AbstractDevCmd {
String newLast = "";
if (words.length > 2) {
newLast = words[2];
for (int i=3; i<words.length; i++)
for (int i = 3; i < words.length; i++)
newLast += ' ' + words[i];
}

5
src/engine/devcmd/cmds/CombatMessageCmd.java

@ -7,9 +7,6 @@ @@ -7,9 +7,6 @@
// www.magicbane.com
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
@ -27,9 +24,7 @@ import engine.objects.AbstractGameObject; @@ -27,9 +24,7 @@ import engine.objects.AbstractGameObject;
import engine.objects.PlayerCharacter;
/**
*
* @author Eighty
*
*/
public class CombatMessageCmd extends AbstractDevCmd {

5
src/engine/devcmd/cmds/CreateItemCmd.java

@ -17,7 +17,6 @@ import engine.objects.PlayerCharacter; @@ -17,7 +17,6 @@ import engine.objects.PlayerCharacter;
/**
* @author Eighty
*
*/
public class CreateItemCmd extends AbstractDevCmd {
@ -37,14 +36,14 @@ public class CreateItemCmd extends AbstractDevCmd { @@ -37,14 +36,14 @@ public class CreateItemCmd extends AbstractDevCmd {
if (id == 0)
id = Integer.parseInt(words[0]);
if (id == 7){
if (id == 7) {
this.throwbackInfo(pc, "use /addgold to add gold.....");
return;
}
int size = 1;
if(words.length < 3) {
if (words.length < 3) {
size = Integer.parseInt(words[1]);
}

17
src/engine/devcmd/cmds/DebugCmd.java

@ -17,12 +17,19 @@ import engine.objects.PlayerCharacter; @@ -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 { @@ -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);
}
}

1
src/engine/devcmd/cmds/DebugMeleeSyncCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd;

4
src/engine/devcmd/cmds/DecachePlayerCmd.java

@ -27,13 +27,13 @@ public class DecachePlayerCmd extends AbstractDevCmd { @@ -27,13 +27,13 @@ public class DecachePlayerCmd extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) {
if(words.length < 1) {
if (words.length < 1) {
this.sendUsage(pc);
}
int objectUUID = Integer.parseInt(words[0]);
if(DbManager.inCache(Enum.GameObjectType.PlayerCharacter, objectUUID)) {
if (DbManager.inCache(Enum.GameObjectType.PlayerCharacter, objectUUID)) {
this.setTarget(PlayerCharacter.getFromCache(objectUUID)); //for logging
PlayerCharacter.getFromCache(objectUUID).removeFromCache();
} else {

13
src/engine/devcmd/cmds/DespawnCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
@ -27,21 +26,15 @@ public class DespawnCmd extends AbstractDevCmd { @@ -27,21 +26,15 @@ public class DespawnCmd extends AbstractDevCmd {
AbstractGameObject target) {
if (pc == null) {
return;
}
Mob mob = null;
if (target != null && target.getObjectType().equals(GameObjectType.Mob))
mob = (Mob)target;
mob = (Mob) target;
if (mob == null)
mob = Mob.getFromCache(Integer.parseInt(words[1]));
@ -49,10 +42,10 @@ public class DespawnCmd extends AbstractDevCmd { @@ -49,10 +42,10 @@ public class DespawnCmd extends AbstractDevCmd {
if (mob == null)
return;
if (words[0].equalsIgnoreCase("respawn")){
if (words[0].equalsIgnoreCase("respawn")) {
mob.respawn();
this.throwbackInfo(pc, "Mob with ID " + mob.getObjectUUID() + " Respawned");
}else if (words[0].equalsIgnoreCase("despawn")){
} else if (words[0].equalsIgnoreCase("despawn")) {
mob.despawn();
this.throwbackInfo(pc, "Mob with ID " + mob.getObjectUUID() + " Despawned");
}

5
src/engine/devcmd/cmds/DistanceCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd;
@ -27,8 +26,6 @@ public class DistanceCmd extends AbstractDevCmd { @@ -27,8 +26,6 @@ public class DistanceCmd extends AbstractDevCmd {
AbstractGameObject target) {
// Arg Count Check
if (words.length != 1) {
this.sendUsage(pc);
@ -43,7 +40,7 @@ public class DistanceCmd extends AbstractDevCmd { @@ -43,7 +40,7 @@ public class DistanceCmd extends AbstractDevCmd {
return;
}
AbstractWorldObject awoTarget = (AbstractWorldObject)target;
AbstractWorldObject awoTarget = (AbstractWorldObject) target;
Vector3fImmutable pcLoc = pc.getLoc();
Vector3fImmutable tarLoc = awoTarget.getLoc();

2
src/engine/devcmd/cmds/EffectCmd.java

@ -17,9 +17,7 @@ import engine.objects.PlayerCharacter; @@ -17,9 +17,7 @@ import engine.objects.PlayerCharacter;
import engine.powers.EffectsBase;
/**
*
* @author Eighty
*
*/
public class EffectCmd extends AbstractDevCmd {

13
src/engine/devcmd/cmds/EnchantCmd.java

@ -28,14 +28,13 @@ public class EnchantCmd extends AbstractDevCmd { @@ -28,14 +28,13 @@ public class EnchantCmd extends AbstractDevCmd {
}
try{
try {
rank = Integer.parseInt(words[0]);
}catch(Exception e){
} catch (Exception e) {
}
Item item;
if (target == null || target instanceof Item)
item = (Item) target;
@ -56,12 +55,12 @@ public class EnchantCmd extends AbstractDevCmd { @@ -56,12 +55,12 @@ public class EnchantCmd extends AbstractDevCmd {
this.setResult(String.valueOf(item.getObjectUUID()));
} else {
int cnt = words.length;
for (int i=1;i<cnt;i++) {
for (int i = 1; i < cnt; i++) {
String enchant = words[i];
boolean valid = true;
for (Effect eff: item.getEffects().values()){
if (eff.getEffectsBase().getIDString().equals(enchant)){
throwbackError(pc,"This item already has that enchantment");
for (Effect eff : item.getEffects().values()) {
if (eff.getEffectsBase().getIDString().equals(enchant)) {
throwbackError(pc, "This item already has that enchantment");
return;
}
}

3
src/engine/devcmd/cmds/FlashMsgCmd.java

@ -15,9 +15,7 @@ import engine.objects.AbstractGameObject; @@ -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 { @@ -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

5
src/engine/devcmd/cmds/GateInfoCmd.java

@ -23,7 +23,7 @@ public class GateInfoCmd extends AbstractDevCmd { @@ -23,7 +23,7 @@ public class GateInfoCmd extends AbstractDevCmd {
Runegate runeGate;
Blueprint blueprint;
String newline = "\r\n ";
targetBuilding = (Building)target;
targetBuilding = (Building) target;
if (targetBuilding.getObjectType() != GameObjectType.Building) {
throwbackInfo(player, "GateInfo: target must be a Building");
@ -34,7 +34,7 @@ public class GateInfoCmd extends AbstractDevCmd { @@ -34,7 +34,7 @@ public class GateInfoCmd extends AbstractDevCmd {
blueprint = Blueprint._meshLookup.get(targetBuilding.getMeshUUID());
if (blueprint == null ||
(blueprint.getBuildingGroup() != BuildingGroup.RUNEGATE)){
(blueprint.getBuildingGroup() != BuildingGroup.RUNEGATE)) {
throwbackInfo(player, "showgate: target must be a Runegate");
return;
}
@ -81,5 +81,4 @@ public class GateInfoCmd extends AbstractDevCmd { @@ -81,5 +81,4 @@ public class GateInfoCmd extends AbstractDevCmd {
}
}

8
src/engine/devcmd/cmds/GetBankCmd.java

@ -17,9 +17,7 @@ import engine.objects.AbstractGameObject; @@ -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 { @@ -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

41
src/engine/devcmd/cmds/GetHeightCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.InterestManagement.HeightMap;
@ -41,7 +40,7 @@ public class GetHeightCmd extends AbstractDevCmd { @@ -41,7 +40,7 @@ public class GetHeightCmd extends AbstractDevCmd {
Zone zone = ZoneManager.findSmallestZone(pc.getLoc());
this.throwbackInfo(pc, "Water Level : " + zone.getSeaLevel());
this.throwbackInfo(pc, "Character Water Level Above : " + (pc.getCharacterHeight() + height - zone.getSeaLevel()) );
this.throwbackInfo(pc, "Character Water Level Above : " + (pc.getCharacterHeight() + height - zone.getSeaLevel()));
if (end)
return;
@ -62,9 +61,9 @@ public class GetHeightCmd extends AbstractDevCmd { @@ -62,9 +61,9 @@ public class GetHeightCmd extends AbstractDevCmd {
//find the next parents heightmap if the currentzone heightmap is null.
while (heightMap == null){
while (heightMap == null) {
if (currentZone == ZoneManager.getSeaFloor()){
if (currentZone == ZoneManager.getSeaFloor()) {
this.throwbackInfo(pc, "Could not find a heightmap to get height.");
break;
}
@ -76,9 +75,9 @@ public class GetHeightCmd extends AbstractDevCmd { @@ -76,9 +75,9 @@ public class GetHeightCmd extends AbstractDevCmd {
}
if ( (heightMap == null) || (currentZone == ZoneManager.getSeaFloor()) ) {
this.throwbackInfo(pc, currentZone.getName() + " has no heightmap " );
this.throwbackInfo(pc, "Current altitude: " + currentZone.absY );
if ((heightMap == null) || (currentZone == ZoneManager.getSeaFloor())) {
this.throwbackInfo(pc, currentZone.getName() + " has no heightmap ");
this.throwbackInfo(pc, "Current altitude: " + currentZone.absY);
return;
}
@ -88,8 +87,6 @@ public class GetHeightCmd extends AbstractDevCmd { @@ -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());
@ -99,10 +96,11 @@ public class GetHeightCmd extends AbstractDevCmd { @@ -99,10 +96,11 @@ public class GetHeightCmd extends AbstractDevCmd {
Vector2f parentZoneLoc = ZoneManager.worldToZoneSpace(pc.getLoc(), currentZone.getParent());
this.throwbackInfo(pc, "Parent Zone Location from Bottom Left : " + parentZoneLoc);
if ((parentZone != null ) && (parentZone.getHeightMap() != null)) {
if ((parentZone != null) && (parentZone.getHeightMap() != null)) {
parentLoc = ZoneManager.worldToZoneSpace(pc.getLoc(), parentZone);
parentGrid = parentZone.getHeightMap().getGridSquare( parentLoc);
} else parentGrid = new Vector2f(-1,-1);
parentGrid = parentZone.getHeightMap().getGridSquare(parentLoc);
} else
parentGrid = new Vector2f(-1, -1);
gridSquare = heightMap.getGridSquare(zoneLoc);
gridOffset = HeightMap.getGridOffset(gridSquare);
@ -110,7 +108,7 @@ public class GetHeightCmd extends AbstractDevCmd { @@ -110,7 +108,7 @@ public class GetHeightCmd extends AbstractDevCmd {
float interaltitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
this.throwbackInfo(pc, currentZone.getName());
this.throwbackInfo(pc, "Current Grid Square: " + gridSquare.x + " , " + gridSquare.y );
this.throwbackInfo(pc, "Current Grid Square: " + gridSquare.x + " , " + gridSquare.y);
this.throwbackInfo(pc, "Grid Offset: " + gridOffset.x + " , " + gridOffset.y);
this.throwbackInfo(pc, "Parent Grid: " + parentGrid.x + " , " + parentGrid.y);
@ -126,15 +124,15 @@ public class GetHeightCmd extends AbstractDevCmd { @@ -126,15 +124,15 @@ public class GetHeightCmd extends AbstractDevCmd {
float realWorldAltitude = interaltitude + currentZone.getWorldAltitude();
//OUTSET
if (parentZone != null){
if (parentZone != null) {
float parentXRadius = currentZone.getBounds().getHalfExtents().x;
float parentZRadius = currentZone.getBounds().getHalfExtents().y;
float offsetX = Math.abs((localLocFromCenter.x / parentXRadius));
float offsetZ = Math.abs((localLocFromCenter.z / parentZRadius));
float bucketScaleX = 100/parentXRadius;
float bucketScaleZ = 200/parentZRadius;
float bucketScaleX = 100 / parentXRadius;
float bucketScaleZ = 200 / parentZRadius;
float outsideGridSizeX = 1 - bucketScaleX; //32/256
float outsideGridSizeZ = 1 - bucketScaleZ;
@ -143,7 +141,7 @@ public class GetHeightCmd extends AbstractDevCmd { @@ -143,7 +141,7 @@ public class GetHeightCmd extends AbstractDevCmd {
double scale;
if (offsetX > outsideGridSizeX && offsetX > offsetZ){
if (offsetX > outsideGridSizeX && offsetX > offsetZ) {
weight = (offsetX - outsideGridSizeX) / bucketScaleX;
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
@ -164,7 +162,7 @@ public class GetHeightCmd extends AbstractDevCmd { @@ -164,7 +162,7 @@ public class GetHeightCmd extends AbstractDevCmd {
outsetALt += currentZone.getParent().getAbsY();
realWorldAltitude = outsetALt;
}else if (offsetZ > outsideGridSizeZ){
} else if (offsetZ > outsideGridSizeZ) {
weight = (offsetZ - outsideGridSizeZ) / bucketScaleZ;
scale = Math.atan2((.5 - weight) * 3.1415927, 1);
@ -184,8 +182,6 @@ public class GetHeightCmd extends AbstractDevCmd { @@ -184,8 +182,6 @@ public class GetHeightCmd extends AbstractDevCmd {
realWorldAltitude = outsetALt;
}
}
@ -196,7 +192,7 @@ public class GetHeightCmd extends AbstractDevCmd { @@ -196,7 +192,7 @@ public class GetHeightCmd extends AbstractDevCmd {
strMod += 1f;
float radius = 0;
switch (pc.getRaceID()){
switch (pc.getRaceID()) {
case 2017:
radius = 3.1415927f;
case 2000:
@ -210,14 +206,11 @@ public class GetHeightCmd extends AbstractDevCmd { @@ -210,14 +206,11 @@ public class GetHeightCmd extends AbstractDevCmd {
strMod -= .5f;
realWorldAltitude += strMod;
this.throwbackInfo(pc, "interpolated height with World: " + realWorldAltitude);
}
@Override

27
src/engine/devcmd/cmds/GetMemoryCmd.java

@ -19,19 +19,6 @@ public class GetMemoryCmd extends AbstractDevCmd { @@ -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 { @@ -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'";

7
src/engine/devcmd/cmds/GetMobBaseLoot.java

@ -18,7 +18,6 @@ import engine.objects.PlayerCharacter; @@ -18,7 +18,6 @@ import engine.objects.PlayerCharacter;
/**
* @author Eighty
*
*/
public class GetMobBaseLoot extends AbstractDevCmd {
@ -29,14 +28,14 @@ public class GetMobBaseLoot extends AbstractDevCmd { @@ -29,14 +28,14 @@ public class GetMobBaseLoot extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) {
if (target.getObjectType() != GameObjectType.Mob){
if (target.getObjectType() != GameObjectType.Mob) {
this.throwbackError(pc, "Must be targeting a Valid Mob For this Command.");
return;
}
Mob mob = (Mob)target;
for (MobLootBase mlb : MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID())){
Mob mob = (Mob) target;
for (MobLootBase mlb : MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID())) {
this.throwbackInfo(pc, "LootTable11 = " + mlb.getLootTableID() + "\rn ");
this.throwbackInfo(pc, "Chance = " + mlb.getChance() + "\rn ");

3
src/engine/devcmd/cmds/GetOffsetCmd.java

@ -24,7 +24,8 @@ public class GetOffsetCmd extends AbstractDevCmd { @@ -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 {

3
src/engine/devcmd/cmds/GetRuneDropRateCmd.java

@ -23,7 +23,8 @@ public class GetRuneDropRateCmd extends AbstractDevCmd { @@ -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);

6
src/engine/devcmd/cmds/GetVaultCmd.java

@ -25,10 +25,12 @@ public class GetVaultCmd extends AbstractDevCmd { @@ -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

3
src/engine/devcmd/cmds/GetZoneCmd.java

@ -26,7 +26,8 @@ public class GetZoneCmd extends AbstractDevCmd { @@ -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);

6
src/engine/devcmd/cmds/GetZoneMobsCmd.java

@ -25,13 +25,15 @@ public class GetZoneMobsCmd extends AbstractDevCmd { @@ -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

17
src/engine/devcmd/cmds/GotoBoundsCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
@ -30,27 +29,27 @@ public class GotoBoundsCmd extends AbstractDevCmd { @@ -30,27 +29,27 @@ public class GotoBoundsCmd extends AbstractDevCmd {
String corner = words[0];
Vector3fImmutable targetLoc = Vector3fImmutable.ZERO;
if (target == null || !target.getObjectType().equals(GameObjectType.Building)){
if (target == null || !target.getObjectType().equals(GameObjectType.Building)) {
this.throwbackError(player, "No Building Selected");
return;
}
Building building = (Building)target;
Building building = (Building) target;
if (building.getBounds() == null){
if (building.getBounds() == null) {
this.throwbackInfo(player, "No valid Bounds for building UUID " + building.getObjectUUID());
return;
}
float x = building.getBounds().getHalfExtents().x;
float z = building.getBounds().getHalfExtents().y;
if (building.getBlueprint() != null){
if (building.getBlueprint() != null) {
x = building.getBlueprint().getExtents().x;
z = building.getBlueprint().getExtents().y;
}
float topLeftX = building.getLoc().x - x;
float topLeftY = building.getLoc().z -z;
float topLeftY = building.getLoc().z - z;
float topRightX = building.getLoc().x + x;
float topRightY = building.getLoc().z - z;
@ -58,11 +57,11 @@ public class GotoBoundsCmd extends AbstractDevCmd { @@ -58,11 +57,11 @@ public class GotoBoundsCmd extends AbstractDevCmd {
float bottomLeftX = building.getLoc().x - x;
float bottomLeftY = building.getLoc().z + z;
float bottomRightX = building.getLoc().x +x;
float bottomRightX = building.getLoc().x + x;
float bottomRightY = building.getLoc().z + z;
switch (corner){
switch (corner) {
case "topleft":
targetLoc = new Vector3fImmutable(topLeftX, 0, topLeftY);
break;
@ -81,7 +80,7 @@ public class GotoBoundsCmd extends AbstractDevCmd { @@ -81,7 +80,7 @@ public class GotoBoundsCmd extends AbstractDevCmd {
}
targetLoc = Vector3fImmutable.transform(building.getLoc(),targetLoc , building.getBounds().getRotationDegrees());
targetLoc = Vector3fImmutable.transform(building.getLoc(), targetLoc, building.getBounds().getRotationDegrees());
// Teleport player

39
src/engine/devcmd/cmds/GotoCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
@ -34,20 +33,20 @@ public class GotoCmd extends AbstractDevCmd { @@ -34,20 +33,20 @@ public class GotoCmd extends AbstractDevCmd {
// Arg Count Check
if (target != null && words[0].isEmpty()){
AbstractWorldObject targetAgo = (AbstractWorldObject)target;
if (target != null && words[0].isEmpty()) {
AbstractWorldObject targetAgo = (AbstractWorldObject) target;
pc.teleport(targetAgo.getLoc());
return;
}
if (words[0].isEmpty()){
if (words[0].isEmpty()) {
this.sendUsage(pc);
return;
}
if (words[0].equalsIgnoreCase("playground")){
if (target instanceof AbstractCharacter){
loc = new Vector3fImmutable(63276,0,-54718);
if (words[0].equalsIgnoreCase("playground")) {
if (target instanceof AbstractCharacter) {
loc = new Vector3fImmutable(63276, 0, -54718);
}
if (loc != null)
@ -56,9 +55,9 @@ public class GotoCmd extends AbstractDevCmd { @@ -56,9 +55,9 @@ public class GotoCmd extends AbstractDevCmd {
return;
}
if (words[0].equalsIgnoreCase("coc")){
if (target instanceof AbstractCharacter){
loc = new Vector3fImmutable(98561.656f,0,-13353.778f);
if (words[0].equalsIgnoreCase("coc")) {
if (target instanceof AbstractCharacter) {
loc = new Vector3fImmutable(98561.656f, 0, -13353.778f);
}
if (loc != null)
@ -68,20 +67,20 @@ public class GotoCmd extends AbstractDevCmd { @@ -68,20 +67,20 @@ public class GotoCmd extends AbstractDevCmd {
}
String cityName = "";
for (String partial: words){
for (String partial : words) {
cityName += partial + ' ';
}
cityName = cityName.substring(0, cityName.length() - 1);
for (AbstractGameObject cityAgo: DbManager.getList(GameObjectType.City)){
City city = (City)cityAgo;
for (AbstractGameObject cityAgo : DbManager.getList(GameObjectType.City)) {
City city = (City) cityAgo;
if (city == null)
continue;
if (!city.getCityName().equalsIgnoreCase(cityName))
continue;
Zone zone = city.getParent();
if (zone != null){
if (zone != null) {
if (zone.isNPCCity() || zone.isPlayerCity())
loc = Vector3fImmutable.getRandomPointOnCircle(zone.getLoc(), MBServerStatics.TREE_TELEPORT_RADIUS);
else
@ -93,14 +92,14 @@ public class GotoCmd extends AbstractDevCmd { @@ -93,14 +92,14 @@ public class GotoCmd extends AbstractDevCmd {
}
}
if (loc == null){
for (AbstractGameObject zoneAgo: DbManager.getList(GameObjectType.Zone)){
Zone zone = (Zone)zoneAgo;
if (loc == null) {
for (AbstractGameObject zoneAgo : DbManager.getList(GameObjectType.Zone)) {
Zone zone = (Zone) zoneAgo;
if (zone == null)
continue;
if (!zone.getName().equalsIgnoreCase(cityName))
continue;
if (zone != null){
if (zone != null) {
if (zone.isNPCCity() || zone.isPlayerCity())
loc = Vector3fImmutable.getRandomPointOnCircle(zone.getLoc(), MBServerStatics.TREE_TELEPORT_RADIUS);
else
@ -112,12 +111,12 @@ public class GotoCmd extends AbstractDevCmd { @@ -112,12 +111,12 @@ public class GotoCmd extends AbstractDevCmd {
}
}
}
if (loc == null && words.length == 1){
if (loc == null && words.length == 1) {
try {
PlayerCharacter pcDest = SessionManager
.getPlayerCharacterByLowerCaseName(words[0]);
if (pcDest == null){
if (pcDest == null) {
this.throwbackError(pc, "Player or Zone not found by name: "
+ words[0]);
this.throwbackInfo(pc, "If you have spaces in the zone name, replace them with '_'");

1
src/engine/devcmd/cmds/GotoObj.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum;

1
src/engine/devcmd/cmds/HeartbeatCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.ai.MobileFSMManager;

2
src/engine/devcmd/cmds/HotzoneCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd;
@ -63,6 +62,7 @@ public class HotzoneCmd extends 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.";

87
src/engine/devcmd/cmds/InfoCmd.java

@ -26,7 +26,6 @@ import java.util.concurrent.ConcurrentHashMap; @@ -26,7 +26,6 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* @author
*
*/
public class InfoCmd extends AbstractDevCmd {
@ -118,7 +117,7 @@ public class InfoCmd extends AbstractDevCmd { @@ -118,7 +117,7 @@ public class InfoCmd extends AbstractDevCmd {
output += ' ' + targetBuilding.getBlueprint().getName();
output += newline;
output += targetBuilding.getBlueprint() != null ? targetBuilding.getBlueprint().getBuildingGroup().name(): " no building group";
output += targetBuilding.getBlueprint() != null ? targetBuilding.getBlueprint().getBuildingGroup().name() : " no building group";
output += newline;
output += "EffectFlags: " + targetBuilding.getEffectFlags();
@ -183,40 +182,40 @@ public class InfoCmd extends AbstractDevCmd { @@ -183,40 +182,40 @@ public class InfoCmd extends AbstractDevCmd {
output += "Nation crest: " + nTag;
}
output+= newline;
output += newline;
if (targetBuilding.getBlueprint() != null){
if (targetBuilding.getBlueprint() != null) {
if(targetBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.MINE){
if (targetBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.MINE) {
Mine mine = Mine.getMineFromTower(targetBuilding.getObjectUUID());
if (mine != null){
output+= newline;
output+= "Mine active: " + mine.getIsActive();
output+= newline;
output+= "Was claimed: " + mine.wasClaimed;
output+= newline;
output+= "Mine Type: "+mine.getMineType().name;
output+= newline;
output+= "Expansion : " + mine.isExpansion();
output+= newline;
output+= "Production type: " +mine.getProduction().name();
if (mine != null) {
output += newline;
output += "Mine active: " + mine.getIsActive();
output += newline;
output += "Was claimed: " + mine.wasClaimed;
output += newline;
output += "Mine Type: " + mine.getMineType().name;
output += newline;
output += "Expansion : " + mine.isExpansion();
output += newline;
output += "Production type: " + mine.getProduction().name();
}
}
output += newline;
if (targetBuilding.maintDateTime != null){
if (targetBuilding.maintDateTime != null) {
output += targetBuilding.maintDateTime.toString();
output+= newline;
output += newline;
}
}
output += "Reserve : " + targetBuilding.reserve;
output+= newline;
output += newline;
output += "Strongbox : " + targetBuilding.getStrongboxValue();
output+= newline;
output += newline;
// List hirelings
@ -235,13 +234,13 @@ public class InfoCmd extends AbstractDevCmd { @@ -235,13 +234,13 @@ public class InfoCmd extends AbstractDevCmd {
}
ArrayList<BuildingRegions> tempList = BuildingRegions._staticRegions.get(targetBuilding.getMeshUUID());
output+= newline;
output+= "Building Regions: Size - " + tempList.size();
output+= newline;
output+= "Building Regions from Bounds: Size - " + targetBuilding.getBounds().getRegions().size();
output+= newline;
output += newline;
output += "Building Regions: Size - " + tempList.size();
output += newline;
output += "Building Regions from Bounds: Size - " + targetBuilding.getBounds().getRegions().size();
output += newline;
for (Regions regions: targetBuilding.getBounds().getRegions()){
for (Regions regions : targetBuilding.getBounds().getRegions()) {
//TODO ADD REGION INFO
}
@ -258,8 +257,8 @@ public class InfoCmd extends AbstractDevCmd { @@ -258,8 +257,8 @@ public class InfoCmd extends AbstractDevCmd {
output += "Race: " + targetPC.getRace().getName();
output += newline;
output += "Safe:" + targetPC.inSafeZone();
output+= newline;
output+= "Experience : " + targetPC.getExp();
output += newline;
output += "Experience : " + targetPC.getExp();
output += newline;
output += "OverFlowExperience : " + targetPC.getOverFlowEXP();
output += newline;
@ -282,13 +281,13 @@ public class InfoCmd extends AbstractDevCmd { @@ -282,13 +281,13 @@ public class InfoCmd extends AbstractDevCmd {
output += newline;
output += "Max Inventory Weight:" + ((int) targetPC.statStrBase * 3);
output += newline;
output += "ALTITUDE :"+ targetPC.getAltitude();
output += "ALTITUDE :" + targetPC.getAltitude();
output += newline;
output += "BuildingID :"+ targetPC.getInBuildingID();
output += "BuildingID :" + targetPC.getInBuildingID();
output += newline;
output += "inBuilding :"+ targetPC.getInBuilding();
output += "inBuilding :" + targetPC.getInBuilding();
output += newline;
output += "inFloor :"+ targetPC.getInFloorID();
output += "inFloor :" + targetPC.getInFloorID();
output += newline;
BaseClass baseClass = targetPC.getBaseClass();
@ -309,12 +308,12 @@ public class InfoCmd extends AbstractDevCmd { @@ -309,12 +308,12 @@ public class InfoCmd extends AbstractDevCmd {
output += "====Guild Info====";
output += newline;
if (targetPC.getGuild() != null){
if (targetPC.getGuild() != null) {
output += "Name: " + targetPC.getGuild().getName();
output += newline;
output += "State: " + targetPC.getGuild().getGuildState();
output += newline;
output += "Realms Owned:" +targetPC.getGuild().getRealmsOwned();
output += "Realms Owned:" + targetPC.getGuild().getRealmsOwned();
output += newline;
output += "====Nation====";
output += newline;
@ -322,9 +321,9 @@ public class InfoCmd extends AbstractDevCmd { @@ -322,9 +321,9 @@ public class InfoCmd extends AbstractDevCmd {
output += newline;
output += "Nation State: " + targetPC.getGuild().getNation().getGuildState();
output += newline;
output += "Realms Owned:" +targetPC.getGuild().getNation().getRealmsOwned();
output += "Realms Owned:" + targetPC.getGuild().getNation().getRealmsOwned();
output += newline;
output += "Guild Rank:" +(GuildStatusController.getRank(targetPC.getGuildStatus()) + targetPC.getGuild().getRealmsOwnedFlag());
output += "Guild Rank:" + (GuildStatusController.getRank(targetPC.getGuildStatus()) + targetPC.getGuild().getRealmsOwnedFlag());
}
output += newline;
@ -426,8 +425,7 @@ 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();
@ -436,10 +434,11 @@ public class InfoCmd extends AbstractDevCmd { @@ -436,10 +434,11 @@ public class InfoCmd extends AbstractDevCmd {
output += newline;
if (targetMob.isPet()) {
output += "isPet: true";
output+= newline;
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();
@ -472,7 +471,7 @@ public class InfoCmd extends AbstractDevCmd { @@ -472,7 +471,7 @@ public class InfoCmd extends AbstractDevCmd {
output += newline;
try {
output += "Parent Zone LoadNum : " + targetMob.getParentZone().getLoadNum();
} catch(Exception ex){
} catch (Exception ex) {
//who cares
}
output += newline;
@ -488,7 +487,7 @@ public class InfoCmd extends AbstractDevCmd { @@ -488,7 +487,7 @@ public class InfoCmd extends AbstractDevCmd {
output += "BuildingID : " + targetMob.building + newline;
output += "Bind Loc : " + targetMob.getBindLoc() + newline;
output += "Curr Loc : " + targetMob.getLoc() + newline;
}else{
} else {
output += newline;
output += "No building found.";
}
@ -516,8 +515,8 @@ public class InfoCmd extends AbstractDevCmd { @@ -516,8 +515,8 @@ public class InfoCmd extends AbstractDevCmd {
ConcurrentHashMap<String, Effect> effects = item.getEffects();
for (String name : effects.keySet()) {
Effect eff = effects.get(name);
output+= eff.getEffectsBase().getIDString();
output+= newline;
output += eff.getEffectsBase().getIDString();
output += newline;
// output += eff.getEffectToken() + (eff.bakedInStat() ? " (baked in)" : "") + newline;
}

2
src/engine/devcmd/cmds/JumpCmd.java

@ -31,7 +31,7 @@ public class JumpCmd extends AbstractDevCmd { @@ -31,7 +31,7 @@ public class JumpCmd extends AbstractDevCmd {
//test
if (words[0].equalsIgnoreCase("face")){
if (words[0].equalsIgnoreCase("face")) {
try {
float range = Float.parseFloat(words[1]);

18
src/engine/devcmd/cmds/MBDropCmd.java

@ -16,9 +16,7 @@ import engine.objects.LootTable; @@ -16,9 +16,7 @@ import engine.objects.LootTable;
import engine.objects.PlayerCharacter;
/**
*
* @author Eighty
*
*/
public class MBDropCmd extends AbstractDevCmd {
@ -30,14 +28,14 @@ public class MBDropCmd extends AbstractDevCmd { @@ -30,14 +28,14 @@ public class MBDropCmd extends AbstractDevCmd {
protected void _doCmd(PlayerCharacter pcSender, String[] args,
AbstractGameObject target) {
String newline = "\r\n ";
if (args.length != 1){
if (args.length != 1) {
this.sendUsage(pcSender);
this.sendHelp(pcSender);
return;
}
String output = "";
switch (args[0].toLowerCase()){
switch (args[0].toLowerCase()) {
case "clear":
LootTable.contractCount = 0;
@ -55,7 +53,7 @@ public class MBDropCmd extends AbstractDevCmd { @@ -55,7 +53,7 @@ public class MBDropCmd extends AbstractDevCmd {
break;
case "all":
output = LootTable.dropCount + " items - ITEM NAME : DROP COUNT" + newline;
for (ItemBase ib: LootTable.itemsDroppedMap.keySet()){
for (ItemBase ib : LootTable.itemsDroppedMap.keySet()) {
int dropCount = LootTable.itemsDroppedMap.get(ib);
output += ib.getName() + " : " + dropCount + newline;
@ -64,7 +62,7 @@ public class MBDropCmd extends AbstractDevCmd { @@ -64,7 +62,7 @@ public class MBDropCmd extends AbstractDevCmd {
break;
case "resource":
output = LootTable.resourceCount + " Resources - ITEM NAME : DROP COUNT" + newline;
for (ItemBase ib: LootTable.resourceDroppedMap.keySet()){
for (ItemBase ib : LootTable.resourceDroppedMap.keySet()) {
int dropCount = LootTable.resourceDroppedMap.get(ib);
output += ib.getName() + " : " + dropCount + newline;
@ -75,7 +73,7 @@ public class MBDropCmd extends AbstractDevCmd { @@ -75,7 +73,7 @@ public class MBDropCmd extends AbstractDevCmd {
case "rune":
output = LootTable.runeCount + " Runes - ITEM NAME : DROP COUNT" + newline;
for (ItemBase ib: LootTable.runeDroppedMap.keySet()){
for (ItemBase ib : LootTable.runeDroppedMap.keySet()) {
int dropCount = LootTable.runeDroppedMap.get(ib);
output += ib.getName() + " : " + dropCount + newline;
@ -85,7 +83,7 @@ public class MBDropCmd extends AbstractDevCmd { @@ -85,7 +83,7 @@ public class MBDropCmd extends AbstractDevCmd {
case "contract":
output = LootTable.contractCount + " Contracts - ITEM NAME : DROP COUNT" + newline;
for (ItemBase ib: LootTable.contractDroppedMap.keySet()){
for (ItemBase ib : LootTable.contractDroppedMap.keySet()) {
int dropCount = LootTable.contractDroppedMap.get(ib);
output += ib.getName() + " : " + dropCount + newline;
@ -97,7 +95,7 @@ public class MBDropCmd extends AbstractDevCmd { @@ -97,7 +95,7 @@ public class MBDropCmd extends AbstractDevCmd {
case "glass":
output = LootTable.glassCount + " Glass - ITEM NAME : DROP COUNT" + newline;
for (ItemBase ib: LootTable.glassDroppedMap.keySet()){
for (ItemBase ib : LootTable.glassDroppedMap.keySet()) {
int dropCount = LootTable.glassDroppedMap.get(ib);
output += ib.getName() + " : " + dropCount + newline;
@ -105,7 +103,7 @@ public class MBDropCmd extends AbstractDevCmd { @@ -105,7 +103,7 @@ public class MBDropCmd extends AbstractDevCmd {
break;
case "chance":
float chance = (float)LootTable.dropCount/(float)LootTable.rollCount * 100;
float chance = (float) LootTable.dropCount / (float) LootTable.rollCount * 100;
output = LootTable.dropCount + " out of " + LootTable.rollCount + " items Dropped. chance = " + chance + '%';
break;

7
src/engine/devcmd/cmds/MakeBaneCmd.java

@ -23,7 +23,6 @@ import org.pmw.tinylog.Logger; @@ -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 { @@ -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;
@ -154,7 +151,7 @@ public class MakeBaneCmd extends AbstractDevCmd { @@ -154,7 +151,7 @@ public class MakeBaneCmd extends AbstractDevCmd {
//Let's drop a banestone!
Vector3fImmutable localLocation = ZoneManager.worldToLocal(pc.getLoc(), zone);
if (localLocation == null){
if (localLocation == null) {
ChatManager.chatSystemError(pc, "Failed to convert world location to zone location. Contact a CCR.");
Logger.info("Failed to Convert World coordinates to local zone coordinates");
return;
@ -171,7 +168,7 @@ public class MakeBaneCmd extends AbstractDevCmd { @@ -171,7 +168,7 @@ public class MakeBaneCmd extends AbstractDevCmd {
}
stone.addEffectBit((1 << 19));
stone.setRank((byte) rank);
stone.setMaxHitPoints( blueprint.getMaxHealth(stone.getRank()));
stone.setMaxHitPoints(blueprint.getMaxHealth(stone.getRank()));
stone.setCurrentHitPoints(stone.getMaxHitPoints());
BuildingManager.setUpgradeDateTime(stone, null, 0);

12
src/engine/devcmd/cmds/MakeItemCmd.java

@ -21,7 +21,6 @@ import java.util.ArrayList; @@ -21,7 +21,6 @@ import java.util.ArrayList;
/**
* @author Eighty
*
*/
public class MakeItemCmd extends AbstractDevCmd {
@ -33,8 +32,8 @@ public class MakeItemCmd extends AbstractDevCmd { @@ -33,8 +32,8 @@ public class MakeItemCmd extends AbstractDevCmd {
protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) {
if (words[0].equals("resources")){
for (int ibID : Warehouse.getMaxResources().keySet()){
if (words[0].equals("resources")) {
for (int ibID : Warehouse.getMaxResources().keySet()) {
if (ibID == 7)
continue;
@ -50,9 +49,9 @@ public class MakeItemCmd extends AbstractDevCmd { @@ -50,9 +49,9 @@ public class MakeItemCmd extends AbstractDevCmd {
boolean worked = false;
Item item = new Item(ib, pc.getObjectUUID(),
OwnerType.PlayerCharacter, (byte)0, (byte)0, (short)ib.getDurability(), (short)ib.getDurability(),
OwnerType.PlayerCharacter, (byte) 0, (byte) 0, (short) ib.getDurability(), (short) ib.getDurability(),
true, false, ItemContainerType.INVENTORY, (byte) 0,
new ArrayList<>(),"");
new ArrayList<>(), "");
item.setNumOfItems(Warehouse.getMaxResources().get(ibID));
@ -70,7 +69,6 @@ public class MakeItemCmd extends AbstractDevCmd { @@ -70,7 +69,6 @@ public class MakeItemCmd extends AbstractDevCmd {
}
//add item to inventory
pc.getCharItemManager().addItemToInventory(item);
}
@ -210,7 +208,7 @@ public class MakeItemCmd extends AbstractDevCmd { @@ -210,7 +208,7 @@ public class MakeItemCmd extends AbstractDevCmd {
Item item = new Item(ib, pc.getObjectUUID(),
OwnerType.PlayerCharacter, charges, charges, dur, dur,
true, false, ItemContainerType.INVENTORY, (byte) 0,
new ArrayList<>(),"");
new ArrayList<>(), "");
if (numItems > 1)
item.setNumOfItems(numItems);

44
src/engine/devcmd/cmds/NetDebugCmd.java

@ -6,9 +6,7 @@ import engine.objects.PlayerCharacter; @@ -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,13 +21,30 @@ public class NetDebugCmd extends AbstractDevCmd { @@ -23,13 +21,30 @@ 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) {
Boolean debugState = false;
if(validateUserInput(args) == false) {
if (validateUserInput(args) == false) {
this.sendUsage(pc);
return;
}
@ -58,29 +73,12 @@ public class NetDebugCmd extends AbstractDevCmd { @@ -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;
}
}

2
src/engine/devcmd/cmds/PrintBankCmd.java

@ -47,7 +47,7 @@ public class PrintBankCmd extends AbstractDevCmd { @@ -47,7 +47,7 @@ public class PrintBankCmd extends AbstractDevCmd {
}
CharacterItemManager cim = ((AbstractCharacter)tar).getCharItemManager();
CharacterItemManager cim = ((AbstractCharacter) tar).getCharItemManager();
ArrayList<Item> list = cim.getBank();
throwbackInfo(pc, "Bank for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (Item item : list) {

7
src/engine/devcmd/cmds/PrintBonusesCmd.java

@ -71,10 +71,9 @@ public class PrintBonusesCmd extends AbstractDevCmd { @@ -71,10 +71,9 @@ public class PrintBonusesCmd extends AbstractDevCmd {
for (AbstractEffectModifier targetName : targetItem.getBonuses().keySet()) {
ChatManager.chatSystemInfo(pc, " " + targetName.modType.name() + "-" + targetName.sourceType.name() + ": " + targetItem.getBonuses().get(name));
}
} else if (((AbstractCharacter)tar).getBonuses() != null) {
((AbstractCharacter)tar).getBonuses().printBonusesToClient(pc);
}
else
} else if (((AbstractCharacter) tar).getBonuses() != null) {
((AbstractCharacter) tar).getBonuses().printBonusesToClient(pc);
} else
throwbackInfo(pc, "Bonuses for " + type + ' ' + name + " not found");
}

16
src/engine/devcmd/cmds/PrintEquipCmd.java

@ -60,27 +60,27 @@ public class PrintEquipCmd extends AbstractDevCmd { @@ -60,27 +60,27 @@ public class PrintEquipCmd extends AbstractDevCmd {
type = "NPC";
}
if (tar.getObjectType() == GameObjectType.Mob){
Mob tarMob = (Mob)tar;
if (tar.getObjectType() == GameObjectType.Mob) {
Mob tarMob = (Mob) tar;
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (int slot:tarMob.getEquip().keySet()){
for (int slot : tarMob.getEquip().keySet()) {
MobEquipment equip = tarMob.getEquip().get(slot);
throwbackInfo(pc, equip.getItemBase().getUUID() + " : " + equip.getItemBase().getName() + ", slot: " + slot);
}
return;
}
if (tar.getObjectType() == GameObjectType.NPC){
NPC tarMob = (NPC)tar;
if (tar.getObjectType() == GameObjectType.NPC) {
NPC tarMob = (NPC) tar;
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (int slot:tarMob.getEquip().keySet()){
for (int slot : tarMob.getEquip().keySet()) {
MobEquipment equip = tarMob.getEquip().get(slot);
throwbackInfo(pc,equip.getItemBase().getUUID() + " : " + equip.getItemBase().getName() + ", slot: " + slot);
throwbackInfo(pc, equip.getItemBase().getUUID() + " : " + equip.getItemBase().getName() + ", slot: " + slot);
}
return;
}
CharacterItemManager cim = ((AbstractCharacter)tar).getCharItemManager();
CharacterItemManager cim = ((AbstractCharacter) tar).getCharItemManager();
ConcurrentHashMap<Integer, Item> list = cim.getEquipped();
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (Integer slot : list.keySet()) {

5
src/engine/devcmd/cmds/PrintInventoryCmd.java

@ -38,7 +38,7 @@ public class PrintInventoryCmd extends AbstractDevCmd { @@ -38,7 +38,7 @@ public class PrintInventoryCmd extends AbstractDevCmd {
DecimalFormat df = new DecimalFormat("###,###,###,##0");
if (target instanceof AbstractCharacter) {
AbstractCharacter tar = (AbstractCharacter)target;
AbstractCharacter tar = (AbstractCharacter) target;
name = tar.getFirstName();
@ -83,7 +83,8 @@ public class PrintInventoryCmd extends AbstractDevCmd { @@ -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();

1
src/engine/devcmd/cmds/PrintLocationCmd.java

@ -16,7 +16,6 @@ import engine.objects.Regions; @@ -16,7 +16,6 @@ import engine.objects.Regions;
/**
* @author Eighty
*
*/
public class PrintLocationCmd extends AbstractDevCmd {

22
src/engine/devcmd/cmds/PrintStatsCmd.java

@ -25,6 +25,16 @@ public class PrintStatsCmd extends AbstractDevCmd { @@ -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 { @@ -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 { @@ -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";

2
src/engine/devcmd/cmds/PrintVaultCmd.java

@ -46,7 +46,7 @@ public class PrintVaultCmd extends AbstractDevCmd { @@ -46,7 +46,7 @@ public class PrintVaultCmd extends AbstractDevCmd {
}
CharacterItemManager cim = ((AbstractCharacter)tar).getCharItemManager();
CharacterItemManager cim = ((AbstractCharacter) tar).getCharItemManager();
ArrayList<Item> list = cim.getVault();
throwbackInfo(pc, "Vault for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (Item item : list) {

76
src/engine/devcmd/cmds/PullCmd.java

@ -8,9 +8,7 @@ import engine.math.Vector3fImmutable; @@ -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 { @@ -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 { @@ -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);
}
}

247
src/engine/devcmd/cmds/PurgeObjectsCmd.java

@ -18,9 +18,8 @@ import java.util.concurrent.locks.ReadWriteLock; @@ -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 {
@ -41,27 +40,26 @@ public class PurgeObjectsCmd extends AbstractDevCmd { @@ -41,27 +40,26 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
super("purge");
}
private static void PurgeWalls(Zone zone, PlayerCharacter pc){
private static void PurgeWalls(Zone zone, PlayerCharacter pc) {
if (!zone.isPlayerCity())
return;
for (Building building: zone.zoneBuildingSet){
for (Building building : zone.zoneBuildingSet) {
if (!BuildingManager.IsWallPiece(building))
continue;
for (AbstractCharacter ac: building.getHirelings().keySet()){
for (AbstractCharacter ac : building.getHirelings().keySet()) {
NPC npc = null;
Mob mobA = null;
if (ac.getObjectType() == GameObjectType.NPC)
npc = (NPC)ac;
npc = (NPC) ac;
else if (ac.getObjectType() == GameObjectType.Mob)
mobA = (Mob)ac;
mobA = (Mob) ac;
if (npc != null){
for (Mob mob: npc.getSiegeMinionMap().keySet()){
if (npc != null) {
for (Mob mob : npc.getSiegeMinionMap().keySet()) {
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob);
@ -72,8 +70,8 @@ public class PurgeObjectsCmd extends AbstractDevCmd { @@ -72,8 +70,8 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
DbManager.removeFromCache(GameObjectType.NPC,
npc.getObjectUUID());
WorldGrid.RemoveWorldObject(npc);
}else if (mobA != null){
for (Mob mob: mobA.getSiegeMinionMap().keySet()){
} else if (mobA != null) {
for (Mob mob : mobA.getSiegeMinionMap().keySet()) {
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
//Mob.getRespawnMap().remove(mob);
@ -100,6 +98,113 @@ public class PurgeObjectsCmd extends AbstractDevCmd { @@ -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) {
@ -110,14 +215,14 @@ public class PurgeObjectsCmd extends AbstractDevCmd { @@ -110,14 +215,14 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
try {
if (args[0].toLowerCase().equals("walls")){
if (args[0].toLowerCase().equals("walls")) {
Zone zone = ZoneManager.findSmallestZone(pc.getLoc());
PurgeWalls(zone, pc);
return;
}
if(validateUserInput(args) == false) {
if (validateUserInput(args) == false) {
this.sendUsage(pc);
return;
}
@ -136,7 +241,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd { @@ -136,7 +241,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
for (AbstractWorldObject awo : objectList) {
switch(awo.getObjectType()) {
switch (awo.getObjectType()) {
case Building:
removeBuilding(pc, (Building) awo);
break;
@ -153,7 +258,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd { @@ -153,7 +258,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
// Send results to user
throwbackInfo(pc, "Purge: " + objectList.size() + " objects were removed in range " + _targetRange);
}catch(Exception e){
} catch (Exception e) {
Logger.error(e);
}
@ -174,38 +279,6 @@ public class PurgeObjectsCmd extends AbstractDevCmd { @@ -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 { @@ -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
src/engine/devcmd/cmds/RealmInfoCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;

6
src/engine/devcmd/cmds/RebootCmd.java

@ -6,9 +6,7 @@ import engine.objects.PlayerCharacter; @@ -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 {
@ -30,7 +28,7 @@ public class RebootCmd extends AbstractDevCmd { @@ -30,7 +28,7 @@ public class RebootCmd extends AbstractDevCmd {
Runtime rt = Runtime.getRuntime();
rt.exec("./mbrestart.sh");
} catch (java.io.IOException err) {
Logger.info( err.getMessage());
Logger.info(err.getMessage());
}
}

19
src/engine/devcmd/cmds/RegionCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd;
@ -37,28 +36,28 @@ public class RegionCmd extends AbstractDevCmd { @@ -37,28 +36,28 @@ public class RegionCmd extends AbstractDevCmd {
String result = "";
result += (pc.region.getClass().getSimpleName());
result += (" {");
result+=(newLine);
result += (newLine);
Field[] fields = pc.region.getClass().getDeclaredFields();
//print field names paired with their values
for ( Field field : fields ) {
for (Field field : fields) {
field.setAccessible(true);
result+=(" ");
result += (" ");
try {
if(field.getName().contains("Furniture"))
if (field.getName().contains("Furniture"))
continue;
result+=( field.getName());
result+=(": ");
result += (field.getName());
result += (": ");
//requires access to private field:
result += (field.get(pc.region).toString());
} catch ( IllegalAccessException ex ) {
} catch (IllegalAccessException ex) {
System.out.println(ex);
}
result.trim();
result+=(newLine);
result += (newLine);
}
result+=("}");
result += ("}");
this.throwbackInfo(pc, result.toString());

1
src/engine/devcmd/cmds/RemoveBaneCmd.java

@ -16,7 +16,6 @@ import engine.objects.*; @@ -16,7 +16,6 @@ import engine.objects.*;
/**
* @author Eighty
*
*/
public class RemoveBaneCmd extends AbstractDevCmd {

16
src/engine/devcmd/cmds/RemoveObjectCmd.java

@ -130,9 +130,9 @@ public class RemoveObjectCmd extends AbstractDevCmd { @@ -130,9 +130,9 @@ public class RemoveObjectCmd extends AbstractDevCmd {
if ((building.getBlueprint() != null) && (building.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE))
building.disableSpire(false);
if ((building.getBlueprint() != null) && (building.getBlueprint().getBuildingGroup() == BuildingGroup.WAREHOUSE)){
City city =City.getCity(building.getParentZone().getPlayerCityUUID());
if (city != null){
if ((building.getBlueprint() != null) && (building.getBlueprint().getBuildingGroup() == BuildingGroup.WAREHOUSE)) {
City city = City.getCity(building.getParentZone().getPlayerCityUUID());
if (city != null) {
city.setWarehouseBuildingID(0);
}
Warehouse.warehouseByBuildingUUID.remove(building.getObjectUUID());
@ -149,11 +149,11 @@ public class RemoveObjectCmd extends AbstractDevCmd { @@ -149,11 +149,11 @@ public class RemoveObjectCmd extends AbstractDevCmd {
Mob mobA = null;
if (ac.getObjectType() == GameObjectType.NPC)
npc = (NPC)ac;
npc = (NPC) ac;
else if (ac.getObjectType() == GameObjectType.Mob)
mobA = (Mob)ac;
mobA = (Mob) ac;
if (npc != null){
if (npc != null) {
for (Mob mob : npc.getSiegeMinionMap().keySet()) {
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
@ -165,7 +165,7 @@ public class RemoveObjectCmd extends AbstractDevCmd { @@ -165,7 +165,7 @@ public class RemoveObjectCmd extends AbstractDevCmd {
DbManager.removeFromCache(npc);
WorldGrid.RemoveWorldObject(npc);
WorldGrid.removeObject(npc, pc);
}else if (mobA != null){
} else if (mobA != null) {
for (Mob mob : mobA.getSiegeMinionMap().keySet()) {
WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc);
@ -185,7 +185,7 @@ public class RemoveObjectCmd extends AbstractDevCmd { @@ -185,7 +185,7 @@ public class RemoveObjectCmd extends AbstractDevCmd {
DbManager.BuildingQueries.DELETE_FROM_DATABASE(building);
DbManager.removeFromCache(building);
zone.zoneBuildingSet.remove(building);
if(building.getBlueprint() != null && building.getBlueprint().getBuildingGroup().equals(BuildingGroup.BARRACK)){
if (building.getBlueprint() != null && building.getBlueprint().getBuildingGroup().equals(BuildingGroup.BARRACK)) {
building.RemoveFromBarracksList();
}
WorldGrid.RemoveWorldObject(building);

6
src/engine/devcmd/cmds/RenameCmd.java

@ -18,9 +18,7 @@ import engine.objects.NPC; @@ -18,9 +18,7 @@ import engine.objects.NPC;
import engine.objects.PlayerCharacter;
/**
*
* @author Eighty
*
*/
public class RenameCmd extends AbstractDevCmd {
@ -46,7 +44,7 @@ public class RenameCmd extends AbstractDevCmd { @@ -46,7 +44,7 @@ public class RenameCmd extends AbstractDevCmd {
if (target instanceof NPC)
npc = (NPC) target;
else if (target instanceof Building)
building = (Building)target;
building = (Building) target;
} else
npc = getTargetAsNPC(pcSender);
if (npc != null) {
@ -60,7 +58,7 @@ public class RenameCmd extends AbstractDevCmd { @@ -60,7 +58,7 @@ public class RenameCmd extends AbstractDevCmd {
// npc.updateDatabase();
WorldGrid.updateObject(npc, pcSender);
} else if (building != null){
} else if (building != null) {
String name = args[0];
name = name.replaceAll("_", " ");
building.setName(name);

1
src/engine/devcmd/cmds/ResetLevelCmd.java

@ -32,5 +32,4 @@ public class ResetLevelCmd extends AbstractDevCmd { @@ -32,5 +32,4 @@ public class ResetLevelCmd extends AbstractDevCmd {
}
}

44
src/engine/devcmd/cmds/RotateCmd.java

@ -28,16 +28,16 @@ public class RotateCmd extends AbstractDevCmd { @@ -28,16 +28,16 @@ public class RotateCmd extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) {
if (target == null && (words.length != 2) ) {
if (target == null && (words.length != 2)) {
this.sendUsage(pc);
return;
}
if (words.length == 3){
try{
if (words.length == 3) {
try {
}catch(Exception e){
} catch (Exception e) {
}
}
@ -47,7 +47,7 @@ public class RotateCmd extends AbstractDevCmd { @@ -47,7 +47,7 @@ public class RotateCmd extends AbstractDevCmd {
if (target != null && words.length == 1) {
try {
if (words[0].equalsIgnoreCase("face")){
if (words[0].equalsIgnoreCase("face")) {
this.rotateFace(pc, target);
return;
}
@ -66,11 +66,11 @@ public class RotateCmd extends AbstractDevCmd { @@ -66,11 +66,11 @@ public class RotateCmd extends AbstractDevCmd {
Vector3f rotation = new Vector3f(0f, rot, 0f);
if (target instanceof Building)
rotateBuilding(pc, (Building) target, rotation, rot,false);
rotateBuilding(pc, (Building) target, rotation, rot, false);
else if (target instanceof NPC)
rotateNPC(pc, (NPC) target, rotation,false);
rotateNPC(pc, (NPC) target, rotation, false);
else if (target instanceof Mob)
rotateMob(pc, (Mob) target, rotation,false);
rotateMob(pc, (Mob) target, rotation, false);
else
throwbackError(pc, "Target " + target.getObjectType()
+ " is not a valid object type");
@ -81,7 +81,7 @@ public class RotateCmd extends AbstractDevCmd { @@ -81,7 +81,7 @@ public class RotateCmd extends AbstractDevCmd {
try {
id = Integer.parseInt(words[0]);
if (words[1].equalsIgnoreCase("face")){
if (words[1].equalsIgnoreCase("face")) {
Building b;
if (id != 0)
@ -149,7 +149,7 @@ public class RotateCmd extends AbstractDevCmd { @@ -149,7 +149,7 @@ public class RotateCmd extends AbstractDevCmd {
else
b = getTargetAsBuilding(pc);
if (b != null) {
rotateBuilding(pc, b, rotation, rot,false);
rotateBuilding(pc, b, rotation, rot, false);
return;
}
@ -160,7 +160,7 @@ public class RotateCmd extends AbstractDevCmd { @@ -160,7 +160,7 @@ public class RotateCmd extends AbstractDevCmd {
else
npc = getTargetAsNPC(pc);
if (npc != null) {
rotateNPC(pc, npc, rotation,false);
rotateNPC(pc, npc, rotation, false);
return;
}
@ -171,7 +171,7 @@ public class RotateCmd extends AbstractDevCmd { @@ -171,7 +171,7 @@ public class RotateCmd extends AbstractDevCmd {
else
mob = getTargetAsMob(pc);
if (mob != null) {
rotateMob(pc, mob, rotation,false);
rotateMob(pc, mob, rotation, false);
return;
}
throwbackError(pc, "Nothing found to rotate.");
@ -190,9 +190,9 @@ public class RotateCmd extends AbstractDevCmd { @@ -190,9 +190,9 @@ public class RotateCmd extends AbstractDevCmd {
private void rotateBuilding(PlayerCharacter pc, Building building, Vector3f rot, float orig, boolean faceDirection) {
if (!faceDirection)
rot.set(0.0f, (float)Math.sin(Math.toRadians(orig)/2), 0.0f);
rot.set(0.0f, (float) Math.sin(Math.toRadians(orig) / 2), 0.0f);
building.setRot(rot);
building.setw( (float) Math.abs(Math.cos(Math.toRadians(orig)/2)) );
building.setw((float) Math.abs(Math.cos(Math.toRadians(orig) / 2)));
building.getBounds().setBounds(building);
WorldGrid.updateObject(building, pc);
DbManager.BuildingQueries.SET_PROPERTY(building, "rotY", building.getRot().getY());
@ -201,7 +201,7 @@ public class RotateCmd extends AbstractDevCmd { @@ -201,7 +201,7 @@ public class RotateCmd extends AbstractDevCmd {
"Building with ID " + building.getObjectUUID() + " rotated");
}
private void rotateNPC(PlayerCharacter pc, NPC npc, Vector3f rot,boolean faceDirection) {
private void rotateNPC(PlayerCharacter pc, NPC npc, Vector3f rot, boolean faceDirection) {
npc.setRot(rot);
DbManager.NPCQueries.SET_PROPERTY(npc, "npc_rotation", rot.y);
WorldGrid.updateObject(npc, pc);
@ -210,7 +210,7 @@ public class RotateCmd extends AbstractDevCmd { @@ -210,7 +210,7 @@ public class RotateCmd extends AbstractDevCmd {
"NPC with ID " + npc.getObjectUUID() + " rotated");
}
private void rotateMob(PlayerCharacter pc, Mob mob, Vector3f rot,boolean faceDirection) {
private void rotateMob(PlayerCharacter pc, Mob mob, Vector3f rot, boolean faceDirection) {
mob.setRot(rot);
DbManager.MobQueries.SET_PROPERTY(mob, "mob_rotation", rot.y);
WorldGrid.updateObject(mob, pc);
@ -219,8 +219,8 @@ public class RotateCmd extends AbstractDevCmd { @@ -219,8 +219,8 @@ public class RotateCmd extends AbstractDevCmd {
"Mob with ID " + mob.getObjectUUID() + " rotated");
}
private void rotateFace(PlayerCharacter pc, AbstractGameObject target){
AbstractWorldObject awo = (AbstractWorldObject)target;
private void rotateFace(PlayerCharacter pc, AbstractGameObject target) {
AbstractWorldObject awo = (AbstractWorldObject) target;
if (awo == null)
return;
Vector3fImmutable buildingLoc = awo.getLoc();
@ -233,16 +233,16 @@ public class RotateCmd extends AbstractDevCmd { @@ -233,16 +233,16 @@ public class RotateCmd extends AbstractDevCmd {
float rot = (float) Math.toDegrees(rotangle);
if (rot > 180)
rot*=-1;
rot *= -1;
Vector3f buildingrotation = new Vector3f(0f, rot, 0f);
Vector3f rotation = new Vector3f(0f, rotangle, 0f);
if (target instanceof Building)
rotateBuilding(pc, (Building) target, buildingrotation, rot,false);
rotateBuilding(pc, (Building) target, buildingrotation, rot, false);
else if (target instanceof NPC)
rotateNPC(pc, (NPC) target, rotation,true);
rotateNPC(pc, (NPC) target, rotation, true);
else if (target instanceof Mob)
rotateMob(pc, (Mob) target, rotation,true);
rotateMob(pc, (Mob) target, rotation, true);
else
throwbackError(pc, "Target " + target.getObjectType()
+ " is not a valid object type");

16
src/engine/devcmd/cmds/SetAICmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.ai.MobileFSMManager;
@ -19,7 +18,6 @@ import engine.server.MBServerStatics; @@ -19,7 +18,6 @@ import engine.server.MBServerStatics;
/**
* @author Steve
*
*/
public class SetAICmd extends AbstractDevCmd {
@ -31,22 +29,22 @@ public class SetAICmd extends AbstractDevCmd { @@ -31,22 +29,22 @@ public class SetAICmd extends AbstractDevCmd {
@Override
protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) {
if (words.length < 2){
if (words.length < 2) {
this.sendUsage(pc);
return;
}
int amount;
try{
try {
amount = Integer.valueOf(words[1]);
}catch (NumberFormatException e) {
} catch (NumberFormatException e) {
this.throwbackError(pc, "Failed to parse amount");
return;
}
switch(words[0]){
case "angle" :
switch (words[0]) {
case "angle":
float angle = Float.parseFloat(words[1]);
MobileFSMManager.AI_MAX_ANGLE = angle;
@ -67,7 +65,7 @@ public class SetAICmd extends AbstractDevCmd { @@ -67,7 +65,7 @@ public class SetAICmd extends AbstractDevCmd {
this.throwbackInfo(pc, "Patrol Chance is now set to " + amount);
break;
case "pulse":
if (amount < 500){
if (amount < 500) {
this.throwbackError(pc, "pulse amount must be greather than 500 to execute.");
return;
}
@ -75,7 +73,7 @@ public class SetAICmd extends AbstractDevCmd { @@ -75,7 +73,7 @@ public class SetAICmd extends AbstractDevCmd {
this.throwbackInfo(pc, "Pulse is now set to " + amount);
break;
case "sleepthread":
if (amount < 500){
if (amount < 500) {
this.throwbackError(pc, "sleep amount must be greather than 500 to execute.");
return;
}

4
src/engine/devcmd/cmds/SetAdminRuneCmd.java

@ -17,9 +17,7 @@ import engine.objects.CharacterRune; @@ -17,9 +17,7 @@ import engine.objects.CharacterRune;
import engine.objects.PlayerCharacter;
/**
*
* @author Eighty
*
*/
public class SetAdminRuneCmd extends AbstractDevCmd {
@ -46,7 +44,7 @@ public class SetAdminRuneCmd extends AbstractDevCmd { @@ -46,7 +44,7 @@ public class SetAdminRuneCmd extends AbstractDevCmd {
return;
}
if(!(target instanceof PlayerCharacter)) {
if (!(target instanceof PlayerCharacter)) {
target = pcSender;
}

1
src/engine/devcmd/cmds/SetBaneActiveCmd.java

@ -15,7 +15,6 @@ import engine.objects.*; @@ -15,7 +15,6 @@ import engine.objects.*;
/**
* @author Eighty
*
*/
public class SetBaneActiveCmd extends AbstractDevCmd {

7
src/engine/devcmd/cmds/SetBuildingAltitudeCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
@ -60,19 +59,19 @@ public class SetBuildingAltitudeCmd extends AbstractDevCmd { @@ -60,19 +59,19 @@ public class SetBuildingAltitudeCmd extends AbstractDevCmd {
return;
}
if (target.getObjectType() != GameObjectType.Building){
if (target.getObjectType() != GameObjectType.Building) {
this.sendUsage(pc);
return;
}
Building targetBuilding = (Building)target;
Building targetBuilding = (Building) target;
float altitude = 0;
try {
altitude = Float.parseFloat(words[0]);
if (!UpdateBuildingAltitude(targetBuilding, targetBuilding.getStatAlt() + altitude)){
if (!UpdateBuildingAltitude(targetBuilding, targetBuilding.getStatAlt() + altitude)) {
this.throwbackError(pc, "Failed to update building altitude");
return;
}

1
src/engine/devcmd/cmds/SetForceRenameCityCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd;

12
src/engine/devcmd/cmds/SetGuildCmd.java

@ -10,9 +10,7 @@ import engine.objects.NPC; @@ -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 {
@ -29,7 +27,7 @@ public class SetGuildCmd extends AbstractDevCmd { @@ -29,7 +27,7 @@ public class SetGuildCmd extends AbstractDevCmd {
NPC targetNPC;
Guild targetGuild;
if(validateUserInput(pcSender, target, args) == false) {
if (validateUserInput(pcSender, target, args) == false) {
this.sendUsage(pcSender);
return;
}
@ -84,8 +82,8 @@ 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;
}
@ -100,6 +98,6 @@ public class SetGuildCmd extends AbstractDevCmd { @@ -100,6 +98,6 @@ public class SetGuildCmd extends AbstractDevCmd {
return true;
}
}
}

1
src/engine/devcmd/cmds/SetHealthCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.DispatchChannel;

5
src/engine/devcmd/cmds/SetInvulCmd.java

@ -27,7 +27,8 @@ public class SetInvulCmd extends AbstractDevCmd { @@ -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);
@ -57,7 +58,7 @@ public class SetInvulCmd extends AbstractDevCmd { @@ -57,7 +58,7 @@ public class SetInvulCmd extends AbstractDevCmd {
// if strucutre is a TOL then we're modifying the protection
// status of the entire city
if ( (b.getBlueprint() != null) &&
if ((b.getBlueprint() != null) &&
(b.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.TOL))) {
City city;

3
src/engine/devcmd/cmds/SetMaintCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum;
@ -36,7 +35,7 @@ public class SetMaintCmd extends AbstractDevCmd { @@ -36,7 +35,7 @@ public class SetMaintCmd extends AbstractDevCmd {
return;
}
Building targetBuilding = (Building)target;
Building targetBuilding = (Building) target;
if (targetBuilding.getProtectionState().equals(Enum.ProtectionState.NPC)) {
ChatManager.chatSayInfo(player, "Target is not a valid building");

38
src/engine/devcmd/cmds/SetNpcEquipSetCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
@ -21,6 +20,7 @@ import engine.objects.PlayerCharacter; @@ -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");
@ -35,14 +35,14 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd { @@ -35,14 +35,14 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd {
return;
}
if (target.getObjectType() != GameObjectType.NPC){
if (target.getObjectType() != GameObjectType.NPC) {
this.sendUsage(pc);
return;
}
NPC npc = (NPC)target;
NPC npc = (NPC) target;
if (words[0].equalsIgnoreCase("next")){
if (words[0].equalsIgnoreCase("next")) {
if (SetNpcEquipSetCmd.lastEquipSetID >= 1222)
SetNpcEquipSetCmd.lastEquipSetID = 1;
@ -51,28 +51,27 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd { @@ -51,28 +51,27 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd {
boolean complete = false;
while (complete == false){
while (complete == false) {
complete = NPC.UpdateEquipSetID(npc, SetNpcEquipSetCmd.lastEquipSetID);
if (!complete){
if (!complete) {
SetNpcEquipSetCmd.lastEquipSetID++;
if (SetNpcEquipSetCmd.lastEquipSetID >= 1222)
SetNpcEquipSetCmd.lastEquipSetID = 1;
}
}
if (complete){
if (complete) {
npc.equip = MobBase.loadEquipmentSet(npc.getEquipmentSetID());
WorldGrid.updateObject(npc);
this.throwbackInfo(pc, "Equipment Set Changed to " + SetNpcEquipSetCmd.lastEquipSetID );
this.throwbackInfo(pc, "Equipment Set Changed to " + SetNpcEquipSetCmd.lastEquipSetID);
}
return;
}
if (words[0].equalsIgnoreCase("last")){
if (words[0].equalsIgnoreCase("last")) {
if (SetNpcEquipSetCmd.lastEquipSetID <= 1)
SetNpcEquipSetCmd.lastEquipSetID = 1222;
@ -81,10 +80,10 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd { @@ -81,10 +80,10 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd {
boolean complete = false;
while (complete == false){
while (complete == false) {
complete = NPC.UpdateEquipSetID(npc, SetNpcEquipSetCmd.lastEquipSetID);
if (!complete){
if (!complete) {
SetNpcEquipSetCmd.lastEquipSetID--;
if (SetNpcEquipSetCmd.lastEquipSetID <= 1)
SetNpcEquipSetCmd.lastEquipSetID = 1222;
@ -92,27 +91,26 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd { @@ -92,27 +91,26 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd {
}
if (complete){
this.throwbackInfo(pc, "Equipment Set Changed to " + SetNpcEquipSetCmd.lastEquipSetID );
if (complete) {
this.throwbackInfo(pc, "Equipment Set Changed to " + SetNpcEquipSetCmd.lastEquipSetID);
npc.equip = MobBase.loadEquipmentSet(npc.getEquipmentSetID());
WorldGrid.updateObject(npc);
}
return;
}
int equipSetID = 0;
try{
try {
equipSetID = Integer.parseInt(words[0]);
}catch(Exception e){
} catch (Exception e) {
this.throwbackError(pc, e.getMessage());
}
if (!NPC.UpdateEquipSetID(npc, equipSetID)){
this.throwbackError(pc, "Unable to find Equipset for ID " + equipSetID );
if (!NPC.UpdateEquipSetID(npc, equipSetID)) {
this.throwbackError(pc, "Unable to find Equipset for ID " + equipSetID);
return;
}
@ -120,7 +118,7 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd { @@ -120,7 +118,7 @@ public class SetNpcEquipSetCmd extends AbstractDevCmd {
npc.equip = MobBase.loadEquipmentSet(npc.getEquipmentSetID());
WorldGrid.updateObject(npc);
this.throwbackInfo(pc, "Equipment Set Changed to " + equipSetID );
this.throwbackInfo(pc, "Equipment Set Changed to " + equipSetID);
}

7
src/engine/devcmd/cmds/SetNpcMobbaseCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
@ -35,16 +34,16 @@ public class SetNpcMobbaseCmd extends AbstractDevCmd { @@ -35,16 +34,16 @@ public class SetNpcMobbaseCmd extends AbstractDevCmd {
return;
}
if (target.getObjectType() != GameObjectType.NPC){
if (target.getObjectType() != GameObjectType.NPC) {
this.sendUsage(player);
return;
}
NPC npc = (NPC)target;
NPC npc = (NPC) target;
int mobBaseID = Integer.parseInt(words[0]);
if (MobBase.getMobBase(mobBaseID) == null){
if (MobBase.getMobBase(mobBaseID) == null) {
this.throwbackError(player, "Cannot find Mobbase for ID " + mobBaseID);
return;
}

6
src/engine/devcmd/cmds/SetNpcNameCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
@ -20,6 +19,7 @@ import engine.objects.PlayerCharacter; @@ -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");
@ -34,12 +34,12 @@ public class SetNpcNameCmd extends AbstractDevCmd { @@ -34,12 +34,12 @@ public class SetNpcNameCmd extends AbstractDevCmd {
return;
}
if (target.getObjectType() != GameObjectType.NPC){
if (target.getObjectType() != GameObjectType.NPC) {
this.sendUsage(pc);
return;
}
NPC npc = (NPC)target;
NPC npc = (NPC) target;
String name = words[0];

19
src/engine/devcmd/cmds/SetOwnerCmd.java

@ -8,9 +8,7 @@ import engine.objects.*; @@ -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 {
@ -27,7 +25,7 @@ public class SetOwnerCmd extends AbstractDevCmd { @@ -27,7 +25,7 @@ public class SetOwnerCmd extends AbstractDevCmd {
protected void _doCmd(PlayerCharacter pcSender, String[] args,
AbstractGameObject target) {
if(validateUserInput(pcSender, target, args) == false) {
if (validateUserInput(pcSender, target, args) == false) {
this.sendUsage(pcSender);
return;
}
@ -45,7 +43,8 @@ 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 { @@ -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;
}
@ -100,10 +99,10 @@ public class SetOwnerCmd extends AbstractDevCmd { @@ -100,10 +99,10 @@ public class SetOwnerCmd extends AbstractDevCmd {
switch (_newOwnerType) {
case NPC:
outOwner = (AbstractCharacter)DbManager.getObject(GameObjectType.NPC, Integer.parseInt(userInput[0]));
outOwner = (AbstractCharacter) DbManager.getObject(GameObjectType.NPC, Integer.parseInt(userInput[0]));
break;
case CHARACTER:
outOwner = (AbstractCharacter)DbManager.getObject(GameObjectType.PlayerCharacter, Integer.parseInt(userInput[0]));
outOwner = (AbstractCharacter) DbManager.getObject(GameObjectType.PlayerCharacter, Integer.parseInt(userInput[0]));
break;
}
@ -113,6 +112,6 @@ public class SetOwnerCmd extends AbstractDevCmd { @@ -113,6 +112,6 @@ public class SetOwnerCmd extends AbstractDevCmd {
}
return true;
}
}
}

16
src/engine/devcmd/cmds/SetRankCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.InterestManagement.WorldGrid;
@ -51,10 +50,10 @@ public class SetRankCmd extends AbstractDevCmd { @@ -51,10 +50,10 @@ public class SetRankCmd extends AbstractDevCmd {
return;
}
if (target != null){
switch(target.getObjectType()){
if (target != null) {
switch (target.getObjectType()) {
case Building:
Building targetBuilding = (Building)target;
Building targetBuilding = (Building) target;
Blueprint blueprint = targetBuilding.getBlueprint();
if (blueprint == null) {
@ -75,14 +74,14 @@ public class SetRankCmd extends AbstractDevCmd { @@ -75,14 +74,14 @@ public class SetRankCmd extends AbstractDevCmd {
ChatManager.chatSayInfo(player, "Rank set for building with ID " + targetBuilding.getObjectUUID() + " to rank " + targetRank);
break;
case NPC:
NPC toRank = (NPC)target;
NPC toRank = (NPC) target;
toRank.setRank(targetRank * 10);
toRank.setUpgradeDateTime(null);
WorldGrid.updateObject(toRank);
break;
case Mob:
Mob toRankCaptain = (Mob)target;
if (toRankCaptain.getContract() != null){
Mob toRankCaptain = (Mob) target;
if (toRankCaptain.getContract() != null) {
toRankCaptain.setRank(targetRank * 10);
Mob.setUpgradeDateTime(toRankCaptain, null);
WorldGrid.updateObject(toRankCaptain);
@ -91,7 +90,7 @@ public class SetRankCmd extends AbstractDevCmd { @@ -91,7 +90,7 @@ public class SetRankCmd extends AbstractDevCmd {
break;
}
}else{
} else {
Building targetBuilding = null;
if (uuid != 0)
targetBuilding = BuildingManager.getBuilding(uuid);
@ -126,7 +125,6 @@ public class SetRankCmd extends AbstractDevCmd { @@ -126,7 +125,6 @@ public class SetRankCmd extends AbstractDevCmd {
}
}
@Override

2
src/engine/devcmd/cmds/SetRuneCmd.java

@ -17,9 +17,7 @@ import engine.objects.CharacterRune; @@ -17,9 +17,7 @@ import engine.objects.CharacterRune;
import engine.objects.PlayerCharacter;
/**
*
* @author Eighty
*
*/
public class SetRuneCmd extends AbstractDevCmd {

1
src/engine/devcmd/cmds/SetStaminaCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.DispatchChannel;

31
src/engine/devcmd/cmds/SetSubRaceCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
@ -29,22 +28,22 @@ public class SetSubRaceCmd extends AbstractDevCmd { @@ -29,22 +28,22 @@ public class SetSubRaceCmd extends AbstractDevCmd {
protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) {
if (target instanceof AbstractCharacter){
if (target instanceof AbstractCharacter) {
if (words[0].equals("race")){
if (words[0].equals("race")) {
if (target.getObjectType() != GameObjectType.PlayerCharacter)
return;
PlayerCharacter player = (PlayerCharacter)target;
PlayerCharacter player = (PlayerCharacter) target;
int raceID = Integer.parseInt(words[1]);
player.setSubRaceID(raceID);
if (raceID == 0)
raceID = player.getRaceID();
UpdateCharOrMobMessage ucm = new UpdateCharOrMobMessage(player, 1,raceID);
UpdateCharOrMobMessage ucm = new UpdateCharOrMobMessage(player, 1, raceID);
DispatchMessage.sendToAllInRange(player, ucm);
return;
}
if (words[0].equals("all")){
for (int i = 15999; i< 16337;i++){
if (words[0].equals("all")) {
for (int i = 15999; i < 16337; i++) {
ApplyBuildingEffectMsg applyBuildingEffectMsg = new ApplyBuildingEffectMsg(4, 0, target.getObjectType().ordinal(), target.getObjectUUID(), i);
DispatchMessage.sendToAllInRange((AbstractWorldObject) target, applyBuildingEffectMsg);
try {
@ -55,7 +54,7 @@ public class SetSubRaceCmd extends AbstractDevCmd { @@ -55,7 +54,7 @@ public class SetSubRaceCmd extends AbstractDevCmd {
}
}
}else{
} else {
ApplyBuildingEffectMsg applyBuildingEffectMsg = new ApplyBuildingEffectMsg(4, 0, target.getObjectType().ordinal(), target.getObjectUUID(), Integer.parseInt(words[0]));
DispatchMessage.sendToAllInRange((AbstractWorldObject) target, applyBuildingEffectMsg);
}
@ -63,10 +62,10 @@ public class SetSubRaceCmd extends AbstractDevCmd { @@ -63,10 +62,10 @@ public class SetSubRaceCmd extends AbstractDevCmd {
return;
}
Building building = (Building)target;
Building building = (Building) target;
building.removeAllVisualEffects();
building.addEffectBit(1<<Integer.parseInt(words[0]));
building.addEffectBit(1 << Integer.parseInt(words[0]));
building.updateEffects();
//63535 38751
// Zone zone = ZoneManager.findSmallestZone(pc.getLoc());
@ -79,7 +78,6 @@ public class SetSubRaceCmd extends AbstractDevCmd { @@ -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 { @@ -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 { @@ -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 { @@ -192,8 +181,6 @@ public class SetSubRaceCmd extends AbstractDevCmd {
// }
}
@Override

3
src/engine/devcmd/cmds/ShowOffsetCmd.java

@ -25,7 +25,7 @@ public class ShowOffsetCmd extends AbstractDevCmd { @@ -25,7 +25,7 @@ public class ShowOffsetCmd extends AbstractDevCmd {
Vector3fImmutable offset;
String newline = "\r\n ";
targetBuilding = (Building)target;
targetBuilding = (Building) target;
if (targetBuilding.getObjectType() != GameObjectType.Building) {
throwbackInfo(pc, "showgate: target must be an Building");
@ -53,5 +53,4 @@ public class ShowOffsetCmd extends AbstractDevCmd { @@ -53,5 +53,4 @@ public class ShowOffsetCmd extends AbstractDevCmd {
}
}

3
src/engine/devcmd/cmds/SlotTestCmd.java

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
// www.magicbane.com
package engine.devcmd.cmds;
import engine.Enum.GameObjectType;
@ -77,7 +76,7 @@ public class SlotTestCmd extends AbstractDevCmd { @@ -77,7 +76,7 @@ public class SlotTestCmd extends AbstractDevCmd {
}
ChatManager.chatSystemInfo(playerCharacter,outString);
ChatManager.chatSystemInfo(playerCharacter, outString);
}

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

Loading…
Cancel
Save