Skip to content

Commit

Permalink
improve javadoc slightly
Browse files Browse the repository at this point in the history
clarify existing check at set
use simple name instead of class string
  • Loading branch information
ghzdude committed Jan 1, 2025
1 parent 2a98aa5 commit b03d1b7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package gregtech.api.metatileentity.multiblock;

import gregtech.api.util.GTLog;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -100,7 +102,8 @@ protected boolean canAdd(Object o) {
public void add(int index, Object element) {
if (!key.checkType(element))
throw new IllegalArgumentException(
String.format("element's class \"%s\" is not of type \"%s\"", element.getClass(),
String.format("element \"%s\" does not extend/implement \"%s\"",
element.getClass().getSimpleName(),
this.key.getType()));
if (!instances.contains(element))
instances.add(index, element);
Expand All @@ -117,10 +120,16 @@ public void add(int index, Object element) {
public Object set(int index, Object element) {
if (!key.checkType(element))
throw new IllegalArgumentException(
String.format("element's class \"%s\" is not of type \"%s\"", element.getClass(),
String.format("element \"%s\" does not extend/implement \"%s\"",
element.getClass().getSimpleName(),
this.key.getType()));
if (instances.contains(element))

int existing = instances.indexOf(element);
if (existing != -1) {
GTLog.logger.warn("attempted to set \"{}\" at index {} when we already have it at {}",
element.getClass().getSimpleName(), index, existing);
return null;
}

return instances.set(index, element);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public interface IMultiblockAbilityPart<T> extends IMultiblockPart {
/**
* Register abilities to the multiblock here
* <br />
* Check {@link AbilityInstances#isKey(MultiblockAbility) AbiliteInstances.isKey()} if you override {@link IMultiblockAbilityPart#getAbilities()}
* Check {@link AbilityInstances#isKey(MultiblockAbility) AbiliteInstances.isKey()} if you override
* {@link IMultiblockAbilityPart#getAbilities()}
*
* @param abilityInstances list to register abilities to
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public boolean checkType(Object o) {
}

public String getType() {
return this.clazz.toString();
return this.clazz.getSimpleName();
}

public @Nullable T checkAndCast(Object o) {
Expand Down

0 comments on commit b03d1b7

Please sign in to comment.