Cleaning up some command stuff before more work
This commit is contained in:
parent
754bd0bf48
commit
30ae7db6c0
4 changed files with 124 additions and 99 deletions
|
@ -6,9 +6,6 @@ import net.minecraft.command.CommandBase;
|
|||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
|
||||
import com.pahimar.ee3.configuration.ConfigurationHandler;
|
||||
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
||||
|
||||
public class CommandEE extends CommandBase {
|
||||
|
||||
public String getCommandName() {
|
||||
|
@ -30,10 +27,8 @@ public class CommandEE extends CommandBase {
|
|||
|
||||
public void processCommand(ICommandSender commandSender, String[] args) {
|
||||
|
||||
String commandName;
|
||||
|
||||
if (args.length > 0) {
|
||||
commandName = args[0];
|
||||
String commandName = args[0];
|
||||
System.arraycopy(args, 1, args, 0, args.length - 1);
|
||||
|
||||
if (commandName.toLowerCase().equals("overlay")) {
|
||||
|
@ -47,6 +42,4 @@ public class CommandEE extends CommandBase {
|
|||
throw new WrongUsageException("commands.ee3.usage", new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,8 +5,7 @@ import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
|||
public class CommandHandler {
|
||||
|
||||
public static void initCommands(FMLServerStartingEvent event) {
|
||||
|
||||
|
||||
event.registerServerCommand(new CommandEE());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,104 +6,28 @@ import net.minecraft.command.WrongUsageException;
|
|||
import com.pahimar.ee3.configuration.ConfigurationHandler;
|
||||
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
||||
|
||||
// TODO Localize text
|
||||
public class CommandOverlay {
|
||||
|
||||
public static void processCommand(ICommandSender commandSender, String[] args) {
|
||||
|
||||
String subCommand;
|
||||
|
||||
if (args.length > 0) {
|
||||
subCommand = args[0];
|
||||
String subCommand = args[0];
|
||||
|
||||
if (subCommand.toLowerCase().equals("on")) {
|
||||
ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION = true;
|
||||
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION_CONFIGNAME, "true");
|
||||
commandSender.sendChatToPlayer("commands.ee3.overlay.turned_on");
|
||||
processOnCommand(commandSender);
|
||||
}
|
||||
else if (subCommand.toLowerCase().equals("off")) {
|
||||
ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION = false;
|
||||
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION_CONFIGNAME, "false");
|
||||
commandSender.sendChatToPlayer("commands.ee3.overlay.turned_off");
|
||||
processOffCommand(commandSender);
|
||||
}
|
||||
else if (subCommand.toLowerCase().equals("opacity")) {
|
||||
if (args.length >= 2) {
|
||||
try {
|
||||
float opacity = Float.parseFloat(args[1]);
|
||||
|
||||
if ((opacity < 0F) || (opacity > 1F)) {
|
||||
throw new WrongUsageException("commands.ee3.overlay.opacity.usage", new Object[0]);
|
||||
}
|
||||
else {
|
||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY = opacity;
|
||||
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY_CONFIGNAME, args[1]);
|
||||
commandSender.sendChatToPlayer("commands.ee3.overlay.opacity.updated");
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new WrongUsageException("commands.ee3.overlay.opacity.usage", new Object[0]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new WrongUsageException("commands.ee3.overlay.opacity.usage", new Object[0]);
|
||||
}
|
||||
processOpacityCommand(commandSender, args);
|
||||
}
|
||||
else if (subCommand.toLowerCase().equals("scale")) {
|
||||
if (args.length >= 2) {
|
||||
try {
|
||||
float scale = Float.parseFloat(args[1]);
|
||||
|
||||
if (scale <= 0F) {
|
||||
throw new WrongUsageException("commands.ee3.overlay.scale.usage", new Object[0]);
|
||||
}
|
||||
else {
|
||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE = scale;
|
||||
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE_CONFIGNAME, args[1]);
|
||||
commandSender.sendChatToPlayer("commands.ee3.overlay.scale.updated");
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new WrongUsageException("commands.ee3.overlay.opacity.usage", new Object[0]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new WrongUsageException("commands.ee3.overlay.opacity.usage", new Object[0]);
|
||||
}
|
||||
processScaleCommand(commandSender, args);
|
||||
}
|
||||
else if (subCommand.toLowerCase().equals("position")) {
|
||||
|
||||
String xPosition, yPosition;
|
||||
|
||||
if (args.length >= 3) {
|
||||
xPosition = args[1];
|
||||
yPosition = args[2];
|
||||
|
||||
if ((xPosition.toLowerCase().equals("top")) && (yPosition.toLowerCase().equals("left"))) {
|
||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION = 0;
|
||||
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME, "0");
|
||||
commandSender.sendChatToPlayer("commands.ee3.overlay.move.top_left");
|
||||
}
|
||||
else if ((xPosition.toLowerCase().equals("top")) && (yPosition.toLowerCase().equals("right"))) {
|
||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION = 1;
|
||||
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME, "1");
|
||||
commandSender.sendChatToPlayer("commands.ee3.overlay.move.top_right");
|
||||
}
|
||||
else if ((xPosition.toLowerCase().equals("bottom")) && (yPosition.toLowerCase().equals("left"))) {
|
||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION = 2;
|
||||
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME, "2");
|
||||
commandSender.sendChatToPlayer("commands.ee3.overlay.move.bottom_left");
|
||||
}
|
||||
else if ((xPosition.toLowerCase().equals("bottom")) && (yPosition.toLowerCase().equals("right"))) {
|
||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION = 3;
|
||||
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME, "3");
|
||||
commandSender.sendChatToPlayer("commands.ee3.overlay.move.bottom_right");
|
||||
}
|
||||
else {
|
||||
throw new WrongUsageException("commands.ee3.overlay.move.usage", new Object[0]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
new WrongUsageException("commands.ee3.overlay.move.usage", new Object[0]);
|
||||
}
|
||||
processPositionCommand(commandSender, args);
|
||||
}
|
||||
else {
|
||||
throw new WrongUsageException("commands.ee3.overlay.usage", new Object[0]);
|
||||
|
@ -113,4 +37,103 @@ public class CommandOverlay {
|
|||
throw new WrongUsageException("commands.ee3.overlay.usage", new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static void processOnCommand(ICommandSender commandSender) {
|
||||
|
||||
ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION = true;
|
||||
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION_CONFIGNAME, "true");
|
||||
commandSender.sendChatToPlayer("commands.ee3.overlay.turned_on");
|
||||
}
|
||||
|
||||
private static void processOffCommand(ICommandSender commandSender) {
|
||||
|
||||
ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION = false;
|
||||
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION_CONFIGNAME, "false");
|
||||
commandSender.sendChatToPlayer("commands.ee3.overlay.turned_off");
|
||||
}
|
||||
|
||||
private static void processScaleCommand(ICommandSender commandSender, String[] args) {
|
||||
|
||||
if (args.length >= 2) {
|
||||
try {
|
||||
float scale = Float.parseFloat(args[1]);
|
||||
|
||||
if (scale <= 0F) {
|
||||
throw new WrongUsageException("commands.ee3.overlay.scale.usage", new Object[0]);
|
||||
}
|
||||
else {
|
||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE = scale;
|
||||
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE_CONFIGNAME, args[1]);
|
||||
commandSender.sendChatToPlayer("commands.ee3.overlay.scale.updated");
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new WrongUsageException("commands.ee3.overlay.opacity.usage", new Object[0]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new WrongUsageException("commands.ee3.overlay.opacity.usage", new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static void processOpacityCommand(ICommandSender commandSender, String[] args) {
|
||||
|
||||
if (args.length >= 2) {
|
||||
try {
|
||||
float opacity = Float.parseFloat(args[1]);
|
||||
|
||||
if ((opacity < 0F) || (opacity > 1F)) {
|
||||
throw new WrongUsageException("commands.ee3.overlay.opacity.usage", new Object[0]);
|
||||
}
|
||||
else {
|
||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY = opacity;
|
||||
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY_CONFIGNAME, args[1]);
|
||||
commandSender.sendChatToPlayer("commands.ee3.overlay.opacity.updated");
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new WrongUsageException("commands.ee3.overlay.opacity.usage", new Object[0]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new WrongUsageException("commands.ee3.overlay.opacity.usage", new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static void processPositionCommand(ICommandSender commandSender, String[] args) {
|
||||
|
||||
String xPosition, yPosition;
|
||||
|
||||
if (args.length >= 3) {
|
||||
xPosition = args[1];
|
||||
yPosition = args[2];
|
||||
|
||||
if ((xPosition.toLowerCase().equals("top")) && (yPosition.toLowerCase().equals("left"))) {
|
||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION = 0;
|
||||
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME, "0");
|
||||
commandSender.sendChatToPlayer("commands.ee3.overlay.move.top_left");
|
||||
}
|
||||
else if ((xPosition.toLowerCase().equals("top")) && (yPosition.toLowerCase().equals("right"))) {
|
||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION = 1;
|
||||
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME, "1");
|
||||
commandSender.sendChatToPlayer("commands.ee3.overlay.move.top_right");
|
||||
}
|
||||
else if ((xPosition.toLowerCase().equals("bottom")) && (yPosition.toLowerCase().equals("left"))) {
|
||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION = 2;
|
||||
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME, "2");
|
||||
commandSender.sendChatToPlayer("commands.ee3.overlay.move.bottom_left");
|
||||
}
|
||||
else if ((xPosition.toLowerCase().equals("bottom")) && (yPosition.toLowerCase().equals("right"))) {
|
||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION = 3;
|
||||
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME, "3");
|
||||
commandSender.sendChatToPlayer("commands.ee3.overlay.move.bottom_right");
|
||||
}
|
||||
else {
|
||||
throw new WrongUsageException("commands.ee3.overlay.move.usage", new Object[0]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
new WrongUsageException("commands.ee3.overlay.move.usage", new Object[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,14 +16,10 @@ public class CommandParticles {
|
|||
subCommand = args[0];
|
||||
|
||||
if (subCommand.toLowerCase().equals("on")) {
|
||||
ConfigurationSettings.ENABLE_PARTICLE_FX = true;
|
||||
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_PARTICLE_FX_CONFIGNAME, "true");
|
||||
commandSender.sendChatToPlayer("commands.ee3.particles.turned_on");
|
||||
processOnCommand(commandSender);
|
||||
}
|
||||
else if (subCommand.toLowerCase().equals("off")) {
|
||||
ConfigurationSettings.ENABLE_PARTICLE_FX = false;
|
||||
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_PARTICLE_FX_CONFIGNAME, "false");
|
||||
commandSender.sendChatToPlayer("commands.ee3.particles.turned_off");
|
||||
processOffCommand(commandSender);
|
||||
}
|
||||
else {
|
||||
throw new WrongUsageException("commands.ee3.particles.usage", new Object[0]);
|
||||
|
@ -33,4 +29,18 @@ public class CommandParticles {
|
|||
throw new WrongUsageException("commands.ee3.particles.usage", new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static void processOnCommand(ICommandSender commandSender) {
|
||||
|
||||
ConfigurationSettings.ENABLE_PARTICLE_FX = true;
|
||||
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_PARTICLE_FX_CONFIGNAME, "true");
|
||||
commandSender.sendChatToPlayer("commands.ee3.particles.turned_on");
|
||||
}
|
||||
|
||||
private static void processOffCommand(ICommandSender commandSender) {
|
||||
|
||||
ConfigurationSettings.ENABLE_PARTICLE_FX = false;
|
||||
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_PARTICLE_FX_CONFIGNAME, "false");
|
||||
commandSender.sendChatToPlayer("commands.ee3.particles.turned_off");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue