Add new kits & recraft nerf
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package club.mcscrims.speedhg.recraft
|
||||
|
||||
import org.bukkit.Material
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
class RecraftMaterial(
|
||||
val maxSoupAmount: Int,
|
||||
val materials: Array<Material>
|
||||
): ConcurrentHashMap<Material, Int>() {
|
||||
|
||||
fun getPoints(): Float
|
||||
{
|
||||
return getOrDefault( getLowestMaterial(), 0 ).toFloat()
|
||||
}
|
||||
|
||||
fun decrease(
|
||||
material: Material,
|
||||
amount: Int,
|
||||
) {
|
||||
put( material, get( material )!! - amount )
|
||||
}
|
||||
|
||||
fun getLowestMaterial(): Material?
|
||||
{
|
||||
if ( size > 1 )
|
||||
{
|
||||
if (values.stream().anyMatch { int -> int == 0 })
|
||||
return null
|
||||
|
||||
val materialIntegerEntry = entries.stream().min(Comparator.comparingInt { it.value })
|
||||
return materialIntegerEntry.map { it.key }.orElse( null )
|
||||
}
|
||||
else return keys.stream().findFirst().orElse( null )
|
||||
}
|
||||
|
||||
fun getMaterialValue() = ( maxSoupAmount / size ).toFloat()
|
||||
|
||||
fun reset()
|
||||
{
|
||||
replaceAll { _, _ -> 0 }
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user