2012-12-21 03:31:59 +01:00
|
|
|
package com.pahimar.ee3.command;
|
|
|
|
|
|
|
|
import net.minecraft.command.ICommandSender;
|
|
|
|
import net.minecraft.command.WrongUsageException;
|
|
|
|
|
|
|
|
import com.pahimar.ee3.configuration.ConfigurationHandler;
|
|
|
|
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
2013-01-11 21:01:47 +01:00
|
|
|
import com.pahimar.ee3.core.helper.LocalizationHelper;
|
|
|
|
import com.pahimar.ee3.lib.Colours;
|
|
|
|
import com.pahimar.ee3.lib.Commands;
|
|
|
|
import com.pahimar.ee3.lib.Strings;
|
2012-12-21 03:31:59 +01:00
|
|
|
|
|
|
|
public class CommandOverlay {
|
|
|
|
|
|
|
|
public static void processCommand(ICommandSender commandSender, String[] args) {
|
|
|
|
|
|
|
|
if (args.length > 0) {
|
2012-12-21 16:44:15 +01:00
|
|
|
String subCommand = args[0];
|
2012-12-21 03:31:59 +01:00
|
|
|
|
2013-01-11 21:01:47 +01:00
|
|
|
if (subCommand.equalsIgnoreCase(Commands.COMMAND_ON)) {
|
2012-12-21 16:44:15 +01:00
|
|
|
processOnCommand(commandSender);
|
2012-12-21 03:31:59 +01:00
|
|
|
}
|
2013-01-11 21:01:47 +01:00
|
|
|
else if (subCommand.equalsIgnoreCase(Commands.COMMAND_OFF)) {
|
2012-12-21 16:44:15 +01:00
|
|
|
processOffCommand(commandSender);
|
2012-12-21 03:31:59 +01:00
|
|
|
}
|
2013-01-11 21:01:47 +01:00
|
|
|
else if (subCommand.equalsIgnoreCase(Commands.COMMAND_OPACITY)) {
|
2012-12-21 16:44:15 +01:00
|
|
|
processOpacityCommand(commandSender, args);
|
2012-12-21 16:25:18 +01:00
|
|
|
}
|
2013-01-11 21:01:47 +01:00
|
|
|
else if (subCommand.equalsIgnoreCase(Commands.COMMAND_SCALE)) {
|
2012-12-21 16:44:15 +01:00
|
|
|
processScaleCommand(commandSender, args);
|
|
|
|
}
|
2013-01-11 21:01:47 +01:00
|
|
|
else if (subCommand.equalsIgnoreCase(Commands.COMMAND_POSITION)) {
|
2012-12-21 16:44:15 +01:00
|
|
|
processPositionCommand(commandSender, args);
|
|
|
|
}
|
|
|
|
else {
|
2013-01-11 21:01:47 +01:00
|
|
|
throw new WrongUsageException(Commands.COMMAND_OVERLAY_USAGE, new Object[0]);
|
2012-12-21 16:44:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2013-01-11 21:01:47 +01:00
|
|
|
throw new WrongUsageException(Commands.COMMAND_OVERLAY_USAGE, new Object[0]);
|
2012-12-21 16:44:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void processOnCommand(ICommandSender commandSender) {
|
|
|
|
|
|
|
|
ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION = true;
|
2013-01-11 21:01:47 +01:00
|
|
|
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION_CONFIGNAME, Strings.TRUE);
|
|
|
|
commandSender.sendChatToPlayer(Colours.TEXT_COLOUR_PREFIX_GRAY + LocalizationHelper.getLocalizedString(Commands.COMMAND_OVERLAY_TURNED_ON));
|
2012-12-21 16:44:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void processOffCommand(ICommandSender commandSender) {
|
|
|
|
|
|
|
|
ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION = false;
|
2013-01-11 21:01:47 +01:00
|
|
|
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION_CONFIGNAME, Strings.FALSE);
|
|
|
|
commandSender.sendChatToPlayer(Colours.TEXT_COLOUR_PREFIX_GRAY + LocalizationHelper.getLocalizedString(Commands.COMMAND_OVERLAY_TURNED_OFF));
|
2012-12-21 16:44:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void processScaleCommand(ICommandSender commandSender, String[] args) {
|
|
|
|
|
2013-01-09 21:22:21 +01:00
|
|
|
if ((args.length > 2) && (args.length < 4)) {
|
2012-12-21 16:44:15 +01:00
|
|
|
try {
|
|
|
|
float scale = Float.parseFloat(args[1]);
|
|
|
|
|
|
|
|
if (scale <= 0F) {
|
2013-01-11 21:01:47 +01:00
|
|
|
throw new WrongUsageException(Commands.COMMAND_OVERLAY_SCALE_USAGE + " " + LocalizationHelper.getLocalizedString(Commands.COMMAND_OVERLAY_SCALE_USAGE_ADDITIONAL_TEXT), new Object[0]);
|
2012-12-21 16:25:18 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-12-21 16:44:15 +01:00
|
|
|
ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE = scale;
|
|
|
|
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE_CONFIGNAME, args[1]);
|
2013-01-11 21:01:47 +01:00
|
|
|
commandSender.sendChatToPlayer(Colours.TEXT_COLOUR_PREFIX_GRAY + LocalizationHelper.getLocalizedString(Commands.COMMAND_OVERLAY_SCALE_UPDATED));
|
2012-12-21 16:25:18 +01:00
|
|
|
}
|
|
|
|
}
|
2012-12-21 16:44:15 +01:00
|
|
|
catch (Exception e) {
|
2013-01-11 21:01:47 +01:00
|
|
|
throw new WrongUsageException(Commands.COMMAND_OVERLAY_SCALE_USAGE + " " + LocalizationHelper.getLocalizedString(Commands.COMMAND_OVERLAY_SCALE_USAGE_ADDITIONAL_TEXT), new Object[0]);
|
2012-12-21 16:44:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2013-01-11 21:01:47 +01:00
|
|
|
throw new WrongUsageException(Commands.COMMAND_OVERLAY_SCALE_USAGE + " " + LocalizationHelper.getLocalizedString(Commands.COMMAND_OVERLAY_SCALE_USAGE_ADDITIONAL_TEXT), new Object[0]);
|
2012-12-21 16:44:15 +01:00
|
|
|
}
|
|
|
|
}
|
2012-12-21 03:31:59 +01:00
|
|
|
|
2012-12-21 16:44:15 +01:00
|
|
|
private static void processOpacityCommand(ICommandSender commandSender, String[] args) {
|
|
|
|
|
2013-01-09 21:22:21 +01:00
|
|
|
if ((args.length > 2) && (args.length < 4)) {
|
2012-12-21 16:44:15 +01:00
|
|
|
try {
|
|
|
|
float opacity = Float.parseFloat(args[1]);
|
|
|
|
|
|
|
|
if ((opacity < 0F) || (opacity > 1F)) {
|
2013-01-11 21:01:47 +01:00
|
|
|
throw new WrongUsageException(Commands.COMMAND_OVERLAY_OPACITY_USAGE + " " + LocalizationHelper.getLocalizedString(Commands.COMMAND_OVERLAY_OPACITY_USAGE_ADDITIONAL_TEXT), new Object[0]);
|
2012-12-21 03:31:59 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-12-21 16:44:15 +01:00
|
|
|
ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY = opacity;
|
|
|
|
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY_CONFIGNAME, args[1]);
|
2013-01-11 21:01:47 +01:00
|
|
|
commandSender.sendChatToPlayer(Colours.TEXT_COLOUR_PREFIX_GRAY + LocalizationHelper.getLocalizedString(Commands.COMMAND_OVERLAY_OPACITY_UPDATED));
|
2012-12-21 03:31:59 +01:00
|
|
|
}
|
|
|
|
}
|
2012-12-21 16:44:15 +01:00
|
|
|
catch (Exception e) {
|
2013-01-11 21:01:47 +01:00
|
|
|
throw new WrongUsageException(Commands.COMMAND_OVERLAY_OPACITY_USAGE + " " + LocalizationHelper.getLocalizedString(Commands.COMMAND_OVERLAY_OPACITY_USAGE_ADDITIONAL_TEXT), new Object[0]);
|
2012-12-21 16:44:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2013-01-11 21:01:47 +01:00
|
|
|
throw new WrongUsageException(Commands.COMMAND_OVERLAY_OPACITY_USAGE + " " + LocalizationHelper.getLocalizedString(Commands.COMMAND_OVERLAY_OPACITY_USAGE_ADDITIONAL_TEXT), new Object[0]);
|
2012-12-21 16:44:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void processPositionCommand(ICommandSender commandSender, String[] args) {
|
|
|
|
|
2013-01-05 00:53:34 +01:00
|
|
|
String yPosition, xPosition;
|
2012-12-21 16:44:15 +01:00
|
|
|
|
2013-01-09 21:22:21 +01:00
|
|
|
if ((args.length > 2) && (args.length < 5)) {
|
2013-01-05 00:53:34 +01:00
|
|
|
yPosition = args[1];
|
|
|
|
xPosition = args[2];
|
2012-12-21 16:44:15 +01:00
|
|
|
|
2013-01-11 21:01:47 +01:00
|
|
|
if ((yPosition.equalsIgnoreCase(Commands.COMMAND_TOP)) && (xPosition.equalsIgnoreCase(Commands.COMMAND_LEFT))) {
|
2012-12-21 16:44:15 +01:00
|
|
|
ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION = 0;
|
|
|
|
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME, "0");
|
2013-01-11 21:01:47 +01:00
|
|
|
commandSender.sendChatToPlayer(Colours.TEXT_COLOUR_PREFIX_GRAY + LocalizationHelper.getLocalizedString(Commands.COMMAND_OVERLAY_POSITION_TOP_LEFT));
|
2012-12-21 16:44:15 +01:00
|
|
|
}
|
2013-01-11 21:01:47 +01:00
|
|
|
else if ((yPosition.equalsIgnoreCase(Commands.COMMAND_TOP)) && (xPosition.equalsIgnoreCase(Commands.COMMAND_RIGHT))) {
|
2012-12-21 16:44:15 +01:00
|
|
|
ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION = 1;
|
|
|
|
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME, "1");
|
2013-01-11 21:01:47 +01:00
|
|
|
commandSender.sendChatToPlayer(Colours.TEXT_COLOUR_PREFIX_GRAY + LocalizationHelper.getLocalizedString(Commands.COMMAND_OVERLAY_POSITION_TOP_RIGHT));
|
2012-12-21 16:44:15 +01:00
|
|
|
}
|
2013-01-11 21:01:47 +01:00
|
|
|
else if ((yPosition.equalsIgnoreCase(Commands.COMMAND_BOTTOM)) && (xPosition.equalsIgnoreCase(Commands.COMMAND_LEFT))) {
|
2012-12-21 16:44:15 +01:00
|
|
|
ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION = 2;
|
|
|
|
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME, "2");
|
2013-01-11 21:01:47 +01:00
|
|
|
commandSender.sendChatToPlayer(Colours.TEXT_COLOUR_PREFIX_GRAY + LocalizationHelper.getLocalizedString(Commands.COMMAND_OVERLAY_POSITION_BOTTOM_LEFT));
|
2012-12-21 16:44:15 +01:00
|
|
|
}
|
2013-01-11 21:01:47 +01:00
|
|
|
else if ((yPosition.equalsIgnoreCase(Commands.COMMAND_BOTTOM)) && (xPosition.equalsIgnoreCase(Commands.COMMAND_RIGHT))) {
|
2012-12-21 16:44:15 +01:00
|
|
|
ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION = 3;
|
|
|
|
ConfigurationHandler.set(ConfigurationHandler.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME, "3");
|
2013-01-11 21:01:47 +01:00
|
|
|
commandSender.sendChatToPlayer(Colours.TEXT_COLOUR_PREFIX_GRAY + LocalizationHelper.getLocalizedString(Commands.COMMAND_OVERLAY_POSITION_BOTTOM_RIGHT));
|
2012-12-21 16:44:15 +01:00
|
|
|
}
|
2012-12-21 03:31:59 +01:00
|
|
|
else {
|
2013-01-11 21:01:47 +01:00
|
|
|
throw new WrongUsageException(Commands.COMMAND_OVERLAY_POSITION_USAGE, new Object[0]);
|
2012-12-21 03:31:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2013-01-11 21:01:47 +01:00
|
|
|
throw new WrongUsageException(Commands.COMMAND_OVERLAY_POSITION_USAGE, new Object[0]);
|
2012-12-21 03:31:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|