Skip to content

Commit

Permalink
chore: Renamed KeyWithCType to CTypeKey
Browse files Browse the repository at this point in the history
  • Loading branch information
phinner committed May 29, 2024
1 parent 83f3425 commit 5afb8bf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.xpdustry.distributor.api.command.cloud.parser.PlayerParser;
import com.xpdustry.distributor.api.command.cloud.parser.TeamParser;
import com.xpdustry.distributor.api.command.cloud.specifier.AllTeams;
import com.xpdustry.distributor.api.key.KeyWithCType;
import com.xpdustry.distributor.api.key.CTypeKey;
import com.xpdustry.distributor.api.plugin.MindustryPlugin;
import com.xpdustry.distributor.api.plugin.PluginAware;
import com.xpdustry.distributor.api.translation.BundleTranslationSource;
Expand Down Expand Up @@ -102,7 +102,7 @@ public MindustryCommandManager(

this.parserRegistry().registerParser(PlayerParser.playerParser());
this.parserRegistry().registerParser(TeamParser.teamParser());
KeyWithCType.ALL.forEach(
CTypeKey.ALL.forEach(
contentType -> this.parserRegistry().registerParser(ContentParser.contentParser(contentType)));

this.parserRegistry()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package com.xpdustry.distributor.api.command.cloud.parser;

import com.xpdustry.distributor.api.command.cloud.MindustryCaptionKeys;
import com.xpdustry.distributor.api.key.KeyWithCType;
import com.xpdustry.distributor.api.key.CTypeKey;
import java.util.Locale;
import mindustry.Vars;
import mindustry.ctype.MappableContent;
Expand All @@ -41,21 +41,20 @@
*/
public final class ContentParser<C, T extends MappableContent> implements ArgumentParser<C, T> {

public static <C, T extends MappableContent> ParserDescriptor<C, T> contentParser(
final KeyWithCType<T> contentType) {
public static <C, T extends MappableContent> ParserDescriptor<C, T> contentParser(final CTypeKey<T> contentType) {
return ParserDescriptor.of(
new ContentParser<>(contentType),
contentType.getKey().getToken().getRawType());
}

public static <C, T extends MappableContent> CommandComponent.Builder<C, T> contentComponent(
final KeyWithCType<T> contentType) {
final CTypeKey<T> contentType) {
return CommandComponent.<C, T>builder().parser(contentParser(contentType));
}

private final KeyWithCType<T> contentType;
private final CTypeKey<T> contentType;

public ContentParser(final KeyWithCType<T> contentType) {
public ContentParser(final CTypeKey<T> contentType) {
this.contentType = contentType;
}

Expand All @@ -75,7 +74,7 @@ public ArgumentParseResult<T> parse(final CommandContext<C> ctx, final CommandIn
public static final class ContentParseException extends ParserException {

private final String input;
private final KeyWithCType<?> contentType;
private final CTypeKey<?> contentType;

/**
* Creates a new {@link ContentParseException}.
Expand All @@ -84,8 +83,7 @@ public static final class ContentParseException extends ParserException {
* @param ctx the command context
* @param contentType the content type
*/
public ContentParseException(
final CommandContext<?> ctx, final String input, final KeyWithCType<?> contentType) {
public ContentParseException(final CommandContext<?> ctx, final String input, final CTypeKey<?> contentType) {
super(
ContentParser.class,
ctx,
Expand All @@ -100,7 +98,7 @@ public String getInput() {
return input;
}

public KeyWithCType<?> getContentType() {
public CTypeKey<?> getContentType() {
return contentType;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,28 @@
*/
@DistributorDataClass
@Value.Immutable
public interface KeyWithCType<T extends MappableContent> {
public interface CTypeKey<T extends MappableContent> {

KeyWithCType<Block> BLOCK =
KeyWithCTypeImpl.of(Key.of(Key.MINDUSTRY_NAMESPACE, "block", Block.class), ContentType.block);
CTypeKey<Block> BLOCK = CTypeKeyImpl.of(Key.of(Key.MINDUSTRY_NAMESPACE, "block", Block.class), ContentType.block);

KeyWithCType<UnitType> UNIT =
KeyWithCTypeImpl.of(Key.of(Key.MINDUSTRY_NAMESPACE, "unit", UnitType.class), ContentType.unit);
CTypeKey<UnitType> UNIT =
CTypeKeyImpl.of(Key.of(Key.MINDUSTRY_NAMESPACE, "unit", UnitType.class), ContentType.unit);

KeyWithCType<Item> ITEM =
KeyWithCTypeImpl.of(Key.of(Key.MINDUSTRY_NAMESPACE, "item", Item.class), ContentType.item);
CTypeKey<Item> ITEM = CTypeKeyImpl.of(Key.of(Key.MINDUSTRY_NAMESPACE, "item", Item.class), ContentType.item);

KeyWithCType<Liquid> LIQUID =
KeyWithCTypeImpl.of(Key.of(Key.MINDUSTRY_NAMESPACE, "liquid", Liquid.class), ContentType.liquid);
CTypeKey<Liquid> LIQUID =
CTypeKeyImpl.of(Key.of(Key.MINDUSTRY_NAMESPACE, "liquid", Liquid.class), ContentType.liquid);

KeyWithCType<Weather> WEATHER =
KeyWithCTypeImpl.of(Key.of(Key.MINDUSTRY_NAMESPACE, "weather", Weather.class), ContentType.weather);
CTypeKey<Weather> WEATHER =
CTypeKeyImpl.of(Key.of(Key.MINDUSTRY_NAMESPACE, "weather", Weather.class), ContentType.weather);

KeyWithCType<StatusEffect> STATUS =
KeyWithCTypeImpl.of(Key.of(Key.MINDUSTRY_NAMESPACE, "status", StatusEffect.class), ContentType.status);
CTypeKey<StatusEffect> STATUS =
CTypeKeyImpl.of(Key.of(Key.MINDUSTRY_NAMESPACE, "status", StatusEffect.class), ContentType.status);

KeyWithCType<Planet> PLANET =
KeyWithCTypeImpl.of(Key.of(Key.MINDUSTRY_NAMESPACE, "planet", Planet.class), ContentType.planet);
CTypeKey<Planet> PLANET =
CTypeKeyImpl.of(Key.of(Key.MINDUSTRY_NAMESPACE, "planet", Planet.class), ContentType.planet);

List<KeyWithCType<?>> ALL = List.of(BLOCK, UNIT, ITEM, LIQUID, WEATHER, STATUS, PLANET);
List<CTypeKey<?>> ALL = List.of(BLOCK, UNIT, ITEM, LIQUID, WEATHER, STATUS, PLANET);

Key<T> getKey();

Expand Down

0 comments on commit 5afb8bf

Please sign in to comment.