Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javagui;
- import com.github.steveice10.mc.auth.data.GameProfile;
- import com.github.steveice10.mc.auth.exception.request.RequestException;
- import com.github.steveice10.mc.protocol.MinecraftConstants;
- import com.github.steveice10.mc.protocol.MinecraftProtocol;
- import com.github.steveice10.mc.protocol.ServerLoginHandler;
- import com.github.steveice10.mc.protocol.data.SubProtocol;
- import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
- import com.github.steveice10.mc.protocol.data.game.setting.Difficulty;
- import com.github.steveice10.mc.protocol.data.game.world.WorldType;
- import com.github.steveice10.mc.protocol.data.message.ChatColor;
- import com.github.steveice10.mc.protocol.data.message.ChatFormat;
- import com.github.steveice10.mc.protocol.data.message.Message;
- import com.github.steveice10.mc.protocol.data.message.MessageStyle;
- import com.github.steveice10.mc.protocol.data.message.TextMessage;
- import com.github.steveice10.mc.protocol.data.message.TranslationMessage;
- import com.github.steveice10.mc.protocol.data.status.PlayerInfo;
- import com.github.steveice10.mc.protocol.data.status.ServerStatusInfo;
- import com.github.steveice10.mc.protocol.data.status.VersionInfo;
- import com.github.steveice10.mc.protocol.data.status.handler.ServerInfoBuilder;
- import com.github.steveice10.mc.protocol.data.status.handler.ServerInfoHandler;
- import com.github.steveice10.mc.protocol.data.status.handler.ServerPingTimeHandler;
- import com.github.steveice10.mc.protocol.packet.ingame.client.ClientChatPacket;
- import com.github.steveice10.mc.protocol.packet.ingame.server.ServerChatPacket;
- import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
- import com.github.steveice10.packetlib.Client;
- import com.github.steveice10.packetlib.Server;
- import com.github.steveice10.packetlib.Session;
- import com.github.steveice10.packetlib.event.server.ServerAdapter;
- import com.github.steveice10.packetlib.event.server.ServerClosedEvent;
- import com.github.steveice10.packetlib.event.server.SessionAddedEvent;
- import com.github.steveice10.packetlib.event.server.SessionRemovedEvent;
- import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
- import com.github.steveice10.packetlib.event.session.PacketReceivedEvent;
- import com.github.steveice10.packetlib.event.session.SessionAdapter;
- import com.github.steveice10.packetlib.tcp.TcpSessionFactory;
- import java.net.Proxy;
- import java.util.Arrays;
- import java.awt.EventQueue;
- import javax.swing.JFrame;
- import javax.swing.JButton;
- import javax.swing.JOptionPane;
- import java.awt.BorderLayout;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- import javax.swing.JTextField;
- import javax.swing.JLabel;
- import java.awt.Font;
- public class App {
- private JFrame frame;
- private JTextField textField;
- Session session = null;
- private String USERNAME = "Strietzl";
- private String PASSWORD = "pascal13";
- private String SERVER_HOST = "spela.granskogen.nu";
- private int SERVER_PORT = 25565;
- private Proxy PROXY = Proxy.NO_PROXY;
- private Proxy AUTH_PROXY = Proxy.NO_PROXY;
- private JLabel lblStatus;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- App window = new App();
- window.frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the application.
- */
- public App() {
- initialize();
- }
- /**
- * Initialize the contents of the frame.
- */
- private void initialize() {
- frame = new JFrame();
- frame.setBounds(100, 100, 556, 372);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.getContentPane().setLayout(null);
- lblStatus = new JLabel("Status: clicc a button plz");
- lblStatus.setFont(new Font("Tahoma", Font.PLAIN, 15));
- lblStatus.setBounds(231, 265, 299, 32);
- frame.getContentPane().add(lblStatus);
- JButton btnMakeBotJoin = new JButton("make bot join eks dee");
- btnMakeBotJoin.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- MinecraftProtocol protocol = null;
- try {
- protocol = new MinecraftProtocol(USERNAME, PASSWORD);
- lblStatus.setText("Status: Authenticated");
- } catch(RequestException e) {
- lblStatus.setText("Status: Failed to authenticate");
- e.printStackTrace();
- }
- Client client = new Client(SERVER_HOST, SERVER_PORT, protocol, new TcpSessionFactory(PROXY));
- client.getSession().setFlag(MinecraftConstants.AUTH_PROXY_KEY, AUTH_PROXY);
- client.getSession().addListener(new SessionAdapter() {
- @Override
- public void packetReceived(PacketReceivedEvent event) {
- if(event.getPacket() instanceof ServerJoinGamePacket) {
- event.getSession().send(new ClientChatPacket("hello humans"));
- session = event.getSession();
- lblStatus.setText("Joined game!");
- }
- }
- });
- }
- });
- btnMakeBotJoin.setBounds(10, 11, 182, 71);
- frame.getContentPane().add(btnMakeBotJoin);
- textField = new JTextField();
- textField.setBounds(20, 200, 250, 32);
- frame.getContentPane().add(textField);
- textField.setColumns(10);
- JButton btnMakeBotTalk = new JButton("make bot talk eks dee");
- btnMakeBotTalk.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- session.send(new ClientChatPacket(textField.getText()));
- }
- });
- btnMakeBotTalk.setBounds(30, 243, 191, 51);
- frame.getContentPane().add(btnMakeBotTalk);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement