Skip to content

Commit

Permalink
Make things more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
esotericenderman committed Aug 14, 2024
1 parent 33e4764 commit e169f62
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public class PlaceCustomMultiblockCommand extends CommandAPICommand {

public PlaceCustomMultiblockCommand(TemplatePaperPlugin plugin) {
super("place");
super("place-custom-multiblock");

String customMultiblockArgumentNodeName = "custom-multiblock-id";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,30 @@
public class SpawnCustomMultientityCommand extends CommandAPICommand {

public SpawnCustomMultientityCommand(TemplatePaperPlugin plugin) {
super("spawn");
super("spawn-custom-multientity");

String customEntityArgumentNodeName = "custom-entity-id";
String customMultientityArgumentNodeName = "custom-multientity-id";

String[] customEntityIds = Stream.of(CustomMultientity.values()).map((customEntity) -> customEntity.name()).toArray(String[]::new);
String[] customMultientityIds = Stream.of(CustomMultientity.values()).map((customMultientity) -> customMultientity.name()).toArray(String[]::new);

Argument<CustomMultientity> customEntityArgument = new CustomArgument<>(new StringArgument(customEntityArgumentNodeName), (info) -> {
Argument<CustomMultientity> customMultientityArgument = new CustomArgument<>(new StringArgument(customMultientityArgumentNodeName), (info) -> {
String input = info.currentInput();

try {
return CustomMultientity.valueOf(input);
} catch (IllegalArgumentException exception) {
throw CustomArgumentException.fromAdventureComponent(plugin.getLanguageManager().getMessage(Message.UNKNOWN_CUSTOM_ENTITY, info.sender(), input));
throw CustomArgumentException.fromAdventureComponent(plugin.getLanguageManager().getMessage(Message.UNKNOWN_CUSTOM_MULTIENTITY, info.sender(), input));
}
}).includeSuggestions(ArgumentSuggestions.strings(customEntityIds));
}).includeSuggestions(ArgumentSuggestions.strings(customMultientityIds));

executesPlayer((info) -> {
CustomMultientity entity = (CustomMultientity) info.args().get(customEntityArgumentNodeName);
CustomMultientity multientity = (CustomMultientity) info.args().get(customMultientityArgumentNodeName);

plugin.getCustomMultientityManager().spawnEntity(entity, info.sender().getLocation());
plugin.getCustomMultientityManager().spawnEntity(multientity, info.sender().getLocation());
});

withPermission(CommandPermission.OP);
withArguments(customEntityArgument);
withArguments(customMultientityArgument);

register(plugin);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ public abstract class AbstractCustomMultientity<E extends Entity> implements Lis

private final CustomMultientity entityId;

protected AbstractCustomMultientity(TemplatePaperPlugin plugin, CustomMultientityManager customEntityManager, CustomMultientity entityId) {
protected AbstractCustomMultientity(TemplatePaperPlugin plugin, CustomMultientityManager customMultientityManager, CustomMultientity entityId) {
this.plugin = plugin;

this.entityId = entityId;

Bukkit.getPluginManager().registerEvents(this, plugin);

customEntityManager.addCustomEntity(entityId, this);
customMultientityManager.addCustomEntity(entityId, this);
}

protected abstract List<E> generateCustomEntity(Location spawnLocation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@

public class CustomMultientityManager {

private final Map<CustomMultientity, AbstractCustomMultientity<?>> customEntityMap = new HashMap<>();
private final Map<CustomMultientity, AbstractCustomMultientity<?>> customMultientityMap = new HashMap<>();

public CustomMultientityManager(TemplatePaperPlugin plugin) {

}

public void addCustomEntity(CustomMultientity itemId, AbstractCustomMultientity<?> customItem) {
customEntityMap.put(itemId, customItem);
public void addCustomEntity(CustomMultientity itemId, AbstractCustomMultientity<?> customMultientity) {
customMultientityMap.put(itemId, customMultientity);
}

public AbstractCustomMultientity<?> getAbstractCustomEntity(CustomMultientity itemId) {
return customEntityMap.get(itemId);
public AbstractCustomMultientity<?> getAbstractCustomEntity(CustomMultientity entityId) {
return customMultientityMap.get(entityId);
}

public <E extends Entity> List<E> spawnEntity(CustomMultientity entityId, Location location) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public enum Message {
UNKNOWN_LANGUAGE(() -> false),

UNKNOWN_CUSTOM_ITEM(() -> CustomItem.isEnabled()),
UNKNOWN_CUSTOM_ENTITY(() -> CustomMultientity.isEnabled()),
UNKNOWN_CUSTOM_MULTIENTITY(() -> CustomMultientity.isEnabled()),
UNKNOWN_CUSTOM_MULTIBLOCK(() -> CustomMultiblock.isEnabled());

private final BooleanSupplier isMessageInUseSupplier;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/languages/English (United Kingdom).yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ SET_LANGUAGE_SUCCESSFULLY: "<green>Successfully set your language to </green>{0}
UNKNOWN_LANGUAGE: "Unsupported or unknown language: '{0}'."

UNKNOWN_CUSTOM_ITEM: "Unknown custom item: '{0}'."
UNKNOWN_CUSTOM_ENTITY: "Unknown custom entity: '{0}'."
UNKNOWN_CUSTOM_MULTIENTITY: "Unknown custom multientity: '{0}'."
UNKNOWN_CUSTOM_MULTIBLOCK: "Unknown custom multiblock: '{0}'."
2 changes: 1 addition & 1 deletion src/main/resources/languages/English (United States).yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ SET_LANGUAGE_SUCCESSFULLY: "<green>Successfully set your language to </green>{0}
UNKNOWN_LANGUAGE: "Unsupported or unknown language: '{0}'."

UNKNOWN_CUSTOM_ITEM: "Unknown custom item: '{0}'."
UNKNOWN_CUSTOM_ENTITY: "Unknown custom entity: '{0}'."
UNKNOWN_CUSTOM_MULTIENTITY: "Unknown custom multientity: '{0}'."
UNKNOWN_CUSTOM_MULTIBLOCK: "Unknown custom multiblock: '{0}'."

0 comments on commit e169f62

Please sign in to comment.