Public Repository for the Magicbane Shadowbane Emulator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.3 KiB

// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.jobs;
import engine.Enum.GameObjectType;
import engine.gameManager.DbManager;
import engine.job.AbstractScheduleJob;
import engine.objects.AbstractGameObject;
import engine.objects.Building;
import engine.objects.PlayerCharacter;
public class DatabaseUpdateJob extends AbstractScheduleJob {
private final AbstractGameObject ago;
private final String type;
public DatabaseUpdateJob(AbstractGameObject ago, String type) {
super();
this.ago = ago;
this.type = type;
}
@Override
protected void doJob() {
if (this.ago == null)
return;
ago.removeDatabaseJob(this.type, false);
if (ago.getObjectType().equals(GameObjectType.PlayerCharacter)) {
PlayerCharacter pc = (PlayerCharacter) ago;
switch (this.type) {
case "Skills":
pc.updateSkillsAndPowersToDatabase();
break;
case "Stats":
DbManager.PlayerCharacterQueries.UPDATE_CHARACTER_STATS(pc);
break;
case "EXP":
DbManager.PlayerCharacterQueries.UPDATE_CHARACTER_EXPERIENCE(pc);
break;
}
}
else if (ago instanceof Building) {
Building b = (Building) ago;
if (this.type.equals("health"))
DbManager.BuildingQueries.UPDATE_BUILDING_HEALTH(b.getObjectUUID(), (int)(b.getHealth()));
}
}
@Override
protected void _cancelJob() {
}
}