Skip to content

Commit

Permalink
Do not use plexus utils
Browse files Browse the repository at this point in the history
This dependency is not available on MC servers
  • Loading branch information
rubensworks committed Dec 27, 2023
1 parent 2f60dcc commit 76a1fc3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import org.codehaus.plexus.util.StringUtils;
import org.cyclops.integrateddynamics.Reference;
import org.cyclops.integrateddynamics.api.evaluate.EvaluationException;
import org.cyclops.integrateddynamics.api.evaluate.variable.IValue;
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueCastRegistry;
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueType;
import org.cyclops.integrateddynamics.api.logicprogrammer.IConfigRenderPattern;
import org.cyclops.integrateddynamics.core.helper.Helpers;
import org.cyclops.integrateddynamics.core.helper.L10NValues;

import java.util.List;
Expand All @@ -24,7 +24,7 @@ public class CastOperator<T1 extends IValueType<V1>, T2 extends IValueType<V2>,
private final IValueCastRegistry.IMapping<T1, T2, V1, V2> mapping;

public CastOperator(final T1 from, final T2 to, final IValueCastRegistry.IMapping<T1, T2, V1, V2> mapping) {
super("()", from.getTranslationKey() + "$" + to.getTranslationKey(), from.getTypeName() + "To" + StringUtils.capitalise(to.getTypeName()), null, false, constructInputVariables(1, from), to, new IFunction() {
super("()", from.getTranslationKey() + "$" + to.getTranslationKey(), from.getTypeName() + "To" + Helpers.capitalizeString(to.getTypeName()), null, false, constructInputVariables(1, from), to, new IFunction() {
@Override
public IValue evaluate(SafeVariablesGetter variables) throws EvaluationException {
IValue value = variables.getValue(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.GsonHelper;
import org.codehaus.plexus.util.StringUtils;
import org.cyclops.cyclopscore.helper.MinecraftHelpers;
import org.cyclops.integrateddynamics.IntegratedDynamics;
import org.cyclops.integrateddynamics.Reference;
Expand All @@ -30,6 +29,7 @@
import org.cyclops.integrateddynamics.api.item.IOperatorVariableFacade;
import org.cyclops.integrateddynamics.api.item.IVariableFacadeHandlerRegistry;
import org.cyclops.integrateddynamics.core.evaluate.expression.LazyExpression;
import org.cyclops.integrateddynamics.core.helper.Helpers;
import org.cyclops.integrateddynamics.core.helper.L10NValues;
import org.cyclops.integrateddynamics.core.item.OperatorVariableFacade;

Expand Down Expand Up @@ -85,7 +85,7 @@ public <O extends IOperator> O register(O operator) {
operator.getGlobalInteractNamePrefix() :
(operator.getInputTypes().length > 0 ? operator.getInputTypes()[0].getTypeName() : null);
String globalInteractName = globalInteractNamePrefix != null ?
globalInteractNamePrefix + StringUtils.capitalise(operator.getInteractName()) :
globalInteractNamePrefix + Helpers.capitalizeString(operator.getInteractName()) :
operator.getInteractName();
if (globalInteractOperators.containsKey(globalInteractName)) {
throw new IllegalStateException("Detected registration of an operator with non-unique global interact name: " + operator.getUniqueName().toString() + ", " + globalInteractOperators.get(globalInteractName).getUniqueName().toString());
Expand All @@ -99,7 +99,7 @@ public <O extends IOperator> O register(O operator) {
scopedInteractOperators.put(operator.getInputTypes()[0], scopedIteracts);
}
String scopedInteractName = operator.shouldAlsoPrefixLocalScope() ?
operator.getGlobalInteractNamePrefix() + StringUtils.capitalise(operator.getInteractName()) :
operator.getGlobalInteractNamePrefix() + Helpers.capitalizeString(operator.getInteractName()) :
operator.getInteractName();
if (scopedIteracts.containsKey(scopedInteractName)) {
throw new IllegalStateException("Detected registration of an operator with non-unique scoped interact name: " + operator.getUniqueName().toString() + ", " + scopedIteracts.get(scopedInteractName).getUniqueName().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import org.codehaus.plexus.util.StringUtils;
import org.cyclops.integrateddynamics.api.evaluate.variable.IValue;
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueType;
import org.cyclops.integrateddynamics.api.logicprogrammer.IConfigRenderPattern;
import org.cyclops.integrateddynamics.core.evaluate.variable.ValueTypes;
import org.cyclops.integrateddynamics.core.helper.Helpers;

import java.util.List;

Expand All @@ -21,7 +21,7 @@ public class ParseOperator<T2 extends IValueType<V2>, V2 extends IValue> extends
public ParseOperator(final T2 to, IFunction operator) {
super("parse_" + to.getTypeName(),
"parse_" + to.getTranslationKey(),
"parseAs" + StringUtils.capitalise(to.getTypeName()),
"parseAs" + Helpers.capitalizeString(to.getTypeName()),
null,
false,
constructInputVariables(1, ValueTypes.STRING),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,21 @@ public static void addInterfaceRetriever(IInterfaceRetriever interfaceRetriever)
INTERFACE_RETRIEVERS.add(interfaceRetriever);
}

/**
* Return a string with the first character capitalized.
* @param value A string.
* @return A capitalized string.
*/
public static String capitalizeString(String value) {
if (value == null) {
return null;
} else if (value.length() == 0) {
return "";
} else {
return Character.toTitleCase(value.charAt(0)) + value.substring(1);
}
}

public static interface IInterfaceRetriever {

/**
Expand Down

0 comments on commit 76a1fc3

Please sign in to comment.