Files
Server/src/engine/jobs/FinishSummonsJob.java
T

82 lines
2.7 KiB
Java
Raw Normal View History

2022-04-30 09:41:17 -04:00
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.jobs;
import engine.Enum.ModType;
import engine.Enum.SourceType;
import engine.gameManager.PowersManager;
import engine.job.AbstractScheduleJob;
import engine.job.JobContainer;
import engine.net.client.msg.ErrorPopupMsg;
import engine.objects.PlayerCharacter;
import java.util.concurrent.ConcurrentHashMap;
public class FinishSummonsJob extends AbstractScheduleJob {
2023-07-15 09:23:48 -04:00
PlayerCharacter source;
PlayerCharacter target;
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
public FinishSummonsJob(PlayerCharacter source, PlayerCharacter target) {
super();
this.source = source;
this.target = target;
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
@Override
protected void doJob() {
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
if (this.target == null)
return;
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
//clear summon timer
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
ConcurrentHashMap<String, JobContainer> timers = this.target.getTimers();
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
if (timers != null && timers.containsKey("Summon"))
timers.remove("Summon");
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
if (this.source == null || !this.source.isAlive() || !this.target.isAlive())
return;
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
// cannot summon a player in combat
if (this.target.isCombat()) {
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
ErrorPopupMsg.sendErrorMsg(this.source, "Cannot summon player in combat.");
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
PowersManager.finishRecycleTime(428523680, this.source, false);
return;
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
if (this.target.getBonuses() != null && this.target.getBonuses().getBool(ModType.BlockedPowerType, SourceType.SUMMON)) {
ErrorPopupMsg.sendErrorMsg(this.target, "You have been blocked from receiving summons!");
ErrorPopupMsg.sendErrorMsg(this.source, "Target is blocked from receiving summons!");
return;
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
if (this.source.region != null)
this.target.setRegion(this.source.region);
//teleport target to source
target.teleport(source.getLoc());
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
@Override
protected void _cancelJob() {
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
public PlayerCharacter getSource() {
return this.source;
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
public PlayerCharacter getTarget() {
return this.target;
}
2022-04-30 09:41:17 -04:00
}