2013-08-23 16:59:50 +02:00
|
|
|
package com.pahimar.ee3.command;
|
|
|
|
|
|
|
|
import net.minecraft.command.ICommandSender;
|
|
|
|
import net.minecraft.command.WrongUsageException;
|
|
|
|
import net.minecraft.util.ChatMessageComponent;
|
|
|
|
|
|
|
|
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
2013-10-18 02:07:59 +02:00
|
|
|
import com.pahimar.ee3.configuration.GeneralConfiguration;
|
2013-08-23 16:59:50 +02:00
|
|
|
import com.pahimar.ee3.lib.Commands;
|
|
|
|
import com.pahimar.ee3.lib.Strings;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Equivalent-Exchange-3
|
|
|
|
*
|
|
|
|
* CommandOverlay
|
|
|
|
*
|
|
|
|
* @author pahimar
|
|
|
|
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public class CommandOverlay {
|
|
|
|
|
|
|
|
public static void processCommand(ICommandSender commandSender, String[] args) {
|
|
|
|
|
|
|
|
if (args.length > 0) {
|
|
|
|
String subCommand = args[0];
|
|
|
|
|
|
|
|
if (subCommand.equalsIgnoreCase(Commands.COMMAND_ON)) {
|
|
|
|
processOnCommand(commandSender);
|
|
|
|
}
|
|
|
|
else if (subCommand.equalsIgnoreCase(Commands.COMMAND_OFF)) {
|
|
|
|
processOffCommand(commandSender);
|
|
|
|
}
|
|
|
|
else if (subCommand.equalsIgnoreCase(Commands.COMMAND_OPACITY)) {
|
|
|
|
processOpacityCommand(commandSender, args);
|
|
|
|
}
|
|
|
|
else if (subCommand.equalsIgnoreCase(Commands.COMMAND_SCALE)) {
|
|
|
|
processScaleCommand(commandSender, args);
|
|
|
|
}
|
|
|
|
else if (subCommand.equalsIgnoreCase(Commands.COMMAND_POSITION)) {
|
|
|
|
processPositionCommand(commandSender, args);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
throw new WrongUsageException(Commands.COMMAND_OVERLAY_USAGE, new Object[0]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
throw new WrongUsageException(Commands.COMMAND_OVERLAY_USAGE, new Object[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void processOnCommand(ICommandSender commandSender) {
|
|
|
|
|
|
|
|
ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION = true;
|
2013-10-18 02:07:59 +02:00
|
|
|
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION_CONFIGNAME, Strings.TRUE);
|
2013-09-04 03:33:10 +02:00
|
|
|
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_OVERLAY_TURNED_ON));
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void processOffCommand(ICommandSender commandSender) {
|
|
|
|
|
|
|
|
ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION = false;
|
2013-10-18 02:07:59 +02:00
|
|
|
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION_CONFIGNAME, Strings.FALSE);
|
2013-09-04 03:33:10 +02:00
|
|
|
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_OVERLAY_TURNED_OFF));
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void processScaleCommand(ICommandSender commandSender, String[] args) {
|
|
|
|
|
|
|
|
if (args.length > 2 && args.length < 4) {
|
|
|
|
try {
|
|
|
|
float scale = Float.parseFloat(args[1]);
|
|
|
|
|
2013-08-30 04:03:13 +02:00
|
|
|
if (scale <= 0F) {
|
2013-09-07 04:47:12 +02:00
|
|
|
throw new WrongUsageException(Commands.COMMAND_OVERLAY_SCALE_USAGE_ADDITIONAL_TEXT, new Object[] { Commands.COMMAND_OVERLAY_SCALE_USAGE });
|
2013-08-30 04:03:13 +02:00
|
|
|
}
|
2013-08-23 16:59:50 +02:00
|
|
|
else {
|
|
|
|
ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE = scale;
|
2013-10-18 02:07:59 +02:00
|
|
|
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE_CONFIGNAME, args[1]);
|
2013-09-04 03:33:10 +02:00
|
|
|
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_OVERLAY_SCALE_UPDATED));
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
2013-09-07 04:47:12 +02:00
|
|
|
throw new WrongUsageException(Commands.COMMAND_OVERLAY_SCALE_USAGE_ADDITIONAL_TEXT, new Object[] { Commands.COMMAND_OVERLAY_SCALE_USAGE });
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|
|
|
|
}
|
2013-08-30 04:03:13 +02:00
|
|
|
else {
|
2013-09-07 04:47:12 +02:00
|
|
|
throw new WrongUsageException(Commands.COMMAND_OVERLAY_SCALE_USAGE_ADDITIONAL_TEXT, new Object[] { Commands.COMMAND_OVERLAY_SCALE_USAGE });
|
2013-08-30 04:03:13 +02:00
|
|
|
}
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void processOpacityCommand(ICommandSender commandSender, String[] args) {
|
|
|
|
|
|
|
|
if (args.length > 2 && args.length < 4) {
|
|
|
|
try {
|
|
|
|
float opacity = Float.parseFloat(args[1]);
|
|
|
|
|
2013-09-02 00:40:54 +02:00
|
|
|
if (opacity < 0F || opacity > 1F) {
|
|
|
|
throw new WrongUsageException(Commands.COMMAND_OVERLAY_OPACITY_USAGE_ADDITIONAL_TEXT, new Object[] { Commands.COMMAND_OVERLAY_OPACITY_USAGE });
|
|
|
|
}
|
2013-08-23 16:59:50 +02:00
|
|
|
else {
|
|
|
|
ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY = opacity;
|
2013-10-18 02:07:59 +02:00
|
|
|
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY_CONFIGNAME, args[1]);
|
2013-09-04 03:33:10 +02:00
|
|
|
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_OVERLAY_OPACITY_UPDATED));
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
2013-09-07 04:47:12 +02:00
|
|
|
throw new WrongUsageException(Commands.COMMAND_OVERLAY_OPACITY_USAGE_ADDITIONAL_TEXT, new Object[] { Commands.COMMAND_OVERLAY_OPACITY_USAGE });
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2013-09-07 04:47:12 +02:00
|
|
|
throw new WrongUsageException(Commands.COMMAND_OVERLAY_OPACITY_USAGE_ADDITIONAL_TEXT, new Object[] { Commands.COMMAND_OVERLAY_OPACITY_USAGE });
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void processPositionCommand(ICommandSender commandSender, String[] args) {
|
|
|
|
|
|
|
|
String yPosition, xPosition;
|
|
|
|
|
|
|
|
if (args.length > 2 && args.length < 5) {
|
|
|
|
yPosition = args[1];
|
|
|
|
xPosition = args[2];
|
|
|
|
|
|
|
|
if (yPosition.equalsIgnoreCase(Commands.COMMAND_TOP) && xPosition.equalsIgnoreCase(Commands.COMMAND_LEFT)) {
|
|
|
|
ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION = 0;
|
2013-10-18 02:07:59 +02:00
|
|
|
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME, "0");
|
2013-09-04 03:33:10 +02:00
|
|
|
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_OVERLAY_POSITION_TOP_LEFT));
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|
|
|
|
else if (yPosition.equalsIgnoreCase(Commands.COMMAND_TOP) && xPosition.equalsIgnoreCase(Commands.COMMAND_RIGHT)) {
|
|
|
|
ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION = 1;
|
2013-10-18 02:07:59 +02:00
|
|
|
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME, "1");
|
2013-09-04 03:33:10 +02:00
|
|
|
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_OVERLAY_POSITION_TOP_RIGHT));
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|
|
|
|
else if (yPosition.equalsIgnoreCase(Commands.COMMAND_BOTTOM) && xPosition.equalsIgnoreCase(Commands.COMMAND_LEFT)) {
|
|
|
|
ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION = 2;
|
2013-10-18 02:07:59 +02:00
|
|
|
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME, "2");
|
2013-09-04 03:33:10 +02:00
|
|
|
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_OVERLAY_POSITION_BOTTOM_LEFT));
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|
|
|
|
else if (yPosition.equalsIgnoreCase(Commands.COMMAND_BOTTOM) && xPosition.equalsIgnoreCase(Commands.COMMAND_RIGHT)) {
|
|
|
|
ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION = 3;
|
2013-10-18 02:07:59 +02:00
|
|
|
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME, "3");
|
2013-09-04 03:33:10 +02:00
|
|
|
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_OVERLAY_POSITION_BOTTOM_RIGHT));
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
throw new WrongUsageException(Commands.COMMAND_OVERLAY_POSITION_USAGE, new Object[0]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
throw new WrongUsageException(Commands.COMMAND_OVERLAY_POSITION_USAGE, new Object[0]);
|
|
|
|
}
|
|
|
|
}
|