Refactoring and fixes
This commit is contained in:
@@ -100,7 +100,7 @@ public class WorldHandler
|
||||
ConfigSliders.load(CONFIG);
|
||||
ConfigButcher.load(CONFIG);
|
||||
|
||||
bar.step("Initialising User Interface");
|
||||
bar.step("Initializing User Interface");
|
||||
|
||||
Content.registerContents();
|
||||
Category.registerCategories();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -232,20 +231,34 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
|
||||
{
|
||||
if(syntax != null)
|
||||
{
|
||||
this.command = syntax.getSyntaxEntries().stream().map(entry -> new AbstractMap.SimpleEntry<SyntaxEntry, String>(entry, entry.toString())).collect(Collectors.toList());
|
||||
this.command = syntax.getSyntaxEntries().stream().map(entry -> new SimpleEntry<SyntaxEntry, String>(entry, entry.toString())).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toCommand()
|
||||
{
|
||||
return "/" + this.getCommandName() + " " + String.join(" ", this.command.stream().map(entry -> this.isDefaultEntry(entry) ? entry.getKey().toString() : entry.getValue()).collect(Collectors.toList()));
|
||||
CommandString command = new CommandString(this.getCommandName());
|
||||
|
||||
for(Entry<SyntaxEntry, String> entry : this.command)
|
||||
{
|
||||
if(this.isDefaultEntry(entry))
|
||||
{
|
||||
command.append(entry.getKey().toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
command.append(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return command.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toActualCommand()
|
||||
{
|
||||
List<String> command = new ArrayList<String>();
|
||||
CommandString command = new CommandString(this.getCommandName());
|
||||
|
||||
for(Entry<SyntaxEntry, String> entry : this.command)
|
||||
{
|
||||
@@ -254,9 +267,9 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
|
||||
break;
|
||||
}
|
||||
|
||||
command.add(entry.getValue());
|
||||
command.append(entry.getValue());
|
||||
}
|
||||
|
||||
return "/" + this.getCommandName() + " " + String.join(" ", command);
|
||||
return command.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class CommandString
|
||||
{
|
||||
private final StringBuilder command = new StringBuilder("/");
|
||||
|
||||
public CommandString(String name)
|
||||
{
|
||||
this.command.append(name);
|
||||
}
|
||||
|
||||
public CommandString(String name, String... arguments)
|
||||
{
|
||||
this(name);
|
||||
this.append(arguments);
|
||||
}
|
||||
|
||||
public void append(String argument)
|
||||
{
|
||||
if(argument != null && !argument.isEmpty())
|
||||
{
|
||||
this.command.append(" " + argument);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.command.append(" " + ChatFormatting.RED + "[error]" + ChatFormatting.RESET);
|
||||
}
|
||||
}
|
||||
|
||||
public void append(String... arguments)
|
||||
{
|
||||
if(arguments != null)
|
||||
{
|
||||
for(String argument : arguments)
|
||||
{
|
||||
this.append(argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.command.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
@@ -28,7 +30,8 @@ public class BuilderAdvancement extends CommandBuilder
|
||||
{
|
||||
this.setNode(0, action != null ? action.toString() : null);
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public EnumActionType getActionType()
|
||||
{
|
||||
return EnumHelper.valueOf(EnumActionType.class, this.getNodeAsString(1));
|
||||
@@ -38,7 +41,8 @@ public class BuilderAdvancement extends CommandBuilder
|
||||
{
|
||||
this.setNode(1, player);
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
@@ -48,7 +52,8 @@ public class BuilderAdvancement extends CommandBuilder
|
||||
{
|
||||
this.setNode(2, mode != null ? mode.toString() : null);
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public EnumMode getMode()
|
||||
{
|
||||
return EnumHelper.valueOf(EnumMode.class, this.getNodeAsString(2));
|
||||
@@ -58,7 +63,8 @@ public class BuilderAdvancement extends CommandBuilder
|
||||
{
|
||||
this.setNode(3, advancement);
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public ResourceLocation getAdvancement()
|
||||
{
|
||||
return this.getNodeAsResourceLocation(3);
|
||||
@@ -92,7 +98,8 @@ public class BuilderAdvancement extends CommandBuilder
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static enum EnumActionType
|
||||
{
|
||||
GRANT,
|
||||
@@ -105,6 +112,7 @@ public class BuilderAdvancement extends CommandBuilder
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static enum EnumMode
|
||||
{
|
||||
ONLY,
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.TargetSelector;
|
||||
@@ -30,7 +33,8 @@ public class BuilderButcher extends CommandBuilder
|
||||
this.targetSelector.set("r", radius);
|
||||
this.setNode(0, this.targetSelector);
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
public int getRadius()
|
||||
{
|
||||
return this.targetSelector.<Integer>get("r");
|
||||
@@ -42,6 +46,7 @@ public class BuilderButcher extends CommandBuilder
|
||||
this.setNode(0, this.targetSelector);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ResourceLocation getEntity()
|
||||
{
|
||||
return this.targetSelector.<ResourceLocation>get("type");
|
||||
|
||||
@@ -129,6 +129,7 @@ public class BuilderClone extends BuilderDoubleBlockPos
|
||||
return syntax;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static enum EnumMask
|
||||
{
|
||||
REPLACE,
|
||||
|
||||
@@ -25,12 +25,9 @@ public class BuilderCustomItem extends BuilderGive
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
public BuilderCustomItem(String username, ResourceLocation item)
|
||||
public BuilderCustomItem(String player, ResourceLocation item)
|
||||
{
|
||||
this.setPlayer(username);
|
||||
this.setItem(item);
|
||||
this.setAmount(1);
|
||||
this.setMetadata(0);
|
||||
super(player, item);
|
||||
this.attribute = this.registerNBTComponent(new ComponentAttributeItem(attribute -> attribute.getApplyable().equals(Applyable.BOTH) || attribute.getApplyable().equals(Applyable.PLAYER)));
|
||||
this.display = this.registerNBTComponent(new ComponentDisplay());
|
||||
this.enchantment = this.registerNBTComponent(new ComponentEnchantment());
|
||||
|
||||
@@ -3,6 +3,8 @@ package exopandora.worldhandler.builder.impl;
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class BuilderDifficulty extends CommandBuilder
|
||||
{
|
||||
@@ -37,6 +39,7 @@ public class BuilderDifficulty extends CommandBuilder
|
||||
return syntax;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static enum EnumDifficulty
|
||||
{
|
||||
PEACEFUL,
|
||||
|
||||
@@ -148,6 +148,7 @@ public class BuilderFill extends BuilderDoubleBlockPos
|
||||
return syntax;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static enum EnumBlockHandling
|
||||
{
|
||||
REPLACE,
|
||||
|
||||
@@ -3,6 +3,8 @@ package exopandora.worldhandler.builder.impl;
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class BuilderGamemode extends CommandBuilder
|
||||
{
|
||||
@@ -49,6 +51,7 @@ public class BuilderGamemode extends CommandBuilder
|
||||
return syntax;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static enum EnumGamemode
|
||||
{
|
||||
SURVIVAL,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandString;
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -19,7 +20,7 @@ public class BuilderGeneric implements ICommandBuilder
|
||||
@Override
|
||||
public String toCommand()
|
||||
{
|
||||
return "/" + this.command + " " + String.join(" ", this.arguments);
|
||||
return new CommandString(this.command, this.arguments).toString();
|
||||
}
|
||||
|
||||
public String toActualCommand()
|
||||
|
||||
@@ -16,6 +16,7 @@ public class BuilderGive extends CommandBuilderNBT
|
||||
{
|
||||
this.setPlayer(player);
|
||||
this.setItem(item);
|
||||
this.setAmount(1);
|
||||
this.setMetadata(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,7 @@ public class BuilderPotionItem extends BuilderGive
|
||||
|
||||
public BuilderPotionItem(ResourceLocation item, String player, ComponentPotionItem potion)
|
||||
{
|
||||
this.setItem(item);
|
||||
this.setPlayer(player);
|
||||
this.setAmount(1);
|
||||
super(player, item);
|
||||
this.potion = this.registerNBTComponent(potion);
|
||||
}
|
||||
|
||||
|
||||
@@ -204,6 +204,7 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
|
||||
return syntax;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static enum EnumTag
|
||||
{
|
||||
ADD,
|
||||
@@ -216,6 +217,7 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static enum EnumPoints
|
||||
{
|
||||
ADD,
|
||||
|
||||
@@ -238,6 +238,7 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
|
||||
return syntax;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static enum EnumMode
|
||||
{
|
||||
JOIN,
|
||||
|
||||
@@ -3,6 +3,8 @@ package exopandora.worldhandler.builder.impl;
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class BuilderTime extends CommandBuilder
|
||||
{
|
||||
@@ -49,6 +51,7 @@ public class BuilderTime extends CommandBuilder
|
||||
return syntax;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static enum EnumMode
|
||||
{
|
||||
ADD,
|
||||
|
||||
@@ -3,6 +3,8 @@ package exopandora.worldhandler.builder.impl;
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class BuilderWeather extends CommandBuilder
|
||||
{
|
||||
@@ -49,6 +51,7 @@ public class BuilderWeather extends CommandBuilder
|
||||
return syntax;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static enum EnumWeather
|
||||
{
|
||||
CLEAR,
|
||||
|
||||
@@ -76,6 +76,7 @@ public class BuilderWhitelist extends CommandBuilder
|
||||
return syntax;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static enum EnumMode
|
||||
{
|
||||
ADD,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package exopandora.worldhandler.builder.types;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -28,6 +30,7 @@ public class Level
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Level valueOf(String value)
|
||||
{
|
||||
if(value != null)
|
||||
|
||||
@@ -4,6 +4,9 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -17,7 +20,8 @@ public class TargetSelector
|
||||
{
|
||||
this.values.put(id.toLowerCase(), value);
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public <T> T get(String id)
|
||||
{
|
||||
return (T) this.values.get(id);
|
||||
@@ -28,6 +32,7 @@ public class TargetSelector
|
||||
return this.values.remove(id.toLowerCase());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static TargetSelector valueOf(String input)
|
||||
{
|
||||
if(input.matches(REGEX));
|
||||
|
||||
@@ -10,6 +10,7 @@ import exopandora.worldhandler.gui.content.Content;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -100,26 +101,57 @@ public class GuiButtonList<T> extends GuiButtonWorldHandler
|
||||
|
||||
public void actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
int max = this.logic.getMax() - 1;
|
||||
int index = this.persistence.getIndex();
|
||||
|
||||
if(this.isHoveringLeft(this.mouseX, this.mouseY))
|
||||
{
|
||||
if(this.persistence.getIndex() > 0)
|
||||
if(GuiScreen.isShiftKeyDown())
|
||||
{
|
||||
this.persistence.decrementIndex();
|
||||
if(index < 10)
|
||||
{
|
||||
this.persistence.setIndex(max - (9 - index));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.persistence.decrementIndex(10);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.persistence.setIndex(this.logic.getMax() - 1);
|
||||
if(index > 0)
|
||||
{
|
||||
this.persistence.decrementIndex();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.persistence.setIndex(max);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(this.isHoveringRight(this.mouseX, this.mouseY))
|
||||
{
|
||||
if(this.persistence.getIndex() < this.logic.getMax() - 1)
|
||||
if(GuiScreen.isShiftKeyDown())
|
||||
{
|
||||
this.persistence.incrementIndex();
|
||||
if(index > max - 10)
|
||||
{
|
||||
this.persistence.setIndex(9 - (max - index));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.persistence.incrementIndex(10);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.persistence.setIndex(0);
|
||||
if(index < max)
|
||||
{
|
||||
this.persistence.incrementIndex();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.persistence.setIndex(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class ButtonValues<T>
|
||||
this.index++;
|
||||
}
|
||||
|
||||
public void incrementIndexBy(int amount)
|
||||
public void incrementIndex(int amount)
|
||||
{
|
||||
this.index += amount;
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class ButtonValues<T>
|
||||
this.index--;
|
||||
}
|
||||
|
||||
public void decrementIndexBy(int amount)
|
||||
public void decrementIndex(int amount)
|
||||
{
|
||||
this.index -= amount;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class Category
|
||||
registerCategory(1, "entities", new Category(Contents.SUMMON, Contents.PLAYSOUND));
|
||||
registerCategory(2, "items", new Category(Contents.CUSTOM_ITEM, Contents.ENCHANTMENT));
|
||||
registerCategory(3, "blocks", new Category(Contents.EDIT_BLOCKS, Contents.SIGN_EDITOR, Contents.NOTE_EDITOR));
|
||||
registerCategory(4, "world", new Category(Contents.WORLD_INFO, Contents.GAMERULES));
|
||||
registerCategory(4, "world", new Category(Contents.WORLD_INFO, Contents.GAMERULES, Contents.RECIPES));
|
||||
registerCategory(5, "player", new Category(Contents.PLAYER, Contents.EXPERIENCE, Contents.ADVANCEMENTS));
|
||||
registerCategory(6, "scoreboard", new Category(Contents.SCOREBOARD_OBJECTIVES, Contents.SCOREBOARD_TEAMS, Contents.SCOREBOARD_PLAYERS));
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import exopandora.worldhandler.gui.content.impl.ContentNoteEditor;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentPlayer;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentPlaysound;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentPotions;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentRecipes;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentScoreboardObjectives;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentScoreboardPlayers;
|
||||
import exopandora.worldhandler.gui.content.impl.ContentScoreboardTeams;
|
||||
@@ -60,24 +61,25 @@ public abstract class Content implements IContent
|
||||
//WORLD
|
||||
registerContent(9, "world", new ContentWorldInfo());
|
||||
registerContent(10, "gamerules", new ContentGamerules());
|
||||
registerContent(11, "recipes", new ContentRecipes());
|
||||
|
||||
//PLAYER
|
||||
registerContent(11, "player", new ContentPlayer());
|
||||
registerContent(12, "experience", new ContentExperience());
|
||||
registerContent(13, "advancements", new ContentAdvancements());
|
||||
registerContent(12, "player", new ContentPlayer());
|
||||
registerContent(13, "experience", new ContentExperience());
|
||||
registerContent(14, "advancements", new ContentAdvancements());
|
||||
|
||||
//SCOREBOARD
|
||||
registerContent(14, "scoreboard_objectives", new ContentScoreboardObjectives());
|
||||
registerContent(15, "scoreboard_teams", new ContentScoreboardTeams());
|
||||
registerContent(16, "scoreboard_players", new ContentScoreboardPlayers());
|
||||
registerContent(15, "scoreboard_objectives", new ContentScoreboardObjectives());
|
||||
registerContent(16, "scoreboard_teams", new ContentScoreboardTeams());
|
||||
registerContent(17, "scoreboard_players", new ContentScoreboardPlayers());
|
||||
|
||||
//MISC
|
||||
registerContent(17, "change_world", new ContentChangeWorld());
|
||||
registerContent(18, "continue", new ContentContinue());
|
||||
registerContent(18, "change_world", new ContentChangeWorld());
|
||||
registerContent(19, "continue", new ContentContinue());
|
||||
|
||||
//NO CATEGORY
|
||||
registerContent(19, "potions", new ContentPotions());
|
||||
registerContent(20, "butcher", new ContentButcher());
|
||||
registerContent(20, "potions", new ContentPotions());
|
||||
registerContent(21, "butcher", new ContentButcher());
|
||||
}
|
||||
|
||||
private static void registerContent(int id, String textualID, Content content)
|
||||
|
||||
@@ -14,10 +14,4 @@ public abstract class Element implements IElement
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,31 +21,29 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ElementClickList extends Element
|
||||
{
|
||||
private final int buttonId;
|
||||
private final int[] buttonIds;
|
||||
private final List<Node> list;
|
||||
private final ILogicClickList logic;
|
||||
private final Content content;
|
||||
private final ElementClickList parent;
|
||||
private final int depth;
|
||||
private final int maxDepth;
|
||||
|
||||
private GuiButtonList button;
|
||||
private ElementClickList child;
|
||||
|
||||
public ElementClickList(int x, int y, List<Node> list, int buttonId, int maxDepth, Content content, ILogicClickList logic)
|
||||
public ElementClickList(int x, int y, List<Node> list, int[] buttonIds, Content content, ILogicClickList logic)
|
||||
{
|
||||
this(x, y, list, buttonId, maxDepth, content, logic, null);
|
||||
this(x, y, list, buttonIds, content, logic, null);
|
||||
}
|
||||
|
||||
private ElementClickList(int x, int y, List<Node> list, int buttonId, int maxDepth, Content content, ILogicClickList logic, ElementClickList parent)
|
||||
private ElementClickList(int x, int y, List<Node> list, int[] buttonIds, Content content, ILogicClickList logic, ElementClickList parent)
|
||||
{
|
||||
super(x, y);
|
||||
this.list = list;
|
||||
this.buttonId = buttonId;
|
||||
this.buttonIds = buttonIds;
|
||||
this.logic = logic;
|
||||
this.content = content;
|
||||
this.parent = parent;
|
||||
this.maxDepth = maxDepth;
|
||||
this.depth = this.parent != null ? this.parent.depth + 1 : 1;
|
||||
}
|
||||
|
||||
@@ -58,7 +56,7 @@ public class ElementClickList extends Element
|
||||
@Override
|
||||
public void initButtons(Container container)
|
||||
{
|
||||
container.add(this.button = new GuiButtonList(this.buttonId, this.x, this.y, 114, 20, EnumTooltip.TOP_RIGHT, this.content, new IListButtonLogic<Node>()
|
||||
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)
|
||||
@@ -108,28 +106,17 @@ public class ElementClickList extends Element
|
||||
|
||||
if(node.getEntries() != null)
|
||||
{
|
||||
this.child = new ElementClickList(this.x, this.y + 24, node.getEntries(), this.buttonId + 1, this.maxDepth, this.content, this.logic, this);
|
||||
this.child = new ElementClickList(this.x, this.y + 24, node.getEntries(), this.buttonIds, this.content, this.logic, this);
|
||||
this.child.initButtons(container);
|
||||
}
|
||||
else if(this.depth < this.maxDepth)
|
||||
else if(this.depth < this.buttonIds.length)
|
||||
{
|
||||
GuiButtonWorldHandler button = new GuiButtonWorldHandler(this.buttonId + 1, this.x, this.y + 24, 114, 20, null);
|
||||
GuiButtonWorldHandler button = new GuiButtonWorldHandler(this.getButtonId(), this.x, this.y + 24, 114, 20, null);
|
||||
button.enabled = false;
|
||||
container.add(button);
|
||||
}
|
||||
}
|
||||
|
||||
private String[] getKeys()
|
||||
{
|
||||
return this.getKeys(new String[this.depth]);
|
||||
}
|
||||
|
||||
private String[] getKeys(String[] keys)
|
||||
{
|
||||
keys[this.depth - 1] = this.getValues().getObject().getKey();
|
||||
return this.parent != null ? this.parent.getKeys(keys) : keys;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ButtonValues<Node> getValues()
|
||||
{
|
||||
@@ -144,7 +131,7 @@ public class ElementClickList extends Element
|
||||
@Override
|
||||
public boolean actionPerformed(Container container, GuiButton button)
|
||||
{
|
||||
if(button.id == this.buttonId)
|
||||
if(button.id == this.getButtonId())
|
||||
{
|
||||
this.button.actionPerformed(container, button);
|
||||
return true;
|
||||
@@ -156,4 +143,30 @@ public class ElementClickList extends Element
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private int getButtonId()
|
||||
{
|
||||
return this.buttonIds[this.depth - 1];
|
||||
}
|
||||
|
||||
private String[] getKeys()
|
||||
{
|
||||
return this.getKeys(new String[this.depth]);
|
||||
}
|
||||
|
||||
private String[] getKeys(String[] keys)
|
||||
{
|
||||
if(keys != null && this.depth <= keys.length)
|
||||
{
|
||||
keys[this.depth - 1] = this.getValues().getObject().getKey();
|
||||
}
|
||||
|
||||
return this.parent != null ? this.parent.getKeys(keys) : keys;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import exopandora.worldhandler.gui.content.element.Element;
|
||||
import exopandora.worldhandler.gui.content.element.logic.ILogicPageList;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -101,13 +102,33 @@ public class ElementPageList<T, K> extends Element
|
||||
{
|
||||
if(button.id == this.ids[0])
|
||||
{
|
||||
this.values.setObject(this.values.getObject() - 1);
|
||||
int value = this.values.getObject();
|
||||
|
||||
if(GuiScreen.isShiftKeyDown())
|
||||
{
|
||||
this.values.setObject(value - Math.min(10, value));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.values.setObject(value - 1);
|
||||
}
|
||||
|
||||
container.initGui();
|
||||
return true;
|
||||
}
|
||||
else if(button.id == this.ids[1])
|
||||
{
|
||||
this.values.setObject(this.values.getObject() + 1);
|
||||
int value = this.values.getObject();
|
||||
|
||||
if(GuiScreen.isShiftKeyDown())
|
||||
{
|
||||
this.values.setObject(value + Math.min(10, this.getTotalPages() - 1 - value));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.values.setObject(value + 1);
|
||||
}
|
||||
|
||||
container.initGui();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package exopandora.worldhandler.gui.content.impl;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
import exopandora.worldhandler.WorldHandler;
|
||||
@@ -43,7 +43,7 @@ public class ContentAdvancements extends Content
|
||||
|
||||
private GuiButtonList modeButton;
|
||||
|
||||
private final List<Advancement> advancements = StreamSupport.stream(new AdvancementManager(null).getAdvancements().spliterator(), true).filter(advancement -> advancement.getDisplay() != null).collect(Collectors.toList());
|
||||
private final List<Advancement> advancements = Lists.newArrayList(new AdvancementManager(null).getAdvancements()).parallelStream().filter(advancement -> advancement.getDisplay() != null).collect(Collectors.toList());
|
||||
|
||||
@Override
|
||||
public ICommandBuilder getCommandBuilder()
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ContentScoreboardObjectives extends ContentScoreboard
|
||||
|
||||
if(this.selectedObjective.equals("create"))
|
||||
{
|
||||
ElementClickList objectives = new ElementClickList(x + 118, y + 24, HELPER.getObjectives(), 7, 2, this, new ILogicClickList()
|
||||
ElementClickList objectives = new ElementClickList(x + 118, y + 24, HELPER.getObjectives(), new int[] {7, 8}, this, new ILogicClickList()
|
||||
{
|
||||
@Override
|
||||
public void consumeKey(String... keys)
|
||||
@@ -116,7 +116,7 @@ public class ContentScoreboardObjectives extends ContentScoreboard
|
||||
}
|
||||
else if(this.selectedObjective.equals("display") || this.selectedObjective.equals("undisplay"))
|
||||
{
|
||||
ElementClickList slots = new ElementClickList(x + 118, y + 24 + (this.selectedObjective.equals("undisplay") ? -12 : 0), HELPER.getSlots(), 9, 2, this, new ILogicClickList()
|
||||
ElementClickList slots = new ElementClickList(x + 118, y + 24 + (this.selectedObjective.equals("undisplay") ? -12 : 0), HELPER.getSlots(), new int[] {9, 10}, this, new ILogicClickList()
|
||||
{
|
||||
@Override
|
||||
public String translate(String... keys)
|
||||
|
||||
@@ -47,7 +47,7 @@ public class ContentScoreboardTeams extends ContentScoreboard
|
||||
|
||||
if(this.selectedTeam.equals("option"))
|
||||
{
|
||||
ElementClickList options = new ElementClickList(x + 118, y + 24, HELPER.getOptions(), 6, 2, this, new ILogicClickList()
|
||||
ElementClickList options = new ElementClickList(x + 118, y + 24, HELPER.getOptions(), new int[] {6, 7}, this, new ILogicClickList()
|
||||
{
|
||||
@Override
|
||||
public String translate(String... keys)
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package exopandora.worldhandler.helper;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class EnumHelper
|
||||
{
|
||||
@Nullable
|
||||
public static <T extends Enum<T>> T valueOf(Class<T> klass, String name)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user