Skip to content

Commit

Permalink
Replaced default constructors with static methods
Browse files Browse the repository at this point in the history
  • Loading branch information
fulminazzo committed Apr 13, 2024
1 parent 86367ba commit e7a399f
Showing 1 changed file with 50 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,48 +36,23 @@ public class PersistentItem extends BukkitItemImpl {
private @Nullable InteractItemAction interactAction;
private Mobility mobility;

/**
* Instantiates a new Persistent item.
*/
public PersistentItem() {
private PersistentItem() {
this((String) null);
}

/**
* Instantiates a new Persistent item.
*
* @param material the material
*/
public PersistentItem(final @NotNull Material material) {
private PersistentItem(final @NotNull Material material) {
this(material.name(), 1);
}

/**
* Instantiates a new Persistent item.
*
* @param material the material
*/
public PersistentItem(final @Nullable String material) {
private PersistentItem(final @Nullable String material) {
this(material, 1);
}

/**
* Instantiates a new Persistent item.
*
* @param material the material
* @param amount the amount
*/
public PersistentItem(final @NotNull Material material, final int amount) {
private PersistentItem(final @NotNull Material material, final int amount) {
this(material.name(), amount);
}

/**
* Instantiates a new Persistent item.
*
* @param material the material
* @param amount the amount
*/
public PersistentItem(final @Nullable String material, final int amount) {
private PersistentItem(final @Nullable String material, final int amount) {
super(material, amount);
this.deathAction = DeathAction.MAINTAIN;
this.mobility = Mobility.STATIC;
Expand Down Expand Up @@ -301,6 +276,51 @@ public PersistentItem copy() {
return null;
}

/**
* Instantiates a new Persistent item.
*/
public static PersistentItem newItem() {
return new PersistentItem();
}

/**
* Instantiates a new Persistent item.
*
* @param material the material
*/
public static PersistentItem newItem(final @NotNull Material material) {
return new PersistentItem(material);
}

/**
* Instantiates a new Persistent item.
*
* @param material the material
*/
public static PersistentItem newItem(final @Nullable String material) {
return new PersistentItem(material);
}

/**
* Instantiates a new Persistent item.
*
* @param material the material
* @param amount the amount
*/
public static PersistentItem newItem(final @NotNull Material material, final int amount) {
return new PersistentItem(material, amount);
}

/**
* Instantiates a new Persistent item.
*
* @param material the material
* @param amount the amount
*/
public static PersistentItem newItem(final @Nullable String material, final int amount) {
return new PersistentItem(material, amount);
}

/**
* Clear persistent items.
*/
Expand Down

0 comments on commit e7a399f

Please sign in to comment.