mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-09-24 20:52:55 +02:00
83 lines
1.9 KiB
Java
83 lines
1.9 KiB
Java
package bskyblock.addon.challenges.commands.admin;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
import org.bukkit.Material;
|
|
import org.bukkit.entity.EntityType;
|
|
|
|
import bskyblock.addon.challenges.ChallengesAddon;
|
|
import us.tastybento.bskyblock.api.user.User;
|
|
|
|
/**
|
|
* Enables the state of a Surrounding Challenge to be stored as it is built
|
|
* @author tastybento
|
|
*
|
|
*/
|
|
public class SurroundChallengeBuilder {
|
|
private ChallengesAddon addon;
|
|
private String name;
|
|
private User owner;
|
|
private Map<Material, Integer> reqBlocks = new HashMap<>();
|
|
private Map<EntityType, Integer> reqEntities = new HashMap<>();
|
|
|
|
public SurroundChallengeBuilder(ChallengesAddon addon) {
|
|
this.addon = addon;
|
|
}
|
|
|
|
SurroundChallengeBuilder name(String name) {
|
|
this.name = name;
|
|
return this;
|
|
}
|
|
|
|
SurroundChallengeBuilder owner(User user) {
|
|
this.owner = user;
|
|
return this;
|
|
}
|
|
|
|
SurroundChallengeBuilder addBlock(Material mat) {
|
|
reqBlocks.computeIfPresent(mat, (material, amount) -> amount + 1);
|
|
reqBlocks.putIfAbsent(mat, 1);
|
|
return this;
|
|
}
|
|
|
|
SurroundChallengeBuilder addEntity(EntityType ent) {
|
|
reqEntities.computeIfPresent(ent, (type, amount) -> amount + 1);
|
|
reqEntities.putIfAbsent(ent, 1);
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* @return the name
|
|
*/
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
/**
|
|
* @return the owner
|
|
*/
|
|
public User getOwner() {
|
|
return owner;
|
|
}
|
|
|
|
/**
|
|
* @return the reqBlocks
|
|
*/
|
|
public Map<Material, Integer> getReqBlocks() {
|
|
return reqBlocks;
|
|
}
|
|
|
|
/**
|
|
* @return the reqEntities
|
|
*/
|
|
public Map<EntityType, Integer> getReqEntities() {
|
|
return reqEntities;
|
|
}
|
|
|
|
public boolean build() {
|
|
return addon.getChallengesManager().createSurroundingChallenge(this);
|
|
|
|
}
|
|
|
|
} |