Added Config Getter, added Logger from PositionViewMod.
This commit is contained in:
@@ -20,10 +20,17 @@ public class Config {
|
|||||||
* Defines the config string for the other-category.
|
* Defines the config string for the other-category.
|
||||||
*/
|
*/
|
||||||
protected static final String categoryOther = "other";
|
protected static final String categoryOther = "other";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard Return Key if there is a problem reading the config.
|
||||||
|
*/
|
||||||
|
private static final int retDefKey = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the Suggested Config File.
|
* Provides the Suggested Config File.
|
||||||
*/
|
*/
|
||||||
protected static Configuration configFile = null;
|
protected static Configuration configFile = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines all 11 Keys you can use with Crafting Keys.
|
* Defines all 11 Keys you can use with Crafting Keys.
|
||||||
*/
|
*/
|
||||||
@@ -31,19 +38,62 @@ public class Config {
|
|||||||
keyCenterLeft, keyCenterCenter, keyCenterRight,
|
keyCenterLeft, keyCenterCenter, keyCenterRight,
|
||||||
keyLowerLeft, keyLowerCenter, keyLowerRight,
|
keyLowerLeft, keyLowerCenter, keyLowerRight,
|
||||||
keyStack, keyInteract, keyDrop;
|
keyStack, keyInteract, keyDrop;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines, if NumPad is always active for crafting.
|
* Defines, if NumPad is always active for crafting.
|
||||||
*/
|
*/
|
||||||
private static Property enableNumPad;
|
private static Property enableNumPad;
|
||||||
|
|
||||||
public static boolean isNumPadEnabled() {
|
public static int getKeyTopLeft() {
|
||||||
return enableNumPad.getBoolean(true);
|
return keyTopLeft.getInt(retDefKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getkeyTopCenter() {
|
||||||
|
return keyTopCenter.getInt(retDefKey);
|
||||||
|
}
|
||||||
|
|
||||||
public static int getKeyCode(KeyType key) {
|
public static int getKeyTopRight() {
|
||||||
//return ((Property)(Config.class.getField((key.toString())))..getInt(-1); // TODO!
|
return keyTopRight.getInt(retDefKey);
|
||||||
return 0;
|
}
|
||||||
|
|
||||||
|
public static int getKeyCenterLeft() {
|
||||||
|
return keyCenterLeft.getInt(retDefKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getKeyCenterCenter() {
|
||||||
|
return keyCenterCenter.getInt(retDefKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getKeyCenterRight() {
|
||||||
|
return keyCenterRight.getInt(retDefKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getKeyLowerLeft() {
|
||||||
|
return keyLowerLeft.getInt(retDefKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getKeyLowerCenter() {
|
||||||
|
return keyLowerCenter.getInt(retDefKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getKeyLowerRight() {
|
||||||
|
return keyLowerRight.getInt(retDefKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getKeyStack() {
|
||||||
|
return keyStack.getInt(retDefKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getKeyInteract() {
|
||||||
|
return keyInteract.getInt(retDefKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getKeyDrop() {
|
||||||
|
return keyDrop.getInt(retDefKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getEnableNumPad() {
|
||||||
|
return enableNumPad.getBoolean(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,24 +132,18 @@ public class Config {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates comments for easier understanding of the categories.
|
* Generates comments for easier understanding of the categories.
|
||||||
*
|
|
||||||
* @param config Mod related Configuration File
|
|
||||||
*/
|
*/
|
||||||
private static void genComments() {
|
private static void genComments() {
|
||||||
|
|
||||||
configFile.addCustomCategoryComment(categoryKeys, "Keyboard codes based on http://minecraft.gamepedia.com/Key_codes");
|
configFile.addCustomCategoryComment(categoryKeys, "Keyboard codes based on http://minecraft.gamepedia.com/Key_codes");
|
||||||
configFile.addCustomCategoryComment(categoryOther, "Other settings which have effects @ crafting keys");
|
configFile.addCustomCategoryComment(categoryOther, "Other settings which have effects @ crafting keys");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads all properties from the configFile file.
|
* Loads all properties from the configFile file.
|
||||||
*
|
|
||||||
* @param config Mod related Configuration File
|
|
||||||
*/
|
*/
|
||||||
private static void syncProperties() {
|
private static void syncProperties() {
|
||||||
|
|
||||||
// Standart Keys
|
// Standard Keys
|
||||||
|
|
||||||
keyTopLeft = configFile.get(categoryKeys, "1. Top Left", Keyboard.KEY_Q, "Top Left crafting key (key value)");
|
keyTopLeft = configFile.get(categoryKeys, "1. Top Left", Keyboard.KEY_Q, "Top Left crafting key (key value)");
|
||||||
keyTopCenter = configFile.get(categoryKeys, "2. Top Center", Keyboard.KEY_W, "Top Center crafting key (key value)");
|
keyTopCenter = configFile.get(categoryKeys, "2. Top Center", Keyboard.KEY_W, "Top Center crafting key (key value)");
|
||||||
@@ -125,11 +169,4 @@ public class Config {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum KeyType {
|
|
||||||
keyTopLeft, keyTopCenter, keyTopRight,
|
|
||||||
keyCenterLeft, keyCenterCenter, keyCenterRight,
|
|
||||||
keyLowerLeft, keyLowerCenter, keyLowerRight,
|
|
||||||
keyStack, keyInteract, keyDrop
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.lwjgl.input.Keyboard;
|
|||||||
*
|
*
|
||||||
* @author sebastian
|
* @author sebastian
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class Helper {
|
public class Helper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package de.skate702.craftingkeys.util;
|
||||||
|
|
||||||
|
import de.skate702.craftingkeys.CraftingKeys;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple Logger Class for debug output. Thank you, compiler!
|
||||||
|
*/
|
||||||
|
public class Logger {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Static Final Level. Compiler optimizing will kill all other calls!
|
||||||
|
*/
|
||||||
|
private static final LevelOfDetail MODE = LevelOfDetail.INFO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard Output in front of every logger action.
|
||||||
|
*/
|
||||||
|
private static final String StdOutput = "[" + CraftingKeys.NAME + "/";
|
||||||
|
|
||||||
|
private static void print(String method, String message, LevelOfDetail in) {
|
||||||
|
System.out.println(StdOutput + in.toString() + "] " + method + ": " + message);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints a INFO-Message if allowed.
|
||||||
|
*
|
||||||
|
* @param method The calling method / method info
|
||||||
|
* @param message The message to print
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void info(String method, String message) {
|
||||||
|
if (MODE.getLevel() <= 0) {
|
||||||
|
print(method, message, LevelOfDetail.INFO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints a DEBUG-Message if allowed.
|
||||||
|
*
|
||||||
|
* @param method The calling method / method info
|
||||||
|
* @param message The message to print
|
||||||
|
*/
|
||||||
|
public static void debug(String method, String message) {
|
||||||
|
if (MODE.getLevel() <= 1) {
|
||||||
|
print(method, message, LevelOfDetail.DEBUG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints a WARN-Message if allowed.
|
||||||
|
*
|
||||||
|
* @param method The calling method / method info
|
||||||
|
* @param message The message to print
|
||||||
|
*/
|
||||||
|
public static void warn(String method, String message) {
|
||||||
|
if (MODE.getLevel() <= 2) {
|
||||||
|
print(method, message, LevelOfDetail.WARN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints a ERROR-Message if allowed.
|
||||||
|
*
|
||||||
|
* @param method The calling method / method info
|
||||||
|
* @param message The message to print
|
||||||
|
*/
|
||||||
|
public static void error(String method, String message) {
|
||||||
|
if (MODE.getLevel() <= 3) {
|
||||||
|
print(method, message, LevelOfDetail.ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define Level Of Detail with fixed numbers.
|
||||||
|
*/
|
||||||
|
private enum LevelOfDetail {
|
||||||
|
INFO(0), DEBUG(1), WARN(2), ERROR(3), NONE(4);
|
||||||
|
|
||||||
|
private final int level;
|
||||||
|
|
||||||
|
LevelOfDetail(int level) {
|
||||||
|
this.level = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLevel() {
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user