use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.
the class TeleportToColony method teleportPlayer.
/**
* Method used to teleport the player.
*
* @param colID the senders colony ID.
* @param playerToTeleport the player which shall be teleported.
*/
private static void teleportPlayer(final EntityPlayer playerToTeleport, final int colID, final ICommandSender sender) {
final Colony colony = ColonyManager.getColony(colID);
final BuildingTownHall townHall = colony.getBuildingManager().getTownHall();
if (townHall == null) {
sender.sendMessage(new TextComponentString(NO_TOWNHALL));
return;
}
playerToTeleport.sendMessage(new TextComponentString("We got places to go, kid..."));
final BlockPos position = townHall.getLocation();
final int dimension = playerToTeleport.getEntityWorld().provider.getDimension();
final int colonyDimension = townHall.getColony().getDimension();
if (colID < MIN_COLONY_ID) {
playerToTeleport.sendMessage(new TextComponentString(CANT_FIND_COLONY));
return;
}
final EntityPlayerMP entityPlayerMP = (EntityPlayerMP) sender;
if (dimension != colonyDimension) {
playerToTeleport.sendMessage(new TextComponentString("Buckle up buttercup, this ain't no joy ride!!!"));
final MinecraftServer server = sender.getEntityWorld().getMinecraftServer();
final WorldServer worldServer = server.getWorld(colonyDimension);
// Vanilla does that as well.
entityPlayerMP.connection.sendPacket(new SPacketEffect(SOUND_TYPE, BlockPos.ORIGIN, 0, false));
entityPlayerMP.addExperience(0);
entityPlayerMP.setPlayerHealthUpdated();
playerToTeleport.sendMessage(new TextComponentString("Hold onto your pants, we're going Inter-Dimensional!"));
worldServer.getMinecraftServer().getPlayerList().transferPlayerToDimension(entityPlayerMP, colonyDimension, new Teleporter(worldServer));
if (dimension == 1) {
worldServer.spawnEntity(playerToTeleport);
worldServer.updateEntityWithOptionalForce(playerToTeleport, false);
}
}
entityPlayerMP.connection.setPlayerLocation(position.getX(), position.getY() + 2.0, position.getZ(), entityPlayerMP.rotationYaw, entityPlayerMP.rotationPitch);
}
use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.
the class ShowColonyInfoCommand method execute.
@Override
public void execute(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final String... args) throws CommandException {
int colonyId = getIthArgument(args, 0, -1);
IColony tempColony = ColonyManager.getColony(colonyId);
if (colonyId == -1 && args.length >= 1) {
final GameProfile playerProfile = server.getPlayerProfileCache().getGameProfileForUsername(args[0]);
if (playerProfile != null) {
tempColony = ColonyManager.getIColonyByOwner(server.getEntityWorld(), playerProfile.getId());
}
}
if (sender.getCommandSenderEntity() != null) {
final UUID mayorID = sender.getCommandSenderEntity().getUniqueID();
if (tempColony == null) {
tempColony = ColonyManager.getIColonyByOwner(sender.getEntityWorld(), mayorID);
}
if (tempColony != null) {
colonyId = tempColony.getID();
}
final EntityPlayer player = (EntityPlayer) sender;
if (!canPlayerUseCommand(player, SHOWCOLONYINFO, colonyId)) {
sender.getCommandSenderEntity().sendMessage(new TextComponentString(NOT_PERMITTED));
return;
}
}
if (tempColony == null) {
if (colonyId == -1 && args.length != 0) {
sender.sendMessage(new TextComponentString(String.format(NO_COLONY_FOR_PLAYER_FOUND_MESSAGE, args[0])));
} else {
sender.sendMessage(new TextComponentString(String.format(NO_COLONY_WITH_ID_FOUND_MESSAGE, colonyId)));
}
return;
}
final Colony colony = ColonyManager.getColony(tempColony.getID());
if (colony == null) {
if (colonyId == -1 && args.length != 0) {
sender.sendMessage(new TextComponentString(String.format(NO_COLONY_FOR_PLAYER_FOUND_MESSAGE, args[0])));
} else {
sender.sendMessage(new TextComponentString(String.format(NO_COLONY_WITH_ID_FOUND_MESSAGE, colonyId)));
}
return;
}
executeShared(server, sender, colony);
}
use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.
the class ShowColonyInfoCommand method executeShared.
private void executeShared(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final Colony colony) throws CommandException {
final BlockPos position = colony.getCenter();
sender.sendMessage(new TextComponentString(ID_TEXT + colony.getID() + NAME_TEXT + colony.getName()));
final String mayor = colony.getPermissions().getOwnerName();
sender.sendMessage(new TextComponentString(MAYOR_TEXT + mayor));
sender.sendMessage(new TextComponentString(CITIZENS + colony.getCitizenManager().getCitizens().size() + "/" + colony.getCitizenManager().getMaxCitizens()));
sender.sendMessage(new TextComponentString(COORDINATES_TEXT + String.format(COORDINATES_XYZ, position.getX(), position.getY(), position.getZ())));
sender.sendMessage(new TextComponentString(String.format(LAST_CONTACT_TEXT, colony.getLastContactInHours())));
sender.sendMessage(new TextComponentString(IS_DELETABLE + !colony.canBeAutoDeleted()));
if (!colony.isCanHaveBarbEvents()) {
sender.sendMessage(new TextComponentString(CANNOT_BE_RAIDED));
}
}
use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.
the class RSResetCommand method executeShared.
private void executeShared(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final Colony colony) throws CommandException {
final Entity senderEntity = sender.getCommandSenderEntity();
if (senderEntity instanceof EntityPlayer) {
final EntityPlayer player = (EntityPlayer) sender;
if (!canPlayerUseCommand(player, RSRESET, colony.getID())) {
senderEntity.sendMessage(new TextComponentString(NOT_PERMITTED));
return;
}
}
colony.getRequestManager().reset();
sender.sendMessage(new TextComponentString(String.format(SUCCESS_MESSAGE, colony.getID())));
}
use of net.minecraft.util.text.TextComponentString in project minecolonies by Minecolonies.
the class RandomTeleportCommand method executeShared.
private void executeShared(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, final String playerName) throws CommandException {
if (SPAWN_NO_TP >= LOWER_BOUNDS) {
sender.sendMessage(new TextComponentString("Please have an admin raise the maxDistanceFromWorldSpawn number in config."));
return;
}
if (!canCommandSenderUseCommand(RTP) || sender.getEntityWorld().provider.getDimension() != 0) {
sender.sendMessage(new TextComponentString("Not happenin bro!!, ask an OP to TP you."));
return;
}
EntityPlayer playerToTeleport = null;
if (sender instanceof EntityPlayer) {
playerToTeleport = (EntityPlayer) sender;
}
// If the arguments aren't empty, the sender probably wants to teleport another player.
if ((null != playerName) && isPlayerOpped(sender)) {
final World world = FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld();
playerToTeleport = ServerUtils.getPlayerFromUUID(FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerProfileCache().getGameProfileForUsername(playerName).getId(), world);
sender.sendMessage(new TextComponentString("TPing Player: " + playerToTeleport.getName()));
}
if (playerToTeleport == null) {
sender.sendMessage(new TextComponentString(CANT_FIND_PLAYER));
return;
}
teleportPlayer(sender, playerToTeleport);
// .fallDistance is used to cancel out fall damage basically if you have -5 it will reduce fall damage by 2.5 hearts
playerToTeleport.fallDistance = FALL_DISTANCE;
}
Aggregations