From 5604e3f380257be9dc4635399a8d6b777a9406df Mon Sep 17 00:00:00 2001 From: diesieben07 Date: Wed, 22 Jun 2016 22:40:27 -0400 Subject: [PATCH] Make ASMDataTable more useful: (#2911) - EnumHolder now has getters for it's data - enum arrays work now - nested annotations work now outside of being in arrays (cherry picked from commit f10f750) --- .../common/discovery/asm/ModAnnotation.java | 43 ++++++++++++------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/src/main/java/net/minecraftforge/fml/common/discovery/asm/ModAnnotation.java b/src/main/java/net/minecraftforge/fml/common/discovery/asm/ModAnnotation.java index 927a28cd0..ad0fc72c7 100644 --- a/src/main/java/net/minecraftforge/fml/common/discovery/asm/ModAnnotation.java +++ b/src/main/java/net/minecraftforge/fml/common/discovery/asm/ModAnnotation.java @@ -1,13 +1,20 @@ /* - * Forge Mod Loader - * Copyright (c) 2012-2013 cpw. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v2.1 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * Minecraft Forge + * Copyright (c) 2016. * - * Contributors: - * cpw - implementation + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ package net.minecraftforge.fml.common.discovery.asm; @@ -27,8 +34,8 @@ public class ModAnnotation { public class EnumHolder { - private String desc; - private String value; + private final String desc; + private final String value; public EnumHolder(String desc, String value) { @@ -36,6 +43,15 @@ public class ModAnnotation this.value = value; } + public String getDesc() + { + return desc; + } + + public String getValue() + { + return value; + } } AnnotationType type; Type asmType; @@ -100,7 +116,7 @@ public class ModAnnotation public void addEnumProperty(String key, String enumName, String value) { - values.put(key, new EnumHolder(enumName, value)); + addProperty(key, new EnumHolder(enumName, value)); } public void endArray() @@ -111,10 +127,7 @@ public class ModAnnotation public ModAnnotation addChildAnnotation(String name, String desc) { ModAnnotation child = new ModAnnotation(AnnotationType.SUBTYPE, Type.getType(desc), this); - if (arrayList != null) - { - arrayList.add(child.getValues()); - } + addProperty(name, child.getValues()); return child; } }