Browse Source

Added ./setrace command

combat-2
FatBoy-DOTC 8 months ago
parent
commit
60b8843563
  1. 14
      src/engine/db/handlers/dbNPCHandler.java
  2. 51
      src/engine/devcmd/cmds/SetRaceCmd.java
  3. 1
      src/engine/gameManager/DevCmdManager.java
  4. 2
      src/engine/objects/NPC.java

14
src/engine/db/handlers/dbNPCHandler.java

@ -309,7 +309,21 @@ public class dbNPCHandler extends dbHandlerBase { @@ -309,7 +309,21 @@ public class dbNPCHandler extends dbHandlerBase {
return false;
}
}
public boolean UPDATE_RACE(NPC npc, int value) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_npc` SET `npc_raceID`=? WHERE `UID`=?")) {
preparedStatement.setInt(1, value);
preparedStatement.setLong(2, npc.getObjectUUID());
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
return false;
}
}
public void LOAD_PIRATE_NAMES() {
String pirateName;

51
src/engine/devcmd/cmds/SetRaceCmd.java

@ -0,0 +1,51 @@ @@ -0,0 +1,51 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.devcmd.cmds;
import engine.InterestManagement.WorldGrid;
import engine.devcmd.AbstractDevCmd;
import engine.gameManager.BuildingManager;
import engine.gameManager.ChatManager;
import engine.gameManager.DbManager;
import engine.mbEnums;
import engine.objects.*;
public class SetRaceCmd extends AbstractDevCmd {
public SetRaceCmd() {
super("setRace");
}
@Override
protected void _doCmd(PlayerCharacter player, String[] words,
AbstractGameObject target) {
int newRace = Integer.parseInt(words[0]);
if(target.getObjectType().equals(mbEnums.GameObjectType.NPC) == false){
throwbackError(player, "You Must Target An NPC");
}
NPC npc = (NPC)target;
npc.loadID = newRace;
DbManager.NPCQueries.UPDATE_RACE(npc,newRace);
}
@Override
protected String _getHelpString() {
return "Sets NPC race";
}
@Override
protected String _getUsageString() {
return "' /setrace ID'";
}
}

1
src/engine/gameManager/DevCmdManager.java

@ -76,6 +76,7 @@ public enum DevCmdManager { @@ -76,6 +76,7 @@ public enum DevCmdManager {
DevCmdManager.registerDevCmd(new SetLevelCmd());
DevCmdManager.registerDevCmd(new SetBaseClassCmd());
DevCmdManager.registerDevCmd(new SetPromotionClassCmd());
DevCmdManager.registerDevCmd(new SetRaceCmd());
DevCmdManager.registerDevCmd(new SetRuneCmd());
DevCmdManager.registerDevCmd(new GetOffsetCmd());
DevCmdManager.registerDevCmd(new AddGoldCmd());

2
src/engine/objects/NPC.java

@ -50,7 +50,7 @@ public class NPC extends AbstractCharacter { @@ -50,7 +50,7 @@ public class NPC extends AbstractCharacter {
public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock();
public int runeSetID = 0;
public int extraRune2 = 0;
protected int loadID;
public int loadID;
protected MobBase mobBase;
protected String name;
protected int dbID;

Loading…
Cancel
Save