diff --git a/src/com/massivecraft/mcore/MCore.java b/src/com/massivecraft/mcore/MCore.java index 3a123220..8d2c6ae1 100644 --- a/src/com/massivecraft/mcore/MCore.java +++ b/src/com/massivecraft/mcore/MCore.java @@ -22,13 +22,13 @@ import com.massivecraft.mcore.integration.vault.VaultFeatures; import com.massivecraft.mcore.mcorecmd.CmdMCore; import com.massivecraft.mcore.mcorecmd.CmdMCoreMStore; import com.massivecraft.mcore.mcorecmd.CmdMCoreUsys; -import com.massivecraft.mcore.mixin.ScheduledTeleportEngine; import com.massivecraft.mcore.mixin.SenderIdMixinDefault; import com.massivecraft.mcore.mixin.TeleportMixinCauseEngine; import com.massivecraft.mcore.ps.PS; import com.massivecraft.mcore.ps.PSAdapter; import com.massivecraft.mcore.store.Coll; import com.massivecraft.mcore.store.ExamineThread; +import com.massivecraft.mcore.teleport.ScheduledTeleportEngine; import com.massivecraft.mcore.util.PlayerUtil; import com.massivecraft.mcore.util.TimeDiffUtil; import com.massivecraft.mcore.util.TimeUnit; diff --git a/src/com/massivecraft/mcore/mixin/Mixin.java b/src/com/massivecraft/mcore/mixin/Mixin.java index 53f104a5..b9eb55eb 100644 --- a/src/com/massivecraft/mcore/mixin/Mixin.java +++ b/src/com/massivecraft/mcore/mixin/Mixin.java @@ -6,7 +6,6 @@ import java.util.Set; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.permissions.Permissible; @@ -14,6 +13,8 @@ import org.bukkit.permissions.Permissible; import com.massivecraft.mcore.Predictate; import com.massivecraft.mcore.event.MCorePlayerLeaveEvent; import com.massivecraft.mcore.ps.PS; +import com.massivecraft.mcore.store.SenderEntity; +import com.massivecraft.mcore.teleport.PSGetter; public class Mixin { @@ -279,38 +280,274 @@ public class Mixin return getTeleportMixin().isCausedByMixin(event); } - public static void teleport(Player teleportee, PS destinationPs) throws TeleporterException + // CommandSender & PS + public static void teleport(CommandSender teleportee, PS to) throws TeleporterException { - getTeleportMixin().teleport(teleportee, destinationPs); + getTeleportMixin().teleport(teleportee, to); } - public static void teleport(Player teleportee, PS destinationPs, String destinationDesc) throws TeleporterException + public static void teleport(CommandSender teleportee, PS to, String desc) throws TeleporterException { - getTeleportMixin().teleport(teleportee, destinationPs, destinationDesc); + getTeleportMixin().teleport(teleportee, to, desc); } - public static void teleport(Player teleportee, PS destinationPs, String destinationDesc, Permissible delayPermissible) throws TeleporterException + public static void teleport(CommandSender teleportee, PS to, String desc, Permissible delayPermissible) throws TeleporterException { - getTeleportMixin().teleport(teleportee, destinationPs, destinationDesc, delayPermissible); + getTeleportMixin().teleport(teleportee, to, desc, delayPermissible); } - public static void teleport(Player teleportee, PS destinationPs, String destinationDesc, int delaySeconds) throws TeleporterException + public static void teleport(CommandSender teleportee, PS to, String desc, int delaySeconds) throws TeleporterException { - getTeleportMixin().teleport(teleportee, destinationPs, destinationDesc, delaySeconds); + getTeleportMixin().teleport(teleportee, to, desc, delaySeconds); } - public static void teleport(String teleporteeId, PS destinationPs) throws TeleporterException + // CommandSender & CommandSender + public static void teleport(CommandSender teleportee, CommandSender to) throws TeleporterException { - getTeleportMixin().teleport(teleporteeId, destinationPs); + getTeleportMixin().teleport(teleportee, to); } - public static void teleport(String teleporteeId, PS destinationPs, String destinationDesc) throws TeleporterException + public static void teleport(CommandSender teleportee, CommandSender to, String desc) throws TeleporterException { - getTeleportMixin().teleport(teleporteeId, destinationPs, destinationDesc); + getTeleportMixin().teleport(teleportee, to, desc); } - public static void teleport(String teleporteeId, PS destinationPs, String destinationDesc, Permissible delayPermissible) throws TeleporterException + public static void teleport(CommandSender teleportee, CommandSender to, String desc, Permissible delayPermissible) throws TeleporterException { - getTeleportMixin().teleport(teleporteeId, destinationPs, destinationDesc, delayPermissible); + getTeleportMixin().teleport(teleportee, to, desc, delayPermissible); } - public static void teleport(String teleporteeId, PS destinationPs, String destinationDesc, int delaySeconds) throws TeleporterException + public static void teleport(CommandSender teleportee, CommandSender to, String desc, int delaySeconds) throws TeleporterException { - getTeleportMixin().teleport(teleporteeId, destinationPs, destinationDesc, delaySeconds); + getTeleportMixin().teleport(teleportee, to, desc, delaySeconds); + } + + // CommandSender & SenderEntity + public static void teleport(CommandSender teleportee, SenderEntity to) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to); + } + public static void teleport(CommandSender teleportee, SenderEntity to, String desc) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc); + } + public static void teleport(CommandSender teleportee, SenderEntity to, String desc, Permissible delayPermissible) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delayPermissible); + } + public static void teleport(CommandSender teleportee, SenderEntity to, String desc, int delaySeconds) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delaySeconds); + } + + // CommandSender & String + public static void teleport(CommandSender teleportee, String to) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to); + } + public static void teleport(CommandSender teleportee, String to, String desc) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc); + } + public static void teleport(CommandSender teleportee, String to, String desc, Permissible delayPermissible) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delayPermissible); + } + public static void teleport(CommandSender teleportee, String to, String desc, int delaySeconds) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delaySeconds); + } + + // CommandSender & PSGetter + public static void teleport(CommandSender teleportee, PSGetter to) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to); + } + public static void teleport(CommandSender teleportee, PSGetter to, String desc) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc); + } + public static void teleport(CommandSender teleportee, PSGetter to, String desc, Permissible delayPermissible) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delayPermissible); + } + public static void teleport(CommandSender teleportee, PSGetter to, String desc, int delaySeconds) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delaySeconds); + } + + // SenderEntity & PS + public static void teleport(SenderEntity teleportee, PS to) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to); + } + public static void teleport(SenderEntity teleportee, PS to, String desc) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc); + } + public static void teleport(SenderEntity teleportee, PS to, String desc, Permissible delayPermissible) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delayPermissible); + } + public static void teleport(SenderEntity teleportee, PS to, String desc, int delaySeconds) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delaySeconds); + } + + // SenderEntity & CommandSender + public static void teleport(SenderEntity teleportee, CommandSender to) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to); + } + public static void teleport(SenderEntity teleportee, CommandSender to, String desc) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc); + } + public static void teleport(SenderEntity teleportee, CommandSender to, String desc, Permissible delayPermissible) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delayPermissible); + } + public static void teleport(SenderEntity teleportee, CommandSender to, String desc, int delaySeconds) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delaySeconds); + } + + // SenderEntity & SenderEntity + public static void teleport(SenderEntity teleportee, SenderEntity to) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to); + } + public static void teleport(SenderEntity teleportee, SenderEntity to, String desc) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc); + } + public static void teleport(SenderEntity teleportee, SenderEntity to, String desc, Permissible delayPermissible) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delayPermissible); + } + public static void teleport(SenderEntity teleportee, SenderEntity to, String desc, int delaySeconds) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delaySeconds); + } + + // SenderEntity & String + public static void teleport(SenderEntity teleportee, String to) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to); + } + public static void teleport(SenderEntity teleportee, String to, String desc) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc); + } + public static void teleport(SenderEntity teleportee, String to, String desc, Permissible delayPermissible) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delayPermissible); + } + public static void teleport(SenderEntity teleportee, String to, String desc, int delaySeconds) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delaySeconds); + } + + // SenderEntity & PSGetter + public static void teleport(SenderEntity teleportee, PSGetter to) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to); + } + public static void teleport(SenderEntity teleportee, PSGetter to, String desc) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc); + } + public static void teleport(SenderEntity teleportee, PSGetter to, String desc, Permissible delayPermissible) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delayPermissible); + } + public static void teleport(SenderEntity teleportee, PSGetter to, String desc, int delaySeconds) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delaySeconds); + } + + // String & PS + public static void teleport(String teleportee, PS to) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to); + } + public static void teleport(String teleportee, PS to, String desc) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc); + } + public static void teleport(String teleportee, PS to, String desc, Permissible delayPermissible) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delayPermissible); + } + public static void teleport(String teleportee, PS to, String desc, int delaySeconds) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delaySeconds); + } + + // String & CommandSender + public static void teleport(String teleportee, CommandSender to) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to); + } + public static void teleport(String teleportee, CommandSender to, String desc) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc); + } + public static void teleport(String teleportee, CommandSender to, String desc, Permissible delayPermissible) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delayPermissible); + } + public static void teleport(String teleportee, CommandSender to, String desc, int delaySeconds) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delaySeconds); + } + + // String & SenderEntity + public static void teleport(String teleportee, SenderEntity to) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to); + } + public static void teleport(String teleportee, SenderEntity to, String desc) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc); + } + public static void teleport(String teleportee, SenderEntity to, String desc, Permissible delayPermissible) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delayPermissible); + } + public static void teleport(String teleportee, SenderEntity to, String desc, int delaySeconds) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delaySeconds); + } + + // String & String + public static void teleport(String teleportee, String to) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to); + } + public static void teleport(String teleportee, String to, String desc) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc); + } + public static void teleport(String teleportee, String to, String desc, Permissible delayPermissible) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delayPermissible); + } + public static void teleport(String teleportee, String to, String desc, int delaySeconds) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delaySeconds); + } + + // String & PSGetter + public static void teleport(String teleportee, PSGetter to) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to); + } + public static void teleport(String teleportee, PSGetter to, String desc) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc); + } + public static void teleport(String teleportee, PSGetter to, String desc, Permissible delayPermissible) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delayPermissible); + } + public static void teleport(String teleportee, PSGetter to, String desc, int delaySeconds) throws TeleporterException + { + getTeleportMixin().teleport(teleportee, to, desc, delaySeconds); } // -------------------------------------------- // diff --git a/src/com/massivecraft/mcore/mixin/TeleportMixin.java b/src/com/massivecraft/mcore/mixin/TeleportMixin.java index 96090aaa..12538213 100644 --- a/src/com/massivecraft/mcore/mixin/TeleportMixin.java +++ b/src/com/massivecraft/mcore/mixin/TeleportMixin.java @@ -1,10 +1,12 @@ package com.massivecraft.mcore.mixin; -import org.bukkit.entity.Player; +import org.bukkit.command.CommandSender; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.permissions.Permissible; import com.massivecraft.mcore.ps.PS; +import com.massivecraft.mcore.store.SenderEntity; +import com.massivecraft.mcore.teleport.PSGetter; public interface TeleportMixin { @@ -14,28 +16,126 @@ public interface TeleportMixin public boolean isCausedByMixin(PlayerTeleportEvent event); - // -------------------------------------------- // - // PLAYER - // -------------------------------------------- // - - public void teleport(Player teleportee, PS to) throws TeleporterException; - - public void teleport(Player teleportee, PS to, String desc) throws TeleporterException; - - public void teleport(Player teleportee, PS to, String desc, Permissible delayPermissible) throws TeleporterException; - - public void teleport(Player teleportee, PS to, String desc, int delaySeconds) throws TeleporterException; + // PERMUTATION + // + // # teleportee + // CommandSender + // SenderEntity + // String + // + // # to + // PS + // CommandSender + // SenderEntity + // String + // PSGetter // -------------------------------------------- // - // PLAYER ID + // COMMAND SENDER // -------------------------------------------- // - public void teleport(String teleporteeId, PS to) throws TeleporterException; + // CommandSender & PS + public void teleport(CommandSender teleportee, PS to) throws TeleporterException; + public void teleport(CommandSender teleportee, PS to, String desc) throws TeleporterException; + public void teleport(CommandSender teleportee, PS to, String desc, Permissible delayPermissible) throws TeleporterException; + public void teleport(CommandSender teleportee, PS to, String desc, int delaySeconds) throws TeleporterException; - public void teleport(String teleporteeId, PS to, String desc) throws TeleporterException; + // CommandSender & CommandSender + public void teleport(CommandSender teleportee, CommandSender to) throws TeleporterException; + public void teleport(CommandSender teleportee, CommandSender to, String desc) throws TeleporterException; + public void teleport(CommandSender teleportee, CommandSender to, String desc, Permissible delayPermissible) throws TeleporterException; + public void teleport(CommandSender teleportee, CommandSender to, String desc, int delaySeconds) throws TeleporterException; - public void teleport(String teleporteeId, PS to, String desc, Permissible delayPermissible) throws TeleporterException; + // CommandSender & SenderEntity + public void teleport(CommandSender teleportee, SenderEntity to) throws TeleporterException; + public void teleport(CommandSender teleportee, SenderEntity to, String desc) throws TeleporterException; + public void teleport(CommandSender teleportee, SenderEntity to, String desc, Permissible delayPermissible) throws TeleporterException; + public void teleport(CommandSender teleportee, SenderEntity to, String desc, int delaySeconds) throws TeleporterException; + + // CommandSender & String + public void teleport(CommandSender teleportee, String to) throws TeleporterException; + public void teleport(CommandSender teleportee, String to, String desc) throws TeleporterException; + public void teleport(CommandSender teleportee, String to, String desc, Permissible delayPermissible) throws TeleporterException; + public void teleport(CommandSender teleportee, String to, String desc, int delaySeconds) throws TeleporterException; + + // CommandSender & PSGetter + public void teleport(CommandSender teleportee, PSGetter to) throws TeleporterException; + public void teleport(CommandSender teleportee, PSGetter to, String desc) throws TeleporterException; + public void teleport(CommandSender teleportee, PSGetter to, String desc, Permissible delayPermissible) throws TeleporterException; + public void teleport(CommandSender teleportee, PSGetter to, String desc, int delaySeconds) throws TeleporterException; + + //// SenderEntity + + // -------------------------------------------- // + // SENDER ENTITY + // -------------------------------------------- // + + // SenderEntity & PS + public void teleport(SenderEntity teleportee, PS to) throws TeleporterException; + public void teleport(SenderEntity teleportee, PS to, String desc) throws TeleporterException; + public void teleport(SenderEntity teleportee, PS to, String desc, Permissible delayPermissible) throws TeleporterException; + public void teleport(SenderEntity teleportee, PS to, String desc, int delaySeconds) throws TeleporterException; + + // SenderEntity & CommandSender + public void teleport(SenderEntity teleportee, CommandSender to) throws TeleporterException; + public void teleport(SenderEntity teleportee, CommandSender to, String desc) throws TeleporterException; + public void teleport(SenderEntity teleportee, CommandSender to, String desc, Permissible delayPermissible) throws TeleporterException; + public void teleport(SenderEntity teleportee, CommandSender to, String desc, int delaySeconds) throws TeleporterException; + + // SenderEntity & SenderEntity + public void teleport(SenderEntity teleportee, SenderEntity to) throws TeleporterException; + public void teleport(SenderEntity teleportee, SenderEntity to, String desc) throws TeleporterException; + public void teleport(SenderEntity teleportee, SenderEntity to, String desc, Permissible delayPermissible) throws TeleporterException; + public void teleport(SenderEntity teleportee, SenderEntity to, String desc, int delaySeconds) throws TeleporterException; + + // SenderEntity & String + public void teleport(SenderEntity teleportee, String to) throws TeleporterException; + public void teleport(SenderEntity teleportee, String to, String desc) throws TeleporterException; + public void teleport(SenderEntity teleportee, String to, String desc, Permissible delayPermissible) throws TeleporterException; + public void teleport(SenderEntity teleportee, String to, String desc, int delaySeconds) throws TeleporterException; + + // SenderEntity & PSGetter + public void teleport(SenderEntity teleportee, PSGetter to) throws TeleporterException; + public void teleport(SenderEntity teleportee, PSGetter to, String desc) throws TeleporterException; + public void teleport(SenderEntity teleportee, PSGetter to, String desc, Permissible delayPermissible) throws TeleporterException; + public void teleport(SenderEntity teleportee, PSGetter to, String desc, int delaySeconds) throws TeleporterException; + + //// String + + // -------------------------------------------- // + // STRING + // -------------------------------------------- // + + // String & PS + public void teleport(String teleportee, PS to) throws TeleporterException; + public void teleport(String teleportee, PS to, String desc) throws TeleporterException; + public void teleport(String teleportee, PS to, String desc, Permissible delayPermissible) throws TeleporterException; + public void teleport(String teleportee, PS to, String desc, int delaySeconds) throws TeleporterException; + + // String & CommandSender + public void teleport(String teleportee, CommandSender to) throws TeleporterException; + public void teleport(String teleportee, CommandSender to, String desc) throws TeleporterException; + public void teleport(String teleportee, CommandSender to, String desc, Permissible delayPermissible) throws TeleporterException; + public void teleport(String teleportee, CommandSender to, String desc, int delaySeconds) throws TeleporterException; + + // String & SenderEntity + public void teleport(String teleportee, SenderEntity to) throws TeleporterException; + public void teleport(String teleportee, SenderEntity to, String desc) throws TeleporterException; + public void teleport(String teleportee, SenderEntity to, String desc, Permissible delayPermissible) throws TeleporterException; + public void teleport(String teleportee, SenderEntity to, String desc, int delaySeconds) throws TeleporterException; + + // String & String + public void teleport(String teleportee, String to) throws TeleporterException; + public void teleport(String teleportee, String to, String desc) throws TeleporterException; + public void teleport(String teleportee, String to, String desc, Permissible delayPermissible) throws TeleporterException; + public void teleport(String teleportee, String to, String desc, int delaySeconds) throws TeleporterException; + + // String & PSGetter + public void teleport(String teleportee, PSGetter to) throws TeleporterException; + public void teleport(String teleportee, PSGetter to, String desc) throws TeleporterException; + public void teleport(String teleportee, PSGetter to, String desc, Permissible delayPermissible) throws TeleporterException; + public void teleport(String teleportee, PSGetter to, String desc, int delaySeconds) throws TeleporterException; + // This very last method is is the core logic. + // Everything else is implemented in the abstract. - // The only one not covered in abstract - 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 1627674f..1890c73d 100644 --- a/src/com/massivecraft/mcore/mixin/TeleportMixinAbstract.java +++ b/src/com/massivecraft/mcore/mixin/TeleportMixinAbstract.java @@ -1,71 +1,19 @@ package com.massivecraft.mcore.mixin; -import org.bukkit.entity.Player; +import org.bukkit.command.CommandSender; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.permissions.Permissible; import com.massivecraft.mcore.MCoreConf; import com.massivecraft.mcore.ps.PS; +import com.massivecraft.mcore.store.SenderEntity; +import com.massivecraft.mcore.teleport.PSGetter; +import com.massivecraft.mcore.teleport.PSGetterPS; +import com.massivecraft.mcore.teleport.PSGetterPlayer; import com.massivecraft.mcore.util.SenderUtil; public abstract class TeleportMixinAbstract implements TeleportMixin { - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public boolean isCausedByMixin(PlayerTeleportEvent event) - { - return TeleportMixinCauseEngine.get().isCausedByTeleportMixin(event); - } - - @Override - public void teleport(Player teleportee, PS to) throws TeleporterException - { - this.teleport(teleportee, to, null); - } - - @Override - public void teleport(Player teleportee, PS to, String desc) throws TeleporterException - { - this.teleport(teleportee, to, desc, 0); - } - - @Override - public void teleport(Player teleportee, PS to, String desc, Permissible delayPermissible) throws TeleporterException - { - int delaySeconds = getTpdelay(delayPermissible); - this.teleport(teleportee, to, desc, delaySeconds); - } - - @Override - public void teleport(Player teleportee, PS to, String desc, int delaySeconds) throws TeleporterException - { - this.teleport(SenderUtil.getSenderId(teleportee), to, desc, delaySeconds); - } - - // ---- - - @Override - public void teleport(String teleporteeId, PS to) throws TeleporterException - { - this.teleport(teleporteeId, to, null); - } - - @Override - public void teleport(String teleporteeId, PS to, String desc) throws TeleporterException - { - this.teleport(teleporteeId, to, desc, 0); - } - - @Override - public void teleport(String teleporteeId, PS to, String desc, Permissible delayPermissible) throws TeleporterException - { - int delaySeconds = getTpdelay(delayPermissible); - this.teleport(teleporteeId, to, desc, delaySeconds); - } - // -------------------------------------------- // // UTIL // -------------------------------------------- // @@ -75,4 +23,395 @@ public abstract class TeleportMixinAbstract implements TeleportMixin return MCoreConf.get().getTpdelay(delayPermissible); } + // -------------------------------------------- // + // CHECK + // -------------------------------------------- // + + @Override + public boolean isCausedByMixin(PlayerTeleportEvent event) + { + return TeleportMixinCauseEngine.get().isCausedByTeleportMixin(event); + } + + // -------------------------------------------- // + // COMMAND SENDER + // -------------------------------------------- // + + // CommandSender & PS + @Override + public void teleport(CommandSender teleportee, PS to) throws TeleporterException + { + this.teleport(teleportee, to, null); + } + + @Override + public void teleport(CommandSender teleportee, PS to, String desc) throws TeleporterException + { + this.teleport(teleportee, to, desc, 0); + } + + @Override + public void teleport(CommandSender teleportee, PS to, String desc, Permissible delayPermissible) throws TeleporterException + { + this.teleport(teleportee, to, desc, getTpdelay(delayPermissible)); + } + + @Override + public void teleport(CommandSender teleportee, PS to, String desc, int delaySeconds) throws TeleporterException + { + this.teleport(SenderUtil.getSenderId(teleportee), to, desc, delaySeconds); + } + + // CommandSender & CommandSender + @Override + public void teleport(CommandSender teleportee, CommandSender to) throws TeleporterException + { + this.teleport(teleportee, to, null); + } + + @Override + public void teleport(CommandSender teleportee, CommandSender to, String desc) throws TeleporterException + { + this.teleport(teleportee, to, desc, 0); + } + + @Override + public void teleport(CommandSender teleportee, CommandSender to, String desc, Permissible delayPermissible) throws TeleporterException + { + this.teleport(teleportee, to, desc, getTpdelay(delayPermissible)); + } + + @Override + public void teleport(CommandSender teleportee, CommandSender to, String desc, int delaySeconds) throws TeleporterException + { + this.teleport(SenderUtil.getSenderId(teleportee), to, desc, delaySeconds); + } + + // CommandSender & SenderEntity + @Override + public void teleport(CommandSender teleportee, SenderEntity to) throws TeleporterException + { + this.teleport(teleportee, to, null); + } + + @Override + public void teleport(CommandSender teleportee, SenderEntity to, String desc) throws TeleporterException + { + this.teleport(teleportee, to, desc, 0); + } + + @Override + public void teleport(CommandSender teleportee, SenderEntity to, String desc, Permissible delayPermissible) throws TeleporterException + { + this.teleport(teleportee, to, desc, getTpdelay(delayPermissible)); + } + + @Override + public void teleport(CommandSender teleportee, SenderEntity to, String desc, int delaySeconds) throws TeleporterException + { + this.teleport(SenderUtil.getSenderId(teleportee), to, desc, delaySeconds); + } + + // CommandSender & String + @Override + public void teleport(CommandSender teleportee, String to) throws TeleporterException + { + this.teleport(teleportee, to, null); + } + + @Override + public void teleport(CommandSender teleportee, String to, String desc) throws TeleporterException + { + this.teleport(teleportee, to, desc, 0); + } + + @Override + public void teleport(CommandSender teleportee, String to, String desc, Permissible delayPermissible) throws TeleporterException + { + this.teleport(teleportee, to, desc, getTpdelay(delayPermissible)); + } + + @Override + public void teleport(CommandSender teleportee, String to, String desc, int delaySeconds) throws TeleporterException + { + this.teleport(SenderUtil.getSenderId(teleportee), to, desc, delaySeconds); + } + + // CommandSender & PSGetter + @Override + public void teleport(CommandSender teleportee, PSGetter to) throws TeleporterException + { + this.teleport(teleportee, to, null); + } + + @Override + public void teleport(CommandSender teleportee, PSGetter to, String desc) throws TeleporterException + { + this.teleport(teleportee, to, desc, 0); + } + + @Override + public void teleport(CommandSender teleportee, PSGetter to, String desc, Permissible delayPermissible) throws TeleporterException + { + this.teleport(teleportee, to, desc, getTpdelay(delayPermissible)); + } + + @Override + public void teleport(CommandSender teleportee, PSGetter to, String desc, int delaySeconds) throws TeleporterException + { + this.teleport(SenderUtil.getSenderId(teleportee), to, desc, delaySeconds); + } + + // -------------------------------------------- // + // SENDER ENTITY + // -------------------------------------------- // + + // SenderEntity & PS + @Override + public void teleport(SenderEntity teleportee, PS to) throws TeleporterException + { + this.teleport(teleportee, to, null); + } + + @Override + public void teleport(SenderEntity teleportee, PS to, String desc) throws TeleporterException + { + this.teleport(teleportee, to, desc, 0); + } + + @Override + public void teleport(SenderEntity teleportee, PS to, String desc, Permissible delayPermissible) throws TeleporterException + { + this.teleport(teleportee, to, desc, getTpdelay(delayPermissible)); + } + + @Override + public void teleport(SenderEntity teleportee, PS to, String desc, int delaySeconds) throws TeleporterException + { + this.teleport(teleportee.getId(), to, desc, delaySeconds); + } + + // SenderEntity & CommandSender + @Override + public void teleport(SenderEntity teleportee, CommandSender to) throws TeleporterException + { + this.teleport(teleportee, to, null); + } + + @Override + public void teleport(SenderEntity teleportee, CommandSender to, String desc) throws TeleporterException + { + this.teleport(teleportee, to, desc, 0); + } + + @Override + public void teleport(SenderEntity teleportee, CommandSender to, String desc, Permissible delayPermissible) throws TeleporterException + { + this.teleport(teleportee, to, desc, getTpdelay(delayPermissible)); + } + + @Override + public void teleport(SenderEntity teleportee, CommandSender to, String desc, int delaySeconds) throws TeleporterException + { + this.teleport(teleportee.getId(), to, desc, delaySeconds); + } + + // SenderEntity & SenderEntity + @Override + public void teleport(SenderEntity teleportee, SenderEntity to) throws TeleporterException + { + this.teleport(teleportee, to, null); + } + + @Override + public void teleport(SenderEntity teleportee, SenderEntity to, String desc) throws TeleporterException + { + this.teleport(teleportee, to, desc, 0); + } + + @Override + public void teleport(SenderEntity teleportee, SenderEntity to, String desc, Permissible delayPermissible) throws TeleporterException + { + this.teleport(teleportee, to, desc, getTpdelay(delayPermissible)); + } + + @Override + public void teleport(SenderEntity teleportee, SenderEntity to, String desc, int delaySeconds) throws TeleporterException + { + this.teleport(teleportee.getId(), to, desc, delaySeconds); + } + + // SenderEntity & String + @Override + public void teleport(SenderEntity teleportee, String to) throws TeleporterException + { + this.teleport(teleportee, to, null); + } + + @Override + public void teleport(SenderEntity teleportee, String to, String desc) throws TeleporterException + { + this.teleport(teleportee, to, desc, 0); + } + + @Override + public void teleport(SenderEntity teleportee, String to, String desc, Permissible delayPermissible) throws TeleporterException + { + this.teleport(teleportee, to, desc, getTpdelay(delayPermissible)); + } + + @Override + public void teleport(SenderEntity teleportee, String to, String desc, int delaySeconds) throws TeleporterException + { + this.teleport(teleportee.getId(), to, desc, delaySeconds); + } + + // SenderEntity & PSGetter + @Override + public void teleport(SenderEntity teleportee, PSGetter to) throws TeleporterException + { + this.teleport(teleportee, to, null); + } + + @Override + public void teleport(SenderEntity teleportee, PSGetter to, String desc) throws TeleporterException + { + this.teleport(teleportee, to, desc, 0); + } + + @Override + public void teleport(SenderEntity teleportee, PSGetter to, String desc, Permissible delayPermissible) throws TeleporterException + { + this.teleport(teleportee, to, desc, getTpdelay(delayPermissible)); + } + + @Override + public void teleport(SenderEntity teleportee, PSGetter to, String desc, int delaySeconds) throws TeleporterException + { + this.teleport(teleportee.getId(), to, desc, delaySeconds); + } + + // -------------------------------------------- // + // STRING + // -------------------------------------------- // + + // String & PS + @Override + public void teleport(String teleportee, PS to) throws TeleporterException + { + this.teleport(teleportee, to, null); + } + + @Override + public void teleport(String teleportee, PS to, String desc) throws TeleporterException + { + this.teleport(teleportee, to, desc, 0); + } + + @Override + public void teleport(String teleportee, PS to, String desc, Permissible delayPermissible) throws TeleporterException + { + this.teleport(teleportee, to, desc, getTpdelay(delayPermissible)); + } + + @Override + public void teleport(String teleportee, PS to, String desc, int delaySeconds) throws TeleporterException + { + this.teleport(teleportee, PSGetterPS.valueOf(to), desc, delaySeconds); + } + + // String & CommandSender + @Override + public void teleport(String teleportee, CommandSender to) throws TeleporterException + { + this.teleport(teleportee, to, null); + } + + @Override + public void teleport(String teleportee, CommandSender to, String desc) throws TeleporterException + { + this.teleport(teleportee, to, desc, 0); + } + + @Override + public void teleport(String teleportee, CommandSender to, String desc, Permissible delayPermissible) throws TeleporterException + { + this.teleport(teleportee, to, desc, getTpdelay(delayPermissible)); + } + + @Override + public void teleport(String teleportee, CommandSender to, String desc, int delaySeconds) throws TeleporterException + { + this.teleport(teleportee, PSGetterPlayer.valueOf(to), desc, delaySeconds); + } + + // String & SenderEntity + @Override + public void teleport(String teleportee, SenderEntity to) throws TeleporterException + { + this.teleport(teleportee, to, null); + } + + @Override + public void teleport(String teleportee, SenderEntity to, String desc) throws TeleporterException + { + this.teleport(teleportee, to, desc, 0); + } + + @Override + public void teleport(String teleportee, SenderEntity to, String desc, Permissible delayPermissible) throws TeleporterException + { + this.teleport(teleportee, to, desc, getTpdelay(delayPermissible)); + } + + @Override + public void teleport(String teleportee, SenderEntity to, String desc, int delaySeconds) throws TeleporterException + { + this.teleport(teleportee, PSGetterPlayer.valueOf(to), desc, delaySeconds); + } + + // String & String + @Override + public void teleport(String teleportee, String to) throws TeleporterException + { + this.teleport(teleportee, to, null); + } + + @Override + public void teleport(String teleportee, String to, String desc) throws TeleporterException + { + this.teleport(teleportee, to, desc, 0); + } + + @Override + public void teleport(String teleportee, String to, String desc, Permissible delayPermissible) throws TeleporterException + { + this.teleport(teleportee, to, desc, getTpdelay(delayPermissible)); + } + + @Override + public void teleport(String teleportee, String to, String desc, int delaySeconds) throws TeleporterException + { + this.teleport(teleportee, PSGetterPlayer.valueOf(to), desc, delaySeconds); + } + + // String & PSGetter + @Override + public void teleport(String teleportee, PSGetter to) throws TeleporterException + { + this.teleport(teleportee, to, null); + } + + @Override + public void teleport(String teleportee, PSGetter to, String desc) throws TeleporterException + { + this.teleport(teleportee, to, desc, 0); + } + + @Override + public void teleport(String teleportee, PSGetter to, String desc, Permissible delayPermissible) throws TeleporterException + { + this.teleport(teleportee, to, desc, getTpdelay(delayPermissible)); + } + } diff --git a/src/com/massivecraft/mcore/mixin/TeleportMixinDefault.java b/src/com/massivecraft/mcore/mixin/TeleportMixinDefault.java index 4a4dca92..8bb6b69d 100644 --- a/src/com/massivecraft/mcore/mixin/TeleportMixinDefault.java +++ b/src/com/massivecraft/mcore/mixin/TeleportMixinDefault.java @@ -7,6 +7,8 @@ import org.bukkit.util.Vector; import com.massivecraft.mcore.event.MCorePlayerPSTeleportEvent; import com.massivecraft.mcore.ps.PS; +import com.massivecraft.mcore.teleport.PSGetter; +import com.massivecraft.mcore.teleport.ScheduledTeleport; import com.massivecraft.mcore.util.SenderUtil; import com.massivecraft.mcore.util.Txt; @@ -69,7 +71,7 @@ public class TeleportMixinDefault extends TeleportMixinAbstract // -------------------------------------------- // @Override - public void teleport(String teleporteeId, PS to, String desc, int delaySeconds) throws TeleporterException + public void teleport(String teleporteeId, PSGetter toGetter, String desc, int delaySeconds) throws TeleporterException { if (!SenderUtil.isPlayerId(teleporteeId)) throw new TeleporterException(Txt.parse("%s is not a player.", Mixin.getDisplayName(teleporteeId))); @@ -85,12 +87,15 @@ public class TeleportMixinDefault extends TeleportMixinAbstract Mixin.msg(teleporteeId, "Teleporting in "+delaySeconds+"s unless you move."); } - new ScheduledTeleport(teleporteeId, to, desc, delaySeconds).schedule(); + new ScheduledTeleport(teleporteeId, toGetter, desc, delaySeconds).schedule(); } else { // Without delay AKA "now"/"at once" + // Resolve the getter + PS to = toGetter.getPS(); + // Run event MCorePlayerPSTeleportEvent event = new MCorePlayerPSTeleportEvent(teleporteeId, Mixin.getSenderPs(teleporteeId), to, desc); event.run(); diff --git a/src/com/massivecraft/mcore/teleport/PSGetter.java b/src/com/massivecraft/mcore/teleport/PSGetter.java new file mode 100644 index 00000000..a77e0c1a --- /dev/null +++ b/src/com/massivecraft/mcore/teleport/PSGetter.java @@ -0,0 +1,10 @@ +package com.massivecraft.mcore.teleport; + +import java.io.Serializable; + +import com.massivecraft.mcore.ps.PS; + +public interface PSGetter extends Serializable +{ + public PS getPS(); +} diff --git a/src/com/massivecraft/mcore/teleport/PSGetterAbstract.java b/src/com/massivecraft/mcore/teleport/PSGetterAbstract.java new file mode 100644 index 00000000..6c287f10 --- /dev/null +++ b/src/com/massivecraft/mcore/teleport/PSGetterAbstract.java @@ -0,0 +1,11 @@ +package com.massivecraft.mcore.teleport; + +public abstract class PSGetterAbstract implements PSGetter +{ + private static final long serialVersionUID = 1L; + + public boolean hasPS() + { + return this.getPS() != null; + } +} diff --git a/src/com/massivecraft/mcore/teleport/PSGetterPS.java b/src/com/massivecraft/mcore/teleport/PSGetterPS.java new file mode 100644 index 00000000..95915508 --- /dev/null +++ b/src/com/massivecraft/mcore/teleport/PSGetterPS.java @@ -0,0 +1,43 @@ +package com.massivecraft.mcore.teleport; + +import com.massivecraft.mcore.ps.PS; + +public final class PSGetterPS extends PSGetterAbstract +{ + private static final long serialVersionUID = 1L; + + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + + private final PS ps; + + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + + private PSGetterPS(PS ps) + { + this.ps = ps; + } + + // -------------------------------------------- // + // VALUE OF + // -------------------------------------------- // + + public static PSGetterPS valueOf(PS ps) + { + return new PSGetterPS(ps); + } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public PS getPS() + { + return this.ps; + } + +} diff --git a/src/com/massivecraft/mcore/teleport/PSGetterPlayer.java b/src/com/massivecraft/mcore/teleport/PSGetterPlayer.java new file mode 100644 index 00000000..980dbfb2 --- /dev/null +++ b/src/com/massivecraft/mcore/teleport/PSGetterPlayer.java @@ -0,0 +1,59 @@ +package com.massivecraft.mcore.teleport; + +import org.bukkit.command.CommandSender; + +import com.massivecraft.mcore.mixin.Mixin; +import com.massivecraft.mcore.ps.PS; +import com.massivecraft.mcore.store.SenderEntity; +import com.massivecraft.mcore.util.SenderUtil; + +public final class PSGetterPlayer extends PSGetterAbstract +{ + private static final long serialVersionUID = 1L; + + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + + private final String senderId; + public String getSenderId() { return this.senderId; } + + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + + private PSGetterPlayer(String senderId) + { + this.senderId = senderId; + } + + // -------------------------------------------- // + // VALUE OF + // -------------------------------------------- // + + public static PSGetterPlayer valueOf(CommandSender player) + { + return new PSGetterPlayer(SenderUtil.getSenderId(player)); + } + + public static PSGetterPlayer valueOf(SenderEntity playerEntity) + { + return new PSGetterPlayer(playerEntity.getId()); + } + + public static PSGetterPlayer valueOf(String playerId) + { + return new PSGetterPlayer(playerId); + } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public PS getPS() + { + return Mixin.getSenderPs(this.senderId); + } + +} diff --git a/src/com/massivecraft/mcore/mixin/ScheduledTeleport.java b/src/com/massivecraft/mcore/teleport/ScheduledTeleport.java similarity index 73% rename from src/com/massivecraft/mcore/mixin/ScheduledTeleport.java rename to src/com/massivecraft/mcore/teleport/ScheduledTeleport.java index 70b39540..9dd9a1c1 100644 --- a/src/com/massivecraft/mcore/mixin/ScheduledTeleport.java +++ b/src/com/massivecraft/mcore/teleport/ScheduledTeleport.java @@ -1,6 +1,7 @@ -package com.massivecraft.mcore.mixin; +package com.massivecraft.mcore.teleport; -import com.massivecraft.mcore.ps.PS; +import com.massivecraft.mcore.mixin.Mixin; +import com.massivecraft.mcore.mixin.TeleporterException; public class ScheduledTeleport implements Runnable { @@ -11,8 +12,8 @@ public class ScheduledTeleport implements Runnable private final String teleporteeId; public String getTeleporteeId() { return this.teleporteeId; } - private final PS destinationPs; - public PS getDestinationPs() { return this.destinationPs; } + private final PSGetter destinationGetter; + public PSGetter getDestinationGetter() { return this.destinationGetter; } private final String destinationDesc; public String getDestinationDesc() { return this.destinationDesc; } @@ -29,10 +30,10 @@ public class ScheduledTeleport implements Runnable // CONSTRUCT // -------------------------------------------- // - public ScheduledTeleport(String teleporteeId, PS destinationPs, String destinationDesc, int delaySeconds) + public ScheduledTeleport(String teleporteeId, PSGetter destinationGetter, String destinationDesc, int delaySeconds) { this.teleporteeId = teleporteeId; - this.destinationPs = destinationPs; + this.destinationGetter = destinationGetter; this.destinationDesc = destinationDesc; this.delaySeconds = delaySeconds; this.dueMillis = 0; @@ -68,7 +69,7 @@ public class ScheduledTeleport implements Runnable try { - Mixin.teleport(this.getTeleporteeId(), this.getDestinationPs(), this.getDestinationDesc()); + Mixin.teleport(this.getTeleporteeId(), this.getDestinationGetter(), this.getDestinationDesc()); } catch (TeleporterException e) { diff --git a/src/com/massivecraft/mcore/mixin/ScheduledTeleportEngine.java b/src/com/massivecraft/mcore/teleport/ScheduledTeleportEngine.java similarity index 94% rename from src/com/massivecraft/mcore/mixin/ScheduledTeleportEngine.java rename to src/com/massivecraft/mcore/teleport/ScheduledTeleportEngine.java index 319d1ab5..1804d617 100644 --- a/src/com/massivecraft/mcore/mixin/ScheduledTeleportEngine.java +++ b/src/com/massivecraft/mcore/teleport/ScheduledTeleportEngine.java @@ -1,4 +1,4 @@ -package com.massivecraft.mcore.mixin; +package com.massivecraft.mcore.teleport; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -10,6 +10,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerMoveEvent; import com.massivecraft.mcore.MCore; +import com.massivecraft.mcore.mixin.Mixin; import com.massivecraft.mcore.util.MUtil; import com.massivecraft.mcore.util.SenderUtil;