Edit: I will probably not return to this as a project, so here is the code if you want to collect stats yourself
Stats are in the format "<unix time (ms)>,<winner username>,<amount won>,<winner's tickets>,<total players>,<total tickets>\n"
Uses MCProtocolLib
Code:import java.io.FileOutputStream; import java.io.IOException; import java.util.Calendar; import java.util.LinkedList; import org.spacehq.mc.auth.exception.AuthenticationException; import org.spacehq.mc.protocol.MinecraftProtocol; import org.spacehq.mc.protocol.data.message.Message; import org.spacehq.mc.protocol.packet.ingame.client.ClientChatPacket; import org.spacehq.packetlib.Client; import org.spacehq.packetlib.Session; import org.spacehq.packetlib.event.session.ConnectedEvent; import org.spacehq.packetlib.event.session.DisconnectedEvent; import org.spacehq.packetlib.event.session.DisconnectingEvent; import org.spacehq.packetlib.event.session.PacketReceivedEvent; import org.spacehq.packetlib.event.session.PacketSentEvent; import org.spacehq.packetlib.event.session.SessionListener; import org.spacehq.packetlib.packet.Packet; import org.spacehq.packetlib.tcp.TcpSessionFactory; public class LottoBot implements SessionListener { private static final String user = "<username>", pass = "<password>"; private static boolean check = true; static LottoBot bot = null; public static void main ( String [] args ) { bot = new LottoBot ( user ); try { bot.login( pass ); } catch ( Exception e ) { e.printStackTrace(); } } private static final String RX_USER = "(\\*\\*)?[a-zA-Z0-9_]+"; public static void parseChat ( String message ) { // TODO parse /rn if ( message.startsWith( "[LOTTERY] " ) ) { System.out.println( message ); message = message.substring( 10 ); /*if ( message.matches( RX_USER + " just bought [0-9]+ ticket(s)?!( Draw in " + RX_DURATION + ")?" ) ) { String name = message.substring( 0, message.indexOf( " " ) ); String qty = message.substring( message.indexOf( " bought " ) + 8, message.indexOf( " ticket" ) ); } else*/ if ( message.matches( "Congratulations go to " + RX_USER + " for winning \\$[0-9\\.]+ with [0-9]+ ticket(s)?[!\\.]?" ) ) { endTime = Calendar.getInstance().getTimeInMillis(); winPlayer = message.substring( message.indexOf( "to " ) + 3, message.indexOf( " for w" ) ); winAmount = message.substring( message.indexOf( "g $" ) + 3, message.indexOf( " with " ) ); winTickets = message.substring( message.indexOf( " with " ) + 6, message.indexOf( " ticket" ) ); //System.err.println( "\"" + name + "\" won $" + amt + " with " + qty + " ticket(s)" ); } else if ( message.matches( "There was a total of [0-9]+ player(s)? buying [0-9]+ ticket(s)?" ) ) { totalPlayers = message.substring( message.indexOf( " of " ) + 4, message.indexOf( " player" ) ); totalTickets = message.substring( message.indexOf( " buying " ) + 8, message.indexOf( " ticket" ) ); //System.err.println( "Lottery ended with " + players + " player(s) buying " + qty + " ticket(s)" ); save(); } } } private static long endTime; private static String winPlayer, winAmount, winTickets, totalPlayers, totalTickets; private static void save () { if ( endTime != 0 && winPlayer != null && winAmount != null && winTickets != null && totalPlayers != null && totalTickets != null ) { try { FileOutputStream out = new FileOutputStream ( "lotto.log", true ); out.write( ( endTime + "," + winPlayer + "," + winAmount + "," + winTickets + "," + totalPlayers + "," + totalTickets + "\n" ).getBytes() ); out.close(); } catch ( IOException e ) { e.printStackTrace(); } } endTime = 0; winPlayer = winAmount = winTickets = totalPlayers = totalTickets = null; } private String serverAddress = "mc.ecocitycraft.com"; private int serverPort = 25565; private String username; private Client client; public LottoBot ( String username ) { this.username = username; } public void login ( String password ) throws AuthenticationException { MinecraftProtocol protocol = new MinecraftProtocol ( username, password, false ); client = new Client ( serverAddress, serverPort, protocol, new TcpSessionFactory () ); Session session = client.getSession(); session.addListener( this ); session.connect(); } public void chat ( String message ) { client.getSession().send( new ClientChatPacket ( message ) ); } public void packetReceived ( PacketReceivedEvent event ) { Packet pkt = event.getPacket(); if ( pkt == null ) return; if ( pkt instanceof org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket ) { LottoBot.parseChat( ( (org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket) pkt ).getMessage().getFullText() ); } } public void packetSent ( PacketSentEvent event ) {} public void connected ( ConnectedEvent event ) {} public void disconnecting ( DisconnectingEvent event ) {} public void disconnected ( DisconnectedEvent event ) {} }
?
How bad do you want it
-
/ignore
6.3% -
meh, it would be kinda neat
28.1% -
definitely important to my enjoyment of the ECC lotto
28.1% -
DO IT OR I WILL HUNT YOU DOWN AND MURDER YOUR BABIES
37.5%
Thread Tools
Thread Tools
-
xerxesbeat BuilderBuilder ⛰️ Ex-Mayor ⚒️⚒️
-
xerxesbeat BuilderBuilder ⛰️ Ex-Mayor ⚒️⚒️
link fixed
-
I have a very very small amount of knowledge in html/css. I don't think it will be of much help.
@JamieSinn -
thehockeykids2 BuilderBuilder ⛰️ Ex-President ⚒️⚒️
I know a fair bit of html, I may be of help, it all depends on how "professional" you want it to be :p
-
-
xerxesbeat BuilderBuilder ⛰️ Ex-Mayor ⚒️⚒️
I don't need it to be particularly professional, just reasonable looking enough to make it comfortable to the eyes
As for the user profile thing, I don't want to have to have people register, but I was trying to think of ways you could enter your username and verify with the bot ingame so you didn't need a password. choosing to stay logged in if desired -
thehockeykids2 BuilderBuilder ⛰️ Ex-President ⚒️⚒️
-
This isn't necessary HTML as it is java code people.. The first four lines destinguish specifically java, so HTML and CSS won't get you far really at all.... I took classes on HTML (easiest coding ever) last year as well as CSS, I created an amateur Gta website for the final project:p and this year I'm taking ap computer science, aka java atm and what I want to major in college. To be completely honest I thought that something like this would be extremely difficult to understand and play with, but I already see similar formatting and common terms in the code as I see in my class. And it's only been about 3 weeks xD this final project will be to construct a game in like 3 days, but seeing this code linked in the description makes me smile:)
CSS was first developed in 1997, as a way for Web developers to define the look and feel of their Web pages. It was intended to allow developers to separate content from design so that HTML could perform more of the function that it was originally based on - the markup of content, without worry about the design and layout.Hypertext Markup Language, a standardized system for tagging text files to achieve font, color, graphic, and hyperlink effects on World Wide Web pages.