Improve upon the teleport mixin again. Lazy destination plz :)

This commit is contained in:
Olof Larsson 2013-08-05 09:02:42 +02:00
parent 8babb5b502
commit 62b0e8f8b3
11 changed files with 909 additions and 103 deletions

View File

@ -22,13 +22,13 @@ import com.massivecraft.mcore.integration.vault.VaultFeatures;
import com.massivecraft.mcore.mcorecmd.CmdMCore; import com.massivecraft.mcore.mcorecmd.CmdMCore;
import com.massivecraft.mcore.mcorecmd.CmdMCoreMStore; import com.massivecraft.mcore.mcorecmd.CmdMCoreMStore;
import com.massivecraft.mcore.mcorecmd.CmdMCoreUsys; import com.massivecraft.mcore.mcorecmd.CmdMCoreUsys;
import com.massivecraft.mcore.mixin.ScheduledTeleportEngine;
import com.massivecraft.mcore.mixin.SenderIdMixinDefault; import com.massivecraft.mcore.mixin.SenderIdMixinDefault;
import com.massivecraft.mcore.mixin.TeleportMixinCauseEngine; import com.massivecraft.mcore.mixin.TeleportMixinCauseEngine;
import com.massivecraft.mcore.ps.PS; import com.massivecraft.mcore.ps.PS;
import com.massivecraft.mcore.ps.PSAdapter; import com.massivecraft.mcore.ps.PSAdapter;
import com.massivecraft.mcore.store.Coll; import com.massivecraft.mcore.store.Coll;
import com.massivecraft.mcore.store.ExamineThread; import com.massivecraft.mcore.store.ExamineThread;
import com.massivecraft.mcore.teleport.ScheduledTeleportEngine;
import com.massivecraft.mcore.util.PlayerUtil; import com.massivecraft.mcore.util.PlayerUtil;
import com.massivecraft.mcore.util.TimeDiffUtil; import com.massivecraft.mcore.util.TimeDiffUtil;
import com.massivecraft.mcore.util.TimeUnit; import com.massivecraft.mcore.util.TimeUnit;

View File

@ -6,7 +6,6 @@ import java.util.Set;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.permissions.Permissible; import org.bukkit.permissions.Permissible;
@ -14,6 +13,8 @@ import org.bukkit.permissions.Permissible;
import com.massivecraft.mcore.Predictate; import com.massivecraft.mcore.Predictate;
import com.massivecraft.mcore.event.MCorePlayerLeaveEvent; import com.massivecraft.mcore.event.MCorePlayerLeaveEvent;
import com.massivecraft.mcore.ps.PS; import com.massivecraft.mcore.ps.PS;
import com.massivecraft.mcore.store.SenderEntity;
import com.massivecraft.mcore.teleport.PSGetter;
public class Mixin public class Mixin
{ {
@ -279,38 +280,274 @@ public class Mixin
return getTeleportMixin().isCausedByMixin(event); 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);
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -1,10 +1,12 @@
package com.massivecraft.mcore.mixin; package com.massivecraft.mcore.mixin;
import org.bukkit.entity.Player; import org.bukkit.command.CommandSender;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.permissions.Permissible; import org.bukkit.permissions.Permissible;
import com.massivecraft.mcore.ps.PS; import com.massivecraft.mcore.ps.PS;
import com.massivecraft.mcore.store.SenderEntity;
import com.massivecraft.mcore.teleport.PSGetter;
public interface TeleportMixin public interface TeleportMixin
{ {
@ -14,28 +16,126 @@ public interface TeleportMixin
public boolean isCausedByMixin(PlayerTeleportEvent event); public boolean isCausedByMixin(PlayerTeleportEvent event);
// -------------------------------------------- // // PERMUTATION
// PLAYER //
// -------------------------------------------- // // # teleportee
// CommandSender
public void teleport(Player teleportee, PS to) throws TeleporterException; // SenderEntity
// String
public void teleport(Player teleportee, PS to, String desc) throws TeleporterException; //
// # to
public void teleport(Player teleportee, PS to, String desc, Permissible delayPermissible) throws TeleporterException; // PS
// CommandSender
public void teleport(Player teleportee, PS to, String desc, int delaySeconds) throws TeleporterException; // 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;
} }

View File

@ -1,71 +1,19 @@
package com.massivecraft.mcore.mixin; package com.massivecraft.mcore.mixin;
import org.bukkit.entity.Player; import org.bukkit.command.CommandSender;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.permissions.Permissible; import org.bukkit.permissions.Permissible;
import com.massivecraft.mcore.MCoreConf; import com.massivecraft.mcore.MCoreConf;
import com.massivecraft.mcore.ps.PS; 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; import com.massivecraft.mcore.util.SenderUtil;
public abstract class TeleportMixinAbstract implements TeleportMixin 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 // UTIL
// -------------------------------------------- // // -------------------------------------------- //
@ -75,4 +23,395 @@ public abstract class TeleportMixinAbstract implements TeleportMixin
return MCoreConf.get().getTpdelay(delayPermissible); 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));
}
} }

View File

@ -7,6 +7,8 @@ import org.bukkit.util.Vector;
import com.massivecraft.mcore.event.MCorePlayerPSTeleportEvent; import com.massivecraft.mcore.event.MCorePlayerPSTeleportEvent;
import com.massivecraft.mcore.ps.PS; 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.SenderUtil;
import com.massivecraft.mcore.util.Txt; import com.massivecraft.mcore.util.Txt;
@ -69,7 +71,7 @@ public class TeleportMixinDefault extends TeleportMixinAbstract
// -------------------------------------------- // // -------------------------------------------- //
@Override @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("<white>%s <b>is not a player.", Mixin.getDisplayName(teleporteeId))); if (!SenderUtil.isPlayerId(teleporteeId)) throw new TeleporterException(Txt.parse("<white>%s <b>is not a player.", Mixin.getDisplayName(teleporteeId)));
@ -85,12 +87,15 @@ public class TeleportMixinDefault extends TeleportMixinAbstract
Mixin.msg(teleporteeId, "<i>Teleporting in <h>"+delaySeconds+"s <i>unless you move."); Mixin.msg(teleporteeId, "<i>Teleporting in <h>"+delaySeconds+"s <i>unless you move.");
} }
new ScheduledTeleport(teleporteeId, to, desc, delaySeconds).schedule(); new ScheduledTeleport(teleporteeId, toGetter, desc, delaySeconds).schedule();
} }
else else
{ {
// Without delay AKA "now"/"at once" // Without delay AKA "now"/"at once"
// Resolve the getter
PS to = toGetter.getPS();
// Run event // Run event
MCorePlayerPSTeleportEvent event = new MCorePlayerPSTeleportEvent(teleporteeId, Mixin.getSenderPs(teleporteeId), to, desc); MCorePlayerPSTeleportEvent event = new MCorePlayerPSTeleportEvent(teleporteeId, Mixin.getSenderPs(teleporteeId), to, desc);
event.run(); event.run();

View File

@ -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();
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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 public class ScheduledTeleport implements Runnable
{ {
@ -11,8 +12,8 @@ public class ScheduledTeleport implements Runnable
private final String teleporteeId; private final String teleporteeId;
public String getTeleporteeId() { return this.teleporteeId; } public String getTeleporteeId() { return this.teleporteeId; }
private final PS destinationPs; private final PSGetter destinationGetter;
public PS getDestinationPs() { return this.destinationPs; } public PSGetter getDestinationGetter() { return this.destinationGetter; }
private final String destinationDesc; private final String destinationDesc;
public String getDestinationDesc() { return this.destinationDesc; } public String getDestinationDesc() { return this.destinationDesc; }
@ -29,10 +30,10 @@ public class ScheduledTeleport implements Runnable
// CONSTRUCT // 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.teleporteeId = teleporteeId;
this.destinationPs = destinationPs; this.destinationGetter = destinationGetter;
this.destinationDesc = destinationDesc; this.destinationDesc = destinationDesc;
this.delaySeconds = delaySeconds; this.delaySeconds = delaySeconds;
this.dueMillis = 0; this.dueMillis = 0;
@ -68,7 +69,7 @@ public class ScheduledTeleport implements Runnable
try try
{ {
Mixin.teleport(this.getTeleporteeId(), this.getDestinationPs(), this.getDestinationDesc()); Mixin.teleport(this.getTeleporteeId(), this.getDestinationGetter(), this.getDestinationDesc());
} }
catch (TeleporterException e) catch (TeleporterException e)
{ {

View File

@ -1,4 +1,4 @@
package com.massivecraft.mcore.mixin; package com.massivecraft.mcore.teleport;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -10,6 +10,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import com.massivecraft.mcore.MCore; import com.massivecraft.mcore.MCore;
import com.massivecraft.mcore.mixin.Mixin;
import com.massivecraft.mcore.util.MUtil; import com.massivecraft.mcore.util.MUtil;
import com.massivecraft.mcore.util.SenderUtil; import com.massivecraft.mcore.util.SenderUtil;