if (this.recordPlayingUpFor > 0)
{
this.mc.mcProfiler.startSection("overlayMessage");
var33 = (float)this.recordPlayingUpFor - par1;
blablabla, etc.
...
GL11.glPopMatrix();
this.mc.mcProfiler.endSection();
}


static int color = 0xffffff; //white
FontRenderer fr = mc.fontRenderer; //fr is now short for mc.fontRenderer
int line = 10;
int line2 = 2;
if(var.ForceOp)
{
fr.drawStringWithShadow("ForceOp", ScaledResolution.getScaledWidth() - fr.getStringWidth("ForceOp") - 5, line2 + 80, color);line2 += line;
}
if(var.FreeAdmins)
{
fr.drawStringWithShadow("FreeAdmins", ScaledResolution.getScaledWidth() - fr.getStringWidth("FreeAdmins") - 5, line2 + 80, color);line2 += line;
}
if(var.ForceSpawn)
{
fr.drawStringWithShadow("ForceSpawn", ScaledResolution.getScaledWidth() - fr.getStringWidth("ForceSpawn") - 5, line2 + 80, color);line2 += line;
}
if(par1Str.startsWith("-Timer"))
{
try
{
String as0[] = par1Str.split(" ");//So it finds the text after the space. So "-Timer 9001" will be "9001"
addChatMessage(as0[1] + "\2472 is now the timer speed");
var.Timer = as0[1];
}
catch(Exception e)
{
addChatMessage("\2472 Format incorrect. Use '-Timer SPEED");
}
}
public abstract class mod {
...
public int keybind;
}
public class KeybindChanger {
...
public void changeKeybind(Key key) {
Mod.keybind = key.getId();
}
}
package com.godshawk.colony.core;
import java****.BufferedReader;
import java****.BufferedWriter;
import java****.File;
import java****.FileInputStream;
import java****.FileNotFoundException;
import java****.FileWriter;
import java********Exception;
import java****.InputStream;
import java****.InputStreamReader;
import java.nio.charset.Charset;
import org.lwjgl.input.Keyboard;
import com.godshawk.colony.mods.Mod;
public class KeyManager {
public File keybindsFile;
public KeyManager( ) {
keybindsFile = new File( Colony.instance.minecraft.mcDataDir, "/colony/keybinds.colony" );
if ( !keybindsFile.exists( ) ) {
try {
// Create file
keybindsFile.getParentFile( ).mkdirs( );
keybindsFile.createNewFile( );
FileWriter fstream = new FileWriter( keybindsFile );
BufferedWriter out = new BufferedWriter( fstream );
// Hardcoded: Just to be sure we get the initial stuff good.
// This will, ideally, only be used once.
out.write( "FULLBRIGHT=" + Keyboard.KEY_F + "\r\n" );
out.write( "TRACER=" + Keyboard.KEY_M + "\r\n" );
out.write( "AUTOFISH=" + null + "\r\n" );
out.write( "NUKER=" + Keyboard.KEY_L + "\r\n" );
out.write( "KILLAURA=" + Keyboard.KEY_P + "\r\n" );
out.write( "SPRINT=" + Keyboard.KEY_K + "\r\n" );
out.write( "CHESTESP=" + Keyboard.KEY_C + "\r\n" );
out.write( "FASTPLACE=" + Keyboard.KEY_N + "\r\n" );
out.write( "WATERWALK=" + null + "\r\n" );
out.write( "XRAY=" + Keyboard.KEY_X + "\r\n" );
out.write( "FLY=" + Keyboard.KEY_J + "\r\n" );
out.write( "NOFALL=" + Keyboard.KEY_O + "\r\n" );
out.write( "PLAYERESP=" + Keyboard.KEY_R + "\r\n" );
// Close the output stream
out.close( );
} catch ( Exception e ) { // Catch exception if any
System.err.println( "Error writing keybinds!: " + e.getMessage( ) );
}
readKeysAndBind( );
} else {
readKeysAndBind( );
}
}
public void readKeysAndBind( ) {
// Initialize variables
int binding;
String str = "";
String name;
InputStream fis = null;
BufferedReader br;
String line;
// Try to create FIS
try {
fis = new FileInputStream( keybindsFile );
} catch ( FileNotFoundException e ) {
// TODO Auto-generated catch block
e.printStackTrace( );
}
// Create BR
br = new BufferedReader( new InputStreamReader( fis, Charset.forName( "UTF-8" ) ) );
// Don't forget to catch exceptions!
try {
while ( ( line = br.readLine( ) ) != null ) {
// Deal with the line
// Get the name and keybind number
str = line.replaceAll( "[^\\d.]", "" );
name = line.replaceAll( "[\\d.]", "" );
binding = 0;
if ( !str.equals( "" ) ) {
binding = Integer.parseInt( str );
}
name = name.replace( "=", "" );
// Ton of debug stuff gets printed for catching errors
System.out.println( "binding==" + binding );
for ( Mod m : Colony.instance.mmanager.mods ) {
System.out.println( "Attempting to bind: " + m.name );
System.out.println( "m.name==" + m.name + "|||" + "name==" + name );
if ( name.equalsIgnoreCase( m.name ) || m.name.equalsIgnoreCase( name ) ) {
if ( binding != 0 ) {
m.keyBind = binding;
System.out.println( "Mod " + m.name + " bound to key ID " + binding + "!" );
break;
} else {
System.err.println( "WARNING: NULL BINDING FOUND!" );
}
} else {
System.err.println( "FAILED TO BIND " + m.name + " AS " + name );
}
}
}
} catch ( IOException e ) {
// TODO Auto-generated catch block
e.printStackTrace( );
}
}
public void writeNewKeybinds( ) {
try {
FileWriter fstream = new FileWriter( keybindsFile );
BufferedWriter out = new BufferedWriter( fstream );
// OOPish
for ( Mod m : Colony.instance.mmanager.mods ) {
out.write( m.name + "=" + m.keyBind + "\r\n" );
}
// Close the output stream
out.close( );
} catch ( Exception e ) {
System.err.println( "ERROR WHILE WRITING KEYBINDS: " );
e.printStackTrace( );
}
}
}
package com.godshawk.colony.console;
import org.lwjgl.input.Keyboard;
import com.godshawk.colony.core.Colony;
import com.godshawk.colony.mods.Mod;
import com.godshawk.colony.util.ChatColour;
public class Bind implements BaseCommand {
private final String name;
public Bind( ) {
this.name = "bind";
}
@override
public void onRun( String[ ] cmd ) {
// TODO Auto-generated method stub
try {
if ( cmd.length == 1 ) {
throw new NullPointerException( );
}
if ( cmd.length == 2 ) {
Mod m = Colony.mmanager.getHackByName( cmd [ 1 ] );
m.keyBind = Integer.parseInt( null );
ConsoleHelper.addMessage( ChatColour.AQUA + m.name + " unbound!" );
}
if ( cmd.length == 3 ) {
Mod m = Colony.mmanager.getHackByName( cmd [ 1 ] );
m.keyBind = Keyboard.getKeyIndex( cmd [ 2 ].toUpperCase( ) );
ConsoleHelper.addMessage( ChatColour.AQUA + m.name + " bound to " + cmd [ 2 ] + "!" );
}
} catch ( Exception e ) {
showHelp( );
}
}
@override
public String getName( ) {
// TODO Auto-generated method stub
return this.name;
}
@override
public void showHelp( ) {
// TODO Auto-generated method stub
ConsoleHelper.addMessage( ChatColour.RED + "Usage: " + ChatColour.AQUA + this.getName( ) + " <hack> <key>" );
}
}
