Search in sources :

Example 6 with PS

use of com.massivecraft.massivecore.ps.PS in project MassiveCore by MassiveCraft.

the class MixinTeleport method teleport.

// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
public void teleport(Object teleporteeObject, Destination destination, int delaySeconds) throws TeleporterException {
    String teleporteeId = IdUtil.getId(teleporteeObject);
    if (!IdUtil.isPlayerId(teleporteeId))
        throw new TeleporterException(Txt.parse("<white>%s <b>is not a player.", MixinDisplayName.get().getDisplayName(teleporteeId, IdUtil.getConsole())));
    PS ps;
    try {
        ps = destination.getPs(teleporteeId);
    } catch (Exception e) {
        throw new TeleporterException(e.getMessage());
    }
    String desc = destination.getDesc(teleporteeId);
    if (delaySeconds > 0) {
        // With delay
        if (desc != null && !desc.isEmpty()) {
            MixinMessage.get().msgOne(teleporteeId, "<i>Teleporting to <h>" + desc + " <i>in <h>" + delaySeconds + "s <i>unless you move.");
        } else {
            MixinMessage.get().msgOne(teleporteeId, "<i>Teleporting in <h>" + delaySeconds + "s <i>unless you move.");
        }
        new ScheduledTeleport(teleporteeId, destination, delaySeconds).schedule();
    } else {
        // Without delay AKA "now"/"at once"
        // Run event
        EventMassiveCorePlayerPSTeleport event = new EventMassiveCorePlayerPSTeleport(teleporteeId, MixinSenderPs.get().getSenderPs(teleporteeId), destination);
        event.run();
        if (event.isCancelled())
            return;
        destination = event.getDestination();
        desc = destination.getDesc(teleporteeId);
        if (desc != null && !desc.isEmpty()) {
            MixinMessage.get().msgOne(teleporteeId, "<i>Teleporting to <h>" + desc + "<i>.");
        }
        Player teleportee = IdUtil.getPlayer(teleporteeId);
        if (teleportee != null) {
            teleportPlayer(teleportee, ps);
        } else {
            MixinSenderPs.get().setSenderPs(teleporteeId, ps);
        }
    }
}
Also used : EventMassiveCorePlayerPSTeleport(com.massivecraft.massivecore.event.EventMassiveCorePlayerPSTeleport) Player(org.bukkit.entity.Player) PS(com.massivecraft.massivecore.ps.PS) ScheduledTeleport(com.massivecraft.massivecore.teleport.ScheduledTeleport)

Example 7 with PS

use of com.massivecraft.massivecore.ps.PS in project MassiveCore by MassiveCraft.

the class MixinWorld method trySetWorldSpawnWp.

public boolean trySetWorldSpawnWp(CommandSender sender, String worldId, PS goal, boolean verbooseChange, boolean verbooseSame) {
    World world = Bukkit.getWorld(worldId);
    if (world == null) {
        if (verbooseChange || verbooseSame) {
            MixinMessage.get().msgOne(sender, "<b>Unknown world <h>%s<b>.", worldId);
        }
        return false;
    }
    // Pre Calculations
    String worldDisplayName = MixinWorld.get().getWorldDisplayName(worldId);
    PS current = this.getWorldSpawnPs(worldId);
    String currentFormatted = current.toString(PSFormatDesc.get());
    String goalFormatted = goal.toString(PSFormatDesc.get());
    // No change?
    if (MUtil.equals(goal, current)) {
        if (verbooseSame) {
            MixinMessage.get().msgOne(sender, "<i>Spawn location is already <h>%s <i>for <h>%s<i>.", currentFormatted, worldDisplayName);
        }
        return true;
    }
    // Report
    if (verbooseChange) {
        MixinMessage.get().msgOne(sender, "<i>Changing spawn location from <h>%s <i>to <h>%s <i>for <h>%s<i>.", currentFormatted, goalFormatted, worldDisplayName);
    }
    // Set it
    this.setWorldSpawnPs(worldId, goal);
    // Return
    return true;
}
Also used : PS(com.massivecraft.massivecore.ps.PS) World(org.bukkit.World)

Aggregations

PS (com.massivecraft.massivecore.ps.PS)7 EventHandler (org.bukkit.event.EventHandler)3 MassiveException (com.massivecraft.massivecore.MassiveException)2 World (org.bukkit.World)2 Player (org.bukkit.entity.Player)2 Region (br.net.fabiozumbi12.RedProtect.Bukkit.Region)1 EventFactionsChunkChangeType (com.massivecraft.factions.event.EventFactionsChunkChangeType)1 EventFactionsChunksChange (com.massivecraft.factions.event.EventFactionsChunksChange)1 EventFactionsCreate (com.massivecraft.factions.event.EventFactionsCreate)1 EventFactionsDisband (com.massivecraft.factions.event.EventFactionsDisband)1 EventFactionsMembershipChange (com.massivecraft.factions.event.EventFactionsMembershipChange)1 EventFactionsPowerChange (com.massivecraft.factions.event.EventFactionsPowerChange)1 EventFactionsRelationChange (com.massivecraft.factions.event.EventFactionsRelationChange)1 TypePS (com.massivecraft.massivecore.command.type.TypePS)1 EventMassiveCoreDestination (com.massivecraft.massivecore.event.EventMassiveCoreDestination)1 EventMassiveCorePlayerPSTeleport (com.massivecraft.massivecore.event.EventMassiveCorePlayerPSTeleport)1 PSBuilder (com.massivecraft.massivecore.ps.PSBuilder)1 Destination (com.massivecraft.massivecore.teleport.Destination)1 DestinationSimple (com.massivecraft.massivecore.teleport.DestinationSimple)1 ScheduledTeleport (com.massivecraft.massivecore.teleport.ScheduledTeleport)1