From dc3cb5e1d1c4c5d2b9bf29a56a36d72b8b950755 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 12 Jun 2013 08:44:41 +0200 Subject: [PATCH] Add destination desc to the event and rename parameters for PS teleport mixin. --- .../event/MCorePlayerPSTeleportEvent.java | 7 ++++- .../mcore/mixin/TeleportMixin.java | 16 +++++------ .../mcore/mixin/TeleportMixinAbstract.java | 28 +++++++++---------- .../mcore/mixin/TeleportMixinDefault.java | 21 +++++++------- 4 files changed, 39 insertions(+), 33 deletions(-) diff --git a/src/com/massivecraft/mcore/event/MCorePlayerPSTeleportEvent.java b/src/com/massivecraft/mcore/event/MCorePlayerPSTeleportEvent.java index 19d6fac8..4c54b2e9 100644 --- a/src/com/massivecraft/mcore/event/MCorePlayerPSTeleportEvent.java +++ b/src/com/massivecraft/mcore/event/MCorePlayerPSTeleportEvent.java @@ -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; } // -------------------------------------------- // diff --git a/src/com/massivecraft/mcore/mixin/TeleportMixin.java b/src/com/massivecraft/mcore/mixin/TeleportMixin.java index 14d6e935..96090aaa 100644 --- a/src/com/massivecraft/mcore/mixin/TeleportMixin.java +++ b/src/com/massivecraft/mcore/mixin/TeleportMixin.java @@ -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; } diff --git a/src/com/massivecraft/mcore/mixin/TeleportMixinAbstract.java b/src/com/massivecraft/mcore/mixin/TeleportMixinAbstract.java index c68ba2ff..1627674f 100644 --- a/src/com/massivecraft/mcore/mixin/TeleportMixinAbstract.java +++ b/src/com/massivecraft/mcore/mixin/TeleportMixinAbstract.java @@ -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); } // -------------------------------------------- // diff --git a/src/com/massivecraft/mcore/mixin/TeleportMixinDefault.java b/src/com/massivecraft/mcore/mixin/TeleportMixinDefault.java index 81ffbbe4..4a4dca92 100644 --- a/src/com/massivecraft/mcore/mixin/TeleportMixinDefault.java +++ b/src/com/massivecraft/mcore/mixin/TeleportMixinDefault.java @@ -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("%s is not a player.", Mixin.getDisplayName(teleporteeId))); if (delaySeconds > 0) { // With delay - if (destinationDesc != null) + if (desc != null) { - Mixin.msg(teleporteeId, "Teleporting to "+destinationDesc+" in "+delaySeconds+"s unless you move."); + Mixin.msg(teleporteeId, "Teleporting to "+desc+" in "+delaySeconds+"s unless you move."); } else { Mixin.msg(teleporteeId, "Teleporting in "+delaySeconds+"s 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, "Teleporting to "+destinationDesc+"."); + Mixin.msg(teleporteeId, "Teleporting to "+desc+"."); } Player teleportee = SenderUtil.getPlayer(teleporteeId); if (teleportee != null) { - teleportPlayer(teleportee, destinationPs); + teleportPlayer(teleportee, to); } else { - Mixin.setSenderPs(teleporteeId, destinationPs); + Mixin.setSenderPs(teleporteeId, to); } } }