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