Search in sources :

Example 1 with EnumAddressee

use of forestry.api.mail.EnumAddressee in project ForestryMC by ForestryMC.

the class GuiLetter method drawGuiContainerBackgroundLayer.

@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
    if (!isProcessedLetter && !checkedSessionVars) {
        checkedSessionVars = true;
        setFromSessionVars();
        String recipient = this.address.getText();
        EnumAddressee recipientType = container.getCarrierType();
        setRecipient(recipient, recipientType);
    }
    // Check for focus changes
    if (addressFocus != address.isFocused()) {
        String recipient = this.address.getText();
        if (StringUtils.isNotBlank(recipient)) {
            EnumAddressee recipientType = container.getCarrierType();
            setRecipient(recipient, recipientType);
        }
    }
    addressFocus = address.isFocused();
    if (textFocus != text.isFocused()) {
        setText();
    }
    textFocus = text.isFocused();
    super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
    if (this.isProcessedLetter) {
        fontRendererObj.drawString(address.getText(), guiLeft + 49, guiTop + 16, fontColor.get("gui.mail.lettertext"));
        fontRendererObj.drawSplitString(text.getText(), guiLeft + 20, guiTop + 34, 119, fontColor.get("gui.mail.lettertext"));
    } else {
        clearTradeInfoWidgets();
        address.drawTextBox();
        if (container.getCarrierType() == EnumAddressee.TRADER) {
            drawTradePreview(18, 32);
        } else {
            text.drawTextBox();
        }
    }
}
Also used : EnumAddressee(forestry.api.mail.EnumAddressee)

Example 2 with EnumAddressee

use of forestry.api.mail.EnumAddressee in project ForestryMC by ForestryMC.

the class ContainerLetter method handleSetRecipient.

public void handleSetRecipient(EntityPlayer player, PacketUpdate packet) {
    String recipientName = packet.payload.stringPayload[0];
    String typeName = packet.payload.stringPayload[1];
    EnumAddressee type = EnumAddressee.fromString(typeName);
    IMailAddress recipient;
    if (type == EnumAddressee.PLAYER) {
        GameProfile gameProfile = MinecraftServer.getServer().func_152358_ax().func_152655_a(recipientName);
        if (gameProfile == null) {
            gameProfile = new GameProfile(new UUID(0, 0), recipientName);
        }
        recipient = PostManager.postRegistry.getMailAddress(gameProfile);
    } else if (type == EnumAddressee.TRADER) {
        recipient = PostManager.postRegistry.getMailAddress(recipientName);
    } else {
        return;
    }
    getLetter().setRecipient(recipient);
    // Update the trading info
    if (recipient == null || recipient.isTrader()) {
        updateTradeInfo(player.worldObj, recipient);
    }
    // Update info on client
    Proxies.net.sendToPlayer(new PacketLetterInfo(PacketIds.LETTER_INFO, type, tradeInfo, recipient), player);
}
Also used : EnumAddressee(forestry.api.mail.EnumAddressee) IMailAddress(forestry.api.mail.IMailAddress) GameProfile(com.mojang.authlib.GameProfile) UUID(java.util.UUID) PacketLetterInfo(forestry.mail.network.PacketLetterInfo)

Example 3 with EnumAddressee

use of forestry.api.mail.EnumAddressee in project ForestryMC by ForestryMC.

the class GuiLetter method setFromSessionVars.

private void setFromSessionVars() {
    if (SessionVars.getStringVar("mail.letter.recipient") == null) {
        return;
    }
    String recipient = SessionVars.getStringVar("mail.letter.recipient");
    String typeName = SessionVars.getStringVar("mail.letter.addressee");
    if (StringUtils.isNotBlank(recipient) && StringUtils.isNotBlank(typeName)) {
        address.setText(recipient);
        EnumAddressee type = EnumAddressee.fromString(typeName);
        container.setCarrierType(type);
    }
    SessionVars.clearStringVar("mail.letter.recipient");
    SessionVars.clearStringVar("mail.letter.addressee");
}
Also used : EnumAddressee(forestry.api.mail.EnumAddressee)

Example 4 with EnumAddressee

use of forestry.api.mail.EnumAddressee in project ForestryMC by ForestryMC.

the class GuiLetter method onGuiClosed.

@Override
public void onGuiClosed() {
    String recipientName = this.address.getText();
    EnumAddressee recipientType = container.getCarrierType();
    setRecipient(recipientName, recipientType);
    setText();
    Keyboard.enableRepeatEvents(false);
    super.onGuiClosed();
}
Also used : EnumAddressee(forestry.api.mail.EnumAddressee)

Aggregations

EnumAddressee (forestry.api.mail.EnumAddressee)4 GameProfile (com.mojang.authlib.GameProfile)1 IMailAddress (forestry.api.mail.IMailAddress)1 PacketLetterInfo (forestry.mail.network.PacketLetterInfo)1 UUID (java.util.UUID)1