just a copy of petroleum right now
This commit is contained in:
commit
183c81258a
88 changed files with 7405 additions and 0 deletions
|
|
@ -0,0 +1,38 @@
|
|||
package pm.j4.petroleum.util.module.option;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
|
||||
/**
|
||||
* The type Boolean value.
|
||||
*/
|
||||
public class BooleanOption extends ConfigurationOption {
|
||||
/**
|
||||
* The Value.
|
||||
*/
|
||||
private boolean value;
|
||||
|
||||
/**
|
||||
* Instantiates a new Boolean option.
|
||||
*
|
||||
* @param description the description
|
||||
*/
|
||||
public BooleanOption(String description) {
|
||||
super(description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStringValue() {
|
||||
return Boolean.toString(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromJson(JsonElement e) {
|
||||
this.value = e.getAsBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement toJson() {
|
||||
return new JsonPrimitive(value);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package pm.j4.petroleum.util.module.option;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
/**
|
||||
* The type Configuration option.
|
||||
*/
|
||||
public abstract class ConfigurationOption {
|
||||
/**
|
||||
* The Description.
|
||||
*/
|
||||
private final String description;
|
||||
|
||||
/**
|
||||
* Instantiates a new Configuration option.
|
||||
*
|
||||
* @param description the description
|
||||
*/
|
||||
protected ConfigurationOption(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets description.
|
||||
*
|
||||
* @return the description
|
||||
*/
|
||||
public final String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets string value.
|
||||
*
|
||||
* @return the string value
|
||||
*/
|
||||
public abstract String getStringValue();
|
||||
|
||||
/**
|
||||
* From json.
|
||||
*
|
||||
* @param e the e
|
||||
*/
|
||||
public abstract void fromJson(JsonElement e);
|
||||
|
||||
/**
|
||||
* To json json element.
|
||||
*
|
||||
* @return the json element
|
||||
*/
|
||||
public abstract JsonElement toJson();
|
||||
|
||||
/**
|
||||
* Update.
|
||||
*/
|
||||
public void update() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package pm.j4.petroleum.util.module.option;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
|
||||
/**
|
||||
* The type Integer value.
|
||||
*/
|
||||
public class IntegerOption extends ConfigurationOption {
|
||||
/**
|
||||
* The Value.
|
||||
*/
|
||||
private int value;
|
||||
|
||||
/**
|
||||
* Instantiates a new Integer option.
|
||||
*
|
||||
* @param description the description
|
||||
*/
|
||||
protected IntegerOption(String description) {
|
||||
super(description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStringValue() {
|
||||
return Integer.toString(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromJson(JsonElement e) {
|
||||
this.value = e.getAsInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement toJson() {
|
||||
return new JsonPrimitive(value);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package pm.j4.petroleum.util.module.option;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import net.minecraft.client.options.KeyBinding;
|
||||
import pm.j4.petroleum.modules.bindings.BindingInfo;
|
||||
import pm.j4.petroleum.util.config.ConfigManager;
|
||||
import pm.j4.petroleum.util.config.GlobalConfig;
|
||||
import pm.j4.petroleum.util.module.ModuleBase;
|
||||
|
||||
/**
|
||||
* The type Keybind value.
|
||||
*/
|
||||
public class KeybindOption extends ConfigurationOption {
|
||||
|
||||
/**
|
||||
* The Value.
|
||||
*/
|
||||
private KeyBinding value;
|
||||
/**
|
||||
* The Converted value.
|
||||
*/
|
||||
private BindingInfo convertedValue;
|
||||
|
||||
/**
|
||||
* Instantiates a new Keybind option.
|
||||
*
|
||||
* @param description the description
|
||||
*/
|
||||
public KeybindOption(String description) {
|
||||
super(description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStringValue() {
|
||||
return value.getDefaultKey().getLocalizedText().getString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromJson(JsonElement e) {
|
||||
BindingInfo bindingInfo = ConfigManager.deserializeElement(e, BindingInfo.class);
|
||||
this.convertedValue = bindingInfo;
|
||||
this.value = GlobalConfig.reconstructBinding(bindingInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement toJson() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* From keybind.
|
||||
*
|
||||
* @param bind the bind
|
||||
* @param base the base
|
||||
*/
|
||||
public void fromKeybind(KeyBinding bind, ModuleBase base) {
|
||||
this.value = bind;
|
||||
this.convertedValue = GlobalConfig.extractBinding(bind, base);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package pm.j4.petroleum.util.module.option;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
/**
|
||||
* The type List option.
|
||||
*/
|
||||
public class ListOption extends ConfigurationOption {
|
||||
/**
|
||||
* Instantiates a new List option.
|
||||
*
|
||||
* @param description the description
|
||||
*/
|
||||
protected ListOption(String description) {
|
||||
super(description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStringValue() {
|
||||
return "ListObject";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromJson(JsonElement e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement toJson() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package pm.j4.petroleum.util.module.option;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
|
||||
/**
|
||||
* The type String value.
|
||||
*/
|
||||
public class StringOption extends ConfigurationOption {
|
||||
|
||||
/**
|
||||
* The Value.
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* Instantiates a new String option.
|
||||
*
|
||||
* @param description the description
|
||||
*/
|
||||
protected StringOption(String description) {
|
||||
super(description);
|
||||
}
|
||||
|
||||
public String getStringValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromJson(JsonElement e) {
|
||||
this.value = e.getAsString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement toJson() {
|
||||
return new JsonPrimitive(value);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue