PageRenderTime 609ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/moCreatures/server/core/sources/net/minecraft/src/ServerGUI.java

https://code.google.com/p/minecraft-smp-mocreatures/
Java | 106 lines | 86 code | 14 blank | 6 comment | 0 complexity | 09ef4de2c4f3707a5c615d60b04812b5 MD5 | raw file
  1. // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
  2. // Jad home page: http://www.kpdus.com/jad.html
  3. // Decompiler options: packimports(3) braces deadcode
  4. package net.minecraft.src;
  5. import java.awt.BorderLayout;
  6. import java.awt.Dimension;
  7. import java.util.logging.Logger;
  8. import javax.swing.*;
  9. import javax.swing.border.EtchedBorder;
  10. import javax.swing.border.TitledBorder;
  11. import net.minecraft.server.MinecraftServer;
  12. // Referenced classes of package net.minecraft.src:
  13. // GuiLogOutputHandler, GuiStatsComponent, PlayerListBox, ICommandListener,
  14. // ServerWindowAdapter, ServerGuiCommandListener, ServerGuiFocusAdapter
  15. public class ServerGUI extends JComponent
  16. implements ICommandListener
  17. {
  18. public static void initGui(MinecraftServer minecraftserver)
  19. {
  20. try
  21. {
  22. UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  23. }
  24. catch(Exception exception) { }
  25. ServerGUI servergui = new ServerGUI(minecraftserver);
  26. JFrame jframe = new JFrame("Minecraft server");
  27. jframe.add(servergui);
  28. jframe.pack();
  29. jframe.setLocationRelativeTo(null);
  30. jframe.setVisible(true);
  31. jframe.addWindowListener(new ServerWindowAdapter(minecraftserver));
  32. }
  33. public ServerGUI(MinecraftServer minecraftserver)
  34. {
  35. mcServer = minecraftserver;
  36. setPreferredSize(new Dimension(854, 480));
  37. setLayout(new BorderLayout());
  38. try
  39. {
  40. add(getLogComponent(), "Center");
  41. add(getStatsComponent(), "West");
  42. }
  43. catch(Exception exception)
  44. {
  45. exception.printStackTrace();
  46. }
  47. }
  48. private JComponent getStatsComponent()
  49. {
  50. JPanel jpanel = new JPanel(new BorderLayout());
  51. jpanel.add(new GuiStatsComponent(), "North");
  52. jpanel.add(getPlayerListComponent(), "Center");
  53. jpanel.setBorder(new TitledBorder(new EtchedBorder(), "Stats"));
  54. return jpanel;
  55. }
  56. private JComponent getPlayerListComponent()
  57. {
  58. PlayerListBox playerlistbox = new PlayerListBox(mcServer);
  59. JScrollPane jscrollpane = new JScrollPane(playerlistbox, 22, 30);
  60. jscrollpane.setBorder(new TitledBorder(new EtchedBorder(), "Players"));
  61. return jscrollpane;
  62. }
  63. private JComponent getLogComponent()
  64. {
  65. JPanel jpanel = new JPanel(new BorderLayout());
  66. JTextArea jtextarea = new JTextArea();
  67. logger.addHandler(new GuiLogOutputHandler(jtextarea));
  68. JScrollPane jscrollpane = new JScrollPane(jtextarea, 22, 30);
  69. jtextarea.setEditable(false);
  70. JTextField jtextfield = new JTextField();
  71. jtextfield.addActionListener(new ServerGuiCommandListener(this, jtextfield));
  72. jtextarea.addFocusListener(new ServerGuiFocusAdapter(this));
  73. jpanel.add(jscrollpane, "Center");
  74. jpanel.add(jtextfield, "South");
  75. jpanel.setBorder(new TitledBorder(new EtchedBorder(), "Log and chat"));
  76. return jpanel;
  77. }
  78. public void log(String s)
  79. {
  80. logger.info(s);
  81. }
  82. public String getUsername()
  83. {
  84. return "CONSOLE";
  85. }
  86. static MinecraftServer getMinecraftServer(ServerGUI servergui)
  87. {
  88. return servergui.mcServer;
  89. }
  90. public static Logger logger = Logger.getLogger("Minecraft");
  91. private MinecraftServer mcServer;
  92. }