Skip to content

Commit

Permalink
mirrored inner classes
Browse files Browse the repository at this point in the history
Removing inner classes was originally intended to fix Java 7 support, but is unnecessary now.

Ignored:
https://sourceforge.net/p/minecraftforge/tickets/14

Co-authored-by: Space Toad <spacetoadcraft@gmail.com>
  • Loading branch information
halotroop2288 and SpaceToad committed Aug 19, 2024
1 parent 92adf96 commit fb15b18
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,31 @@
* @since 1.0.0
*/
public class Configuration {
/**
* No specific category.
*
* @since 1.0.1
* @deprecated use {@link PropertyKind#GENERAL} instead
*/
@Deprecated
public static final int GENERAL_PROPERTY = PropertyKind.GENERAL.ordinal();
/**
* The Block category.
*
* @since 1.0.1
* @deprecated use {@link PropertyKind#GENERAL} instead
*/
@Deprecated
public static final int BLOCK_PROPERTY = PropertyKind.BLOCK.ordinal();
/**
* The Item category.
*
* @since 1.0.1
* @deprecated use {@link PropertyKind#GENERAL} instead
*/
@Deprecated
public static final int ITEM_PROPERTY = PropertyKind.ITEM.ordinal();

private boolean[] configBlocks = null;

private final @NotNull File file;
Expand Down Expand Up @@ -96,6 +121,23 @@ public Configuration(@NotNull File file) {
throw new RuntimeException("No more block ids available for " + key);
}

/**
* The same as {@link #getOrCreateProperty(String, PropertyKind, String)}
* but for {@link Integer#TYPE int} properties rather than {@link String} properties.
*
* @param key the key for which to get or create a property
* @param kind the category to look for the property in
* @param defaultValue the value to use if the property doesn't already exist
* @return the property associated with the given key, or null if the property couldn't be created.
* @author Space Toad
* @see #getOrCreateIntProperty(String, PropertyKind, int)
* @since 1.0.1
* @deprecated use {@link #getOrCreateIntProperty(String, PropertyKind, int)} instead
*/
public @Nullable Property getOrCreateIntProperty(@NotNull String key, int kind, int defaultValue) {
return getOrCreateIntProperty(key, PropertyKind.values()[kind], defaultValue);
}

/**
* The same as {@link #getOrCreateProperty(String, PropertyKind, String)}
* but for {@link Integer#TYPE int} properties rather than {@link String} properties.
Expand Down Expand Up @@ -154,20 +196,41 @@ public Configuration(@NotNull File file) {
* @return the property associated with the given key, or null if the property couldn't be created.
* @author Space Toad
* @since 1.0.0
* @deprecated use {@link #getOrCreateProperty(String, PropertyKind, String)} instead
*/
public @Nullable Property getOrCreateProperty(@NotNull String key, @NotNull PropertyKind kind, @Nullable String defaultValue) {
public @Nullable Property getOrCreateProperty(@NotNull String key, int kind, @Nullable String defaultValue) {
return getOrCreateProperty(key, PropertyKind.values()[kind], defaultValue);
}

/**
* Gets or creates a property.<br>
* If the property key is already in the configuration, then it will be used.
* Otherwise, {@code defaultValue} will be used.
*
* @param key the key for which to get or create a property
* @param kind the category to look for the property in
* @param defaultValue the value to use if the property doesn't already exist
* @return the property associated with the given key, or null if the property couldn't be created.
* @author Space Toad
* @since 1.0.0
*/
public @Nullable Property getOrCreateProperty(@NotNull String key, @Nullable PropertyKind kind, @Nullable String defaultValue) {
TreeMap<String, Property> source = null;

switch (kind) {
case GENERAL:
source = generalProperties;
break;
case BLOCK:
source = blockProperties;
break;
case ITEM:
source = itemProperties;
break;
if (kind == null) {
source = generalProperties;
} else {
switch (kind) {
case GENERAL:
source = generalProperties;
break;
case BLOCK:
source = blockProperties;
break;
case ITEM:
source = itemProperties;
break;
}
}

if (source.containsKey(key)) {
Expand Down Expand Up @@ -345,19 +408,23 @@ private void writeProperties(BufferedWriter buffer, Collection<Property> props)
public static class Property {
/**
* The name of the configuration property.
* @since 1.0.0
*/
public String name;
/**
* The value associated with the configuration property.
* @since 1.0.0
*/
public String value;
/**
* The comment that describes the configuration property to the user.
* @since 1.0.0
*/
public String comment;

/**
* Default constructor.
* @since 1.0.0
*/
public Property() {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* This software is provided under the terms of the Minecraft Forge Public License v1.1.
*/
package net.minecraft.src.forge;

/**
* @author Space Toad
* @since 1.0.1
* @deprecated use {@link Configuration.Property} instead.
*/
@Deprecated
public class Property extends Configuration.Property {
/**
* Default constructor.
* @since 1.0.1
*/
public Property() {
}
}

0 comments on commit fb15b18

Please sign in to comment.