use of com.massivecraft.massivecore.teleport.ScheduledTeleport in project MassiveCore by MassiveCraft.
the class EngineMassiveCoreScheduledTeleport method cancelTeleport.
// -------------------------------------------- //
// LISTENER: CANCEL TELEPORT
// -------------------------------------------- //
public void cancelTeleport(Player player) {
if (MUtil.isntPlayer(player))
return;
// If there there is a ScheduledTeleport ...
ScheduledTeleport scheduledTeleport = teleporteeIdToScheduledTeleport.get(IdUtil.getId(player));
if (scheduledTeleport == null)
return;
// ... unschedule it ...
scheduledTeleport.unschedule();
// ... and inform the teleportee.
MixinMessage.get().msgOne(scheduledTeleport.getTeleporteeId(), "<rose>Cancelled <i>teleport to <h>" + scheduledTeleport.getDestination().getDesc(scheduledTeleport.getTeleporteeId()) + "<i>.");
}
use of com.massivecraft.massivecore.teleport.ScheduledTeleport in project MassiveCore by MassiveCraft.
the class EngineMassiveCoreScheduledTeleport method schedule.
public ScheduledTeleport schedule(ScheduledTeleport st) {
ScheduledTeleport old = this.teleporteeIdToScheduledTeleport.get(st.getTeleporteeId());
if (old != null)
old.unschedule();
this.teleporteeIdToScheduledTeleport.put(st.getTeleporteeId(), st);
st.setDueMillis(System.currentTimeMillis() + st.getDelaySeconds() * TimeUnit.MILLIS_PER_SECOND);
return old;
}
use of com.massivecraft.massivecore.teleport.ScheduledTeleport in project MassiveCore by MassiveCraft.
the class MixinTeleport method teleport.
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
public void teleport(Object teleporteeObject, Destination destination, int delaySeconds) throws TeleporterException {
String teleporteeId = IdUtil.getId(teleporteeObject);
if (!IdUtil.isPlayerId(teleporteeId))
throw new TeleporterException(Txt.parse("<white>%s <b>is not a player.", MixinDisplayName.get().getDisplayName(teleporteeId, IdUtil.getConsole())));
PS ps;
try {
ps = destination.getPs(teleporteeId);
} catch (Exception e) {
throw new TeleporterException(e.getMessage());
}
String desc = destination.getDesc(teleporteeId);
if (delaySeconds > 0) {
// With delay
if (desc != null && !desc.isEmpty()) {
MixinMessage.get().msgOne(teleporteeId, "<i>Teleporting to <h>" + desc + " <i>in <h>" + delaySeconds + "s <i>unless you move.");
} else {
MixinMessage.get().msgOne(teleporteeId, "<i>Teleporting in <h>" + delaySeconds + "s <i>unless you move.");
}
new ScheduledTeleport(teleporteeId, destination, delaySeconds).schedule();
} else {
// Without delay AKA "now"/"at once"
// Run event
EventMassiveCorePlayerPSTeleport event = new EventMassiveCorePlayerPSTeleport(teleporteeId, MixinSenderPs.get().getSenderPs(teleporteeId), destination);
event.run();
if (event.isCancelled())
return;
destination = event.getDestination();
desc = destination.getDesc(teleporteeId);
if (desc != null && !desc.isEmpty()) {
MixinMessage.get().msgOne(teleporteeId, "<i>Teleporting to <h>" + desc + "<i>.");
}
Player teleportee = IdUtil.getPlayer(teleporteeId);
if (teleportee != null) {
teleportPlayer(teleportee, ps);
} else {
MixinSenderPs.get().setSenderPs(teleporteeId, ps);
}
}
}
Aggregations