turt2live

Untitled

Jan 1st, 2013
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.91 KB | None | 0 0
  1. package com.turt2live.xmail.spout;
  2.  
  3. import java.util.HashMap;
  4. import java.util.Map;
  5.  
  6. import org.bukkit.entity.Player;
  7. import org.getspout.spoutapi.gui.GenericButton;
  8. import org.getspout.spoutapi.gui.GenericLabel;
  9. import org.getspout.spoutapi.gui.GenericPopup;
  10. import org.getspout.spoutapi.gui.GenericTextField;
  11. import org.getspout.spoutapi.gui.WidgetAnchor;
  12. import org.getspout.spoutapi.player.SpoutPlayer;
  13.  
  14. import com.turt2live.xmail.XMail;
  15.  
  16. public class SpoutSendMail {
  17.  
  18.     private static XMail plugin = XMail.getInstance();
  19.     public static final Map<SpoutPlayer, GenericPopup> playerPopup = new HashMap<SpoutPlayer, GenericPopup>();
  20.  
  21.     private static final int labelWidth = 25, labelHeight = 20, labelX = 5, labelY = 11,
  22.             textWidth = 400, toHeight = 20, messageHeight = 175, padding = 5, buttonWidth = (labelWidth * 2) + 12,
  23.             buttonHeight = labelHeight;
  24.  
  25.     public static boolean show(Player owner){
  26.         if(owner instanceof SpoutPlayer){
  27.             SpoutPlayer player = (SpoutPlayer) owner;
  28.  
  29.             GenericPopup popup = new GenericPopup();
  30.  
  31.             GenericLabel toLbl = new GenericLabel("To:");
  32.             toLbl.setAnchor(WidgetAnchor.TOP_LEFT);
  33.             toLbl.setWidth(labelWidth).setHeight(labelHeight);
  34.             toLbl.shiftXPos(labelX).shiftYPos(labelY);
  35.  
  36.             GenericLabel messageLbl = new GenericLabel("Message:");
  37.             messageLbl.setWidth(labelWidth).setHeight(labelHeight);
  38.             messageLbl.shiftXPos(labelX).shiftYPos(labelY + toLbl.getHeight());
  39.  
  40.             GenericTextField toTxt = new GenericTextField();
  41.             toTxt.setAnchor(WidgetAnchor.TOP_LEFT);
  42.             toTxt.setWidth(textWidth).setHeight(toHeight);
  43.             toTxt.setMaximumCharacters(60);
  44.             toTxt.setMaximumLines(1);
  45.             toTxt.shiftXPos(toLbl.getWidth() + padding + padding).shiftYPos(padding);
  46.  
  47.             GenericTextField messageTxt = new GenericTextField();
  48.             messageTxt.setAnchor(WidgetAnchor.TOP_LEFT);
  49.             messageTxt.setWidth(textWidth).setHeight(messageHeight);
  50.             messageTxt.setMaximumCharacters(1500);
  51.             messageTxt.setMaximumLines(14);
  52.             messageTxt.shiftXPos(messageLbl.getWidth() + padding + padding).shiftYPos(padding + padding + toTxt.getHeight());
  53.  
  54.             GenericButton cancelBtn = new GenericButton("Cancel");
  55.             cancelBtn.setAnchor(WidgetAnchor.BOTTOM_RIGHT);
  56.             cancelBtn.setWidth(buttonWidth).setHeight(buttonHeight);
  57.             cancelBtn.shiftXPos(-(padding + buttonWidth)).shiftYPos(-(padding + buttonHeight));
  58.  
  59.             GenericButton sendBtn = new GenericButton("Send");
  60.             sendBtn.setAnchor(WidgetAnchor.BOTTOM_LEFT);
  61.             sendBtn.setWidth(buttonWidth).setHeight(buttonHeight);
  62.             sendBtn.shiftXPos(padding).shiftYPos(-(buttonHeight + padding));
  63.  
  64.             popup.attachWidget(plugin, toLbl);
  65.             popup.attachWidget(plugin, messageLbl);
  66.             popup.attachWidget(plugin, toTxt);
  67.             popup.attachWidget(plugin, messageTxt);
  68.             popup.attachWidget(plugin, cancelBtn);
  69.             popup.attachWidget(plugin, sendBtn);
  70.  
  71.             playerPopup.put(player, popup);
  72.             player.getMainScreen().attachPopupScreen(popup);
  73.         }
  74.         return false;
  75.     }
  76.  
  77. }
Advertisement
Add Comment
Please, Sign In to add comment