Skip to content

Commit

Permalink
Dont instantiate commands if feature is unused
Browse files Browse the repository at this point in the history
  • Loading branch information
esotericenderman committed Aug 12, 2024
1 parent fd0daa4 commit 3266d69
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import net.slqmy.template_paper_plugin.commands.GiveCustomItemCommand;
import net.slqmy.template_paper_plugin.commands.SetLanguageCommand;
import net.slqmy.template_paper_plugin.commands.SpawnCustomEntityCommand;
import net.slqmy.template_paper_plugin.custom_entity.CustomEntity;
import net.slqmy.template_paper_plugin.custom_entity.CustomEntityManager;
import net.slqmy.template_paper_plugin.custom_item.CustomItem;
import net.slqmy.template_paper_plugin.custom_item.CustomItemManager;
import net.slqmy.template_paper_plugin.data.player.PlayerDataManager;
import net.slqmy.template_paper_plugin.file.FileManager;
Expand Down Expand Up @@ -88,8 +90,12 @@ public void onEnable() {

new SetLanguageCommand(this);

new GiveCustomItemCommand(this);
new SpawnCustomEntityCommand(this);
if (CustomItem.values().length != 0) {
new GiveCustomItemCommand(this);
}
if (CustomEntity.values().length != 0) {
new SpawnCustomEntityCommand(this);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ public class GiveCustomItemCommand extends CommandAPICommand {
public GiveCustomItemCommand(TemplatePaperPlugin plugin) {
super("give-custom-item");

if (CustomItem.values().length == 0) {
return;
}

String customItemArgumentNodeName = "custom-item-id";

String[] customItemIds = Stream.of(CustomItem.values()).map((customItem) -> customItem.name()).toArray(String[]::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ public class SpawnCustomEntityCommand extends CommandAPICommand {
public SpawnCustomEntityCommand(TemplatePaperPlugin plugin) {
super("spawn");

if (CustomEntity.values().length == 0) {
return;
}

String customEntityArgumentNodeName = "custom-entity-id";

String[] customEntityIds = Stream.of(CustomEntity.values()).map((customEntity) -> customEntity.name()).toArray(String[]::new);
Expand Down

0 comments on commit 3266d69

Please sign in to comment.