Skip to content

Update CosmeticManager.java #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 24 additions & 121 deletions src/main/java/fr/hashtek/spigot/breakffa/cosmetics/CosmeticManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,16 @@
import java.util.function.Supplier;
import java.util.stream.Collectors;

public class CosmeticManager
{

/**
* Function used to get the cosmetic setter according to a Player's Cosmetic Manager.
*
* @param <T> Cosmetic
*/
public interface CurrentCosmeticSetter
<T extends Cosmetic<? extends AbstractCosmetic>>
{

/**
* @param manager Cosmetic Manager of the player who clicked
*/
Consumer<T> getSetter(CosmeticManager manager);
public class CosmeticManager {

public interface CurrentCosmeticSetter<T extends Cosmetic<? extends AbstractCosmetic>> {
Consumer<T> getSetter(CosmeticManager manager);
}

/**
* Function used to get the cosmetic getter according to a Player's Cosmetic Manager.
*
* @param <T> Cosmetic
*/
public interface CurrentCosmeticGetter
<T extends Cosmetic<? extends AbstractCosmetic>>
{

/**
* @param manager Cosmetic Manager of the player who clicked
*/
public interface CurrentCosmeticGetter<T extends Cosmetic<? extends AbstractCosmetic>> {
Supplier<T> getGetter(CosmeticManager manager);

}


public static final Map<String, Cosmetic<? extends AbstractCosmetic>> COSMETIC_REGISTRY =
getCosmetics().stream().collect(Collectors.toMap(Cosmetic::getRawName, cosmetic -> cosmetic));

Expand All @@ -59,23 +33,13 @@ public interface CurrentCosmeticGetter
private Cosmetic<CosmeticTypeKillSfx> currentKillSfx;
private Cosmetic<CosmeticTypeNexusSfx> currentNexusSfx;


/**
* Creates a new instance of CosmeticManager.
*/
public CosmeticManager()
{
this.ownedCosmetics = new HashSet<Cosmetic<? extends AbstractCosmetic>>();
public CosmeticManager() {
this.ownedCosmetics = new HashSet<>();
}

/**
* @return Every cosmetic that exists
*/
@SuppressWarnings("unchecked")
public static Set<Cosmetic<? extends AbstractCosmetic>> getCosmetics()
{
public static Set<Cosmetic<? extends AbstractCosmetic>> getCosmetics() {
final Class<? extends Enum<? extends CosmeticCategoryArticles<? extends AbstractCosmetic>>>[] cosmeticEnums =
new Class[] {
new Class[]{
CosmeticTypeHat.Hat.class,
CosmeticTypeKillSfx.KillSfx.class,
CosmeticTypeBlock.Block.class,
Expand All @@ -87,128 +51,67 @@ public static Set<Cosmetic<? extends AbstractCosmetic>> getCosmetics()

return Arrays.stream(cosmeticEnums)
.flatMap(enumClass -> Arrays.stream(enumClass.getEnumConstants())
.map(enumValue -> ((CosmeticCategoryArticles<? extends AbstractCosmetic>) enumValue).getCosmetic()))
.map(enumValue -> ((CosmeticCategoryArticles<? extends AbstractCosmetic>) enumValue).getCosmetic()))
.collect(Collectors.toSet());
}

/**
* @return Cosmetic that player owns
*/
public Set<Cosmetic<? extends AbstractCosmetic>> getOwnedCosmetics()
{
public Set<Cosmetic<? extends AbstractCosmetic>> getOwnedCosmetics() {
return this.ownedCosmetics;
}

/**
* @return Current Nexus Sfx
*/
public Cosmetic<CosmeticTypeNexusSfx> getCurrentNexusSfx()
{
public Cosmetic<CosmeticTypeNexusSfx> getCurrentNexusSfx() {
return this.currentNexusSfx;
}

/**
* @return Current Kill Sfx
*/
public Cosmetic<CosmeticTypeKillSfx> getCurrentKillSfx()
{
public Cosmetic<CosmeticTypeKillSfx> getCurrentKillSfx() {
return this.currentKillSfx;
}

/**
* @return Current Kill Particles
*/
public Cosmetic<CosmeticTypeKillParticles> getCurrentKillParticles()
{
public Cosmetic<CosmeticTypeKillParticles> getCurrentKillParticles() {
return this.currentKillParticles;
}

/**
* @return Current Kill Messages
*/
public Cosmetic<CosmeticTypeKillMessages> getCurrentKillMessages()
{
public Cosmetic<CosmeticTypeKillMessages> getCurrentKillMessages() {
return this.currentKillMessages;
}

/**
* @return Current Hat
*/
public Cosmetic<CosmeticTypeHat> getCurrentHat()
{
public Cosmetic<CosmeticTypeHat> getCurrentHat() {
return this.currentHat;
}

/**
* @return Current Emblem
*/
public Cosmetic<CosmeticTypeEmblem> getCurrentEmblem()
{
public Cosmetic<CosmeticTypeEmblem> getCurrentEmblem() {
return this.currentEmblem;
}

/**
* @return Current Block
*/
public Cosmetic<CosmeticTypeBlock> getCurrentBlock()
{
public Cosmetic<CosmeticTypeBlock> getCurrentBlock() {
return this.currentBlock;
}

/**
* @param currentBlock New Current Block
*/
public void setCurrentBlock(Cosmetic<CosmeticTypeBlock> currentBlock)
{
public void setCurrentBlock(Cosmetic<CosmeticTypeBlock> currentBlock) {
this.currentBlock = currentBlock;
}

/**
* @param currentEmblem New Current Emblem
*/
public void setCurrentEmblem(Cosmetic<CosmeticTypeEmblem> currentEmblem)
{
public void setCurrentEmblem(Cosmetic<CosmeticTypeEmblem> currentEmblem) {
this.currentEmblem = currentEmblem;
}

/**
* @param currentHat New Current Hat
*/
public void setCurrentHat(Cosmetic<CosmeticTypeHat> currentHat)
{
public void setCurrentHat(Cosmetic<CosmeticTypeHat> currentHat) {
this.currentHat = currentHat;
}

/**
* @param currentKillMessages New Current Kill Messages
*/
public void setCurrentKillMessage(Cosmetic<CosmeticTypeKillMessages> currentKillMessages)
{
public void setCurrentKillMessage(Cosmetic<CosmeticTypeKillMessages> currentKillMessages) {
this.currentKillMessages = currentKillMessages;
}

/**
* @param currentKillParticles New Current Kill Particles
*/
public void setCurrentKillParticles(Cosmetic<CosmeticTypeKillParticles> currentKillParticles)
{
public void setCurrentKillParticles(Cosmetic<CosmeticTypeKillParticles> currentKillParticles) {
this.currentKillParticles = currentKillParticles;
}

/**
* @param currentKillSfx New Current Kill Sfx
*/
public void setCurrentKillSfx(Cosmetic<CosmeticTypeKillSfx> currentKillSfx)
{
public void setCurrentKillSfx(Cosmetic<CosmeticTypeKillSfx> currentKillSfx) {
this.currentKillSfx = currentKillSfx;
}

/**
* @param currentNexusSfx New Current Nexus Sfx
*/
public void setCurrentNexusSfx(Cosmetic<CosmeticTypeNexusSfx> currentNexusSfx)
{
public void setCurrentNexusSfx(Cosmetic<CosmeticTypeNexusSfx> currentNexusSfx) {
this.currentNexusSfx = currentNexusSfx;
}

}