Skip to content

Commit

Permalink
Simplify custom feature constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
esotericenderman committed Oct 11, 2024
1 parent acb7739 commit 1cd8f47
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataType;

import org.esoteric.minecraft.plugins.template.TemplatePaperPlugin;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.esoteric.minecraft.plugins.template.TemplatePaperPlugin;

public abstract class AbstractCustomItem implements Listener {

protected final TemplatePaperPlugin plugin;
private final TemplatePaperPlugin plugin;

private final CustomItem itemId;
private final Material material;

public AbstractCustomItem(TemplatePaperPlugin plugin, CustomItemManager customItemManager, CustomItem itemId, Material material) {
this.plugin = plugin;
public AbstractCustomItem(CustomItemManager customItemManager, CustomItem itemId, Material material) {
this.plugin = customItemManager.getPlugin();

this.itemId = itemId;
this.material = material;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@

public class CustomItemManager {

private final TemplatePaperPlugin plugin;

private final Map<CustomItem, AbstractCustomItem> customItemMap = new HashMap<>();

public TemplatePaperPlugin getPlugin() {
return plugin;
}

public CustomItemManager(TemplatePaperPlugin plugin) {
this.plugin = plugin;
}

public void addCustomItem(CustomItem itemId, AbstractCustomItem customItem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public void addMultiblocks(List<List<BlockLocation>> addedMultiblocks) {
multiblocks.addAll(addedMultiblocks);
}

public AbstractCustomMultiblock(TemplatePaperPlugin plugin, CustomMultiblockManager customMultiblockManager, CustomMultiblock multiblockId) {
this.plugin = plugin;
public AbstractCustomMultiblock(CustomMultiblockManager customMultiblockManager, CustomMultiblock multiblockId) {
this.plugin = customMultiblockManager.getPlugin();

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ public class CustomMultiblockManager {

private final Map<CustomMultiblock, AbstractCustomMultiblock> customMultiblockMap = new HashMap<>();

public TemplatePaperPlugin getPlugin() {
return plugin;
}

public CustomMultiblockManager(TemplatePaperPlugin plugin) {
this.plugin = plugin;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public abstract class AbstractCustomMultientity<E extends Entity> implements Lis

private final CustomMultientity entityId;

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

this.entityId = entityId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@

public class CustomMultientityManager {

private final TemplatePaperPlugin plugin;

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

public CustomMultientityManager(TemplatePaperPlugin plugin) {
public TemplatePaperPlugin getPlugin() {
return plugin;
}

public CustomMultientityManager(TemplatePaperPlugin plugin) {
this.plugin = plugin;
}

public void addCustomEntity(CustomMultientity itemId, AbstractCustomMultientity<?> customMultientity) {
Expand Down

0 comments on commit 1cd8f47

Please sign in to comment.