Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.turt2live.xmail.spout;
- import java.util.HashMap;
- import java.util.Map;
- import org.bukkit.entity.Player;
- import org.getspout.spoutapi.gui.GenericButton;
- import org.getspout.spoutapi.gui.GenericLabel;
- import org.getspout.spoutapi.gui.GenericPopup;
- import org.getspout.spoutapi.gui.GenericTextField;
- import org.getspout.spoutapi.gui.WidgetAnchor;
- import org.getspout.spoutapi.player.SpoutPlayer;
- import com.turt2live.xmail.XMail;
- public class SpoutSendMail {
- private static XMail plugin = XMail.getInstance();
- public static final Map<SpoutPlayer, GenericPopup> playerPopup = new HashMap<SpoutPlayer, GenericPopup>();
- private static final int labelWidth = 25, labelHeight = 20, labelX = 5, labelY = 11,
- textWidth = 400, toHeight = 20, messageHeight = 175, padding = 5, buttonWidth = (labelWidth * 2) + 12,
- buttonHeight = labelHeight;
- public static boolean show(Player owner){
- if(owner instanceof SpoutPlayer){
- SpoutPlayer player = (SpoutPlayer) owner;
- GenericPopup popup = new GenericPopup();
- GenericLabel toLbl = new GenericLabel("To:");
- toLbl.setAnchor(WidgetAnchor.TOP_LEFT);
- toLbl.setWidth(labelWidth).setHeight(labelHeight);
- toLbl.shiftXPos(labelX).shiftYPos(labelY);
- GenericLabel messageLbl = new GenericLabel("Message:");
- messageLbl.setWidth(labelWidth).setHeight(labelHeight);
- messageLbl.shiftXPos(labelX).shiftYPos(labelY + toLbl.getHeight());
- GenericTextField toTxt = new GenericTextField();
- toTxt.setAnchor(WidgetAnchor.TOP_LEFT);
- toTxt.setWidth(textWidth).setHeight(toHeight);
- toTxt.setMaximumCharacters(60);
- toTxt.setMaximumLines(1);
- toTxt.shiftXPos(toLbl.getWidth() + padding + padding).shiftYPos(padding);
- GenericTextField messageTxt = new GenericTextField();
- messageTxt.setAnchor(WidgetAnchor.TOP_LEFT);
- messageTxt.setWidth(textWidth).setHeight(messageHeight);
- messageTxt.setMaximumCharacters(1500);
- messageTxt.setMaximumLines(14);
- messageTxt.shiftXPos(messageLbl.getWidth() + padding + padding).shiftYPos(padding + padding + toTxt.getHeight());
- GenericButton cancelBtn = new GenericButton("Cancel");
- cancelBtn.setAnchor(WidgetAnchor.BOTTOM_RIGHT);
- cancelBtn.setWidth(buttonWidth).setHeight(buttonHeight);
- cancelBtn.shiftXPos(-(padding + buttonWidth)).shiftYPos(-(padding + buttonHeight));
- GenericButton sendBtn = new GenericButton("Send");
- sendBtn.setAnchor(WidgetAnchor.BOTTOM_LEFT);
- sendBtn.setWidth(buttonWidth).setHeight(buttonHeight);
- sendBtn.shiftXPos(padding).shiftYPos(-(buttonHeight + padding));
- popup.attachWidget(plugin, toLbl);
- popup.attachWidget(plugin, messageLbl);
- popup.attachWidget(plugin, toTxt);
- popup.attachWidget(plugin, messageTxt);
- popup.attachWidget(plugin, cancelBtn);
- popup.attachWidget(plugin, sendBtn);
- playerPopup.put(player, popup);
- player.getMainScreen().attachPopupScreen(popup);
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment