Add destination desc to the event and rename parameters for PS teleport mixin.
This commit is contained in:
parent
b4095ed4ab
commit
dc3cb5e1d1
@ -35,15 +35,20 @@ public class MCorePlayerPSTeleportEvent extends Event implements Cancellable, Ru
|
||||
public PS getTo() { return this.to; }
|
||||
public void setTo(PS to) { this.to = to; }
|
||||
|
||||
private String desc;
|
||||
public String getDesc() { return this.desc; }
|
||||
public void setDesc(String desc) { this.desc = desc; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public MCorePlayerPSTeleportEvent(String teleporteeId, PS from, PS to)
|
||||
public MCorePlayerPSTeleportEvent(String teleporteeId, PS from, PS to, String desc)
|
||||
{
|
||||
this.teleporteeId = teleporteeId;
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@ -18,24 +18,24 @@ public interface TeleportMixin
|
||||
// PLAYER
|
||||
// -------------------------------------------- //
|
||||
|
||||
public void teleport(Player teleportee, PS destinationPs) throws TeleporterException;
|
||||
public void teleport(Player teleportee, PS to) throws TeleporterException;
|
||||
|
||||
public void teleport(Player teleportee, PS destinationPs, String destinationDesc) throws TeleporterException;
|
||||
public void teleport(Player teleportee, PS to, String desc) throws TeleporterException;
|
||||
|
||||
public void teleport(Player teleportee, PS destinationPs, String destinationDesc, Permissible delayPermissible) throws TeleporterException;
|
||||
public void teleport(Player teleportee, PS to, String desc, Permissible delayPermissible) throws TeleporterException;
|
||||
|
||||
public void teleport(Player teleportee, PS destinationPs, String destinationDesc, int delaySeconds) throws TeleporterException;
|
||||
public void teleport(Player teleportee, PS to, String desc, int delaySeconds) throws TeleporterException;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// PLAYER ID
|
||||
// -------------------------------------------- //
|
||||
|
||||
public void teleport(String teleporteeId, PS destinationPs) throws TeleporterException;
|
||||
public void teleport(String teleporteeId, PS to) throws TeleporterException;
|
||||
|
||||
public void teleport(String teleporteeId, PS destinationPs, String destinationDesc) throws TeleporterException;
|
||||
public void teleport(String teleporteeId, PS to, String desc) throws TeleporterException;
|
||||
|
||||
public void teleport(String teleporteeId, PS destinationPs, String destinationDesc, Permissible delayPermissible) throws TeleporterException;
|
||||
public void teleport(String teleporteeId, PS to, String desc, Permissible delayPermissible) throws TeleporterException;
|
||||
|
||||
// The only one not covered in abstract
|
||||
public void teleport(String teleporteeId, PS destinationPs, String destinationDesc, int delaySeconds) throws TeleporterException;
|
||||
public void teleport(String teleporteeId, PS to, String desc, int delaySeconds) throws TeleporterException;
|
||||
}
|
||||
|
@ -21,49 +21,49 @@ public abstract class TeleportMixinAbstract implements TeleportMixin
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Player teleportee, PS destinationPs) throws TeleporterException
|
||||
public void teleport(Player teleportee, PS to) throws TeleporterException
|
||||
{
|
||||
this.teleport(teleportee, destinationPs, null);
|
||||
this.teleport(teleportee, to, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Player teleportee, PS destinationPs, String destinationDesc) throws TeleporterException
|
||||
public void teleport(Player teleportee, PS to, String desc) throws TeleporterException
|
||||
{
|
||||
this.teleport(teleportee, destinationPs, destinationDesc, 0);
|
||||
this.teleport(teleportee, to, desc, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Player teleportee, PS destinationPs, String destinationDesc, Permissible delayPermissible) throws TeleporterException
|
||||
public void teleport(Player teleportee, PS to, String desc, Permissible delayPermissible) throws TeleporterException
|
||||
{
|
||||
int delaySeconds = getTpdelay(delayPermissible);
|
||||
this.teleport(teleportee, destinationPs, destinationDesc, delaySeconds);
|
||||
this.teleport(teleportee, to, desc, delaySeconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Player teleportee, PS destinationPs, String destinationDesc, int delaySeconds) throws TeleporterException
|
||||
public void teleport(Player teleportee, PS to, String desc, int delaySeconds) throws TeleporterException
|
||||
{
|
||||
this.teleport(SenderUtil.getSenderId(teleportee), destinationPs, destinationDesc, delaySeconds);
|
||||
this.teleport(SenderUtil.getSenderId(teleportee), to, desc, delaySeconds);
|
||||
}
|
||||
|
||||
// ----
|
||||
|
||||
@Override
|
||||
public void teleport(String teleporteeId, PS destinationPs) throws TeleporterException
|
||||
public void teleport(String teleporteeId, PS to) throws TeleporterException
|
||||
{
|
||||
this.teleport(teleporteeId, destinationPs, null);
|
||||
this.teleport(teleporteeId, to, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(String teleporteeId, PS destinationPs, String destinationDesc) throws TeleporterException
|
||||
public void teleport(String teleporteeId, PS to, String desc) throws TeleporterException
|
||||
{
|
||||
this.teleport(teleporteeId, destinationPs, destinationDesc, 0);
|
||||
this.teleport(teleporteeId, to, desc, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(String teleporteeId, PS destinationPs, String destinationDesc, Permissible delayPermissible) throws TeleporterException
|
||||
public void teleport(String teleporteeId, PS to, String desc, Permissible delayPermissible) throws TeleporterException
|
||||
{
|
||||
int delaySeconds = getTpdelay(delayPermissible);
|
||||
this.teleport(teleporteeId, destinationPs, destinationDesc, delaySeconds);
|
||||
this.teleport(teleporteeId, to, desc, delaySeconds);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@ -69,48 +69,49 @@ public class TeleportMixinDefault extends TeleportMixinAbstract
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void teleport(String teleporteeId, PS destinationPs, String destinationDesc, int delaySeconds) throws TeleporterException
|
||||
public void teleport(String teleporteeId, PS to, String desc, int delaySeconds) throws TeleporterException
|
||||
{
|
||||
if (!SenderUtil.isPlayerId(teleporteeId)) throw new TeleporterException(Txt.parse("<white>%s <b>is not a player.", Mixin.getDisplayName(teleporteeId)));
|
||||
|
||||
if (delaySeconds > 0)
|
||||
{
|
||||
// With delay
|
||||
if (destinationDesc != null)
|
||||
if (desc != null)
|
||||
{
|
||||
Mixin.msg(teleporteeId, "<i>Teleporting to <h>"+destinationDesc+" <i>in <h>"+delaySeconds+"s <i>unless you move.");
|
||||
Mixin.msg(teleporteeId, "<i>Teleporting to <h>"+desc+" <i>in <h>"+delaySeconds+"s <i>unless you move.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Mixin.msg(teleporteeId, "<i>Teleporting in <h>"+delaySeconds+"s <i>unless you move.");
|
||||
}
|
||||
|
||||
new ScheduledTeleport(teleporteeId, destinationPs, destinationDesc, delaySeconds).schedule();
|
||||
new ScheduledTeleport(teleporteeId, to, desc, delaySeconds).schedule();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Without delay AKA "now"/"at once"
|
||||
|
||||
// Run event
|
||||
MCorePlayerPSTeleportEvent event = new MCorePlayerPSTeleportEvent(teleporteeId, Mixin.getSenderPs(teleporteeId), destinationPs);
|
||||
MCorePlayerPSTeleportEvent event = new MCorePlayerPSTeleportEvent(teleporteeId, Mixin.getSenderPs(teleporteeId), to, desc);
|
||||
event.run();
|
||||
if (event.isCancelled()) return;
|
||||
if (event.getTo() == null) return;
|
||||
destinationPs = event.getTo();
|
||||
to = event.getTo();
|
||||
desc = event.getDesc();
|
||||
|
||||
if (destinationDesc != null)
|
||||
if (desc != null)
|
||||
{
|
||||
Mixin.msg(teleporteeId, "<i>Teleporting to <h>"+destinationDesc+"<i>.");
|
||||
Mixin.msg(teleporteeId, "<i>Teleporting to <h>"+desc+"<i>.");
|
||||
}
|
||||
|
||||
Player teleportee = SenderUtil.getPlayer(teleporteeId);
|
||||
if (teleportee != null)
|
||||
{
|
||||
teleportPlayer(teleportee, destinationPs);
|
||||
teleportPlayer(teleportee, to);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mixin.setSenderPs(teleporteeId, destinationPs);
|
||||
Mixin.setSenderPs(teleporteeId, to);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user