Added crash recovery and renamed ButtonValue(s) and SliderValue(s)

This commit is contained in:
Marcel Konrad
2018-09-11 00:03:51 +02:00
parent c71679cc40
commit 65e41fb7d8
42 changed files with 558 additions and 462 deletions

View File

@@ -21,6 +21,12 @@ import exopandora.worldhandler.util.UtilKeyBinding;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.command.ICommand;
import net.minecraft.util.text.ChatType;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.event.ClickEvent;
import net.minecraft.util.text.event.ClickEvent.Action;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.client.registry.ClientRegistry;
@@ -168,4 +174,22 @@ public class WorldHandler
}
}
}
public static void throwError(Exception exception)
{
if(!Minecraft.getMinecraft().inGameHasFocus)
{
Minecraft.getMinecraft().displayGuiScreen(null);
Minecraft.getMinecraft().setIngameFocus();
}
TextComponentString name = new TextComponentString(Main.NAME);
name.setStyle(new Style().setUnderlined(true).setClickEvent(new ClickEvent(Action.OPEN_URL, "$url")));
TextComponentTranslation message = new TextComponentTranslation("worldhandler.error.gui", name);
message.setStyle(new Style().setColor(net.minecraft.util.text.TextFormatting.RED));
Minecraft.getMinecraft().ingameGUI.addChatMessage(ChatType.SYSTEM, message);
exception.printStackTrace();
}
}

View File

@@ -13,7 +13,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ConfigButcher
{
{
private static Map<String, Boolean> ENTITIES = new HashMap<String, Boolean>();
public static final String CATEGORY = "butcher";

View File

@@ -17,6 +17,7 @@ import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.util.text.ChatType;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
@@ -142,22 +143,29 @@ public class EventListener
{
if(!UtilPlayer.canIssueCommand() && ConfigSettings.isPermissionQueryEnabled())
{
Minecraft.getMinecraft().player.sendMessage(new TextComponentString(ChatFormatting.RED + I18n.format("worldhandler.permission.refused")));
Minecraft.getMinecraft().player.sendMessage(new TextComponentString(ChatFormatting.RED + I18n.format("worldhandler.permission.refused.change", I18n.format("gui.worldhandler.config.key.settings.permission_query"))));
Minecraft.getMinecraft().ingameGUI.addChatMessage(ChatType.GAME_INFO, new TextComponentString(ChatFormatting.RED + I18n.format("worldhandler.permission.refused")));
Minecraft.getMinecraft().ingameGUI.addChatMessage(ChatType.GAME_INFO, new TextComponentString(ChatFormatting.RED + I18n.format("worldhandler.permission.refused.change", I18n.format("gui.worldhandler.config.key.settings.permission_query"))));
}
else
{
if(BlockHelper.isFocusedBlockEqualTo(Blocks.STANDING_SIGN) || BlockHelper.isFocusedBlockEqualTo(Blocks.WALL_SIGN))
try
{
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.SIGN_EDITOR));
if(BlockHelper.isFocusedBlockEqualTo(Blocks.STANDING_SIGN) || BlockHelper.isFocusedBlockEqualTo(Blocks.WALL_SIGN))
{
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.SIGN_EDITOR));
}
else if(BlockHelper.isFocusedBlockEqualTo(Blocks.NOTEBLOCK))
{
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.NOTE_EDITOR));
}
else
{
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.MAIN));
}
}
else if(BlockHelper.isFocusedBlockEqualTo(Blocks.NOTEBLOCK))
catch(Exception e)
{
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.NOTE_EDITOR));
}
else
{
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.MAIN));
WorldHandler.throwError(e);
}
}
}

View File

@@ -3,6 +3,7 @@ package exopandora.worldhandler.gui.button;
import org.lwjgl.input.Mouse;
import exopandora.worldhandler.Main;
import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.config.ConfigSkin;
import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.gui.content.Content;
@@ -148,7 +149,15 @@ public class GuiButtonKeyboard extends GuiButtonWorldHandler
if(mousePressed(minecraft, mouseX, mouseY) && Mouse.isButtonDown(0))
{
this.playPressSound(minecraft.getSoundHandler());
this.content.actionPerformed(this.container, this);
try
{
this.content.actionPerformed(this.container, this);
}
catch(Exception e)
{
WorldHandler.throwError(e);
}
}
this.lastMousePressed = mousePressed(minecraft, mouseX, mouseY);

View File

@@ -4,7 +4,7 @@ import com.mojang.realmsclient.gui.ChatFormatting;
import exopandora.worldhandler.format.TextFormatting;
import exopandora.worldhandler.gui.button.logic.IListButtonLogic;
import exopandora.worldhandler.gui.button.persistence.ButtonValues;
import exopandora.worldhandler.gui.button.persistence.ButtonValue;
import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.gui.content.Content;
import net.minecraft.client.Minecraft;
@@ -18,7 +18,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class GuiButtonList<T> extends GuiButtonWorldHandler
{
private final IListButtonLogic<T> logic;
private final ButtonValues<T> persistence;
private final ButtonValue<T> persistence;
private int mouseX;
private int mouseY;

View File

@@ -2,8 +2,8 @@ package exopandora.worldhandler.gui.button;
import exopandora.worldhandler.config.ConfigSkin;
import exopandora.worldhandler.gui.button.logic.ISliderResponder;
import exopandora.worldhandler.gui.button.persistence.ButtonValues;
import exopandora.worldhandler.gui.button.persistence.SliderValues;
import exopandora.worldhandler.gui.button.persistence.ButtonValue;
import exopandora.worldhandler.gui.button.persistence.SliderValue;
import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.gui.content.Content;
import exopandora.worldhandler.helper.ResourceHelper;
@@ -25,7 +25,7 @@ public class GuiSlider<T> extends GuiButton
private final String name;
private final ISliderResponder responder;
private final Container frame;
private final ButtonValues<SliderValues> persistence;
private final ButtonValue<SliderValue> persistence;
public GuiSlider(Content content, Container frame, Object key, int x, int y, int width, int height, String name, double min, double max, double start, ISliderResponder responder)
{
@@ -45,16 +45,16 @@ public class GuiSlider<T> extends GuiButton
{
if(min == max)
{
this.persistence.setObject(new SliderValues(min, max, 0.0D));
this.persistence.setObject(new SliderValue(min, max, 0.0D));
}
else
{
this.persistence.setObject(new SliderValues(min, max, (start - min) / (max - min)));
this.persistence.setObject(new SliderValue(min, max, (start - min) / (max - min)));
}
}
else if(this.persistence.getObject().getMin() != min || this.persistence.getObject().getMax() != max)
{
this.persistence.setObject(new SliderValues(min, max, (int) MathHelper.clamp(this.getValue(), min, max)));
this.persistence.setObject(new SliderValue(min, max, (int) MathHelper.clamp(this.getValue(), min, max)));
}
}

View File

@@ -5,7 +5,7 @@ import java.util.Arrays;
import com.mojang.realmsclient.gui.ChatFormatting;
import exopandora.worldhandler.format.EnumColor;
import exopandora.worldhandler.gui.button.persistence.ButtonValues;
import exopandora.worldhandler.gui.button.persistence.ButtonValue;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@@ -26,13 +26,13 @@ public abstract class ColorListButtonLogic implements IListButtonLogic<Integer>
}
@Override
public String getTooltipString(ButtonValues<Integer> values)
public String getTooltipString(ButtonValue<Integer> values)
{
return null;
}
@Override
public String getDisplayString(ButtonValues values)
public String getDisplayString(ButtonValue values)
{
EnumColor color = EnumColor.getColorFromId(values.getIndex());
return color + I18n.format("gui.worldhandler.color") + ": " + I18n.format("gui.worldhandler.color." + color.getFormat());

View File

@@ -1,6 +1,6 @@
package exopandora.worldhandler.gui.button.logic;
import exopandora.worldhandler.gui.button.persistence.ButtonValues;
import exopandora.worldhandler.gui.button.persistence.ButtonValue;
import exopandora.worldhandler.gui.container.Container;
import net.minecraft.client.gui.GuiButton;
import net.minecraftforge.fml.relauncher.Side;
@@ -9,15 +9,15 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public interface IListButtonLogic<T>
{
void actionPerformed(Container container, GuiButton button, ButtonValues<T> values);
void actionPerformed(Container container, GuiButton button, ButtonValue<T> values);
int getMax();
T getObject(int index);
String getDisplayString(ButtonValues<T> values);
String getDisplayString(ButtonValue<T> values);
default String getTooltipString(ButtonValues<T> values)
default String getTooltipString(ButtonValue<T> values)
{
if(values != null && values.getObject() != null)
{

View File

@@ -4,7 +4,7 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ButtonValues<T>
public class ButtonValue<T>
{
private int index;
private T object;

View File

@@ -3,27 +3,26 @@ package exopandora.worldhandler.gui.button.persistence;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class SliderValues
public class SliderValue
{
private final double min;
private final double max;
private double position;
private SliderValues(double min, double max)
private SliderValue(double min, double max)
{
this.min = min;
this.max = max;
}
public SliderValues(double min, double max, double position)
public SliderValue(double min, double max, double position)
{
this(min, max);
this.position = position;
}
public SliderValues(double min, double max, int value)
public SliderValue(double min, double max, int value)
{
this(min, max);
this.position = this.valueToPosition(value);

View File

@@ -9,6 +9,7 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.Main;
import exopandora.worldhandler.gui.content.Content;
import exopandora.worldhandler.gui.content.Contents;
import exopandora.worldhandler.gui.content.impl.ContentPlaysound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.RegistryNamespaced;
import net.minecraftforge.fml.relauncher.Side;
@@ -61,7 +62,7 @@ public class Category
public static void registerCategories()
{
registerCategory(0, "main", new Category(Contents.MAIN, Contents.CONTAINERS, Contents.MULTIPLAYER));
registerCategory(1, "entities", new Category(Contents.SUMMON));
registerCategory(1, "entities", new Category(Contents.SUMMON, new ContentPlaysound()));
registerCategory(2, "items", new Category(Contents.CUSTOM_ITEM, Contents.ENCHANTMENT, Contents.RECIPES));
registerCategory(3, "blocks", new Category(Contents.EDIT_BLOCKS, Contents.SIGN_EDITOR, Contents.NOTE_EDITOR));
registerCategory(4, "world", new Category(Contents.WORLD_INFO, Contents.GAMERULES));

View File

@@ -67,7 +67,7 @@ public class GuiWorldHandlerContainer extends Container
private static final BuilderWorldHandler BUILDER_WORLD_HANDLER = new BuilderWorldHandler();
public GuiWorldHandlerContainer(Content content)
public GuiWorldHandlerContainer(Content content) throws Exception
{
this.content = content;
this.tabSize = this.content.getCategory().getSize();
@@ -81,75 +81,82 @@ public class GuiWorldHandlerContainer extends Container
@Override
public void initGui()
{
this.finalButtons.clear();
this.elements.clear();
//INIT
this.content.onPlayerNameChanged(this.getPlayer());
this.content.initGui(this, this.getContentX(), this.getContentY());
//ELEMENTS
for(IElement element : this.elements)
try
{
element.initGui(this);
}
//SHORTCUTS
final int x = this.width / 2 - 10;
final int delta = 21;
if(ConfigSettings.areShortcutsEnabled())
{
this.finalButtons.add(new GuiButtonWorldHandler(-1, x - delta * 7, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.dawn", ConfigSettings.getDawn())), EnumTooltip.RIGHT, EnumIcon.TIME_DAWN));
this.finalButtons.add(new GuiButtonWorldHandler(-2, x - delta * 6, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.noon", ConfigSettings.getNoon())), EnumTooltip.RIGHT, EnumIcon.TIME_NOON));
this.finalButtons.add(new GuiButtonWorldHandler(-3, x - delta * 5, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.sunset", ConfigSettings.getSunset())), EnumTooltip.RIGHT, EnumIcon.TIME_SUNSET));
this.finalButtons.add(new GuiButtonWorldHandler(-4, x - delta * 4, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.midnight", ConfigSettings.getMidnight())), EnumTooltip.RIGHT, EnumIcon.TIME_MIDNIGHT));
this.finalButtons.add(new GuiButtonWorldHandler(-5, x - delta * 3, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.clear")), EnumTooltip.RIGHT, EnumIcon.WEATHER_SUN));
this.finalButtons.add(new GuiButtonWorldHandler(-6, x - delta * 2, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.rainy")), EnumTooltip.RIGHT, EnumIcon.WEATHER_RAIN));
this.finalButtons.add(new GuiButtonWorldHandler(-7, x - delta * 1, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.thunder")), EnumTooltip.RIGHT, EnumIcon.WEATHER_STORM));
this.finalButtons.add(new GuiButtonWorldHandler(-8, x - delta * 0, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.peaceful")), EnumTooltip.RIGHT, EnumIcon.DIFFICULTY_PEACEFUL));
this.finalButtons.add(new GuiButtonWorldHandler(-9, x + delta * 1, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.easy")), EnumTooltip.RIGHT, EnumIcon.DIFFICULTY_EASY));
this.finalButtons.add(new GuiButtonWorldHandler(-10, x + delta * 2, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.normal")), EnumTooltip.RIGHT, EnumIcon.DIFFICULTY_NORMAL));
this.finalButtons.add(new GuiButtonWorldHandler(-11, x + delta * 3, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.hard")), EnumTooltip.RIGHT, EnumIcon.DIFFICULTY_HARD));
this.finalButtons.add(new GuiButtonWorldHandler(-12, x + delta * 4, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.survival")), EnumTooltip.RIGHT, EnumIcon.GAMEMODE_SURVIVAL));
this.finalButtons.add(new GuiButtonWorldHandler(-13, x + delta * 5, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.creative")), EnumTooltip.RIGHT, EnumIcon.GAMEMODE_CREATIVE));
this.finalButtons.add(new GuiButtonWorldHandler(-14, x + delta * 6, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.adventure")), EnumTooltip.RIGHT, EnumIcon.GAMEMODE_ADVENTURE));
this.finalButtons.add(new GuiButtonWorldHandler(-15, x + delta * 7, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.spectator")), EnumTooltip.RIGHT, EnumIcon.GAMEMODE_SPECTATOR));
}
//SYNTAX
if(ConfigSettings.isCommandSyntaxEnabled())
{
this.syntaxField = new GuiTextFieldTooltip(x - delta * 7 + 1, this.height - 22, delta * 15 - 3, 20);
this.updateSyntax();
}
//NAME
this.nameField = new GuiTextFieldTooltip(0, 0, 0, 11);
this.nameField.setMaxStringLength(16);
this.nameField.setText(this.getPlayer());
this.updateNameField();
final int backgroundX = this.getBackgroundX();
final int backgroundY = this.getBackgroundY();
this.forEachTab((index, xOffset) ->
{
IContent tab = this.content.getCategory().getContent(index);
this.finalButtons.clear();
this.elements.clear();
if(!this.content.getActiveContent().equals(tab))
//INIT
this.content.onPlayerNameChanged(this.getPlayer());
this.content.initGui(this, this.getContentX(), this.getContentY());
//ELEMENTS
for(IElement element : this.elements)
{
this.finalButtons.add(new GuiButtonTab(-16, (int) (backgroundX + xOffset), backgroundY - 20, (int) this.tabWidth + (int) Math.ceil(this.tabEpsilon / this.tabSize), 21, index));
element.initGui(this);
}
});
//BUTTONS
this.initButtons();
//SHORTCUTS
final int x = this.width / 2 - 10;
final int delta = 21;
if(ConfigSettings.areShortcutsEnabled())
{
this.finalButtons.add(new GuiButtonWorldHandler(-1, x - delta * 7, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.dawn", ConfigSettings.getDawn())), EnumTooltip.RIGHT, EnumIcon.TIME_DAWN));
this.finalButtons.add(new GuiButtonWorldHandler(-2, x - delta * 6, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.noon", ConfigSettings.getNoon())), EnumTooltip.RIGHT, EnumIcon.TIME_NOON));
this.finalButtons.add(new GuiButtonWorldHandler(-3, x - delta * 5, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.sunset", ConfigSettings.getSunset())), EnumTooltip.RIGHT, EnumIcon.TIME_SUNSET));
this.finalButtons.add(new GuiButtonWorldHandler(-4, x - delta * 4, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.time", I18n.format("gui.worldhandler.shortcuts.tooltip.time.midnight", ConfigSettings.getMidnight())), EnumTooltip.RIGHT, EnumIcon.TIME_MIDNIGHT));
this.finalButtons.add(new GuiButtonWorldHandler(-5, x - delta * 3, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.clear")), EnumTooltip.RIGHT, EnumIcon.WEATHER_SUN));
this.finalButtons.add(new GuiButtonWorldHandler(-6, x - delta * 2, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.rainy")), EnumTooltip.RIGHT, EnumIcon.WEATHER_RAIN));
this.finalButtons.add(new GuiButtonWorldHandler(-7, x - delta * 1, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.weather", I18n.format("gui.worldhandler.shortcuts.tooltip.weather.thunder")), EnumTooltip.RIGHT, EnumIcon.WEATHER_STORM));
this.finalButtons.add(new GuiButtonWorldHandler(-8, x - delta * 0, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.peaceful")), EnumTooltip.RIGHT, EnumIcon.DIFFICULTY_PEACEFUL));
this.finalButtons.add(new GuiButtonWorldHandler(-9, x + delta * 1, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.easy")), EnumTooltip.RIGHT, EnumIcon.DIFFICULTY_EASY));
this.finalButtons.add(new GuiButtonWorldHandler(-10, x + delta * 2, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.normal")), EnumTooltip.RIGHT, EnumIcon.DIFFICULTY_NORMAL));
this.finalButtons.add(new GuiButtonWorldHandler(-11, x + delta * 3, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty", I18n.format("gui.worldhandler.shortcuts.tooltip.difficulty.hard")), EnumTooltip.RIGHT, EnumIcon.DIFFICULTY_HARD));
this.finalButtons.add(new GuiButtonWorldHandler(-12, x + delta * 4, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.survival")), EnumTooltip.RIGHT, EnumIcon.GAMEMODE_SURVIVAL));
this.finalButtons.add(new GuiButtonWorldHandler(-13, x + delta * 5, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.creative")), EnumTooltip.RIGHT, EnumIcon.GAMEMODE_CREATIVE));
this.finalButtons.add(new GuiButtonWorldHandler(-14, x + delta * 6, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.adventure")), EnumTooltip.RIGHT, EnumIcon.GAMEMODE_ADVENTURE));
this.finalButtons.add(new GuiButtonWorldHandler(-15, x + delta * 7, 0, 20, 20, null, I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode", I18n.format("gui.worldhandler.shortcuts.tooltip.gamemode.spectator")), EnumTooltip.RIGHT, EnumIcon.GAMEMODE_SPECTATOR));
}
//SYNTAX
if(ConfigSettings.isCommandSyntaxEnabled())
{
this.syntaxField = new GuiTextFieldTooltip(x - delta * 7 + 1, this.height - 22, delta * 15 - 3, 20);
this.updateSyntax();
}
//NAME
this.nameField = new GuiTextFieldTooltip(0, 0, 0, 11);
this.nameField.setMaxStringLength(16);
this.nameField.setText(this.getPlayer());
this.updateNameField();
final int backgroundX = this.getBackgroundX();
final int backgroundY = this.getBackgroundY();
this.forEachTab((index, xOffset) ->
{
IContent tab = this.content.getCategory().getContent(index);
if(!this.content.getActiveContent().equals(tab))
{
this.finalButtons.add(new GuiButtonTab(-16, (int) (backgroundX + xOffset), backgroundY - 20, (int) this.tabWidth + (int) Math.ceil(this.tabEpsilon / this.tabSize), 21, index));
}
});
//BUTTONS
this.initButtons();
}
catch(Exception e)
{
WorldHandler.throwError(e);
}
}
public void initButtons()
@@ -192,8 +199,15 @@ public class GuiWorldHandlerContainer extends Container
@Override
public void updateScreen()
{
this.content.updateScreen(this);
this.updateSyntax();
try
{
this.content.updateScreen(this);
this.updateSyntax();
}
catch(Exception e)
{
WorldHandler.throwError(e);
}
}
private int getBackgroundX()
@@ -270,80 +284,87 @@ public class GuiWorldHandlerContainer extends Container
@Override
protected void actionPerformed(GuiButton button) throws IOException
{
buttons:
switch(button.id)
try
{
case 1:
Minecraft.getMinecraft().displayGuiScreen((GuiScreen) null);
Minecraft.getMinecraft().setIngameFocus();
break;
case 0:
if(this.content.getBackContent() != null)
{
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(this.content.getBackContent()));
}
break;
case -1:
WorldHandler.sendCommand(new BuilderTime(EnumMode.SET, ConfigSettings.getDawn()));
break;
case -2:
WorldHandler.sendCommand(new BuilderTime(EnumMode.SET, ConfigSettings.getNoon()));
break;
case -3:
WorldHandler.sendCommand(new BuilderTime(EnumMode.SET, ConfigSettings.getSunset()));
break;
case -4:
WorldHandler.sendCommand(new BuilderTime(EnumMode.SET, ConfigSettings.getMidnight()));
break;
case -5:
WorldHandler.sendCommand(new BuilderWeather(EnumWeather.CLEAR));
break;
case -6:
WorldHandler.sendCommand(new BuilderWeather(EnumWeather.RAIN));
break;
case -7:
WorldHandler.sendCommand(new BuilderWeather(EnumWeather.THUNDER));
break;
case -8:
WorldHandler.sendCommand(new BuilderDifficulty(EnumDifficulty.PEACEFUL));
break;
case -9:
WorldHandler.sendCommand(new BuilderDifficulty(EnumDifficulty.EASY));
break;
case -10:
WorldHandler.sendCommand(new BuilderDifficulty(EnumDifficulty.NORMAL));
break;
case -11:
WorldHandler.sendCommand(new BuilderDifficulty(EnumDifficulty.HARD));
break;
case -12:
WorldHandler.sendCommand(new BuilderGamemode(EnumGamemode.SURVIVAL));
break;
case -13:
WorldHandler.sendCommand(new BuilderGamemode(EnumGamemode.CREATIVE));
break;
case -14:
WorldHandler.sendCommand(new BuilderGamemode(EnumGamemode.ADVENTURE));
break;
case -15:
WorldHandler.sendCommand(new BuilderGamemode(EnumGamemode.SPECTATOR));
break;
case -16:
if(button instanceof GuiButtonTab)
{
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(this.content.getCategory().getContent(((GuiButtonTab)button).getIndex())));
}
break;
default:
for(IElement element : this.elements)
{
if(element.actionPerformed(this, button))
buttons:
switch(button.id)
{
case 1:
Minecraft.getMinecraft().displayGuiScreen((GuiScreen) null);
Minecraft.getMinecraft().setIngameFocus();
break;
case 0:
if(this.content.getBackContent() != null)
{
break buttons;
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(this.content.getBackContent()));
}
}
this.content.actionPerformed(this, button);
break;
break;
case -1:
WorldHandler.sendCommand(new BuilderTime(EnumMode.SET, ConfigSettings.getDawn()));
break;
case -2:
WorldHandler.sendCommand(new BuilderTime(EnumMode.SET, ConfigSettings.getNoon()));
break;
case -3:
WorldHandler.sendCommand(new BuilderTime(EnumMode.SET, ConfigSettings.getSunset()));
break;
case -4:
WorldHandler.sendCommand(new BuilderTime(EnumMode.SET, ConfigSettings.getMidnight()));
break;
case -5:
WorldHandler.sendCommand(new BuilderWeather(EnumWeather.CLEAR));
break;
case -6:
WorldHandler.sendCommand(new BuilderWeather(EnumWeather.RAIN));
break;
case -7:
WorldHandler.sendCommand(new BuilderWeather(EnumWeather.THUNDER));
break;
case -8:
WorldHandler.sendCommand(new BuilderDifficulty(EnumDifficulty.PEACEFUL));
break;
case -9:
WorldHandler.sendCommand(new BuilderDifficulty(EnumDifficulty.EASY));
break;
case -10:
WorldHandler.sendCommand(new BuilderDifficulty(EnumDifficulty.NORMAL));
break;
case -11:
WorldHandler.sendCommand(new BuilderDifficulty(EnumDifficulty.HARD));
break;
case -12:
WorldHandler.sendCommand(new BuilderGamemode(EnumGamemode.SURVIVAL));
break;
case -13:
WorldHandler.sendCommand(new BuilderGamemode(EnumGamemode.CREATIVE));
break;
case -14:
WorldHandler.sendCommand(new BuilderGamemode(EnumGamemode.ADVENTURE));
break;
case -15:
WorldHandler.sendCommand(new BuilderGamemode(EnumGamemode.SPECTATOR));
break;
case -16:
if(button instanceof GuiButtonTab)
{
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(this.content.getCategory().getContent(((GuiButtonTab)button).getIndex())));
}
break;
default:
for(IElement element : this.elements)
{
if(element.actionPerformed(this, button))
{
break buttons;
}
}
this.content.actionPerformed(this, button);
break;
}
}
catch(Exception e)
{
WorldHandler.throwError(e);
}
}
@@ -399,318 +420,346 @@ public class GuiWorldHandlerContainer extends Container
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
final int backgroundX = this.getBackgroundX();
final int backgroundY = this.getBackgroundY();
//DEFAULT BACKGROUND
if(ConfigSkin.isBackgroundDrawingEnabled())
try
{
super.drawDefaultBackground();
}
//COLOR
this.defaultColor();
//BACKGROUND
this.bindBackground();
this.drawTexturedModalRect(backgroundX, backgroundY, 0, 0, this.bgTextureWidth, this.bgTextureHeight);
//TABS
this.forEachTab((index, xOffset) ->
{
IContent tab = this.content.getCategory().getContent(index);
int yOffset;
int fHeight;
int color;
final int backgroundX = this.getBackgroundX();
final int backgroundY = this.getBackgroundY();
if(this.content.getActiveContent().equals(tab))
//DEFAULT BACKGROUND
if(ConfigSkin.isBackgroundDrawingEnabled())
{
yOffset = -22;
fHeight = 25;
color = 0xFFFFFF;
this.defaultColor();
}
else
{
yOffset = -20;
fHeight = 20;
color = 0xE0E0E0;
this.darkColor();
super.drawDefaultBackground();
}
//COLOR
this.defaultColor();
//BACKGROUND
this.bindBackground();
this.drawTexturedModalRect((int) (backgroundX + xOffset), (int) (backgroundY + yOffset), 0, 0, (int) Math.ceil(this.tabHalf), fHeight);
this.drawTexturedModalRect((int) (backgroundX + this.tabHalf + xOffset), (int) (backgroundY + yOffset), this.bgTextureWidth - (int) Math.ceil(this.tabHalf), 0, (int) Math.ceil(this.tabHalf), fHeight);
this.drawTexturedModalRect(backgroundX, backgroundY, 0, 0, this.bgTextureWidth, this.bgTextureHeight);
if(!ConfigSkin.areSharpEdgesEnabled())
//TABS
this.forEachTab((index, xOffset) ->
{
IContent tab = this.content.getCategory().getContent(index);
int yOffset;
int fHeight;
int color;
if(this.content.getActiveContent().equals(tab))
{
//RIGHT TAB CURVATURE
if(index < this.tabSize - 1 || this.tabSize == 1)
{
int factor = 2;
for(int x = 0; x < factor; x++)
{
this.drawTexturedModalRect((int) (backgroundX + this.tabWidth + xOffset - x - 1), (int) (backgroundY + x + 1), (int) (this.tabWidth - x - 1), x + 1, x + 1, 1);
}
}
//LEFT TAB CURVATURE
if(index > 0)
{
int factor = 2;
for(int x = 0; x < factor; x++)
{
this.drawTexturedModalRect((int) (backgroundX + xOffset), (int) (backgroundY + x + 1), xOffset.intValue(), x + 1, x + 1, 1);
}
}
int width = (int)(this.tabWidth - 3);
int interval = 5;
//LEFT GRADIENT
if(index == 0)
{
for(int x = 0; x < width; x += interval)
{
this.defaultColor(1.0F - (x / (width + 5.0F * interval)));
this.drawTexturedModalRect((int) (backgroundX + xOffset), (int) (backgroundY + yOffset + fHeight + x / interval), 0, fHeight, width - x, 1);
}
}
//RIGHT GRADIENT
if(index == this.tabSize - 1 && this.tabSize > 1)
{
int offset = 3;
for(int x = 0; x < width; x += interval)
{
this.defaultColor(1.0F - (x / (width + 5.0F * interval)));
this.drawTexturedModalRect((int) (backgroundX + Math.ceil(xOffset) + x + offset), (int) (backgroundY + yOffset + fHeight + x / interval), this.bgTextureWidth - width + x, fHeight, width - x, 1);
}
}
yOffset = -22;
fHeight = 25;
color = 0xFFFFFF;
this.defaultColor();
}
else
{
//LEFT CORNER FILLER
if(index == 0)
yOffset = -20;
fHeight = 20;
color = 0xE0E0E0;
this.darkColor();
}
this.bindBackground();
this.drawTexturedModalRect((int) (backgroundX + xOffset), (int) (backgroundY + yOffset), 0, 0, (int) Math.ceil(this.tabHalf), fHeight);
this.drawTexturedModalRect((int) (backgroundX + this.tabHalf + xOffset), (int) (backgroundY + yOffset), this.bgTextureWidth - (int) Math.ceil(this.tabHalf), 0, (int) Math.ceil(this.tabHalf), fHeight);
if(!ConfigSkin.areSharpEdgesEnabled())
{
if(this.content.getActiveContent().equals(tab))
{
int factor = 2;
//RIGHT TAB CURVATURE
for(int x = 0; x < factor; x++)
if(index < this.tabSize - 1 || this.tabSize == 1)
{
this.drawTexturedModalRect(backgroundX, backgroundY + x, 0, fHeight, factor - x, 1);
int factor = 2;
for(int x = 0; x < factor; x++)
{
this.drawTexturedModalRect((int) (backgroundX + this.tabWidth + xOffset - x - 1), (int) (backgroundY + x + 1), (int) (this.tabWidth - x - 1), x + 1, x + 1, 1);
}
}
//LEFT TAB CURVATURE
if(index > 0)
{
int factor = 2;
for(int x = 0; x < factor; x++)
{
this.drawTexturedModalRect((int) (backgroundX + xOffset), (int) (backgroundY + x + 1), xOffset.intValue(), x + 1, x + 1, 1);
}
}
int width = (int)(this.tabWidth - 3);
int interval = 5;
//LEFT GRADIENT
if(index == 0)
{
for(int x = 0; x < width; x += interval)
{
this.defaultColor(1.0F - (x / (width + 5.0F * interval)));
this.drawTexturedModalRect((int) (backgroundX + xOffset), (int) (backgroundY + yOffset + fHeight + x / interval), 0, fHeight, width - x, 1);
}
}
//RIGHT GRADIENT
if(index == this.tabSize - 1 && this.tabSize > 1)
{
int offset = 3;
for(int x = 0; x < width; x += interval)
{
this.defaultColor(1.0F - (x / (width + 5.0F * interval)));
this.drawTexturedModalRect((int) (backgroundX + Math.ceil(xOffset) + x + offset), (int) (backgroundY + yOffset + fHeight + x / interval), this.bgTextureWidth - width + x, fHeight, width - x, 1);
}
}
}
//RIGHT CORNER FILLER
if(index == this.tabSize - 1)
else
{
int factor = 3;
//LEFT CORNER FILLER
for(int x = 0; x < factor + 1; x++)
if(index == 0)
{
this.drawTexturedModalRect(backgroundX + this.bgTextureWidth - x, backgroundY + factor - x, this.bgTextureWidth - x, fHeight, x, 1);
int factor = 2;
for(int x = 0; x < factor; x++)
{
this.drawTexturedModalRect(backgroundX, backgroundY + x, 0, fHeight, factor - x, 1);
}
}
//RIGHT CORNER FILLER
if(index == this.tabSize - 1)
{
int factor = 3;
for(int x = 0; x < factor + 1; x++)
{
this.drawTexturedModalRect(backgroundX + this.bgTextureWidth - x, backgroundY + factor - x, this.bgTextureWidth - x, fHeight, x, 1);
}
}
}
}
this.drawCenteredString(this.fontRenderer, ChatFormatting.UNDERLINE + tab.getTabTitle(), (int) (backgroundX + this.tabHalf + xOffset), (int) (backgroundY - 13), color);
});
this.defaultColor();
//VERSION LABEL
final String label = "$mcversion-$version";
final int hexAlpha = (int) (0xFF * 0.2) << 24;
final int color = ConfigSkin.getLabelColor() + hexAlpha;
final int versionWidth = this.width - this.fontRenderer.getStringWidth(label) - 2;
final int versionHeight = this.height - 10;
this.fontRenderer.drawString(label, versionWidth, versionHeight, color);
//TITLE
final int maxWidth = this.bgTextureWidth - 7 - 2 - this.fontRenderer.getStringWidth(WorldHandler.USERNAME) - 2 - this.getWatchOffset() - 7;
this.fontRenderer.drawString(TextFormatting.shortenString(this.content.getTitle(), maxWidth, this.fontRenderer), backgroundX + 7, backgroundY + 7, ConfigSkin.getLabelColor());
//HEADLINE
if(this.content.getHeadline() != null)
{
if(this.content.getHeadline().length > 0)
{
this.fontRenderer.drawString(this.content.getHeadline()[0], backgroundX + 8, backgroundY + 22, ConfigSkin.getHeadlineColor());
}
if(this.content.getHeadline().length > 1)
{
this.fontRenderer.drawString(this.content.getHeadline()[1], backgroundX + 126, backgroundY + 22, ConfigSkin.getHeadlineColor());
}
}
//NAME FIELD
final String username = WorldHandler.USERNAME.isEmpty() && !this.nameField.isFocused() ? I18n.format("gui.worldhandler.generic.edit_username") : WorldHandler.USERNAME;
this.fontRenderer.drawString(username, backgroundX + 232 - this.fontRenderer.getStringWidth(username), backgroundY + 7, ConfigSkin.getLabelColor());
//WATCH
if(ConfigSettings.isWatchEnabled())
{
final int watchX = backgroundX + 233;
final int watchY = backgroundY + 5;
UtilRender.drawWatchIntoGui(this, watchX, watchY, Minecraft.getMinecraft().world.getWorldInfo().getWorldTime(), ConfigSettings.isSmoothWatchEnabled());
if(ConfigSettings.areTooltipsEnabled())
{
if(mouseX >= watchX && mouseX <= watchX + 9 && mouseY >= watchY && mouseY <= watchY + 9)
{
GuiUtils.drawHoveringText(Arrays.asList(TextFormatting.getWorldTime(Minecraft.getMinecraft().world.getWorldTime())), mouseX, mouseY + 9, this.width, this.height, this.width, this.fontRenderer);
GlStateManager.disableLighting();
}
}
}
this.drawCenteredString(this.fontRenderer, ChatFormatting.UNDERLINE + tab.getTabTitle(), (int) (backgroundX + this.tabHalf + xOffset), (int) (backgroundY - 13), color);
});
this.defaultColor();
//VERSION LABEL
final String label = "$mcversion-$version";
final int hexAlpha = (int) (0xFF * 0.2) << 24;
final int color = ConfigSkin.getLabelColor() + hexAlpha;
final int versionWidth = this.width - this.fontRenderer.getStringWidth(label) - 2;
final int versionHeight = this.height - 10;
this.fontRenderer.drawString(label, versionWidth, versionHeight, color);
//TITLE
final int maxWidth = this.bgTextureWidth - 7 - 2 - this.fontRenderer.getStringWidth(WorldHandler.USERNAME) - 2 - this.getWatchOffset() - 7;
this.fontRenderer.drawString(TextFormatting.shortenString(this.content.getTitle(), maxWidth, this.fontRenderer), backgroundX + 7, backgroundY + 7, ConfigSkin.getLabelColor());
//HEADLINE
if(this.content.getHeadline() != null)
{
if(this.content.getHeadline().length > 0)
//BUTTONS
for(int x = 0; x < this.buttonList.size(); x++)
{
this.fontRenderer.drawString(this.content.getHeadline()[0], backgroundX + 8, backgroundY + 22, ConfigSkin.getHeadlineColor());
this.buttonList.get(x).drawButton(this.mc, mouseX, mouseY, partialTicks);
}
if(this.content.getHeadline().length > 1)
for(int x = 0; x < this.labelList.size(); x++)
{
this.fontRenderer.drawString(this.content.getHeadline()[1], backgroundX + 126, backgroundY + 22, ConfigSkin.getHeadlineColor());
this.labelList.get(x).drawLabel(this.mc, mouseX, mouseY);
}
}
//NAME FIELD
final String username = WorldHandler.USERNAME.isEmpty() && !this.nameField.isFocused() ? I18n.format("gui.worldhandler.generic.edit_username") : WorldHandler.USERNAME;
this.fontRenderer.drawString(username, backgroundX + 232 - this.fontRenderer.getStringWidth(username), backgroundY + 7, ConfigSkin.getLabelColor());
//WATCH
if(ConfigSettings.isWatchEnabled())
{
final int watchX = backgroundX + 233;
final int watchY = backgroundY + 5;
UtilRender.drawWatchIntoGui(this, watchX, watchY, Minecraft.getMinecraft().world.getWorldInfo().getWorldTime(), ConfigSettings.isSmoothWatchEnabled());
//CONTAINER
this.content.drawScreen(this, this.getContentX(), this.getContentY(), mouseX, mouseY, partialTicks);
//CONTAINER ELEMENTS
for(IElement element : this.elements)
{
element.draw();
}
//SYNTAX
if(ConfigSettings.isCommandSyntaxEnabled() && this.syntaxField != null)
{
this.syntaxField.drawTextBox();
}
//SPLASHTEXT
if(this.splash != null)
{
GlStateManager.pushMatrix();
RenderHelper.enableGUIStandardItemLighting();
GlStateManager.disableLighting();
GlStateManager.translate((float) (backgroundX + 212), backgroundY + 15, 0.0F);
GlStateManager.rotate(17.0F, 0.0F, 0.0F, 1.0F);
float scale = 1.1F - MathHelper.abs(MathHelper.sin((float) (Minecraft.getSystemTime() % 1000L) / 1000.0F * (float) Math.PI * 2.0F) * 0.1F);
scale = scale * 100.0F / this.fontRenderer.getStringWidth(this.splash);
GlStateManager.scale(scale, scale, scale);
this.drawCenteredString(this.fontRenderer, this.splash, 0, (int) scale, 0xFFFF00);
GlStateManager.popMatrix();
}
//TOOLTIPS
if(ConfigSettings.areTooltipsEnabled())
{
if(mouseX >= watchX && mouseX <= watchX + 9 && mouseY >= watchY && mouseY <= watchY + 9)
for(int x = 0; x < this.buttonList.size(); x++)
{
GuiUtils.drawHoveringText(Arrays.asList(TextFormatting.getWorldTime(Minecraft.getMinecraft().world.getWorldTime())), mouseX, mouseY + 9, this.width, this.height, this.width, this.fontRenderer);
GlStateManager.disableLighting();
if(this.buttonList.get(x) instanceof GuiButtonWorldHandler)
{
((GuiButtonWorldHandler) this.buttonList.get(x)).drawTooltip(mouseX, mouseY, this.width, this.height);
}
}
}
}
//BUTTONS
for(int x = 0; x < this.buttonList.size(); x++)
{
this.buttonList.get(x).drawButton(this.mc, mouseX, mouseY, partialTicks);
}
for(int x = 0; x < this.labelList.size(); x++)
{
this.labelList.get(x).drawLabel(this.mc, mouseX, mouseY);
}
//CONTAINER
this.content.drawScreen(this, this.getContentX(), this.getContentY(), mouseX, mouseY, partialTicks);
//CONTAINER ELEMENTS
for(IElement element : this.elements)
{
element.draw();
}
//SYNTAX
if(ConfigSettings.isCommandSyntaxEnabled() && this.syntaxField != null)
{
this.syntaxField.drawTextBox();
}
//SPLASHTEXT
if(this.splash != null)
{
GlStateManager.pushMatrix();
RenderHelper.enableGUIStandardItemLighting();
GlStateManager.disableLighting();
GlStateManager.translate((float) (backgroundX + 212), backgroundY + 15, 0.0F);
GlStateManager.rotate(17.0F, 0.0F, 0.0F, 1.0F);
float scale = 1.1F - MathHelper.abs(MathHelper.sin((float) (Minecraft.getSystemTime() % 1000L) / 1000.0F * (float) Math.PI * 2.0F) * 0.1F);
scale = scale * 100.0F / this.fontRenderer.getStringWidth(this.splash);
GlStateManager.scale(scale, scale, scale);
//VERSION LABEL TOOLTIP
this.drawCenteredString(this.fontRenderer, this.splash, 0, (int) scale, 0xFFFF00);
GlStateManager.popMatrix();
}
//TOOLTIPS
if(ConfigSettings.areTooltipsEnabled())
{
for(int x = 0; x < this.buttonList.size(); x++)
if(mouseX >= versionWidth && mouseY >= versionHeight)
{
if(this.buttonList.get(x) instanceof GuiButtonWorldHandler)
{
((GuiButtonWorldHandler) this.buttonList.get(x)).drawTooltip(mouseX, mouseY, this.width, this.height);
}
GuiUtils.drawHoveringText(Arrays.asList(label), versionWidth - 12, versionHeight + 12, this.width + this.fontRenderer.getStringWidth(label), this.height + 10, this.width, this.fontRenderer);
}
}
//VERSION LABEL TOOLTIP
if(mouseX >= versionWidth && mouseY >= versionHeight)
catch(Exception e)
{
GuiUtils.drawHoveringText(Arrays.asList(label), versionWidth - 12, versionHeight + 12, this.width + this.fontRenderer.getStringWidth(label), this.height + 10, this.width, this.fontRenderer);
WorldHandler.throwError(e);
}
}
@Override
protected void keyTyped(char charTyped, int keyCode) throws IOException
{
super.keyTyped(charTyped, keyCode);
this.content.keyTyped(this, charTyped, keyCode);
if(this.nameField.isFocused())
try
{
this.nameField.textboxKeyTyped(charTyped, keyCode);
WorldHandler.USERNAME = this.nameField.getText();
this.updateNameField();
super.keyTyped(charTyped, keyCode);
this.content.keyTyped(this, charTyped, keyCode);
if(this.nameField.isFocused())
{
this.nameField.textboxKeyTyped(charTyped, keyCode);
WorldHandler.USERNAME = this.nameField.getText();
this.updateNameField();
}
if(ConfigSettings.isCommandSyntaxEnabled() && this.syntaxField != null)
{
this.syntaxField.textboxKeyTyped(charTyped, keyCode);
}
for(IElement element : this.elements)
{
element.keyTyped(this, charTyped, keyCode);
}
}
if(ConfigSettings.isCommandSyntaxEnabled() && this.syntaxField != null)
catch(Exception e)
{
this.syntaxField.textboxKeyTyped(charTyped, keyCode);
}
for(IElement element : this.elements)
{
element.keyTyped(this, charTyped, keyCode);
WorldHandler.throwError(e);
}
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
super.mouseClicked(mouseX, mouseY, mouseButton);
this.content.mouseClicked(mouseX, mouseY, mouseButton);
this.nameField.mouseClicked(mouseX, mouseY, mouseButton);
if(this.nameField.isFocused())
try
{
this.nameField.setCursorPositionEnd();
super.mouseClicked(mouseX, mouseY, mouseButton);
this.content.mouseClicked(mouseX, mouseY, mouseButton);
this.nameField.mouseClicked(mouseX, mouseY, mouseButton);
if(this.nameField.isFocused())
{
this.nameField.setCursorPositionEnd();
}
if(ConfigSettings.isCommandSyntaxEnabled() && this.syntaxField != null)
{
this.syntaxField.mouseClicked(mouseX, mouseY, mouseButton);
}
for(IElement element : this.elements)
{
element.mouseClicked(mouseX, mouseY, mouseButton);
}
}
if(ConfigSettings.isCommandSyntaxEnabled() && this.syntaxField != null)
catch(Exception e)
{
this.syntaxField.mouseClicked(mouseX, mouseY, mouseButton);
}
for(IElement element : this.elements)
{
element.mouseClicked(mouseX, mouseY, mouseButton);
WorldHandler.throwError(e);
}
}
@Override
public void onGuiClosed()
{
this.content.onGuiClosed();
try
{
this.content.onGuiClosed();
}
catch(Exception e)
{
WorldHandler.throwError(e);
}
}
@Override

View File

@@ -4,7 +4,7 @@ import java.util.HashMap;
import java.util.Map;
import exopandora.worldhandler.Main;
import exopandora.worldhandler.gui.button.persistence.ButtonValues;
import exopandora.worldhandler.gui.button.persistence.ButtonValue;
import exopandora.worldhandler.gui.content.impl.ContentAdvancements;
import exopandora.worldhandler.gui.content.impl.ContentButcher;
import exopandora.worldhandler.gui.content.impl.ContentChangeWorld;
@@ -91,13 +91,13 @@ public abstract class Content implements IContent
REGISTRY.register(id, textualID, content);
}
private Map<Object, ButtonValues> persistence;
private Map<Object, ButtonValue> persistence;
public <T> ButtonValues<T> getPersistence(Object id)
public <T> ButtonValue<T> getPersistence(Object id)
{
if(this.persistence == null)
{
this.persistence = new HashMap<Object, ButtonValues>();
this.persistence = new HashMap<Object, ButtonValue>();
}
if(this.persistence.containsKey(id))
@@ -105,7 +105,7 @@ public abstract class Content implements IContent
return this.persistence.get(id);
}
ButtonValues<T> values = new ButtonValues<T>();
ButtonValue<T> values = new ButtonValue<T>();
this.persistence.put(id, values);

View File

@@ -29,7 +29,7 @@ public interface IContent
}
default void actionPerformed(Container container, GuiButton button)
default void actionPerformed(Container container, GuiButton button) throws Exception
{
}

View File

@@ -8,7 +8,7 @@ import exopandora.worldhandler.gui.button.EnumTooltip;
import exopandora.worldhandler.gui.button.GuiButtonList;
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
import exopandora.worldhandler.gui.button.logic.IListButtonLogic;
import exopandora.worldhandler.gui.button.persistence.ButtonValues;
import exopandora.worldhandler.gui.button.persistence.ButtonValue;
import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.gui.content.Content;
import exopandora.worldhandler.gui.content.element.Element;
@@ -59,7 +59,7 @@ public class ElementClickList extends Element
container.add(this.button = new GuiButtonList(this.getButtonId(), this.x, this.y, 114, 20, EnumTooltip.TOP_RIGHT, this.content, new IListButtonLogic<Node>()
{
@Override
public void actionPerformed(Container container, GuiButton button, ButtonValues<Node> values)
public void actionPerformed(Container container, GuiButton button, ButtonValue<Node> values)
{
content.getPersistence(logic.getId() + (depth + 1)).setIndex(0);
container.initButtons();
@@ -78,13 +78,13 @@ public class ElementClickList extends Element
}
@Override
public String getDisplayString(ButtonValues<Node> values)
public String getDisplayString(ButtonValue<Node> values)
{
return logic.translate(getKeys());
}
@Override
public String getTooltipString(ButtonValues<Node> values)
public String getTooltipString(ButtonValue<Node> values)
{
if(values != null && values.getObject() != null)
{
@@ -118,7 +118,7 @@ public class ElementClickList extends Element
}
@Nullable
private ButtonValues<Node> getValues()
private ButtonValue<Node> getValues()
{
if(this.button != null)
{

View File

@@ -7,7 +7,7 @@ import exopandora.worldhandler.gui.button.GuiButtonList;
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
import exopandora.worldhandler.gui.button.logic.ColorListButtonLogic;
import exopandora.worldhandler.gui.button.persistence.ButtonValues;
import exopandora.worldhandler.gui.button.persistence.ButtonValue;
import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.gui.content.Content;
import exopandora.worldhandler.gui.content.element.Element;
@@ -59,7 +59,7 @@ public class ElementColorMenu extends Element
container.add(this.colorList = new GuiButtonList(this.ids[0], this.x + 118, this.y + 24, 114, 20, this.content, new ColorListButtonLogic()
{
@Override
public void actionPerformed(Container container, GuiButton button, ButtonValues<Integer> values)
public void actionPerformed(Container container, GuiButton button, ButtonValue<Integer> values)
{
string.setColor(values.getIndex());
}

View File

@@ -5,7 +5,7 @@ import java.util.List;
import exopandora.worldhandler.config.ConfigSkin;
import exopandora.worldhandler.format.TextFormatting;
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
import exopandora.worldhandler.gui.button.persistence.ButtonValues;
import exopandora.worldhandler.gui.button.persistence.ButtonValue;
import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.gui.content.Content;
import exopandora.worldhandler.gui.content.element.Element;
@@ -25,7 +25,7 @@ public class ElementPageList<T, K> extends Element
private final int width;
private final int height;
private final int[] ids;
private final ButtonValues<Integer> values;
private final ButtonValue<Integer> values;
public ElementPageList(int x, int y, List<T> list, K initial, int width, int height, int length, Content content, int[] ids, ILogicPageList<T, K> logic)
{

View File

@@ -17,7 +17,7 @@ import exopandora.worldhandler.gui.button.EnumTooltip;
import exopandora.worldhandler.gui.button.GuiButtonList;
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
import exopandora.worldhandler.gui.button.logic.IListButtonLogic;
import exopandora.worldhandler.gui.button.persistence.ButtonValues;
import exopandora.worldhandler.gui.button.persistence.ButtonValue;
import exopandora.worldhandler.gui.category.Categories;
import exopandora.worldhandler.gui.category.Category;
import exopandora.worldhandler.gui.container.Container;
@@ -109,7 +109,7 @@ public class ContentAdvancements extends Content
private final EnumMode[] values = Arrays.stream(EnumMode.values()).filter(mode -> !mode.equals(EnumMode.EVERYTHING)).toArray(EnumMode[]::new);
@Override
public void actionPerformed(Container container, GuiButton button, ButtonValues<EnumMode> values)
public void actionPerformed(Container container, GuiButton button, ButtonValue<EnumMode> values)
{
builderAdvancement.setMode(values.getObject());
}
@@ -127,7 +127,7 @@ public class ContentAdvancements extends Content
}
@Override
public String getDisplayString(ButtonValues<EnumMode> values)
public String getDisplayString(ButtonValue<EnumMode> values)
{
return I18n.format("gui.worldhandler.advancements." + values.getObject().toString());
}
@@ -145,7 +145,7 @@ public class ContentAdvancements extends Content
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
switch(button.id)
{

View File

@@ -54,7 +54,7 @@ public class ContentButcher extends ContentChild
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
switch(button.id)
{

View File

@@ -30,7 +30,7 @@ public class ContentChangeWorld extends ContentChild
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
switch(button.id)
{

View File

@@ -43,7 +43,7 @@ public class ContentContainers extends Content
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
switch(button.id)
{

View File

@@ -72,7 +72,7 @@ public class ContentContinue extends ContentChild
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
switch(button.id)
{

View File

@@ -257,7 +257,7 @@ public class ContentCustomItem extends Content
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
switch(button.id)
{

View File

@@ -14,7 +14,7 @@ import exopandora.worldhandler.gui.button.GuiButtonList;
import exopandora.worldhandler.gui.button.GuiButtonWorldHandler;
import exopandora.worldhandler.gui.button.GuiTextFieldTooltip;
import exopandora.worldhandler.gui.button.logic.IListButtonLogic;
import exopandora.worldhandler.gui.button.persistence.ButtonValues;
import exopandora.worldhandler.gui.button.persistence.ButtonValue;
import exopandora.worldhandler.gui.category.Categories;
import exopandora.worldhandler.gui.category.Category;
import exopandora.worldhandler.gui.container.Container;
@@ -178,7 +178,7 @@ public class ContentEditBlocks extends Content
container.add(this.cloneButton = new GuiButtonList(9, x + 118, y, 114, 20, EnumTooltip.TOP_RIGHT, this, new IListButtonLogic<EnumMask>()
{
@Override
public void actionPerformed(Container container, GuiButton button, ButtonValues<EnumMask> values)
public void actionPerformed(Container container, GuiButton button, ButtonValue<EnumMask> values)
{
builderClone.setMask(values.getObject());
}
@@ -196,7 +196,7 @@ public class ContentEditBlocks extends Content
}
@Override
public String getDisplayString(ButtonValues<EnumMask> values)
public String getDisplayString(ButtonValue<EnumMask> values)
{
return I18n.format("gui.worldhandler.edit_blocks.clone.mode." + values.getObject().toString());
}
@@ -216,7 +216,7 @@ public class ContentEditBlocks extends Content
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
switch(button.id)
{

View File

@@ -98,7 +98,7 @@ public class ContentEnchantment extends Content
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
switch(button.id)
{

View File

@@ -72,7 +72,7 @@ public class ContentExperience extends Content
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
switch(button.id)
{

View File

@@ -127,7 +127,7 @@ public class ContentGamerules extends Content
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
switch(button.id)
{

View File

@@ -59,7 +59,7 @@ public class ContentMain extends Content
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
switch(button.id)
{

View File

@@ -180,7 +180,7 @@ public class ContentMultiplayer extends Content
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
switch(button.id)
{

View File

@@ -99,7 +99,7 @@ public class ContentNoteEditor extends Content
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
switch(button.id)
{

View File

@@ -121,7 +121,7 @@ public class ContentPlayer extends Content
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
switch(button.id)
{

View File

@@ -186,7 +186,7 @@ public class ContentPotions extends ContentChild
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
Potion potion = this.builderPotion.getEffectAsPotion();

View File

@@ -109,7 +109,7 @@ public class ContentRecipes extends Content
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
switch(button.id)
{

View File

@@ -199,7 +199,7 @@ public class ContentScoreboardObjectives extends ContentScoreboard
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
switch(button.id)
{

View File

@@ -144,7 +144,7 @@ public class ContentScoreboardPlayers extends ContentScoreboard
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
switch(button.id)
{

View File

@@ -148,7 +148,7 @@ public class ContentScoreboardTeams extends ContentScoreboard
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
switch(button.id)
{

View File

@@ -132,7 +132,7 @@ public class ContentSignEditor extends Content
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
switch(button.id)
{

View File

@@ -365,7 +365,7 @@ public class ContentSummon extends Content
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
switch(button.id)
{

View File

@@ -108,7 +108,7 @@ public class ContentWorldInfo extends Content
}
@Override
public void actionPerformed(Container container, GuiButton button)
public void actionPerformed(Container container, GuiButton button) throws Exception
{
switch(button.id)
{