public static void teleport(EntityPlayerMP player, WarpPoint point) { if (point.getWorld() == null) { DimensionManager.initDimension(point.getDimension()); if (point.getWorld() == null) { ChatOutputHandler.chatError( player, Translator.translate("Unable to teleport! Target dimension does not exist")); return; } } // Check permissions UserIdent ident = UserIdent.get(player); if (!APIRegistry.perms.checkPermission(player, TELEPORT_FROM)) throw new TranslatedCommandException("You are not allowed to teleport from here."); if (!APIRegistry.perms.checkUserPermission(ident, point.toWorldPoint(), TELEPORT_TO)) throw new TranslatedCommandException("You are not allowed to teleport to that location."); if (player.dimension != point.getDimension() && !APIRegistry.perms.checkUserPermission(ident, point.toWorldPoint(), TELEPORT_CROSSDIM)) throw new TranslatedCommandException("You are not allowed to teleport across dimensions."); // Get and check teleport cooldown int teleportCooldown = ServerUtil.parseIntDefault( APIRegistry.perms.getUserPermissionProperty(ident, TELEPORT_COOLDOWN), 0) * 1000; if (teleportCooldown > 0) { PlayerInfo pi = PlayerInfo.get(player); long cooldownDuration = (pi.getLastTeleportTime() + teleportCooldown) - System.currentTimeMillis(); if (cooldownDuration >= 0) { ChatOutputHandler.chatNotification( player, Translator.format("Cooldown still active. %d seconds to go.", cooldownDuration / 1000)); return; } } // Get and check teleport warmup int teleportWarmup = ServerUtil.parseIntDefault( APIRegistry.perms.getUserPermissionProperty(ident, TELEPORT_WARMUP), 0); if (teleportWarmup <= 0) { checkedTeleport(player, point); return; } if (!canTeleportTo(point)) { ChatOutputHandler.chatError( player, Translator.translate("Unable to teleport! Target location obstructed.")); return; } // Setup timed teleport tpInfos.put(player.getPersistentID(), new TeleportInfo(player, point, teleportWarmup * 1000)); ChatOutputHandler.chatNotification( player, Translator.format( "Teleporting. Please stand still for %s.", ChatOutputHandler.formatTimeDurationReadable(teleportWarmup, true))); }
@Override public void processCommandPlayer(EntityPlayerMP player, String[] args) { /*if (!PlayerInfo.get(player).getHasFEClient()) { ChatOutputHandler.chatError(player, "You need the FE client addon to use this command."); ChatOutputHandler.chatError(player, "Please visit https://github.com/ForgeEssentials/ForgeEssentialsMain/wiki/FE-Client-mod for more information."); return; }*/ ChatOutputHandler.chatWarning( player, "Here be dragons. Proceed at own risk. Use /speed reset to reset your speed.."); if (args.length >= 1) { // float speed = Float.parseFloat(args[0]); if (args[0].equals("reset")) { ChatOutputHandler.chatNotification(player, "Resetting speed to regular walking speed."); // NetworkUtils.netHandler.sendTo(new Packet6Speed(0.0F), player); NBTTagCompound tagCompound = new NBTTagCompound(); player.capabilities.writeCapabilitiesToNBT(tagCompound); tagCompound.getCompoundTag("abilities").setTag("flySpeed", new NBTTagFloat(0.05F)); tagCompound.getCompoundTag("abilities").setTag("walkSpeed", new NBTTagFloat(0.1F)); player.capabilities.readCapabilitiesFromNBT(tagCompound); player.sendPlayerAbilities(); return; } float speed = 0.05F; int multiplier = parseInt(player, args[0]); if (multiplier >= 10) { ChatOutputHandler.chatWarning( player, "Multiplier set too high. Bad things may happen, so we're throttling your speed to 10x walking speed."); multiplier = 10; } speed = speed * multiplier; NBTTagCompound tagCompound = new NBTTagCompound(); player.capabilities.writeCapabilitiesToNBT(tagCompound); tagCompound.getCompoundTag("abilities").setTag("flySpeed", new NBTTagFloat(speed)); tagCompound.getCompoundTag("abilities").setTag("walkSpeed", new NBTTagFloat(speed)); player.capabilities.readCapabilitiesFromNBT(tagCompound); player.sendPlayerAbilities(); ChatOutputHandler.chatNotification(player, "Walk/fly speed set to " + speed); // NetworkUtils.netHandler.sendTo(new Packet6Speed(speed), player); } }